aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/latin/settings/SettingsFragment.java
diff options
context:
space:
mode:
authorTadashi G. Takaoka <takaoka@google.com>2014-07-29 15:33:40 +0900
committerTadashi G. Takaoka <takaoka@google.com>2014-07-29 18:19:20 +0900
commita715d7f6fd3b29e660d78f83815ebe75837f1436 (patch)
treee756589e0aa0408699a5ff1e82bfbae6c40ed143 /java/src/com/android/inputmethod/latin/settings/SettingsFragment.java
parent6c39db9f725b50177ce3bf5bd4ce38ff074fe0da (diff)
downloadlatinime-a715d7f6fd3b29e660d78f83815ebe75837f1436.tar.gz
latinime-a715d7f6fd3b29e660d78f83815ebe75837f1436.tar.xz
latinime-a715d7f6fd3b29e660d78f83815ebe75837f1436.zip
Use fragment for keyboard theme settings
Bug: 11866784 Change-Id: Ic50b6eb1bd8f2b823e2c9dfad04d8615bc910936
Diffstat (limited to 'java/src/com/android/inputmethod/latin/settings/SettingsFragment.java')
-rw-r--r--java/src/com/android/inputmethod/latin/settings/SettingsFragment.java87
1 files changed, 2 insertions, 85 deletions
diff --git a/java/src/com/android/inputmethod/latin/settings/SettingsFragment.java b/java/src/com/android/inputmethod/latin/settings/SettingsFragment.java
index 93645203b..6734a9ce6 100644
--- a/java/src/com/android/inputmethod/latin/settings/SettingsFragment.java
+++ b/java/src/com/android/inputmethod/latin/settings/SettingsFragment.java
@@ -16,47 +16,23 @@
package com.android.inputmethod.latin.settings;
-import android.app.Activity;
-import android.app.backup.BackupManager;
-import android.content.Context;
import android.content.Intent;
-import android.content.SharedPreferences;
-import android.content.res.Resources;
import android.os.Bundle;
-import android.preference.ListPreference;
import android.preference.PreferenceScreen;
-import android.util.Log;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
-import com.android.inputmethod.keyboard.KeyboardTheme;
-import com.android.inputmethod.latin.AudioAndHapticFeedbackManager;
import com.android.inputmethod.latin.R;
import com.android.inputmethod.latin.utils.ApplicationUtils;
import com.android.inputmethod.latin.utils.FeedbackUtils;
import com.android.inputmethodcommon.InputMethodSettingsFragment;
-public final class SettingsFragment extends InputMethodSettingsFragment
- implements SharedPreferences.OnSharedPreferenceChangeListener {
- private static final String TAG = SettingsFragment.class.getSimpleName();
-
+public final class SettingsFragment extends InputMethodSettingsFragment {
private static final int NO_MENU_GROUP = Menu.NONE; // We don't care about menu grouping.
private static final int MENU_FEEDBACK = Menu.FIRST; // The first menu item id and order.
private static final int MENU_ABOUT = Menu.FIRST + 1; // The second menu item id and order.
- private void updateListPreferenceSummaryToCurrentValue(final String prefKey) {
- // Because the "%s" summary trick of {@link ListPreference} doesn't work properly before
- // KitKat, we need to update the summary programmatically.
- final ListPreference listPreference = (ListPreference)findPreference(prefKey);
- if (listPreference == null) {
- return;
- }
- final CharSequence entries[] = listPreference.getEntries();
- final int entryIndex = listPreference.findIndexOfValue(listPreference.getValue());
- listPreference.setSummary(entryIndex < 0 ? null : entries[entryIndex]);
- }
-
@Override
public void onCreate(final Bundle icicle) {
super.onCreate(icicle);
@@ -65,73 +41,14 @@ public final class SettingsFragment extends InputMethodSettingsFragment
setSubtypeEnablerTitle(R.string.select_language);
addPreferencesFromResource(R.xml.prefs);
final PreferenceScreen preferenceScreen = getPreferenceScreen();
- TwoStatePreferenceHelper.replaceCheckBoxPreferencesBySwitchPreferences(preferenceScreen);
preferenceScreen.setTitle(
ApplicationUtils.getActivityTitleResId(getActivity(), SettingsActivity.class));
-
- final Resources res = getResources();
- final Context context = getActivity();
-
- // When we are called from the Settings application but we are not already running, some
- // singleton and utility classes may not have been initialized. We have to call
- // initialization method of these classes here. See {@link LatinIME#onCreate()}.
- AudioAndHapticFeedbackManager.init(context);
-
- final SharedPreferences prefs = getPreferenceManager().getSharedPreferences();
- prefs.registerOnSharedPreferenceChangeListener(this);
-
- if (!Settings.readFromBuildConfigIfGestureInputEnabled(res)) {
- getPreferenceScreen().removePreference(findPreference(Settings.SCREEN_GESTURE));
- }
-
- AdditionalFeaturesSettingUtils.addAdditionalFeaturesPreferences(context, this);
}
@Override
public void onResume() {
super.onResume();
- final SharedPreferences prefs = getPreferenceManager().getSharedPreferences();
- final ListPreference keyboardThemePref = (ListPreference)findPreference(
- Settings.PREF_KEYBOARD_THEME);
- if (keyboardThemePref != null) {
- final KeyboardTheme keyboardTheme = KeyboardTheme.getKeyboardTheme(prefs);
- final String value = Integer.toString(keyboardTheme.mThemeId);
- final CharSequence entries[] = keyboardThemePref.getEntries();
- final int entryIndex = keyboardThemePref.findIndexOfValue(value);
- keyboardThemePref.setSummary(entryIndex < 0 ? null : entries[entryIndex]);
- keyboardThemePref.setValue(value);
- }
- }
-
- @Override
- public void onPause() {
- super.onPause();
- final SharedPreferences prefs = getPreferenceManager().getSharedPreferences();
- final ListPreference keyboardThemePref = (ListPreference)findPreference(
- Settings.PREF_KEYBOARD_THEME);
- if (keyboardThemePref != null) {
- KeyboardTheme.saveKeyboardThemeId(keyboardThemePref.getValue(), prefs);
- }
- }
-
- @Override
- public void onDestroy() {
- getPreferenceManager().getSharedPreferences().unregisterOnSharedPreferenceChangeListener(
- this);
- super.onDestroy();
- }
-
- @Override
- public void onSharedPreferenceChanged(final SharedPreferences prefs, final String key) {
- final Activity activity = getActivity();
- if (activity == null) {
- // TODO: Introduce a static function to register this class and ensure that
- // onCreate must be called before "onSharedPreferenceChanged" is called.
- Log.w(TAG, "onSharedPreferenceChanged called before activity starts.");
- return;
- }
- (new BackupManager(activity)).dataChanged();
- updateListPreferenceSummaryToCurrentValue(Settings.PREF_KEYBOARD_THEME);
+ ThemeSettingsFragment.updateKeyboardThemeSummary(findPreference(Settings.SCREEN_THEME));
}
@Override