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

Commit 21eafd79 authored by Tadashi G. Takaoka's avatar Tadashi G. Takaoka
Browse files

Use KeyboardTheme id insteand of index

This CL must be checked in together with I771216f8bd.

Bug: 14042743
Change-Id: I45c3acf9242985fb03721a9a6d377fbccc8e2019
parent 3568fca9
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -24,8 +24,8 @@
         at input history to suggest a hopefully helpful suggestions for the next word? -->
    <bool name="config_default_next_word_prediction">true</bool>

    <!-- This configuration is an index of  {@link KeyboardSwitcher#KEYBOARD_THEMES[]}. -->
    <string name="config_default_keyboard_theme_index" translatable="false">2</string>
    <!-- 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>
+4 −4
Original line number Diff line number Diff line
@@ -58,7 +58,7 @@
        <item>@string/layout_gingerbread</item>
        <item>@string/layout_klp</item>
    </string-array>
    <!-- An element must be an index of {@link KeyboardSwitcher#KEYBOARD_THEMES[]}. -->
    <!-- An element must be a keyboard theme id of {@link KeyboardTheme#THEME_ID_*}. -->
    <string-array name="keyboard_layout_modes_values">
        <item>0</item>
        <item>1</item>
@@ -66,12 +66,12 @@
    </string-array>

    <!-- For keyboard color scheme option dialog. -->
    <string-array name="keyboard_color_schemes">
    <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 an index of {@link KeyboardSwitcher#KEYBOARD_THEMES[]}. -->
    <string-array name="keyboard_color_schemes_values">
    <!-- 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>
+3 −3
Original line number Diff line number Diff line
@@ -168,9 +168,9 @@
                android:key="pref_keyboard_layout_20110916"
                android:title="@string/keyboard_color_scheme"
                android:persistent="true"
                android:entryValues="@array/keyboard_color_schemes_values"
                android:entries="@array/keyboard_color_schemes"
                android:defaultValue="@string/config_default_keyboard_theme_index" />
                android:entryValues="@array/keyboard_theme_ids"
                android:entries="@array/keyboard_theme_names"
                android:defaultValue="@string/config_default_keyboard_theme_id" />
            <PreferenceScreen
                android:fragment="com.android.inputmethod.latin.settings.AdditionalSubtypeSettings"
                android:key="custom_input_styles"
+1 −1
Original line number Diff line number Diff line
@@ -33,7 +33,7 @@
        android:persistent="true"
        android:entryValues="@array/keyboard_layout_modes_values"
        android:entries="@array/keyboard_layout_modes"
        android:defaultValue="@string/config_default_keyboard_theme_index" />
        android:defaultValue="@string/config_default_keyboard_theme_id" />
    <CheckBoxPreference
        android:key="debug_mode"
        android:title="@string/prefs_debug_mode"
+2 −17
Original line number Diff line number Diff line
@@ -38,7 +38,6 @@ import com.android.inputmethod.latin.R;
import com.android.inputmethod.latin.RichInputMethodManager;
import com.android.inputmethod.latin.SubtypeSwitcher;
import com.android.inputmethod.latin.WordComposer;
import com.android.inputmethod.latin.settings.Settings;
import com.android.inputmethod.latin.settings.SettingsValues;
import com.android.inputmethod.latin.utils.ResourceUtils;

@@ -66,8 +65,7 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions {
     * what user actually typed. */
    private boolean mIsAutoCorrectionActive;

    private KeyboardTheme mKeyboardTheme =
            KeyboardTheme.KEYBOARD_THEMES[KeyboardTheme.DEFAULT_THEME_INDEX];
    private KeyboardTheme mKeyboardTheme = KeyboardTheme.getDefaultKeyboardTheme();
    private Context mThemeContext;

    private static final KeyboardSwitcher sInstance = new KeyboardSwitcher();
@@ -96,25 +94,12 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions {

    public void updateKeyboardTheme() {
        final boolean themeUpdated = updateKeyboardThemeAndContextThemeWrapper(
                mLatinIME, getKeyboardTheme(mLatinIME, mPrefs));
                mLatinIME, KeyboardTheme.getKeyboardTheme(mPrefs));
        if (themeUpdated && mKeyboardView != null) {
            mLatinIME.setInputView(onCreateInputView(mIsHardwareAcceleratedDrawingEnabled));
        }
    }

    private static KeyboardTheme getKeyboardTheme(final Context context,
            final SharedPreferences prefs) {
        final Resources res = context.getResources();
        final int index = Settings.readKeyboardThemeIndex(prefs, res);
        if (index >= 0 && index < KeyboardTheme.KEYBOARD_THEMES.length) {
            return KeyboardTheme.KEYBOARD_THEMES[index];
        }
        final int defaultThemeIndex = Settings.resetAndGetDefaultKeyboardThemeIndex(prefs, res);
        Log.w(TAG, "Illegal keyboard theme in preference: " + index + ", default to "
                + defaultThemeIndex);
        return KeyboardTheme.KEYBOARD_THEMES[defaultThemeIndex];
    }

    private boolean updateKeyboardThemeAndContextThemeWrapper(final Context context,
            final KeyboardTheme keyboardTheme) {
        if (mThemeContext == null || mKeyboardTheme.mThemeId != keyboardTheme.mThemeId) {
Loading