From 054fc44cae0d412ca5e72c709f0d5e3deb7768a7 Mon Sep 17 00:00:00 2001 From: satok Date: Tue, 27 Sep 2011 15:46:42 +0900 Subject: [PATCH] Tweak IME settings Change-Id: I13b044abdcb1215306ecfd5070d6e1a16e2d92d7 --- res/layout/preference_inputmethod.xml | 2 +- .../inputmethod/InputMethodPreference.java | 59 +++++++++++-------- 2 files changed, 37 insertions(+), 24 deletions(-) diff --git a/res/layout/preference_inputmethod.xml b/res/layout/preference_inputmethod.xml index f1bd0a0956b..f477a6e3192 100644 --- a/res/layout/preference_inputmethod.xml +++ b/res/layout/preference_inputmethod.xml @@ -61,7 +61,7 @@ android:textAppearance="?android:attr/textAppearanceSmall" android:textSize="13sp" android:textColor="?android:attr/textColorSecondary" - android:background="?android:attr/selectableItemBackground" + android:focusable="false" android:maxLines="4" /> diff --git a/src/com/android/settings/inputmethod/InputMethodPreference.java b/src/com/android/settings/inputmethod/InputMethodPreference.java index 5cc7ad0adb1..4b926e22741 100644 --- a/src/com/android/settings/inputmethod/InputMethodPreference.java +++ b/src/com/android/settings/inputmethod/InputMethodPreference.java @@ -59,6 +59,24 @@ public class InputMethodPreference extends CheckBoxPreference private TextView mSummaryText; private View mInputMethodPref; + private final OnClickListener mPrefOnclickListener = new OnClickListener() { + @Override + public void onClick(View arg0) { + if (!isEnabled()) { + return; + } + if (isChecked()) { + setChecked(false); + } else { + if (mIsSystemIme) { + setChecked(true); + } else { + showSecurityWarnDialog(mImi, InputMethodPreference.this); + } + } + } + }; + public InputMethodPreference(SettingsPreferenceFragment fragment, Intent settingsIntent, InputMethodManager imm, InputMethodInfo imi, int imiCount) { super(fragment.getActivity(), null, R.style.InputMethodPreferenceStyle); @@ -80,36 +98,23 @@ public class InputMethodPreference extends CheckBoxPreference protected void onBindView(View view) { super.onBindView(view); mInputMethodPref = view.findViewById(R.id.inputmethod_pref); - mInputMethodPref.setOnClickListener( - new OnClickListener() { - @Override - public void onClick(View arg0) { - if (isChecked()) { - setChecked(false); - } else { - if (mIsSystemIme) { - setChecked(true); - } else { - showSecurityWarnDialog(mImi, InputMethodPreference.this); - } - } - } - }); + mInputMethodPref.setOnClickListener(mPrefOnclickListener); mInputMethodSettingsButton = (ImageView)view.findViewById(R.id.inputmethod_settings); mTitleText = (TextView)view.findViewById(android.R.id.title); - + mSummaryText = (TextView)view.findViewById(android.R.id.summary); final boolean hasSubtypes = mImi.getSubtypeCount() > 1; final String imiId = mImi.getId(); - mSummaryText = (TextView)view.findViewById(android.R.id.summary); - mSummaryText.setOnClickListener(new OnClickListener() { + mInputMethodPref.setOnLongClickListener(new OnLongClickListener() { @Override - public void onClick(View arg0) { + public boolean onLongClick(View arg0) { final Bundle bundle = new Bundle(); bundle.putString(Settings.EXTRA_INPUT_METHOD_ID, imiId); startFragment(mFragment, InputMethodAndSubtypeEnabler.class.getName(), 0, bundle); + return true; } }); + if (mSettingsIntent != null) { mInputMethodSettingsButton.setOnClickListener( new OnClickListener() { @@ -141,17 +146,17 @@ public class InputMethodPreference extends CheckBoxPreference if (mSettingsIntent == null) { mInputMethodSettingsButton.setVisibility(View.GONE); } else { - enableSettingsButton(); + updatePreferenceViews(); } } @Override public void setEnabled(boolean enabled) { super.setEnabled(enabled); - enableSettingsButton(); + updatePreferenceViews(); } - private void enableSettingsButton() { + private void updatePreferenceViews() { final boolean checked = isChecked(); if (mInputMethodSettingsButton != null) { mInputMethodSettingsButton.setEnabled(checked); @@ -166,7 +171,15 @@ public class InputMethodPreference extends CheckBoxPreference } if (mSummaryText != null) { mSummaryText.setEnabled(checked); - mSummaryText.setClickable(checked); + } + if (mInputMethodPref != null) { + mInputMethodPref.setEnabled(true); + mInputMethodPref.setLongClickable(checked); + final boolean enabled = isEnabled(); + mInputMethodPref.setOnClickListener(enabled ? mPrefOnclickListener : null); + if (!enabled) { + mInputMethodPref.setBackgroundColor(0); + } } }