From 3a90cb9ad00150b1a557c67c280eba296cebc625 Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" Date: Fri, 12 Sep 2014 12:24:32 +0900 Subject: [PATCH] Reorganize settings in Google Keyboard Changes : Input languages -> Languages Input preferences -> Preferences Multi lingual Options -> Multilingual Options Keyboard Theme -> Theme Gesture typing preferences -> Gesture typing **New Appearance -> Theme -> Custom input style **Removed Multilingual options from L dynamically Bug: 11866784 Change-Id: I07404c27868e1b087b0cafb63d2031a5b493a885 --- java/res/values/strings.xml | 18 ++++---- java/res/xml/prefs.xml | 16 +++---- java/res/xml/prefs_screen_appearance.xml | 29 +++++++++++++ ...gual.xml => prefs_screen_multilingual.xml} | 8 +--- ...input.xml => prefs_screen_preferences.xml} | 2 +- java/res/xml/prefs_screen_theme.xml | 2 +- .../settings/AppearanceSettingsFragment.java | 41 ++++++++++++++++++ .../CustomInputStyleSettingsFragment.java | 20 +++++++++ .../MultiLingualSettingsFragment.java | 43 +------------------ ....java => PreferencesSettingsFragment.java} | 6 +-- .../inputmethod/latin/settings/Settings.java | 8 +++- .../latin/settings/SettingsFragment.java | 11 +++-- .../latin/utils/FragmentUtils.java | 6 ++- 13 files changed, 132 insertions(+), 78 deletions(-) create mode 100644 java/res/xml/prefs_screen_appearance.xml rename java/res/xml/{prefs_screen_multi_lingual.xml => prefs_screen_multilingual.xml} (81%) rename java/res/xml/{prefs_screen_input.xml => prefs_screen_preferences.xml} (97%) create mode 100644 java/src/com/android/inputmethod/latin/settings/AppearanceSettingsFragment.java rename java/src/com/android/inputmethod/latin/settings/{InputSettingsFragment.java => PreferencesSettingsFragment.java} (95%) diff --git a/java/res/values/strings.xml b/java/res/values/strings.xml index bccab935e..a809d835a 100644 --- a/java/res/values/strings.xml +++ b/java/res/values/strings.xml @@ -36,18 +36,20 @@ Popup on keypress - - Input preferences + + Preferences - Appearance - - Multi lingual options + Appearance + + Multilingual options - Gesture typing preferences + Gesture Typing Text correction Advanced + + Theme Switch to other input methods @@ -152,14 +154,14 @@ Configure input methods - Input languages + Languages Help & feedback - Input languages + Languages Touch again to save diff --git a/java/res/xml/prefs.xml b/java/res/xml/prefs.xml index ba285de09..c14cd645a 100644 --- a/java/res/xml/prefs.xml +++ b/java/res/xml/prefs.xml @@ -19,17 +19,17 @@ xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" android:key="english_ime_settings"> + android:fragment="com.android.inputmethod.latin.settings.PreferencesSettingsFragment" + android:title="@string/settings_screen_preferences" + android:key="screen_preferences" /> + android:fragment="com.android.inputmethod.latin.settings.AppearanceSettingsFragment" + android:title="@string/settings_screen_appearance" + android:key="screen_appearance" /> + android:title="@string/settings_screen_multilingual" + android:key="screen_multilingual" /> + + + + + + diff --git a/java/res/xml/prefs_screen_multi_lingual.xml b/java/res/xml/prefs_screen_multilingual.xml similarity index 81% rename from java/res/xml/prefs_screen_multi_lingual.xml rename to java/res/xml/prefs_screen_multilingual.xml index 937d439d6..07a4b701c 100644 --- a/java/res/xml/prefs_screen_multi_lingual.xml +++ b/java/res/xml/prefs_screen_multilingual.xml @@ -16,8 +16,8 @@ + android:title="@string/settings_screen_multilingual" + android:key="screen_multilingual"> - diff --git a/java/res/xml/prefs_screen_input.xml b/java/res/xml/prefs_screen_preferences.xml similarity index 97% rename from java/res/xml/prefs_screen_input.xml rename to java/res/xml/prefs_screen_preferences.xml index 7704e3f80..101edc855 100644 --- a/java/res/xml/prefs_screen_input.xml +++ b/java/res/xml/prefs_screen_preferences.xml @@ -17,7 +17,7 @@ + android:title="@string/settings_screen_preferences"> diff --git a/java/src/com/android/inputmethod/latin/settings/AppearanceSettingsFragment.java b/java/src/com/android/inputmethod/latin/settings/AppearanceSettingsFragment.java new file mode 100644 index 000000000..f5e4d33a2 --- /dev/null +++ b/java/src/com/android/inputmethod/latin/settings/AppearanceSettingsFragment.java @@ -0,0 +1,41 @@ +/* + * 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.os.Bundle; + +import com.android.inputmethod.latin.R; + + +/** + * "Appearance" settings sub screen. + */ +public final class AppearanceSettingsFragment extends SubScreenFragment { + @Override + public void onCreate(final Bundle icicle) { + super.onCreate(icicle); + addPreferencesFromResource(R.xml.prefs_screen_appearance); + } + + @Override + public void onResume() { + super.onResume(); + CustomInputStyleSettingsFragment.updateCustomInputStylesSummary( + findPreference(Settings.PREF_CUSTOM_INPUT_STYLES)); + ThemeSettingsFragment.updateKeyboardThemeSummary(findPreference(Settings.SCREEN_THEME)); + } +} diff --git a/java/src/com/android/inputmethod/latin/settings/CustomInputStyleSettingsFragment.java b/java/src/com/android/inputmethod/latin/settings/CustomInputStyleSettingsFragment.java index d53a61654..9bc398654 100644 --- a/java/src/com/android/inputmethod/latin/settings/CustomInputStyleSettingsFragment.java +++ b/java/src/com/android/inputmethod/latin/settings/CustomInputStyleSettingsFragment.java @@ -31,6 +31,7 @@ import android.preference.Preference; import android.preference.PreferenceFragment; import android.preference.PreferenceGroup; import android.support.v4.view.ViewCompat; +import android.text.TextUtils; import android.util.Pair; import android.view.LayoutInflater; import android.view.Menu; @@ -396,6 +397,25 @@ public final class CustomInputStyleSettingsFragment extends PreferenceFragment { // Empty constructor for fragment generation. } + static void updateCustomInputStylesSummary(final Preference pref) { + // 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()}. + SubtypeLocaleUtils.init(pref.getContext()); + + final Resources res = pref.getContext().getResources(); + final SharedPreferences prefs = pref.getSharedPreferences(); + final String prefSubtype = Settings.readPrefAdditionalSubtypes(prefs, res); + final InputMethodSubtype[] subtypes = + AdditionalSubtypeUtils.createAdditionalSubtypesArray(prefSubtype); + final ArrayList subtypeNames = new ArrayList<>(); + for (final InputMethodSubtype subtype : subtypes) { + subtypeNames.add(SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(subtype)); + } + // TODO: A delimiter of custom input styles should be localized. + pref.setSummary(TextUtils.join(", ", subtypeNames)); + } + @Override public void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); diff --git a/java/src/com/android/inputmethod/latin/settings/MultiLingualSettingsFragment.java b/java/src/com/android/inputmethod/latin/settings/MultiLingualSettingsFragment.java index fcdd39316..b073c50a4 100644 --- a/java/src/com/android/inputmethod/latin/settings/MultiLingualSettingsFragment.java +++ b/java/src/com/android/inputmethod/latin/settings/MultiLingualSettingsFragment.java @@ -16,66 +16,27 @@ package com.android.inputmethod.latin.settings; -import android.content.Context; -import android.content.SharedPreferences; -import android.content.res.Resources; import android.os.Bundle; -import android.preference.PreferenceScreen; -import android.text.TextUtils; -import android.view.inputmethod.InputMethodSubtype; import com.android.inputmethod.latin.R; -import com.android.inputmethod.latin.utils.AdditionalSubtypeUtils; -import com.android.inputmethod.latin.utils.SubtypeLocaleUtils; import java.util.ArrayList; /** - * "Multi lingual options" settings sub screen. + * "Multilingual options" settings sub screen. * * This settings sub screen handles the following input preferences. * - Language switch key * - Switch to other input methods - * - Custom input styles */ public final class MultiLingualSettingsFragment extends SubScreenFragment { @Override public void onCreate(final Bundle icicle) { super.onCreate(icicle); - addPreferencesFromResource(R.xml.prefs_screen_multi_lingual); - - 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()}. - SubtypeLocaleUtils.init(context); - + addPreferencesFromResource(R.xml.prefs_screen_multilingual); if (!Settings.ENABLE_SHOW_LANGUAGE_SWITCH_KEY_SETTINGS) { removePreference(Settings.PREF_SHOW_LANGUAGE_SWITCH_KEY); removePreference(Settings.PREF_INCLUDE_OTHER_IMES_IN_LANGUAGE_SWITCH_LIST); } } - - @Override - public void onResume() { - super.onResume(); - updateCustomInputStylesSummary(); - } - - private void updateCustomInputStylesSummary() { - final SharedPreferences prefs = getSharedPreferences(); - final Resources res = getResources(); - final PreferenceScreen customInputStyles = - (PreferenceScreen)findPreference(Settings.PREF_CUSTOM_INPUT_STYLES); - final String prefSubtype = Settings.readPrefAdditionalSubtypes(prefs, res); - final InputMethodSubtype[] subtypes = - AdditionalSubtypeUtils.createAdditionalSubtypesArray(prefSubtype); - final ArrayList subtypeNames = new ArrayList<>(); - for (final InputMethodSubtype subtype : subtypes) { - subtypeNames.add(SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(subtype)); - } - // TODO: A delimiter of custom input styles should be localized. - customInputStyles.setSummary(TextUtils.join(", ", subtypeNames)); - } } diff --git a/java/src/com/android/inputmethod/latin/settings/InputSettingsFragment.java b/java/src/com/android/inputmethod/latin/settings/PreferencesSettingsFragment.java similarity index 95% rename from java/src/com/android/inputmethod/latin/settings/InputSettingsFragment.java rename to java/src/com/android/inputmethod/latin/settings/PreferencesSettingsFragment.java index f459d68dd..49db2bdc0 100644 --- a/java/src/com/android/inputmethod/latin/settings/InputSettingsFragment.java +++ b/java/src/com/android/inputmethod/latin/settings/PreferencesSettingsFragment.java @@ -27,7 +27,7 @@ import com.android.inputmethod.latin.R; import com.android.inputmethod.latin.SubtypeSwitcher; /** - * "Input preferences" settings sub screen. + * "Preferences" settings sub screen. * * This settings sub screen handles the following input preferences. * - Auto-capitalization @@ -37,11 +37,11 @@ import com.android.inputmethod.latin.SubtypeSwitcher; * - Popup on keypress * - Voice input key */ -public final class InputSettingsFragment extends SubScreenFragment { +public final class PreferencesSettingsFragment extends SubScreenFragment { @Override public void onCreate(final Bundle icicle) { super.onCreate(icicle); - addPreferencesFromResource(R.xml.prefs_screen_input); + addPreferencesFromResource(R.xml.prefs_screen_preferences); final Resources res = getResources(); final Context context = getActivity(); diff --git a/java/src/com/android/inputmethod/latin/settings/Settings.java b/java/src/com/android/inputmethod/latin/settings/Settings.java index 3c7a99102..0de2d8831 100644 --- a/java/src/com/android/inputmethod/latin/settings/Settings.java +++ b/java/src/com/android/inputmethod/latin/settings/Settings.java @@ -42,9 +42,10 @@ import java.util.concurrent.locks.ReentrantLock; public final class Settings implements SharedPreferences.OnSharedPreferenceChangeListener { private static final String TAG = Settings.class.getSimpleName(); // Settings screens - public static final String SCREEN_INPUT = "screen_input"; + public static final String SCREEN_PREFERENCES = "screen_preferences"; + public static final String SCREEN_APPEARANCE = "screen_appearance"; public static final String SCREEN_THEME = "screen_theme"; - public static final String SCREEN_MULTI_LINGUAL = "screen_multi_lingual"; + public static final String SCREEN_MULTILINGUAL = "screen_multilingual"; public static final String SCREEN_GESTURE = "screen_gesture"; public static final String SCREEN_CORRECTION = "screen_correction"; public static final String SCREEN_ADVANCED = "screen_advanced"; @@ -69,6 +70,9 @@ public final class Settings implements SharedPreferences.OnSharedPreferenceChang "pref_key_use_double_space_period"; public static final String PREF_BLOCK_POTENTIALLY_OFFENSIVE = "pref_key_block_potentially_offensive"; + // No multilingual options in Android L and above for now. + public static final boolean SHOW_MULTILINGUAL_SETTINGS = + BuildCompatUtils.EFFECTIVE_SDK_INT <= Build.VERSION_CODES.KITKAT; public static final boolean ENABLE_SHOW_LANGUAGE_SWITCH_KEY_SETTINGS = BuildCompatUtils.EFFECTIVE_SDK_INT <= Build.VERSION_CODES.KITKAT; public static final boolean HAS_UI_TO_ACCEPT_TYPED_WORD = diff --git a/java/src/com/android/inputmethod/latin/settings/SettingsFragment.java b/java/src/com/android/inputmethod/latin/settings/SettingsFragment.java index ff7495853..4fc17387f 100644 --- a/java/src/com/android/inputmethod/latin/settings/SettingsFragment.java +++ b/java/src/com/android/inputmethod/latin/settings/SettingsFragment.java @@ -18,6 +18,7 @@ package com.android.inputmethod.latin.settings; import android.content.Intent; import android.os.Bundle; +import android.preference.Preference; import android.preference.PreferenceScreen; import android.view.Menu; import android.view.MenuInflater; @@ -46,12 +47,10 @@ public final class SettingsFragment extends InputMethodSettingsFragment { final PreferenceScreen preferenceScreen = getPreferenceScreen(); preferenceScreen.setTitle( ApplicationUtils.getActivityTitleResId(getActivity(), SettingsActivity.class)); - } - - @Override - public void onResume() { - super.onResume(); - ThemeSettingsFragment.updateKeyboardThemeSummary(findPreference(Settings.SCREEN_THEME)); + if (!Settings.SHOW_MULTILINGUAL_SETTINGS) { + final Preference multilingualOptions = findPreference(Settings.SCREEN_MULTILINGUAL); + preferenceScreen.removePreference(multilingualOptions); + } } @Override diff --git a/java/src/com/android/inputmethod/latin/utils/FragmentUtils.java b/java/src/com/android/inputmethod/latin/utils/FragmentUtils.java index 08f5b0b41..c2167a76b 100644 --- a/java/src/com/android/inputmethod/latin/utils/FragmentUtils.java +++ b/java/src/com/android/inputmethod/latin/utils/FragmentUtils.java @@ -19,12 +19,13 @@ package com.android.inputmethod.latin.utils; import com.android.inputmethod.dictionarypack.DictionarySettingsFragment; import com.android.inputmethod.latin.about.AboutPreferences; import com.android.inputmethod.latin.settings.AdvancedSettingsFragment; +import com.android.inputmethod.latin.settings.AppearanceSettingsFragment; import com.android.inputmethod.latin.settings.CorrectionSettingsFragment; import com.android.inputmethod.latin.settings.CustomInputStyleSettingsFragment; import com.android.inputmethod.latin.settings.DebugSettingsFragment; 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.PreferencesSettingsFragment; import com.android.inputmethod.latin.settings.SettingsFragment; import com.android.inputmethod.latin.settings.ThemeSettingsFragment; import com.android.inputmethod.latin.spellcheck.SpellCheckerSettingsFragment; @@ -40,7 +41,8 @@ public class FragmentUtils { static { sLatinImeFragments.add(DictionarySettingsFragment.class.getName()); sLatinImeFragments.add(AboutPreferences.class.getName()); - sLatinImeFragments.add(InputSettingsFragment.class.getName()); + sLatinImeFragments.add(PreferencesSettingsFragment.class.getName()); + sLatinImeFragments.add(AppearanceSettingsFragment.class.getName()); sLatinImeFragments.add(ThemeSettingsFragment.class.getName()); sLatinImeFragments.add(MultiLingualSettingsFragment.class.getName()); sLatinImeFragments.add(CustomInputStyleSettingsFragment.class.getName());