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 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 Builder setTitle(CharSequence title) { super.setTitle(title); return this; }
public ColorPickerDialogBuilder setTitle(String title) { builder.setTitle(title); return this; }
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 showErrorDialog(String message) { AlertDialog dialog = new AlertDialog.Builder(this) .setTitle(R.string.error) .setMessage(message) .setIcon(R.drawable.ic_error_outline) .setPositiveButton(R.string.ok, null) .create(); if (dialog.getWindow() != null) { dialog.getWindow().setBackgroundDrawableResource(R.drawable.rounded_corners_background); } dialog.show(); }
private void showError(String message) { AlertDialog dialog = new AlertDialog.Builder(this) .setTitle(getString(R.string.error)) .setMessage(message) .setPositiveButton(R.string.ok, null) .create(); if (dialog.getWindow() != null) { dialog.getWindow().setBackgroundDrawableResource(R.drawable.rounded_corners_background); } dialog.show(); }
@Override public void buildDialog(AlertDialog.Builder builder, Bundle savedInstanceState) { LayoutInflater inflater = LayoutInflater.from(builder.getContext()); mBinding = DataBindingUtil.inflate(inflater, R.layout.file_details_dialog, null, true); mBinding.setModel(mModel); builder.setTitle(R.string.file_details_dialog_title) .setView(mBinding.getRoot()) .setPositiveButton(R.string.action_close, null); }
@NonNull @Override public Dialog onCreateDialog(Bundle savedInstanceState) { return new AlertDialog.Builder(getContext()) .setTitle(R.string.app_name) .setIcon(R.mipmap.ic_launcher) .setMessage(getResources().getText(R.string.about_text)) .setPositiveButton(android.R.string.ok, null) .create(); }
public void loadSavedMacDialog() { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setTitle("Load saved MAC:"); builder.setMessage("Not implemented WIP"); builder.setPositiveButton("OK", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }); builder.show(); }
private void showProgressBarDialog() { progress = new AlertDialog.Builder(mContext) .setTitle(R.string.feedback_sending) .setView(new ProgressBar(mContext)) .setCancelable(false) .setNeutralButton(R.string.cancel, (dialogInterface, i) -> dialogInterface.cancel()) .create(); if (progress.getWindow() != null) { progress.getWindow().setBackgroundDrawableResource(R.drawable.rounded_corners_background); } progress.show(); }
public ColorPickerDialogBuilder setTitle(int titleId) { builder.setTitle(titleId); return this; }
@Override public void onClick(View v) { ListSetting listEntry = getEntry(); new AlertDialog.Builder(v.getContext()) .setTitle(listEntry.mName) .setSingleChoiceItems(listEntry.mOptions, listEntry.mSelectedOption, (DialogInterface i, int which) -> { listEntry.setSelectedOption(which); i.cancel(); }) .show(); }
if (activateCounter % 10 == 0) { new AlertDialog.Builder(this) .setTitle("觉得还不错?") .setMessage("您的支持是我动力来源!\n请考虑为我买杯咖啡醒醒脑,甚至其他…… ;)") .setPositiveButton("为我买杯咖啡", new DialogInterface.OnClickListener() {
@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(); } };
@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(); } } }
public void readSignature(View view) { Log.e("Signature", LibraryUtilsKt.getApkSignature(this)); new AlertDialog.Builder(this) .setTitle("APK") .setMessage(LibraryUtilsKt.getApkSignature((this))) .show(); }
@Override public void onSequenceCanceled(TapTarget lastTarget) { final AlertDialog dialog = new AlertDialog.Builder(MainActivity.this) .setTitle("Uh oh") .setMessage("You canceled the sequence") .setPositiveButton("Oops", null).show(); TapTargetView.showFor(dialog, TapTarget.forView(dialog.getButton(DialogInterface.BUTTON_POSITIVE), "Uh oh!", "You canceled the sequence at step " + lastTarget.id()) .cancelable(false) .tintTarget(false), new TapTargetView.Listener() { @Override public void onTargetClick(TapTargetView view) { super.onTargetClick(view); dialog.dismiss(); } }); } });
/** * 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(); }