am d0d8f90a: Merge "Reorganize settings in Google Keyboard" into lmp-dev

* commit 'd0d8f90a32b907b867f8fa934dc7582ff53a9a43':
  Reorganize settings in Google Keyboard
main
Jatin Matani 2014-09-12 18:51:23 +00:00 committed by Android Git Automerger
commit d07f7c5377
13 changed files with 132 additions and 78 deletions

View File

@ -36,18 +36,20 @@
<!-- Option to control whether or not to show a popup with a larger font on each key press. -->
<string name="popup_on_keypress">Popup on keypress</string>
<!-- Settings screen title for input preferences [CHAR LIMIT=33]-->
<string name="settings_screen_input">Input preferences</string>
<!-- Settings screen title for preferences [CHAR LIMIT=33]-->
<string name="settings_screen_preferences">Preferences</string>
<!-- Settings screen title for appearance preferences [CHAR LIMIT=33] -->
<string name="settings_screen_appearances">Appearance</string>
<!-- Settings screen title for multi lingual options [CHAR_LIMIT=33] -->
<string name="settings_screen_multi_lingual">Multi lingual options</string>
<string name="settings_screen_appearance">Appearance</string>
<!-- Settings screen title for multilingual options [CHAR_LIMIT=33] -->
<string name="settings_screen_multilingual">Multilingual options</string>
<!-- Settings screen title for gesture typing preferences [CHAR_LIMIT=33] -->
<string name="settings_screen_gesture">Gesture typing preferences</string>
<string name="settings_screen_gesture">Gesture Typing</string>
<!-- Settings screen title for text correction options [CHAR_LIMIT=33] -->
<string name="settings_screen_correction">Text correction</string>
<!-- Settings screen title for advanced settings [CHAR LIMIT=33] -->
<string name="settings_screen_advanced">Advanced</string>
<!-- Settings screen title for keyboard theme settings [CHAR LIMIT=33] -->
<string name="settings_screen_theme">Theme</string>
<!-- Option name for including other IMEs in the language switch list [CHAR LIMIT=30] -->
<string name="include_other_imes_in_language_switch_list">Switch to other input methods</string>
@ -152,14 +154,14 @@
<string name="configure_input_method">Configure input methods</string>
<!-- Title for input language selection screen -->
<string name="language_selection_title">Input languages</string>
<string name="language_selection_title">Languages</string>
<!-- Title for the 'Help & feedback' settings fragment which shows a help page and has a button
for submitting feedback. [CHAR LIMIT=35] -->
<string name="help_and_feedback">Help &amp; feedback</string>
<!-- Preference for input language selection -->
<string name="select_language">Input languages</string>
<string name="select_language">Languages</string>
<!-- Add to dictionary hint -->
<string name="hint_add_to_dictionary">Touch again to save</string>

View File

@ -19,17 +19,17 @@
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
android:key="english_ime_settings">
<PreferenceScreen
android:fragment="com.android.inputmethod.latin.settings.InputSettingsFragment"
android:title="@string/settings_screen_input"
android:key="screen_input" />
android:fragment="com.android.inputmethod.latin.settings.PreferencesSettingsFragment"
android:title="@string/settings_screen_preferences"
android:key="screen_preferences" />
<PreferenceScreen
android:fragment="com.android.inputmethod.latin.settings.ThemeSettingsFragment"
android:title="@string/keyboard_theme"
android:key="screen_theme" />
android:fragment="com.android.inputmethod.latin.settings.AppearanceSettingsFragment"
android:title="@string/settings_screen_appearance"
android:key="screen_appearance" />
<PreferenceScreen
android:fragment="com.android.inputmethod.latin.settings.MultiLingualSettingsFragment"
android:title="@string/settings_screen_multi_lingual"
android:key="screen_multi_lingual" />
android:title="@string/settings_screen_multilingual"
android:key="screen_multilingual" />
<PreferenceScreen
android:fragment="com.android.inputmethod.latin.settings.GestureSettingsFragment"
android:title="@string/settings_screen_gesture"

View File

@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- 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.
-->
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
android:key="screen_appearance"
android:title="@string/settings_screen_appearance">
<PreferenceScreen
android:fragment="com.android.inputmethod.latin.settings.ThemeSettingsFragment"
android:key="screen_theme"
android:title="@string/settings_screen_theme" />
<PreferenceScreen
android:fragment="com.android.inputmethod.latin.settings.CustomInputStyleSettingsFragment"
android:key="custom_input_styles"
android:title="@string/custom_input_styles_title" />
</PreferenceScreen>

View File

@ -16,8 +16,8 @@
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
android:title="@string/settings_screen_multi_lingual"
android:key="screen_multi_lingual">
android:title="@string/settings_screen_multilingual"
android:key="screen_multilingual">
<CheckBoxPreference
android:key="pref_show_language_switch_key"
android:title="@string/show_language_switch_key"
@ -31,8 +31,4 @@
android:summary="@string/include_other_imes_in_language_switch_list_summary"
android:defaultValue="false"
android:persistent="true" />
<PreferenceScreen
android:fragment="com.android.inputmethod.latin.settings.CustomInputStyleSettingsFragment"
android:key="custom_input_styles"
android:title="@string/custom_input_styles_title" />
</PreferenceScreen>

View File

@ -17,7 +17,7 @@
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
android:title="@string/settings_screen_input">
android:title="@string/settings_screen_preferences">
<CheckBoxPreference
android:key="auto_cap"
android:title="@string/auto_cap"

View File

@ -17,7 +17,7 @@
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
android:title="@string/keyboard_theme"
android:title="@string/settings_screen_theme"
android:key="screen_theme">
<!-- Keyboard theme list will be populated programmatically here. -->
</PreferenceScreen>

View File

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

View File

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

View File

@ -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<String> 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));
}
}

View File

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

View File

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

View File

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

View File

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