am 7081a36e: Merge "Add spacebar background drawable"
* commit '7081a36e2f67c6c98abb5fca844af22f30809f5d': Add spacebar background drawablemain
commit
f7c3b5dcfa
|
@ -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>
|
|
@ -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>
|
|
@ -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>
|
|
@ -41,9 +41,9 @@
|
||||||
</declare-styleable>
|
</declare-styleable>
|
||||||
|
|
||||||
<declare-styleable name="KeyboardView">
|
<declare-styleable name="KeyboardView">
|
||||||
<!-- Image for the key. This image needs to be a StateListDrawable, with the following
|
<!-- Image for the key. This image needs to be a {@link StateListDrawable}, with the
|
||||||
possible states: normal, pressed, checkable, checkable+pressed, checkable+checked,
|
following possible states: normal, pressed, checkable, checkable+pressed,
|
||||||
checkable+checked+pressed. -->
|
checkable+checked, checkable+checked+pressed. -->
|
||||||
<attr name="keyBackground" format="reference" />
|
<attr name="keyBackground" format="reference" />
|
||||||
<!-- Image for the functional key used in Emoji layout. -->
|
<!-- Image for the functional key used in Emoji layout. -->
|
||||||
<attr name="keyBackgroundEmojiFunctional" format="reference" />
|
<attr name="keyBackgroundEmojiFunctional" format="reference" />
|
||||||
|
@ -75,6 +75,8 @@
|
||||||
<attr name="languageOnSpacebarTextRatio" format="fraction" />
|
<attr name="languageOnSpacebarTextRatio" format="fraction" />
|
||||||
<attr name="languageOnSpacebarTextColor" format="color" />
|
<attr name="languageOnSpacebarTextColor" format="color" />
|
||||||
<attr name="languageOnSpacebarTextShadowColor" format="color" />
|
<attr name="languageOnSpacebarTextShadowColor" format="color" />
|
||||||
|
<!-- Background image for the spacebar. -->
|
||||||
|
<attr name="spacebarBackground" format="reference" />
|
||||||
<!-- Fadeout animator for spacebar language label. -->
|
<!-- Fadeout animator for spacebar language label. -->
|
||||||
<attr name="languageOnSpacebarFinalAlpha" format="integer" />
|
<attr name="languageOnSpacebarFinalAlpha" format="integer" />
|
||||||
<attr name="languageOnSpacebarFadeoutAnimator" format="reference" />
|
<attr name="languageOnSpacebarFadeoutAnimator" format="reference" />
|
||||||
|
|
|
@ -93,6 +93,7 @@
|
||||||
<item name="autoCorrectionSpacebarLedIcon">@drawable/sym_keyboard_space_led_gb</item>
|
<item name="autoCorrectionSpacebarLedIcon">@drawable/sym_keyboard_space_led_gb</item>
|
||||||
<item name="languageOnSpacebarTextColor">@color/spacebar_text_color_gb</item>
|
<item name="languageOnSpacebarTextColor">@color/spacebar_text_color_gb</item>
|
||||||
<item name="languageOnSpacebarTextShadowColor">@color/spacebar_text_shadow_color_gb</item>
|
<item name="languageOnSpacebarTextShadowColor">@color/spacebar_text_shadow_color_gb</item>
|
||||||
|
<item name="spacebarBackground">@drawable/btn_keyboard_spacebar_gb</item>
|
||||||
</style>
|
</style>
|
||||||
<style
|
<style
|
||||||
name="KeyPreviewTextView.GB"
|
name="KeyPreviewTextView.GB"
|
||||||
|
|
|
@ -72,6 +72,7 @@
|
||||||
<item name="autoCorrectionSpacebarLedIcon">@drawable/sym_keyboard_space_led_holo</item>
|
<item name="autoCorrectionSpacebarLedIcon">@drawable/sym_keyboard_space_led_holo</item>
|
||||||
<item name="languageOnSpacebarTextColor">@color/spacebar_text_color_holo</item>
|
<item name="languageOnSpacebarTextColor">@color/spacebar_text_color_holo</item>
|
||||||
<item name="languageOnSpacebarTextShadowColor">@color/spacebar_text_shadow_color_holo</item>
|
<item name="languageOnSpacebarTextShadowColor">@color/spacebar_text_shadow_color_holo</item>
|
||||||
|
<item name="spacebarBackground">@drawable/btn_keyboard_spacebar_ics</item>
|
||||||
</style>
|
</style>
|
||||||
<style
|
<style
|
||||||
name="KeyPreviewTextView.ICS"
|
name="KeyPreviewTextView.ICS"
|
||||||
|
|
|
@ -72,6 +72,7 @@
|
||||||
<item name="autoCorrectionSpacebarLedIcon">@drawable/sym_keyboard_space_led_holo</item>
|
<item name="autoCorrectionSpacebarLedIcon">@drawable/sym_keyboard_space_led_holo</item>
|
||||||
<item name="languageOnSpacebarTextColor">@color/spacebar_text_color_holo</item>
|
<item name="languageOnSpacebarTextColor">@color/spacebar_text_color_holo</item>
|
||||||
<item name="languageOnSpacebarTextShadowColor">@color/spacebar_text_shadow_color_holo</item>
|
<item name="languageOnSpacebarTextShadowColor">@color/spacebar_text_shadow_color_holo</item>
|
||||||
|
<item name="spacebarBackground">@drawable/btn_keyboard_spacebar_klp</item>
|
||||||
</style>
|
</style>
|
||||||
<style
|
<style
|
||||||
name="KeyPreviewTextView.KLP"
|
name="KeyPreviewTextView.KLP"
|
||||||
|
|
|
@ -319,7 +319,7 @@ public class KeyboardView extends View {
|
||||||
params.mAnimAlpha = Constants.Color.ALPHA_OPAQUE;
|
params.mAnimAlpha = Constants.Color.ALPHA_OPAQUE;
|
||||||
|
|
||||||
if (!key.isSpacer()) {
|
if (!key.isSpacer()) {
|
||||||
onDrawKeyBackground(key, canvas);
|
onDrawKeyBackground(key, canvas, mKeyBackground);
|
||||||
}
|
}
|
||||||
onDrawKeyTopVisuals(key, canvas, paint, params);
|
onDrawKeyTopVisuals(key, canvas, paint, params);
|
||||||
|
|
||||||
|
@ -327,14 +327,14 @@ public class KeyboardView extends View {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw key background.
|
// 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 Rect padding = mKeyBackgroundPadding;
|
||||||
final int bgWidth = key.getDrawWidth() + padding.left + padding.right;
|
final int bgWidth = key.getDrawWidth() + padding.left + padding.right;
|
||||||
final int bgHeight = key.getHeight() + padding.top + padding.bottom;
|
final int bgHeight = key.getHeight() + padding.top + padding.bottom;
|
||||||
final int bgX = -padding.left;
|
final int bgX = -padding.left;
|
||||||
final int bgY = -padding.top;
|
final int bgY = -padding.top;
|
||||||
final int[] drawableState = key.getCurrentDrawableState();
|
final int[] drawableState = key.getCurrentDrawableState();
|
||||||
final Drawable background = mKeyBackground;
|
|
||||||
background.setState(drawableState);
|
background.setState(drawableState);
|
||||||
final Rect bounds = background.getBounds();
|
final Rect bounds = background.getBounds();
|
||||||
if (bgWidth != bounds.right || bgHeight != bounds.bottom) {
|
if (bgWidth != bounds.right || bgHeight != bounds.bottom) {
|
||||||
|
|
|
@ -84,6 +84,7 @@ import java.util.WeakHashMap;
|
||||||
* @attr ref R.styleable#MainKeyboardView_languageOnSpacebarTextRatio
|
* @attr ref R.styleable#MainKeyboardView_languageOnSpacebarTextRatio
|
||||||
* @attr ref R.styleable#MainKeyboardView_languageOnSpacebarTextColor
|
* @attr ref R.styleable#MainKeyboardView_languageOnSpacebarTextColor
|
||||||
* @attr ref R.styleable#MainKeyboardView_languageOnSpacebarTextShadowColor
|
* @attr ref R.styleable#MainKeyboardView_languageOnSpacebarTextShadowColor
|
||||||
|
* @attr ref R.styleable#MainKeyboardView_spacebarBackground
|
||||||
* @attr ref R.styleable#MainKeyboardView_languageOnSpacebarFinalAlpha
|
* @attr ref R.styleable#MainKeyboardView_languageOnSpacebarFinalAlpha
|
||||||
* @attr ref R.styleable#MainKeyboardView_languageOnSpacebarFadeoutAnimator
|
* @attr ref R.styleable#MainKeyboardView_languageOnSpacebarFadeoutAnimator
|
||||||
* @attr ref R.styleable#MainKeyboardView_altCodeKeyWhileTypingFadeoutAnimator
|
* @attr ref R.styleable#MainKeyboardView_altCodeKeyWhileTypingFadeoutAnimator
|
||||||
|
@ -124,9 +125,10 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
|
||||||
/** Listener for {@link KeyboardActionListener}. */
|
/** Listener for {@link KeyboardActionListener}. */
|
||||||
private KeyboardActionListener mKeyboardActionListener;
|
private KeyboardActionListener mKeyboardActionListener;
|
||||||
|
|
||||||
/* Space key and its icons */
|
/* Space key and its icon and background. */
|
||||||
private Key mSpaceKey;
|
private Key mSpaceKey;
|
||||||
private Drawable mSpaceIcon;
|
private Drawable mSpacebarIcon;
|
||||||
|
private final Drawable mSpacebarBackground;
|
||||||
// Stuff to draw language name on spacebar.
|
// Stuff to draw language name on spacebar.
|
||||||
private final int mLanguageOnSpacebarFinalAlpha;
|
private final int mLanguageOnSpacebarFinalAlpha;
|
||||||
private ObjectAnimator mLanguageOnSpacebarFadeoutAnimator;
|
private ObjectAnimator mLanguageOnSpacebarFadeoutAnimator;
|
||||||
|
@ -244,6 +246,8 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
|
||||||
R.styleable.MainKeyboardView_backgroundDimAlpha, 0);
|
R.styleable.MainKeyboardView_backgroundDimAlpha, 0);
|
||||||
mBackgroundDimAlphaPaint.setColor(Color.BLACK);
|
mBackgroundDimAlphaPaint.setColor(Color.BLACK);
|
||||||
mBackgroundDimAlphaPaint.setAlpha(backgroundDimAlpha);
|
mBackgroundDimAlphaPaint.setAlpha(backgroundDimAlpha);
|
||||||
|
mSpacebarBackground = mainKeyboardViewAttr.getDrawable(
|
||||||
|
R.styleable.MainKeyboardView_spacebarBackground);
|
||||||
mAutoCorrectionSpacebarLedEnabled = mainKeyboardViewAttr.getBoolean(
|
mAutoCorrectionSpacebarLedEnabled = mainKeyboardViewAttr.getBoolean(
|
||||||
R.styleable.MainKeyboardView_autoCorrectionSpacebarLedEnabled, false);
|
R.styleable.MainKeyboardView_autoCorrectionSpacebarLedEnabled, false);
|
||||||
mAutoCorrectionSpacebarLedIcon = mainKeyboardViewAttr.getDrawable(
|
mAutoCorrectionSpacebarLedIcon = mainKeyboardViewAttr.getDrawable(
|
||||||
|
@ -431,7 +435,7 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
|
||||||
mMoreKeysKeyboardCache.clear();
|
mMoreKeysKeyboardCache.clear();
|
||||||
|
|
||||||
mSpaceKey = keyboard.getKey(Constants.CODE_SPACE);
|
mSpaceKey = keyboard.getKey(Constants.CODE_SPACE);
|
||||||
mSpaceIcon = (mSpaceKey != null)
|
mSpacebarIcon = (mSpaceKey != null)
|
||||||
? mSpaceKey.getIcon(keyboard.mIconsSet, Constants.Color.ALPHA_OPAQUE) : null;
|
? mSpaceKey.getIcon(keyboard.mIconsSet, Constants.Color.ALPHA_OPAQUE) : null;
|
||||||
final int keyHeight = keyboard.mMostCommonKeyHeight - keyboard.mVerticalGap;
|
final int keyHeight = keyboard.mMostCommonKeyHeight - keyboard.mVerticalGap;
|
||||||
mLanguageOnSpacebarTextSize = keyHeight * mLanguageOnSpacebarTextRatio;
|
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
|
@Override
|
||||||
protected void onDrawKeyTopVisuals(final Key key, final Canvas canvas, final Paint paint,
|
protected void onDrawKeyTopVisuals(final Key key, final Canvas canvas, final Paint paint,
|
||||||
final KeyDrawParams params) {
|
final KeyDrawParams params) {
|
||||||
|
@ -1201,12 +1216,12 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
|
||||||
int x = (width - iconWidth) / 2;
|
int x = (width - iconWidth) / 2;
|
||||||
int y = height - iconHeight;
|
int y = height - iconHeight;
|
||||||
drawIcon(canvas, mAutoCorrectionSpacebarLedIcon, x, y, iconWidth, iconHeight);
|
drawIcon(canvas, mAutoCorrectionSpacebarLedIcon, x, y, iconWidth, iconHeight);
|
||||||
} else if (mSpaceIcon != null) {
|
} else if (mSpacebarIcon != null) {
|
||||||
final int iconWidth = mSpaceIcon.getIntrinsicWidth();
|
final int iconWidth = mSpacebarIcon.getIntrinsicWidth();
|
||||||
final int iconHeight = mSpaceIcon.getIntrinsicHeight();
|
final int iconHeight = mSpacebarIcon.getIntrinsicHeight();
|
||||||
int x = (width - iconWidth) / 2;
|
int x = (width - iconWidth) / 2;
|
||||||
int y = height - iconHeight;
|
int y = height - iconHeight;
|
||||||
drawIcon(canvas, mSpaceIcon, x, y, iconWidth, iconHeight);
|
drawIcon(canvas, mSpacebarIcon, x, y, iconWidth, iconHeight);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue