From 8ae8c761493867be7364806cdc4d7103a46dc181 Mon Sep 17 00:00:00 2001
From: Satoshi Kataoka <satok@google.com>
Date: Fri, 21 Sep 2012 15:09:47 +0900
Subject: [PATCH] Cleanup settings

bug: 7200189

Change-Id: Ibfd9254670cde5f4b2b693cc9334ee2845bede59
---
 java/res/xml/prefs.xml                        | 10 ++---
 java/res/xml/prefs_for_debug.xml              |  6 +++
 .../inputmethod/latin/DebugSettings.java      | 11 +++++
 .../android/inputmethod/latin/Settings.java   | 41 ++++++-------------
 .../inputmethod/latin/SettingsValues.java     |  2 +-
 5 files changed, 35 insertions(+), 35 deletions(-)

diff --git a/java/res/xml/prefs.xml b/java/res/xml/prefs.xml
index 3e83fc0fc..478dc0f80 100644
--- a/java/res/xml/prefs.xml
+++ b/java/res/xml/prefs.xml
@@ -92,11 +92,6 @@
             android:summary="@string/gesture_input_summary"
             android:persistent="true"
             android:defaultValue="true" />
-        <CheckBoxPreference
-            android:key="usability_study_mode"
-            android:title="@string/prefs_usability_study_mode"
-            android:persistent="true"
-            android:defaultValue="false" />
         <PreferenceScreen
             android:key="pref_advanced_settings"
             android:title="@string/advanced_settings"
@@ -145,5 +140,10 @@
                 android:persistent="true"
                 android:defaultValue="false" />
         </PreferenceScreen>
+        <PreferenceScreen
+            android:key="debug_settings"
+            android:title="Debug settings"
+            android:persistent="true"
+            android:defaultValue="false" />
     </PreferenceCategory>
 </PreferenceScreen>
diff --git a/java/res/xml/prefs_for_debug.xml b/java/res/xml/prefs_for_debug.xml
index b926ed065..605a02f07 100644
--- a/java/res/xml/prefs_for_debug.xml
+++ b/java/res/xml/prefs_for_debug.xml
@@ -48,4 +48,10 @@
             android:persistent="true"
             android:defaultValue="false"
             />
+
+    <CheckBoxPreference
+            android:key="usability_study_mode"
+            android:title="@string/prefs_usability_study_mode"
+            android:persistent="true"
+            android:defaultValue="false" />
 </PreferenceScreen>
diff --git a/java/src/com/android/inputmethod/latin/DebugSettings.java b/java/src/com/android/inputmethod/latin/DebugSettings.java
index af7649863..1ea14dad5 100644
--- a/java/src/com/android/inputmethod/latin/DebugSettings.java
+++ b/java/src/com/android/inputmethod/latin/DebugSettings.java
@@ -23,10 +23,12 @@ import android.content.pm.PackageManager.NameNotFoundException;
 import android.os.Bundle;
 import android.os.Process;
 import android.preference.CheckBoxPreference;
+import android.preference.Preference;
 import android.preference.PreferenceFragment;
 import android.util.Log;
 
 import com.android.inputmethod.keyboard.KeyboardSwitcher;
+import com.android.inputmethod.research.ResearchLogger;
 
 public class DebugSettings extends PreferenceFragment
         implements SharedPreferences.OnSharedPreferenceChangeListener {
@@ -34,6 +36,7 @@ public class DebugSettings extends PreferenceFragment
     private static final String TAG = DebugSettings.class.getSimpleName();
     private static final String DEBUG_MODE_KEY = "debug_mode";
     public static final String FORCE_NON_DISTINCT_MULTITOUCH_KEY = "force_non_distinct_multitouch";
+    public static final String PREF_USABILITY_STUDY_MODE = "usability_study_mode";
 
     private boolean mServiceNeedsRestart = false;
     private CheckBoxPreference mDebugMode;
@@ -45,6 +48,14 @@ public class DebugSettings extends PreferenceFragment
         SharedPreferences prefs = getPreferenceManager().getSharedPreferences();
         prefs.registerOnSharedPreferenceChangeListener(this);
 
+        final Preference usabilityStudyPref = findPreference(PREF_USABILITY_STUDY_MODE);
+        if (usabilityStudyPref instanceof CheckBoxPreference) {
+            final CheckBoxPreference checkbox = (CheckBoxPreference)usabilityStudyPref;
+            checkbox.setChecked(prefs.getBoolean(PREF_USABILITY_STUDY_MODE,
+                    ResearchLogger.DEFAULT_USABILITY_STUDY_MODE));
+            checkbox.setSummary(R.string.settings_warning_researcher_mode);
+        }
+
         mServiceNeedsRestart = false;
         mDebugMode = (CheckBoxPreference) findPreference(DEBUG_MODE_KEY);
         updateDebugMode();
diff --git a/java/src/com/android/inputmethod/latin/Settings.java b/java/src/com/android/inputmethod/latin/Settings.java
index 9479a88a7..b984ec367 100644
--- a/java/src/com/android/inputmethod/latin/Settings.java
+++ b/java/src/com/android/inputmethod/latin/Settings.java
@@ -39,12 +39,10 @@ import android.widget.SeekBar.OnSeekBarChangeListener;
 import android.widget.TextView;
 
 import com.android.inputmethod.latin.define.ProductionFlag;
-import com.android.inputmethod.research.ResearchLogger;
 import com.android.inputmethodcommon.InputMethodSettingsFragment;
 
 public final class Settings extends InputMethodSettingsFragment
         implements SharedPreferences.OnSharedPreferenceChangeListener {
-    public static final boolean ENABLE_INTERNAL_SETTINGS = ProductionFlag.IS_INTERNAL;
 
     // In the same order as xml/prefs.xml
     public static final String PREF_GENERAL_SETTINGS = "general_settings";
@@ -58,7 +56,6 @@ public final class Settings extends InputMethodSettingsFragment
     public static final String PREF_AUTO_CORRECTION_THRESHOLD = "auto_correction_threshold";
     public static final String PREF_SHOW_SUGGESTIONS_SETTING = "show_suggestions_setting";
     public static final String PREF_MISC_SETTINGS = "misc_settings";
-    public static final String PREF_USABILITY_STUDY_MODE = "usability_study_mode";
     public static final String PREF_LAST_USER_DICTIONARY_WRITE_TIME =
             "last_user_dictionary_write_time";
     public static final String PREF_ADVANCED_SETTINGS = "pref_advanced_settings";
@@ -133,14 +130,6 @@ public final class Settings extends InputMethodSettingsFragment
         mAutoCorrectionThresholdPreference =
                 (ListPreference) findPreference(PREF_AUTO_CORRECTION_THRESHOLD);
         mBigramPrediction = (CheckBoxPreference) findPreference(PREF_BIGRAM_PREDICTIONS);
-        mDebugSettingsPreference = findPreference(PREF_DEBUG_SETTINGS);
-        if (mDebugSettingsPreference != null) {
-            final Intent debugSettingsIntent = new Intent(Intent.ACTION_MAIN);
-            debugSettingsIntent.setClassName(
-                    context.getPackageName(), DebugSettings.class.getName());
-            mDebugSettingsPreference.setIntent(debugSettingsIntent);
-        }
-
         ensureConsistencyOfAutoCorrectionSettings();
 
         final PreferenceGroup generalSettings =
@@ -150,6 +139,18 @@ public final class Settings extends InputMethodSettingsFragment
         final PreferenceGroup miscSettings =
                 (PreferenceGroup) findPreference(PREF_MISC_SETTINGS);
 
+        mDebugSettingsPreference = findPreference(PREF_DEBUG_SETTINGS);
+        if (mDebugSettingsPreference != null) {
+            if (ProductionFlag.IS_INTERNAL) {
+                final Intent debugSettingsIntent = new Intent(Intent.ACTION_MAIN);
+                debugSettingsIntent.setClassName(
+                        context.getPackageName(), DebugSettingsActivity.class.getName());
+                mDebugSettingsPreference.setIntent(debugSettingsIntent);
+            } else {
+                miscSettings.removePreference(mDebugSettingsPreference);
+            }
+        }
+
         final boolean showVoiceKeyOption = res.getBoolean(
                 R.bool.config_enable_show_voice_key_option);
         if (!showVoiceKeyOption) {
@@ -218,24 +219,6 @@ public final class Settings extends InputMethodSettingsFragment
             setPreferenceEnabled(gestureFloatingPreviewText, gestureInputEnabledByUser);
         }
 
-        final boolean showUsabilityStudyModeOption =
-                res.getBoolean(R.bool.config_enable_usability_study_mode_option)
-                        || ProductionFlag.IS_EXPERIMENTAL || ENABLE_INTERNAL_SETTINGS;
-        final Preference usabilityStudyPref = findPreference(PREF_USABILITY_STUDY_MODE);
-        if (!showUsabilityStudyModeOption) {
-            if (usabilityStudyPref != null) {
-                miscSettings.removePreference(usabilityStudyPref);
-            }
-        }
-        if (ProductionFlag.IS_EXPERIMENTAL) {
-            if (usabilityStudyPref instanceof CheckBoxPreference) {
-                CheckBoxPreference checkbox = (CheckBoxPreference)usabilityStudyPref;
-                checkbox.setChecked(prefs.getBoolean(PREF_USABILITY_STUDY_MODE,
-                        ResearchLogger.DEFAULT_USABILITY_STUDY_MODE));
-                checkbox.setSummary(R.string.settings_warning_researcher_mode);
-            }
-        }
-
         mKeypressVibrationDurationSettingsPref =
                 (PreferenceScreen) findPreference(PREF_VIBRATION_DURATION_SETTINGS);
         if (mKeypressVibrationDurationSettingsPref != null) {
diff --git a/java/src/com/android/inputmethod/latin/SettingsValues.java b/java/src/com/android/inputmethod/latin/SettingsValues.java
index 9d8379a7a..5b8f1cfb4 100644
--- a/java/src/com/android/inputmethod/latin/SettingsValues.java
+++ b/java/src/com/android/inputmethod/latin/SettingsValues.java
@@ -410,7 +410,7 @@ public final class SettingsValues {
     // Likewise
     public static boolean getUsabilityStudyMode(final SharedPreferences prefs) {
         // TODO: use mUsabilityStudyMode instead of reading it again here
-        return prefs.getBoolean(Settings.PREF_USABILITY_STUDY_MODE, true);
+        return prefs.getBoolean(DebugSettings.PREF_USABILITY_STUDY_MODE, true);
     }
 
     public static long getLastUserHistoryWriteTime(final SharedPreferences prefs,