Loading java/src/com/android/inputmethod/keyboard/Key.java +10 −9 Original line number Diff line number Diff line Loading @@ -28,8 +28,9 @@ import android.util.Xml; import com.android.inputmethod.keyboard.internal.KeyStyles; import com.android.inputmethod.keyboard.internal.KeyStyles.KeyStyle; import com.android.inputmethod.keyboard.internal.KeyboardIconsSet; import com.android.inputmethod.keyboard.internal.MoreKeySpecParser; import com.android.inputmethod.keyboard.internal.KeySpecParser; import com.android.inputmethod.latin.R; import com.android.inputmethod.latin.Utils; import com.android.inputmethod.latin.XmlParseUtils; import org.xmlpull.v1.XmlPullParser; Loading Loading @@ -128,7 +129,7 @@ public class Key { private boolean mEnabled = true; private static Drawable getIcon(Keyboard.Params params, String moreKeySpec) { final int iconAttrId = MoreKeySpecParser.getIconAttrId(moreKeySpec); final int iconAttrId = KeySpecParser.getIconAttrId(moreKeySpec); if (iconAttrId == KeyboardIconsSet.ICON_UNDEFINED) { return null; } else { Loading @@ -141,9 +142,9 @@ public class Key { */ public Key(Resources res, Keyboard.Params params, String moreKeySpec, int x, int y, int width, int height) { this(params, MoreKeySpecParser.getLabel(moreKeySpec), null, getIcon(params, moreKeySpec), MoreKeySpecParser.getCode(res, moreKeySpec), MoreKeySpecParser.getOutputText(moreKeySpec), this(params, KeySpecParser.getLabel(moreKeySpec), null, getIcon(params, moreKeySpec), KeySpecParser.getCode(res, moreKeySpec), KeySpecParser.getOutputText(moreKeySpec), x, y, width, height); } Loading Loading @@ -245,7 +246,7 @@ public class Key { int actionFlags = style.getFlag(keyAttr, R.styleable.Keyboard_Key_keyActionFlags, 0); final String[] additionalMoreKeys = style.getStringArray( keyAttr, R.styleable.Keyboard_Key_additionalMoreKeys); final String[] moreKeys = MoreKeySpecParser.insertAddtionalMoreKeys(style.getStringArray( final String[] moreKeys = KeySpecParser.insertAddtionalMoreKeys(style.getStringArray( keyAttr, R.styleable.Keyboard_Key_moreKeys), additionalMoreKeys); if (moreKeys != null) { actionFlags |= ACTION_FLAGS_ENABLE_LONG_PRESS; Loading @@ -270,7 +271,7 @@ public class Key { // Choose the first letter of the label as primary code if not specified. if (code == Keyboard.CODE_UNSPECIFIED && TextUtils.isEmpty(outputText) && !TextUtils.isEmpty(mLabel)) { if (mLabel.codePointCount(0, mLabel.length()) == 1) { if (Utils.codePointCount(mLabel) == 1) { // Use the first letter of the hint label if shiftedLetterActivated flag is // specified. if (hasShiftedLetterHint() && isShiftedLetterActivated() Loading Loading @@ -308,7 +309,7 @@ public class Key { if (!Keyboard.isLetterCode(code) || preserveCase) return code; final String text = new String(new int[] { code } , 0, 1); final String casedText = adjustCaseOfStringForKeyboardId(text, preserveCase, id); return casedText.codePointCount(0, casedText.length()) == 1 return Utils.codePointCount(casedText) == 1 ? casedText.codePointAt(0) : Keyboard.CODE_UNSPECIFIED; } Loading Loading @@ -380,7 +381,7 @@ public class Key { @Override public String toString() { String top = Keyboard.printableCode(mCode); if (mLabel != null && mLabel.codePointCount(0, mLabel.length()) != 1) { if (Utils.codePointCount(mLabel) != 1) { top += "/\"" + mLabel + '"'; } return String.format("%s %d,%d", top, mX, mY); Loading java/src/com/android/inputmethod/keyboard/KeyboardView.java +2 −1 Original line number Diff line number Diff line Loading @@ -41,6 +41,7 @@ import com.android.inputmethod.compat.FrameLayoutCompatUtils; import com.android.inputmethod.latin.LatinImeLogger; import com.android.inputmethod.latin.R; import com.android.inputmethod.latin.StaticInnerHandlerWrapper; import com.android.inputmethod.latin.Utils; import java.util.HashMap; Loading Loading @@ -851,7 +852,7 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy { if (key.mLabel != null) { // TODO Should take care of temporaryShiftLabel here. previewText.setCompoundDrawables(null, null, null, null); if (key.mLabel.length() > 1) { if (Utils.codePointCount(key.mLabel) > 1) { previewText.setTextSize(TypedValue.COMPLEX_UNIT_PX, params.mKeyLetterSize); previewText.setTypeface(Typeface.DEFAULT_BOLD); } else { Loading java/src/com/android/inputmethod/keyboard/MiniKeyboard.java +2 −2 Original line number Diff line number Diff line Loading @@ -18,7 +18,7 @@ package com.android.inputmethod.keyboard; import android.graphics.Paint; import com.android.inputmethod.keyboard.internal.MoreKeySpecParser; import com.android.inputmethod.keyboard.internal.KeySpecParser; import com.android.inputmethod.latin.R; public class MiniKeyboard extends Keyboard { Loading Loading @@ -235,7 +235,7 @@ public class MiniKeyboard extends Keyboard { Paint paint = null; int maxWidth = minKeyWidth; for (String moreKeySpec : moreKeys) { final String label = MoreKeySpecParser.getLabel(moreKeySpec); final String label = KeySpecParser.getLabel(moreKeySpec); // If the label is single letter, minKeyWidth is enough to hold the label. if (label != null && label.length() > 1) { if (paint == null) { Loading java/src/com/android/inputmethod/keyboard/internal/MoreKeySpecParser.java→java/src/com/android/inputmethod/keyboard/internal/KeySpecParser.java +9 −6 Original line number Diff line number Diff line Loading @@ -39,14 +39,14 @@ import java.util.Arrays; * Note that the character '@' and '\' are also parsed by XML parser and CSV parser as well. * See {@link KeyboardIconsSet} about icon_number. */ public class MoreKeySpecParser { public class KeySpecParser { private static final boolean DEBUG = LatinImeLogger.sDBG; private static final char LABEL_END = '|'; private static final String PREFIX_ICON = Utils.PREFIX_AT + "icon" + Utils.SUFFIX_SLASH; private static final String PREFIX_CODE = Utils.PREFIX_AT + "integer" + Utils.SUFFIX_SLASH; private static final String ADDITIONAL_MORE_KEY_MARKER = "%"; private MoreKeySpecParser() { private KeySpecParser() { // Intentional empty constructor for utility class. } Loading Loading @@ -79,7 +79,9 @@ public class MoreKeySpecParser { for (int pos = 0; pos < length; pos++) { final char c = text.charAt(pos); if (c == Utils.ESCAPE_CHAR && pos + 1 < length) { sb.append(text.charAt(++pos)); // Skip escape char pos++; sb.append(text.charAt(pos)); } else { sb.append(c); } Loading @@ -99,6 +101,7 @@ public class MoreKeySpecParser { for (int pos = start; pos < length; pos++) { final char c = moreKeySpec.charAt(pos); if (c == Utils.ESCAPE_CHAR && pos + 1 < length) { // Skip escape char pos++; } else if (c == LABEL_END) { return pos; Loading Loading @@ -142,7 +145,7 @@ public class MoreKeySpecParser { throw new MoreKeySpecParserError("Empty label: " + moreKeySpec); } // Code is automatically generated for one letter label. See {@link getCode()}. return (label.length() == 1) ? null : label; return (Utils.codePointCount(label) == 1) ? null : label; } public static int getCode(Resources res, String moreKeySpec) { Loading @@ -162,8 +165,8 @@ public class MoreKeySpecParser { } final String label = getLabel(moreKeySpec); // Code is automatically generated for one letter label. if (label != null && label.length() == 1) { return label.charAt(0); if (Utils.codePointCount(label) == 1) { return label.codePointAt(0); } return Keyboard.CODE_OUTPUT_TEXT; } Loading java/src/com/android/inputmethod/latin/SettingsValues.java +5 −5 Original line number Diff line number Diff line Loading @@ -25,7 +25,7 @@ import android.view.inputmethod.EditorInfo; import com.android.inputmethod.compat.InputTypeCompatUtils; import com.android.inputmethod.compat.VibratorCompatWrapper; import com.android.inputmethod.keyboard.internal.MoreKeySpecParser; import com.android.inputmethod.keyboard.internal.KeySpecParser; import java.util.Arrays; import java.util.Locale; Loading Loading @@ -158,7 +158,7 @@ public class SettingsValues { final StringBuilder sb = new StringBuilder(); if (puncs != null) { for (final String puncSpec : puncs) { sb.append(MoreKeySpecParser.getLabel(puncSpec)); sb.append(KeySpecParser.getLabel(puncSpec)); } } return sb.toString(); Loading @@ -168,7 +168,7 @@ public class SettingsValues { final SuggestedWords.Builder builder = new SuggestedWords.Builder(); if (puncs != null) { for (final String puncSpec : puncs) { builder.addWord(MoreKeySpecParser.getLabel(puncSpec)); builder.addWord(KeySpecParser.getLabel(puncSpec)); } } return builder.setIsPunctuationSuggestions().build(); Loading @@ -178,11 +178,11 @@ public class SettingsValues { final SuggestedWords.Builder builder = new SuggestedWords.Builder(); if (puncs != null) { for (final String puncSpec : puncs) { final String outputText = MoreKeySpecParser.getOutputText(puncSpec); final String outputText = KeySpecParser.getOutputText(puncSpec); if (outputText != null) { builder.addWord(outputText); } else { builder.addWord(MoreKeySpecParser.getLabel(puncSpec)); builder.addWord(KeySpecParser.getLabel(puncSpec)); } } } Loading Loading
java/src/com/android/inputmethod/keyboard/Key.java +10 −9 Original line number Diff line number Diff line Loading @@ -28,8 +28,9 @@ import android.util.Xml; import com.android.inputmethod.keyboard.internal.KeyStyles; import com.android.inputmethod.keyboard.internal.KeyStyles.KeyStyle; import com.android.inputmethod.keyboard.internal.KeyboardIconsSet; import com.android.inputmethod.keyboard.internal.MoreKeySpecParser; import com.android.inputmethod.keyboard.internal.KeySpecParser; import com.android.inputmethod.latin.R; import com.android.inputmethod.latin.Utils; import com.android.inputmethod.latin.XmlParseUtils; import org.xmlpull.v1.XmlPullParser; Loading Loading @@ -128,7 +129,7 @@ public class Key { private boolean mEnabled = true; private static Drawable getIcon(Keyboard.Params params, String moreKeySpec) { final int iconAttrId = MoreKeySpecParser.getIconAttrId(moreKeySpec); final int iconAttrId = KeySpecParser.getIconAttrId(moreKeySpec); if (iconAttrId == KeyboardIconsSet.ICON_UNDEFINED) { return null; } else { Loading @@ -141,9 +142,9 @@ public class Key { */ public Key(Resources res, Keyboard.Params params, String moreKeySpec, int x, int y, int width, int height) { this(params, MoreKeySpecParser.getLabel(moreKeySpec), null, getIcon(params, moreKeySpec), MoreKeySpecParser.getCode(res, moreKeySpec), MoreKeySpecParser.getOutputText(moreKeySpec), this(params, KeySpecParser.getLabel(moreKeySpec), null, getIcon(params, moreKeySpec), KeySpecParser.getCode(res, moreKeySpec), KeySpecParser.getOutputText(moreKeySpec), x, y, width, height); } Loading Loading @@ -245,7 +246,7 @@ public class Key { int actionFlags = style.getFlag(keyAttr, R.styleable.Keyboard_Key_keyActionFlags, 0); final String[] additionalMoreKeys = style.getStringArray( keyAttr, R.styleable.Keyboard_Key_additionalMoreKeys); final String[] moreKeys = MoreKeySpecParser.insertAddtionalMoreKeys(style.getStringArray( final String[] moreKeys = KeySpecParser.insertAddtionalMoreKeys(style.getStringArray( keyAttr, R.styleable.Keyboard_Key_moreKeys), additionalMoreKeys); if (moreKeys != null) { actionFlags |= ACTION_FLAGS_ENABLE_LONG_PRESS; Loading @@ -270,7 +271,7 @@ public class Key { // Choose the first letter of the label as primary code if not specified. if (code == Keyboard.CODE_UNSPECIFIED && TextUtils.isEmpty(outputText) && !TextUtils.isEmpty(mLabel)) { if (mLabel.codePointCount(0, mLabel.length()) == 1) { if (Utils.codePointCount(mLabel) == 1) { // Use the first letter of the hint label if shiftedLetterActivated flag is // specified. if (hasShiftedLetterHint() && isShiftedLetterActivated() Loading Loading @@ -308,7 +309,7 @@ public class Key { if (!Keyboard.isLetterCode(code) || preserveCase) return code; final String text = new String(new int[] { code } , 0, 1); final String casedText = adjustCaseOfStringForKeyboardId(text, preserveCase, id); return casedText.codePointCount(0, casedText.length()) == 1 return Utils.codePointCount(casedText) == 1 ? casedText.codePointAt(0) : Keyboard.CODE_UNSPECIFIED; } Loading Loading @@ -380,7 +381,7 @@ public class Key { @Override public String toString() { String top = Keyboard.printableCode(mCode); if (mLabel != null && mLabel.codePointCount(0, mLabel.length()) != 1) { if (Utils.codePointCount(mLabel) != 1) { top += "/\"" + mLabel + '"'; } return String.format("%s %d,%d", top, mX, mY); Loading
java/src/com/android/inputmethod/keyboard/KeyboardView.java +2 −1 Original line number Diff line number Diff line Loading @@ -41,6 +41,7 @@ import com.android.inputmethod.compat.FrameLayoutCompatUtils; import com.android.inputmethod.latin.LatinImeLogger; import com.android.inputmethod.latin.R; import com.android.inputmethod.latin.StaticInnerHandlerWrapper; import com.android.inputmethod.latin.Utils; import java.util.HashMap; Loading Loading @@ -851,7 +852,7 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy { if (key.mLabel != null) { // TODO Should take care of temporaryShiftLabel here. previewText.setCompoundDrawables(null, null, null, null); if (key.mLabel.length() > 1) { if (Utils.codePointCount(key.mLabel) > 1) { previewText.setTextSize(TypedValue.COMPLEX_UNIT_PX, params.mKeyLetterSize); previewText.setTypeface(Typeface.DEFAULT_BOLD); } else { Loading
java/src/com/android/inputmethod/keyboard/MiniKeyboard.java +2 −2 Original line number Diff line number Diff line Loading @@ -18,7 +18,7 @@ package com.android.inputmethod.keyboard; import android.graphics.Paint; import com.android.inputmethod.keyboard.internal.MoreKeySpecParser; import com.android.inputmethod.keyboard.internal.KeySpecParser; import com.android.inputmethod.latin.R; public class MiniKeyboard extends Keyboard { Loading Loading @@ -235,7 +235,7 @@ public class MiniKeyboard extends Keyboard { Paint paint = null; int maxWidth = minKeyWidth; for (String moreKeySpec : moreKeys) { final String label = MoreKeySpecParser.getLabel(moreKeySpec); final String label = KeySpecParser.getLabel(moreKeySpec); // If the label is single letter, minKeyWidth is enough to hold the label. if (label != null && label.length() > 1) { if (paint == null) { Loading
java/src/com/android/inputmethod/keyboard/internal/MoreKeySpecParser.java→java/src/com/android/inputmethod/keyboard/internal/KeySpecParser.java +9 −6 Original line number Diff line number Diff line Loading @@ -39,14 +39,14 @@ import java.util.Arrays; * Note that the character '@' and '\' are also parsed by XML parser and CSV parser as well. * See {@link KeyboardIconsSet} about icon_number. */ public class MoreKeySpecParser { public class KeySpecParser { private static final boolean DEBUG = LatinImeLogger.sDBG; private static final char LABEL_END = '|'; private static final String PREFIX_ICON = Utils.PREFIX_AT + "icon" + Utils.SUFFIX_SLASH; private static final String PREFIX_CODE = Utils.PREFIX_AT + "integer" + Utils.SUFFIX_SLASH; private static final String ADDITIONAL_MORE_KEY_MARKER = "%"; private MoreKeySpecParser() { private KeySpecParser() { // Intentional empty constructor for utility class. } Loading Loading @@ -79,7 +79,9 @@ public class MoreKeySpecParser { for (int pos = 0; pos < length; pos++) { final char c = text.charAt(pos); if (c == Utils.ESCAPE_CHAR && pos + 1 < length) { sb.append(text.charAt(++pos)); // Skip escape char pos++; sb.append(text.charAt(pos)); } else { sb.append(c); } Loading @@ -99,6 +101,7 @@ public class MoreKeySpecParser { for (int pos = start; pos < length; pos++) { final char c = moreKeySpec.charAt(pos); if (c == Utils.ESCAPE_CHAR && pos + 1 < length) { // Skip escape char pos++; } else if (c == LABEL_END) { return pos; Loading Loading @@ -142,7 +145,7 @@ public class MoreKeySpecParser { throw new MoreKeySpecParserError("Empty label: " + moreKeySpec); } // Code is automatically generated for one letter label. See {@link getCode()}. return (label.length() == 1) ? null : label; return (Utils.codePointCount(label) == 1) ? null : label; } public static int getCode(Resources res, String moreKeySpec) { Loading @@ -162,8 +165,8 @@ public class MoreKeySpecParser { } final String label = getLabel(moreKeySpec); // Code is automatically generated for one letter label. if (label != null && label.length() == 1) { return label.charAt(0); if (Utils.codePointCount(label) == 1) { return label.codePointAt(0); } return Keyboard.CODE_OUTPUT_TEXT; } Loading
java/src/com/android/inputmethod/latin/SettingsValues.java +5 −5 Original line number Diff line number Diff line Loading @@ -25,7 +25,7 @@ import android.view.inputmethod.EditorInfo; import com.android.inputmethod.compat.InputTypeCompatUtils; import com.android.inputmethod.compat.VibratorCompatWrapper; import com.android.inputmethod.keyboard.internal.MoreKeySpecParser; import com.android.inputmethod.keyboard.internal.KeySpecParser; import java.util.Arrays; import java.util.Locale; Loading Loading @@ -158,7 +158,7 @@ public class SettingsValues { final StringBuilder sb = new StringBuilder(); if (puncs != null) { for (final String puncSpec : puncs) { sb.append(MoreKeySpecParser.getLabel(puncSpec)); sb.append(KeySpecParser.getLabel(puncSpec)); } } return sb.toString(); Loading @@ -168,7 +168,7 @@ public class SettingsValues { final SuggestedWords.Builder builder = new SuggestedWords.Builder(); if (puncs != null) { for (final String puncSpec : puncs) { builder.addWord(MoreKeySpecParser.getLabel(puncSpec)); builder.addWord(KeySpecParser.getLabel(puncSpec)); } } return builder.setIsPunctuationSuggestions().build(); Loading @@ -178,11 +178,11 @@ public class SettingsValues { final SuggestedWords.Builder builder = new SuggestedWords.Builder(); if (puncs != null) { for (final String puncSpec : puncs) { final String outputText = MoreKeySpecParser.getOutputText(puncSpec); final String outputText = KeySpecParser.getOutputText(puncSpec); if (outputText != null) { builder.addWord(outputText); } else { builder.addWord(MoreKeySpecParser.getLabel(puncSpec)); builder.addWord(KeySpecParser.getLabel(puncSpec)); } } } Loading