aboutsummaryrefslogtreecommitdiffstats
path: root/java
diff options
context:
space:
mode:
Diffstat (limited to 'java')
-rw-r--r--java/src/com/android/inputmethod/keyboard/Key.java25
-rw-r--r--java/src/com/android/inputmethod/keyboard/KeyboardView.java7
-rw-r--r--java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java5
-rw-r--r--java/src/com/android/inputmethod/keyboard/MiniKeyboard.java4
-rw-r--r--java/src/com/android/inputmethod/latin/CandidateView.java28
5 files changed, 40 insertions, 29 deletions
diff --git a/java/src/com/android/inputmethod/keyboard/Key.java b/java/src/com/android/inputmethod/keyboard/Key.java
index c3db1b318..9cf64e151 100644
--- a/java/src/com/android/inputmethod/keyboard/Key.java
+++ b/java/src/com/android/inputmethod/keyboard/Key.java
@@ -192,21 +192,30 @@ public class Key {
}
}
+ private static int getCode(Resources res, KeyboardParams params, String popupSpec) {
+ return getRtlParenthesisCode(
+ PopupCharactersParser.getCode(res, popupSpec), params.mIsRtlKeyboard);
+ }
+
+ private static Drawable getIcon(KeyboardParams params, String popupSpec) {
+ return params.mIconsSet.getIcon(PopupCharactersParser.getIconId(popupSpec));
+ }
+
/**
* This constructor is being used only for key in popup mini keyboard.
*/
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(params, PopupCharactersParser.getLabel(popupSpec), null, getIcon(params, popupSpec),
+ getCode(res, params, popupSpec), PopupCharactersParser.getOutputText(popupSpec),
+ 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) {
+ public Key(KeyboardParams params, CharSequence label, CharSequence hintLabel, Drawable icon,
+ int code, CharSequence outputText, int x, int y, int width, int height, int edgeFlags) {
mHeight = height - params.mVerticalGap;
mHorizontalGap = params.mHorizontalGap;
mVerticalGap = params.mVerticalGap;
@@ -220,10 +229,10 @@ public class Key {
mRepeatable = false;
mPopupCharacters = null;
mMaxPopupColumn = 0;
- mLabel = PopupCharactersParser.getLabel(popupSpec);
- mOutputText = PopupCharactersParser.getOutputText(popupSpec);
+ mLabel = label;
+ mOutputText = outputText;
mCode = code;
- mIcon = params.mIconsSet.getIcon(PopupCharactersParser.getIconId(popupSpec));
+ mIcon = icon;
// Horizontal gap is divided equally to both sides of the key.
mX = x + mHorizontalGap / 2;
mY = y;
diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardView.java b/java/src/com/android/inputmethod/keyboard/KeyboardView.java
index 5f824537e..9e5e20953 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyboardView.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyboardView.java
@@ -35,6 +35,7 @@ import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
+import android.view.ViewGroup.LayoutParams;
import android.widget.RelativeLayout;
import android.widget.TextView;
@@ -122,9 +123,6 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy {
new HashMap<Integer, Float>();
private static final String KEY_LABEL_REFERENCE_CHAR = "M";
- private static final int MEASURESPEC_UNSPECIFIED = MeasureSpec.makeMeasureSpec(
- 0, MeasureSpec.UNSPECIFIED);
-
private final DrawingHandler mDrawingHandler = new DrawingHandler(this);
public static class DrawingHandler extends StaticInnerHandlerWrapper<KeyboardView> {
@@ -859,7 +857,8 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy {
}
previewText.setBackgroundDrawable(params.mPreviewBackground);
- previewText.measure(MEASURESPEC_UNSPECIFIED, MEASURESPEC_UNSPECIFIED);
+ previewText.measure(
+ ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
final int previewWidth = Math.max(previewText.getMeasuredWidth(), keyDrawWidth
+ previewText.getPaddingLeft() + previewText.getPaddingRight());
final int previewHeight = params.mPreviewHeight;
diff --git a/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java b/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java
index 69cbcb154..85084847d 100644
--- a/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java
+++ b/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java
@@ -30,6 +30,7 @@ import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewConfiguration;
+import android.view.ViewGroup;
import android.view.accessibility.AccessibilityEvent;
import android.widget.PopupWindow;
@@ -379,9 +380,7 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke
final Keyboard miniKeyboard = new MiniKeyboard.Builder(
this, parentKeyboard.mPopupKeyboardResId, parentKey, parentKeyboard).build();
miniKeyboardView.setKeyboard(miniKeyboard);
-
- container.measure(MeasureSpec.makeMeasureSpec(getWidth(), MeasureSpec.AT_MOST),
- MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
+ container.measure(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
return miniKeyboardView;
}
diff --git a/java/src/com/android/inputmethod/keyboard/MiniKeyboard.java b/java/src/com/android/inputmethod/keyboard/MiniKeyboard.java
index ff4e72853..e6045dc90 100644
--- a/java/src/com/android/inputmethod/keyboard/MiniKeyboard.java
+++ b/java/src/com/android/inputmethod/keyboard/MiniKeyboard.java
@@ -260,9 +260,9 @@ public class MiniKeyboard extends Keyboard {
public MiniKeyboard build() {
final MiniKeyboardParams params = mParams;
for (int n = 0; n < mPopupCharacters.length; n++) {
- final CharSequence label = mPopupCharacters[n];
+ final String popupSpec = mPopupCharacters[n].toString();
final int row = n / params.mNumColumns;
- final Key key = new Key(mResources, params, label.toString(), params.getX(n, row),
+ final Key key = new Key(mResources, params, popupSpec, 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/CandidateView.java b/java/src/com/android/inputmethod/latin/CandidateView.java
index f445abf48..b9ded31cb 100644
--- a/java/src/com/android/inputmethod/latin/CandidateView.java
+++ b/java/src/com/android/inputmethod/latin/CandidateView.java
@@ -59,8 +59,6 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo
// The maximum number of suggestions available. See {@link Suggest#mPrefMaxSuggestions}.
private static final int MAX_SUGGESTIONS = 18;
- private static final int WRAP_CONTENT = ViewGroup.LayoutParams.WRAP_CONTENT;
- private static final int MATCH_PARENT = ViewGroup.LayoutParams.MATCH_PARENT;
private static final boolean DBG = LatinImeLogger.sDBG;
@@ -155,7 +153,8 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo
final TextView word = words.get(0);
final View divider = dividers.get(0);
mPadding = word.getCompoundPaddingLeft() + word.getCompoundPaddingRight();
- divider.measure(WRAP_CONTENT, MATCH_PARENT);
+ divider.measure(
+ ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
mDividerWidth = divider.getMeasuredWidth();
mDividerHeight = divider.getMeasuredHeight();
@@ -224,7 +223,7 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo
lastView = word;
if (x == 0)
centeringFrom = word;
- word.measure(WRAP_CONTENT,
+ word.measure(ViewGroup.LayoutParams.WRAP_CONTENT,
MeasureSpec.makeMeasureSpec(mCandidateStripHeight, MeasureSpec.EXACTLY));
final int width = word.getMeasuredWidth();
final int height = word.getMeasuredHeight();
@@ -234,7 +233,8 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo
if (info != null) {
paneView.addView(info);
lastView = info;
- info.measure(WRAP_CONTENT, WRAP_CONTENT);
+ info.measure(ViewGroup.LayoutParams.WRAP_CONTENT,
+ ViewGroup.LayoutParams.WRAP_CONTENT);
final int infoWidth = info.getMeasuredWidth();
FrameLayoutCompatUtils.placeViewAt(
info, x - infoWidth, y, infoWidth, info.getMeasuredHeight());
@@ -430,7 +430,8 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo
word.setText(text); // TextView.setText() resets text scale x to 1.0.
word.setTextScaleX(scaleX);
stripView.addView(word);
- setLayoutWeight(word, getCandidateWeight(index), MATCH_PARENT);
+ setLayoutWeight(
+ word, getCandidateWeight(index), ViewGroup.LayoutParams.MATCH_PARENT);
x += word.getMeasuredWidth();
if (DBG) {
@@ -439,7 +440,8 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo
final TextView info = mInfos.get(pos);
info.setText(debugInfo);
placer.addView(info);
- info.measure(WRAP_CONTENT, WRAP_CONTENT);
+ info.measure(ViewGroup.LayoutParams.WRAP_CONTENT,
+ ViewGroup.LayoutParams.WRAP_CONTENT);
final int infoWidth = info.getMeasuredWidth();
final int y = info.getMeasuredHeight();
FrameLayoutCompatUtils.placeViewAt(
@@ -515,7 +517,7 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo
wordView.setText(text);
wordView.setTextScaleX(wordScaleX);
stripView.addView(wordView);
- setLayoutWeight(wordView, mCenterCandidateWeight, MATCH_PARENT);
+ setLayoutWeight(wordView, mCenterCandidateWeight, ViewGroup.LayoutParams.MATCH_PARENT);
stripView.addView(mDividers.get(0));
@@ -526,7 +528,8 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo
hintView.setText(mHintToSaveText);
hintView.setTextScaleX(hintScaleX);
stripView.addView(hintView);
- setLayoutWeight(hintView, 1.0f - mCenterCandidateWeight, MATCH_PARENT);
+ setLayoutWeight(
+ hintView, 1.0f - mCenterCandidateWeight, ViewGroup.LayoutParams.MATCH_PARENT);
}
}
@@ -558,7 +561,8 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo
mPreviewPopup = new PopupWindow(context);
mPreviewText = (TextView) inflater.inflate(R.layout.candidate_preview, null);
- mPreviewPopup.setWindowLayoutMode(WRAP_CONTENT, WRAP_CONTENT);
+ mPreviewPopup.setWindowLayoutMode(
+ ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
mPreviewPopup.setContentView(mPreviewText);
mPreviewPopup.setBackgroundDrawable(null);
@@ -796,8 +800,8 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo
final TextView previewText = mPreviewText;
previewText.setTextColor(mStripParams.mColorTypedWord);
previewText.setText(word);
- previewText.measure(MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED),
- MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
+ previewText.measure(
+ ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
final int[] offsetInWindow = new int[2];
view.getLocationInWindow(offsetInWindow);
final int posX = offsetInWindow[0];