Gray out "alt-code-while-typing" key icon while typing
Bug: 6128215 Change-Id: Ie9c13d9d38aad6e92cc465e22f3ef20c80e0a36amain
parent
02e70cf999
commit
73a46bfeb7
|
@ -0,0 +1,26 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--
|
||||||
|
/*
|
||||||
|
**
|
||||||
|
** Copyright 2012, 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.
|
||||||
|
*/
|
||||||
|
-->
|
||||||
|
|
||||||
|
<animator
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:valueType="intType"
|
||||||
|
android:duration="100"
|
||||||
|
android:valueFrom="128"
|
||||||
|
android:valueTo="255" />
|
|
@ -0,0 +1,26 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--
|
||||||
|
/*
|
||||||
|
**
|
||||||
|
** Copyright 2012, 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.
|
||||||
|
*/
|
||||||
|
-->
|
||||||
|
|
||||||
|
<animator
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:valueType="intType"
|
||||||
|
android:duration="400"
|
||||||
|
android:valueFrom="255"
|
||||||
|
android:valueTo="128" />
|
|
@ -134,6 +134,9 @@
|
||||||
<attr name="spacebarTextShadowColor" format="color" />
|
<attr name="spacebarTextShadowColor" format="color" />
|
||||||
<!-- Fadeout animator for spacebar language label. -->
|
<!-- Fadeout animator for spacebar language label. -->
|
||||||
<attr name="languageOnSpacebarFadeoutAnimator" format="reference" />
|
<attr name="languageOnSpacebarFadeoutAnimator" format="reference" />
|
||||||
|
<!-- Fadeout and fadein animator for altCodeWhileTyping keys. -->
|
||||||
|
<attr name="altCodeKeyWhileTypingFadeoutAnimator" format="reference" />
|
||||||
|
<attr name="altCodeKeyWhileTypingFadeinAnimator" format="reference" />
|
||||||
<!-- Key detection hysteresis distance. -->
|
<!-- Key detection hysteresis distance. -->
|
||||||
<attr name="keyHysteresisDistance" format="dimension" />
|
<attr name="keyHysteresisDistance" format="dimension" />
|
||||||
<!-- Touch noise threshold time in millisecond -->
|
<!-- Touch noise threshold time in millisecond -->
|
||||||
|
@ -153,7 +156,7 @@
|
||||||
<!-- Long press timeout of space key in millisecond. -->
|
<!-- Long press timeout of space key in millisecond. -->
|
||||||
<attr name="longPressSpaceKeyTimeout" format="integer" />
|
<attr name="longPressSpaceKeyTimeout" format="integer" />
|
||||||
<!-- Ignore special key timeout while typing in millisecond. -->
|
<!-- Ignore special key timeout while typing in millisecond. -->
|
||||||
<attr name="ignoreSpecialKeyTimeout" format="integer" />
|
<attr name="ignoreAltCodeKeyTimeout" format="integer" />
|
||||||
<!-- More keys keyboard will shown at touched point. -->
|
<!-- More keys keyboard will shown at touched point. -->
|
||||||
<attr name="showMoreKeysKeyboardAtTouchedPoint" format="boolean" />
|
<attr name="showMoreKeysKeyboardAtTouchedPoint" format="boolean" />
|
||||||
</declare-styleable>
|
</declare-styleable>
|
||||||
|
|
|
@ -65,7 +65,7 @@
|
||||||
<!-- Long pressing space will invoke IME switcher if > 0, never invoke IME switcher if == 0 -->
|
<!-- Long pressing space will invoke IME switcher if > 0, never invoke IME switcher if == 0 -->
|
||||||
<integer name="config_long_press_space_key_timeout">
|
<integer name="config_long_press_space_key_timeout">
|
||||||
@integer/config_long_press_key_timeout</integer>
|
@integer/config_long_press_key_timeout</integer>
|
||||||
<integer name="config_ignore_special_key_timeout">700</integer>
|
<integer name="config_ignore_alt_code_key_timeout">700</integer>
|
||||||
<!-- Showing more keys keyboard, just above the touched point if true, aligned to the key if
|
<!-- Showing more keys keyboard, just above the touched point if true, aligned to the key if
|
||||||
false -->
|
false -->
|
||||||
<bool name="config_show_more_keys_keyboard_at_touched_point">false</bool>
|
<bool name="config_show_more_keys_keyboard_at_touched_point">false</bool>
|
||||||
|
|
|
@ -76,9 +76,11 @@
|
||||||
<item name="longPressKeyTimeout">@integer/config_long_press_key_timeout</item>
|
<item name="longPressKeyTimeout">@integer/config_long_press_key_timeout</item>
|
||||||
<item name="longPressShiftKeyTimeout">@integer/config_long_press_shift_key_timeout</item>
|
<item name="longPressShiftKeyTimeout">@integer/config_long_press_shift_key_timeout</item>
|
||||||
<item name="longPressSpaceKeyTimeout">@integer/config_long_press_space_key_timeout</item>
|
<item name="longPressSpaceKeyTimeout">@integer/config_long_press_space_key_timeout</item>
|
||||||
<item name="ignoreSpecialKeyTimeout">@integer/config_ignore_special_key_timeout</item>
|
<item name="ignoreAltCodeKeyTimeout">@integer/config_ignore_alt_code_key_timeout</item>
|
||||||
<item name="showMoreKeysKeyboardAtTouchedPoint">@bool/config_show_more_keys_keyboard_at_touched_point</item>
|
<item name="showMoreKeysKeyboardAtTouchedPoint">@bool/config_show_more_keys_keyboard_at_touched_point</item>
|
||||||
<item name="languageOnSpacebarFadeoutAnimator">@anim/language_on_spacebar_fadeout</item>
|
<item name="languageOnSpacebarFadeoutAnimator">@anim/language_on_spacebar_fadeout</item>
|
||||||
|
<item name="altCodeKeyWhileTypingFadeoutAnimator">@anim/alt_code_key_while_typing_fadeout</item>
|
||||||
|
<item name="altCodeKeyWhileTypingFadeinAnimator">@anim/alt_code_key_while_typing_fadein</item>
|
||||||
</style>
|
</style>
|
||||||
<style
|
<style
|
||||||
name="LatinKeyboardView"
|
name="LatinKeyboardView"
|
||||||
|
|
|
@ -95,6 +95,8 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy {
|
||||||
// The maximum key label width in the proportion to the key width.
|
// The maximum key label width in the proportion to the key width.
|
||||||
private static final float MAX_LABEL_RATIO = 0.90f;
|
private static final float MAX_LABEL_RATIO = 0.90f;
|
||||||
|
|
||||||
|
private final static int ALPHA_OPAQUE = 255;
|
||||||
|
|
||||||
// Main keyboard
|
// Main keyboard
|
||||||
private Keyboard mKeyboard;
|
private Keyboard mKeyboard;
|
||||||
private final KeyDrawParams mKeyDrawParams;
|
private final KeyDrawParams mKeyDrawParams;
|
||||||
|
@ -201,6 +203,7 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy {
|
||||||
public int mKeyHintLetterSize;
|
public int mKeyHintLetterSize;
|
||||||
public int mKeyShiftedLetterHintSize;
|
public int mKeyShiftedLetterHintSize;
|
||||||
public int mKeyHintLabelSize;
|
public int mKeyHintLabelSize;
|
||||||
|
public int mAnimAlpha;
|
||||||
|
|
||||||
public KeyDrawParams(TypedArray a) {
|
public KeyDrawParams(TypedArray a) {
|
||||||
mKeyBackground = a.getDrawable(R.styleable.KeyboardView_keyBackground);
|
mKeyBackground = a.getDrawable(R.styleable.KeyboardView_keyBackground);
|
||||||
|
@ -256,6 +259,12 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy {
|
||||||
mKeyShiftedLetterHintSize = (int)(keyHeight * mKeyShiftedLetterHintRatio);
|
mKeyShiftedLetterHintSize = (int)(keyHeight * mKeyShiftedLetterHintRatio);
|
||||||
mKeyHintLabelSize = (int)(keyHeight * mKeyHintLabelRatio);
|
mKeyHintLabelSize = (int)(keyHeight * mKeyHintLabelRatio);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void brendAlpha(Paint paint) {
|
||||||
|
final int color = paint.getColor();
|
||||||
|
paint.setARGB((paint.getAlpha() * mAnimAlpha) / ALPHA_OPAQUE,
|
||||||
|
Color.red(color), Color.green(color), Color.blue(color));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* package */ static class KeyPreviewDrawParams {
|
/* package */ static class KeyPreviewDrawParams {
|
||||||
|
@ -343,7 +352,6 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy {
|
||||||
|
|
||||||
mPaint.setAntiAlias(true);
|
mPaint.setAntiAlias(true);
|
||||||
mPaint.setTextAlign(Align.CENTER);
|
mPaint.setTextAlign(Align.CENTER);
|
||||||
mPaint.setAlpha(255);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read fraction value in TypedArray as float.
|
// Read fraction value in TypedArray as float.
|
||||||
|
@ -492,6 +500,7 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy {
|
||||||
final int keyDrawY = key.mY + getPaddingTop();
|
final int keyDrawY = key.mY + getPaddingTop();
|
||||||
canvas.translate(keyDrawX, keyDrawY);
|
canvas.translate(keyDrawX, keyDrawY);
|
||||||
|
|
||||||
|
params.mAnimAlpha = ALPHA_OPAQUE;
|
||||||
if (!key.isSpacer()) {
|
if (!key.isSpacer()) {
|
||||||
onDrawKeyBackground(key, canvas, params);
|
onDrawKeyBackground(key, canvas, params);
|
||||||
}
|
}
|
||||||
|
@ -535,6 +544,9 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy {
|
||||||
|
|
||||||
// Draw key label.
|
// Draw key label.
|
||||||
final Drawable icon = key.getIcon(mKeyboard.mIconsSet);
|
final Drawable icon = key.getIcon(mKeyboard.mIconsSet);
|
||||||
|
if (icon != null) {
|
||||||
|
icon.setAlpha(params.mAnimAlpha);
|
||||||
|
}
|
||||||
float positionX = centerX;
|
float positionX = centerX;
|
||||||
if (key.mLabel != null) {
|
if (key.mLabel != null) {
|
||||||
final String label = key.mLabel;
|
final String label = key.mLabel;
|
||||||
|
@ -589,6 +601,7 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy {
|
||||||
// Make label invisible
|
// Make label invisible
|
||||||
paint.setColor(Color.TRANSPARENT);
|
paint.setColor(Color.TRANSPARENT);
|
||||||
}
|
}
|
||||||
|
params.brendAlpha(paint);
|
||||||
canvas.drawText(label, 0, label.length(), positionX, baseline, paint);
|
canvas.drawText(label, 0, label.length(), positionX, baseline, paint);
|
||||||
// Turn off drop shadow and reset x-scale.
|
// Turn off drop shadow and reset x-scale.
|
||||||
paint.setShadowLayer(0, 0, 0, 0);
|
paint.setShadowLayer(0, 0, 0, 0);
|
||||||
|
@ -633,6 +646,7 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy {
|
||||||
hintSize = params.mKeyHintLetterSize;
|
hintSize = params.mKeyHintLetterSize;
|
||||||
}
|
}
|
||||||
paint.setColor(hintColor);
|
paint.setColor(hintColor);
|
||||||
|
params.brendAlpha(paint);
|
||||||
paint.setTextSize(hintSize);
|
paint.setTextSize(hintSize);
|
||||||
final float hintX, hintY;
|
final float hintX, hintY;
|
||||||
if (key.hasHintLabel()) {
|
if (key.hasHintLabel()) {
|
||||||
|
@ -701,6 +715,7 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy {
|
||||||
|
|
||||||
paint.setTextSize(params.mKeyHintLetterSize);
|
paint.setTextSize(params.mKeyHintLetterSize);
|
||||||
paint.setColor(params.mKeyHintLabelColor);
|
paint.setColor(params.mKeyHintLabelColor);
|
||||||
|
params.brendAlpha(paint);
|
||||||
paint.setTextAlign(Align.CENTER);
|
paint.setTextAlign(Align.CENTER);
|
||||||
final float hintX = keyWidth - params.mKeyHintLetterPadding
|
final float hintX = keyWidth - params.mKeyHintLetterPadding
|
||||||
- getCharWidth(KEY_LABEL_REFERENCE_CHAR, paint) / 2;
|
- getCharWidth(KEY_LABEL_REFERENCE_CHAR, paint) / 2;
|
||||||
|
|
|
@ -98,6 +98,11 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke
|
||||||
private final Drawable mAutoCorrectionSpacebarLedIcon;
|
private final Drawable mAutoCorrectionSpacebarLedIcon;
|
||||||
private static final int SPACE_LED_LENGTH_PERCENT = 80;
|
private static final int SPACE_LED_LENGTH_PERCENT = 80;
|
||||||
|
|
||||||
|
// Stuff to draw altCodeWhileTyping keys.
|
||||||
|
private ValueAnimator mAltCodeKeyWhileTypingFadeoutAnimator;
|
||||||
|
private ValueAnimator mAltCodeKeyWhileTypingFadeinAnimator;
|
||||||
|
private int mAltCodeKeyWhileTypingAnimAlpha;
|
||||||
|
|
||||||
// More keys keyboard
|
// More keys keyboard
|
||||||
private PopupWindow mMoreKeysWindow;
|
private PopupWindow mMoreKeysWindow;
|
||||||
private MoreKeysPanel mMoreKeysPanel;
|
private MoreKeysPanel mMoreKeysPanel;
|
||||||
|
@ -122,7 +127,7 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke
|
||||||
private static final int MSG_REPEAT_KEY = 1;
|
private static final int MSG_REPEAT_KEY = 1;
|
||||||
private static final int MSG_LONGPRESS_KEY = 2;
|
private static final int MSG_LONGPRESS_KEY = 2;
|
||||||
private static final int MSG_DOUBLE_TAP = 3;
|
private static final int MSG_DOUBLE_TAP = 3;
|
||||||
private static final int MSG_KEY_TYPED = 4;
|
private static final int MSG_TYPING_STATE_EXPIRED = 4;
|
||||||
|
|
||||||
private final KeyTimerParams mParams;
|
private final KeyTimerParams mParams;
|
||||||
private boolean mInKeyRepeat;
|
private boolean mInKeyRepeat;
|
||||||
|
@ -148,6 +153,18 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke
|
||||||
KeyboardSwitcher.getInstance().onLongPressTimeout(msg.arg1);
|
KeyboardSwitcher.getInstance().onLongPressTimeout(msg.arg1);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case MSG_TYPING_STATE_EXPIRED:
|
||||||
|
final ValueAnimator fadeout = keyboardView.mAltCodeKeyWhileTypingFadeoutAnimator;
|
||||||
|
if (fadeout != null && fadeout.isStarted()) {
|
||||||
|
fadeout.cancel();
|
||||||
|
}
|
||||||
|
// TODO: Start the fade in animation with an initial value that is the same as the
|
||||||
|
// final value when the above fade out animation gets cancelled.
|
||||||
|
final ValueAnimator fadein = keyboardView.mAltCodeKeyWhileTypingFadeinAnimator;
|
||||||
|
if (fadein != null && !fadein.isStarted()) {
|
||||||
|
fadein.start();
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -222,14 +239,30 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void startKeyTypedTimer() {
|
public void startTypingStateTimer() {
|
||||||
removeMessages(MSG_KEY_TYPED);
|
final boolean isTyping = isTypingState();
|
||||||
sendMessageDelayed(obtainMessage(MSG_KEY_TYPED), mParams.mIgnoreSpecialKeyTimeout);
|
removeMessages(MSG_TYPING_STATE_EXPIRED);
|
||||||
|
sendMessageDelayed(
|
||||||
|
obtainMessage(MSG_TYPING_STATE_EXPIRED), mParams.mIgnoreAltCodeKeyTimeout);
|
||||||
|
final LatinKeyboardView keyboardView = getOuterInstance();
|
||||||
|
if (isTyping) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
final ValueAnimator fadein = keyboardView.mAltCodeKeyWhileTypingFadeinAnimator;
|
||||||
|
if (fadein != null && fadein.isStarted()) {
|
||||||
|
fadein.cancel();
|
||||||
|
}
|
||||||
|
// TODO: Start the fade out animation with an initial value that is the same as the
|
||||||
|
// final value when the above fade in animation gets cancelled.
|
||||||
|
final ValueAnimator fadeout = keyboardView.mAltCodeKeyWhileTypingFadeoutAnimator;
|
||||||
|
if (fadeout != null && !fadeout.isStarted()) {
|
||||||
|
fadeout.start();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isTyping() {
|
public boolean isTypingState() {
|
||||||
return hasMessages(MSG_KEY_TYPED);
|
return hasMessages(MSG_TYPING_STATE_EXPIRED);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -288,7 +321,7 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke
|
||||||
public final int mLongPressKeyTimeout;
|
public final int mLongPressKeyTimeout;
|
||||||
public final int mLongPressShiftKeyTimeout;
|
public final int mLongPressShiftKeyTimeout;
|
||||||
public final int mLongPressSpaceKeyTimeout;
|
public final int mLongPressSpaceKeyTimeout;
|
||||||
public final int mIgnoreSpecialKeyTimeout;
|
public final int mIgnoreAltCodeKeyTimeout;
|
||||||
|
|
||||||
KeyTimerParams() {
|
KeyTimerParams() {
|
||||||
mKeyRepeatStartTimeout = 0;
|
mKeyRepeatStartTimeout = 0;
|
||||||
|
@ -296,7 +329,7 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke
|
||||||
mLongPressKeyTimeout = 0;
|
mLongPressKeyTimeout = 0;
|
||||||
mLongPressShiftKeyTimeout = 0;
|
mLongPressShiftKeyTimeout = 0;
|
||||||
mLongPressSpaceKeyTimeout = 0;
|
mLongPressSpaceKeyTimeout = 0;
|
||||||
mIgnoreSpecialKeyTimeout = 0;
|
mIgnoreAltCodeKeyTimeout = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public KeyTimerParams(TypedArray latinKeyboardViewAttr) {
|
public KeyTimerParams(TypedArray latinKeyboardViewAttr) {
|
||||||
|
@ -310,8 +343,8 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke
|
||||||
R.styleable.LatinKeyboardView_longPressShiftKeyTimeout, 0);
|
R.styleable.LatinKeyboardView_longPressShiftKeyTimeout, 0);
|
||||||
mLongPressSpaceKeyTimeout = latinKeyboardViewAttr.getInt(
|
mLongPressSpaceKeyTimeout = latinKeyboardViewAttr.getInt(
|
||||||
R.styleable.LatinKeyboardView_longPressSpaceKeyTimeout, 0);
|
R.styleable.LatinKeyboardView_longPressSpaceKeyTimeout, 0);
|
||||||
mIgnoreSpecialKeyTimeout = latinKeyboardViewAttr.getInt(
|
mIgnoreAltCodeKeyTimeout = latinKeyboardViewAttr.getInt(
|
||||||
R.styleable.LatinKeyboardView_ignoreSpecialKeyTimeout, 0);
|
R.styleable.LatinKeyboardView_ignoreAltCodeKeyTimeout, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -342,6 +375,10 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke
|
||||||
R.styleable.LatinKeyboardView_spacebarTextShadowColor, 0);
|
R.styleable.LatinKeyboardView_spacebarTextShadowColor, 0);
|
||||||
final int languageOnSpacebarFadeoutAnimatorResId = a.getResourceId(
|
final int languageOnSpacebarFadeoutAnimatorResId = a.getResourceId(
|
||||||
R.styleable.LatinKeyboardView_languageOnSpacebarFadeoutAnimator, 0);
|
R.styleable.LatinKeyboardView_languageOnSpacebarFadeoutAnimator, 0);
|
||||||
|
final int altCodeKeyWhileTypingFadeoutAnimatorResId = a.getResourceId(
|
||||||
|
R.styleable.LatinKeyboardView_altCodeKeyWhileTypingFadeoutAnimator, 0);
|
||||||
|
final int altCodeKeyWhileTypingFadeinAnimatorResId = a.getResourceId(
|
||||||
|
R.styleable.LatinKeyboardView_altCodeKeyWhileTypingFadeinAnimator, 0);
|
||||||
|
|
||||||
final KeyTimerParams keyTimerParams = new KeyTimerParams(a);
|
final KeyTimerParams keyTimerParams = new KeyTimerParams(a);
|
||||||
mPointerTrackerParams = new PointerTrackerParams(a);
|
mPointerTrackerParams = new PointerTrackerParams(a);
|
||||||
|
@ -357,7 +394,7 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke
|
||||||
|
|
||||||
PointerTracker.setParameters(mPointerTrackerParams);
|
PointerTracker.setParameters(mPointerTrackerParams);
|
||||||
|
|
||||||
ValueAnimator animator = loadValueAnimator(context, languageOnSpacebarFadeoutAnimatorResId);
|
final ValueAnimator animator = loadValueAnimator(languageOnSpacebarFadeoutAnimatorResId);
|
||||||
if (animator != null) {
|
if (animator != null) {
|
||||||
animator.addUpdateListener(new AnimatorUpdateListener() {
|
animator.addUpdateListener(new AnimatorUpdateListener() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -377,11 +414,47 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke
|
||||||
animator.end();
|
animator.end();
|
||||||
}
|
}
|
||||||
mLanguageOnSpacebarFadeoutAnimator = animator;
|
mLanguageOnSpacebarFadeoutAnimator = animator;
|
||||||
|
|
||||||
|
final ValueAnimator fadeout = loadValueAnimator(altCodeKeyWhileTypingFadeoutAnimatorResId);
|
||||||
|
if (fadeout != null) {
|
||||||
|
fadeout.addUpdateListener(new AnimatorUpdateListener() {
|
||||||
|
@Override
|
||||||
|
public void onAnimationUpdate(ValueAnimator animation) {
|
||||||
|
mAltCodeKeyWhileTypingAnimAlpha = (Integer)animation.getAnimatedValue();
|
||||||
|
updateAltCodeKeyWhileTyping();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
fadeout.addListener(new AnimatorListenerAdapter() {
|
||||||
|
@Override
|
||||||
|
public void onAnimationEnd(Animator a) {
|
||||||
|
final ValueAnimator valueAnimator = (ValueAnimator)a;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
mAltCodeKeyWhileTypingFadeoutAnimator = fadeout;
|
||||||
|
|
||||||
|
final ValueAnimator fadein = loadValueAnimator(altCodeKeyWhileTypingFadeinAnimatorResId);
|
||||||
|
if (fadein != null) {
|
||||||
|
fadein.addUpdateListener(new AnimatorUpdateListener() {
|
||||||
|
@Override
|
||||||
|
public void onAnimationUpdate(ValueAnimator animation) {
|
||||||
|
mAltCodeKeyWhileTypingAnimAlpha = (Integer)animation.getAnimatedValue();
|
||||||
|
updateAltCodeKeyWhileTyping();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
fadein.addListener(new AnimatorListenerAdapter() {
|
||||||
|
@Override
|
||||||
|
public void onAnimationEnd(Animator a) {
|
||||||
|
final ValueAnimator valueAnimator = (ValueAnimator)a;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
mAltCodeKeyWhileTypingFadeinAnimator = fadein;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ValueAnimator loadValueAnimator(Context context, int resId) {
|
private ValueAnimator loadValueAnimator(int resId) {
|
||||||
if (resId == 0) return null;
|
if (resId == 0) return null;
|
||||||
return (ValueAnimator)AnimatorInflater.loadAnimator(context, resId);
|
return (ValueAnimator)AnimatorInflater.loadAnimator(getContext(), resId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setKeyboardActionListener(KeyboardActionListener listener) {
|
public void setKeyboardActionListener(KeyboardActionListener listener) {
|
||||||
|
@ -437,6 +510,8 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke
|
||||||
final int keyHeight = keyboard.mMostCommonKeyHeight - keyboard.mVerticalGap;
|
final int keyHeight = keyboard.mMostCommonKeyHeight - keyboard.mVerticalGap;
|
||||||
mSpacebarTextSize = keyHeight * mSpacebarTextRatio;
|
mSpacebarTextSize = keyHeight * mSpacebarTextRatio;
|
||||||
mSpacebarLocale = keyboard.mId.mLocale;
|
mSpacebarLocale = keyboard.mId.mLocale;
|
||||||
|
mSpacebarTextAlpha = ALPHA_OPAQUE;
|
||||||
|
mAltCodeKeyWhileTypingAnimAlpha = ALPHA_OPAQUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -797,6 +872,14 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke
|
||||||
invalidateKey(shortcutKey);
|
invalidateKey(shortcutKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void updateAltCodeKeyWhileTyping() {
|
||||||
|
final Keyboard keyboard = getKeyboard();
|
||||||
|
if (keyboard == null) return;
|
||||||
|
for (final Key key : keyboard.mAltCodeKeysWhileTyping) {
|
||||||
|
invalidateKey(key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void startDisplayLanguageOnSpacebar(boolean subtypeChanged,
|
public void startDisplayLanguageOnSpacebar(boolean subtypeChanged,
|
||||||
boolean needsToDisplayLanguage) {
|
boolean needsToDisplayLanguage) {
|
||||||
final ValueAnimator animator = mLanguageOnSpacebarFadeoutAnimator;
|
final ValueAnimator animator = mLanguageOnSpacebarFadeoutAnimator;
|
||||||
|
@ -825,6 +908,9 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onDrawKeyTopVisuals(Key key, Canvas canvas, Paint paint, KeyDrawParams params) {
|
protected void onDrawKeyTopVisuals(Key key, Canvas canvas, Paint paint, KeyDrawParams params) {
|
||||||
|
if (key.altCodeWhileTyping()) {
|
||||||
|
params.mAnimAlpha = mAltCodeKeyWhileTypingAnimAlpha;
|
||||||
|
}
|
||||||
if (key.mCode == Keyboard.CODE_SPACE) {
|
if (key.mCode == Keyboard.CODE_SPACE) {
|
||||||
drawSpacebar(key, canvas, paint);
|
drawSpacebar(key, canvas, paint);
|
||||||
|
|
||||||
|
|
|
@ -68,8 +68,8 @@ public class PointerTracker {
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface TimerProxy {
|
public interface TimerProxy {
|
||||||
public void startKeyTypedTimer();
|
public void startTypingStateTimer();
|
||||||
public boolean isTyping();
|
public boolean isTypingState();
|
||||||
public void startKeyRepeatTimer(PointerTracker tracker);
|
public void startKeyRepeatTimer(PointerTracker tracker);
|
||||||
public void startLongPressTimer(PointerTracker tracker);
|
public void startLongPressTimer(PointerTracker tracker);
|
||||||
public void startLongPressTimer(int code);
|
public void startLongPressTimer(int code);
|
||||||
|
@ -81,9 +81,9 @@ public class PointerTracker {
|
||||||
|
|
||||||
public static class Adapter implements TimerProxy {
|
public static class Adapter implements TimerProxy {
|
||||||
@Override
|
@Override
|
||||||
public void startKeyTypedTimer() {}
|
public void startTypingStateTimer() {}
|
||||||
@Override
|
@Override
|
||||||
public boolean isTyping() { return false; }
|
public boolean isTypingState() { return false; }
|
||||||
@Override
|
@Override
|
||||||
public void startKeyRepeatTimer(PointerTracker tracker) {}
|
public void startKeyRepeatTimer(PointerTracker tracker) {}
|
||||||
@Override
|
@Override
|
||||||
|
@ -251,7 +251,7 @@ public class PointerTracker {
|
||||||
// primaryCode is different from {@link Key#mCode}.
|
// primaryCode is different from {@link Key#mCode}.
|
||||||
private void callListenerOnCodeInput(Key key, int primaryCode, int x, int y) {
|
private void callListenerOnCodeInput(Key key, int primaryCode, int x, int y) {
|
||||||
final boolean ignoreModifierKey = mIgnoreModifierKey && key.isModifier();
|
final boolean ignoreModifierKey = mIgnoreModifierKey && key.isModifier();
|
||||||
final boolean alterCode = key.altCodeWhileTyping() && mTimerProxy.isTyping();
|
final boolean alterCode = key.altCodeWhileTyping() && mTimerProxy.isTypingState();
|
||||||
final int code = alterCode ? key.mAltCode : primaryCode;
|
final int code = alterCode ? key.mAltCode : primaryCode;
|
||||||
if (DEBUG_LISTENER) {
|
if (DEBUG_LISTENER) {
|
||||||
Log.d(TAG, "onCodeInput: " + Keyboard.printableCode(code) + " text=" + key.mOutputText
|
Log.d(TAG, "onCodeInput: " + Keyboard.printableCode(code) + " text=" + key.mOutputText
|
||||||
|
@ -269,7 +269,7 @@ public class PointerTracker {
|
||||||
mListener.onCodeInput(code, x, y);
|
mListener.onCodeInput(code, x, y);
|
||||||
}
|
}
|
||||||
if (!key.altCodeWhileTyping() && !key.isModifier()) {
|
if (!key.altCodeWhileTyping() && !key.isModifier()) {
|
||||||
mTimerProxy.startKeyTypedTimer();
|
mTimerProxy.startTypingStateTimer();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -368,7 +368,7 @@ public class PointerTracker {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (key.altCodeWhileTyping() && mTimerProxy.isTyping()) {
|
if (key.altCodeWhileTyping() && mTimerProxy.isTypingState()) {
|
||||||
final int altCode = key.mAltCode;
|
final int altCode = key.mAltCode;
|
||||||
final Key altKey = mKeyboard.getKey(altCode);
|
final Key altKey = mKeyboard.getKey(altCode);
|
||||||
if (altKey != null) {
|
if (altKey != null) {
|
||||||
|
|
Loading…
Reference in New Issue