am 8ae8c761: Cleanup settings

* commit '8ae8c761493867be7364806cdc4d7103a46dc181':
  Cleanup settings
main
Satoshi Kataoka 2012-09-21 17:45:08 -07:00 committed by Android Git Automerger
commit 1d2d36d1ee
5 changed files with 35 additions and 35 deletions

View File

@ -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>

View File

@ -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>

View File

@ -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();

View File

@ -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) {

View File

@ -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,