Don't reset animation alpha value when keyboard is set

The keys' blinking that mentioned in the bug is caused by switching
keyboard layout resets the animation's alpha value to opaque but the
animation is still running and changing the alpha value
asynchronously.

I think that switching keyboard layout between alphabet and symbols
doesn't imply that the user stops typing. So the keyboard view should
continue typing state timer to keep animations' alpha values changing
and never reset the value.

Bug: 6174273
Change-Id: Id795feaf44750358f30c1b3dc8e783a7e62aefe8
main
Tadashi G. Takaoka 2012-03-15 21:05:17 +09:00
parent 2be7a37acf
commit b9720a55b4
2 changed files with 26 additions and 47 deletions

View File

@ -383,6 +383,7 @@ public class Keyboard {
case CODE_ACTION_ENTER: return "actionEnter";
case CODE_ACTION_NEXT: return "actionNext";
case CODE_ACTION_PREVIOUS: return "actionPrevious";
case CODE_LANGUAGE_SWITCH: return "languageSwitch";
case CODE_UNSPECIFIED: return "unspec";
case CODE_TAB: return "tab";
case CODE_ENTER: return "enter";

View File

@ -84,7 +84,7 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke
private static final int ALPHA_OPAQUE = 255;
private boolean mNeedsToDisplayLanguage;
private Locale mSpacebarLocale;
private int mSpacebarTextAlpha;
private int mSpacebarTextAlpha = ALPHA_OPAQUE;
private final float mSpacebarTextRatio;
private float mSpacebarTextSize;
private final int mSpacebarTextColor;
@ -101,7 +101,7 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke
// Stuff to draw altCodeWhileTyping keys.
private ValueAnimator mAltCodeKeyWhileTypingFadeoutAnimator;
private ValueAnimator mAltCodeKeyWhileTypingFadeinAnimator;
private int mAltCodeKeyWhileTypingAnimAlpha;
private int mAltCodeKeyWhileTypingAnimAlpha = ALPHA_OPAQUE;
// More keys keyboard
private PopupWindow mMoreKeysWindow;
@ -154,16 +154,8 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke
}
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();
}
cancelAndStartAnimators(keyboardView.mAltCodeKeyWhileTypingFadeoutAnimator,
keyboardView.mAltCodeKeyWhileTypingFadeinAnimator);
break;
}
}
@ -238,26 +230,34 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke
removeMessages(MSG_LONGPRESS_KEY);
}
private static void cancelAndStartAnimators(ValueAnimator animatorToCancel,
ValueAnimator animatorToStart) {
if (animatorToCancel != null && animatorToCancel.isStarted()) {
animatorToCancel.cancel();
}
// TODO: Start the animation with an initial value that is the same as the final value
// of the above animation when it gets cancelled.
if (animatorToStart != null && !animatorToStart.isStarted()) {
animatorToStart.start();
}
}
private void cancelTypingStateTimer() {
removeMessages(MSG_TYPING_STATE_EXPIRED);
}
@Override
public void startTypingStateTimer() {
final boolean isTyping = isTypingState();
removeMessages(MSG_TYPING_STATE_EXPIRED);
cancelTypingStateTimer();
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();
}
final LatinKeyboardView keyboardView = getOuterInstance();
cancelAndStartAnimators(keyboardView.mAltCodeKeyWhileTypingFadeinAnimator,
keyboardView.mAltCodeKeyWhileTypingFadeoutAnimator);
}
@Override
@ -289,6 +289,7 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke
public void cancelAllMessages() {
cancelKeyTimers();
cancelTypingStateTimer();
}
}
@ -323,15 +324,6 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke
public final int mLongPressSpaceKeyTimeout;
public final int mIgnoreAltCodeKeyTimeout;
KeyTimerParams() {
mKeyRepeatStartTimeout = 0;
mKeyRepeatInterval = 0;
mLongPressKeyTimeout = 0;
mLongPressShiftKeyTimeout = 0;
mLongPressSpaceKeyTimeout = 0;
mIgnoreAltCodeKeyTimeout = 0;
}
public KeyTimerParams(TypedArray latinKeyboardViewAttr) {
mKeyRepeatStartTimeout = latinKeyboardViewAttr.getInt(
R.styleable.LatinKeyboardView_keyRepeatStartTimeout, 0);
@ -424,12 +416,6 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke
updateAltCodeKeyWhileTyping();
}
});
fadeout.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator a) {
final ValueAnimator valueAnimator = (ValueAnimator)a;
}
});
}
mAltCodeKeyWhileTypingFadeoutAnimator = fadeout;
@ -442,12 +428,6 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke
updateAltCodeKeyWhileTyping();
}
});
fadein.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator a) {
final ValueAnimator valueAnimator = (ValueAnimator)a;
}
});
}
mAltCodeKeyWhileTypingFadeinAnimator = fadein;
}
@ -510,8 +490,6 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke
final int keyHeight = keyboard.mMostCommonKeyHeight - keyboard.mVerticalGap;
mSpacebarTextSize = keyHeight * mSpacebarTextRatio;
mSpacebarLocale = keyboard.mId.mLocale;
mSpacebarTextAlpha = ALPHA_OPAQUE;
mAltCodeKeyWhileTypingAnimAlpha = ALPHA_OPAQUE;
}
/**