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

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

Utilize InputMethodSubtype and additional subtype

* Remove de_QY and fr_CH from supported subtypes
* Add de-qwerty and fr-qwertz predefined additional subtypes instead.

Change-Id: I49e8ba0299529302f2b91b4d018b07304cdd6897
parent f338f8b5
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -134,24 +134,24 @@
        <item>5</item>
    </string-array>

    <!-- Subtype locale name exceptions -->
    <!-- Subtype locale display name exceptions -->
    <string-array name="subtype_locale_exception_keys">
        <item>en_US</item>
        <item>en_GB</item>
        <item>*_QY</item>
        <item>QY</item>
    </string-array>
    <string-array name="subtype_locale_exception_values">
        <item>English (US)</item>
        <item>English (UK)</item>
        <item>@string/subtype_generic_qwerty</item>
        <item>QWERTY</item>
    </string-array>

    <!-- Generic subtype label -->
    <string name="subtype_generic">%s</string>
    <!-- Description for generic QWERTY keyboard subtype -->
    <string name="subtype_generic_qwerty">%s (QWERTY)</string>
    <!-- Description for generic QWERTZ keyboard subtype -->
    <string name="subtype_generic_qwertz">%s (QWERTZ)</string>
    <!-- Description for generic AZERTY keyboard subtype -->
    <string name="subtype_generic_azerty">%s (AZERTY)</string>

    <!-- dictionary pack package name /settings activity (for shared prefs and settings) -->
    <string name="dictionary_pack_package_name">com.google.android.inputmethod.latin.dictionarypack</string>
+2 −16
Original line number Diff line number Diff line
@@ -28,7 +28,6 @@
    cs: Czech/qwertz
    da: Danish/nordic
    de: German/qwertz
    de_QY: German (QWERTY)/qwerty
    el: Greek/greek
    en_US: English United States/qwerty
    en_GB: English Great Britain/qwerty
@@ -38,7 +37,6 @@
    fi: Finnish/nordic
    fr: French/azerty
    fr_CA: French Canada/qwerty
    fr_CH: French Switzerland/qwertz
    hi: Hindi/hindi
    hr: Croatian/qwertz
    hu: Hungarian/qwertz
@@ -64,7 +62,7 @@
    tr: Turkish/qwerty
    uk: Ukrainian/east_slavic
    vi: Vietnamese/qwerty
    zz_QY: QWERTY/qwerty
    zz: QWERTY/qwerty
    -->
<!-- TODO: use <lang>_keyboard icon instead of a common keyboard icon. -->
<!-- If IME doesn't have an applicable subtype, the first subtype will be used as a default
@@ -120,12 +118,6 @@
            android:imeSubtypeMode="keyboard"
            android:imeSubtypeExtraValue="KeyboardLayoutSet=qwertz,AsciiCapable"
    />
    <subtype android:icon="@drawable/ic_subtype_keyboard"
            android:label="@string/subtype_generic_qwerty"
            android:imeSubtypeLocale="de"
            android:imeSubtypeMode="keyboard"
            android:imeSubtypeExtraValue="KeyboardLayoutSet=qwerty:de_QY,AsciiCapable"
    />
    <subtype android:icon="@drawable/ic_subtype_keyboard"
            android:label="@string/subtype_generic"
            android:imeSubtypeLocale="el"
@@ -168,12 +160,6 @@
            android:imeSubtypeMode="keyboard"
            android:imeSubtypeExtraValue="KeyboardLayoutSet=qwerty,AsciiCapable"
    />
    <subtype android:icon="@drawable/ic_subtype_keyboard"
            android:label="@string/subtype_generic"
            android:imeSubtypeLocale="fr_CH"
            android:imeSubtypeMode="keyboard"
            android:imeSubtypeExtraValue="KeyboardLayoutSet=qwertz,AsciiCapable"
    />
    <subtype android:icon="@drawable/ic_subtype_keyboard"
            android:label="@string/subtype_generic"
            android:imeSubtypeLocale="hi"
@@ -327,7 +313,7 @@
    />
    <subtype android:icon="@drawable/ic_subtype_keyboard"
            android:label="@string/subtype_no_language_qwerty"
            android:imeSubtypeLocale="zz_QY"
            android:imeSubtypeLocale="zz"
            android:imeSubtypeMode="keyboard"
            android:imeSubtypeExtraValue="KeyboardLayoutSet=qwerty,AsciiCapable,EnabledWhenDefaultIsNotAsciiCapable"
    />
+4 −0
Original line number Diff line number Diff line
@@ -53,6 +53,10 @@ public class InputMethodManagerCompatWrapper {
        sInstance.mImm = (InputMethodManager)context.getSystemService(Context.INPUT_METHOD_SERVICE);
    }

    public void setAdditionalInputMethodSubtypes(String imiId, InputMethodSubtype[] subtypes) {
        mImm.setAdditionalInputMethodSubtypes(imiId, subtypes);
    }

    public InputMethodSubtype getCurrentInputMethodSubtype() {
        return mImm.getCurrentInputMethodSubtype();
    }
+1 −1
Original line number Diff line number Diff line
@@ -793,7 +793,7 @@ public class Keyboard {
                    }
                };
                // Null means the current system locale.
                final Locale locale = language.equals(SubtypeLocale.NO_LANGUAGE)
                final Locale locale = SubtypeLocale.isNoLanguage(params.mId.mSubtype)
                        ? null : params.mId.mLocale;
                job.runInLocale(mResources, locale);

+12 −6
Original line number Diff line number Diff line
@@ -19,9 +19,12 @@ package com.android.inputmethod.keyboard;
import android.text.InputType;
import android.text.TextUtils;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputMethodSubtype;

import com.android.inputmethod.compat.EditorInfoCompatUtils;
import com.android.inputmethod.latin.InputTypeUtils;
import com.android.inputmethod.latin.LatinIME;
import com.android.inputmethod.latin.SubtypeLocale;

import java.util.Arrays;
import java.util.Locale;
@@ -53,6 +56,7 @@ public class KeyboardId {

    private static final int IME_ACTION_CUSTOM_LABEL = EditorInfo.IME_MASK_ACTION + 1;

    public final InputMethodSubtype mSubtype;
    public final Locale mLocale;
    public final int mOrientation;
    public final int mWidth;
@@ -67,10 +71,11 @@ public class KeyboardId {

    private final int mHashCode;

    public KeyboardId(int elementId, Locale locale, int orientation, int width, int mode,
            EditorInfo editorInfo, boolean clobberSettingsKey, boolean shortcutKeyEnabled,
    public KeyboardId(int elementId, InputMethodSubtype subtype, int orientation, int width,
            int mode, EditorInfo editorInfo, boolean clobberSettingsKey, boolean shortcutKeyEnabled,
            boolean hasShortcutKey, boolean languageSwitchKeyEnabled) {
        mLocale = locale;
        mSubtype = subtype;
        mLocale = SubtypeLocale.getSubtypeLocale(subtype);
        mOrientation = orientation;
        mWidth = width;
        mMode = mode;
@@ -102,7 +107,7 @@ public class KeyboardId {
                id.mCustomActionLabel,
                id.navigateNext(),
                id.navigatePrevious(),
                id.mLocale
                id.mSubtype
        });
    }

@@ -123,7 +128,7 @@ public class KeyboardId {
                && TextUtils.equals(other.mCustomActionLabel, mCustomActionLabel)
                && other.navigateNext() == navigateNext()
                && other.navigatePrevious() == navigatePrevious()
                && other.mLocale.equals(mLocale);
                && other.mSubtype.equals(mSubtype);
    }

    public boolean isAlphabetKeyboard() {
@@ -176,9 +181,10 @@ public class KeyboardId {

    @Override
    public String toString() {
        return String.format("[%s %s %s%d %s %s %s%s%s%s%s%s%s%s]",
        return String.format("[%s %s:%s %s%d %s %s %s%s%s%s%s%s%s%s]",
                elementIdToName(mElementId),
                mLocale,
                mSubtype.getExtraValueOf(LatinIME.SUBTYPE_EXTRA_VALUE_KEYBOARD_LAYOUT_SET),
                (mOrientation == 1 ? "port" : "land"), mWidth,
                modeName(mMode),
                imeAction(),
Loading