aboutsummaryrefslogtreecommitdiffstats
path: root/java/src
diff options
context:
space:
mode:
Diffstat (limited to 'java/src')
-rw-r--r--java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java2
-rw-r--r--java/src/com/android/inputmethod/keyboard/KeyboardView.java20
-rw-r--r--java/src/com/android/inputmethod/keyboard/LatinKeyboard.java13
-rw-r--r--java/src/com/android/inputmethod/keyboard/PopupMiniKeyboardView.java7
-rw-r--r--java/src/com/android/inputmethod/keyboard/PopupPanel.java1
-rw-r--r--java/src/com/android/inputmethod/keyboard/internal/Key.java6
-rw-r--r--java/src/com/android/inputmethod/keyboard/internal/KeyboardIconsSet.java21
-rw-r--r--java/src/com/android/inputmethod/keyboard/internal/KeyboardParser.java10
8 files changed, 42 insertions, 38 deletions
diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
index 90cf3d855..1ad5b08eb 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
@@ -54,7 +54,7 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
R.style.KeyboardTheme_Stone,
R.style.KeyboardTheme_Stone_Bold,
R.style.KeyboardTheme_Gingerbread,
- R.style.KeyboardTheme_Honeycomb,
+ R.style.KeyboardTheme_IceCreamSandwich,
};
private SubtypeSwitcher mSubtypeSwitcher;
diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardView.java b/java/src/com/android/inputmethod/keyboard/KeyboardView.java
index 6bb80648e..a6aef27e0 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyboardView.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyboardView.java
@@ -828,16 +828,18 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
// For characters, use large font. For labels like "Done", use small font.
final int labelSize;
final Typeface labelStyle;
+ if ((keyLabelOption & Key.LABEL_OPTION_FONT_NORMAL) != 0) {
+ labelStyle = Typeface.DEFAULT;
+ } else if ((keyLabelOption & Key.LABEL_OPTION_FONT_FIXED_WIDTH) != 0) {
+ labelStyle = Typeface.MONOSPACE;
+ } else {
+ labelStyle = mKeyTextStyle;
+ }
if (label.length() > 1) {
- labelSize = mKeyLabelSize;
- if ((keyLabelOption & Key.LABEL_OPTION_FONT_NORMAL) != 0) {
- labelStyle = Typeface.DEFAULT;
- } else {
- labelStyle = Typeface.DEFAULT_BOLD;
- }
+ labelSize = (keyLabelOption & Key.LABEL_OPTION_FOLLOW_KEY_LETTER_RATIO) != 0
+ ? mKeyLetterSize : mKeyLabelSize;
} else {
labelSize = mKeyLetterSize;
- labelStyle = mKeyTextStyle;
}
paint.setTextSize(labelSize);
paint.setTypeface(labelStyle);
@@ -971,7 +973,6 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
if (key.mLabel != null) {
// TODO Should take care of temporaryShiftLabel here.
previewText.setCompoundDrawables(null, null, null, null);
- previewText.setText(adjustCase(tracker.getPreviewText(key)));
if (key.mLabel.length() > 1) {
previewText.setTextSize(TypedValue.COMPLEX_UNIT_PX, mKeyLetterSize);
previewText.setTypeface(Typeface.DEFAULT_BOLD);
@@ -979,6 +980,7 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
previewText.setTextSize(TypedValue.COMPLEX_UNIT_PX, mPreviewTextSize);
previewText.setTypeface(mKeyTextStyle);
}
+ previewText.setText(adjustCase(tracker.getPreviewText(key)));
} else {
final Drawable previewIcon = key.getPreviewIcon();
previewText.setCompoundDrawables(null, null, null,
@@ -1120,7 +1122,7 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
miniKeyboardView.setKeyboard(keyboard);
container.measure(MeasureSpec.makeMeasureSpec(getWidth(), MeasureSpec.AT_MOST),
- MeasureSpec.makeMeasureSpec(getHeight(), MeasureSpec.AT_MOST));
+ MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
return miniKeyboardView;
}
diff --git a/java/src/com/android/inputmethod/keyboard/LatinKeyboard.java b/java/src/com/android/inputmethod/keyboard/LatinKeyboard.java
index e741625ca..0329ee2b3 100644
--- a/java/src/com/android/inputmethod/keyboard/LatinKeyboard.java
+++ b/java/src/com/android/inputmethod/keyboard/LatinKeyboard.java
@@ -60,6 +60,7 @@ public class LatinKeyboard extends Keyboard {
private final Drawable mSpaceIcon;
private final Drawable mSpacePreviewIcon;
private final int mSpaceKeyIndex;
+ private final boolean mAutoCorrectionSpacebarLedEnabled;
private final Drawable mAutoCorrectionSpacebarLedIcon;
private final Drawable mSpacebarArrowLeftIcon;
private final Drawable mSpacebarArrowRightIcon;
@@ -123,6 +124,8 @@ public class LatinKeyboard extends Keyboard {
final TypedArray a = context.obtainStyledAttributes(
null, R.styleable.LatinKeyboard, R.attr.latinKeyboardStyle, R.style.LatinKeyboard);
+ mAutoCorrectionSpacebarLedEnabled = a.getBoolean(
+ R.styleable.LatinKeyboard_autoCorrectionSpacebarLedEnabled, false);
mAutoCorrectionSpacebarLedIcon = a.getDrawable(
R.styleable.LatinKeyboard_autoCorrectionSpacebarLedIcon);
mDisabledShortcutIcon = a.getDrawable(R.styleable.LatinKeyboard_disabledShortcutIcon);
@@ -179,7 +182,7 @@ public class LatinKeyboard extends Keyboard {
}
public boolean needsAutoCorrectionSpacebarLed() {
- return mAutoCorrectionSpacebarLedIcon != null;
+ return mAutoCorrectionSpacebarLedEnabled;
}
/**
@@ -212,7 +215,7 @@ public class LatinKeyboard extends Keyboard {
}
// Layout local language name and left and right arrow on spacebar.
- private static String layoutSpacebar(Paint paint, Locale locale, Drawable lArrow,
+ private static String layoutSpacebar(Paint paint, Locale locale, Drawable icon, Drawable lArrow,
Drawable rArrow, int width, int height, float origTextSize) {
final float arrowWidth = lArrow.getIntrinsicWidth();
final float arrowHeight = lArrow.getIntrinsicHeight();
@@ -249,7 +252,9 @@ public class LatinKeyboard extends Keyboard {
paint.setTextSize(textSize);
// Place left and right arrow just before and after language text.
- final float baseline = height * SPACEBAR_LANGUAGE_BASELINE;
+ final float textHeight = -paint.ascent() + paint.descent();
+ final float baseline = (icon != null) ? height * SPACEBAR_LANGUAGE_BASELINE
+ : height / 2 + textHeight / 2;
final int top = (int)(baseline - arrowHeight);
final float remains = (width - textWidth) / 2;
lArrow.setBounds((int)(remains - arrowWidth), top, (int)remains, (int)baseline);
@@ -300,7 +305,7 @@ public class LatinKeyboard extends Keyboard {
defaultTextSize = 14;
}
- final String language = layoutSpacebar(paint, inputLocale,
+ final String language = layoutSpacebar(paint, inputLocale, mSpaceIcon,
mSpacebarArrowLeftIcon, mSpacebarArrowRightIcon, width, height,
getTextSizeFromTheme(mTheme, textStyle, defaultTextSize));
diff --git a/java/src/com/android/inputmethod/keyboard/PopupMiniKeyboardView.java b/java/src/com/android/inputmethod/keyboard/PopupMiniKeyboardView.java
index 2085404dc..6180f09c1 100644
--- a/java/src/com/android/inputmethod/keyboard/PopupMiniKeyboardView.java
+++ b/java/src/com/android/inputmethod/keyboard/PopupMiniKeyboardView.java
@@ -78,15 +78,12 @@ public class PopupMiniKeyboardView extends KeyboardView implements PopupPanel {
final int pointY = parentKey.mY;
final int miniKeyboardLeft = pointX - miniKeyboard.getDefaultCoordX()
+ parentKeyboardView.getPaddingLeft();
- final int miniKeyboardX = Math.max(0, Math.min(miniKeyboardLeft,
+ final int x = Math.max(0, Math.min(miniKeyboardLeft,
parentKeyboardView.getWidth() - miniKeyboard.getMinWidth()))
- container.getPaddingLeft() + mCoordinates[0];
- final int miniKeyboardY = pointY - parentKeyboard.getVerticalGap()
+ final int y = pointY - parentKeyboard.getVerticalGap()
- (container.getMeasuredHeight() - container.getPaddingBottom())
+ parentKeyboardView.getPaddingTop() + mCoordinates[1];
- final int x = miniKeyboardX;
- final int y = parentKeyboardView.isKeyPreviewPopupEnabled() &&
- miniKeyboard.isOneRowKeyboard() && keyPreviewY >= 0 ? keyPreviewY : miniKeyboardY;
if (miniKeyboard.setShifted(parentKeyboard.isShiftedOrShiftLocked())) {
invalidateAllKeys();
diff --git a/java/src/com/android/inputmethod/keyboard/PopupPanel.java b/java/src/com/android/inputmethod/keyboard/PopupPanel.java
index 72fa7406a..48454679e 100644
--- a/java/src/com/android/inputmethod/keyboard/PopupPanel.java
+++ b/java/src/com/android/inputmethod/keyboard/PopupPanel.java
@@ -30,6 +30,7 @@ public interface PopupPanel {
* @param keyPreviewY the Y-coordinate of key preview
* @param window PopupWindow to be used to show this popup panel
*/
+ // TODO: Remove keyPreviewY from argument.
public void showPanel(KeyboardView parentKeyboardView, Key parentKey,
PointerTracker tracker, int keyPreviewY, PopupWindow window);
diff --git a/java/src/com/android/inputmethod/keyboard/internal/Key.java b/java/src/com/android/inputmethod/keyboard/internal/Key.java
index 5470067dc..ebd80be5e 100644
--- a/java/src/com/android/inputmethod/keyboard/internal/Key.java
+++ b/java/src/com/android/inputmethod/keyboard/internal/Key.java
@@ -49,8 +49,10 @@ public class Key {
public static final int LABEL_OPTION_ALIGN_RIGHT = 0x02;
public static final int LABEL_OPTION_ALIGN_BOTTOM = 0x08;
public static final int LABEL_OPTION_FONT_NORMAL = 0x10;
- private static final int LABEL_OPTION_POPUP_HINT = 0x20;
- private static final int LABEL_OPTION_HAS_UPPERCASE_LETTER = 0x40;
+ public static final int LABEL_OPTION_FONT_FIXED_WIDTH = 0x20;
+ public static final int LABEL_OPTION_FOLLOW_KEY_LETTER_RATIO = 0x40;
+ private static final int LABEL_OPTION_POPUP_HINT = 0x80;
+ private static final int LABEL_OPTION_HAS_UPPERCASE_LETTER = 0x100;
/** Icon to display instead of a label. Icon takes precedence over a label */
private Drawable mIcon;
diff --git a/java/src/com/android/inputmethod/keyboard/internal/KeyboardIconsSet.java b/java/src/com/android/inputmethod/keyboard/internal/KeyboardIconsSet.java
index 9916af5da..37b36825a 100644
--- a/java/src/com/android/inputmethod/keyboard/internal/KeyboardIconsSet.java
+++ b/java/src/com/android/inputmethod/keyboard/internal/KeyboardIconsSet.java
@@ -50,18 +50,15 @@ public class KeyboardIconsSet {
private static final int ICON_NUM8_KEY = 18;
private static final int ICON_NUM9_KEY = 19;
private static final int ICON_NUM0_KEY = 20;
- private static final int ICON_NUM_STAR_KEY = 21;
- private static final int ICON_NUM_POUND_KEY = 22;
- private static final int ICON_NUM_ALT_KEY = 23;
// This should be aligned with Keyboard.keyIconShifted enum.
- private static final int ICON_SHIFTED_SHIFT_KEY = 24;
+ private static final int ICON_SHIFTED_SHIFT_KEY = 21;
// This should be aligned with Keyboard.keyIconPreview enum.
- private static final int ICON_PREVIEW_SPACE_KEY = 25;
- private static final int ICON_PREVIEW_TAB_KEY = 26;
- private static final int ICON_PREVIEW_SETTINGS_KEY = 27;
- private static final int ICON_PREVIEW_SHORTCUT_KEY = 28;
+ private static final int ICON_PREVIEW_SPACE_KEY = 22;
+ private static final int ICON_PREVIEW_TAB_KEY = 23;
+ private static final int ICON_PREVIEW_SETTINGS_KEY = 24;
+ private static final int ICON_PREVIEW_SHORTCUT_KEY = 25;
- private static final int ICON_LAST = 28;
+ private static final int ICON_LAST = 25;
private final Drawable mIcons[] = new Drawable[ICON_LAST + 1];
@@ -107,12 +104,6 @@ public class KeyboardIconsSet {
return ICON_NUM9_KEY;
case R.styleable.Keyboard_iconNum0Key:
return ICON_NUM0_KEY;
- case R.styleable.Keyboard_iconNumStarKey:
- return ICON_NUM_STAR_KEY;
- case R.styleable.Keyboard_iconNumPoundKey:
- return ICON_NUM_POUND_KEY;
- case R.styleable.Keyboard_iconNumAltKey:
- return ICON_NUM_ALT_KEY;
case R.styleable.Keyboard_iconShiftedShiftKey:
return ICON_SHIFTED_SHIFT_KEY;
case R.styleable.Keyboard_iconPreviewSpaceKey:
diff --git a/java/src/com/android/inputmethod/keyboard/internal/KeyboardParser.java b/java/src/com/android/inputmethod/keyboard/internal/KeyboardParser.java
index 78546f879..d5b364818 100644
--- a/java/src/com/android/inputmethod/keyboard/internal/KeyboardParser.java
+++ b/java/src/com/android/inputmethod/keyboard/internal/KeyboardParser.java
@@ -126,6 +126,8 @@ public class KeyboardParser {
private final Context mContext;
private final Resources mResources;
+ private int mKeyboardTopPadding;
+ private int mKeyboardBottomPadding;
private int mHorizontalEdgesPadding;
private int mCurrentX = 0;
private int mCurrentY = 0;
@@ -234,6 +236,10 @@ public class KeyboardParser {
R.styleable.Keyboard_Key_maxPopupKeyboardColumn, 5));
mKeyboard.mIconsSet.loadIcons(keyboardAttr);
+ mKeyboardTopPadding = keyboardAttr.getDimensionPixelSize(
+ R.styleable.Keyboard_keyboardTopPadding, 0);
+ mKeyboardBottomPadding = keyboardAttr.getDimensionPixelSize(
+ R.styleable.Keyboard_keyboardBottomPadding, 0);
} finally {
keyAttr.recycle();
keyboardAttr.recycle();
@@ -602,7 +608,7 @@ public class KeyboardParser {
}
private void startKeyboard() {
- mCurrentY += (int)mResources.getDimension(R.dimen.keyboard_top_padding);
+ mCurrentY += mKeyboardTopPadding;
}
private void startRow(Row row) {
@@ -626,7 +632,7 @@ public class KeyboardParser {
}
private void endKeyboard(int defaultVerticalGap) {
- mCurrentY += (int)mResources.getDimension(R.dimen.keyboard_bottom_padding);
+ mCurrentY += mKeyboardBottomPadding;
mTotalHeight = mCurrentY - defaultVerticalGap;
}