From 8eaf75aa7bfa471e17626b1741f63475353bf36b Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" Date: Mon, 10 Dec 2012 19:46:23 -0800 Subject: [PATCH] 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 --- java/res/values/attrs.xml | 1 + java/res/xml-sw600dp/key_styles_common.xml | 19 +++-- java/res/xml-sw768dp/key_styles_common.xml | 21 +++--- java/res/xml/key_styles_common.xml | 36 +++++----- .../inputmethod/keyboard/KeyboardId.java | 70 +++++++++++-------- .../keyboard/KeyboardLayoutSet.java | 26 ++----- .../keyboard/internal/KeyboardBuilder.java | 12 ++-- 7 files changed, 91 insertions(+), 94 deletions(-) diff --git a/java/res/values/attrs.xml b/java/res/values/attrs.xml index 3eb27e76b..2f1a209fc 100644 --- a/java/res/values/attrs.xml +++ b/java/res/values/attrs.xml @@ -389,6 +389,7 @@ + diff --git a/java/res/xml-sw600dp/key_styles_common.xml b/java/res/xml-sw600dp/key_styles_common.xml index bf2e76a6b..6b06ce77a 100644 --- a/java/res/xml-sw600dp/key_styles_common.xml +++ b/java/res/xml-sw600dp/key_styles_common.xml @@ -154,31 +154,30 @@ + + latin:parentStyle="baseForLayoutSwitchKeyStyle" /> + latin:parentStyle="baseForLayoutSwitchKeyStyle" /> + latin:parentStyle="baseForLayoutSwitchKeyStyle" /> + + latin:parentStyle="baseForLayoutSwitchKeyStyle" /> + latin:parentStyle="baseForLayoutSwitchKeyStyle" /> + latin:parentStyle="baseForLayoutSwitchKeyStyle" /> + + latin:parentStyle="baseForLayoutSwitchKeyStyle" /> + latin:parentStyle="baseForLayoutSwitchKeyStyle" /> + + latin:parentStyle="baseForLayoutSwitchKeyStyle" /> + latin:parentStyle="baseForLayoutSwitchKeyStyle" /> + latin:parentStyle="baseForToSymbolKeyStyle" /> mKeyboardLayoutSetElementIdToParamsMap = CollectionUtils.newSparseArray(); - public Params() {} } public static void clearKeyboardCache() { @@ -149,7 +149,11 @@ public final class KeyboardLayoutSet { elementParams = mParams.mKeyboardLayoutSetElementIdToParamsMap.get( KeyboardId.ELEMENT_ALPHABET); } - final KeyboardId id = getKeyboardId(keyboardLayoutSetElementId); + // Note: The keyboard for each shift state, and mode are represented as an elementName + // attribute in a keyboard_layout_set XML file. Also each keyboard layout XML resource is + // specified as an elementKeyboard attribute in the file. + // The KeyboardId is an internal key for a Keyboard object. + final KeyboardId id = new KeyboardId(keyboardLayoutSetElementId, mParams); try { return getKeyboard(elementParams, id); } catch (RuntimeException e) { @@ -187,22 +191,6 @@ public final class KeyboardLayoutSet { return keyboard; } - // Note: The keyboard for each locale, shift state, and mode are represented as - // KeyboardLayoutSet element id that is a key in keyboard_set.xml. Also that file specifies - // which XML layout should be used for each keyboard. The KeyboardId is an internal key for - // Keyboard object. - private KeyboardId getKeyboardId(final int keyboardLayoutSetElementId) { - final Params params = mParams; - final boolean isSymbols = (keyboardLayoutSetElementId == KeyboardId.ELEMENT_SYMBOLS - || keyboardLayoutSetElementId == KeyboardId.ELEMENT_SYMBOLS_SHIFTED); - final boolean hasShortcutKey = params.mVoiceKeyEnabled - && (isSymbols != params.mVoiceKeyOnMain); - return new KeyboardId(keyboardLayoutSetElementId, params.mSubtype, params.mDeviceFormFactor, - params.mOrientation, params.mWidth, params.mMode, params.mEditorInfo, - params.mNoSettingsKey, params.mVoiceKeyEnabled, hasShortcutKey, - params.mLanguageSwitchKeyEnabled); - } - public static final class Builder { private final Context mContext; private final String mPackageName; diff --git a/java/src/com/android/inputmethod/keyboard/internal/KeyboardBuilder.java b/java/src/com/android/inputmethod/keyboard/internal/KeyboardBuilder.java index 36342688e..da418f41a 100644 --- a/java/src/com/android/inputmethod/keyboard/internal/KeyboardBuilder.java +++ b/java/src/com/android/inputmethod/keyboard/internal/KeyboardBuilder.java @@ -622,6 +622,8 @@ public class KeyboardBuilder { R.styleable.Keyboard_Case_clobberSettingsKey, id.mClobberSettingsKey); final boolean shortcutKeyEnabledMatched = matchBoolean(a, R.styleable.Keyboard_Case_shortcutKeyEnabled, id.mShortcutKeyEnabled); + final boolean shortcutKeyOnSymbolsMatched = matchBoolean(a, + R.styleable.Keyboard_Case_shortcutKeyOnSymbols, id.mShortcutKeyOnSymbols); final boolean hasShortcutKeyMatched = matchBoolean(a, R.styleable.Keyboard_Case_hasShortcutKey, id.mHasShortcutKey); final boolean languageSwitchKeyEnabledMatched = matchBoolean(a, @@ -640,12 +642,12 @@ public class KeyboardBuilder { final boolean selected = keyboardLayoutSetElementMatched && modeMatched && navigateNextMatched && navigatePreviousMatched && passwordInputMatched && clobberSettingsKeyMatched && shortcutKeyEnabledMatched - && hasShortcutKeyMatched && languageSwitchKeyEnabledMatched - && isMultiLineMatched && imeActionMatched && localeCodeMatched - && languageCodeMatched && countryCodeMatched; + && shortcutKeyOnSymbolsMatched && hasShortcutKeyMatched + && languageSwitchKeyEnabledMatched && isMultiLineMatched && imeActionMatched + && localeCodeMatched && languageCodeMatched && countryCodeMatched; if (DEBUG) { - startTag("<%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s>%s", TAG_CASE, + startTag("<%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s>%s", TAG_CASE, textAttr(a.getString( R.styleable.Keyboard_Case_keyboardLayoutSetElement), "keyboardLayoutSetElement"), @@ -662,6 +664,8 @@ public class KeyboardBuilder { "passwordInput"), booleanAttr(a, R.styleable.Keyboard_Case_shortcutKeyEnabled, "shortcutKeyEnabled"), + booleanAttr(a, R.styleable.Keyboard_Case_shortcutKeyOnSymbols, + "shortcutKeyOnSymbols"), booleanAttr(a, R.styleable.Keyboard_Case_hasShortcutKey, "hasShortcutKey"), booleanAttr(a, R.styleable.Keyboard_Case_languageSwitchKeyEnabled,