From d4fc13d261c77b3ccf6847e69d28cb2da583fd5c Mon Sep 17 00:00:00 2001 From: Jean Chalard Date: Wed, 24 Apr 2013 18:21:44 +0900 Subject: [PATCH] [PB9] Make buttons that animate-out unclickable Clicking on a button that is animating-out is only done by mistake. Better make them unclickable. Also, interrupt an out-in animation if it has been preempted. Bug: 7600384 Change-Id: Ic4700cda46a894ea580bc67ee7bef885ecf1d3bc --- .../com/android/inputmethod/dictionarypack/ButtonSwitcher.java | 3 +++ .../android/inputmethod/dictionarypack/WordListPreference.java | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/java/src/com/android/inputmethod/dictionarypack/ButtonSwitcher.java b/java/src/com/android/inputmethod/dictionarypack/ButtonSwitcher.java index 391a15c97..5ab94a429 100644 --- a/java/src/com/android/inputmethod/dictionarypack/ButtonSwitcher.java +++ b/java/src/com/android/inputmethod/dictionarypack/ButtonSwitcher.java @@ -126,6 +126,7 @@ public class ButtonSwitcher extends FrameLayout { new AnimatorListenerAdapter() { @Override public void onAnimationEnd(final Animator animation) { + if (newStatus != mStatus) return; animateButton(newButton, ANIMATION_IN); } }); @@ -144,8 +145,10 @@ public class ButtonSwitcher extends FrameLayout { final float outerX = getWidth(); final float innerX = button.getX() - button.getTranslationX(); if (ANIMATION_IN == direction) { + button.setClickable(true); return button.animate().translationX(0); } else { + button.setClickable(false); return button.animate().translationX(outerX - innerX); } } diff --git a/java/src/com/android/inputmethod/dictionarypack/WordListPreference.java b/java/src/com/android/inputmethod/dictionarypack/WordListPreference.java index 1cf9196b5..e14055b50 100644 --- a/java/src/com/android/inputmethod/dictionarypack/WordListPreference.java +++ b/java/src/com/android/inputmethod/dictionarypack/WordListPreference.java @@ -219,8 +219,9 @@ public final class WordListPreference extends Preference { final ListView listView = (ListView)parent; final int indexToOpen; // Close all first, we'll open back any item that needs to be open. + final boolean wasOpen = mInterfaceState.isOpen(mWordlistId); mInterfaceState.closeAll(); - if (mInterfaceState.isOpen(mWordlistId)) { + if (wasOpen) { // This button being shown. Take note that we don't want to open any button in the // loop below. indexToOpen = -1;