Search in sources :

Example 6 with OnCancelListener

use of android.content.DialogInterface.OnCancelListener in project XobotOS by xamarin.

the class WebView method onSavePassword.

/* package */
boolean onSavePassword(String schemePlusHost, String username, String password, final Message resumeMsg) {
    boolean rVal = false;
    if (resumeMsg == null) {
        // null resumeMsg implies saving password silently
        mDatabase.setUsernamePassword(schemePlusHost, username, password);
    } else {
        final Message remember = mPrivateHandler.obtainMessage(REMEMBER_PASSWORD);
        remember.getData().putString("host", schemePlusHost);
        remember.getData().putString("username", username);
        remember.getData().putString("password", password);
        remember.obj = resumeMsg;
        final Message neverRemember = mPrivateHandler.obtainMessage(NEVER_REMEMBER_PASSWORD);
        neverRemember.getData().putString("host", schemePlusHost);
        neverRemember.getData().putString("username", username);
        neverRemember.getData().putString("password", password);
        neverRemember.obj = resumeMsg;
        new AlertDialog.Builder(getContext()).setTitle(com.android.internal.R.string.save_password_label).setMessage(com.android.internal.R.string.save_password_message).setPositiveButton(com.android.internal.R.string.save_password_notnow, new DialogInterface.OnClickListener() {

            public void onClick(DialogInterface dialog, int which) {
                resumeMsg.sendToTarget();
            }
        }).setNeutralButton(com.android.internal.R.string.save_password_remember, new DialogInterface.OnClickListener() {

            public void onClick(DialogInterface dialog, int which) {
                remember.sendToTarget();
            }
        }).setNegativeButton(com.android.internal.R.string.save_password_never, new DialogInterface.OnClickListener() {

            public void onClick(DialogInterface dialog, int which) {
                neverRemember.sendToTarget();
            }
        }).setOnCancelListener(new OnCancelListener() {

            public void onCancel(DialogInterface dialog) {
                resumeMsg.sendToTarget();
            }
        }).show();
        // Return true so that WebViewCore will pause while the dialog is
        // up.
        rVal = true;
    }
    return rVal;
}
Also used : AlertDialog(android.app.AlertDialog) Message(android.os.Message) DialogInterface(android.content.DialogInterface) Paint(android.graphics.Paint) Point(android.graphics.Point) OnCancelListener(android.content.DialogInterface.OnCancelListener)

Example 7 with OnCancelListener

use of android.content.DialogInterface.OnCancelListener in project collect by opendatakit.

the class AndroidShortcuts method buildMenuList.

/**
 * Builds a list of shortcuts
 */
private void buildMenuList() {
    ArrayList<String> names = new ArrayList<String>();
    ArrayList<Uri> commands = new ArrayList<Uri>();
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle(R.string.select_odk_shortcut);
    Cursor c = null;
    try {
        c = new FormsDao().getFormsCursor();
        if (c.getCount() > 0) {
            c.moveToPosition(-1);
            while (c.moveToNext()) {
                String formName = c.getString(c.getColumnIndex(FormsColumns.DISPLAY_NAME));
                names.add(formName);
                Uri uri = Uri.withAppendedPath(FormsColumns.CONTENT_URI, c.getString(c.getColumnIndex(FormsColumns._ID)));
                commands.add(uri);
            }
        }
    } finally {
        if (c != null) {
            c.close();
        }
    }
    this.names = names.toArray(new String[0]);
    this.commands = commands.toArray(new Uri[0]);
    builder.setItems(this.names, new DialogInterface.OnClickListener() {

        public void onClick(DialogInterface dialog, int item) {
            returnShortcut(AndroidShortcuts.this.names[item], AndroidShortcuts.this.commands[item]);
        }
    });
    builder.setOnCancelListener(new OnCancelListener() {

        public void onCancel(DialogInterface dialog) {
            AndroidShortcuts sc = AndroidShortcuts.this;
            sc.setResult(RESULT_CANCELED);
            sc.finish();
        }
    });
    AlertDialog alert = builder.create();
    alert.show();
}
Also used : AlertDialog(android.app.AlertDialog) FormsDao(org.odk.collect.android.dao.FormsDao) DialogInterface(android.content.DialogInterface) ArrayList(java.util.ArrayList) Cursor(android.database.Cursor) Uri(android.net.Uri) OnCancelListener(android.content.DialogInterface.OnCancelListener)

Example 8 with OnCancelListener

use of android.content.DialogInterface.OnCancelListener in project android_frameworks_base by AOSPA.

the class InputMethodManagerService method showInputMethodMenu.

private void showInputMethodMenu(boolean showAuxSubtypes) {
    if (DEBUG)
        Slog.v(TAG, "Show switching menu. showAuxSubtypes=" + showAuxSubtypes);
    final Context context = mContext;
    final boolean isScreenLocked = isScreenLocked();
    final String lastInputMethodId = mSettings.getSelectedInputMethod();
    int lastInputMethodSubtypeId = mSettings.getSelectedInputMethodSubtypeId(lastInputMethodId);
    if (DEBUG)
        Slog.v(TAG, "Current IME: " + lastInputMethodId);
    synchronized (mMethodMap) {
        final HashMap<InputMethodInfo, List<InputMethodSubtype>> immis = mSettings.getExplicitlyOrImplicitlyEnabledInputMethodsAndSubtypeListLocked(mContext);
        if (immis == null || immis.size() == 0) {
            return;
        }
        hideInputMethodMenuLocked();
        final List<ImeSubtypeListItem> imList = mSwitchingController.getSortedInputMethodAndSubtypeListLocked(showAuxSubtypes, isScreenLocked);
        if (lastInputMethodSubtypeId == NOT_A_SUBTYPE_ID) {
            final InputMethodSubtype currentSubtype = getCurrentInputMethodSubtypeLocked();
            if (currentSubtype != null) {
                final InputMethodInfo currentImi = mMethodMap.get(mCurMethodId);
                lastInputMethodSubtypeId = InputMethodUtils.getSubtypeIdFromHashCode(currentImi, currentSubtype.hashCode());
            }
        }
        final int N = imList.size();
        mIms = new InputMethodInfo[N];
        mSubtypeIds = new int[N];
        int checkedItem = 0;
        for (int i = 0; i < N; ++i) {
            final ImeSubtypeListItem item = imList.get(i);
            mIms[i] = item.mImi;
            mSubtypeIds[i] = item.mSubtypeId;
            if (mIms[i].getId().equals(lastInputMethodId)) {
                int subtypeId = mSubtypeIds[i];
                if ((subtypeId == NOT_A_SUBTYPE_ID) || (lastInputMethodSubtypeId == NOT_A_SUBTYPE_ID && subtypeId == 0) || (subtypeId == lastInputMethodSubtypeId)) {
                    checkedItem = i;
                }
            }
        }
        final Context settingsContext = new ContextThemeWrapper(context, com.android.internal.R.style.Theme_DeviceDefault_Settings);
        mDialogBuilder = new AlertDialog.Builder(settingsContext);
        mDialogBuilder.setOnCancelListener(new OnCancelListener() {

            @Override
            public void onCancel(DialogInterface dialog) {
                hideInputMethodMenu();
            }
        });
        final Context dialogContext = mDialogBuilder.getContext();
        final TypedArray a = dialogContext.obtainStyledAttributes(null, com.android.internal.R.styleable.DialogPreference, com.android.internal.R.attr.alertDialogStyle, 0);
        final Drawable dialogIcon = a.getDrawable(com.android.internal.R.styleable.DialogPreference_dialogIcon);
        a.recycle();
        mDialogBuilder.setIcon(dialogIcon);
        final LayoutInflater inflater = dialogContext.getSystemService(LayoutInflater.class);
        final View tv = inflater.inflate(com.android.internal.R.layout.input_method_switch_dialog_title, null);
        mDialogBuilder.setCustomTitle(tv);
        // Setup layout for a toggle switch of the hardware keyboard
        mSwitchingDialogTitleView = tv;
        mSwitchingDialogTitleView.findViewById(com.android.internal.R.id.hard_keyboard_section).setVisibility(mWindowManagerInternal.isHardKeyboardAvailable() ? View.VISIBLE : View.GONE);
        final Switch hardKeySwitch = (Switch) mSwitchingDialogTitleView.findViewById(com.android.internal.R.id.hard_keyboard_switch);
        hardKeySwitch.setChecked(mShowImeWithHardKeyboard);
        hardKeySwitch.setOnCheckedChangeListener(new OnCheckedChangeListener() {

            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                mSettings.setShowImeWithHardKeyboard(isChecked);
                // Ensure that the input method dialog is dismissed when changing
                // the hardware keyboard state.
                hideInputMethodMenu();
            }
        });
        final ImeSubtypeListAdapter adapter = new ImeSubtypeListAdapter(dialogContext, com.android.internal.R.layout.input_method_switch_item, imList, checkedItem);
        final OnClickListener choiceListener = new OnClickListener() {

            @Override
            public void onClick(final DialogInterface dialog, final int which) {
                synchronized (mMethodMap) {
                    if (mIms == null || mIms.length <= which || mSubtypeIds == null || mSubtypeIds.length <= which) {
                        return;
                    }
                    final InputMethodInfo im = mIms[which];
                    int subtypeId = mSubtypeIds[which];
                    adapter.mCheckedItem = which;
                    adapter.notifyDataSetChanged();
                    hideInputMethodMenu();
                    if (im != null) {
                        if (subtypeId < 0 || subtypeId >= im.getSubtypeCount()) {
                            subtypeId = NOT_A_SUBTYPE_ID;
                        }
                        setInputMethodLocked(im.getId(), subtypeId);
                    }
                }
            }
        };
        mDialogBuilder.setSingleChoiceItems(adapter, checkedItem, choiceListener);
        mSwitchingDialog = mDialogBuilder.create();
        mSwitchingDialog.setCanceledOnTouchOutside(true);
        mSwitchingDialog.getWindow().setType(WindowManager.LayoutParams.TYPE_INPUT_METHOD_DIALOG);
        mSwitchingDialog.getWindow().getAttributes().privateFlags |= WindowManager.LayoutParams.PRIVATE_FLAG_SHOW_FOR_ALL_USERS;
        mSwitchingDialog.getWindow().getAttributes().setTitle("Select input method");
        updateSystemUi(mCurToken, mImeWindowVis, mBackDisposition);
        mSwitchingDialog.show();
    }
}
Also used : AlertDialog(android.app.AlertDialog) DialogInterface(android.content.DialogInterface) InputMethodInfo(android.view.inputmethod.InputMethodInfo) TypedArray(android.content.res.TypedArray) ArrayList(java.util.ArrayList) List(java.util.List) LocaleList(android.os.LocaleList) OnCancelListener(android.content.DialogInterface.OnCancelListener) IInputContext(com.android.internal.view.IInputContext) Context(android.content.Context) InputMethodSubtype(android.view.inputmethod.InputMethodSubtype) OnCheckedChangeListener(android.widget.CompoundButton.OnCheckedChangeListener) Drawable(android.graphics.drawable.Drawable) View(android.view.View) TextView(android.widget.TextView) ImeSubtypeListItem(com.android.internal.inputmethod.InputMethodSubtypeSwitchingController.ImeSubtypeListItem) ContextThemeWrapper(android.view.ContextThemeWrapper) Switch(android.widget.Switch) LayoutInflater(android.view.LayoutInflater) OnClickListener(android.content.DialogInterface.OnClickListener) CompoundButton(android.widget.CompoundButton)

Example 9 with OnCancelListener

use of android.content.DialogInterface.OnCancelListener in project bitcoin-wallet by bitcoin-wallet.

the class RestoreWalletFromExternalDialogFragment method onCreateDialog.

@Override
public Dialog onCreateDialog(final Bundle savedInstanceState) {
    final View view = LayoutInflater.from(activity).inflate(R.layout.restore_wallet_from_external_dialog, null);
    passwordView = (EditText) view.findViewById(R.id.import_keys_from_content_dialog_password);
    showView = (CheckBox) view.findViewById(R.id.import_keys_from_content_dialog_show);
    replaceWarningView = view.findViewById(R.id.restore_wallet_from_content_dialog_replace_warning);
    final DialogBuilder builder = new DialogBuilder(activity);
    builder.setTitle(R.string.import_keys_dialog_title);
    builder.setView(view);
    builder.setPositiveButton(R.string.import_keys_dialog_button_import, new OnClickListener() {

        @Override
        public void onClick(final DialogInterface dialog, final int which) {
            final String password = passwordView.getText().toString().trim();
            // get rid of it asap
            passwordView.setText(null);
            handleRestore(password);
        }
    });
    builder.setNegativeButton(R.string.button_cancel, new OnClickListener() {

        @Override
        public void onClick(final DialogInterface dialog, final int which) {
            // get rid of it asap
            passwordView.setText(null);
            activity.finish();
        }
    });
    builder.setOnCancelListener(new OnCancelListener() {

        @Override
        public void onCancel(final DialogInterface dialog) {
            // get rid of it asap
            passwordView.setText(null);
            activity.finish();
        }
    });
    final AlertDialog dialog = builder.create();
    dialog.setOnShowListener(new OnShowListener() {

        @Override
        public void onShow(final DialogInterface d) {
            final ImportDialogButtonEnablerListener dialogButtonEnabler = new ImportDialogButtonEnablerListener(passwordView, dialog) {

                @Override
                protected boolean hasFile() {
                    return true;
                }
            };
            passwordView.addTextChangedListener(dialogButtonEnabler);
            RestoreWalletFromExternalDialogFragment.this.dialog = dialog;
            updateView();
        }
    });
    return dialog;
}
Also used : AlertDialog(android.app.AlertDialog) DialogInterface(android.content.DialogInterface) OnClickListener(android.content.DialogInterface.OnClickListener) DialogBuilder(de.schildbach.wallet.ui.DialogBuilder) View(android.view.View) OnShowListener(android.content.DialogInterface.OnShowListener) OnCancelListener(android.content.DialogInterface.OnCancelListener)

Example 10 with OnCancelListener

use of android.content.DialogInterface.OnCancelListener in project AndroidChromium by JackyAndroid.

the class ExternalNavigationDelegateImpl method startIncognitoIntent.

@Override
public void startIncognitoIntent(final Intent intent, final String referrerUrl, final String fallbackUrl, final Tab tab, final boolean needsToCloseTab, final boolean proxy) {
    Context context = tab.getWindowAndroid().getContext().get();
    if (!(context instanceof Activity))
        return;
    Activity activity = (Activity) context;
    new AlertDialog.Builder(activity, R.style.AlertDialogTheme).setTitle(R.string.external_app_leave_incognito_warning_title).setMessage(R.string.external_app_leave_incognito_warning).setPositiveButton(R.string.ok, new OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            startActivity(intent, proxy);
            if (tab != null && !tab.isClosing() && tab.isInitialized() && needsToCloseTab) {
                closeTab(tab);
            }
        }
    }).setNegativeButton(R.string.cancel, new OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            loadIntent(intent, referrerUrl, fallbackUrl, tab, needsToCloseTab, true);
        }
    }).setOnCancelListener(new OnCancelListener() {

        @Override
        public void onCancel(DialogInterface dialog) {
            loadIntent(intent, referrerUrl, fallbackUrl, tab, needsToCloseTab, true);
        }
    }).show();
}
Also used : Context(android.content.Context) DialogInterface(android.content.DialogInterface) ChromeActivity(org.chromium.chrome.browser.ChromeActivity) WebappActivity(org.chromium.chrome.browser.webapps.WebappActivity) ChromeLauncherActivity(org.chromium.chrome.browser.document.ChromeLauncherActivity) AuthenticatedProxyActivity(org.chromium.chrome.browser.instantapps.AuthenticatedProxyActivity) Activity(android.app.Activity) OnClickListener(android.content.DialogInterface.OnClickListener) OnCancelListener(android.content.DialogInterface.OnCancelListener)

Aggregations

OnCancelListener (android.content.DialogInterface.OnCancelListener)58 DialogInterface (android.content.DialogInterface)54 AlertDialog (android.app.AlertDialog)23 OnClickListener (android.content.DialogInterface.OnClickListener)18 View (android.view.View)13 Context (android.content.Context)12 ProgressDialog (android.app.ProgressDialog)11 TextView (android.widget.TextView)11 Intent (android.content.Intent)10 OnDismissListener (android.content.DialogInterface.OnDismissListener)7 Dialog (android.app.Dialog)6 SharedPreferences (android.content.SharedPreferences)6 TypedArray (android.content.res.TypedArray)6 ArrayList (java.util.ArrayList)6 Drawable (android.graphics.drawable.Drawable)5 LocaleList (android.os.LocaleList)5 LayoutInflater (android.view.LayoutInflater)5 InputMethodInfo (android.view.inputmethod.InputMethodInfo)5 InputMethodSubtype (android.view.inputmethod.InputMethodSubtype)5 CompoundButton (android.widget.CompoundButton)5