Search in sources :

Example 61 with OnClickListener

use of android.content.DialogInterface.OnClickListener in project AndroidChromium by JackyAndroid.

the class ExternalNavigationDelegateImpl method startIncognitoIntent.

@Override
public void startIncognitoIntent(final Intent intent, final String referrerUrl, final String fallbackUrl, final Tab tab, final boolean needsToCloseTab, final boolean proxy) {
    Context context = tab.getWindowAndroid().getContext().get();
    if (!(context instanceof Activity))
        return;
    Activity activity = (Activity) context;
    new AlertDialog.Builder(activity, R.style.AlertDialogTheme).setTitle(R.string.external_app_leave_incognito_warning_title).setMessage(R.string.external_app_leave_incognito_warning).setPositiveButton(R.string.ok, new OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            startActivity(intent, proxy);
            if (tab != null && !tab.isClosing() && tab.isInitialized() && needsToCloseTab) {
                closeTab(tab);
            }
        }
    }).setNegativeButton(R.string.cancel, new OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            loadIntent(intent, referrerUrl, fallbackUrl, tab, needsToCloseTab, true);
        }
    }).setOnCancelListener(new OnCancelListener() {

        @Override
        public void onCancel(DialogInterface dialog) {
            loadIntent(intent, referrerUrl, fallbackUrl, tab, needsToCloseTab, true);
        }
    }).show();
}
Also used : Context(android.content.Context) DialogInterface(android.content.DialogInterface) ChromeActivity(org.chromium.chrome.browser.ChromeActivity) WebappActivity(org.chromium.chrome.browser.webapps.WebappActivity) ChromeLauncherActivity(org.chromium.chrome.browser.document.ChromeLauncherActivity) AuthenticatedProxyActivity(org.chromium.chrome.browser.instantapps.AuthenticatedProxyActivity) Activity(android.app.Activity) OnClickListener(android.content.DialogInterface.OnClickListener) OnCancelListener(android.content.DialogInterface.OnCancelListener)

Example 62 with OnClickListener

use of android.content.DialogInterface.OnClickListener in project android_frameworks_base by crdroidandroid.

the class TunerService method showResetRequest.

public static final void showResetRequest(final Context context, final Runnable onDisabled) {
    SystemUIDialog dialog = new SystemUIDialog(context);
    dialog.setShowForAllUsers(true);
    dialog.setMessage(R.string.remove_from_settings_prompt);
    dialog.setButton(DialogInterface.BUTTON_NEGATIVE, context.getString(R.string.cancel), (OnClickListener) null);
    dialog.setButton(DialogInterface.BUTTON_POSITIVE, context.getString(R.string.guest_exit_guest_dialog_remove), new OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            // Tell the tuner (in main SysUI process) to clear all its settings.
            context.sendBroadcast(new Intent(TunerService.ACTION_CLEAR));
            // Disable access to tuner.
            TunerService.setTunerEnabled(context, false);
            // Make them sit through the warning dialog again.
            Settings.Secure.putInt(context.getContentResolver(), TunerFragment.SETTING_SEEN_TUNER_WARNING, 0);
            if (onDisabled != null) {
                onDisabled.run();
            }
        }
    });
    dialog.show();
}
Also used : SystemUIDialog(com.android.systemui.statusbar.phone.SystemUIDialog) DialogInterface(android.content.DialogInterface) OnClickListener(android.content.DialogInterface.OnClickListener) Intent(android.content.Intent)

Example 63 with OnClickListener

use of android.content.DialogInterface.OnClickListener in project android_frameworks_base by crdroidandroid.

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 64 with OnClickListener

use of android.content.DialogInterface.OnClickListener in project android_frameworks_base by AOSPA.

the class TunerService method showResetRequest.

public static final void showResetRequest(final Context context, final Runnable onDisabled) {
    SystemUIDialog dialog = new SystemUIDialog(context);
    dialog.setShowForAllUsers(true);
    dialog.setMessage(R.string.remove_from_settings_prompt);
    dialog.setButton(DialogInterface.BUTTON_NEGATIVE, context.getString(R.string.cancel), (OnClickListener) null);
    dialog.setButton(DialogInterface.BUTTON_POSITIVE, context.getString(R.string.guest_exit_guest_dialog_remove), new OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            // Tell the tuner (in main SysUI process) to clear all its settings.
            context.sendBroadcast(new Intent(TunerService.ACTION_CLEAR));
            // Disable access to tuner.
            TunerService.setTunerEnabled(context, false);
            // Make them sit through the warning dialog again.
            Settings.Secure.putInt(context.getContentResolver(), TunerFragment.SETTING_SEEN_TUNER_WARNING, 0);
            if (onDisabled != null) {
                onDisabled.run();
            }
        }
    });
    dialog.show();
}
Also used : SystemUIDialog(com.android.systemui.statusbar.phone.SystemUIDialog) DialogInterface(android.content.DialogInterface) OnClickListener(android.content.DialogInterface.OnClickListener) Intent(android.content.Intent)

Example 65 with OnClickListener

use of android.content.DialogInterface.OnClickListener in project android_frameworks_base by AOSPA.

the class InputMethodManagerService method showInputMethodMenu.

private void showInputMethodMenu(boolean showAuxSubtypes) {
    if (DEBUG)
        Slog.v(TAG, "Show switching menu. showAuxSubtypes=" + showAuxSubtypes);
    final Context context = mContext;
    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 = mSettings.getExplicitlyOrImplicitlyEnabledInputMethodsAndSubtypeListLocked(mContext);
        if (immis == null || immis.size() == 0) {
            return;
        }
        hideInputMethodMenuLocked();
        final List<ImeSubtypeListItem> imList = mSwitchingController.getSortedInputMethodAndSubtypeListLocked(showAuxSubtypes, 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 Context settingsContext = new ContextThemeWrapper(context, com.android.internal.R.style.Theme_DeviceDefault_Settings);
        mDialogBuilder = new AlertDialog.Builder(settingsContext);
        mDialogBuilder.setOnCancelListener(new OnCancelListener() {

            @Override
            public void onCancel(DialogInterface dialog) {
                hideInputMethodMenu();
            }
        });
        final Context dialogContext = mDialogBuilder.getContext();
        final TypedArray a = dialogContext.obtainStyledAttributes(null, com.android.internal.R.styleable.DialogPreference, com.android.internal.R.attr.alertDialogStyle, 0);
        final Drawable dialogIcon = a.getDrawable(com.android.internal.R.styleable.DialogPreference_dialogIcon);
        a.recycle();
        mDialogBuilder.setIcon(dialogIcon);
        final LayoutInflater inflater = dialogContext.getSystemService(LayoutInflater.class);
        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(mWindowManagerInternal.isHardKeyboardAvailable() ? View.VISIBLE : View.GONE);
        final Switch hardKeySwitch = (Switch) mSwitchingDialogTitleView.findViewById(com.android.internal.R.id.hard_keyboard_switch);
        hardKeySwitch.setChecked(mShowImeWithHardKeyboard);
        hardKeySwitch.setOnCheckedChangeListener(new OnCheckedChangeListener() {

            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                mSettings.setShowImeWithHardKeyboard(isChecked);
                // Ensure that the input method dialog is dismissed when changing
                // the hardware keyboard state.
                hideInputMethodMenu();
            }
        });
        final ImeSubtypeListAdapter adapter = new ImeSubtypeListAdapter(dialogContext, com.android.internal.R.layout.input_method_switch_item, imList, checkedItem);
        final OnClickListener choiceListener = new OnClickListener() {

            @Override
            public void onClick(final DialogInterface dialog, final int which) {
                synchronized (mMethodMap) {
                    if (mIms == null || mIms.length <= which || mSubtypeIds == null || mSubtypeIds.length <= which) {
                        return;
                    }
                    final 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);
                    }
                }
            }
        };
        mDialogBuilder.setSingleChoiceItems(adapter, checkedItem, choiceListener);
        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");
        updateSystemUi(mCurToken, mImeWindowVis, mBackDisposition);
        mSwitchingDialog.show();
    }
}
Also used : AlertDialog(android.app.AlertDialog) DialogInterface(android.content.DialogInterface) InputMethodInfo(android.view.inputmethod.InputMethodInfo) TypedArray(android.content.res.TypedArray) ArrayList(java.util.ArrayList) List(java.util.List) LocaleList(android.os.LocaleList) OnCancelListener(android.content.DialogInterface.OnCancelListener) IInputContext(com.android.internal.view.IInputContext) Context(android.content.Context) InputMethodSubtype(android.view.inputmethod.InputMethodSubtype) OnCheckedChangeListener(android.widget.CompoundButton.OnCheckedChangeListener) Drawable(android.graphics.drawable.Drawable) View(android.view.View) TextView(android.widget.TextView) ImeSubtypeListItem(com.android.internal.inputmethod.InputMethodSubtypeSwitchingController.ImeSubtypeListItem) ContextThemeWrapper(android.view.ContextThemeWrapper) Switch(android.widget.Switch) LayoutInflater(android.view.LayoutInflater) OnClickListener(android.content.DialogInterface.OnClickListener) CompoundButton(android.widget.CompoundButton)

Aggregations

OnClickListener (android.content.DialogInterface.OnClickListener)264 DialogInterface (android.content.DialogInterface)259 AlertDialog (android.app.AlertDialog)161 View (android.view.View)75 TextView (android.widget.TextView)52 Intent (android.content.Intent)44 SuppressLint (android.annotation.SuppressLint)41 Context (android.content.Context)35 AlertDialog (android.support.v7.app.AlertDialog)32 LayoutInflater (android.view.LayoutInflater)30 EditText (android.widget.EditText)30 Activity (android.app.Activity)27 Bundle (android.os.Bundle)25 OnCancelListener (android.content.DialogInterface.OnCancelListener)21 ImageView (android.widget.ImageView)17 Builder (android.app.AlertDialog.Builder)16 Dialog (android.app.Dialog)16 ProgressDialog (android.app.ProgressDialog)15 Paint (android.graphics.Paint)15 AdapterView (android.widget.AdapterView)15