diff options
Diffstat (limited to 'java/src/com/android/inputmethod')
-rw-r--r-- | java/src/com/android/inputmethod/keyboard/Keyboard.java | 10 | ||||
-rw-r--r-- | java/src/com/android/inputmethod/keyboard/internal/KeySpecParser.java | 24 | ||||
-rw-r--r-- | java/src/com/android/inputmethod/keyboard/internal/KeyStyles.java | 28 | ||||
-rw-r--r-- | java/src/com/android/inputmethod/keyboard/internal/KeyboardTextsSet.java (renamed from java/src/com/android/inputmethod/keyboard/internal/KeyboardLabelsSet.java) | 58 |
4 files changed, 60 insertions, 60 deletions
diff --git a/java/src/com/android/inputmethod/keyboard/Keyboard.java b/java/src/com/android/inputmethod/keyboard/Keyboard.java index fca8f56c8..dcbdc2731 100644 --- a/java/src/com/android/inputmethod/keyboard/Keyboard.java +++ b/java/src/com/android/inputmethod/keyboard/Keyboard.java @@ -30,7 +30,7 @@ import android.view.InflateException; import com.android.inputmethod.keyboard.internal.KeyStyles; import com.android.inputmethod.keyboard.internal.KeyboardCodesSet; import com.android.inputmethod.keyboard.internal.KeyboardIconsSet; -import com.android.inputmethod.keyboard.internal.KeyboardLabelsSet; +import com.android.inputmethod.keyboard.internal.KeyboardTextsSet; import com.android.inputmethod.latin.LatinImeLogger; import com.android.inputmethod.latin.LocaleUtils.RunInLocale; import com.android.inputmethod.latin.R; @@ -236,8 +236,8 @@ public class Keyboard { public final ArrayList<Key> mAltCodeKeysWhileTyping = new ArrayList<Key>(); public final KeyboardIconsSet mIconsSet = new KeyboardIconsSet(); public final KeyboardCodesSet mCodesSet = new KeyboardCodesSet(); - public final KeyboardLabelsSet mLabelsSet = new KeyboardLabelsSet(); - public final KeyStyles mKeyStyles = new KeyStyles(mLabelsSet); + public final KeyboardTextsSet mTextsSet = new KeyboardTextsSet(); + public final KeyStyles mKeyStyles = new KeyStyles(mTextsSet); public KeyboardLayoutSet.KeysCache mKeysCache; @@ -776,11 +776,11 @@ public class Keyboard { params.mIconsSet.loadIcons(keyboardAttr); final String language = params.mId.mLocale.getLanguage(); params.mCodesSet.setLanguage(language); - params.mLabelsSet.setLanguage(language); + params.mTextsSet.setLanguage(language); final RunInLocale<Void> job = new RunInLocale<Void>() { @Override protected Void job(Resources res) { - params.mLabelsSet.loadStringResources(mContext); + params.mTextsSet.loadStringResources(mContext); return null; } }; diff --git a/java/src/com/android/inputmethod/keyboard/internal/KeySpecParser.java b/java/src/com/android/inputmethod/keyboard/internal/KeySpecParser.java index 97e360e0b..a44ddf182 100644 --- a/java/src/com/android/inputmethod/keyboard/internal/KeySpecParser.java +++ b/java/src/com/android/inputmethod/keyboard/internal/KeySpecParser.java @@ -30,8 +30,8 @@ import java.util.Arrays; * The specification is comma separated texts each of which represents one "more key". * The specification might have label or string resource reference in it. These references are * expanded before parsing comma. - * - Label reference should be a string representation of label (!label/label_name) - * - String resource reference should be a string representation of resource (!label/resource_name) + * - Label reference should be a string representation of label (!text/label_name) + * - String resource reference should be a string representation of resource (!text/resource_name) * Each "more key" specification is one of the following: * - Label optionally followed by keyOutputText or code (keyLabel|keyOutputText). * - Icon followed by keyOutputText or code (!icon/icon_name|!code/code_name) @@ -51,7 +51,7 @@ public class KeySpecParser { private static int COMMA = ','; private static final char ESCAPE_CHAR = '\\'; private static final char LABEL_END = '|'; - private static final String PREFIX_LABEL = "!label/"; + private static final String PREFIX_TEXT = "!text/"; private static final String PREFIX_ICON = "!icon/"; private static final String PREFIX_CODE = "!code/"; private static final String PREFIX_HEX = "0x"; @@ -334,7 +334,7 @@ public class KeySpecParser { } } - public static String resolveLabelReference(String rawText, KeyboardLabelsSet labelsSet) { + public static String resolveTextReference(String rawText, KeyboardTextsSet textsSet) { int level = 0; String text = rawText; StringBuilder sb; @@ -344,7 +344,7 @@ public class KeySpecParser { throw new RuntimeException("too many @string/resource indirection: " + text); } - final int prefixLen = PREFIX_LABEL.length(); + final int prefixLen = PREFIX_TEXT.length(); final int size = text.length(); if (size < prefixLen) { return text; @@ -353,14 +353,14 @@ public class KeySpecParser { sb = null; for (int pos = 0; pos < size; pos++) { final char c = text.charAt(pos); - if (text.regionMatches(true, pos, PREFIX_LABEL, 0, prefixLen) - && labelsSet != null) { + if (text.regionMatches(true, pos, PREFIX_TEXT, 0, prefixLen) + && textsSet != null) { if (sb == null) { sb = new StringBuilder(text.substring(0, pos)); } - final int end = searchLabelNameEnd(text, pos + prefixLen); + final int end = searchTextNameEnd(text, pos + prefixLen); final String name = text.substring(pos + prefixLen, end); - sb.append(labelsSet.getLabel(name)); + sb.append(textsSet.getText(name)); pos = end - 1; } else if (c == ESCAPE_CHAR) { if (sb != null) { @@ -381,7 +381,7 @@ public class KeySpecParser { return text; } - private static int searchLabelNameEnd(String text, int start) { + private static int searchTextNameEnd(String text, int start) { final int size = text.length(); for (int pos = start; pos < size; pos++) { final char c = text.charAt(pos); @@ -395,8 +395,8 @@ public class KeySpecParser { return size; } - public static String[] parseCsvString(String rawText, KeyboardLabelsSet labelsSet) { - final String text = resolveLabelReference(rawText, labelsSet); + public static String[] parseCsvString(String rawText, KeyboardTextsSet textsSet) { + final String text = resolveTextReference(rawText, textsSet); final int size = text.length(); if (size == 0) { return null; diff --git a/java/src/com/android/inputmethod/keyboard/internal/KeyStyles.java b/java/src/com/android/inputmethod/keyboard/internal/KeyStyles.java index 922a44158..b32172ebe 100644 --- a/java/src/com/android/inputmethod/keyboard/internal/KeyStyles.java +++ b/java/src/com/android/inputmethod/keyboard/internal/KeyStyles.java @@ -35,19 +35,19 @@ public class KeyStyles { private final HashMap<String, DeclaredKeyStyle> mStyles = new HashMap<String, DeclaredKeyStyle>(); - private final KeyboardLabelsSet mLabelsSet; + private final KeyboardTextsSet mTextsSet; private final KeyStyle mEmptyKeyStyle; - public KeyStyles(KeyboardLabelsSet labelsSet) { - mLabelsSet = labelsSet; - mEmptyKeyStyle = new EmptyKeyStyle(labelsSet); + public KeyStyles(KeyboardTextsSet textsSet) { + mTextsSet = textsSet; + mEmptyKeyStyle = new EmptyKeyStyle(textsSet); } public static abstract class KeyStyle { - protected final KeyboardLabelsSet mLabelsSet; + protected final KeyboardTextsSet mTextsSet; - public KeyStyle(KeyboardLabelsSet labelsSet) { - mLabelsSet = labelsSet; + public KeyStyle(KeyboardTextsSet textsSet) { + mTextsSet = textsSet; } public abstract String[] getStringArray(TypedArray a, int index); @@ -57,22 +57,22 @@ public class KeyStyles { protected String parseString(TypedArray a, int index) { if (a.hasValue(index)) { - return KeySpecParser.resolveLabelReference(a.getString(index), mLabelsSet); + return KeySpecParser.resolveTextReference(a.getString(index), mTextsSet); } return null; } protected String[] parseStringArray(TypedArray a, int index) { if (a.hasValue(index)) { - return KeySpecParser.parseCsvString(a.getString(index), mLabelsSet); + return KeySpecParser.parseCsvString(a.getString(index), mTextsSet); } return null; } } private static class EmptyKeyStyle extends KeyStyle { - public EmptyKeyStyle(KeyboardLabelsSet labelsSet) { - super(labelsSet); + public EmptyKeyStyle(KeyboardTextsSet textsSet) { + super(textsSet); } @Override @@ -99,8 +99,8 @@ public class KeyStyles { private static class DeclaredKeyStyle extends KeyStyle { private final HashMap<Integer, Object> mStyleAttributes = new HashMap<Integer, Object>(); - public DeclaredKeyStyle(KeyboardLabelsSet labelsSet) { - super(labelsSet); + public DeclaredKeyStyle(KeyboardTextsSet textsSet) { + super(textsSet); } @Override @@ -195,7 +195,7 @@ public class KeyStyles { } } - final DeclaredKeyStyle style = new DeclaredKeyStyle(mLabelsSet); + final DeclaredKeyStyle style = new DeclaredKeyStyle(mTextsSet); if (keyStyleAttr.hasValue(R.styleable.Keyboard_KeyStyle_parentStyle)) { final String parentStyle = keyStyleAttr.getString( R.styleable.Keyboard_KeyStyle_parentStyle); diff --git a/java/src/com/android/inputmethod/keyboard/internal/KeyboardLabelsSet.java b/java/src/com/android/inputmethod/keyboard/internal/KeyboardTextsSet.java index 1ba84e505..d0f27a9a8 100644 --- a/java/src/com/android/inputmethod/keyboard/internal/KeyboardLabelsSet.java +++ b/java/src/com/android/inputmethod/keyboard/internal/KeyboardTextsSet.java @@ -25,23 +25,23 @@ import java.util.HashMap; /** * !!!!! DO NOT EDIT THIS FILE !!!!! - * This file is generated by tools/makelabel. + * This file is generated by tools/maketext. */ -public final class KeyboardLabelsSet { - // Language to labels map. - private static final HashMap<String, String[]> sLocaleToLabelsMap = +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 = new HashMap<String, Integer>(); - private String[] mLabels; - // Resource name to label map. - private HashMap<String, String> mResourceNameToLabelsMap = new HashMap<String, String>(); + private String[] mTexts; + // Resource name to text map. + private HashMap<String, String> mResourceNameToTextsMap = new HashMap<String, String>(); public void setLanguage(final String language) { - mLabels = sLocaleToLabelsMap.get(language); - if (mLabels == null) { - mLabels = LANGUAGE_DEFAULT; + mTexts = sLocaleToTextsMap.get(language); + if (mTexts == null) { + mTexts = LANGUAGE_DEFAULT; } } @@ -56,31 +56,31 @@ public final class KeyboardLabelsSet { final String packageName = res.getResourcePackageName(referenceId); for (final String resName : resourceNames) { final int resId = res.getIdentifier(resName, "string", packageName); - mResourceNameToLabelsMap.put(resName, res.getString(resId)); + mResourceNameToTextsMap.put(resName, res.getString(resId)); } } - public String getLabel(final String name) { + public String getText(final String name) { String lowerCaseName = null; - String label = mResourceNameToLabelsMap.get(name); - if (label == null) { + String text = mResourceNameToTextsMap.get(name); + if (text == null) { lowerCaseName = name.toLowerCase(); - label = mResourceNameToLabelsMap.get(lowerCaseName); + text = mResourceNameToTextsMap.get(lowerCaseName); } - if (label != null) { - return label; + if (text != null) { + return text; } Integer id = sLowerCaseNameToIdsMap.get(name); if (id == null) { id = sLowerCaseNameToIdsMap.get(lowerCaseName); // lowerCaseName != null } if (id == null) throw new RuntimeException("Unknown label: " + name); - label = (id < mLabels.length) ? mLabels[id] : null; - return (label == null) ? LANGUAGE_DEFAULT[id] : label; + text = (id < mTexts.length) ? mTexts[id] : null; + return (text == null) ? LANGUAGE_DEFAULT[id] : text; } private static final String[] RESOURCE_NAMES = { - // These labels' name should be aligned with the @string/<name> in values/strings.xml. + // These texts' name should be aligned with the @string/<name> in values/strings.xml. // Labels for action. "label_go_key", // "label_search_key", @@ -222,7 +222,7 @@ public final class KeyboardLabelsSet { private static final String EMPTY = ""; - /* Default labels */ + /* Default texts */ private static final String[] LANGUAGE_DEFAULT = { /* 0~ */ EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, @@ -344,11 +344,11 @@ public final class KeyboardLabelsSet { // U+2666: "♦" BLACK DIAMOND SUIT // U+2663: "♣" BLACK CLUB SUIT /* 108 */ "\u266A,\u2665,\u2660,\u2666,\u2663", - /* 109 */ "!fixedColumnOrder!2,!hasLabels!,!label/label_time_am,!label/label_time_pm", + /* 109 */ "!fixedColumnOrder!2,!hasLabels!,!text/label_time_am,!text/label_time_pm", /* 110 */ "!icon/settings_key|!code/key_settings", /* 111 */ "!icon/shortcut_key|!code/key_shortcut", - /* 112 */ "!hasLabels!,!label/label_next_key|!code/key_action_next", - /* 113 */ "!hasLabels!,!label/label_previous_key|!code/key_action_previous", + /* 112 */ "!hasLabels!,!text/label_next_key|!code/key_action_next", + /* 113 */ "!hasLabels!,!text/label_previous_key|!code/key_action_previous", // Label for "switch to more symbol" modifier key. Must be short to fit on key! /* 114 */ "= \\ <", // Label for "switch to more symbol" modifier key on tablets. Must be short to fit on key! @@ -2458,7 +2458,7 @@ public final class KeyboardLabelsSet { /* 19 */ "\u0175", }; - private static final Object[] LANGUAGES_AND_LABELS = { + private static final Object[] LANGUAGES_AND_TEXTS = { "DEFAULT", LANGUAGE_DEFAULT, /* default */ "ar", LANGUAGE_ar, /* Arabic */ "be", LANGUAGE_be, /* Belarusian */ @@ -2505,10 +2505,10 @@ public final class KeyboardLabelsSet { sLowerCaseNameToIdsMap.put(name, id++); } - for (int i = 0; i < LANGUAGES_AND_LABELS.length; i += 2) { - final String language = (String)LANGUAGES_AND_LABELS[i]; - final String[] labels = (String[])LANGUAGES_AND_LABELS[i + 1]; - sLocaleToLabelsMap.put(language, labels); + for (int i = 0; i < LANGUAGES_AND_TEXTS.length; i += 2) { + final String language = (String)LANGUAGES_AND_TEXTS[i]; + final String[] texts = (String[])LANGUAGES_AND_TEXTS[i + 1]; + sLocaleToTextsMap.put(language, texts); } } } |