Search in sources :

Example 21 with DialogInterface

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

the class QuickSettings 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) AlertDialog(android.app.AlertDialog) Dialog(android.app.Dialog) OnClickListener(android.content.DialogInterface.OnClickListener) RemoteException(android.os.RemoteException)

Example 22 with DialogInterface

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

the class InputMethodManagerService method showInputMethodMenuInternal.

private void showInputMethodMenuInternal(boolean showSubtypes) {
    if (DEBUG)
        Slog.v(TAG, "Show switching menu");
    final Context context = getUiContext();
    final boolean isScreenLocked = isScreenLocked();
    final String lastInputMethodId = mSettings.getSelectedInputMethod();
    int lastInputMethodSubtypeId = mSettings.getSelectedInputMethodSubtypeId(lastInputMethodId);
    if (DEBUG)
        Slog.v(TAG, "Current IME: " + lastInputMethodId);
    synchronized (mMethodMap) {
        final HashMap<InputMethodInfo, List<InputMethodSubtype>> immis = getExplicitlyOrImplicitlyEnabledInputMethodsAndSubtypeListLocked();
        if (immis == null || immis.size() == 0) {
            return;
        }
        hideInputMethodMenuLocked();
        final List<ImeSubtypeListItem> imList = mImListManager.getSortedInputMethodAndSubtypeList(showSubtypes, mInputShown, isScreenLocked);
        if (lastInputMethodSubtypeId == NOT_A_SUBTYPE_ID) {
            final InputMethodSubtype currentSubtype = getCurrentInputMethodSubtypeLocked();
            if (currentSubtype != null) {
                final InputMethodInfo currentImi = mMethodMap.get(mCurMethodId);
                lastInputMethodSubtypeId = InputMethodUtils.getSubtypeIdFromHashCode(currentImi, currentSubtype.hashCode());
            }
        }
        final int N = imList.size();
        mIms = new InputMethodInfo[N];
        mSubtypeIds = new int[N];
        int checkedItem = 0;
        for (int i = 0; i < N; ++i) {
            final ImeSubtypeListItem item = imList.get(i);
            mIms[i] = item.mImi;
            mSubtypeIds[i] = item.mSubtypeId;
            if (mIms[i].getId().equals(lastInputMethodId)) {
                int subtypeId = mSubtypeIds[i];
                if ((subtypeId == NOT_A_SUBTYPE_ID) || (lastInputMethodSubtypeId == NOT_A_SUBTYPE_ID && subtypeId == 0) || (subtypeId == lastInputMethodSubtypeId)) {
                    checkedItem = i;
                }
            }
        }
        final TypedArray a = context.obtainStyledAttributes(null, com.android.internal.R.styleable.DialogPreference, com.android.internal.R.attr.alertDialogStyle, 0);
        mDialogBuilder = new AlertDialog.Builder(context).setOnCancelListener(new OnCancelListener() {

            @Override
            public void onCancel(DialogInterface dialog) {
                hideInputMethodMenu();
            }
        }).setIcon(a.getDrawable(com.android.internal.R.styleable.DialogPreference_dialogTitle));
        a.recycle();
        final LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        final View tv = inflater.inflate(com.android.internal.R.layout.input_method_switch_dialog_title, null);
        mDialogBuilder.setCustomTitle(tv);
        // Setup layout for a toggle switch of the hardware keyboard
        mSwitchingDialogTitleView = tv;
        mSwitchingDialogTitleView.findViewById(com.android.internal.R.id.hard_keyboard_section).setVisibility(mWindowManagerService.isHardKeyboardAvailable() ? View.VISIBLE : View.GONE);
        final Switch hardKeySwitch = ((Switch) mSwitchingDialogTitleView.findViewById(com.android.internal.R.id.hard_keyboard_switch));
        hardKeySwitch.setChecked(mWindowManagerService.isHardKeyboardEnabled());
        hardKeySwitch.setOnCheckedChangeListener(new OnCheckedChangeListener() {

            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                mWindowManagerService.setHardKeyboardEnabled(isChecked);
                // Ensure that the input method dialog is dismissed when changing
                // the hardware keyboard state.
                hideInputMethodMenu();
            }
        });
        final ImeSubtypeListAdapter adapter = new ImeSubtypeListAdapter(context, com.android.internal.R.layout.simple_list_item_2_single_choice, imList, checkedItem);
        mDialogBuilder.setSingleChoiceItems(adapter, checkedItem, new AlertDialog.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
                synchronized (mMethodMap) {
                    if (mIms == null || mIms.length <= which || mSubtypeIds == null || mSubtypeIds.length <= which) {
                        return;
                    }
                    InputMethodInfo im = mIms[which];
                    int subtypeId = mSubtypeIds[which];
                    adapter.mCheckedItem = which;
                    adapter.notifyDataSetChanged();
                    hideInputMethodMenu();
                    if (im != null) {
                        if ((subtypeId < 0) || (subtypeId >= im.getSubtypeCount())) {
                            subtypeId = NOT_A_SUBTYPE_ID;
                        }
                        setInputMethodLocked(im.getId(), subtypeId);
                    }
                }
            }
        });
        if (showSubtypes && !isScreenLocked) {
            mDialogBuilder.setPositiveButton(com.android.internal.R.string.configure_input_methods, new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int whichButton) {
                    showConfigureInputMethods();
                }
            });
        }
        mSwitchingDialog = mDialogBuilder.create();
        mSwitchingDialog.setCanceledOnTouchOutside(true);
        mSwitchingDialog.getWindow().setType(WindowManager.LayoutParams.TYPE_INPUT_METHOD_DIALOG);
        mSwitchingDialog.getWindow().getAttributes().privateFlags |= WindowManager.LayoutParams.PRIVATE_FLAG_SHOW_FOR_ALL_USERS;
        mSwitchingDialog.getWindow().getAttributes().setTitle("Select input method");
        mSwitchingDialog.show();
    }
}
Also used : IInputContext(com.android.internal.view.IInputContext) Context(android.content.Context) AlertDialog(android.app.AlertDialog) InputMethodSubtype(android.view.inputmethod.InputMethodSubtype) OnCheckedChangeListener(android.widget.CompoundButton.OnCheckedChangeListener) DialogInterface(android.content.DialogInterface) View(android.view.View) TextView(android.widget.TextView) InputMethodInfo(android.view.inputmethod.InputMethodInfo) Switch(android.widget.Switch) TypedArray(android.content.res.TypedArray) LayoutInflater(android.view.LayoutInflater) ArrayList(java.util.ArrayList) List(java.util.List) CompoundButton(android.widget.CompoundButton) OnCancelListener(android.content.DialogInterface.OnCancelListener)

Example 23 with DialogInterface

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

the class AccessibilityManagerService method showEnableTouchExplorationDialog.

private void showEnableTouchExplorationDialog(final Service service) {
    synchronized (mLock) {
        String label = service.mResolveInfo.loadLabel(mContext.getPackageManager()).toString();
        final UserState state = getCurrentUserStateLocked();
        if (state.mIsTouchExplorationEnabled) {
            return;
        }
        if (mEnableTouchExplorationDialog != null && mEnableTouchExplorationDialog.isShowing()) {
            return;
        }
        mEnableTouchExplorationDialog = new AlertDialog.Builder(mContext).setIconAttribute(android.R.attr.alertDialogIcon).setPositiveButton(android.R.string.ok, new OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
                // The user allowed the service to toggle touch exploration.
                state.mTouchExplorationGrantedServices.add(service.mComponentName);
                persistComponentNamesToSettingLocked(Settings.Secure.TOUCH_EXPLORATION_GRANTED_ACCESSIBILITY_SERVICES, state.mTouchExplorationGrantedServices, state.mUserId);
                // Enable touch exploration.
                UserState userState = getUserStateLocked(service.mUserId);
                userState.mIsTouchExplorationEnabled = true;
                Settings.Secure.putIntForUser(mContext.getContentResolver(), Settings.Secure.TOUCH_EXPLORATION_ENABLED, 1, service.mUserId);
                onUserStateChangedLocked(userState);
            }
        }).setNegativeButton(android.R.string.cancel, new OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
            }
        }).setTitle(R.string.enable_explore_by_touch_warning_title).setMessage(mContext.getString(R.string.enable_explore_by_touch_warning_message, label)).create();
        mEnableTouchExplorationDialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
        mEnableTouchExplorationDialog.getWindow().getAttributes().privateFlags |= WindowManager.LayoutParams.PRIVATE_FLAG_SHOW_FOR_ALL_USERS;
        mEnableTouchExplorationDialog.setCanceledOnTouchOutside(true);
        mEnableTouchExplorationDialog.show();
    }
}
Also used : AlertDialog(android.app.AlertDialog) DialogInterface(android.content.DialogInterface) OnClickListener(android.content.DialogInterface.OnClickListener) Point(android.graphics.Point)

Example 24 with DialogInterface

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

the class DirListActivity method onCreateDialog.

@Override
protected Dialog onCreateDialog(int id, final Bundle args) {
    Dialog dialog = null;
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    switch(id) {
        case DIALOG_RUN_ABORT_DIR:
            builder.setTitle(getText(R.string.dialog_run_abort_dir_title_prefix) + " " + args.getString("name"));
            builder.setMessage(R.string.dialog_run_abort_dir_msg);
            builder.setCancelable(true);
            builder.setPositiveButton(R.string.dialog_run_abort_dir_ok_button, new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    removeDialog(DIALOG_RUN_ABORT_DIR);
                    runAllTestsUnder(args.getString("relativePath"));
                }
            });
            builder.setNegativeButton(R.string.dialog_run_abort_dir_abort_button, new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    removeDialog(DIALOG_RUN_ABORT_DIR);
                }
            });
            dialog = builder.create();
            dialog.setOnCancelListener(new DialogInterface.OnCancelListener() {

                @Override
                public void onCancel(DialogInterface dialog) {
                    removeDialog(DIALOG_RUN_ABORT_DIR);
                }
            });
            break;
    }
    return dialog;
}
Also used : AlertDialog(android.app.AlertDialog) DialogInterface(android.content.DialogInterface) Dialog(android.app.Dialog) ProgressDialog(android.app.ProgressDialog) AlertDialog(android.app.AlertDialog)

Example 25 with DialogInterface

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

the class FileList method onListItemClick.

protected void onListItemClick(ListView l, View v, int position, long id) {
    Map map = (Map) l.getItemAtPosition(position);
    final String path = (String) map.get("path");
    if ((new File(path)).isDirectory()) {
        final CharSequence[] items = { "Open", "Run" };
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle("Select an Action");
        builder.setSingleChoiceItems(items, -1, new DialogInterface.OnClickListener() {

            public void onClick(DialogInterface dialog, int which) {
                switch(which) {
                    case OPEN_DIRECTORY:
                        dialog.dismiss();
                        mPath = path;
                        mFocusFile = null;
                        updateList();
                        break;
                    case RUN_TESTS:
                        dialog.dismiss();
                        processDirectory(path, false);
                        break;
                }
            }
        });
        builder.create().show();
    } else {
        processFile(path, false);
    }
}
Also used : AlertDialog(android.app.AlertDialog) DialogInterface(android.content.DialogInterface) HashMap(java.util.HashMap) Map(java.util.Map) File(java.io.File)

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