Search in sources :

Example 76 with AlertDialog

use of android.app.AlertDialog in project android_frameworks_base by AOSPA.

the class CreateDirectoryFragment method onCreateDialog.

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    final Context context = getActivity();
    final ContentResolver resolver = context.getContentResolver();
    final AlertDialog.Builder builder = new AlertDialog.Builder(context);
    final LayoutInflater dialogInflater = LayoutInflater.from(builder.getContext());
    final View view = dialogInflater.inflate(R.layout.dialog_file_name, null, false);
    final EditText editText = (EditText) view.findViewById(android.R.id.text1);
    builder.setTitle(R.string.menu_create_dir);
    builder.setView(view);
    builder.setPositiveButton(android.R.string.ok, new OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            createDirectory(editText.getText().toString());
        }
    });
    builder.setNegativeButton(android.R.string.cancel, null);
    final AlertDialog dialog = builder.create();
    // Workaround for the problem - virtual keyboard doesn't show on the phone.
    Shared.ensureKeyboardPresent(context, dialog);
    editText.setOnEditorActionListener(new OnEditorActionListener() {

        @Override
        public boolean onEditorAction(TextView view, int actionId, @Nullable KeyEvent event) {
            if ((actionId == EditorInfo.IME_ACTION_DONE) || (event != null && event.getKeyCode() == KeyEvent.KEYCODE_ENTER && event.hasNoModifiers())) {
                createDirectory(editText.getText().toString());
                dialog.dismiss();
                return true;
            }
            return false;
        }
    });
    return dialog;
}
Also used : Context(android.content.Context) AlertDialog(android.app.AlertDialog) EditText(android.widget.EditText) DialogInterface(android.content.DialogInterface) View(android.view.View) TextView(android.widget.TextView) ContentResolver(android.content.ContentResolver) KeyEvent(android.view.KeyEvent) LayoutInflater(android.view.LayoutInflater) OnClickListener(android.content.DialogInterface.OnClickListener) OnEditorActionListener(android.widget.TextView.OnEditorActionListener) TextView(android.widget.TextView)

Example 77 with AlertDialog

use of android.app.AlertDialog in project xabber-android by redsolution.

the class BaseLoginActivity method loginGithub.

public void loginGithub() {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setMessage(R.string.github_alert).setTitle("GitHub").setPositiveButton(R.string.ok, null);
    AlertDialog dialog = builder.create();
    dialog.show();
}
Also used : AlertDialog(android.app.AlertDialog)

Example 78 with AlertDialog

use of android.app.AlertDialog 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 79 with AlertDialog

use of android.app.AlertDialog in project android_packages_apps_Settings by LineageOS.

the class BluetoothPairingDialogFragment method createUserEntryDialog.

/**
 * Returns a dialog with UI elements that allow a user to provide input.
 */
private AlertDialog createUserEntryDialog() {
    mBuilder.setTitle(getString(R.string.bluetooth_pairing_request, mPairingController.getDeviceName()));
    mBuilder.setView(createPinEntryView());
    mBuilder.setPositiveButton(getString(android.R.string.ok), this);
    mBuilder.setNegativeButton(getString(android.R.string.cancel), this);
    AlertDialog dialog = mBuilder.create();
    dialog.setOnShowListener(d -> {
        if (TextUtils.isEmpty(getPairingViewText())) {
            mDialog.getButton(Dialog.BUTTON_POSITIVE).setEnabled(false);
        }
        if (mPairingView != null && mPairingView.requestFocus()) {
            InputMethodManager imm = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
            if (imm != null) {
                imm.showSoftInput(mPairingView, InputMethodManager.SHOW_IMPLICIT);
            }
        }
    });
    return dialog;
}
Also used : AlertDialog(android.app.AlertDialog) InputMethodManager(android.view.inputmethod.InputMethodManager)

Example 80 with AlertDialog

use of android.app.AlertDialog in project android_packages_apps_Settings by LineageOS.

the class BluetoothPairingDialogFragment method setupDialog.

/**
 * Creates the appropriate type of dialog and returns it.
 */
private AlertDialog setupDialog() {
    AlertDialog dialog;
    switch(mPairingController.getDialogType()) {
        case BluetoothPairingController.USER_ENTRY_DIALOG:
            dialog = createUserEntryDialog();
            break;
        case BluetoothPairingController.CONFIRMATION_DIALOG:
            dialog = createConsentDialog();
            break;
        case BluetoothPairingController.DISPLAY_PASSKEY_DIALOG:
            dialog = createDisplayPasskeyOrPinDialog();
            break;
        default:
            dialog = null;
            Log.e(TAG, "Incorrect pairing type received, not showing any dialog");
    }
    return dialog;
}
Also used : AlertDialog(android.app.AlertDialog)

Aggregations

AlertDialog (android.app.AlertDialog)1029 DialogInterface (android.content.DialogInterface)573 View (android.view.View)278 TextView (android.widget.TextView)213 Intent (android.content.Intent)172 EditText (android.widget.EditText)160 Test (org.junit.Test)148 ShadowAlertDialog (org.robolectric.shadows.ShadowAlertDialog)111 Context (android.content.Context)96 ListView (android.widget.ListView)87 ImageView (android.widget.ImageView)86 LayoutInflater (android.view.LayoutInflater)80 Button (android.widget.Button)78 AdapterView (android.widget.AdapterView)72 Activity (android.app.Activity)66 SuppressLint (android.annotation.SuppressLint)61 Bundle (android.os.Bundle)56 OnClickListener (android.content.DialogInterface.OnClickListener)54 ArrayList (java.util.ArrayList)50 Dialog (android.app.Dialog)46