Search in sources :

Example 1 with SelectPhoneAccountListener

use of com.android.contacts.common.widget.SelectPhoneAccountDialogFragment.SelectPhoneAccountListener in project android_packages_apps_Dialer by MoKee.

the class SpecialCharSequenceMgr method handlePinEntry.

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) {
            // 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;
}
Also used : PhoneAccountHandle(android.telecom.PhoneAccountHandle) DialogFragment(android.app.DialogFragment) SelectPhoneAccountDialogFragment(com.android.contacts.common.widget.SelectPhoneAccountDialogFragment) SelectPhoneAccountListener(com.android.contacts.common.widget.SelectPhoneAccountDialogFragment.SelectPhoneAccountListener)

Example 2 with SelectPhoneAccountListener

use of com.android.contacts.common.widget.SelectPhoneAccountDialogFragment.SelectPhoneAccountListener in project android_packages_apps_Dialer by LineageOS.

the class SpecialCharSequenceMgr method handlePinEntry.

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) {
            // a subscription account.
            return TelecomUtil.handleMmi(context, input, null);
        } else {
            SelectPhoneAccountListener listener = new HandleMmiAccountSelectedCallback(context, input);
            DialogFragment dialogFragment = SelectPhoneAccountDialogFragment.newInstance(subscriptionAccountHandles, listener, null);
            dialogFragment.show(((Activity) context).getFragmentManager(), TAG_SELECT_ACCT_FRAGMENT);
        }
        return true;
    }
    return false;
}
Also used : PhoneAccountHandle(android.telecom.PhoneAccountHandle) DialogFragment(android.app.DialogFragment) SelectPhoneAccountDialogFragment(com.android.contacts.common.widget.SelectPhoneAccountDialogFragment) SelectPhoneAccountListener(com.android.contacts.common.widget.SelectPhoneAccountDialogFragment.SelectPhoneAccountListener)

Example 3 with SelectPhoneAccountListener

use of com.android.contacts.common.widget.SelectPhoneAccountDialogFragment.SelectPhoneAccountListener in project android_packages_apps_Dialer by LineageOS.

the class SpecialCharSequenceMgr method handleAdnEntry.

/**
 * Handle ADN requests by filling in the SIM contact number into the requested EditText.
 *
 * <p>This code works alongside the Asynchronous query handler {@link QueryHandler} and query
 * cancel handler implemented in {@link SimContactQueryCookie}.
 */
static boolean handleAdnEntry(Context context, String input, EditText textField) {
    /* ADN entries are of the form "N(N)(N)#" */
    TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    if (telephonyManager == null || telephonyManager.getPhoneType() != TelephonyManager.PHONE_TYPE_GSM) {
        return false;
    }
    // if the phone is keyguard-restricted, then just ignore this
    // input.  We want to make sure that sim card contacts are NOT
    // exposed unless the phone is unlocked, and this code can be
    // accessed from the emergency dialer.
    KeyguardManager keyguardManager = (KeyguardManager) context.getSystemService(Context.KEYGUARD_SERVICE);
    if (keyguardManager.inKeyguardRestrictedInputMode()) {
        return false;
    }
    int len = input.length();
    if ((len > 1) && (len < 5) && (input.endsWith("#"))) {
        try {
            // get the ordinal number of the sim contact
            final int index = Integer.parseInt(input.substring(0, len - 1));
            // The original code that navigated to a SIM Contacts list view did not
            // highlight the requested contact correctly, a requirement for PTCRB
            // certification.  This behaviour is consistent with the UI paradigm
            // for touch-enabled lists, so it does not make sense to try to work
            // around it.  Instead we fill in the the requested phone number into
            // the dialer text field.
            // create the async query handler
            final QueryHandler handler = new QueryHandler(context.getContentResolver());
            // create the cookie object
            final SimContactQueryCookie sc = new SimContactQueryCookie(index - 1, handler, ADN_QUERY_TOKEN);
            // setup the cookie fields
            sc.contactNum = index - 1;
            sc.setTextField(textField);
            // create the progress dialog
            sc.progressDialog = new ProgressDialog(context);
            sc.progressDialog.setTitle(R.string.simContacts_title);
            sc.progressDialog.setMessage(context.getText(R.string.simContacts_emptyLoading));
            sc.progressDialog.setIndeterminate(true);
            sc.progressDialog.setCancelable(true);
            sc.progressDialog.setOnCancelListener(sc);
            sc.progressDialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND);
            List<PhoneAccountHandle> subscriptionAccountHandles = PhoneAccountUtils.getSubscriptionPhoneAccounts(context);
            Context applicationContext = context.getApplicationContext();
            boolean hasUserSelectedDefault = subscriptionAccountHandles.contains(TelecomUtil.getDefaultOutgoingPhoneAccount(applicationContext, PhoneAccount.SCHEME_TEL));
            if (subscriptionAccountHandles.size() <= 1 || hasUserSelectedDefault) {
                Uri uri = TelecomUtil.getAdnUriForPhoneAccount(applicationContext, null);
                handleAdnQuery(handler, sc, uri);
            } else {
                SelectPhoneAccountListener callback = new HandleAdnEntryAccountSelectedCallback(applicationContext, handler, sc);
                DialogFragment dialogFragment = SelectPhoneAccountDialogFragment.newInstance(subscriptionAccountHandles, callback, null);
                dialogFragment.show(((Activity) context).getFragmentManager(), TAG_SELECT_ACCT_FRAGMENT);
            }
            return true;
        } catch (NumberFormatException ex) {
        // Ignore
        }
    }
    return false;
}
Also used : Context(android.content.Context) NoNullCursorAsyncQueryHandler(com.android.contacts.common.database.NoNullCursorAsyncQueryHandler) PhoneAccountHandle(android.telecom.PhoneAccountHandle) DialogFragment(android.app.DialogFragment) SelectPhoneAccountDialogFragment(com.android.contacts.common.widget.SelectPhoneAccountDialogFragment) ProgressDialog(android.app.ProgressDialog) Uri(android.net.Uri) TelephonyManager(android.telephony.TelephonyManager) SelectPhoneAccountListener(com.android.contacts.common.widget.SelectPhoneAccountDialogFragment.SelectPhoneAccountListener) KeyguardManager(android.app.KeyguardManager)

Example 4 with SelectPhoneAccountListener

use of com.android.contacts.common.widget.SelectPhoneAccountDialogFragment.SelectPhoneAccountListener in project android_packages_apps_Dialer by MoKee.

the class SpecialCharSequenceMgr method handleAdnEntry.

/**
 * Handle ADN requests by filling in the SIM contact number into the requested
 * EditText.
 *
 * This code works alongside the Asynchronous query handler {@link QueryHandler}
 * and query cancel handler implemented in {@link SimContactQueryCookie}.
 */
static boolean handleAdnEntry(Context context, String input, EditText textField) {
    /* ADN entries are of the form "N(N)(N)#" */
    TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    if (telephonyManager == null || telephonyManager.getPhoneType() != TelephonyManager.PHONE_TYPE_GSM) {
        return false;
    }
    // if the phone is keyguard-restricted, then just ignore this
    // input.  We want to make sure that sim card contacts are NOT
    // exposed unless the phone is unlocked, and this code can be
    // accessed from the emergency dialer.
    KeyguardManager keyguardManager = (KeyguardManager) context.getSystemService(Context.KEYGUARD_SERVICE);
    if (keyguardManager.inKeyguardRestrictedInputMode()) {
        return false;
    }
    int len = input.length();
    if ((len > 1) && (len < 5) && (input.endsWith("#"))) {
        try {
            // get the ordinal number of the sim contact
            final int index = Integer.parseInt(input.substring(0, len - 1));
            // The original code that navigated to a SIM Contacts list view did not
            // highlight the requested contact correctly, a requirement for PTCRB
            // certification.  This behaviour is consistent with the UI paradigm
            // for touch-enabled lists, so it does not make sense to try to work
            // around it.  Instead we fill in the the requested phone number into
            // the dialer text field.
            // create the async query handler
            final QueryHandler handler = new QueryHandler(context.getContentResolver());
            // create the cookie object
            final SimContactQueryCookie sc = new SimContactQueryCookie(index - 1, handler, ADN_QUERY_TOKEN);
            // setup the cookie fields
            sc.contactNum = index - 1;
            sc.setTextField(textField);
            // create the progress dialog
            sc.progressDialog = new ProgressDialog(context);
            sc.progressDialog.setTitle(R.string.simContacts_title);
            sc.progressDialog.setMessage(context.getText(R.string.simContacts_emptyLoading));
            sc.progressDialog.setIndeterminate(true);
            sc.progressDialog.setCancelable(true);
            sc.progressDialog.setOnCancelListener(sc);
            sc.progressDialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND);
            List<PhoneAccountHandle> subscriptionAccountHandles = PhoneAccountUtils.getSubscriptionPhoneAccounts(context);
            Context applicationContext = context.getApplicationContext();
            boolean hasUserSelectedDefault = subscriptionAccountHandles.contains(TelecomUtil.getDefaultOutgoingPhoneAccount(applicationContext, PhoneAccount.SCHEME_TEL));
            if (subscriptionAccountHandles.size() <= 1 || hasUserSelectedDefault) {
                Uri uri = TelecomUtil.getAdnUriForPhoneAccount(applicationContext, null);
                handleAdnQuery(handler, sc, uri);
            } else {
                SelectPhoneAccountListener callback = new HandleAdnEntryAccountSelectedCallback(applicationContext, handler, sc);
                DialogFragment dialogFragment = SelectPhoneAccountDialogFragment.newInstance(subscriptionAccountHandles, callback);
                dialogFragment.show(((Activity) context).getFragmentManager(), TAG_SELECT_ACCT_FRAGMENT);
            }
            return true;
        } catch (NumberFormatException ex) {
        // Ignore
        }
    }
    return false;
}
Also used : Context(android.content.Context) NoNullCursorAsyncQueryHandler(com.android.contacts.common.database.NoNullCursorAsyncQueryHandler) PhoneAccountHandle(android.telecom.PhoneAccountHandle) DialogFragment(android.app.DialogFragment) SelectPhoneAccountDialogFragment(com.android.contacts.common.widget.SelectPhoneAccountDialogFragment) ProgressDialog(android.app.ProgressDialog) Uri(android.net.Uri) TelephonyManager(android.telephony.TelephonyManager) SelectPhoneAccountListener(com.android.contacts.common.widget.SelectPhoneAccountDialogFragment.SelectPhoneAccountListener) KeyguardManager(android.app.KeyguardManager)

Aggregations

DialogFragment (android.app.DialogFragment)4 PhoneAccountHandle (android.telecom.PhoneAccountHandle)4 SelectPhoneAccountDialogFragment (com.android.contacts.common.widget.SelectPhoneAccountDialogFragment)4 SelectPhoneAccountListener (com.android.contacts.common.widget.SelectPhoneAccountDialogFragment.SelectPhoneAccountListener)4 KeyguardManager (android.app.KeyguardManager)2 ProgressDialog (android.app.ProgressDialog)2 Context (android.content.Context)2 Uri (android.net.Uri)2 TelephonyManager (android.telephony.TelephonyManager)2 NoNullCursorAsyncQueryHandler (com.android.contacts.common.database.NoNullCursorAsyncQueryHandler)2