diff options
author | Tadashi G. Takaoka <takaoka@google.com> | 2014-07-23 10:40:47 -0700 |
---|---|---|
committer | Tadashi G. Takaoka <takaoka@google.com> | 2014-07-27 14:51:18 +0900 |
commit | 990fcb1a6dbb5d1204cc8ec86e4bc3f691f4aeeb (patch) | |
tree | b1761697142c6fa94bcc0714a2ac9d3b455456a2 | |
parent | df9dd39c2047992a43b64e13bb0fc348a1630f3b (diff) | |
download | android_frameworks_opt_inputmethodcommon-stable/cm-12.0-YNG3C.tar.gz android_frameworks_opt_inputmethodcommon-stable/cm-12.0-YNG3C.tar.bz2 android_frameworks_opt_inputmethodcommon-stable/cm-12.0-YNG3C.zip |
Use Intent in preference to invoke subtype enablerHEADreplicant-6.0-0004-transitionreplicant-6.0-0004-rc6replicant-6.0-0004-rc5-transitionreplicant-6.0-0004-rc5replicant-6.0-0004-rc4replicant-6.0-0004-rc3replicant-6.0-0004-rc2replicant-6.0-0004-rc1replicant-6.0-0004replicant-6.0-0003replicant-6.0-0002replicant-6.0-0001staging/cm-14.0staging/cm-12.1staging/cm-12.0-cafstable/cm-13.0-ZNH5Ystable/cm-13.0-ZNH2KBstable/cm-13.0-ZNH2Kstable/cm-13.0-ZNH0Estable/cm-12.1-YOG7Dstable/cm-12.1-YOG4Pstable/cm-12.1-YOG3Cstable/cm-12.0-YNG4Nstable/cm-12.0-YNG3Cstable/cm-12.0-YNG1TAstable/cm-12.0-YNG1Tstable/cm-12.0-YNG1Icm-13.0cm-12.1cm-12.0
This CL also allows resetting a title and an icon of subtype enabler.
Change-Id: I1de10557aeae9d2185ea0560ba8fdd9889248459
-rw-r--r-- | java/com/android/inputmethodcommon/InputMethodSettingsImpl.java | 69 |
1 files changed, 28 insertions, 41 deletions
diff --git a/java/com/android/inputmethodcommon/InputMethodSettingsImpl.java b/java/com/android/inputmethodcommon/InputMethodSettingsImpl.java index 8c209d7..cfa1a65 100644 --- a/java/com/android/inputmethodcommon/InputMethodSettingsImpl.java +++ b/java/com/android/inputmethodcommon/InputMethodSettingsImpl.java @@ -40,7 +40,6 @@ import java.util.List; private Drawable mSubtypeEnablerIcon; private InputMethodManager mImm; private InputMethodInfo mImi; - private Context mContext; /** * Initialize internal states of this object. @@ -49,31 +48,18 @@ import java.util.List; * @return true if this application is an IME and has two or more subtypes, false otherwise. */ public boolean init(final Context context, final PreferenceScreen prefScreen) { - mContext = context; mImm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE); mImi = getMyImi(context, mImm); if (mImi == null || mImi.getSubtypeCount() <= 1) { return false; } + final Intent intent = new Intent(Settings.ACTION_INPUT_METHOD_SUBTYPE_SETTINGS); + intent.putExtra(Settings.EXTRA_INPUT_METHOD_ID, mImi.getId()); + intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK + | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED + | Intent.FLAG_ACTIVITY_CLEAR_TOP); mSubtypeEnablerPreference = new Preference(context); - mSubtypeEnablerPreference - .setOnPreferenceClickListener(new OnPreferenceClickListener() { - @Override - public boolean onPreferenceClick(Preference preference) { - final CharSequence title = getSubtypeEnablerTitle(context); - final Intent intent = - new Intent(Settings.ACTION_INPUT_METHOD_SUBTYPE_SETTINGS); - intent.putExtra(Settings.EXTRA_INPUT_METHOD_ID, mImi.getId()); - if (!TextUtils.isEmpty(title)) { - intent.putExtra(Intent.EXTRA_TITLE, title); - } - intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK - | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED - | Intent.FLAG_ACTIVITY_CLEAR_TOP); - context.startActivity(intent); - return true; - } - }); + mSubtypeEnablerPreference.setIntent(intent); prefScreen.addPreference(mSubtypeEnablerPreference); updateSubtypeEnabler(); return true; @@ -163,30 +149,31 @@ import java.util.List; updateSubtypeEnabler(); } - private CharSequence getSubtypeEnablerTitle(Context context) { + public void updateSubtypeEnabler() { + final Preference pref = mSubtypeEnablerPreference; + if (pref == null) { + return; + } + final Context context = pref.getContext(); + final CharSequence title; if (mSubtypeEnablerTitleRes != 0) { - return context.getString(mSubtypeEnablerTitleRes); + title = context.getString(mSubtypeEnablerTitleRes); } else { - return mSubtypeEnablerTitle; + title = mSubtypeEnablerTitle; } - } - - public void updateSubtypeEnabler() { - if (mSubtypeEnablerPreference != null) { - if (mSubtypeEnablerTitleRes != 0) { - mSubtypeEnablerPreference.setTitle(mSubtypeEnablerTitleRes); - } else if (!TextUtils.isEmpty(mSubtypeEnablerTitle)) { - mSubtypeEnablerPreference.setTitle(mSubtypeEnablerTitle); - } - final String summary = getEnabledSubtypesLabel(mContext, mImm, mImi); - if (!TextUtils.isEmpty(summary)) { - mSubtypeEnablerPreference.setSummary(summary); - } - if (mSubtypeEnablerIconRes != 0) { - mSubtypeEnablerPreference.setIcon(mSubtypeEnablerIconRes); - } else if (mSubtypeEnablerIcon != null) { - mSubtypeEnablerPreference.setIcon(mSubtypeEnablerIcon); - } + pref.setTitle(title); + final Intent intent = pref.getIntent(); + if (intent != null) { + intent.putExtra(Intent.EXTRA_TITLE, title); + } + final String summary = getEnabledSubtypesLabel(context, mImm, mImi); + if (!TextUtils.isEmpty(summary)) { + pref.setSummary(summary); + } + if (mSubtypeEnablerIconRes != 0) { + pref.setIcon(mSubtypeEnablerIconRes); + } else { + pref.setIcon(mSubtypeEnablerIcon); } } } |