diff options
author | 2012-04-19 21:21:18 -0700 | |
---|---|---|
committer | 2012-04-19 21:21:18 -0700 | |
commit | 050b577bfb9a033cfa049b2d4be2a15609ea7ce2 (patch) | |
tree | 796a8c3bfd8a0e770dac200dd6be5fbc7fba2a0d /tools | |
parent | 5b92113cdb3158adfebc27eb4842765a8459d635 (diff) | |
parent | 2f16fd40faab7287dfcae4899050b9df360d0c29 (diff) | |
download | latinime-050b577bfb9a033cfa049b2d4be2a15609ea7ce2.tar.gz latinime-050b577bfb9a033cfa049b2d4be2a15609ea7ce2.tar.xz latinime-050b577bfb9a033cfa049b2d4be2a15609ea7ce2.zip |
Merge "Make KeySpecParser case insensitive"
Diffstat (limited to 'tools')
-rw-r--r-- | tools/makelabel/res/com/android/inputmethod/keyboard/internal/KeyboardLabelsSet.tmpl | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/tools/makelabel/res/com/android/inputmethod/keyboard/internal/KeyboardLabelsSet.tmpl b/tools/makelabel/res/com/android/inputmethod/keyboard/internal/KeyboardLabelsSet.tmpl index 0e887e494..72f4edda7 100644 --- a/tools/makelabel/res/com/android/inputmethod/keyboard/internal/KeyboardLabelsSet.tmpl +++ b/tools/makelabel/res/com/android/inputmethod/keyboard/internal/KeyboardLabelsSet.tmpl @@ -31,7 +31,8 @@ public final class KeyboardLabelsSet { // Language to labels map. private static final HashMap<String, String[]> sLocaleToLabelsMap = new HashMap<String, String[]>(); - private static final HashMap<String, Integer> sNameToIdMap = new HashMap<String, Integer>(); + private static final HashMap<String, Integer> sLowerCaseNameToIdsMap = + new HashMap<String, Integer>(); private String[] mLabels; // Resource name to label map. @@ -60,12 +61,21 @@ public final class KeyboardLabelsSet { } public String getLabel(final String name) { - if (mResourceNameToLabelsMap.containsKey(name)) { - return mResourceNameToLabelsMap.get(name); + String lowerCaseName = null; + String label = mResourceNameToLabelsMap.get(name); + if (label == null) { + lowerCaseName = name.toLowerCase(); + label = mResourceNameToLabelsMap.get(lowerCaseName); + } + if (label != null) { + return label; + } + Integer id = sLowerCaseNameToIdsMap.get(name); + if (id == null) { + id = sLowerCaseNameToIdsMap.get(lowerCaseName); // lowerCaseName != null } - final Integer id = sNameToIdMap.get(name); if (id == null) throw new RuntimeException("Unknown label: " + name); - final String label = (id < mLabels.length) ? mLabels[id] : null; + label = (id < mLabels.length) ? mLabels[id] : null; return (label == null) ? LANGUAGE_DEFAULT[id] : label; } @@ -105,7 +115,7 @@ public final class KeyboardLabelsSet { static { int id = 0; for (final String name : NAMES) { - sNameToIdMap.put(name, id++); + sLowerCaseNameToIdsMap.put(name, id++); } for (int i = 0; i < LANGUAGES_AND_LABELS.length; i += 2) { |