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

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

Fix label of switch to symbols key when symbols has shortcut key

This change fixes the labels of switch to symbols key and switch back
from more symbols key when symbols layout has shortcut key.

Change-Id: I3fbbef2d929486d0f0542f4d89cb086d9f5bad82
parent ac3720ce
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -389,6 +389,7 @@
        <attr name="passwordInput" format="boolean" />
        <attr name="clobberSettingsKey" format="boolean" />
        <attr name="shortcutKeyEnabled" format="boolean" />
        <attr name="shortcutKeyOnSymbols" format="boolean" />
        <attr name="hasShortcutKey" format="boolean" />
        <attr name="languageSwitchKeyEnabled" format="boolean" />
        <attr name="isMultiLine" format="boolean" />
+9 −10
Original line number Diff line number Diff line
@@ -154,31 +154,30 @@
        </default>
    </switch>
    <key-style
        latin:styleName="toSymbolKeyStyle"
        latin:code="!code/key_switch_alpha_symbol"
        latin:keyLabel="!text/label_to_symbol_key"
        latin:styleName="baseForLayoutSwitchKeyStyle"
        latin:keyLabelFlags="preserveCase"
        latin:keyActionFlags="noKeyPreview"
        latin:backgroundType="functional" />
    <key-style
        latin:styleName="toSymbolKeyStyle"
        latin:code="!code/key_switch_alpha_symbol"
        latin:keyLabel="!text/label_to_symbol_key"
        latin:parentStyle="baseForLayoutSwitchKeyStyle" />
    <key-style
        latin:styleName="toAlphaKeyStyle"
        latin:code="!code/key_switch_alpha_symbol"
        latin:keyLabel="!text/label_to_alpha_key"
        latin:keyLabelFlags="preserveCase"
        latin:keyActionFlags="noKeyPreview"
        latin:backgroundType="functional" />
        latin:parentStyle="baseForLayoutSwitchKeyStyle" />
    <key-style
        latin:styleName="toMoreSymbolKeyStyle"
        latin:code="!code/key_shift"
        latin:keyLabel="!text/label_to_more_symbol_for_tablet_key"
        latin:keyActionFlags="noKeyPreview"
        latin:backgroundType="functional" />
        latin:parentStyle="baseForLayoutSwitchKeyStyle" />
    <key-style
        latin:styleName="backFromMoreSymbolKeyStyle"
        latin:code="!code/key_shift"
        latin:keyLabel="!text/label_to_symbol_key"
        latin:keyActionFlags="noKeyPreview"
        latin:backgroundType="functional" />
        latin:parentStyle="baseForLayoutSwitchKeyStyle" />
    <key-style
        latin:styleName="comKeyStyle"
        latin:keyLabel="!text/keylabel_for_popular_domain"
+9 −12
Original line number Diff line number Diff line
@@ -144,33 +144,30 @@
        </default>
    </switch>
    <key-style
        latin:styleName="toSymbolKeyStyle"
        latin:code="!code/key_switch_alpha_symbol"
        latin:keyLabel="!text/label_to_symbol_key"
        latin:styleName="baseForLayoutSwitchKeyStyle"
        latin:keyLabelFlags="fontNormal|preserveCase"
        latin:keyActionFlags="noKeyPreview"
        latin:backgroundType="functional" />
    <key-style
        latin:styleName="toSymbolKeyStyle"
        latin:code="!code/key_switch_alpha_symbol"
        latin:keyLabel="!text/label_to_symbol_key"
        latin:parentStyle="baseForLayoutSwitchKeyStyle" />
    <key-style
        latin:styleName="toAlphaKeyStyle"
        latin:code="!code/key_switch_alpha_symbol"
        latin:keyLabel="!text/label_to_alpha_key"
        latin:keyLabelFlags="fontNormal|preserveCase"
        latin:keyActionFlags="noKeyPreview"
        latin:backgroundType="functional" />
        latin:parentStyle="baseForLayoutSwitchKeyStyle" />
    <key-style
        latin:styleName="toMoreSymbolKeyStyle"
        latin:code="!code/key_shift"
        latin:keyLabel="!text/label_to_more_symbol_for_tablet_key"
        latin:keyLabelFlags="fontNormal"
        latin:keyActionFlags="noKeyPreview"
        latin:backgroundType="functional" />
        latin:parentStyle="baseForLayoutSwitchKeyStyle" />
    <key-style
        latin:styleName="backFromMoreSymbolKeyStyle"
        latin:code="!code/key_shift"
        latin:keyLabel="!text/label_to_symbol_key"
        latin:keyLabelFlags="fontNormal"
        latin:keyActionFlags="noKeyPreview"
        latin:backgroundType="functional" />
        latin:parentStyle="baseForLayoutSwitchKeyStyle" />
    <key-style
        latin:styleName="comKeyStyle"
        latin:keyLabel="!text/keylabel_for_popular_domain"
+17 −19
Original line number Diff line number Diff line
@@ -134,52 +134,50 @@
        latin:code="!code/key_tab"
        latin:keyIcon="!icon/tab_key"
        latin:keyIconPreview="!icon/tab_key_preview" />
    <key-style
        latin:styleName="baseForLayoutSwitchKeyStyle"
        latin:keyLabelFlags="preserveCase"
        latin:keyActionFlags="noKeyPreview"
        latin:backgroundType="functional" />
    <switch>
        <!-- When this qwerty keyboard has no shortcut keys but shortcut key is enabled, then symbol
             keyboard will have a shortcut key. That means we should use label_to_symbol_key label
             and shortcut_for_label icon. -->
        <case
            latin:shortcutKeyEnabled="true"
            latin:hasShortcutKey="false"
            latin:shortcutKeyOnSymbols="true"
        >
            <key-style
                latin:styleName="toSymbolKeyStyle"
                latin:code="!code/key_switch_alpha_symbol"
                latin:styleName="baseForToSymbolKeyStyle"
                latin:keyIcon="!icon/shortcut_for_label"
                latin:keyLabel="!text/label_to_symbol_with_microphone_key"
                latin:keyLabelFlags="withIconRight|preserveCase"
                latin:keyActionFlags="noKeyPreview"
                latin:backgroundType="functional" />
                latin:parentStyle="baseForLayoutSwitchKeyStyle" />
        </case>
        <default>
            <key-style
                latin:styleName="toSymbolKeyStyle"
                latin:code="!code/key_switch_alpha_symbol"
                latin:styleName="baseForToSymbolKeyStyle"
                latin:keyLabel="!text/label_to_symbol_key"
                latin:keyLabelFlags="preserveCase"
                latin:keyActionFlags="noKeyPreview"
                latin:backgroundType="functional" />
                latin:parentStyle="baseForLayoutSwitchKeyStyle" />
        </default>
    </switch>
    <key-style
        latin:styleName="toSymbolKeyStyle"
        latin:code="!code/key_switch_alpha_symbol"
        latin:parentStyle="baseForToSymbolKeyStyle" />
    <key-style
        latin:styleName="toAlphaKeyStyle"
        latin:code="!code/key_switch_alpha_symbol"
        latin:keyLabel="!text/label_to_alpha_key"
        latin:keyLabelFlags="preserveCase"
        latin:keyActionFlags="noKeyPreview"
        latin:backgroundType="functional" />
        latin:parentStyle="baseForLayoutSwitchKeyStyle" />
    <key-style
        latin:styleName="toMoreSymbolKeyStyle"
        latin:code="!code/key_shift"
        latin:keyLabel="!text/label_to_more_symbol_key"
        latin:keyActionFlags="noKeyPreview"
        latin:backgroundType="functional" />
        latin:parentStyle="baseForLayoutSwitchKeyStyle" />
    <key-style
        latin:styleName="backFromMoreSymbolKeyStyle"
        latin:code="!code/key_shift"
        latin:keyLabel="!text/label_to_symbol_key"
        latin:keyActionFlags="noKeyPreview"
        latin:backgroundType="functional" />
        latin:parentStyle="baseForToSymbolKeyStyle" />
    <key-style
        latin:styleName="punctuationKeyStyle"
        latin:keyLabel="."
+40 −30
Original line number Diff line number Diff line
@@ -71,34 +71,39 @@ public final class KeyboardId {
    private final EditorInfo mEditorInfo;
    public final boolean mClobberSettingsKey;
    public final boolean mShortcutKeyEnabled;
    public final boolean mHasShortcutKey;
    public final boolean mShortcutKeyOnSymbols;
    public final boolean mLanguageSwitchKeyEnabled;
    public final String mCustomActionLabel;
    public final boolean mHasShortcutKey;

    private final int mHashCode;

    public KeyboardId(int elementId, InputMethodSubtype subtype, int deviceFormFactor,
            int orientation, int width, int mode, EditorInfo editorInfo, boolean clobberSettingsKey,
            boolean shortcutKeyEnabled, boolean hasShortcutKey, boolean languageSwitchKeyEnabled) {
        mSubtype = subtype;
        mLocale = SubtypeLocale.getSubtypeLocale(subtype);
        mDeviceFormFactor = deviceFormFactor;
        mOrientation = orientation;
        mWidth = width;
        mMode = mode;
    public KeyboardId(final int elementId, final KeyboardLayoutSet.Params params) {
        mSubtype = params.mSubtype;
        mLocale = SubtypeLocale.getSubtypeLocale(mSubtype);
        mDeviceFormFactor = params.mDeviceFormFactor;
        mOrientation = params.mOrientation;
        mWidth = params.mWidth;
        mMode = params.mMode;
        mElementId = elementId;
        mEditorInfo = editorInfo;
        mClobberSettingsKey = clobberSettingsKey;
        mShortcutKeyEnabled = shortcutKeyEnabled;
        mHasShortcutKey = hasShortcutKey;
        mLanguageSwitchKeyEnabled = languageSwitchKeyEnabled;
        mCustomActionLabel = (editorInfo.actionLabel != null)
                ? editorInfo.actionLabel.toString() : null;
        mEditorInfo = params.mEditorInfo;
        mClobberSettingsKey = params.mNoSettingsKey;
        mShortcutKeyEnabled = params.mVoiceKeyEnabled;
        mShortcutKeyOnSymbols = mShortcutKeyEnabled && !params.mVoiceKeyOnMain;
        mLanguageSwitchKeyEnabled = params.mLanguageSwitchKeyEnabled;
        mCustomActionLabel = (mEditorInfo.actionLabel != null)
                ? mEditorInfo.actionLabel.toString() : null;
        final boolean alphabetMayHaveShortcutKey = isAlphabetKeyboard(elementId)
                && !mShortcutKeyOnSymbols;
        final boolean symbolsMayHaveShortcutKey = (elementId == KeyboardId.ELEMENT_SYMBOLS)
                && mShortcutKeyOnSymbols;
        mHasShortcutKey = mShortcutKeyEnabled
                && (alphabetMayHaveShortcutKey || symbolsMayHaveShortcutKey);

        mHashCode = computeHashCode(this);
    }

    private static int computeHashCode(KeyboardId id) {
    private static int computeHashCode(final KeyboardId id) {
        return Arrays.hashCode(new Object[] {
                id.mDeviceFormFactor,
                id.mOrientation,
@@ -108,7 +113,7 @@ public final class KeyboardId {
                id.passwordInput(),
                id.mClobberSettingsKey,
                id.mShortcutKeyEnabled,
                id.mHasShortcutKey,
                id.mShortcutKeyOnSymbols,
                id.mLanguageSwitchKeyEnabled,
                id.isMultiLine(),
                id.imeAction(),
@@ -119,7 +124,7 @@ public final class KeyboardId {
        });
    }

    private boolean equals(KeyboardId other) {
    private boolean equals(final KeyboardId other) {
        if (other == this)
            return true;
        return other.mDeviceFormFactor == mDeviceFormFactor
@@ -130,7 +135,7 @@ public final class KeyboardId {
                && other.passwordInput() == passwordInput()
                && other.mClobberSettingsKey == mClobberSettingsKey
                && other.mShortcutKeyEnabled == mShortcutKeyEnabled
                && other.mHasShortcutKey == mHasShortcutKey
                && other.mShortcutKeyOnSymbols == mShortcutKeyOnSymbols
                && other.mLanguageSwitchKeyEnabled == mLanguageSwitchKeyEnabled
                && other.isMultiLine() == isMultiLine()
                && other.imeAction() == imeAction()
@@ -140,8 +145,12 @@ public final class KeyboardId {
                && other.mSubtype.equals(mSubtype);
    }

    private static boolean isAlphabetKeyboard(final int elementId) {
        return elementId < ELEMENT_SYMBOLS;
    }

    public boolean isAlphabetKeyboard() {
        return mElementId < ELEMENT_SYMBOLS;
        return isAlphabetKeyboard(mElementId);
    }

    public boolean navigateNext() {
@@ -181,7 +190,7 @@ public final class KeyboardId {
    }

    @Override
    public boolean equals(Object other) {
    public boolean equals(final Object other) {
        return other instanceof KeyboardId && equals((KeyboardId) other);
    }

@@ -192,7 +201,7 @@ public final class KeyboardId {

    @Override
    public String toString() {
        return String.format("[%s %s:%s %s-%s:%d %s %s %s%s%s%s%s%s%s%s]",
        return String.format("[%s %s:%s %s-%s:%d %s %s %s%s%s%s%s%s%s%s%s]",
                elementIdToName(mElementId),
                mLocale,
                mSubtype.getExtraValueOf(KEYBOARD_LAYOUT_SET),
@@ -204,13 +213,14 @@ public final class KeyboardId {
                (mClobberSettingsKey ? " clobberSettingsKey" : ""),
                (passwordInput() ? " passwordInput" : ""),
                (mShortcutKeyEnabled ? " shortcutKeyEnabled" : ""),
                (mShortcutKeyOnSymbols ? " shortcutKeyOnSymbols" : ""),
                (mHasShortcutKey ? " hasShortcutKey" : ""),
                (mLanguageSwitchKeyEnabled ? " languageSwitchKeyEnabled" : ""),
                (isMultiLine() ? "isMultiLine" : "")
        );
    }

    public static boolean equivalentEditorInfoForKeyboard(EditorInfo a, EditorInfo b) {
    public static boolean equivalentEditorInfoForKeyboard(final EditorInfo a, final EditorInfo b) {
        if (a == null && b == null) return true;
        if (a == null || b == null) return false;
        return a.inputType == b.inputType
@@ -218,7 +228,7 @@ public final class KeyboardId {
                && TextUtils.equals(a.privateImeOptions, b.privateImeOptions);
    }

    public static String elementIdToName(int elementId) {
    public static String elementIdToName(final int elementId) {
        switch (elementId) {
        case ELEMENT_ALPHABET: return "alphabet";
        case ELEMENT_ALPHABET_MANUAL_SHIFTED: return "alphabetManualShifted";
@@ -234,8 +244,8 @@ public final class KeyboardId {
        }
    }

    public static String deviceFormFactor(int devoceFormFactor) {
        switch (devoceFormFactor) {
    public static String deviceFormFactor(final int deviceFormFactor) {
        switch (deviceFormFactor) {
        case FORM_FACTOR_PHONE: return "phone";
        case FORM_FACTOR_TABLET7: return "tablet7";
        case FORM_FACTOR_TABLET10: return "tablet10";
@@ -243,7 +253,7 @@ public final class KeyboardId {
        }
    }

    public static String modeName(int mode) {
    public static String modeName(final int mode) {
        switch (mode) {
        case MODE_TEXT: return "text";
        case MODE_URL: return "url";
@@ -258,7 +268,7 @@ public final class KeyboardId {
        }
    }

    public static String actionName(int actionId) {
    public static String actionName(final int actionId) {
        return (actionId == IME_ACTION_CUSTOM_LABEL) ? "actionCustomLabel"
                : EditorInfoCompatUtils.imeActionName(actionId);
    }
Loading