new AlertDialog.Builder(this) .setMessage(R.string.confirmation_cancel_prev_download_title) .setPositiveButton(android.R.string.ok, (dialog, which) -> downloadAreaConfirmed(enclosingBBox)) .setNegativeButton(android.R.string.cancel, null) .show();
@Override public void onClick() { AlertDialog.Builder alertBuilder = new AlertDialog.Builder(c); alertBuilder.setTitle(dialogTitle); final WebView wv = new WebView(c); wv.getSettings().setSupportZoom(supportZoom); if (!supportZoom) { wv.getSettings().setLoadWithOverviewMode(true); wv.getSettings().setUseWideViewPort(true); } if (isStringUrl) { wv.loadUrl(htmlString); } else { wv.loadData(htmlString, "text/html; charset=utf-8", "UTF-8"); } alertBuilder.setView(wv); alertBuilder.setNegativeButton(dialogNegativeButton, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { wv.destroy(); dialog.dismiss(); } }); final AlertDialog dialog = alertBuilder.create(); dialog.show(); } };
private void askUserToSendErrorReport(final Activity activityCtx, final int titleResourceId, String error) { final String report = "Describe how to reproduce it here:\n\n\n\n" + getDeviceInformationString() + "\n" + error; new Handler(Looper.getMainLooper()).post(() -> { new AlertDialog.Builder(activityCtx) .setTitle(titleResourceId) .setMessage(R.string.crash_message) .setPositiveButton(R.string.crash_compose_email, (dialog, which) -> sendEmail(activityCtx, report)) .setNegativeButton(android.R.string.no, (dialog, which) -> Toast.makeText(activityCtx, "\uD83D\uDE22",Toast.LENGTH_SHORT).show()) .setCancelable(false) .show(); }); }
final AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setCancelable(true); builder.setTitle(getResources().getString(R.string.lang)); builder.setItems( lang, new DialogInterface.OnClickListener() { builder.show(); return true;
final View promptsView = inflater.inflate(R.layout.custon_commands_dialog, null); AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(getActivity()); alertDialogBuilder.setView(promptsView); alertDialogBuilder.setCancelable(false); alertDialogBuilder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) {
AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage(R.string.crypto_dlg_message); builder.setCancelable(false); mDLoading = builder.create(); mDLoading.setCanceledOnTouchOutside(false);
/** * Display an obtrusive error dialog because on the provided {@link Throwable}. * @param throwable The {@link Throwable} that occurred */ private void displayErrorDialog(Throwable throwable) { int messageResId; if (throwable instanceof InactiveTokenException) { messageResId = R.string.error_access_token_inactive; } else if (throwable instanceof InvalidTokenException) { messageResId = R.string.error_invalid_access_token; } else if (throwable instanceof UnknownErrorException) { messageResId = R.string.error_unknown; } else if (throwable instanceof TokenLimitReachedException) { messageResId = R.string.error_access_token_limit_reached; } else if (throwable instanceof RequestLimitReachedException) { messageResId = R.string.error_request_limit_reached; } else { messageResId = R.string.error_access_token_could_not_be_generated; } AlertDialog dialog = new AlertDialog.Builder(this) .setMessage(messageResId) .setPositiveButton(R.string.ok, null) .setCancelable(true) .create(); if (dialog.getWindow() != null) { dialog.getWindow().setBackgroundDrawableResource(R.drawable.rounded_corners_background); } dialog.show(); }
@Override public void showDialog(Activity activity) { dismissDialog(null); AlertDialog.Builder builder = new AlertDialog.Builder(activity); builder.setTitle(activity.getString(R.string.certificate_error, getServerName())); LayoutInflater inflater = activity.getLayoutInflater(); View view = inflater.inflate(R.layout.bad_certificate_layout, null, false); ((TextView) view.findViewById(R.id.error_certificate)).setText(ServerCertificateManager.buildCertOverviewString(mCertificate)); ((TextView) view.findViewById(R.id.error_header)).setText(String.format(activity.getString(mStringId), mStringArgs)); builder.setView(view); builder.setCancelable(false); builder.setPositiveButton(R.string.action_cancel, (DialogInterface dialog, int which) -> { mReturnValue.set(false); dismiss(); }); builder.setNegativeButton(R.string.certificate_error_ignore, (DialogInterface dialog, int which) -> { if (mReturnValue.isDone()) return; boolean remember = (((CheckBox) view.findViewById(R.id.error_remember)).isChecked()); addCertificateException(mCertificate, !remember); mReturnValue.set(true); dismiss(); }); builder.setOnDismissListener((DialogInterface di) -> { if (mLastDialog != null && mLastDialog.get() == di) mLastDialog = null; }); mLastDialog = new WeakReference<>(builder.show()); }
if (shouldShowRequestPermissionRationale( Manifest.permission.WRITE_EXTERNAL_STORAGE)) { new AlertDialog.Builder(this) .setTitle(R.string.permission_error_title) .setMessage(R.string.permission_error_storage) .setCancelable(false) .setPositiveButton(getString(R.string.permission_error_ask_again), ((dialog, which) -> requestStoragePermission())) .setNegativeButton(getString(R.string.dismiss), (((dialog, which) -> dialog.dismiss()))) .show(); } else { Snackbar.make(mCoordinator, getString(R.string.permission_error_forever),
private void init() { if (mStorage.getBoolean(LocalStorageManager.PREF_IS_SETTING_UP) && !isWorkProfileAvailable()) { // Provision is still going on... Toast.makeText(this, R.string.provision_still_pending, Toast.LENGTH_SHORT).show(); finish(); } else if (!mStorage.getBoolean(LocalStorageManager.PREF_HAS_SETUP)) { // Reset the authentication key first AuthenticationUtility.reset(); // If not set up yet, we have to provision the profile first new AlertDialog.Builder(this) .setCancelable(false) .setMessage(R.string.first_run_alert) .setPositiveButton(R.string.first_run_alert_continue, (dialog, which) -> setupProfile()) .setNegativeButton(R.string.first_run_alert_cancel, (dialog, which) -> finish()) .show(); } else { // Initialize the settings SettingsManager.getInstance().applyAll(); // Initialize the app (start by binding the services) bindServices(); } }
@Override public void onReceivedHttpAuthRequest(WebView view, final HttpAuthHandler handler, final String host, final String realm) { Log.i(TAG, "realm " + realm); CredentialsHelper.getInstance(getContext()).handleAuthRequest(host, realm, handler, () -> { final AlertDialog alert = new AlertDialog.Builder(getContext()) .setCancelable(false) .setTitle(R.string.credentials_required) .setMessage(getContext().getString(R.string.host_realm, host, realm)) .setView(R.layout.dialog_credentials) .setPositiveButton(R.string.okay, (dialog12, id) -> { EditText userT = ((AlertDialog) dialog12).findViewById(R.id.username); EditText passT = ((AlertDialog) dialog12).findViewById(R.id.password); CheckBox storeCB = ((AlertDialog) dialog12).findViewById(R.id.checkBox); if (storeCB.isChecked()) { CredentialsHelper.getInstance(getContext()).registerCredentials(host, realm, userT.getText().toString(), passT.getText().toString()); } handler.proceed(userT.getText().toString(), passT.getText().toString()); }).setNegativeButton(R.string.cancel, (dialog1, which) -> handler.cancel()) .create(); if (getContext() != null && !((Activity) getContext()).isFinishing()) { alert.show(); } }); } });
private void showDialog() { AlertDialog.Builder builder = new AlertDialog.Builder(activity); builder.setIcon(getIcon()); builder.setTitle(getTitle()); builder.setMessage(Html.fromHtml(getMessage(), null, getCustomTagHandler())); switch (mMode) { case MODE_CHECK_VERSION: builder.setPositiveButton(getUpdateNowLabel(), listener); builder.setNeutralButton(getRemindMeLaterLabel(), listener); builder.setNegativeButton(getIgnoreThisVersionLabel(), listener); break; case MODE_ASK_FOR_RATE: builder.setPositiveButton(getAskForRatePositiveLabel(), listener); builder.setNegativeButton(getAskForRateNegativeLabel(), listener); break; default: return; } builder.setCancelable(isDialogCancelable()); AlertDialog dialog = builder.create(); if (activity != null && !activity.isFinishing()) { dialog.show(); } }
private void showDialog(final AskAgainCallback.UserResponse response) { if (getActivity() == null) return; new AlertDialog.Builder(getActivity()) .setTitle("Permission needed") .setMessage("This app realy need to use this permission, you wont to authorize it?") .setPositiveButton("OK", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { response.result(true); } }) .setNegativeButton("NOT NOW", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { response.result(false); } }) .setCancelable(false) .show(); }
@NonNull @Override public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) { int argChoice = getArguments().getInt(ARG_CHOICE); int argChoiceArr = getArguments().getInt(ARG_CHOICE_ARR); int argTitle = getArguments().getInt(ARG_TITLE); String[] stringArray = getContext().getResources().getStringArray(argChoiceArr); List<String> stringList = Arrays.asList(stringArray); View view = LayoutInflater.from(getActivity()).inflate(R.layout.dialog_simple_choice, null); RecyclerView recyclerView = view.findViewById(R.id.simple_choice_list); recyclerView.setAdapter(new SimpleChoiceAdapter(stringList, argChoice)); recyclerView.setLayoutManager(new LinearLayoutManager(getContext())); return new AlertDialog.Builder(getActivity()) .setView(view) .setTitle(argTitle) .create(); }
@Override public void buildDialog(AlertDialog.Builder builder, Bundle savedInstanceState) { LayoutInflater inflater = LayoutInflater.from(builder.getContext()); mBinding = DataBindingUtil.inflate(inflater, R.layout.included_in_dialog, null, true); mBinding.branches.listenTo(link -> { if (getActivity() != null) { String title = getString(R.string.change_details_branch); ChangeQuery filter = new ChangeQuery().branch(link); ActivityHelper.openChangeListByFilterActivity( getActivity(), title, filter, false, false); } }); mBinding.setModel(mModel); builder.setTitle(R.string.included_in_dialog_title) .setView(mBinding.getRoot()) .setPositiveButton(R.string.action_close, null); }
@NonNull @Override public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) { mArgCategory = getArguments().getString(ARG_CATEGORY); mView = LayoutInflater.from(getActivity()).inflate(R.layout.dialog_category_select, null); return new AlertDialog.Builder(getActivity()) .setView(mView) .setTitle(R.string.select_category) .setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dismiss(); } }) .create(); }
private void showDialog(final AskAgainCallback.UserResponse response) { new AlertDialog.Builder(getActivity()) .setTitle("Permission needed") .setMessage("This app realy need to use this permission, you wont to authorize it?") .setPositiveButton("OK", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { response.result(true); } }) .setNegativeButton("NOT NOW", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { response.result(false); } }) .setCancelable(false) .show(); }
private void showDialog(final AskAgainCallback.UserResponse response) { new AlertDialog.Builder(MainActivity.this) .setTitle("Permission needed") .setMessage("This app realy need to use this permission, you wont to authorize it?") .setPositiveButton("OK", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { response.result(true); } }) .setNegativeButton("NOT NOW", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { response.result(false); } }) .setCancelable(false) .show(); }
public void showDialog(final String url) { AlertDialog.Builder builder = new AlertDialog.Builder(mActivity); View dialogView = LayoutInflater.from(mActivity).inflate(R.layout.polling_dialog, null); TextView linkView = dialogView.findViewById(R.id.tv_link_redirect); linkView.setText(R.string.verify); linkView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); mActivity.startActivity(browserIntent); } }); builder.setView(dialogView); mAlertDialog = builder.create(); mAlertDialog.show(); }
public void shareLocation(View view) { if (!validLocation(lastLocation)) { return; } String linkChoice = PreferenceManager.getDefaultSharedPreferences(this).getString("prefLinkType", ""); if (linkChoice.equals(getResources().getString(R.string.always_ask))) { new Builder(this).setTitle(R.string.choose_link) .setCancelable(true) .setItems(R.array.link_names, new onClickShareListener()) .create() .show(); } else { shareLocationText(formatLocation(lastLocation, linkChoice)); } }