aboutsummaryrefslogtreecommitdiffstats
path: root/java/src
diff options
context:
space:
mode:
Diffstat (limited to 'java/src')
-rw-r--r--java/src/com/android/inputmethod/keyboard/Key.java33
-rw-r--r--java/src/com/android/inputmethod/keyboard/Keyboard.java15
-rw-r--r--java/src/com/android/inputmethod/keyboard/KeyboardLayoutSet.java28
-rw-r--r--java/src/com/android/inputmethod/keyboard/MoreKeysKeyboard.java5
4 files changed, 42 insertions, 39 deletions
diff --git a/java/src/com/android/inputmethod/keyboard/Key.java b/java/src/com/android/inputmethod/keyboard/Key.java
index 254d2d618..fa7ec5cbf 100644
--- a/java/src/com/android/inputmethod/keyboard/Key.java
+++ b/java/src/com/android/inputmethod/keyboard/Key.java
@@ -60,10 +60,12 @@ public class Key {
private static final int LABEL_FLAGS_ALIGN_LEFT = 0x01;
private static final int LABEL_FLAGS_ALIGN_RIGHT = 0x02;
private static final int LABEL_FLAGS_ALIGN_LEFT_OF_CENTER = 0x08;
- private static final int LABEL_FLAGS_LARGE_LETTER = 0x10;
- private static final int LABEL_FLAGS_FONT_NORMAL = 0x20;
- private static final int LABEL_FLAGS_FONT_MONO_SPACE = 0x40;
- public static final int LABEL_FLAGS_FOLLOW_KEY_LETTER_RATIO = 0x80;
+ private static final int LABEL_FLAGS_FONT_NORMAL = 0x10;
+ private static final int LABEL_FLAGS_FONT_MONO_SPACE = 0x20;
+ private static final int LABEL_FLAGS_FOLLOW_KEY_RATIO_MASK = 0x1C0;
+ private static final int LABEL_FLAGS_FOLLOW_KEY_LARGE_LETTER_RATIO = 0x40;
+ private static final int LABEL_FLAGS_FOLLOW_KEY_LETTER_RATIO = 0x80;
+ private static final int LABEL_FLAGS_FOLLOW_KEY_LABEL_RATIO = 0xC0;
private static final int LABEL_FLAGS_FOLLOW_KEY_HINT_LABEL_RATIO = 0x100;
private static final int LABEL_FLAGS_HAS_POPUP_HINT = 0x200;
private static final int LABEL_FLAGS_HAS_SHIFTED_LETTER_HINT = 0x400;
@@ -498,16 +500,17 @@ public class Key {
}
public int selectTextSize(int letter, int largeLetter, int label, int hintLabel) {
- if (StringUtils.codePointCount(mLabel) > 1
- && (mLabelFlags & (LABEL_FLAGS_FOLLOW_KEY_LETTER_RATIO
- | LABEL_FLAGS_FOLLOW_KEY_HINT_LABEL_RATIO)) == 0) {
- return label;
- } else if ((mLabelFlags & LABEL_FLAGS_FOLLOW_KEY_HINT_LABEL_RATIO) != 0) {
- return hintLabel;
- } else if ((mLabelFlags & LABEL_FLAGS_LARGE_LETTER) != 0) {
+ switch (mLabelFlags & LABEL_FLAGS_FOLLOW_KEY_RATIO_MASK) {
+ case LABEL_FLAGS_FOLLOW_KEY_LARGE_LETTER_RATIO:
return largeLetter;
- } else {
+ case LABEL_FLAGS_FOLLOW_KEY_LETTER_RATIO:
return letter;
+ case LABEL_FLAGS_FOLLOW_KEY_LABEL_RATIO:
+ return label;
+ case LABEL_FLAGS_FOLLOW_KEY_HINT_LABEL_RATIO:
+ return hintLabel;
+ default: // No follow key ratio flag specified.
+ return StringUtils.codePointCount(mLabel) == 1 ? letter : label;
}
}
@@ -563,6 +566,12 @@ public class Key {
return (mMoreKeysColumnAndFlags & MORE_KEYS_FLAGS_HAS_LABELS) != 0;
}
+ public int getMoreKeyLabelFlags() {
+ return hasLabelsInMoreKeys()
+ ? LABEL_FLAGS_FOLLOW_KEY_LABEL_RATIO
+ : LABEL_FLAGS_FOLLOW_KEY_LETTER_RATIO;
+ }
+
public boolean needsDividersInMoreKeys() {
return (mMoreKeysColumnAndFlags & MORE_KEYS_FLAGS_NEEDS_DIVIDERS) != 0;
}
diff --git a/java/src/com/android/inputmethod/keyboard/Keyboard.java b/java/src/com/android/inputmethod/keyboard/Keyboard.java
index 4018d65d4..58225e95d 100644
--- a/java/src/com/android/inputmethod/keyboard/Keyboard.java
+++ b/java/src/com/android/inputmethod/keyboard/Keyboard.java
@@ -32,7 +32,9 @@ 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.latin.LatinImeLogger;
+import com.android.inputmethod.latin.LocaleUtils.RunInLocale;
import com.android.inputmethod.latin.R;
+import com.android.inputmethod.latin.SubtypeLocale;
import com.android.inputmethod.latin.Utils;
import com.android.inputmethod.latin.XmlParseUtils;
@@ -44,6 +46,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.Locale;
/**
* Loads an XML description of a keyboard and stores the attributes of the keys. A keyboard
@@ -782,7 +785,17 @@ public class Keyboard {
final String language = params.mId.mLocale.getLanguage();
params.mCodesSet.setLanguage(language);
params.mLabelsSet.setLanguage(language);
- params.mLabelsSet.loadStringResources(mContext);
+ final RunInLocale<Void> job = new RunInLocale<Void>() {
+ @Override
+ protected Void job(Resources res) {
+ params.mLabelsSet.loadStringResources(mContext);
+ return null;
+ }
+ };
+ // Null means the current system locale.
+ final Locale locale = language.equals(SubtypeLocale.NO_LANGUAGE)
+ ? null : params.mId.mLocale;
+ job.runInLocale(mResources, locale);
final int resourceId = keyboardAttr.getResourceId(
R.styleable.Keyboard_touchPositionCorrectionData, 0);
diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardLayoutSet.java b/java/src/com/android/inputmethod/keyboard/KeyboardLayoutSet.java
index c8ec3a4dd..803a2948e 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyboardLayoutSet.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyboardLayoutSet.java
@@ -29,12 +29,10 @@ import android.view.inputmethod.InputMethodSubtype;
import com.android.inputmethod.compat.EditorInfoCompatUtils;
import com.android.inputmethod.keyboard.KeyboardLayoutSet.Params.ElementParams;
-import com.android.inputmethod.keyboard.internal.KeySpecParser;
import com.android.inputmethod.latin.InputTypeUtils;
import com.android.inputmethod.latin.LatinIME;
import com.android.inputmethod.latin.LatinImeLogger;
import com.android.inputmethod.latin.LocaleUtils;
-import com.android.inputmethod.latin.LocaleUtils.RunInLocale;
import com.android.inputmethod.latin.R;
import com.android.inputmethod.latin.StringUtils;
import com.android.inputmethod.latin.SubtypeLocale;
@@ -183,14 +181,7 @@ public class KeyboardLayoutSet {
builder.setAutoGenerate(sKeysCache);
}
final int keyboardXmlId = elementParams.mKeyboardXmlId;
- final RunInLocale<Void> job = new RunInLocale<Void>() {
- @Override
- protected Void job(Resources res) {
- builder.load(keyboardXmlId, id);
- return null;
- }
- };
- job.runInLocale(context.getResources(), id.mLocale);
+ builder.load(keyboardXmlId, id);
builder.setTouchPositionCorrectionEnabled(mParams.mTouchPositionCorrectionEnabled);
builder.setProximityCharsCorrectionEnabled(
elementParams.mProximityCharsCorrectionEnabled);
@@ -321,18 +312,11 @@ public class KeyboardLayoutSet {
R.xml.keyboard_layout_set_qwerty);
final String keyboardLayoutSetName = mParams.mKeyboardLayoutSetName;
final int xmlId = mResources.getIdentifier(keyboardLayoutSetName, "xml", packageName);
- final RunInLocale<Void> job = new RunInLocale<Void>() {
- @Override
- protected Void job(Resources res) {
- try {
- parseKeyboardLayoutSet(res, xmlId);
- } catch (Exception e) {
- throw new RuntimeException(e.getMessage() + " in " + keyboardLayoutSetName);
- }
- return null;
- }
- };
- job.runInLocale(mResources, mParams.mLocale);
+ try {
+ parseKeyboardLayoutSet(mResources, xmlId);
+ } catch (Exception e) {
+ throw new RuntimeException(e.getMessage() + " in " + keyboardLayoutSetName);
+ }
return new KeyboardLayoutSet(mContext, mParams);
}
diff --git a/java/src/com/android/inputmethod/keyboard/MoreKeysKeyboard.java b/java/src/com/android/inputmethod/keyboard/MoreKeysKeyboard.java
index f8682d8ca..7154086e2 100644
--- a/java/src/com/android/inputmethod/keyboard/MoreKeysKeyboard.java
+++ b/java/src/com/android/inputmethod/keyboard/MoreKeysKeyboard.java
@@ -332,10 +332,7 @@ public class MoreKeysKeyboard extends Keyboard {
@Override
public MoreKeysKeyboard build() {
final MoreKeysKeyboardParams params = mParams;
- // moreKeyFlags == 0 means that the rendered text size will be determined by its
- // label's code point count.
- final int moreKeyFlags = mParentKey.hasLabelsInMoreKeys() ? 0
- : Key.LABEL_FLAGS_FOLLOW_KEY_LETTER_RATIO;
+ final int moreKeyFlags = mParentKey.getMoreKeyLabelFlags();
final MoreKeySpec[] moreKeys = mParentKey.mMoreKeys;
for (int n = 0; n < moreKeys.length; n++) {
final MoreKeySpec moreKeySpec = moreKeys[n];