From 3c8a075a584018f58225377d0f09e84887a7d2f9 Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" Date: Sun, 27 Jul 2014 15:28:48 +0900 Subject: [PATCH] Use fragment for gesture typing preference screen Bug: 16522808 Change-Id: Ib8c2997466bb006c6b5d4e980344507b822d0023 --- java/res/xml/prefs.xml | 30 +----------- java/res/xml/prefs_screen_gesture.xml | 47 +++++++++++++++++++ .../settings/GestureSettingsFragment.java | 44 +++++++++++++++++ .../latin/settings/SettingsFragment.java | 5 +- .../latin/utils/FragmentUtils.java | 2 + 5 files changed, 96 insertions(+), 32 deletions(-) create mode 100644 java/res/xml/prefs_screen_gesture.xml create mode 100644 java/src/com/android/inputmethod/latin/settings/GestureSettingsFragment.java diff --git a/java/res/xml/prefs.xml b/java/res/xml/prefs.xml index 6493d0cbd..494cdc91d 100644 --- a/java/res/xml/prefs.xml +++ b/java/res/xml/prefs.xml @@ -33,35 +33,9 @@ android:title="@string/settings_screen_multi_lingual" android:key="screen_multi_lingual" /> - - - - - + android:key="screen_gesture" /> diff --git a/java/res/xml/prefs_screen_gesture.xml b/java/res/xml/prefs_screen_gesture.xml new file mode 100644 index 000000000..c87316dfa --- /dev/null +++ b/java/res/xml/prefs_screen_gesture.xml @@ -0,0 +1,47 @@ + + + + + + + + + diff --git a/java/src/com/android/inputmethod/latin/settings/GestureSettingsFragment.java b/java/src/com/android/inputmethod/latin/settings/GestureSettingsFragment.java new file mode 100644 index 000000000..b95c35637 --- /dev/null +++ b/java/src/com/android/inputmethod/latin/settings/GestureSettingsFragment.java @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.inputmethod.latin.settings; + +import android.content.SharedPreferences; +import android.os.Bundle; + +import com.android.inputmethod.latin.R; + +/** + * "Gesture typing preferences" settings sub screen. + * + * This settings sub screen handles the following gesture typing preferences. + * - Enable gesture typing + * - Dynamic floating preview + * - Show gesture trail + * - Phrase gesture + */ +public final class GestureSettingsFragment extends SubScreenFragment { + @Override + public void onCreate(final Bundle icicle) { + super.onCreate(icicle); + addPreferencesFromResource(R.xml.prefs_screen_gesture); + } + + @Override + public void onSharedPreferenceChanged(final SharedPreferences prefs, final String key) { + // Nothing to do here. + } +} diff --git a/java/src/com/android/inputmethod/latin/settings/SettingsFragment.java b/java/src/com/android/inputmethod/latin/settings/SettingsFragment.java index f0bc27972..363cb498d 100644 --- a/java/src/com/android/inputmethod/latin/settings/SettingsFragment.java +++ b/java/src/com/android/inputmethod/latin/settings/SettingsFragment.java @@ -117,8 +117,6 @@ public final class SettingsFragment extends InputMethodSettingsFragment ensureConsistencyOfAutoCorrectionSettings(); - final PreferenceScreen gestureScreen = - (PreferenceScreen) findPreference(Settings.SCREEN_GESTURE); final PreferenceScreen correctionScreen = (PreferenceScreen) findPreference(Settings.SCREEN_CORRECTION); final PreferenceScreen advancedScreen = @@ -196,7 +194,7 @@ public final class SettingsFragment extends InputMethodSettingsFragment } if (!Settings.readFromBuildConfigIfGestureInputEnabled(res)) { - getPreferenceScreen().removePreference(gestureScreen); + getPreferenceScreen().removePreference(findPreference(Settings.SCREEN_GESTURE)); } AdditionalFeaturesSettingUtils.addAdditionalFeaturesPreferences(context, this); @@ -210,7 +208,6 @@ public final class SettingsFragment extends InputMethodSettingsFragment public void onResume() { super.onResume(); final SharedPreferences prefs = getPreferenceManager().getSharedPreferences(); - final Resources res = getResources(); final TwoStatePreference showSetupWizardIcon = (TwoStatePreference)findPreference(Settings.PREF_SHOW_SETUP_WIZARD_ICON); if (showSetupWizardIcon != null) { diff --git a/java/src/com/android/inputmethod/latin/utils/FragmentUtils.java b/java/src/com/android/inputmethod/latin/utils/FragmentUtils.java index a44c5764a..002231aea 100644 --- a/java/src/com/android/inputmethod/latin/utils/FragmentUtils.java +++ b/java/src/com/android/inputmethod/latin/utils/FragmentUtils.java @@ -20,6 +20,7 @@ import com.android.inputmethod.dictionarypack.DictionarySettingsFragment; import com.android.inputmethod.latin.about.AboutPreferences; import com.android.inputmethod.latin.settings.CustomInputStyleSettingsFragment; import com.android.inputmethod.latin.settings.DebugSettings; +import com.android.inputmethod.latin.settings.GestureSettingsFragment; import com.android.inputmethod.latin.settings.InputSettingsFragment; import com.android.inputmethod.latin.settings.MultiLingualSettingsFragment; import com.android.inputmethod.latin.settings.SettingsFragment; @@ -39,6 +40,7 @@ public class FragmentUtils { sLatinImeFragments.add(InputSettingsFragment.class.getName()); sLatinImeFragments.add(MultiLingualSettingsFragment.class.getName()); sLatinImeFragments.add(CustomInputStyleSettingsFragment.class.getName()); + sLatinImeFragments.add(GestureSettingsFragment.class.getName()); sLatinImeFragments.add(DebugSettings.class.getName()); sLatinImeFragments.add(SettingsFragment.class.getName()); sLatinImeFragments.add(SpellCheckerSettingsFragment.class.getName());