Java Code Examples for androidx.appcompat.app.AlertDialog#dismiss()
The following examples show how to use
androidx.appcompat.app.AlertDialog#dismiss() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HostsActivity.java From MHViewer with Apache License 2.0 | 7 votes |
protected void put(AlertDialog dialog) { TextView host = dialog.findViewById(R.id.host); TextView ip = dialog.findViewById(R.id.ip); String hostString = host.getText().toString().trim().toLowerCase(Locale.US); String ipString = ip.getText().toString().trim(); if (!Hosts.isValidHost(hostString)) { TextInputLayout hostInputLayout = dialog.findViewById(R.id.host_input_layout); hostInputLayout.setError(getContext().getString(R.string.invalid_host)); return; } if (!Hosts.isValidIp(ipString)) { TextInputLayout ipInputLayout = dialog.findViewById(R.id.ip_input_layout); ipInputLayout.setError(getContext().getString(R.string.invalid_ip)); return; } HostsActivity activity = (HostsActivity) dialog.getOwnerActivity(); activity.hosts.put(hostString, ipString); activity.notifyHostsChanges(); dialog.dismiss(); }
Example 2
Source File: HostsActivity.java From EhViewer with Apache License 2.0 | 6 votes |
protected void put(AlertDialog dialog) { TextView host = dialog.findViewById(R.id.host); TextView ip = dialog.findViewById(R.id.ip); String hostString = host.getText().toString().trim().toLowerCase(Locale.US); String ipString = ip.getText().toString().trim(); if (!Hosts.isValidHost(hostString)) { TextInputLayout hostInputLayout = dialog.findViewById(R.id.host_input_layout); hostInputLayout.setError(getContext().getString(R.string.invalid_host)); return; } if (!Hosts.isValidIp(ipString)) { TextInputLayout ipInputLayout = dialog.findViewById(R.id.ip_input_layout); ipInputLayout.setError(getContext().getString(R.string.invalid_ip)); return; } HostsActivity activity = (HostsActivity) dialog.getOwnerActivity(); activity.hosts.put(hostString, ipString); activity.notifyHostsChanges(); dialog.dismiss(); }
Example 3
Source File: SignalPinReminderDialog.java From mollyim-android with GNU General Public License v3.0 | 5 votes |
private static PinVerifier.Callback getPinWatcherCallback(@NonNull Context context, @NonNull AlertDialog dialog, @NonNull EditText inputText, @NonNull TextView statusText, @NonNull Callback mainCallback) { return new PinVerifier.Callback() { boolean hadWrongGuess = false; @Override public void onPinCorrect(@NonNull String pin) { Log.i(TAG, "Correct PIN entry."); dialog.dismiss(); mainCallback.onReminderCompleted(pin, hadWrongGuess); } @Override public void onPinWrong() { Log.i(TAG, "Incorrect PIN entry."); hadWrongGuess = true; inputText.getText().clear(); statusText.setText(context.getString(R.string.KbsReminderDialog__incorrect_pin_try_again)); } @Override public boolean hadWrongGuess() { return hadWrongGuess; } }; }
Example 4
Source File: ColorsSetting.java From leafpicrevived with GNU General Public License v3.0 | 5 votes |
public void chooseBaseTheme() { final AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(getActivity(), getActivity().getDialogStyle()); final View dialogLayout = LayoutInflater.from(getActivity()).inflate(R.layout.dialog_base_theme, null); final TextView dialogTitle = dialogLayout.findViewById(R.id.basic_theme_title); final CardView dialogCardView = dialogLayout.findViewById(R.id.basic_theme_card); /** SET OBJ THEME **/ dialogTitle.setBackgroundColor(getActivity().getPrimaryColor()); dialogCardView.setCardBackgroundColor(getActivity().getCardBackgroundColor()); dialogBuilder.setView(dialogLayout); dialogBuilder.setView(dialogLayout); final AlertDialog dialog = dialogBuilder.show(); View.OnClickListener listener = new View.OnClickListener() { @Override public void onClick(View view) { switch (view.getId()) { case R.id.ll_white_basic_theme: getActivity().setBaseTheme(LIGHT); break; case R.id.ll_dark_basic_theme: getActivity().setBaseTheme(DARK); break; case R.id.ll_dark_amoled_basic_theme: getActivity().setBaseTheme(AMOLED); break; } getActivity().updateUiElements(); dialog.dismiss(); } }; ((ThemedIcon) dialogLayout.findViewById(R.id.white_basic_theme_icon)).setColor(getActivity().getIconColor()); ((ThemedIcon) dialogLayout.findViewById(R.id.dark_basic_theme_icon)).setColor(getActivity().getIconColor()); ((ThemedIcon) dialogLayout.findViewById(R.id.dark_amoled_basic_theme_icon)).setColor(getActivity().getIconColor()); dialogLayout.findViewById(R.id.ll_white_basic_theme).setOnClickListener(listener); dialogLayout.findViewById(R.id.ll_dark_basic_theme).setOnClickListener(listener); dialogLayout.findViewById(R.id.ll_dark_amoled_basic_theme).setOnClickListener(listener); }
Example 5
Source File: HostsActivity.java From MHViewer with Apache License 2.0 | 5 votes |
protected void delete(AlertDialog dialog) { TextView host = dialog.findViewById(R.id.host); String hostString = host.getText().toString().trim().toLowerCase(Locale.US); HostsActivity activity = (HostsActivity) dialog.getOwnerActivity(); activity.hosts.delete(hostString); activity.notifyHostsChanges(); dialog.dismiss(); }
Example 6
Source File: EditProfileActivity.java From Aria2App with GNU General Public License v3.0 | 5 votes |
private void addCondition(@NonNull AlertDialog dialog, @NonNull ConnectivityCondition condition) { conditions.add(new ConditionWithState(condition, emptyConditionBundle())); refreshSpinner(); conditionsSpinner.setSelection(conditions.size() - 1); pager.setCurrentItem(0, false); dialog.dismiss(); }
Example 7
Source File: UserOverrideTrustManager.java From revolution-irc with GNU General Public License v3.0 | 5 votes |
@Override public void dismissDialog(Activity activity) { if (mLastDialog != null) { AlertDialog dialog = mLastDialog.get(); if (dialog != null) dialog.dismiss(); mLastDialog = null; } }
Example 8
Source File: CreatePublicChannelDialog.java From Pix-Art-Messenger with GNU General Public License v3.0 | 5 votes |
private void goBack(AlertDialog dialog, CreatePublicChannelDialogBinding binding) { if (nameEntered) { nameEntered = false; updateInputs(binding, true); updateButtons(dialog); } else { dialog.dismiss(); } }
Example 9
Source File: SimpleListFragment.java From hipda with GNU General Public License v2.0 | 5 votes |
@Override public void onSmsPostDone(int status, final String message, AlertDialog dialog) { if (status == Constants.STATUS_SUCCESS) { mSmsPostProgressDialog.dismiss(message); if (dialog != null) dialog.dismiss(); onRefresh(); } else { mSmsPostProgressDialog.dismissError(message); } }
Example 10
Source File: UserinfoFragment.java From hipda with GNU General Public License v2.0 | 5 votes |
@Override public void onSmsPostDone(int status, final String message, AlertDialog dialog) { if (status == Constants.STATUS_SUCCESS) { smsPostProgressDialog.dismiss(message); if (dialog != null) dialog.dismiss(); } else { smsPostProgressDialog.dismissError(message); } }
Example 11
Source File: HostsActivity.java From EhViewer with Apache License 2.0 | 5 votes |
protected void delete(AlertDialog dialog) { TextView host = dialog.findViewById(R.id.host); String hostString = host.getText().toString().trim().toLowerCase(Locale.US); HostsActivity activity = (HostsActivity) dialog.getOwnerActivity(); activity.hosts.delete(hostString); activity.notifyHostsChanges(); dialog.dismiss(); }
Example 12
Source File: SignalPinReminderDialog.java From mollyim-android with GNU General Public License v3.0 | 4 votes |
public static void show(@NonNull Context context, @NonNull Launcher launcher, @NonNull Callback mainCallback) { if (!SignalStore.kbsValues().hasPin()) { throw new AssertionError("Must have a PIN!"); } Log.i(TAG, "Showing PIN reminder dialog."); AlertDialog dialog = new AlertDialog.Builder(context, ThemeUtil.isDarkTheme(context) ? R.style.Theme_Signal_AlertDialog_Dark_Cornered_ColoredAccent : R.style.Theme_Signal_AlertDialog_Light_Cornered_ColoredAccent) .setView(R.layout.kbs_pin_reminder_view) .setCancelable(false) .setOnCancelListener(d -> RegistrationLockReminders.scheduleReminder(context, false)) .create(); WindowManager windowManager = ServiceUtil.getWindowManager(context); Display display = windowManager.getDefaultDisplay(); DisplayMetrics metrics = new DisplayMetrics(); display.getMetrics(metrics); dialog.show(); dialog.getWindow().setLayout((int)(metrics.widthPixels * .80), ViewGroup.LayoutParams.WRAP_CONTENT); EditText pinEditText = (EditText) DialogCompat.requireViewById(dialog, R.id.pin); TextView pinStatus = (TextView) DialogCompat.requireViewById(dialog, R.id.pin_status); TextView reminder = (TextView) DialogCompat.requireViewById(dialog, R.id.reminder); View skip = DialogCompat.requireViewById(dialog, R.id.skip); View submit = DialogCompat.requireViewById(dialog, R.id.submit); SpannableString reminderText = new SpannableString(context.getString(R.string.KbsReminderDialog__to_help_you_memorize_your_pin)); SpannableString forgotText = new SpannableString(context.getString(R.string.KbsReminderDialog__forgot_pin)); pinEditText.post(() -> { if (pinEditText.requestFocus()) { ServiceUtil.getInputMethodManager(pinEditText.getContext()).showSoftInput(pinEditText, 0); } }); ViewCompat.setAutofillHints(pinEditText, HintConstants.AUTOFILL_HINT_PASSWORD); switch (SignalStore.pinValues().getKeyboardType()) { case NUMERIC: pinEditText.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_VARIATION_PASSWORD); break; case ALPHA_NUMERIC: pinEditText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD); break; } ClickableSpan clickableSpan = new ClickableSpan() { @Override public void onClick(@NonNull View widget) { dialog.dismiss(); launcher.launch(CreateKbsPinActivity.getIntentForPinChangeFromForgotPin(context), CreateKbsPinActivity.REQUEST_NEW_PIN); } }; forgotText.setSpan(clickableSpan, 0, forgotText.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); reminder.setText(new SpannableStringBuilder(reminderText).append(" ").append(forgotText)); reminder.setMovementMethod(LinkMovementMethod.getInstance()); PinVerifier.Callback callback = getPinWatcherCallback(context, dialog, pinEditText, pinStatus, mainCallback); PinVerifier verifier = new V2PinVerifier(); skip.setOnClickListener(v -> { dialog.dismiss(); mainCallback.onReminderDismissed(callback.hadWrongGuess()); }); submit.setEnabled(false); submit.setOnClickListener(v -> { Editable pinEditable = pinEditText.getText(); verifier.verifyPin(pinEditable == null ? null : pinEditable.toString(), callback); }); pinEditText.addTextChangedListener(new SimpleTextWatcher() { private final String localHash = Objects.requireNonNull(SignalStore.kbsValues().getLocalPinHash()); @Override public void onTextChanged(String text) { if (text.length() >= KbsConstants.MINIMUM_PIN_LENGTH) { submit.setEnabled(true); if (PinHashing.verifyLocalPinHash(localHash, text)) { dialog.dismiss(); mainCallback.onReminderCompleted(text, callback.hadWrongGuess()); } } else { submit.setEnabled(false); } } }); }
Example 13
Source File: XmppActivity.java From Pix-Art-Messenger with GNU General Public License v3.0 | 4 votes |
@SuppressLint("InflateParams") private void quickEdit(final String previousValue, final OnValueEdited callback, final @StringRes int hint, boolean password, boolean permitEmpty) { final AlertDialog.Builder builder = new AlertDialog.Builder(this); DialogQuickeditBinding binding = DataBindingUtil.inflate(getLayoutInflater(), R.layout.dialog_quickedit, null, false); if (password) { binding.inputEditText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD); } builder.setPositiveButton(R.string.accept, null); if (hint != 0) { binding.inputLayout.setHint(getString(hint)); } binding.inputEditText.requestFocus(); if (previousValue != null) { binding.inputEditText.getText().append(previousValue); } builder.setView(binding.getRoot()); builder.setNegativeButton(R.string.cancel, null); final AlertDialog dialog = builder.create(); dialog.setOnShowListener(d -> SoftKeyboardUtils.showKeyboard(binding.inputEditText)); dialog.show(); View.OnClickListener clickListener = v -> { String value = binding.inputEditText.getText().toString(); if (!value.equals(previousValue) && (!value.trim().isEmpty() || permitEmpty)) { String error = callback.onValueEdited(value); if (error != null) { binding.inputLayout.setError(error); return; } } SoftKeyboardUtils.hideSoftKeyboard(binding.inputEditText); dialog.dismiss(); }; dialog.getButton(DialogInterface.BUTTON_POSITIVE).setOnClickListener(clickListener); dialog.getButton(DialogInterface.BUTTON_NEGATIVE).setOnClickListener((v -> { SoftKeyboardUtils.hideSoftKeyboard(binding.inputEditText); dialog.dismiss(); })); dialog.setCanceledOnTouchOutside(false); dialog.setOnDismissListener(dialog1 -> { SoftKeyboardUtils.hideSoftKeyboard(binding.inputEditText); }); }