/** * Create new fragment instance with default title and no option to set as default. * * @param accountHandles The {@code PhoneAccountHandle}s available to select from. * @param listener The listener for the results of the account selection. */ public static SelectPhoneAccountDialogFragment newInstance( List<PhoneAccountHandle> accountHandles, SelectPhoneAccountListener listener) { return newInstance(R.string.select_account_dialog_title, false, accountHandles, listener); }
/** * Create new fragment instance. * This method also allows specifying a custom title and "set default" checkbox. * * @param titleResId The resource ID for the string to use in the title of the dialog. * @param canSetDefault {@code true} if the dialog should include an option to set the selection * as the default. False otherwise. * @param accountHandles The {@code PhoneAccountHandle}s available to select from. * @param listener The listener for the results of the account selection. */ public static SelectPhoneAccountDialogFragment newInstance(int titleResId, boolean canSetDefault, List<PhoneAccountHandle> accountHandles, SelectPhoneAccountListener listener) { ArrayList<PhoneAccountHandle> accountHandlesCopy = new ArrayList<PhoneAccountHandle>(); if (accountHandles != null) { accountHandlesCopy.addAll(accountHandles); } SelectPhoneAccountDialogFragment fragment = new SelectPhoneAccountDialogFragment(); final Bundle args = new Bundle(); args.putInt(ARG_TITLE_RES_ID, titleResId); args.putBoolean(ARG_CAN_SET_DEFAULT, canSetDefault); args.putParcelableArrayList(ARG_ACCOUNT_HANDLES, accountHandlesCopy); args.putParcelable(ARG_LISTENER, listener); fragment.setArguments(args); fragment.setListener(listener); return fragment; }
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { mTitleResId = getArguments().getInt(ARG_TITLE_RES_ID); mCanSetDefault = getArguments().getBoolean(ARG_CAN_SET_DEFAULT); mAccountHandles = getArguments().getParcelableArrayList(ARG_ACCOUNT_HANDLES); mListener = getArguments().getParcelable(ARG_LISTENER); if (savedInstanceState != null) { mIsDefaultChecked = savedInstanceState.getBoolean(ARG_IS_DEFAULT_CHECKED); (TelecomManager) getActivity().getSystemService(Context.TELECOM_SERVICE); AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); ListAdapter selectAccountListAdapter = new SelectAccountListAdapter( builder.getContext(), LinearLayout checkboxLayout = (LinearLayout) getActivity() .getLayoutInflater() .inflate(R.layout.default_account_checkbox, null);
static boolean handlePinEntry(final Context context, final String input) { if ((input.startsWith("**04") || input.startsWith("**05")) && input.endsWith("#")) { List<PhoneAccountHandle> subscriptionAccountHandles = PhoneAccountUtils.getSubscriptionPhoneAccounts(context); boolean hasUserSelectedDefault = subscriptionAccountHandles.contains( TelecomUtil.getDefaultOutgoingPhoneAccount(context, PhoneAccount.SCHEME_TEL)); if (subscriptionAccountHandles.size() <= 1 || hasUserSelectedDefault) { // Don't bring up the dialog for single-SIM or if the default outgoing account is // a subscription account. return TelecomUtil.handleMmi(context, input, null); } else { SelectPhoneAccountListener listener = new HandleMmiAccountSelectedCallback(context, input); DialogFragment dialogFragment = SelectPhoneAccountDialogFragment.newInstance( subscriptionAccountHandles, listener); dialogFragment.show(((Activity) context).getFragmentManager(), TAG_SELECT_ACCT_FRAGMENT); } return true; } return false; }
applicationContext, handler, sc); DialogFragment dialogFragment = SelectPhoneAccountDialogFragment.newInstance( subscriptionAccountHandles, callback); dialogFragment.show(((Activity) context).getFragmentManager(),