Loading java/src/com/android/inputmethod/keyboard/Key.java +9 −9 Original line number Diff line number Diff line Loading @@ -278,8 +278,8 @@ public class Key implements Comparable<Key> { mLabelFlags = style.getFlags(keyAttr, R.styleable.Keyboard_Key_keyLabelFlags) | row.getDefaultKeyLabelFlags(); final boolean needsToUpperCase = needsToUpperCase(mLabelFlags, params.mId.mElementId); final Locale locale = params.mId.mLocale; final boolean needsToUpcase = needsToUpcase(mLabelFlags, params.mId.mElementId); final Locale localeForUpcasing = params.mId.getLocales()[0]; int actionFlags = style.getFlags(keyAttr, R.styleable.Keyboard_Key_keyActionFlags); String[] moreKeys = style.getStringArray(keyAttr, R.styleable.Keyboard_Key_moreKeys); Loading Loading @@ -321,7 +321,7 @@ public class Key implements Comparable<Key> { actionFlags |= ACTION_FLAGS_ENABLE_LONG_PRESS; mMoreKeys = new MoreKeySpec[moreKeys.length]; for (int i = 0; i < moreKeys.length; i++) { mMoreKeys[i] = new MoreKeySpec(moreKeys[i], needsToUpperCase, locale); mMoreKeys[i] = new MoreKeySpec(moreKeys[i], needsToUpcase, localeForUpcasing); } } else { mMoreKeys = null; Loading @@ -342,16 +342,16 @@ public class Key implements Comparable<Key> { mLabel = new StringBuilder().appendCodePoint(code).toString(); } else { mLabel = StringUtils.toUpperCaseOfStringForLocale( KeySpecParser.getLabel(keySpec), needsToUpperCase, locale); KeySpecParser.getLabel(keySpec), needsToUpcase, localeForUpcasing); } if ((mLabelFlags & LABEL_FLAGS_DISABLE_HINT_LABEL) != 0) { mHintLabel = null; } else { mHintLabel = StringUtils.toUpperCaseOfStringForLocale(style.getString(keyAttr, R.styleable.Keyboard_Key_keyHintLabel), needsToUpperCase, locale); R.styleable.Keyboard_Key_keyHintLabel), needsToUpcase, localeForUpcasing); } String outputText = StringUtils.toUpperCaseOfStringForLocale( KeySpecParser.getOutputText(keySpec), needsToUpperCase, locale); KeySpecParser.getOutputText(keySpec), needsToUpcase, localeForUpcasing); // Choose the first letter of the label as primary code if not specified. if (code == CODE_UNSPECIFIED && TextUtils.isEmpty(outputText) && !TextUtils.isEmpty(mLabel)) { Loading @@ -377,12 +377,12 @@ public class Key implements Comparable<Key> { mCode = CODE_OUTPUT_TEXT; } } else { mCode = StringUtils.toUpperCaseOfCodeForLocale(code, needsToUpperCase, locale); mCode = StringUtils.toUpperCaseOfCodeForLocale(code, needsToUpcase, localeForUpcasing); } final int altCodeInAttr = KeySpecParser.parseCode( style.getString(keyAttr, R.styleable.Keyboard_Key_altCode), CODE_UNSPECIFIED); final int altCode = StringUtils.toUpperCaseOfCodeForLocale( altCodeInAttr, needsToUpperCase, locale); altCodeInAttr, needsToUpcase, localeForUpcasing); mOptionalAttributes = OptionalAttributes.newInstance(outputText, altCode, disabledIconId, visualInsetsLeft, visualInsetsRight); mKeyVisualAttributes = KeyVisualAttributes.newInstance(keyAttr); Loading Loading @@ -432,7 +432,7 @@ public class Key implements Comparable<Key> { return (filteredMoreKeys == moreKeys) ? key : new Key(key, filteredMoreKeys); } private static boolean needsToUpperCase(final int labelFlags, final int keyboardElementId) { private static boolean needsToUpcase(final int labelFlags, final int keyboardElementId) { if ((labelFlags & LABEL_FLAGS_PRESERVE_CASE) != 0) return false; switch (keyboardElementId) { case KeyboardId.ELEMENT_ALPHABET_MANUAL_SHIFTED: Loading java/src/com/android/inputmethod/keyboard/KeyboardId.java +6 −3 Original line number Diff line number Diff line Loading @@ -63,7 +63,6 @@ public final class KeyboardId { public static final int ELEMENT_EMOJI_CATEGORY6 = 16; public final RichInputMethodSubtype mSubtype; public final Locale mLocale; public final int mWidth; public final int mHeight; public final int mMode; Loading @@ -79,7 +78,6 @@ public final class KeyboardId { public KeyboardId(final int elementId, final KeyboardLayoutSet.Params params) { mSubtype = params.mSubtype; mLocale = SubtypeLocaleUtils.getSubtypeLocale(mSubtype); mWidth = params.mKeyboardWidth; mHeight = params.mKeyboardHeight; mMode = params.mMode; Loading Loading @@ -167,6 +165,10 @@ public final class KeyboardId { return InputTypeUtils.getImeOptionsActionIdFromEditorInfo(mEditorInfo); } public Locale[] getLocales() { return mSubtype.getLocales(); } @Override public boolean equals(final Object other) { return other instanceof KeyboardId && equals((KeyboardId) other); Loading @@ -181,7 +183,8 @@ public final class KeyboardId { public String toString() { return String.format(Locale.ROOT, "[%s %s:%s %dx%d %s %s%s%s%s%s%s%s%s%s]", elementIdToName(mElementId), mLocale, mSubtype.getExtraValueOf(KEYBOARD_LAYOUT_SET), Arrays.deepToString(mSubtype.getLocales()), mSubtype.getExtraValueOf(KEYBOARD_LAYOUT_SET), mWidth, mHeight, modeName(mMode), actionName(imeAction()), Loading java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java +4 −2 Original line number Diff line number Diff line Loading @@ -120,7 +120,9 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions { mKeyboardLayoutSet = builder.build(); try { mState.onLoadKeyboard(currentAutoCapsState, currentRecapitalizeState); mKeyboardTextsSet.setLocale(mSubtypeSwitcher.getCurrentSubtypeLocale(), mThemeContext); // TODO: revisit this for multi-lingual input mKeyboardTextsSet.setLocale(mSubtypeSwitcher.getCurrentSubtypeLocales()[0], mThemeContext); } catch (KeyboardLayoutSetException e) { Log.w(TAG, "loading keyboard failed: " + e.mKeyboardId, e.getCause()); return; Loading Loading @@ -161,7 +163,7 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions { currentSettingsValues.mKeyPreviewDismissDuration); keyboardView.updateShortcutKey(mSubtypeSwitcher.isShortcutImeReady()); final boolean subtypeChanged = (oldKeyboard == null) || !keyboard.mId.mLocale.equals(oldKeyboard.mId.mLocale); || !keyboard.mId.mSubtype.equals(oldKeyboard.mId.mSubtype); final int languageOnSpacebarFormatType = mSubtypeSwitcher.getLanguageOnSpacebarFormatType( keyboard.mId.mSubtype); final boolean hasMultipleEnabledIMEsOrSubtypes = RichInputMethodManager.getInstance() Loading java/src/com/android/inputmethod/keyboard/MainKeyboardView.java +5 −0 Original line number Diff line number Diff line Loading @@ -875,6 +875,11 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack // Layout language name on spacebar. private String layoutLanguageOnSpacebar(final Paint paint, final RichInputMethodSubtype subtype, final int width) { if (mLanguageOnSpacebarFormatType == LanguageOnSpacebarHelper.FORMAT_TYPE_MULTIPLE) { // TODO: return an appropriate string return ""; } // Choose appropriate language name to fit into the width. if (mLanguageOnSpacebarFormatType == LanguageOnSpacebarHelper.FORMAT_TYPE_FULL_LOCALE) { final String fullText = subtype.getFullDisplayName(); Loading java/src/com/android/inputmethod/keyboard/internal/KeyboardBuilder.java +24 −7 Original line number Diff line number Diff line Loading @@ -45,6 +45,7 @@ import org.xmlpull.v1.XmlPullParserException; import java.io.IOException; import java.util.Arrays; import java.util.Locale; /** * Keyboard Building helper. Loading Loading @@ -281,7 +282,8 @@ public class KeyboardBuilder<KP extends KeyboardParams> { params.mThemeId = keyboardAttr.getInt(R.styleable.Keyboard_themeId, 0); params.mIconsSet.loadIcons(keyboardAttr); params.mTextsSet.setLocale(params.mId.mLocale, mContext); // TODO: this needs to be revisited for multi-lingual input. params.mTextsSet.setLocale(params.mId.getLocales()[0], mContext); final int resourceId = keyboardAttr.getResourceId( R.styleable.Keyboard_touchPositionCorrectionData, 0); Loading Loading @@ -672,12 +674,10 @@ public class KeyboardBuilder<KP extends KeyboardParams> { R.styleable.Keyboard_Case_imeAction, id.imeAction()); final boolean isIconDefinedMatched = isIconDefined(caseAttr, R.styleable.Keyboard_Case_isIconDefined, mParams.mIconsSet); final boolean localeCodeMatched = matchString(caseAttr, R.styleable.Keyboard_Case_localeCode, id.mLocale.toString()); final boolean languageCodeMatched = matchString(caseAttr, R.styleable.Keyboard_Case_languageCode, id.mLocale.getLanguage()); final boolean countryCodeMatched = matchString(caseAttr, R.styleable.Keyboard_Case_countryCode, id.mLocale.getCountry()); final Locale[] locales = id.getLocales(); final boolean localeCodeMatched = matchLocaleCodes(caseAttr, locales); final boolean languageCodeMatched = matchLanguageCodes(caseAttr, locales); final boolean countryCodeMatched = matchCountryCodes(caseAttr, locales); final boolean splitLayoutMatched = matchBoolean(caseAttr, R.styleable.Keyboard_Case_isSplitLayout, id.mIsSplitLayout); final boolean selected = keyboardLayoutSetMatched && keyboardLayoutSetElementMatched Loading Loading @@ -733,6 +733,23 @@ public class KeyboardBuilder<KP extends KeyboardParams> { } } private boolean matchLocaleCodes(TypedArray caseAttr, final Locale[] locales) { // TODO: adujst this for multilingual input return matchString(caseAttr, R.styleable.Keyboard_Case_localeCode, locales[0].toString()); } private boolean matchLanguageCodes(TypedArray caseAttr, Locale[] locales) { // TODO: adujst this for multilingual input return matchString(caseAttr, R.styleable.Keyboard_Case_languageCode, locales[0].getLanguage()); } private boolean matchCountryCodes(TypedArray caseAttr, Locale[] locales) { // TODO: adujst this for multilingual input return matchString(caseAttr, R.styleable.Keyboard_Case_countryCode, locales[0].getCountry()); } private static boolean matchInteger(final TypedArray a, final int index, final int value) { // If <case> does not have "index" attribute, that means this <case> is wild-card for // the attribute. Loading Loading
java/src/com/android/inputmethod/keyboard/Key.java +9 −9 Original line number Diff line number Diff line Loading @@ -278,8 +278,8 @@ public class Key implements Comparable<Key> { mLabelFlags = style.getFlags(keyAttr, R.styleable.Keyboard_Key_keyLabelFlags) | row.getDefaultKeyLabelFlags(); final boolean needsToUpperCase = needsToUpperCase(mLabelFlags, params.mId.mElementId); final Locale locale = params.mId.mLocale; final boolean needsToUpcase = needsToUpcase(mLabelFlags, params.mId.mElementId); final Locale localeForUpcasing = params.mId.getLocales()[0]; int actionFlags = style.getFlags(keyAttr, R.styleable.Keyboard_Key_keyActionFlags); String[] moreKeys = style.getStringArray(keyAttr, R.styleable.Keyboard_Key_moreKeys); Loading Loading @@ -321,7 +321,7 @@ public class Key implements Comparable<Key> { actionFlags |= ACTION_FLAGS_ENABLE_LONG_PRESS; mMoreKeys = new MoreKeySpec[moreKeys.length]; for (int i = 0; i < moreKeys.length; i++) { mMoreKeys[i] = new MoreKeySpec(moreKeys[i], needsToUpperCase, locale); mMoreKeys[i] = new MoreKeySpec(moreKeys[i], needsToUpcase, localeForUpcasing); } } else { mMoreKeys = null; Loading @@ -342,16 +342,16 @@ public class Key implements Comparable<Key> { mLabel = new StringBuilder().appendCodePoint(code).toString(); } else { mLabel = StringUtils.toUpperCaseOfStringForLocale( KeySpecParser.getLabel(keySpec), needsToUpperCase, locale); KeySpecParser.getLabel(keySpec), needsToUpcase, localeForUpcasing); } if ((mLabelFlags & LABEL_FLAGS_DISABLE_HINT_LABEL) != 0) { mHintLabel = null; } else { mHintLabel = StringUtils.toUpperCaseOfStringForLocale(style.getString(keyAttr, R.styleable.Keyboard_Key_keyHintLabel), needsToUpperCase, locale); R.styleable.Keyboard_Key_keyHintLabel), needsToUpcase, localeForUpcasing); } String outputText = StringUtils.toUpperCaseOfStringForLocale( KeySpecParser.getOutputText(keySpec), needsToUpperCase, locale); KeySpecParser.getOutputText(keySpec), needsToUpcase, localeForUpcasing); // Choose the first letter of the label as primary code if not specified. if (code == CODE_UNSPECIFIED && TextUtils.isEmpty(outputText) && !TextUtils.isEmpty(mLabel)) { Loading @@ -377,12 +377,12 @@ public class Key implements Comparable<Key> { mCode = CODE_OUTPUT_TEXT; } } else { mCode = StringUtils.toUpperCaseOfCodeForLocale(code, needsToUpperCase, locale); mCode = StringUtils.toUpperCaseOfCodeForLocale(code, needsToUpcase, localeForUpcasing); } final int altCodeInAttr = KeySpecParser.parseCode( style.getString(keyAttr, R.styleable.Keyboard_Key_altCode), CODE_UNSPECIFIED); final int altCode = StringUtils.toUpperCaseOfCodeForLocale( altCodeInAttr, needsToUpperCase, locale); altCodeInAttr, needsToUpcase, localeForUpcasing); mOptionalAttributes = OptionalAttributes.newInstance(outputText, altCode, disabledIconId, visualInsetsLeft, visualInsetsRight); mKeyVisualAttributes = KeyVisualAttributes.newInstance(keyAttr); Loading Loading @@ -432,7 +432,7 @@ public class Key implements Comparable<Key> { return (filteredMoreKeys == moreKeys) ? key : new Key(key, filteredMoreKeys); } private static boolean needsToUpperCase(final int labelFlags, final int keyboardElementId) { private static boolean needsToUpcase(final int labelFlags, final int keyboardElementId) { if ((labelFlags & LABEL_FLAGS_PRESERVE_CASE) != 0) return false; switch (keyboardElementId) { case KeyboardId.ELEMENT_ALPHABET_MANUAL_SHIFTED: Loading
java/src/com/android/inputmethod/keyboard/KeyboardId.java +6 −3 Original line number Diff line number Diff line Loading @@ -63,7 +63,6 @@ public final class KeyboardId { public static final int ELEMENT_EMOJI_CATEGORY6 = 16; public final RichInputMethodSubtype mSubtype; public final Locale mLocale; public final int mWidth; public final int mHeight; public final int mMode; Loading @@ -79,7 +78,6 @@ public final class KeyboardId { public KeyboardId(final int elementId, final KeyboardLayoutSet.Params params) { mSubtype = params.mSubtype; mLocale = SubtypeLocaleUtils.getSubtypeLocale(mSubtype); mWidth = params.mKeyboardWidth; mHeight = params.mKeyboardHeight; mMode = params.mMode; Loading Loading @@ -167,6 +165,10 @@ public final class KeyboardId { return InputTypeUtils.getImeOptionsActionIdFromEditorInfo(mEditorInfo); } public Locale[] getLocales() { return mSubtype.getLocales(); } @Override public boolean equals(final Object other) { return other instanceof KeyboardId && equals((KeyboardId) other); Loading @@ -181,7 +183,8 @@ public final class KeyboardId { public String toString() { return String.format(Locale.ROOT, "[%s %s:%s %dx%d %s %s%s%s%s%s%s%s%s%s]", elementIdToName(mElementId), mLocale, mSubtype.getExtraValueOf(KEYBOARD_LAYOUT_SET), Arrays.deepToString(mSubtype.getLocales()), mSubtype.getExtraValueOf(KEYBOARD_LAYOUT_SET), mWidth, mHeight, modeName(mMode), actionName(imeAction()), Loading
java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java +4 −2 Original line number Diff line number Diff line Loading @@ -120,7 +120,9 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions { mKeyboardLayoutSet = builder.build(); try { mState.onLoadKeyboard(currentAutoCapsState, currentRecapitalizeState); mKeyboardTextsSet.setLocale(mSubtypeSwitcher.getCurrentSubtypeLocale(), mThemeContext); // TODO: revisit this for multi-lingual input mKeyboardTextsSet.setLocale(mSubtypeSwitcher.getCurrentSubtypeLocales()[0], mThemeContext); } catch (KeyboardLayoutSetException e) { Log.w(TAG, "loading keyboard failed: " + e.mKeyboardId, e.getCause()); return; Loading Loading @@ -161,7 +163,7 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions { currentSettingsValues.mKeyPreviewDismissDuration); keyboardView.updateShortcutKey(mSubtypeSwitcher.isShortcutImeReady()); final boolean subtypeChanged = (oldKeyboard == null) || !keyboard.mId.mLocale.equals(oldKeyboard.mId.mLocale); || !keyboard.mId.mSubtype.equals(oldKeyboard.mId.mSubtype); final int languageOnSpacebarFormatType = mSubtypeSwitcher.getLanguageOnSpacebarFormatType( keyboard.mId.mSubtype); final boolean hasMultipleEnabledIMEsOrSubtypes = RichInputMethodManager.getInstance() Loading
java/src/com/android/inputmethod/keyboard/MainKeyboardView.java +5 −0 Original line number Diff line number Diff line Loading @@ -875,6 +875,11 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack // Layout language name on spacebar. private String layoutLanguageOnSpacebar(final Paint paint, final RichInputMethodSubtype subtype, final int width) { if (mLanguageOnSpacebarFormatType == LanguageOnSpacebarHelper.FORMAT_TYPE_MULTIPLE) { // TODO: return an appropriate string return ""; } // Choose appropriate language name to fit into the width. if (mLanguageOnSpacebarFormatType == LanguageOnSpacebarHelper.FORMAT_TYPE_FULL_LOCALE) { final String fullText = subtype.getFullDisplayName(); Loading
java/src/com/android/inputmethod/keyboard/internal/KeyboardBuilder.java +24 −7 Original line number Diff line number Diff line Loading @@ -45,6 +45,7 @@ import org.xmlpull.v1.XmlPullParserException; import java.io.IOException; import java.util.Arrays; import java.util.Locale; /** * Keyboard Building helper. Loading Loading @@ -281,7 +282,8 @@ public class KeyboardBuilder<KP extends KeyboardParams> { params.mThemeId = keyboardAttr.getInt(R.styleable.Keyboard_themeId, 0); params.mIconsSet.loadIcons(keyboardAttr); params.mTextsSet.setLocale(params.mId.mLocale, mContext); // TODO: this needs to be revisited for multi-lingual input. params.mTextsSet.setLocale(params.mId.getLocales()[0], mContext); final int resourceId = keyboardAttr.getResourceId( R.styleable.Keyboard_touchPositionCorrectionData, 0); Loading Loading @@ -672,12 +674,10 @@ public class KeyboardBuilder<KP extends KeyboardParams> { R.styleable.Keyboard_Case_imeAction, id.imeAction()); final boolean isIconDefinedMatched = isIconDefined(caseAttr, R.styleable.Keyboard_Case_isIconDefined, mParams.mIconsSet); final boolean localeCodeMatched = matchString(caseAttr, R.styleable.Keyboard_Case_localeCode, id.mLocale.toString()); final boolean languageCodeMatched = matchString(caseAttr, R.styleable.Keyboard_Case_languageCode, id.mLocale.getLanguage()); final boolean countryCodeMatched = matchString(caseAttr, R.styleable.Keyboard_Case_countryCode, id.mLocale.getCountry()); final Locale[] locales = id.getLocales(); final boolean localeCodeMatched = matchLocaleCodes(caseAttr, locales); final boolean languageCodeMatched = matchLanguageCodes(caseAttr, locales); final boolean countryCodeMatched = matchCountryCodes(caseAttr, locales); final boolean splitLayoutMatched = matchBoolean(caseAttr, R.styleable.Keyboard_Case_isSplitLayout, id.mIsSplitLayout); final boolean selected = keyboardLayoutSetMatched && keyboardLayoutSetElementMatched Loading Loading @@ -733,6 +733,23 @@ public class KeyboardBuilder<KP extends KeyboardParams> { } } private boolean matchLocaleCodes(TypedArray caseAttr, final Locale[] locales) { // TODO: adujst this for multilingual input return matchString(caseAttr, R.styleable.Keyboard_Case_localeCode, locales[0].toString()); } private boolean matchLanguageCodes(TypedArray caseAttr, Locale[] locales) { // TODO: adujst this for multilingual input return matchString(caseAttr, R.styleable.Keyboard_Case_languageCode, locales[0].getLanguage()); } private boolean matchCountryCodes(TypedArray caseAttr, Locale[] locales) { // TODO: adujst this for multilingual input return matchString(caseAttr, R.styleable.Keyboard_Case_countryCode, locales[0].getCountry()); } private static boolean matchInteger(final TypedArray a, final int index, final int value) { // If <case> does not have "index" attribute, that means this <case> is wild-card for // the attribute. Loading