Loading java/src/com/android/inputmethod/keyboard/Key.java +5 −5 Original line number Diff line number Diff line Loading @@ -331,16 +331,16 @@ public class Key implements Comparable<Key> { // code point nor as a surrogate pair. mLabel = new StringBuilder().appendCodePoint(code).toString(); } else { mLabel = KeySpecParser.toUpperCaseOfStringForLocale(style.getString(keyAttr, mLabel = StringUtils.toUpperCaseOfStringForLocale(style.getString(keyAttr, R.styleable.Keyboard_Key_keyLabel), needsToUpperCase, locale); } if ((mLabelFlags & LABEL_FLAGS_DISABLE_HINT_LABEL) != 0) { mHintLabel = null; } else { mHintLabel = KeySpecParser.toUpperCaseOfStringForLocale(style.getString(keyAttr, mHintLabel = StringUtils.toUpperCaseOfStringForLocale(style.getString(keyAttr, R.styleable.Keyboard_Key_keyHintLabel), needsToUpperCase, locale); } String outputText = KeySpecParser.toUpperCaseOfStringForLocale(style.getString(keyAttr, String outputText = StringUtils.toUpperCaseOfStringForLocale(style.getString(keyAttr, R.styleable.Keyboard_Key_keyOutputText), needsToUpperCase, locale); // Choose the first letter of the label as primary code if not specified. if (code == CODE_UNSPECIFIED && TextUtils.isEmpty(outputText) Loading @@ -367,9 +367,9 @@ public class Key implements Comparable<Key> { mCode = CODE_OUTPUT_TEXT; } } else { mCode = KeySpecParser.toUpperCaseOfCodeForLocale(code, needsToUpperCase, locale); mCode = StringUtils.toUpperCaseOfCodeForLocale(code, needsToUpperCase, locale); } final int altCode = KeySpecParser.toUpperCaseOfCodeForLocale( final int altCode = StringUtils.toUpperCaseOfCodeForLocale( KeySpecParser.parseCode(style.getString(keyAttr, R.styleable.Keyboard_Key_altCode), params.mCodesSet, CODE_UNSPECIFIED), needsToUpperCase, locale); Loading java/src/com/android/inputmethod/keyboard/internal/KeySpecParser.java +0 −18 Original line number Diff line number Diff line Loading @@ -21,14 +21,12 @@ import static com.android.inputmethod.latin.Constants.CODE_UNSPECIFIED; import android.text.TextUtils; import com.android.inputmethod.latin.Constants; import com.android.inputmethod.latin.LatinImeLogger; import com.android.inputmethod.latin.utils.CollectionUtils; import com.android.inputmethod.latin.utils.StringUtils; import java.util.ArrayList; import java.util.Arrays; import java.util.Locale; /** * The string parser of more keys specification. Loading Loading @@ -482,20 +480,4 @@ public final class KeySpecParser { } return value; } public static int toUpperCaseOfCodeForLocale(final int code, final boolean needsToUpperCase, final Locale locale) { if (!Constants.isLetterCode(code) || !needsToUpperCase) return code; final String text = StringUtils.newSingleCodePointString(code); final String casedText = KeySpecParser.toUpperCaseOfStringForLocale( text, needsToUpperCase, locale); return StringUtils.codePointCount(casedText) == 1 ? casedText.codePointAt(0) : CODE_UNSPECIFIED; } public static String toUpperCaseOfStringForLocale(final String text, final boolean needsToUpperCase, final Locale locale) { if (text == null || !needsToUpperCase) return text; return text.toUpperCase(locale); } } java/src/com/android/inputmethod/keyboard/internal/MoreKeySpec.java +3 −3 Original line number Diff line number Diff line Loading @@ -31,9 +31,9 @@ public final class MoreKeySpec { public MoreKeySpec(final String moreKeySpec, boolean needsToUpperCase, final Locale locale, final KeyboardCodesSet codesSet) { mLabel = KeySpecParser.toUpperCaseOfStringForLocale( mLabel = StringUtils.toUpperCaseOfStringForLocale( KeySpecParser.getLabel(moreKeySpec), needsToUpperCase, locale); final int code = KeySpecParser.toUpperCaseOfCodeForLocale( final int code = StringUtils.toUpperCaseOfCodeForLocale( KeySpecParser.getCode(moreKeySpec, codesSet), needsToUpperCase, locale); if (code == Constants.CODE_UNSPECIFIED) { // Some letter, for example German Eszett (U+00DF: "ß"), has multiple characters Loading @@ -42,7 +42,7 @@ public final class MoreKeySpec { mOutputText = mLabel; } else { mCode = code; mOutputText = KeySpecParser.toUpperCaseOfStringForLocale( mOutputText = StringUtils.toUpperCaseOfStringForLocale( KeySpecParser.getOutputText(moreKeySpec), needsToUpperCase, locale); } mIconId = KeySpecParser.getIconId(moreKeySpec); Loading java/src/com/android/inputmethod/latin/utils/StringUtils.java +18 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package com.android.inputmethod.latin.utils; import static com.android.inputmethod.latin.Constants.CODE_UNSPECIFIED; import android.text.TextUtils; import com.android.inputmethod.annotations.UsedForTesting; Loading Loading @@ -471,4 +473,20 @@ public final class StringUtils { } return bytes; } public static String toUpperCaseOfStringForLocale(final String text, final boolean needsToUpperCase, final Locale locale) { if (text == null || !needsToUpperCase) return text; return text.toUpperCase(locale); } public static int toUpperCaseOfCodeForLocale(final int code, final boolean needsToUpperCase, final Locale locale) { if (!Constants.isLetterCode(code) || !needsToUpperCase) return code; final String text = newSingleCodePointString(code); final String casedText = toUpperCaseOfStringForLocale( text, needsToUpperCase, locale); return codePointCount(casedText) == 1 ? casedText.codePointAt(0) : CODE_UNSPECIFIED; } } Loading
java/src/com/android/inputmethod/keyboard/Key.java +5 −5 Original line number Diff line number Diff line Loading @@ -331,16 +331,16 @@ public class Key implements Comparable<Key> { // code point nor as a surrogate pair. mLabel = new StringBuilder().appendCodePoint(code).toString(); } else { mLabel = KeySpecParser.toUpperCaseOfStringForLocale(style.getString(keyAttr, mLabel = StringUtils.toUpperCaseOfStringForLocale(style.getString(keyAttr, R.styleable.Keyboard_Key_keyLabel), needsToUpperCase, locale); } if ((mLabelFlags & LABEL_FLAGS_DISABLE_HINT_LABEL) != 0) { mHintLabel = null; } else { mHintLabel = KeySpecParser.toUpperCaseOfStringForLocale(style.getString(keyAttr, mHintLabel = StringUtils.toUpperCaseOfStringForLocale(style.getString(keyAttr, R.styleable.Keyboard_Key_keyHintLabel), needsToUpperCase, locale); } String outputText = KeySpecParser.toUpperCaseOfStringForLocale(style.getString(keyAttr, String outputText = StringUtils.toUpperCaseOfStringForLocale(style.getString(keyAttr, R.styleable.Keyboard_Key_keyOutputText), needsToUpperCase, locale); // Choose the first letter of the label as primary code if not specified. if (code == CODE_UNSPECIFIED && TextUtils.isEmpty(outputText) Loading @@ -367,9 +367,9 @@ public class Key implements Comparable<Key> { mCode = CODE_OUTPUT_TEXT; } } else { mCode = KeySpecParser.toUpperCaseOfCodeForLocale(code, needsToUpperCase, locale); mCode = StringUtils.toUpperCaseOfCodeForLocale(code, needsToUpperCase, locale); } final int altCode = KeySpecParser.toUpperCaseOfCodeForLocale( final int altCode = StringUtils.toUpperCaseOfCodeForLocale( KeySpecParser.parseCode(style.getString(keyAttr, R.styleable.Keyboard_Key_altCode), params.mCodesSet, CODE_UNSPECIFIED), needsToUpperCase, locale); Loading
java/src/com/android/inputmethod/keyboard/internal/KeySpecParser.java +0 −18 Original line number Diff line number Diff line Loading @@ -21,14 +21,12 @@ import static com.android.inputmethod.latin.Constants.CODE_UNSPECIFIED; import android.text.TextUtils; import com.android.inputmethod.latin.Constants; import com.android.inputmethod.latin.LatinImeLogger; import com.android.inputmethod.latin.utils.CollectionUtils; import com.android.inputmethod.latin.utils.StringUtils; import java.util.ArrayList; import java.util.Arrays; import java.util.Locale; /** * The string parser of more keys specification. Loading Loading @@ -482,20 +480,4 @@ public final class KeySpecParser { } return value; } public static int toUpperCaseOfCodeForLocale(final int code, final boolean needsToUpperCase, final Locale locale) { if (!Constants.isLetterCode(code) || !needsToUpperCase) return code; final String text = StringUtils.newSingleCodePointString(code); final String casedText = KeySpecParser.toUpperCaseOfStringForLocale( text, needsToUpperCase, locale); return StringUtils.codePointCount(casedText) == 1 ? casedText.codePointAt(0) : CODE_UNSPECIFIED; } public static String toUpperCaseOfStringForLocale(final String text, final boolean needsToUpperCase, final Locale locale) { if (text == null || !needsToUpperCase) return text; return text.toUpperCase(locale); } }
java/src/com/android/inputmethod/keyboard/internal/MoreKeySpec.java +3 −3 Original line number Diff line number Diff line Loading @@ -31,9 +31,9 @@ public final class MoreKeySpec { public MoreKeySpec(final String moreKeySpec, boolean needsToUpperCase, final Locale locale, final KeyboardCodesSet codesSet) { mLabel = KeySpecParser.toUpperCaseOfStringForLocale( mLabel = StringUtils.toUpperCaseOfStringForLocale( KeySpecParser.getLabel(moreKeySpec), needsToUpperCase, locale); final int code = KeySpecParser.toUpperCaseOfCodeForLocale( final int code = StringUtils.toUpperCaseOfCodeForLocale( KeySpecParser.getCode(moreKeySpec, codesSet), needsToUpperCase, locale); if (code == Constants.CODE_UNSPECIFIED) { // Some letter, for example German Eszett (U+00DF: "ß"), has multiple characters Loading @@ -42,7 +42,7 @@ public final class MoreKeySpec { mOutputText = mLabel; } else { mCode = code; mOutputText = KeySpecParser.toUpperCaseOfStringForLocale( mOutputText = StringUtils.toUpperCaseOfStringForLocale( KeySpecParser.getOutputText(moreKeySpec), needsToUpperCase, locale); } mIconId = KeySpecParser.getIconId(moreKeySpec); Loading
java/src/com/android/inputmethod/latin/utils/StringUtils.java +18 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package com.android.inputmethod.latin.utils; import static com.android.inputmethod.latin.Constants.CODE_UNSPECIFIED; import android.text.TextUtils; import com.android.inputmethod.annotations.UsedForTesting; Loading Loading @@ -471,4 +473,20 @@ public final class StringUtils { } return bytes; } public static String toUpperCaseOfStringForLocale(final String text, final boolean needsToUpperCase, final Locale locale) { if (text == null || !needsToUpperCase) return text; return text.toUpperCase(locale); } public static int toUpperCaseOfCodeForLocale(final int code, final boolean needsToUpperCase, final Locale locale) { if (!Constants.isLetterCode(code) || !needsToUpperCase) return code; final String text = newSingleCodePointString(code); final String casedText = toUpperCaseOfStringForLocale( text, needsToUpperCase, locale); return codePointCount(casedText) == 1 ? casedText.codePointAt(0) : CODE_UNSPECIFIED; } }