Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 59c3ef1f authored by Tadashi G. Takaoka's avatar Tadashi G. Takaoka
Browse files

Refactor KeyboardTheme

This CL introduces two preference keys in addition to the existing one.

- pref_keyboard_theme: The new preference key that is used only in the
  preference settings.

- pref_keyboard_layout_20110916: The previous preference key that
  holds keyboard color scheme settings. This is superseded by the next
  key.

- pref_keyboard_theme_20140509: The new preference key that holds
  keyboard theme settings. This value is forcibly reset to LMP theme
  on a LMP device. On a KitKat and previous device, the settings of
  the pref_keyboard_layout_20110916 is carried on into this
  preference.

This CL must be checked in together with Id7b3ddd8aa.

Change-Id: I2d55602d026e30b38d8f822d2124f5c5e4a9a812
parent 6b74f516
Loading
Loading
Loading
Loading
+0 −3
Original line number Diff line number Diff line
@@ -24,9 +24,6 @@
         at input history to suggest a hopefully helpful suggestions for the next word? -->
    <bool name="config_default_next_word_prediction">true</bool>

    <!-- This configuration must be aligned with {@link KeyboardTheme#DEFAULT_THEME_ID}. -->
    <string name="config_default_keyboard_theme_id" translatable="false">2</string>

    <integer name="config_delay_update_shift_state">100</integer>
    <integer name="config_double_space_period_timeout">1100</integer>

+0 −11
Original line number Diff line number Diff line
@@ -47,17 +47,6 @@
    <string name="prefs_debug_mode">Debug Mode</string>
    <string name="prefs_force_non_distinct_multitouch">Force non-distinct multitouch</string>

    <!-- For keyboard color scheme option dialog. -->
    <string-array name="keyboard_theme_names">
        <item>@string/keyboard_color_scheme_white</item>
        <item>@string/keyboard_color_scheme_blue</item>
    </string-array>
    <!-- An element must be a keyboard theme id of {@link KeyboardTheme#THEME_ID_*}. -->
    <string-array name="keyboard_theme_ids">
        <item>2</item>
        <item>0</item>
    </string-array>

    <!-- Subtype locale display name exceptions.
         For each exception, there should be related string resources for display name that may have
         explicit keyboard layout. The string resource name must be "subtype_<locale>" or
+34 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
/*
**
** Copyright 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.
*/
-->
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
    <!-- For keyboard color scheme option dialog. -->
    <string-array name="keyboard_theme_names" translatable="false">
        <item>@string/keyboard_color_scheme_white</item>
        <item>@string/keyboard_color_scheme_blue</item>
        <!-- TODO: Make this item as translatable string resource. -->
        <item>Quantum</item>
    </string-array>
    <!-- An element must be a keyboard theme id of {@link KeyboardTheme#THEME_ID_*}. -->
    <string-array name="keyboard_theme_ids" translatable="false">
        <item>2</item>
        <item>0</item>
        <item>3</item>
    </string-array>
</resources>
+2 −3
Original line number Diff line number Diff line
@@ -158,12 +158,11 @@
                android:persistent="true"
                android:defaultValue="false" />
            <ListPreference
                android:key="pref_keyboard_layout_20110916"
                android:key="pref_keyboard_theme"
                android:title="@string/keyboard_color_scheme"
                android:persistent="true"
                android:entryValues="@array/keyboard_theme_ids"
                android:entries="@array/keyboard_theme_names"
                android:defaultValue="@string/config_default_keyboard_theme_id" />
                android:entries="@array/keyboard_theme_names" />
            <PreferenceScreen
                android:fragment="com.android.inputmethod.latin.settings.AdditionalSubtypeSettings"
                android:key="custom_input_styles"
+4 −3
Original line number Diff line number Diff line
@@ -64,7 +64,7 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions {
     * what user actually typed. */
    private boolean mIsAutoCorrectionActive;

    private KeyboardTheme mKeyboardTheme = KeyboardTheme.getDefaultKeyboardTheme();
    private KeyboardTheme mKeyboardTheme;
    private Context mThemeContext;

    private static final KeyboardSwitcher sInstance = new KeyboardSwitcher();
@@ -101,7 +101,7 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions {

    private boolean updateKeyboardThemeAndContextThemeWrapper(final Context context,
            final KeyboardTheme keyboardTheme) {
        if (mThemeContext == null || mKeyboardTheme.mThemeId != keyboardTheme.mThemeId) {
        if (mThemeContext == null || !keyboardTheme.equals(mKeyboardTheme)) {
            mKeyboardTheme = keyboardTheme;
            mThemeContext = new ContextThemeWrapper(context, keyboardTheme.mStyleId);
            KeyboardLayoutSet.clearKeyboardCache();
@@ -342,7 +342,8 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions {
            mKeyboardView.closing();
        }

        updateKeyboardThemeAndContextThemeWrapper(mLatinIME, mKeyboardTheme);
        updateKeyboardThemeAndContextThemeWrapper(
                mLatinIME, KeyboardTheme.getKeyboardTheme(mPrefs));
        mCurrentInputView = (InputView)LayoutInflater.from(mThemeContext).inflate(
                R.layout.input_view, null);
        mMainKeyboardFrame = mCurrentInputView.findViewById(R.id.main_keyboard_frame);
Loading