aboutsummaryrefslogtreecommitdiffstats
path: root/java/src
diff options
context:
space:
mode:
authorTadashi G. Takaoka <takaoka@google.com>2011-08-30 18:35:56 +0900
committerTadashi G. Takaoka <takaoka@google.com>2011-08-30 19:14:52 +0900
commit392276d73dd6a1787afd3b859c213378e8e7bdb5 (patch)
treebf201047c74235828ed439d8fa19e9634e64d11c /java/src
parent84b1284d01ffa1f730763471e1f2e9eddfb8ddea (diff)
downloadlatinime-392276d73dd6a1787afd3b859c213378e8e7bdb5.tar.gz
latinime-392276d73dd6a1787afd3b859c213378e8e7bdb5.tar.xz
latinime-392276d73dd6a1787afd3b859c213378e8e7bdb5.zip
Add Key constructor for suggestions pane
Bug: 5023981 Change-Id: I737bacb1a6bb40f70be65d6eff85614afe6c79ed
Diffstat (limited to 'java/src')
-rw-r--r--java/src/com/android/inputmethod/keyboard/Key.java36
-rw-r--r--java/src/com/android/inputmethod/keyboard/MiniKeyboard.java2
-rw-r--r--java/src/com/android/inputmethod/latin/LatinIME.java4
3 files changed, 25 insertions, 17 deletions
diff --git a/java/src/com/android/inputmethod/keyboard/Key.java b/java/src/com/android/inputmethod/keyboard/Key.java
index f56b52388..c3db1b318 100644
--- a/java/src/com/android/inputmethod/keyboard/Key.java
+++ b/java/src/com/android/inputmethod/keyboard/Key.java
@@ -26,10 +26,10 @@ 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.KeyboardParams;
import com.android.inputmethod.keyboard.internal.KeyboardBuilder;
import com.android.inputmethod.keyboard.internal.KeyboardBuilder.ParseException;
+import com.android.inputmethod.keyboard.internal.KeyboardIconsSet;
+import com.android.inputmethod.keyboard.internal.KeyboardParams;
import com.android.inputmethod.keyboard.internal.PopupCharactersParser;
import com.android.inputmethod.keyboard.internal.Row;
import com.android.inputmethod.latin.R;
@@ -184,8 +184,8 @@ public class Key {
sRtlParenthesisMap.put(right, left);
}
- public static int getRtlParenthesisCode(int code) {
- if (sRtlParenthesisMap.containsKey(code)) {
+ public static int getRtlParenthesisCode(int code, boolean isRtl) {
+ if (isRtl && sRtlParenthesisMap.containsKey(code)) {
return sRtlParenthesisMap.get(code);
} else {
return code;
@@ -195,27 +195,35 @@ public class Key {
/**
* This constructor is being used only for key in popup mini keyboard.
*/
- public Key(Resources res, KeyboardParams params, CharSequence popupCharacter, int x, int y,
- int width, int height, int edgeFlags) {
+ public Key(Resources res, KeyboardParams params, String popupSpec,
+ int x, int y, int width, int height, int edgeFlags) {
+ this(params, getRtlParenthesisCode(PopupCharactersParser.getCode(res, popupSpec),
+ params.mIsRtlKeyboard),
+ popupSpec, null, x, y, width, height, edgeFlags);
+ }
+
+ /**
+ * This constructor is being used only for key in popup suggestions pane.
+ */
+ public Key(KeyboardParams params, int code, String popupSpec, String hintLabel,
+ int x, int y, int width, int height, int edgeFlags) {
mHeight = height - params.mVerticalGap;
mHorizontalGap = params.mHorizontalGap;
mVerticalGap = params.mVerticalGap;
mVisualInsetsLeft = mVisualInsetsRight = 0;
mWidth = width - mHorizontalGap;
mEdgeFlags = edgeFlags;
- mHintLabel = null;
+ mHintLabel = hintLabel;
mLabelOption = 0;
mFunctional = false;
mSticky = false;
mRepeatable = false;
mPopupCharacters = null;
mMaxPopupColumn = 0;
- final String popupSpecification = popupCharacter.toString();
- mLabel = PopupCharactersParser.getLabel(popupSpecification);
- mOutputText = PopupCharactersParser.getOutputText(popupSpecification);
- final int code = PopupCharactersParser.getCode(res, popupSpecification);
- mCode = params.mIsRtlKeyboard ? getRtlParenthesisCode(code) : code;
- mIcon = params.mIconsSet.getIcon(PopupCharactersParser.getIconId(popupSpecification));
+ mLabel = PopupCharactersParser.getLabel(popupSpec);
+ mOutputText = PopupCharactersParser.getOutputText(popupSpec);
+ mCode = code;
+ mIcon = params.mIconsSet.getIcon(PopupCharactersParser.getIconId(popupSpec));
// Horizontal gap is divided equally to both sides of the key.
mX = x + mHorizontalGap / 2;
mY = y;
@@ -344,7 +352,7 @@ public class Key {
Keyboard.CODE_UNSPECIFIED);
if (code == Keyboard.CODE_UNSPECIFIED && !TextUtils.isEmpty(mLabel)) {
final int firstChar = mLabel.charAt(0);
- mCode = params.mIsRtlKeyboard ? getRtlParenthesisCode(firstChar) : firstChar;
+ mCode = getRtlParenthesisCode(firstChar, params.mIsRtlKeyboard);
} else if (code != Keyboard.CODE_UNSPECIFIED) {
mCode = code;
} else {
diff --git a/java/src/com/android/inputmethod/keyboard/MiniKeyboard.java b/java/src/com/android/inputmethod/keyboard/MiniKeyboard.java
index f84eb19cd..ff4e72853 100644
--- a/java/src/com/android/inputmethod/keyboard/MiniKeyboard.java
+++ b/java/src/com/android/inputmethod/keyboard/MiniKeyboard.java
@@ -262,7 +262,7 @@ public class MiniKeyboard extends Keyboard {
for (int n = 0; n < mPopupCharacters.length; n++) {
final CharSequence label = mPopupCharacters[n];
final int row = n / params.mNumColumns;
- final Key key = new Key(mResources, params, label, params.getX(n, row),
+ final Key key = new Key(mResources, params, label.toString(), params.getX(n, row),
params.getY(row), params.mDefaultKeyWidth, params.mDefaultRowHeight,
params.getRowFlags(row));
params.onAddKey(key);
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index 229bf0f4c..7559108f3 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -1708,8 +1708,8 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
final int rawPrimaryCode = suggestion.charAt(0);
// Maybe apply the "bidi mirrored" conversions for parentheses
final LatinKeyboard keyboard = mKeyboardSwitcher.getLatinKeyboard();
- final int primaryCode = keyboard.mIsRtlKeyboard
- ? Key.getRtlParenthesisCode(rawPrimaryCode) : rawPrimaryCode;
+ final int primaryCode = Key.getRtlParenthesisCode(
+ rawPrimaryCode, keyboard.mIsRtlKeyboard);
final CharSequence beforeText = ic != null ? ic.getTextBeforeCursor(1, 0) : "";
final int toLeft = (ic == null || TextUtils.isEmpty(beforeText))