Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1006)

Unified Diff: components/autofill/android/java/src/org/chromium/components/autofill/AutofillKeyboardAccessory.java

Issue 2940483002: Autofill keyboard accessory: Fix repeated animations/accessibility announcements (Closed)
Patch Set: Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/autofill/android/java/src/org/chromium/components/autofill/AutofillKeyboardAccessory.java
diff --git a/components/autofill/android/java/src/org/chromium/components/autofill/AutofillKeyboardAccessory.java b/components/autofill/android/java/src/org/chromium/components/autofill/AutofillKeyboardAccessory.java
index 7f0ea2a5a45d422c70934a79f658d21d875ede2d..d65f86582a89c929ff434708b002915b9902f8e8 100644
--- a/components/autofill/android/java/src/org/chromium/components/autofill/AutofillKeyboardAccessory.java
+++ b/components/autofill/android/java/src/org/chromium/components/autofill/AutofillKeyboardAccessory.java
@@ -55,6 +55,8 @@ public class AutofillKeyboardAccessory extends LinearLayout
private int mSeparatorPosition;
private Animator mAnimator;
private Runnable mReverseAnimationRunnable;
+ // Boolean to track if the keyboard accessory has just popped up or has already been showing.
+ private boolean mFirstAppearance;
/**
* Creates an AutofillKeyboardAccessory with specified parameters.
@@ -84,6 +86,7 @@ public class AutofillKeyboardAccessory extends LinearLayout
mAnimationDurationMillis = animationDurationMillis;
mStartAnimationTranslationPx = getResources().getDimensionPixelSize(
R.dimen.keyboard_accessory_start_animation_translation);
+ mFirstAppearance = true;
}
/**
@@ -192,7 +195,7 @@ public class AutofillKeyboardAccessory extends LinearLayout
container.sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED);
}
- if (mAnimationDurationMillis > 0) {
+ if (mAnimationDurationMillis > 0 && mFirstAppearance) {
cancelAnimations(container);
mAnimator = ObjectAnimator.ofFloat(
this, View.TRANSLATION_X, -mStartAnimationTranslationPx, 0);
@@ -205,6 +208,7 @@ public class AutofillKeyboardAccessory extends LinearLayout
// finished the reverse animation and removed the first suggestion. This
// prevents a sudden movement of these suggestions when the container view
// is redrawn. See |scheduleReverseAnimation|.
+ // TODO(jsaul): Doesn't work properly; investigate animate+hint variation.
for (int i = mSeparatorPosition + 1; i < getChildCount(); ++i) {
getChildAt(i).setAlpha(0);
}
@@ -223,14 +227,17 @@ public class AutofillKeyboardAccessory extends LinearLayout
container.post(new Runnable() {
@Override
public void run() {
- if (mAnimationDurationMillis > 0) {
+ if (mAnimationDurationMillis > 0 && mFirstAppearance) {
mAnimator.start();
} else {
container.scrollTo(isRtl ? getRight() : 0, 0);
}
+ mFirstAppearance = false;
}
});
- announceForAccessibility(container.getContentDescription());
+ if (mFirstAppearance) {
+ announceForAccessibility(container.getContentDescription());
+ }
}
/**
@@ -242,6 +249,8 @@ public class AutofillKeyboardAccessory extends LinearLayout
container.setVisibility(View.GONE);
mWindowAndroid.removeKeyboardVisibilityListener(this);
((View) container.getParent()).requestLayout();
+ // Next time the keyboard accessory appears, do animations/accessibility work if applicable.
+ mFirstAppearance = true;
}
@Override
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698