diff --git a/java/res/drawable-hdpi/sym_keyboard_spacebar_lxx_dark.9.png b/java/res/drawable-hdpi/sym_keyboard_spacebar_lxx_dark.9.png
new file mode 100644
index 000000000..e70f0c1e8
Binary files /dev/null and b/java/res/drawable-hdpi/sym_keyboard_spacebar_lxx_dark.9.png differ
diff --git a/java/res/drawable-mdpi/sym_keyboard_spacebar_lxx_dark.9.png b/java/res/drawable-mdpi/sym_keyboard_spacebar_lxx_dark.9.png
new file mode 100644
index 000000000..86e816d5b
Binary files /dev/null and b/java/res/drawable-mdpi/sym_keyboard_spacebar_lxx_dark.9.png differ
diff --git a/java/res/drawable-xhdpi/sym_keyboard_spacebar_lxx_dark.9.png b/java/res/drawable-xhdpi/sym_keyboard_spacebar_lxx_dark.9.png
new file mode 100644
index 000000000..cb660545e
Binary files /dev/null and b/java/res/drawable-xhdpi/sym_keyboard_spacebar_lxx_dark.9.png differ
diff --git a/java/res/drawable-xxhdpi/sym_keyboard_spacebar_lxx_dark.9.png b/java/res/drawable-xxhdpi/sym_keyboard_spacebar_lxx_dark.9.png
new file mode 100644
index 000000000..1f25e272d
Binary files /dev/null and b/java/res/drawable-xxhdpi/sym_keyboard_spacebar_lxx_dark.9.png differ
diff --git a/java/res/values/attrs.xml b/java/res/values/attrs.xml
index 7363b6108..b90e82b53 100644
--- a/java/res/values/attrs.xml
+++ b/java/res/values/attrs.xml
@@ -51,6 +51,7 @@
+
@@ -284,6 +285,7 @@
+
diff --git a/java/res/values/keyboard-icons-lxx.xml b/java/res/values/keyboard-icons-lxx.xml
index 8a3886316..56d660475 100644
--- a/java/res/values/keyboard-icons-lxx.xml
+++ b/java/res/values/keyboard-icons-lxx.xml
@@ -25,7 +25,7 @@
- @drawable/sym_keyboard_shift_holo_dark
- @drawable/sym_keyboard_delete_lxx_dark
- @drawable/sym_keyboard_settings_lxx_dark
- - @drawable/sym_keyboard_space_holo_dark
+ - @drawable/sym_keyboard_spacebar_lxx_dark
- @drawable/sym_keyboard_return_holo_dark
- @drawable/sym_keyboard_go_lxx_dark
- @drawable/sym_keyboard_search_lxx_dark
diff --git a/java/res/values/themes-lxx.xml b/java/res/values/themes-lxx.xml
index 3c7a2b511..03babd259 100644
--- a/java/res/values/themes-lxx.xml
+++ b/java/res/values/themes-lxx.xml
@@ -50,6 +50,7 @@
- @drawable/btn_keyboard_key_lxx
- @drawable/btn_keyboard_key_functional_lxx
- @drawable/btn_keyboard_spacebar_lxx
+ - 0.9
- bold
- @color/key_text_color_holo
- @color/key_text_inactive_color_lxx
diff --git a/java/res/xml-sw600dp/key_styles_common.xml b/java/res/xml-sw600dp/key_styles_common.xml
index 35b3576af..d302ab270 100644
--- a/java/res/xml-sw600dp/key_styles_common.xml
+++ b/java/res/xml-sw600dp/key_styles_common.xml
@@ -79,6 +79,7 @@
diff --git a/java/res/xml/key_styles_common.xml b/java/res/xml/key_styles_common.xml
index f8b4a2a60..0a274e009 100644
--- a/java/res/xml/key_styles_common.xml
+++ b/java/res/xml/key_styles_common.xml
@@ -88,6 +88,7 @@
diff --git a/java/res/xml/key_styles_number.xml b/java/res/xml/key_styles_number.xml
index df4448c25..8a76fe397 100644
--- a/java/res/xml/key_styles_number.xml
+++ b/java/res/xml/key_styles_number.xml
@@ -120,6 +120,7 @@
diff --git a/java/src/com/android/inputmethod/keyboard/Key.java b/java/src/com/android/inputmethod/keyboard/Key.java
index a1269c801..cf68c565d 100644
--- a/java/src/com/android/inputmethod/keyboard/Key.java
+++ b/java/src/com/android/inputmethod/keyboard/Key.java
@@ -60,6 +60,7 @@ public class Key implements Comparable {
private final int mLabelFlags;
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_BUTTOM = 0x04;
private static final int LABEL_FLAGS_ALIGN_LEFT_OF_CENTER = 0x08;
private static final int LABEL_FLAGS_FONT_NORMAL = 0x10;
private static final int LABEL_FLAGS_FONT_MONO_SPACE = 0x20;
@@ -646,6 +647,10 @@ public class Key implements Comparable {
return (mLabelFlags & LABEL_FLAGS_ALIGN_RIGHT) != 0;
}
+ public final boolean isAlignButtom() {
+ return (mLabelFlags & LABEL_FLAGS_ALIGN_BUTTOM) != 0;
+ }
+
public final boolean isAlignLeftOfCenter() {
return (mLabelFlags & LABEL_FLAGS_ALIGN_LEFT_OF_CENTER) != 0;
}
diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardView.java b/java/src/com/android/inputmethod/keyboard/KeyboardView.java
index a6eac4cd7..edfc5fded 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyboardView.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyboardView.java
@@ -28,6 +28,7 @@ import android.graphics.Rect;
import android.graphics.Region;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
+import android.graphics.drawable.NinePatchDrawable;
import android.util.AttributeSet;
import android.view.View;
@@ -49,6 +50,7 @@ import java.util.HashSet;
* @attr ref R.styleable#KeyboardView_keyBackground
* @attr ref R.styleable#KeyboardView_functionalKeyBackground
* @attr ref R.styleable#KeyboardView_spacebarBackground
+ * @attr ref R.styleable#KeyboardView_spacebarIconWidthRatio
* @attr ref R.styleable#KeyboardView_keyLabelHorizontalPadding
* @attr ref R.styleable#KeyboardView_keyHintLetterPadding
* @attr ref R.styleable#KeyboardView_keyPopupHintLetterPadding
@@ -85,6 +87,7 @@ public class KeyboardView extends View {
private final Drawable mKeyBackground;
private final Drawable mFunctionalKeyBackground;
private final Drawable mSpacebarBackground;
+ private final float mSpacebarIconWidthRatio;
private final Rect mKeyBackgroundPadding = new Rect();
private static final float KET_TEXT_SHADOW_RADIUS_DISABLED = -1.0f;
@@ -135,8 +138,9 @@ public class KeyboardView extends View {
: mKeyBackground;
final Drawable spacebarBackground = keyboardViewAttr.getDrawable(
R.styleable.KeyboardView_spacebarBackground);
- mSpacebarBackground = (spacebarBackground != null) ? spacebarBackground
- : mKeyBackground;
+ mSpacebarBackground = (spacebarBackground != null) ? spacebarBackground : mKeyBackground;
+ mSpacebarIconWidthRatio = keyboardViewAttr.getFloat(
+ R.styleable.KeyboardView_spacebarIconWidthRatio, 1.0f);
mKeyLabelHorizontalPadding = keyboardViewAttr.getDimensionPixelOffset(
R.styleable.KeyboardView_keyLabelHorizontalPadding, 0);
mKeyHintLetterPadding = keyboardViewAttr.getDimension(
@@ -513,10 +517,16 @@ public class KeyboardView extends View {
// Draw key icon.
if (label == null && icon != null) {
- final int iconWidth = Math.min(icon.getIntrinsicWidth(), keyWidth);
+ final int iconWidth;
+ if (key.getCode() == Constants.CODE_SPACE && icon instanceof NinePatchDrawable) {
+ iconWidth = (int)(keyWidth * mSpacebarIconWidthRatio);
+ } else {
+ iconWidth = Math.min(icon.getIntrinsicWidth(), keyWidth);
+ }
final int iconHeight = icon.getIntrinsicHeight();
final int iconX, alignX;
- final int iconY = (keyHeight - iconHeight) / 2;
+ final int iconY = key.isAlignButtom() ? keyHeight - iconHeight
+ : (keyHeight - iconHeight) / 2;
if (key.isAlignLeft()) {
iconX = mKeyLabelHorizontalPadding;
alignX = iconX;
diff --git a/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java b/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java
index ac11dca97..26b6dd06a 100644
--- a/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java
+++ b/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java
@@ -27,7 +27,6 @@ import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Paint.Align;
import android.graphics.Typeface;
-import android.graphics.drawable.Drawable;
import android.preference.PreferenceManager;
import android.util.AttributeSet;
import android.util.Log;
@@ -116,7 +115,6 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
/* Space key and its icon and background. */
private Key mSpaceKey;
- private Drawable mSpacebarIcon;
// Stuff to draw language name on spacebar.
private final int mLanguageOnSpacebarFinalAlpha;
private ObjectAnimator mLanguageOnSpacebarFadeoutAnimator;
@@ -389,8 +387,6 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
mMoreKeysKeyboardCache.clear();
mSpaceKey = keyboard.getKey(Constants.CODE_SPACE);
- mSpacebarIcon = (mSpaceKey != null)
- ? mSpaceKey.getIcon(keyboard.mIconsSet, Constants.Color.ALPHA_OPAQUE) : null;
final int keyHeight = keyboard.mMostCommonKeyHeight - keyboard.mVerticalGap;
mLanguageOnSpacebarTextSize = keyHeight * mLanguageOnSpacebarTextRatio;
if (ProductionFlag.USES_DEVELOPMENT_ONLY_DIAGNOSTICS) {
@@ -847,18 +843,19 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
if (key.altCodeWhileTyping() && key.isEnabled()) {
params.mAnimAlpha = mAltCodeKeyWhileTypingAnimAlpha;
}
+ super.onDrawKeyTopVisuals(key, canvas, paint, params);
final int code = key.getCode();
if (code == Constants.CODE_SPACE) {
- drawSpacebar(key, canvas, paint);
+ // If input language are explicitly selected.
+ if (mLanguageOnSpacebarFormatType != LanguageOnSpacebarHelper.FORMAT_TYPE_NONE) {
+ drawLanguageOnSpacebar(key, canvas, paint);
+ }
// Whether space key needs to show the "..." popup hint for special purposes
if (key.isLongPressEnabled() && mHasMultipleEnabledIMEsOrSubtypes) {
drawKeyPopupHint(key, canvas, paint, params);
}
} else if (code == Constants.CODE_LANGUAGE_SWITCH) {
- super.onDrawKeyTopVisuals(key, canvas, paint, params);
drawKeyPopupHint(key, canvas, paint, params);
- } else {
- super.onDrawKeyTopVisuals(key, canvas, paint, params);
}
}
@@ -898,42 +895,29 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
return "";
}
- private void drawSpacebar(final Key key, final Canvas canvas, final Paint paint) {
+ private void drawLanguageOnSpacebar(final Key key, final Canvas canvas, final Paint paint) {
final int width = key.getWidth();
final int height = key.getHeight();
-
- // If input language are explicitly selected.
- if (mLanguageOnSpacebarFormatType != LanguageOnSpacebarHelper.FORMAT_TYPE_NONE) {
- paint.setTextAlign(Align.CENTER);
- paint.setTypeface(Typeface.DEFAULT);
- paint.setTextSize(mLanguageOnSpacebarTextSize);
- final InputMethodSubtype subtype = getKeyboard().mId.mSubtype;
- final String language = layoutLanguageOnSpacebar(paint, subtype, width);
- // Draw language text with shadow
- final float descent = paint.descent();
- final float textHeight = -paint.ascent() + descent;
- final float baseline = height / 2 + textHeight / 2;
- if (mLanguageOnSpacebarTextShadowRadius > 0.0f) {
- paint.setShadowLayer(mLanguageOnSpacebarTextShadowRadius, 0, 0,
- mLanguageOnSpacebarTextShadowColor);
- } else {
- paint.clearShadowLayer();
- }
- paint.setColor(mLanguageOnSpacebarTextColor);
- paint.setAlpha(mLanguageOnSpacebarAnimAlpha);
- canvas.drawText(language, width / 2, baseline - descent, paint);
+ paint.setTextAlign(Align.CENTER);
+ paint.setTypeface(Typeface.DEFAULT);
+ paint.setTextSize(mLanguageOnSpacebarTextSize);
+ final InputMethodSubtype subtype = getKeyboard().mId.mSubtype;
+ final String language = layoutLanguageOnSpacebar(paint, subtype, width);
+ // Draw language text with shadow
+ final float descent = paint.descent();
+ final float textHeight = -paint.ascent() + descent;
+ final float baseline = height / 2 + textHeight / 2;
+ if (mLanguageOnSpacebarTextShadowRadius > 0.0f) {
+ paint.setShadowLayer(mLanguageOnSpacebarTextShadowRadius, 0, 0,
+ mLanguageOnSpacebarTextShadowColor);
+ } else {
paint.clearShadowLayer();
- paint.setTextScaleX(1.0f);
- }
-
- // Draw the spacebar icon at the bottom
- if (mSpacebarIcon != null) {
- final int iconWidth = mSpacebarIcon.getIntrinsicWidth();
- final int iconHeight = mSpacebarIcon.getIntrinsicHeight();
- int x = (width - iconWidth) / 2;
- int y = height - iconHeight;
- drawIcon(canvas, mSpacebarIcon, x, y, iconWidth, iconHeight);
}
+ paint.setColor(mLanguageOnSpacebarTextColor);
+ paint.setAlpha(mLanguageOnSpacebarAnimAlpha);
+ canvas.drawText(language, width / 2, baseline - descent, paint);
+ paint.clearShadowLayer();
+ paint.setTextScaleX(1.0f);
}
@Override