diff options
author | 2012-05-28 03:22:46 -0700 | |
---|---|---|
committer | 2012-05-28 03:22:46 -0700 | |
commit | e09520290fbcaff9a143e8c8bce80161b0e2c5a1 (patch) | |
tree | 227f296bf925cfb1b8f6fa734d82bca808fa0d49 /java/src | |
parent | 7fe18b62b94e900f9e1ef00589a5422e586fbe08 (diff) | |
parent | 0a3362d26474cbd60bf870be7ad1413359e4fad6 (diff) | |
download | latinime-e09520290fbcaff9a143e8c8bce80161b0e2c5a1.tar.gz latinime-e09520290fbcaff9a143e8c8bce80161b0e2c5a1.tar.xz latinime-e09520290fbcaff9a143e8c8bce80161b0e2c5a1.zip |
Merge "Make KeySpecParser case sensitive again" into jb-dev
Diffstat (limited to 'java/src')
3 files changed, 16 insertions, 30 deletions
diff --git a/java/src/com/android/inputmethod/keyboard/internal/KeySpecParser.java b/java/src/com/android/inputmethod/keyboard/internal/KeySpecParser.java index b95bddc81..c4452a5f5 100644 --- a/java/src/com/android/inputmethod/keyboard/internal/KeySpecParser.java +++ b/java/src/com/android/inputmethod/keyboard/internal/KeySpecParser.java @@ -83,13 +83,13 @@ public class KeySpecParser { } private static boolean hasIcon(String moreKeySpec) { - return moreKeySpec.regionMatches(true, 0, PREFIX_ICON, 0, PREFIX_ICON.length()); + return moreKeySpec.startsWith(PREFIX_ICON); } private static boolean hasCode(String moreKeySpec) { final int end = indexOfLabelEnd(moreKeySpec, 0); - if (end > 0 && end + 1 < moreKeySpec.length() && moreKeySpec.regionMatches( - true, end + 1, PREFIX_CODE, 0, PREFIX_CODE.length())) { + if (end > 0 && end + 1 < moreKeySpec.length() && moreKeySpec.startsWith( + PREFIX_CODE, end + 1)) { return true; } return false; @@ -210,9 +210,9 @@ public class KeySpecParser { public static int parseCode(String text, KeyboardCodesSet codesSet, int defCode) { if (text == null) return defCode; - if (text.regionMatches(true, 0, PREFIX_CODE, 0, PREFIX_CODE.length())) { + if (text.startsWith(PREFIX_CODE)) { return codesSet.getCode(text.substring(PREFIX_CODE.length())); - } else if (text.regionMatches(true, 0, PREFIX_HEX, 0, PREFIX_HEX.length())) { + } else if (text.startsWith(PREFIX_HEX)) { return Integer.parseInt(text.substring(PREFIX_HEX.length()), 16); } else { return Integer.parseInt(text); @@ -359,8 +359,7 @@ public class KeySpecParser { sb = null; for (int pos = 0; pos < size; pos++) { final char c = text.charAt(pos); - if (text.regionMatches(true, pos, PREFIX_TEXT, 0, prefixLen) - && textsSet != null) { + if (text.startsWith(PREFIX_TEXT, pos) && textsSet != null) { if (sb == null) { sb = new StringBuilder(text.substring(0, pos)); } @@ -392,8 +391,7 @@ public class KeySpecParser { for (int pos = start; pos < size; pos++) { final char c = text.charAt(pos); // Label name should be consisted of [a-zA-Z_0-9]. - if ((c >= 'a' && c <= 'z') || c == '_' || (c >= '0' && c <= '9') - || (c >= 'A' && c <= 'Z')) { + if ((c >= 'a' && c <= 'z') || c == '_' || (c >= '0' && c <= '9')) { continue; } return pos; @@ -449,7 +447,7 @@ public class KeySpecParser { int value = defaultValue; for (int i = 0; i < moreKeys.length; i++) { final String moreKeySpec = moreKeys[i]; - if (moreKeySpec == null || !moreKeySpec.regionMatches(true, 0, key, 0, keyLen)) { + if (moreKeySpec == null || !moreKeySpec.startsWith(key)) { continue; } moreKeys[i] = null; @@ -473,7 +471,7 @@ public class KeySpecParser { boolean value = false; for (int i = 0; i < moreKeys.length; i++) { final String moreKeySpec = moreKeys[i]; - if (moreKeySpec == null || !moreKeySpec.equalsIgnoreCase(key)) { + if (moreKeySpec == null || !moreKeySpec.equals(key)) { continue; } moreKeys[i] = null; diff --git a/java/src/com/android/inputmethod/keyboard/internal/KeyboardIconsSet.java b/java/src/com/android/inputmethod/keyboard/internal/KeyboardIconsSet.java index a86a9577f..540e63b3f 100644 --- a/java/src/com/android/inputmethod/keyboard/internal/KeyboardIconsSet.java +++ b/java/src/com/android/inputmethod/keyboard/internal/KeyboardIconsSet.java @@ -34,9 +34,8 @@ public class KeyboardIconsSet { private static final HashMap<Integer, Integer> ATTR_ID_TO_ICON_ID = new HashMap<Integer, Integer>(); - // Lower case icon name to icon id map. - private static final HashMap<String, Integer> sLowerCaseNameToIdsMap = - new HashMap<String, Integer>(); + // Icon name to icon id map. + private static final HashMap<String, Integer> sNameToIdsMap = new HashMap<String, Integer>(); private static final Object[] NAMES_AND_ATTR_IDS = { "undefined", ATTR_UNDEFINED, @@ -70,7 +69,7 @@ public class KeyboardIconsSet { if (attrId != ATTR_UNDEFINED) { ATTR_ID_TO_ICON_ID.put(attrId, iconId); } - sLowerCaseNameToIdsMap.put(name, iconId); + sNameToIdsMap.put(name, iconId); ICON_NAMES[iconId] = name; iconId++; } @@ -100,10 +99,7 @@ public class KeyboardIconsSet { } static int getIconId(final String name) { - Integer iconId = sLowerCaseNameToIdsMap.get(name); - if (iconId == null) { - iconId = sLowerCaseNameToIdsMap.get(name.toLowerCase()); - } + Integer iconId = sNameToIdsMap.get(name); if (iconId != null) { return iconId; } diff --git a/java/src/com/android/inputmethod/keyboard/internal/KeyboardTextsSet.java b/java/src/com/android/inputmethod/keyboard/internal/KeyboardTextsSet.java index 425b5e0bf..f429a3e52 100644 --- a/java/src/com/android/inputmethod/keyboard/internal/KeyboardTextsSet.java +++ b/java/src/com/android/inputmethod/keyboard/internal/KeyboardTextsSet.java @@ -47,7 +47,7 @@ public final class KeyboardTextsSet { // Language to texts map. private static final HashMap<String, String[]> sLocaleToTextsMap = new HashMap<String, String[]>(); - private static final HashMap<String, Integer> sLowerCaseNameToIdsMap = + private static final HashMap<String, Integer> sNameToIdsMap = new HashMap<String, Integer>(); private String[] mTexts; @@ -77,19 +77,11 @@ public final class KeyboardTextsSet { } public String getText(final String name) { - String lowerCaseName = null; String text = mResourceNameToTextsMap.get(name); - if (text == null) { - lowerCaseName = name.toLowerCase(); - text = mResourceNameToTextsMap.get(lowerCaseName); - } if (text != null) { return text; } - Integer id = sLowerCaseNameToIdsMap.get(name); - if (id == null) { - id = sLowerCaseNameToIdsMap.get(lowerCaseName); // lowerCaseName != null - } + final Integer id = sNameToIdsMap.get(name); if (id == null) throw new RuntimeException("Unknown label: " + name); text = (id < mTexts.length) ? mTexts[id] : null; return (text == null) ? LANGUAGE_DEFAULT[id] : text; @@ -2484,7 +2476,7 @@ public final class KeyboardTextsSet { static { int id = 0; for (final String name : NAMES) { - sLowerCaseNameToIdsMap.put(name, id++); + sNameToIdsMap.put(name, id++); } for (int i = 0; i < LANGUAGES_AND_TEXTS.length; i += 2) { |