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;
}
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();
}
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;
}
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;
}
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;
}
Aggregations