Java Code Examples for androidx.appcompat.app.AlertDialog#setCanceledOnTouchOutside()
The following examples show how to use
androidx.appcompat.app.AlertDialog#setCanceledOnTouchOutside() .
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: CompileDialogFragment.java From EdXposedManager with GNU General Public License v3.0 | 6 votes |
@Override @NonNull public Dialog onCreateDialog(Bundle savedInstanceState) { Bundle arguments = getArguments(); if (arguments == null) { throw new IllegalStateException("arguments should not be null."); } appInfo = arguments.getParcelable(KEY_APP_INFO); if (appInfo == null) { throw new IllegalStateException("appInfo should not be null."); } String msg = arguments.getString(KEY_MSG, getString(R.string.compile_speed_msg)); final PackageManager pm = requireContext().getPackageManager(); AlertDialog.Builder builder = new AlertDialog.Builder(requireContext()) .setIcon(appInfo.loadIcon(pm)) .setTitle(appInfo.loadLabel(pm)) .setCancelable(false); View customView = LayoutInflater.from(requireContext()).inflate(R.layout.fragment_compile_dialog, null); builder.setView(customView); TextView msgView = customView.findViewById(R.id.message); //ProgressBar progressView = customView.findViewById(R.id.progress); msgView.setText(msg); AlertDialog alertDialog = builder.create(); alertDialog.setCanceledOnTouchOutside(false); return alertDialog; }
Example 2
Source File: CrashReportActivity.java From Easy_xkcd with Apache License 2.0 | 6 votes |
@Override protected void init(Bundle savedInstanceState) { super.init(savedInstanceState); ThemePrefs themePrefs = new ThemePrefs(this); setTheme(themePrefs.getNewTheme()); final AlertDialog dialog = new AlertDialog.Builder(this) .setTitle(R.string.crash_dialog_title) .setView(R.layout.crash_report_dialog) .setPositiveButton(R.string.crash_ok, this) .setNegativeButton(R.string.crash_cancel, this) .create(); dialog.setCanceledOnTouchOutside(false); dialog.setOnDismissListener(this); dialog.show(); comment = dialog.findViewById(android.R.id.input); if (savedInstanceState != null) { comment.setText(savedInstanceState.getString(STATE_COMMENT)); } }
Example 3
Source File: ResetPasswordDialogFragment.java From edx-app-android with Apache License 2.0 | 6 votes |
@NonNull @Override public Dialog onCreateDialog(Bundle savedInstanceState) { binding = DataBindingUtil.inflate(getActivity().getLayoutInflater(), R.layout.reset_password_dialog, null, false); binding.emailEditText.setText(getArguments().getString(ARG_LOGIN_EMAIL)); final AlertDialog alertDialog = new AlertDialog.Builder(getContext()) .setTitle(R.string.confirm_dialog_title_help) .setMessage(R.string.confirm_dialog_message_help) .setPositiveButton(android.R.string.ok, null) .setNegativeButton(android.R.string.cancel, null) .setView(binding.getRoot()) .create(); alertDialog.setCanceledOnTouchOutside(false); return alertDialog; }
Example 4
Source File: DialogFragmentAuthenticationInput.java From Android-nRF-Mesh-Library with BSD 3-Clause "New" or "Revised" License | 5 votes |
@NonNull @Override public Dialog onCreateDialog(final Bundle savedInstanceState) { @SuppressLint("InflateParams") final View rootView = LayoutInflater.from(requireActivity()).inflate(R.layout.dialog_fragment_auth_input, null); ButterKnife.bind(this, rootView); AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(requireContext()). setIcon(R.drawable.ic_lock_open_24dp). setTitle(getString(R.string.provisioner_authentication_title)). setView(rootView); updateAuthUI(alertDialogBuilder); final AlertDialog alertDialog = alertDialogBuilder.show(); alertDialog.setCanceledOnTouchOutside(false); alertDialog.setCancelable(false); final Button button = alertDialog.getButton(DialogInterface.BUTTON_POSITIVE); if(button != null) { button.setOnClickListener(v -> { final String pin = pinInput.getEditableText().toString().trim(); if (validateInput(pin)) { ((ProvisionerInputFragmentListener) requireActivity()).onPinInputComplete(pin); dismiss(); } }); } return alertDialog; }
Example 5
Source File: DialogFragmentMessage.java From Android-nRF-Mesh-Library with BSD 3-Clause "New" or "Revised" License | 5 votes |
@NonNull @Override public Dialog onCreateDialog(final Bundle savedInstanceState) { alertDialogBuilder.setTitle(title); alertDialogBuilder.setMessage(message); final AlertDialog alertDialog = alertDialogBuilder.show(); alertDialog.setCancelable(false); alertDialog.setCanceledOnTouchOutside(false); return alertDialog; }
Example 6
Source File: AlertDialogFragment.java From QuickDevFramework with Apache License 2.0 | 5 votes |
@NonNull @Override public Dialog onCreateDialog(Bundle savedInstanceState) { AlertDialog.Builder builder = new AlertDialog.Builder(getContext()); String title = getArguments().getString(KEY_TITLE); String message = getArguments().getString(KEY_MESSAGE); if (!TextUtils.isEmpty(title)) { builder.setTitle(title); } if (iconDrawable != null) { builder.setIcon(iconDrawable); } builder.setMessage(message); if (positiveListener != null) { builder.setPositiveButton(positiveBtnText, positiveListener); } if (negativeListener != null) { builder.setNegativeButton(negativeBtnText, negativeListener); } if (dismissListener != null) { builder.setOnDismissListener(dismissListener); } if (keyListener != null) { builder.setOnKeyListener(keyListener); } AlertDialog dialog = builder.create(); dialog.setCanceledOnTouchOutside(false); dialog.setCancelable(cancelable); return dialog; }
Example 7
Source File: LoginActivity.java From mage-android with Apache License 2.0 | 5 votes |
private void showSessionExpiredDialog() { AlertDialog dialog = new AlertDialog.Builder(this) .setTitle("Session Expired") .setCancelable(false) .setMessage("We apologize, but it looks like your MAGE session has expired. Please login and we will take you back to what you were doing.") .setPositiveButton(android.R.string.ok, null).create(); dialog.setCanceledOnTouchOutside(false); dialog.show(); }
Example 8
Source File: AlertDialogFragment.java From edx-app-android with Apache License 2.0 | 5 votes |
@NonNull @Override public Dialog onCreateDialog(Bundle savedInstanceState) { final Bundle args = getArguments(); final int titleResId = args.getInt(ARG_TITLE_RES); final int messageResId = args.getInt(ARG_MESSAGE_RES); final CharSequence title = titleResId != 0 ? getText(titleResId) : args.getString(ARG_TITLE); final CharSequence message = messageResId != 0 ? getText(messageResId) : args.getString(ARG_MESSAGE); final AlertDialog alertDialog = new AlertDialog.Builder(getContext()) .setMessage(message) .create(); alertDialog.setCanceledOnTouchOutside(false); if (title != null) { alertDialog.setTitle(title); } if (positiveButtonAttr != null) { alertDialog.setButton(DialogInterface.BUTTON_POSITIVE, positiveButtonAttr.getText(), positiveButtonAttr.getOnClickListener()); } if (negativeButtonAttr != null) { alertDialog.setButton(DialogInterface.BUTTON_NEGATIVE, negativeButtonAttr.getText(), negativeButtonAttr.getOnClickListener()); } return alertDialog; }
Example 9
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); }); }