Example usage for android.app AlertDialog.Builder setInverseBackgroundForced

List of usage examples for android.app AlertDialog.Builder setInverseBackgroundForced

Introduction

In this page you can find the example usage for android.app AlertDialog.Builder setInverseBackgroundForced.

Prototype

public void setInverseBackgroundForced(boolean forceInverseBackground) 

Source Link

Usage

From source file:Main.java

public static void createCancellableAcceptDialog(Context context, String title, String message,
        String acceptButtonText, final Runnable onAccept) {
    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    builder.setTitle(title);/*from  w ww  .  ja v a2 s.c  o m*/
    builder.setMessage(message);
    builder.setInverseBackgroundForced(true);
    builder.setPositiveButton(acceptButtonText, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
            if (onAccept != null)
                onAccept.run();
        }
    });
    AlertDialog alert = builder.create();
    alert.show();
}

From source file:Main.java

public static void createNonCancellableAcceptOrCancelDialog(Context context, String title, String message,
        String acceptButtonText, String cancelButtonText, final Runnable onAccept, final Runnable onCancel) {
    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    builder.setCancelable(false);// w w w.  java 2s .c  om
    builder.setTitle(title);
    builder.setMessage(message);
    builder.setInverseBackgroundForced(true);
    builder.setPositiveButton(acceptButtonText, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
            if (onAccept != null)
                onAccept.run();
        }
    });

    builder.setNegativeButton(cancelButtonText, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
            if (onCancel != null)
                onCancel.run();
        }
    });
    AlertDialog alert = builder.create();
    alert.setOnKeyListener(new DialogInterface.OnKeyListener() {
        @Override
        public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
            if (keyCode == KeyEvent.KEYCODE_SEARCH && event.getRepeatCount() == 0) {
                return true; // Pretend we processed it
            }
            return false; // Any other keys are still processed as normal
        }
    });
    alert.show();
}

From source file:org.geek.utils.ApplicationUtils.java

/**
 * Display a continue / cancel dialog./*from  w  w w.  ja v  a2s . c o  m*/
 * @param context The current context.
 * @param icon The dialog icon.
 * @param title The dialog title.
 * @param message The dialog message.
 * @param onContinue The dialog listener for the continue button.
 * @param onCancel The dialog listener for the cancel button.
 */
public static void showContinueCancelDialog(Context context, int icon, String title, String message,
        DialogInterface.OnClickListener onContinue, DialogInterface.OnClickListener onCancel) {
    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    builder.setCancelable(true);
    builder.setIcon(icon);
    builder.setTitle(title);
    builder.setMessage(message);

    builder.setInverseBackgroundForced(true);
    builder.setPositiveButton(context.getResources().getString(R.string.Commons_Continue), onContinue);
    builder.setNegativeButton(context.getResources().getString(R.string.Commons_Cancel), onCancel);
    AlertDialog alert = builder.create();
    alert.show();
}

From source file:org.geek.utils.ApplicationUtils.java

/**
 * Display a standard Ok dialog.//from   ww w .  j a v a 2 s  .c  o m
 * @param context The current context.
 * @param icon The dialog icon.
 * @param title The dialog title.
 * @param message The dialog message.
 */
public static void showOkDialog(Context context, int icon, String title, String message) {
    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    builder.setCancelable(false);
    builder.setIcon(icon);
    builder.setTitle(title);
    builder.setMessage(message);

    builder.setInverseBackgroundForced(true);
    builder.setPositiveButton(context.getResources().getString(R.string.Commons_Ok),
            new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                }
            });
    AlertDialog alert = builder.create();
    alert.show();
}

From source file:org.geek.utils.ApplicationUtils.java

/**
 * Display a standard Ok / Cancel dialog.
 * @param context The current context.//w w  w. j  a  va2s  .  c  o m
 * @param icon The dialog icon.
 * @param title The dialog title.
 * @param message The dialog message.
 * @param onYes The dialog listener for the yes button.
 */
public static void showOkCancelDialog(Context context, int icon, String title, String message,
        DialogInterface.OnClickListener onYes) {
    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    builder.setCancelable(true);
    builder.setIcon(icon);
    builder.setTitle(title);
    builder.setMessage(message);

    builder.setInverseBackgroundForced(true);
    builder.setPositiveButton(context.getResources().getString(R.string.Commons_Ok), onYes);
    builder.setNegativeButton(context.getResources().getString(R.string.Commons_Cancel),
            new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                }
            });
    AlertDialog alert = builder.create();
    alert.show();
}

From source file:org.geek.utils.ApplicationUtils.java

/**
 * Display a standard yes / no dialog./*from  w  w w .  j a va2 s  .c  om*/
 * @param context The current context.
 * @param icon The dialog icon.
 * @param title The dialog title.
 * @param message The dialog message.
 * @param onYes The dialog listener for the yes button.
 */
public static void showYesNoDialog(Context context, int icon, int title, int message,
        DialogInterface.OnClickListener onYes) {
    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    builder.setCancelable(true);
    builder.setIcon(icon);
    builder.setTitle(context.getResources().getString(title));
    builder.setMessage(context.getResources().getString(message));

    builder.setInverseBackgroundForced(true);
    builder.setPositiveButton(context.getResources().getString(R.string.Commons_Yes), onYes);
    builder.setNegativeButton(context.getResources().getString(R.string.Commons_No),
            new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                }
            });
    AlertDialog alert = builder.create();
    alert.show();
}

From source file:nl.atcomputing.refcard.fragments.AboutDialogFragment.java

@NonNull
@Override//from   ww w.  j a v a  2s.co m
public Dialog onCreateDialog(Bundle savedInstanceState) {
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    builder.setInverseBackgroundForced(true);

    LayoutInflater inflater = getActivity().getLayoutInflater();
    View view = inflater.inflate(R.layout.dialog_about, null);

    String version;
    try {
        PackageInfo info = getActivity().getPackageManager().getPackageInfo("nl.atcomputing.refcard", 0);
        version = info.versionName + "-" + info.versionCode;
    } catch (PackageManager.NameNotFoundException e) {
        version = getString(R.string.unknown);
    }
    TextView tv = (TextView) view.findViewById(R.id.about_version_number);
    tv.setText(version);

    builder.setView(view).setPositiveButton(R.string.confirm_ok, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int id) {
            AboutDialogFragment.this.getDialog().dismiss();
        }
    });

    return builder.create();
}

From source file:nl.atcomputing.refcard.fragments.ChangelogDialogFragment.java

@NonNull
@Override//from  w w  w.  ja  v  a 2s .  c  o  m
public Dialog onCreateDialog(Bundle savedInstanceState) {
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    builder.setInverseBackgroundForced(true);

    LayoutInflater inflater = getActivity().getLayoutInflater();
    View view = inflater.inflate(R.layout.dialog_changelog, null);

    LinearLayout layout = (LinearLayout) view.findViewById(R.id.changelogentries);
    for (String line : changelog) {
        View v = (View) inflater.inflate(R.layout.changelog_entry, null);
        TextView tv = (TextView) v.findViewById(R.id.bullet);
        tv.setText(Html.fromHtml("•"));
        tv = (TextView) v.findViewById(R.id.changelogtext);
        tv.setText(line);
        layout.addView(v);
    }

    builder.setView(view).setPositiveButton(R.string.confirm_ok, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int id) {
            ChangelogDialogFragment.this.getDialog().dismiss();
        }
    });

    return builder.create();
}

From source file:de.schildbach.wallet.ui.EditTransactionNoteFragment.java

@Override
public Dialog onCreateDialog(final Bundle savedInstanceState) {
    final Bundle args = getArguments();
    final String txid = args.getString(KEY_TRANSACTION);

    final LayoutInflater inflater = LayoutInflater.from(activity);

    final String note = prefs.getString("tx:" + txid, "");
    final boolean isAdd = note.isEmpty();

    final AlertDialog.Builder dialog = new AlertDialog.Builder(activity);
    dialog.setInverseBackgroundForced(true);
    dialog.setTitle(R.string.edit_transaction_note_dialog_title_edit);

    final View view = inflater.inflate(R.layout.edit_transaction_note_dialog, null);

    final TextView viewTxid = (TextView) view.findViewById(R.id.edit_transaction_note_txid);
    viewTxid.setText(txid);/*from  ww  w  .j  a v a2  s  .c  o m*/

    final TextView viewNote = (TextView) view.findViewById(R.id.edit_transaction_note_note);
    viewNote.setText(note);

    dialog.setView(view);

    final DialogInterface.OnClickListener onClickListener = new DialogInterface.OnClickListener() {
        @Override
        public void onClick(final DialogInterface dialog, final int which) {
            if (which == DialogInterface.BUTTON_POSITIVE) {
                final String newNote = viewNote.getText().toString().trim();

                if (!newNote.isEmpty()) {
                    prefs.edit().putString("tx:" + txid, newNote).commit();
                }
            }
            if (which == DialogInterface.BUTTON_NEUTRAL) {
                prefs.edit().remove("tx:" + txid).commit();
            }
            // Notify list of update
            if (adapter != null)
                adapter.notifyDataSetChanged();

            dismiss();
        }
    };

    dialog.setPositiveButton(isAdd ? R.string.button_add : R.string.edit_address_book_entry_dialog_button_edit,
            onClickListener);
    if (!isAdd)
        dialog.setNeutralButton(R.string.button_delete, onClickListener);
    dialog.setNegativeButton(R.string.button_cancel, onClickListener);

    return dialog.create();
}

From source file:com.feathercoin.wallet.feathercoin.ui.EditAddressBookEntryFragment.java

@Override
public Dialog onCreateDialog(final Bundle savedInstanceState) {
    final Bundle args = getArguments();
    final String address = args.getString(KEY_ADDRESS);
    final String suggestedAddressLabel = args.getString(KEY_SUGGESTED_ADDRESS_LABEL);

    final LayoutInflater inflater = LayoutInflater.from(activity);

    final Uri uri = AddressBookProvider.contentUri(activity.getPackageName()).buildUpon().appendPath(address)
            .build();//from  w  ww .  ja va  2  s.  c om

    final String label = AddressBookProvider.resolveLabel(activity, address);

    final boolean isAdd = label == null;

    final AlertDialog.Builder dialog = new AlertDialog.Builder(activity);
    dialog.setInverseBackgroundForced(true);
    dialog.setTitle(isAdd ? R.string.edit_address_book_entry_dialog_title_add
            : R.string.edit_address_book_entry_dialog_title_edit);

    final View view = inflater.inflate(R.layout.edit_address_book_entry_dialog, null);

    final TextView viewAddress = (TextView) view.findViewById(R.id.edit_address_book_entry_address);
    viewAddress.setText(WalletUtils.formatHash(address, Constants.ADDRESS_FORMAT_GROUP_SIZE,
            Constants.ADDRESS_FORMAT_LINE_SIZE));

    final TextView viewLabel = (TextView) view.findViewById(R.id.edit_address_book_entry_label);
    viewLabel.setText(label != null ? label : suggestedAddressLabel);

    dialog.setView(view);

    final DialogInterface.OnClickListener onClickListener = new DialogInterface.OnClickListener() {
        public void onClick(final DialogInterface dialog, final int which) {
            if (which == DialogInterface.BUTTON_POSITIVE) {
                final String newLabel = viewLabel.getText().toString().trim();

                if (newLabel.length() > 0) {
                    final ContentValues values = new ContentValues();
                    values.put(AddressBookProvider.KEY_LABEL, newLabel);

                    if (isAdd)
                        contentResolver.insert(uri, values);
                    else
                        contentResolver.update(uri, values, null, null);
                } else if (!isAdd) {
                    contentResolver.delete(uri, null, null);
                }
            } else if (which == DialogInterface.BUTTON_NEUTRAL) {
                contentResolver.delete(uri, null, null);
            }

            dismiss();
        }
    };

    dialog.setPositiveButton(isAdd ? R.string.button_add : R.string.edit_address_book_entry_dialog_button_edit,
            onClickListener);
    if (!isAdd)
        dialog.setNeutralButton(R.string.button_delete, onClickListener);
    dialog.setNegativeButton(R.string.button_cancel, onClickListener);

    return dialog.create();
}