From 229ed1a784a78a713908a0f452238c7345920aaf Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" Date: Mon, 21 Jul 2014 14:17:47 -0700 Subject: [PATCH] Remove unused and unnecessary code from subtype enabler Change-Id: I9935b5bda8ae7cd1ce2d20ee6c4622eeb9a02b6a --- .../InputMethodAndSubtypeEnabler.java | 71 ------------------- 1 file changed, 71 deletions(-) diff --git a/src/com/android/settings/inputmethod/InputMethodAndSubtypeEnabler.java b/src/com/android/settings/inputmethod/InputMethodAndSubtypeEnabler.java index d14d08b5609..4019bb4ed63 100644 --- a/src/com/android/settings/inputmethod/InputMethodAndSubtypeEnabler.java +++ b/src/com/android/settings/inputmethod/InputMethodAndSubtypeEnabler.java @@ -16,9 +16,7 @@ package com.android.settings.inputmethod; -import android.app.AlertDialog; import android.content.Context; -import android.content.DialogInterface; import android.content.Intent; import android.content.pm.PackageManager; import android.content.res.Configuration; @@ -32,7 +30,6 @@ import android.view.inputmethod.InputMethodInfo; import android.view.inputmethod.InputMethodManager; import android.view.inputmethod.InputMethodSubtype; -import com.android.internal.inputmethod.InputMethodUtils; import com.android.settings.R; import com.android.settings.SettingsPreferenceFragment; @@ -52,7 +49,6 @@ public class InputMethodAndSubtypeEnabler extends SettingsPreferenceFragment { // TODO: Change mInputMethodInfoList to Map private List mInputMethodInfoList; private Collator mCollator; - private AlertDialog mDialog = null; @Override public void onCreate(final Bundle icicle) { @@ -142,82 +138,15 @@ public class InputMethodAndSubtypeEnabler extends SettingsPreferenceFragment { } } - final String id = chkPref.getKey(); // Turns off a subtype. if (!chkPref.isChecked()) { - // TODO: Because no preference on this screen has {@link InputMethodInfo} id as a key, - // the following setSubtypesPreferenceEnabled call is effectively no-operation and - // can be removed. - InputMethodAndSubtypeUtil.setSubtypesPreferenceEnabled( - this, mInputMethodInfoList, id, false); updateAutoSelectionPreferences(); return super.onPreferenceTreeClick(preferenceScreen, preference); } - // Turns on a subtype. - final InputMethodInfo imi = getInputMethodInfoById(id); - // TODO: Because no preference on this screen has {@link InputMethodInfo} id as a key, - // imi is always null and the following code can be removed. - if (imi == null) { - return super.onPreferenceTreeClick(preferenceScreen, preference); - } - // Turns on a system IME's subtype. - if (InputMethodUtils.isSystemIme(imi)) { - InputMethodAndSubtypeUtil.setSubtypesPreferenceEnabled( - this, mInputMethodInfoList, id, true); - // This is a built-in IME, so no need to warn. - return super.onPreferenceTreeClick(preferenceScreen, preference); - } - // Turns on a 3rd party IME's subtype. - // Turns off a subtype before showing a security warning dialog. - chkPref.setChecked(false); - if (mDialog != null && mDialog.isShowing()) { - mDialog.dismiss(); - } - final AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); - builder.setCancelable(true); - builder.setTitle(android.R.string.dialog_alert_title); - final CharSequence label = imi.getServiceInfo().applicationInfo - .loadLabel(getPackageManager()); - builder.setMessage(getString(R.string.ime_security_warning, label)); - builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { - @Override - public void onClick(final DialogInterface dialog, final int which) { - // The user explicitly enable the subtype. - chkPref.setChecked(true); - InputMethodAndSubtypeUtil.setSubtypesPreferenceEnabled( - InputMethodAndSubtypeEnabler.this, mInputMethodInfoList, id, true); - } - }); - builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { - @Override - public void onClick(final DialogInterface dialog, final int which) {} - }); - mDialog = builder.create(); - mDialog.show(); return super.onPreferenceTreeClick(preferenceScreen, preference); } - private InputMethodInfo getInputMethodInfoById(final String imiId) { - final int imiCount = mInputMethodInfoList.size(); - for (int index = 0; index < imiCount; ++index) { - final InputMethodInfo imi = mInputMethodInfoList.get(index); - if (imi.getId().equals(imiId)) { - return imi; - } - } - return null; - } - - @Override - public void onDestroy() { - super.onDestroy(); - if (mDialog != null) { - mDialog.dismiss(); - mDialog = null; - } - } - private void addInputMethodSubtypePreferences(final InputMethodInfo imi, final PreferenceScreen root) { final Context context = getActivity();