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();
}
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();
}
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();
}
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();
}
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();
}
}
Aggregations