Search in sources :

Example 26 with DialogInterface

use of android.content.DialogInterface in project android_frameworks_base by ParanoidAndroid.

the class TrackerActivity method showConfirm.

private void showConfirm(int textId, final Runnable onConfirmAction) {
    AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(this);
    dialogBuilder.setTitle(R.string.confirm_title);
    dialogBuilder.setMessage(textId);
    dialogBuilder.setPositiveButton(android.R.string.ok, new OnClickListener() {

        public void onClick(DialogInterface dialog, int which) {
            onConfirmAction.run();
        }
    });
    dialogBuilder.setNegativeButton(android.R.string.cancel, new OnClickListener() {

        public void onClick(DialogInterface dialog, int which) {
        // do nothing
        }
    });
    dialogBuilder.show();
}
Also used : AlertDialog(android.app.AlertDialog) DialogInterface(android.content.DialogInterface) OnClickListener(android.content.DialogInterface.OnClickListener)

Example 27 with DialogInterface

use of android.content.DialogInterface in project android_frameworks_base by ParanoidAndroid.

the class VersionDialog method onCreateDialog.

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    final Activity activity = getActivity();
    // Need to use our library's resources for showing the dialog.
    final Context context;
    try {
        context = activity.createPackageContext(SharedLibraryMain.LIBRARY_PACKAGE, 0);
    } catch (PackageManager.NameNotFoundException e) {
        throw new IllegalStateException("Can't find my package!", e);
    }
    final Resources res = context.getResources();
    AlertDialog.Builder builder = new AlertDialog.Builder(activity);
    builder.setTitle(res.getText(R.string.upgrade_title));
    builder.setMessage(res.getString(R.string.upgrade_body, activity.getApplicationInfo().loadLabel(activity.getPackageManager()), context.getApplicationInfo().loadLabel(context.getPackageManager())));
    builder.setPositiveButton(res.getText(R.string.upgrade_button), new Dialog.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            // Launch play store into the details of our app.
            try {
                activity.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + SharedLibraryMain.LIBRARY_PACKAGE)));
            } catch (android.content.ActivityNotFoundException anfe) {
                activity.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://play.google.com/store/apps/details?id=" + SharedLibraryMain.LIBRARY_PACKAGE)));
            }
        }
    });
    return builder.create();
}
Also used : Context(android.content.Context) AlertDialog(android.app.AlertDialog) DialogInterface(android.content.DialogInterface) Activity(android.app.Activity) Intent(android.content.Intent) PackageManager(android.content.pm.PackageManager) AlertDialog(android.app.AlertDialog) Dialog(android.app.Dialog) Resources(android.content.res.Resources)

Example 28 with DialogInterface

use of android.content.DialogInterface in project android_frameworks_base by ParanoidAndroid.

the class BugReportTile method showBugreportDialog.

private void showBugreportDialog() {
    final AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
    builder.setPositiveButton(com.android.internal.R.string.report, new OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            if (which == DialogInterface.BUTTON_POSITIVE) {
                // Add a little delay before executing, to give the
                // dialog a chance to go away before it takes a
                // screenshot.
                mHandler.postDelayed(new Runnable() {

                    @Override
                    public void run() {
                        try {
                            ActivityManagerNative.getDefault().requestBugReport();
                        } catch (RemoteException e) {
                        }
                    }
                }, 500);
            }
        }
    });
    builder.setMessage(com.android.internal.R.string.bugreport_message);
    builder.setTitle(com.android.internal.R.string.bugreport_title);
    builder.setCancelable(true);
    final Dialog dialog = builder.create();
    dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
    try {
        WindowManagerGlobal.getWindowManagerService().dismissKeyguard();
    } catch (RemoteException e) {
    }
    dialog.show();
}
Also used : AlertDialog(android.app.AlertDialog) DialogInterface(android.content.DialogInterface) Dialog(android.app.Dialog) AlertDialog(android.app.AlertDialog) OnClickListener(android.content.DialogInterface.OnClickListener) RemoteException(android.os.RemoteException)

Example 29 with DialogInterface

use of android.content.DialogInterface in project AndEngine by nicolasgramlich.

the class GenericInputDialogBuilder method create.

// ===========================================================
// Methods
// ===========================================================
public Dialog create() {
    final EditText etInput = new EditText(this.mContext);
    etInput.setText(this.mDefaultText);
    final AlertDialog.Builder ab = new AlertDialog.Builder(this.mContext);
    if (this.mTitleResID != 0) {
        ab.setTitle(this.mTitleResID);
    }
    if (this.mMessageResID != 0) {
        ab.setMessage(this.mMessageResID);
    }
    if (this.mIconResID != 0) {
        ab.setIcon(this.mIconResID);
    }
    this.setView(ab, etInput);
    ab.setOnCancelListener(this.mOnCancelListener).setPositiveButton(android.R.string.ok, new OnClickListener() {

        @Override
        public void onClick(final DialogInterface pDialog, final int pWhich) {
            final T result;
            try {
                result = GenericInputDialogBuilder.this.generateResult(etInput.getText().toString());
            } catch (final IllegalArgumentException e) {
                Debug.e("Error in GenericInputDialogBuilder.generateResult()", e);
                Toast.makeText(GenericInputDialogBuilder.this.mContext, GenericInputDialogBuilder.this.mErrorResID, Toast.LENGTH_SHORT).show();
                return;
            }
            GenericInputDialogBuilder.this.mSuccessCallback.onCallback(result);
            pDialog.dismiss();
        }
    }).setNegativeButton(android.R.string.cancel, new OnClickListener() {

        @Override
        public void onClick(final DialogInterface pDialog, final int pWhich) {
            GenericInputDialogBuilder.this.mOnCancelListener.onCancel(pDialog);
            pDialog.dismiss();
        }
    });
    return ab.create();
}
Also used : EditText(android.widget.EditText) AlertDialog(android.app.AlertDialog) DialogInterface(android.content.DialogInterface) OnClickListener(android.content.DialogInterface.OnClickListener)

Example 30 with DialogInterface

use of android.content.DialogInterface in project barcodescanner by dm77.

the class FormatSelectorDialogFragment method onCreateDialog.

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    if (mSelectedIndices == null || mListener == null) {
        dismiss();
        return null;
    }
    String[] formats = new String[BarcodeFormat.ALL_FORMATS.size()];
    boolean[] checkedIndices = new boolean[BarcodeFormat.ALL_FORMATS.size()];
    int i = 0;
    for (BarcodeFormat format : BarcodeFormat.ALL_FORMATS) {
        formats[i] = format.getName();
        if (mSelectedIndices.contains(i)) {
            checkedIndices[i] = true;
        } else {
            checkedIndices[i] = false;
        }
        i++;
    }
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    // Set the dialog title
    builder.setTitle(R.string.choose_formats).setMultiChoiceItems(formats, checkedIndices, new DialogInterface.OnMultiChoiceClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which, boolean isChecked) {
            if (isChecked) {
                // If the user checked the item, add it to the selected items
                mSelectedIndices.add(which);
            } else if (mSelectedIndices.contains(which)) {
                // Else, if the item is already in the array, remove it
                mSelectedIndices.remove(mSelectedIndices.indexOf(which));
            }
        }
    }).setPositiveButton(R.string.ok_button, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int id) {
            // or return them to the component that opened the dialog
            if (mListener != null) {
                mListener.onFormatsSaved(mSelectedIndices);
            }
        }
    }).setNegativeButton(R.string.cancel_button, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int id) {
        }
    });
    return builder.create();
}
Also used : AlertDialog(android.app.AlertDialog) DialogInterface(android.content.DialogInterface) BarcodeFormat(me.dm7.barcodescanner.zbar.BarcodeFormat)

Aggregations

DialogInterface (android.content.DialogInterface)2733 AlertDialog (android.app.AlertDialog)1228 View (android.view.View)877 Intent (android.content.Intent)709 TextView (android.widget.TextView)653 AlertDialog (android.support.v7.app.AlertDialog)649 EditText (android.widget.EditText)426 ImageView (android.widget.ImageView)308 OnClickListener (android.content.DialogInterface.OnClickListener)285 LayoutInflater (android.view.LayoutInflater)242 SuppressLint (android.annotation.SuppressLint)225 AdapterView (android.widget.AdapterView)220 ListView (android.widget.ListView)220 ArrayList (java.util.ArrayList)213 Context (android.content.Context)181 Dialog (android.app.Dialog)180 File (java.io.File)160 OnClickListener (android.view.View.OnClickListener)157 Bundle (android.os.Bundle)146 Activity (android.app.Activity)143