aboutsummaryrefslogtreecommitdiffstats
path: root/java
diff options
context:
space:
mode:
Diffstat (limited to 'java')
-rw-r--r--java/res/drawable/btn_keyboard_spacebar_gb.xml21
-rw-r--r--java/res/drawable/btn_keyboard_spacebar_ics.xml21
-rw-r--r--java/res/drawable/btn_keyboard_spacebar_klp.xml21
-rw-r--r--java/res/values/attrs.xml8
-rw-r--r--java/res/values/themes-gb.xml1
-rw-r--r--java/res/values/themes-ics.xml1
-rw-r--r--java/res/values/themes-klp.xml1
-rw-r--r--java/src/com/android/inputmethod/keyboard/KeyboardView.java6
-rw-r--r--java/src/com/android/inputmethod/keyboard/MainKeyboardView.java29
9 files changed, 96 insertions, 13 deletions
diff --git a/java/res/drawable/btn_keyboard_spacebar_gb.xml b/java/res/drawable/btn_keyboard_spacebar_gb.xml
new file mode 100644
index 000000000..4d51f3c9c
--- /dev/null
+++ b/java/res/drawable/btn_keyboard_spacebar_gb.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2013 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+ <item android:state_pressed="true"
+ android:drawable="@drawable/btn_keyboard_key_light_pressed" />
+ <item android:drawable="@drawable/btn_keyboard_key_light_normal" />
+</selector>
diff --git a/java/res/drawable/btn_keyboard_spacebar_ics.xml b/java/res/drawable/btn_keyboard_spacebar_ics.xml
new file mode 100644
index 000000000..4530ea079
--- /dev/null
+++ b/java/res/drawable/btn_keyboard_spacebar_ics.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2013 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+ <item android:state_pressed="true"
+ android:drawable="@drawable/btn_keyboard_key_light_pressed_ics" />
+ <item android:drawable="@drawable/btn_keyboard_key_light_normal_holo" />
+</selector>
diff --git a/java/res/drawable/btn_keyboard_spacebar_klp.xml b/java/res/drawable/btn_keyboard_spacebar_klp.xml
new file mode 100644
index 000000000..6b07a392f
--- /dev/null
+++ b/java/res/drawable/btn_keyboard_spacebar_klp.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2013 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+ <item android:state_pressed="true"
+ android:drawable="@drawable/btn_keyboard_key_light_pressed_klp" />
+ <item android:drawable="@drawable/btn_keyboard_key_light_normal_holo" />
+</selector>
diff --git a/java/res/values/attrs.xml b/java/res/values/attrs.xml
index 8191ffbcb..a9474a03a 100644
--- a/java/res/values/attrs.xml
+++ b/java/res/values/attrs.xml
@@ -41,9 +41,9 @@
</declare-styleable>
<declare-styleable name="KeyboardView">
- <!-- Image for the key. This image needs to be a StateListDrawable, with the following
- possible states: normal, pressed, checkable, checkable+pressed, checkable+checked,
- checkable+checked+pressed. -->
+ <!-- Image for the key. This image needs to be a {@link StateListDrawable}, with the
+ following possible states: normal, pressed, checkable, checkable+pressed,
+ checkable+checked, checkable+checked+pressed. -->
<attr name="keyBackground" format="reference" />
<!-- Image for the functional key used in Emoji layout. -->
<attr name="keyBackgroundEmojiFunctional" format="reference" />
@@ -75,6 +75,8 @@
<attr name="languageOnSpacebarTextRatio" format="fraction" />
<attr name="languageOnSpacebarTextColor" format="color" />
<attr name="languageOnSpacebarTextShadowColor" format="color" />
+ <!-- Background image for the spacebar. -->
+ <attr name="spacebarBackground" format="reference" />
<!-- Fadeout animator for spacebar language label. -->
<attr name="languageOnSpacebarFinalAlpha" format="integer" />
<attr name="languageOnSpacebarFadeoutAnimator" format="reference" />
diff --git a/java/res/values/themes-gb.xml b/java/res/values/themes-gb.xml
index 78d47f9ee..52ecafd62 100644
--- a/java/res/values/themes-gb.xml
+++ b/java/res/values/themes-gb.xml
@@ -93,6 +93,7 @@
<item name="autoCorrectionSpacebarLedIcon">@drawable/sym_keyboard_space_led_gb</item>
<item name="languageOnSpacebarTextColor">@color/spacebar_text_color_gb</item>
<item name="languageOnSpacebarTextShadowColor">@color/spacebar_text_shadow_color_gb</item>
+ <item name="spacebarBackground">@drawable/btn_keyboard_spacebar_gb</item>
</style>
<style
name="KeyPreviewTextView.GB"
diff --git a/java/res/values/themes-ics.xml b/java/res/values/themes-ics.xml
index db8dccb4d..125b640b6 100644
--- a/java/res/values/themes-ics.xml
+++ b/java/res/values/themes-ics.xml
@@ -72,6 +72,7 @@
<item name="autoCorrectionSpacebarLedIcon">@drawable/sym_keyboard_space_led_holo</item>
<item name="languageOnSpacebarTextColor">@color/spacebar_text_color_holo</item>
<item name="languageOnSpacebarTextShadowColor">@color/spacebar_text_shadow_color_holo</item>
+ <item name="spacebarBackground">@drawable/btn_keyboard_spacebar_ics</item>
</style>
<style
name="KeyPreviewTextView.ICS"
diff --git a/java/res/values/themes-klp.xml b/java/res/values/themes-klp.xml
index dd1f630b3..f6c076767 100644
--- a/java/res/values/themes-klp.xml
+++ b/java/res/values/themes-klp.xml
@@ -72,6 +72,7 @@
<item name="autoCorrectionSpacebarLedIcon">@drawable/sym_keyboard_space_led_holo</item>
<item name="languageOnSpacebarTextColor">@color/spacebar_text_color_holo</item>
<item name="languageOnSpacebarTextShadowColor">@color/spacebar_text_shadow_color_holo</item>
+ <item name="spacebarBackground">@drawable/btn_keyboard_spacebar_klp</item>
</style>
<style
name="KeyPreviewTextView.KLP"
diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardView.java b/java/src/com/android/inputmethod/keyboard/KeyboardView.java
index dcd90070e..422bd12a3 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyboardView.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyboardView.java
@@ -319,7 +319,7 @@ public class KeyboardView extends View {
params.mAnimAlpha = Constants.Color.ALPHA_OPAQUE;
if (!key.isSpacer()) {
- onDrawKeyBackground(key, canvas);
+ onDrawKeyBackground(key, canvas, mKeyBackground);
}
onDrawKeyTopVisuals(key, canvas, paint, params);
@@ -327,14 +327,14 @@ public class KeyboardView extends View {
}
// Draw key background.
- protected void onDrawKeyBackground(final Key key, final Canvas canvas) {
+ protected void onDrawKeyBackground(final Key key, final Canvas canvas,
+ final Drawable background) {
final Rect padding = mKeyBackgroundPadding;
final int bgWidth = key.getDrawWidth() + padding.left + padding.right;
final int bgHeight = key.getHeight() + padding.top + padding.bottom;
final int bgX = -padding.left;
final int bgY = -padding.top;
final int[] drawableState = key.getCurrentDrawableState();
- final Drawable background = mKeyBackground;
background.setState(drawableState);
final Rect bounds = background.getBounds();
if (bgWidth != bounds.right || bgHeight != bounds.bottom) {
diff --git a/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java b/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java
index b67d4e7c7..8b4986f96 100644
--- a/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java
+++ b/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java
@@ -84,6 +84,7 @@ import java.util.WeakHashMap;
* @attr ref R.styleable#MainKeyboardView_languageOnSpacebarTextRatio
* @attr ref R.styleable#MainKeyboardView_languageOnSpacebarTextColor
* @attr ref R.styleable#MainKeyboardView_languageOnSpacebarTextShadowColor
+ * @attr ref R.styleable#MainKeyboardView_spacebarBackground
* @attr ref R.styleable#MainKeyboardView_languageOnSpacebarFinalAlpha
* @attr ref R.styleable#MainKeyboardView_languageOnSpacebarFadeoutAnimator
* @attr ref R.styleable#MainKeyboardView_altCodeKeyWhileTypingFadeoutAnimator
@@ -124,9 +125,10 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
/** Listener for {@link KeyboardActionListener}. */
private KeyboardActionListener mKeyboardActionListener;
- /* Space key and its icons */
+ /* Space key and its icon and background. */
private Key mSpaceKey;
- private Drawable mSpaceIcon;
+ private Drawable mSpacebarIcon;
+ private final Drawable mSpacebarBackground;
// Stuff to draw language name on spacebar.
private final int mLanguageOnSpacebarFinalAlpha;
private ObjectAnimator mLanguageOnSpacebarFadeoutAnimator;
@@ -244,6 +246,8 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
R.styleable.MainKeyboardView_backgroundDimAlpha, 0);
mBackgroundDimAlphaPaint.setColor(Color.BLACK);
mBackgroundDimAlphaPaint.setAlpha(backgroundDimAlpha);
+ mSpacebarBackground = mainKeyboardViewAttr.getDrawable(
+ R.styleable.MainKeyboardView_spacebarBackground);
mAutoCorrectionSpacebarLedEnabled = mainKeyboardViewAttr.getBoolean(
R.styleable.MainKeyboardView_autoCorrectionSpacebarLedEnabled, false);
mAutoCorrectionSpacebarLedIcon = mainKeyboardViewAttr.getDrawable(
@@ -431,7 +435,7 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
mMoreKeysKeyboardCache.clear();
mSpaceKey = keyboard.getKey(Constants.CODE_SPACE);
- mSpaceIcon = (mSpaceKey != null)
+ mSpacebarIcon = (mSpaceKey != null)
? mSpaceKey.getIcon(keyboard.mIconsSet, Constants.Color.ALPHA_OPAQUE) : null;
final int keyHeight = keyboard.mMostCommonKeyHeight - keyboard.mVerticalGap;
mLanguageOnSpacebarTextSize = keyHeight * mLanguageOnSpacebarTextRatio;
@@ -1103,6 +1107,17 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
}
}
+ // Draw key background.
+ @Override
+ protected void onDrawKeyBackground(final Key key, final Canvas canvas,
+ final Drawable background) {
+ if (key.getCode() == Constants.CODE_SPACE) {
+ super.onDrawKeyBackground(key, canvas, mSpacebarBackground);
+ return;
+ }
+ super.onDrawKeyBackground(key, canvas, background);
+ }
+
@Override
protected void onDrawKeyTopVisuals(final Key key, final Canvas canvas, final Paint paint,
final KeyDrawParams params) {
@@ -1201,12 +1216,12 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
int x = (width - iconWidth) / 2;
int y = height - iconHeight;
drawIcon(canvas, mAutoCorrectionSpacebarLedIcon, x, y, iconWidth, iconHeight);
- } else if (mSpaceIcon != null) {
- final int iconWidth = mSpaceIcon.getIntrinsicWidth();
- final int iconHeight = mSpaceIcon.getIntrinsicHeight();
+ } else if (mSpacebarIcon != null) {
+ final int iconWidth = mSpacebarIcon.getIntrinsicWidth();
+ final int iconHeight = mSpacebarIcon.getIntrinsicHeight();
int x = (width - iconWidth) / 2;
int y = height - iconHeight;
- drawIcon(canvas, mSpaceIcon, x, y, iconWidth, iconHeight);
+ drawIcon(canvas, mSpacebarIcon, x, y, iconWidth, iconHeight);
}
}