/** * helper method to open the license dialog / or website * * @param ctx Context for startActivity * @param libsBuilder * @param library */ private void openLicense(Context ctx, LibsBuilder libsBuilder, Library library) { try { if (libsBuilder.showLicenseDialog && !TextUtils.isEmpty(library.getLicense().getLicenseDescription())) { AlertDialog.Builder builder = new AlertDialog.Builder(ctx); builder.setMessage(Html.fromHtml(library.getLicense().getLicenseDescription())); builder.create().show(); } else { Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(library.getLicense().getLicenseWebsite())); ctx.startActivity(browserIntent); } } catch (Exception ex) { } }
@Override public void onReceive(Context context, Intent intent) { dlg.dismiss(); unregisterForLocationProviderChanges(); requestLocationSettingsToBeOn(); } };
@Override public void onClick(View v) { boolean consumed = false; if (LibsConfiguration.getInstance().getListener() != null) { consumed = LibsConfiguration.getInstance().getListener().onExtraClicked(v, Libs.SpecialButton.SPECIAL1); } if (!consumed && !TextUtils.isEmpty(libsBuilder.aboutAppSpecial1Description)) { try { AlertDialog alert = new AlertDialog.Builder(ctx) .setMessage(Html.fromHtml(libsBuilder.aboutAppSpecial1Description)) .create(); alert.show(); TextView alertText = (TextView) alert.findViewById(android.R.id.message); if (alertText != null) { alertText.setMovementMethod(LinkMovementMethod.getInstance()); } } catch (Exception ex) { } } } });
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(); }
private void displayError(String errorMessage) { AlertDialog alertDialog = new AlertDialog.Builder(this).create(); alertDialog.setTitle("Error"); alertDialog.setMessage(errorMessage); alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, "OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); alertDialog.show(); }
private void showDialog(AlertDialog dialog) { if (mCurrentDialog != null) mCurrentDialog.dismiss(); mCurrentDialog = dialog; dialog.setOnDismissListener((DialogInterface i) -> { mCurrentDialog = null; showDialogsIfNeeded(); }); dialog.show(); }
private void initAddDialog(final AlertDialog dialog) final TextInputEditText field = dialog.findViewById(R.id.text_input_dialog); final TextInputLayout fieldLayout = dialog.findViewById(R.id.layout_text_input_dialog); Button positiveButton = dialog.getButton(AlertDialog.BUTTON_POSITIVE); addTorrentDialog(Uri.parse(url)); dialog.dismiss();
.create(); alertDialog.setCanceledOnTouchOutside(false); alertDialog.show(); Window window = alertDialog.getWindow(); if (window != null) { window.setWindowAnimations(0); alertDialog.setOnDismissListener(new DialogInterface.OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) {
private void showLicense() { // @binkybear here goes the changelog etc... \n\n%s String readmeData = String.format("%s\n\n%s", getResources().getString(R.string.licenseInfo), getResources().getString(R.string.nhwarning)); AlertDialog.Builder adb = new AlertDialog.Builder(this); adb.setTitle("README INFO") .setMessage(readmeData) .setNegativeButton("Close", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); //nhwarning AlertDialog ad = adb.create(); ad.setCancelable(false); ad.getWindow().getAttributes().windowAnimations = R.style.DialogStyle; ad.show(); }
/** * Show information dialog with OK button * @param context Context * @param title Title * @param message Message */ static void showInfo(Context context, CharSequence title, CharSequence message) { AlertDialog alertDialog = initDialog(context, title, message); alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, context.getString(R.string.ok), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); alertDialog.show(); }
@Test public void shouldPositiveListener_whenClickingPositiveButtonFromSupportFragment() { AlertDialog alertDialog = new AppSettingsDialog.Builder(spyFragment) .setTitle(TITLE) .setRationale(RATIONALE) .setPositiveButton(POSITIVE) .setNegativeButton(NEGATIVE) .setThemeResId(R.style.Theme_AppCompat) .build() .showDialog(positiveListener, negativeListener); Button positive = alertDialog.getButton(AlertDialog.BUTTON_POSITIVE); positive.performClick(); verify(positiveListener, times(1)) .onClick(any(DialogInterface.class), anyInt()); }
private void initAboutDialog(final AlertDialog dialog) { TextView version = dialog.findViewById(R.id.about_version); if (version != null) { String versionName = Utils.getAppVersionName(activity); if (versionName != null) version.setText(versionName); } }
@Override public void dismissDialog(Activity activity) { if (mDialog != null) { mDialog.setOnDismissListener(null); mDialog.dismiss(); mDialog = null; } }
final AlertDialog dialog = (AlertDialog) getDialog(); if (dialog != null) { final EditText editText = dialog.findViewById(android.R.id.edit); Button positiveButton = dialog.getButton(Dialog.BUTTON_POSITIVE); if (editText != null && positiveButton != null) { positiveButton.setOnClickListener(new View.OnClickListener() {
@Override public void onStart() { super.onStart(); AlertDialog dialog = (AlertDialog) getDialog(); // http://stackoverflow.com/a/16972670/1048340 //noinspection ConstantConditions dialog.getWindow() .clearFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM); dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE); // Do not dismiss the dialog when clicking the neutral button. Button neutralButton = dialog.getButton(AlertDialog.BUTTON_NEUTRAL); if (neutralButton != null) { neutralButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { rootView.removeAllViews(); switch (dialogType) { case TYPE_CUSTOM: dialogType = TYPE_PRESETS; ((Button) v).setText(customButtonStringRes != 0 ? customButtonStringRes : R.string.cpv_custom); rootView.addView(createPresetsView()); break; case TYPE_PRESETS: dialogType = TYPE_CUSTOM; ((Button) v).setText(presetsButtonStringRes != 0 ? presetsButtonStringRes : R.string.cpv_presets); rootView.addView(createPickerView()); } } }); } }
.setPositiveButton(mCloseText, (dialogInterface, i) -> dialogInterface.dismiss()); final AlertDialog dialog = builder.create(); dialog.setOnDismissListener(dialog1 -> { if (mOnDismissListener != null) { mOnDismissListener.onDismiss(dialog1); dialog.setOnShowListener(dialogInterface -> { if (mDividerColor != 0) { final View titleDivider = dialog.findViewById(titleDividerId); if (titleDivider != null) { titleDivider.setBackgroundColor(mDividerColor);
@Override public Dialog onCreateDialog(@Nullable final Bundle savedInstanceState) { final AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(getActivity()); alertDialogBuilder.setTitle(R.string.excluded_applications); final AppListDialogFragmentBinding binding = AppListDialogFragmentBinding.inflate(getActivity().getLayoutInflater(), null, false); binding.executePendingBindings(); alertDialogBuilder.setView(binding.getRoot()); alertDialogBuilder.setPositiveButton(R.string.set_exclusions, (dialog, which) -> setExclusionsAndDismiss()); alertDialogBuilder.setNegativeButton(R.string.cancel, (dialog, which) -> dialog.dismiss()); alertDialogBuilder.setNeutralButton(R.string.deselect_all, (dialog, which) -> { }); binding.setFragment(this); binding.setAppData(appData); loadData(); final AlertDialog dialog = alertDialogBuilder.create(); dialog.setOnShowListener(d -> dialog.getButton(DialogInterface.BUTTON_NEUTRAL).setOnClickListener(view -> { for (final ApplicationData app : appData) app.setExcludedFromTunnel(false); })); return dialog; }
.create(); dialog.setOnShowListener(new DialogInterface.OnShowListener() { @Override public void onShow(DialogInterface dialogInterface) { dialog.getWindow().getAttributes().windowAnimations = R.style.DialogAnimation;
@NonNull @Override public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) { View view = LayoutInflater.from(getActivity()).inflate(R.layout.dialog_about_durable_event, null); AlertDialog dialog = new AlertDialog.Builder(getActivity()) .setTitle(R.string.about_durable_event) .setView(view) .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { sendResult(Activity.RESULT_OK, true); dismiss(); } }) .create(); dialog.getWindow().getAttributes().windowAnimations = R.style.DialogAnimation; return dialog; }