@UiThread private void requestOAuthorized() { if(dontShowRequestAuthorizationAgain) return; View inner = LayoutInflater.from(this).inflate( R.layout.dialog_authorize_now, null, false); final CheckBox checkBox = inner.findViewById(R.id.checkBoxDontShowAgain); new AlertDialog.Builder(this) .setView(inner) .setPositiveButton(android.R.string.ok, (dialog, which) -> { Intent intent = new Intent(MainActivity.this, SettingsActivity.class); intent.putExtra(SettingsActivity.EXTRA_LAUNCH_AUTH, true); startActivity(intent); }) .setNegativeButton(R.string.later, (dialog, which) -> { dontShowRequestAuthorizationAgain = checkBox.isChecked(); }).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(); }); }
public void findSource(final long questId, final QuestGroup group, @Nullable final Location location, final Listener listener) { if(dontShowAgain || isWithinSurveyDistance(questId, group, location)) { listener.onFindQuestSourceResult(SURVEY); } else { View inner = LayoutInflater.from(activity).inflate( R.layout.quest_source_dialog_layout, null, false); final CheckBox checkBox = inner.findViewById(R.id.checkBoxDontShowAgain); AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(activity); alertDialogBuilder .setTitle(R.string.quest_source_dialog_title) .setView(inner) .setPositiveButton(R.string.quest_generic_confirmation_yes, (dialog, which) -> { ++timesShown; dontShowAgain = checkBox.isChecked(); listener.onFindQuestSourceResult(SURVEY); }) .setNegativeButton(android.R.string.cancel, null); checkBox.setVisibility(timesShown < 2 ? View.GONE : View.VISIBLE); alertDialogBuilder.show(); } }
private void performRestore() { //noinspection ConstantConditions AlertDialog dialog = new AlertDialog.Builder(getContext()) .setTitle(R.string.change_edit_restore_file_title) .setMessage(R.string.change_edit_restore_file_message) .setPositiveButton(R.string.action_restore, (dialogInterface, i) -> restoreFile()) .setNegativeButton(R.string.action_cancel, null) .create(); dialog.show(); }
private void displayCalendarSyncSuccessDialog() { new AlertDialog.Builder(this) .setMessage(getString(R.string.dialog_show_calendar)) .setNegativeButton(R.string.no, null) .setPositiveButton(R.string.yes, (dialog, i) -> displayCalendarOnGoogleCalendar()) .show(); }
public ColorPickerDialogBuilder setNegativeButton(int textId, DialogInterface.OnClickListener onClickListener) { builder.setNegativeButton(textId, onClickListener); return this; }
public ColorPickerDialogBuilder setNegativeButton(CharSequence text, DialogInterface.OnClickListener onClickListener) { builder.setNegativeButton(text, onClickListener); return this; }
@Override public Builder setNegativeButton(CharSequence text, OnClickListener listener) { super.setNegativeButton(text, listener); return this; }
downloadedTilesDao.removeAll(); }) .setNegativeButton(android.R.string.cancel, null) .show();
.setNegativeButton("取消", null) .show();
.setMessage(R.string.confirmation_cancel_prev_download_title) .setPositiveButton(android.R.string.ok, (dialog, which) -> downloadAreaConfirmed(enclosingBBox)) .setNegativeButton(android.R.string.cancel, null) .show();
private void requestLocationSettingsToBeOn() { if(LocationUtil.isLocationOn(getContext())) { state = LocationState.ENABLED; nextStep(); } else { final AlertDialog dlg = new AlertDialog.Builder(getContext()) .setMessage(R.string.turn_on_location_request) .setPositiveButton(android.R.string.yes, (dialog, which) -> { dialog.dismiss(); Intent viewIntent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS); startActivityForResult(viewIntent, LOCATION_TURN_ON_REQUEST); }) .setNegativeButton(android.R.string.no, (dialog, which) -> cancelTurnLocationOnDialog()) .setOnCancelListener(dialog -> cancelTurnLocationOnDialog()) .create(); // the user may turn on location in the pull-down-overlay, without actually going into // settings dialog registerForLocationProviderChanges(dlg); dlg.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 confirmUndo(final OsmQuest quest) { Element element = questController.getOsmElement(quest); View inner = LayoutInflater.from(this).inflate(R.layout.dialog_undo, null, false); ImageView icon = inner.findViewById(R.id.icon); icon.setImageResource(quest.getType().getIcon()); TextView text = inner.findViewById(R.id.text); text.setText(QuestUtilKt.getHtmlQuestTitle(getResources(), quest.getType(), element)); new AlertDialog.Builder(this) .setTitle(R.string.undo_confirm_title) .setView(inner) .setPositiveButton(R.string.undo_confirm_positive, (dialog, which) -> { questController.undo(quest); questAutoSyncer.triggerAutoUpload(); answersCounter.subtractOneUnsynced(quest.getChangesSource()); }) .setNegativeButton(R.string.undo_confirm_negative, null) .show(); }
@Override public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { // must be for someone else... if(requestCode != LOCATION_PERMISSION_REQUEST) return; if(permissions.length == 0 || !permissions[0].equals(Manifest.permission.ACCESS_FINE_LOCATION)) return; if(grantResults[0] == PackageManager.PERMISSION_GRANTED) { requestLocationPermissions(); // retry then... } else { new AlertDialog.Builder(getContext()) .setMessage(R.string.no_location_permission_warning) .setPositiveButton(R.string.retry, (dialog, which) -> requestLocationPermissions()) .setNegativeButton(android.R.string.cancel, (dialog, which) -> deniedLocationPermissions()) .setOnCancelListener(dialog -> deniedLocationPermissions()) .show(); } }
/** Request to close the form through user interaction (back button, clicked other quest,..), * requires user confirmation if any changes have been made */ @UiThread public void onClickClose(final Runnable confirmed) { if (!isRejectingClose()) { onDiscard(); confirmed.run(); } else { new AlertDialog.Builder(getActivity()) .setMessage(R.string.confirmation_discard_title) .setPositiveButton(R.string.confirmation_discard_positive, (dialog, which) -> { onDiscard(); confirmed.run(); }) .setNegativeButton(R.string.confirmation_discard_negative, null) .show(); } }
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.action_reset: new AlertDialog.Builder(getContext()) .setMessage(R.string.pref_quests_reset) .setPositiveButton(android.R.string.ok, (dialog, which) -> onReset()) .setNegativeButton(android.R.string.cancel, null) .show(); return true; case R.id.action_deselect_all: onDeselectAll(); return true; } return super.onOptionsItemSelected(item); }
@Override public void onCheckedChanged(final CompoundButton compoundButton, boolean b) { item.visible = b; updateSelectionStatus(); visibleQuestTypeDao.setVisible(item.questType, item.visible); if(b && item.questType.getDefaultDisabledMessage() > 0) { new AlertDialog.Builder(compoundButton.getContext()) .setTitle(R.string.enable_quest_confirmation_title) .setMessage(item.questType.getDefaultDisabledMessage()) .setPositiveButton(android.R.string.yes, null) .setNegativeButton(android.R.string.no, (dialog, which) -> compoundButton.setChecked(false)) .show(); } } }
/** * Show the dialog. {@link #show()} is a wrapper to ensure backwards compatibility */ AlertDialog showDialog(DialogInterface.OnClickListener positiveListener, DialogInterface.OnClickListener negativeListener) { AlertDialog.Builder builder; if (mThemeResId != -1) { builder = new AlertDialog.Builder(mContext, mThemeResId); } else { builder = new AlertDialog.Builder(mContext); } return builder .setCancelable(false) .setTitle(mTitle) .setMessage(mRationale) .setPositiveButton(mPositiveButtonText, positiveListener) .setNegativeButton(mNegativeButtonText, negativeListener) .show(); }
AlertDialog createSupportDialog(Context context, Dialog.OnClickListener listener) { AlertDialog.Builder builder; if (theme > 0) { builder = new AlertDialog.Builder(context, theme); } else { builder = new AlertDialog.Builder(context); } return builder .setCancelable(false) .setPositiveButton(positiveButton, listener) .setNegativeButton(negativeButton, listener) .setMessage(rationaleMsg) .create(); }