From cee174b8ccb47ccddc8a8a7e88a9c617f9b5e766 Mon Sep 17 00:00:00 2001
From: Ken Wakasa <kwakasa@google.com>
Date: Mon, 22 Aug 2011 12:19:37 +0900
Subject: [PATCH] Settings key visibility should always follow the system
 default value, by ignoring its preference value, when the "show settings key
 option" in the settings is disabled.

Change-Id: I934be2d9eb0bf6bf731e03f5d9b752de4a7a1c7c
---
 .../keyboard/KeyboardSwitcher.java            |  2 +-
 .../android/inputmethod/latin/Settings.java   | 21 +++++++++++--------
 2 files changed, 13 insertions(+), 10 deletions(-)

diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
index 9937937ff0..10f110e0b9 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
@@ -402,7 +402,7 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
             break;
         }
 
-        final boolean settingsKeyEnabled = settingsValues.isSettingsKeyEnabled(editorInfo);
+        final boolean settingsKeyEnabled = settingsValues.isSettingsKeyEnabled();
         final boolean noMicrophone = Utils.inPrivateImeOptions(
                 mPackageName, LatinIME.IME_OPTION_NO_MICROPHONE, editorInfo)
                 || Utils.inPrivateImeOptions(
diff --git a/java/src/com/android/inputmethod/latin/Settings.java b/java/src/com/android/inputmethod/latin/Settings.java
index 4c2627be32..87a713f5c9 100644
--- a/java/src/com/android/inputmethod/latin/Settings.java
+++ b/java/src/com/android/inputmethod/latin/Settings.java
@@ -53,7 +53,7 @@ import java.util.Locale;
 public class Settings extends InputMethodSettingsActivity
         implements SharedPreferences.OnSharedPreferenceChangeListener,
         DialogInterface.OnDismissListener, OnPreferenceClickListener {
-    private static final String TAG = "Settings";
+    private static final String TAG = Settings.class.getSimpleName();
 
     public static final String PREF_GENERAL_SETTINGS_KEY = "general_settings";
     public static final String PREF_VIBRATE_ON = "vibrate_on";
@@ -182,8 +182,9 @@ public class Settings extends InputMethodSettingsActivity
             mUseContactsDict = prefs.getBoolean(Settings.PREF_KEY_USE_CONTACTS_DICT, true);
             final boolean defaultShowSettingsKey = res.getBoolean(
                     R.bool.config_default_show_settings_key);
-            mShowSettingsKey = prefs.getBoolean(Settings.PREF_SHOW_SETTINGS_KEY,
-                    defaultShowSettingsKey);
+            mShowSettingsKey = isShowSettingsKeyOption(res)
+                    ? prefs.getBoolean(Settings.PREF_SHOW_SETTINGS_KEY, defaultShowSettingsKey)
+                    : defaultShowSettingsKey;
             final String voiceModeMain = res.getString(R.string.voice_mode_main);
             final String voiceModeOff = res.getString(R.string.voice_mode_off);
             final String voiceMode = prefs.getString(PREF_VOICE_SETTINGS_KEY, voiceModeMain);
@@ -292,7 +293,12 @@ public class Settings extends InputMethodSettingsActivity
             return builder.setIsPunctuationSuggestions().build();
         }
 
-        public boolean isSettingsKeyEnabled(EditorInfo attribute) {
+        public static boolean isShowSettingsKeyOption(final Resources resources) {
+            return resources.getBoolean(R.bool.config_enable_show_settings_key_option);
+
+        }
+
+        public boolean isSettingsKeyEnabled() {
             return mShowSettingsKey;
         }
 
@@ -386,9 +392,7 @@ public class Settings extends InputMethodSettingsActivity
         final PreferenceGroup textCorrectionGroup =
                 (PreferenceGroup) findPreference(PREF_CORRECTION_SETTINGS_KEY);
 
-        final boolean showSettingsKeyOption = res.getBoolean(
-                R.bool.config_enable_show_settings_key_option);
-        if (!showSettingsKeyOption) {
+        if (!Values.isShowSettingsKeyOption(res)) {
             generalSettings.removePreference(mShowSettingsKeyPreference);
         }
 
@@ -445,8 +449,7 @@ public class Settings extends InputMethodSettingsActivity
         if (null == mKeyPreviewPopupDismissDelay.getValue()) {
             mKeyPreviewPopupDismissDelay.setValue(popupDismissDelayDefaultValue);
         }
-        mKeyPreviewPopupDismissDelay.setEnabled(
-                Settings.Values.isKeyPreviewPopupEnabled(prefs, res));
+        mKeyPreviewPopupDismissDelay.setEnabled(Values.isKeyPreviewPopupEnabled(prefs, res));
 
         final PreferenceScreen dictionaryLink =
                 (PreferenceScreen) findPreference(PREF_CONFIGURE_DICTIONARIES_KEY);
-- 
GitLab