Search in sources :

Example 41 with DialogInterface

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

the class NekoLand method showNameDialog.

private void showNameDialog(final Cat cat) {
    final Context context = new ContextThemeWrapper(this, android.R.style.Theme_Material_Light_Dialog_NoActionBar);
    // TODO: Move to XML, add correct margins.
    View view = LayoutInflater.from(context).inflate(R.layout.edit_text, null);
    final EditText text = (EditText) view.findViewById(android.R.id.edit);
    text.setText(cat.getName());
    text.setSelection(cat.getName().length());
    final int size = context.getResources().getDimensionPixelSize(android.R.dimen.app_icon_size);
    Drawable catIcon = cat.createIcon(this, size, size).loadDrawable(this);
    new AlertDialog.Builder(context).setTitle(" ").setIcon(catIcon).setView(view).setPositiveButton(android.R.string.ok, new OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            cat.logRename(context);
            cat.setName(text.getText().toString().trim());
            mPrefs.addCat(cat);
        }
    }).show();
}
Also used : Context(android.content.Context) EditText(android.widget.EditText) AlertDialog(android.app.AlertDialog) ContextThemeWrapper(android.view.ContextThemeWrapper) DialogInterface(android.content.DialogInterface) Drawable(android.graphics.drawable.Drawable) OnClickListener(android.content.DialogInterface.OnClickListener) ImageView(android.widget.ImageView) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView)

Example 42 with DialogInterface

use of android.content.DialogInterface in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class IconPickerActivity method getIconPackDialog.

private Dialog getIconPackDialog(Context context) {
    final LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    final View view = inflater.inflate(R.layout.dialog_iconpack, null);
    final AlertDialog.Builder builder = new AlertDialog.Builder(this);
    final IconPackageAdapter adapter = new IconPackageAdapter(this);
    final ListView listView = (ListView) view.findViewById(R.id.iconpack_list);
    final Dialog dialog;
    adapter.load();
    dialog = builder.setTitle(getString(R.string.icon_pack_picker_dialog_title)).setView(view).setOnCancelListener(this).setNegativeButton(android.R.string.cancel, new OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            onCancel(dialog);
        }
    }).create();
    listView.setAdapter(adapter);
    listView.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            ResolveInfo info = adapter.getItem(position);
            String packageName = info.activityInfo.packageName;
            Intent intent = new Intent();
            intent.setClassName("com.android.settings", "com.android.settings.rr.IconPackGridActivity");
            intent.putExtra("icon_package_name", packageName);
            dialog.dismiss();
            startActivityForResult(intent, ICON_PACK_ICON_RESULT);
        }
    });
    return dialog;
}
Also used : AlertDialog(android.app.AlertDialog) OnItemClickListener(android.widget.AdapterView.OnItemClickListener) DialogInterface(android.content.DialogInterface) Intent(android.content.Intent) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ListView(android.widget.ListView) ResolveInfo(android.content.pm.ResolveInfo) ListView(android.widget.ListView) Dialog(android.app.Dialog) AlertDialog(android.app.AlertDialog) LayoutInflater(android.view.LayoutInflater) OnClickListener(android.content.DialogInterface.OnClickListener)

Example 43 with DialogInterface

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

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 44 with DialogInterface

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

the class DirectoryFragment method deleteDocuments.

private void deleteDocuments(final Selection selected) {
    Metrics.logUserAction(getContext(), Metrics.USER_ACTION_DELETE);
    if (selected.isEmpty()) {
        return;
    }
    final DocumentInfo srcParent = getDisplayState().stack.peek();
    // Model must be accessed in UI thread, since underlying cursor is not threadsafe.
    List<DocumentInfo> docs = mModel.getDocuments(selected);
    TextView message = (TextView) mInflater.inflate(R.layout.dialog_delete_confirmation, null);
    message.setText(generateDeleteMessage(docs));
    // This "insta-hides" files that are being deleted, because
    // the delete operation may be not execute immediately (it
    // may be queued up on the FileOperationService.)
    // To hide the files locally, we call the hide method on the adapter
    // ...which a live object...cannot be parceled.
    // For that reason, for now, we implement this dialog NOT
    // as a fragment (which can survive rotation and have its own state),
    // but as a simple runtime dialog. So rotating a device with an
    // active delete dialog...results in that dialog disappearing.
    // We can do better, but don't have cycles for it now.
    new AlertDialog.Builder(getActivity()).setView(message).setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int id) {
            // the user cancels the delete.
            if (mActionMode != null) {
                mActionMode.finish();
            } else {
                Log.w(TAG, "Action mode is null before deleting documents.");
            }
            // Hide the files in the UI...since the operation
            // might be queued up on FileOperationService.
            // We're walking a line here.
            mAdapter.hide(selected.getAll());
            FileOperations.delete(getActivity(), docs, srcParent, getDisplayState().stack);
        }
    }).setNegativeButton(android.R.string.no, null).show();
}
Also used : DialogInterface(android.content.DialogInterface) TextView(android.widget.TextView) Point(android.graphics.Point) DocumentInfo(com.android.documentsui.model.DocumentInfo)

Example 45 with DialogInterface

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

the class DataSaverTile method handleClick.

@Override
protected void handleClick() {
    if (mState.value || Prefs.getBoolean(mContext, Prefs.Key.QS_DATA_SAVER_DIALOG_SHOWN, false)) {
        // Do it right away.
        toggleDataSaver();
        return;
    }
    // Shows dialog first
    SystemUIDialog dialog = new SystemUIDialog(mContext);
    dialog.setTitle(com.android.internal.R.string.data_saver_enable_title);
    dialog.setMessage(com.android.internal.R.string.data_saver_description);
    dialog.setPositiveButton(com.android.internal.R.string.data_saver_enable_button, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            toggleDataSaver();
        }
    });
    dialog.setNegativeButton(com.android.internal.R.string.cancel, null);
    dialog.setShowForAllUsers(true);
    dialog.show();
    Prefs.putBoolean(mContext, Prefs.Key.QS_DATA_SAVER_DIALOG_SHOWN, true);
}
Also used : SystemUIDialog(com.android.systemui.statusbar.phone.SystemUIDialog) DialogInterface(android.content.DialogInterface)

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