summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTreeHugger Robot <treehugger-gerrit@google.com>2018-03-28 17:42:07 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2018-03-28 17:42:07 +0000
commit71d45a0ab018f004cc085e22d05fc40ec8e6ee8a (patch)
tree05b2cb6ac3a1a34b84d852fd02fe6226a70ee9aa
parentfbcd52f407c99d059b5adca19f72dd20df07bd2f (diff)
parent18d718492a11b838be91aab34952866b285ed0ee (diff)
downloadandroid_packages_apps_Trebuchet-71d45a0ab018f004cc085e22d05fc40ec8e6ee8a.tar.gz
android_packages_apps_Trebuchet-71d45a0ab018f004cc085e22d05fc40ec8e6ee8a.tar.bz2
android_packages_apps_Trebuchet-71d45a0ab018f004cc085e22d05fc40ec8e6ee8a.zip
Merge "Removing accessibility workaround for changing View visibility" into ub-launcher3-master
-rw-r--r--src/com/android/launcher3/DropTargetBar.java3
-rw-r--r--src/com/android/launcher3/anim/AlphaUpdateListener.java42
-rw-r--r--src/com/android/launcher3/anim/PropertySetter.java7
3 files changed, 18 insertions, 34 deletions
diff --git a/src/com/android/launcher3/DropTargetBar.java b/src/com/android/launcher3/DropTargetBar.java
index dec6cb452..d025a9b99 100644
--- a/src/com/android/launcher3/DropTargetBar.java
+++ b/src/com/android/launcher3/DropTargetBar.java
@@ -20,7 +20,6 @@ import static com.android.launcher3.ButtonDropTarget.TOOLTIP_DEFAULT;
import static com.android.launcher3.ButtonDropTarget.TOOLTIP_LEFT;
import static com.android.launcher3.ButtonDropTarget.TOOLTIP_RIGHT;
import static com.android.launcher3.anim.AlphaUpdateListener.updateVisibility;
-import static com.android.launcher3.compat.AccessibilityManagerCompat.isAccessibilityEnabled;
import android.animation.TimeInterpolator;
import android.content.Context;
@@ -47,7 +46,7 @@ public class DropTargetBar extends FrameLayout
protected static final TimeInterpolator DEFAULT_INTERPOLATOR = Interpolators.ACCEL;
private final Runnable mFadeAnimationEndRunnable =
- () -> updateVisibility(DropTargetBar.this, isAccessibilityEnabled(getContext()));
+ () -> updateVisibility(DropTargetBar.this);
@ViewDebug.ExportedProperty(category = "launcher")
protected boolean mDeferOnDragEnd;
diff --git a/src/com/android/launcher3/anim/AlphaUpdateListener.java b/src/com/android/launcher3/anim/AlphaUpdateListener.java
index 04d97a728..a3d02d949 100644
--- a/src/com/android/launcher3/anim/AlphaUpdateListener.java
+++ b/src/com/android/launcher3/anim/AlphaUpdateListener.java
@@ -17,7 +17,6 @@
package com.android.launcher3.anim;
import android.animation.Animator;
-import android.animation.AnimatorListenerAdapter;
import android.animation.ValueAnimator;
import android.animation.ValueAnimator.AnimatorUpdateListener;
import android.view.View;
@@ -25,44 +24,24 @@ import android.view.View;
/**
* A convenience class to update a view's visibility state after an alpha animation.
*/
-public class AlphaUpdateListener extends AnimatorListenerAdapter implements AnimatorUpdateListener {
+public class AlphaUpdateListener extends AnimationSuccessListener
+ implements AnimatorUpdateListener {
private static final float ALPHA_CUTOFF_THRESHOLD = 0.01f;
private View mView;
- private boolean mAccessibilityEnabled;
- private boolean mCanceled = false;
- public AlphaUpdateListener(View v, boolean accessibilityEnabled) {
+ public AlphaUpdateListener(View v) {
mView = v;
- mAccessibilityEnabled = accessibilityEnabled;
}
@Override
public void onAnimationUpdate(ValueAnimator arg0) {
- updateVisibility(mView, mAccessibilityEnabled);
- }
-
- public static void updateVisibility(View view, boolean accessibilityEnabled) {
- // We want to avoid the extra layout pass by setting the views to GONE unless
- // accessibility is on, in which case not setting them to GONE causes a glitch.
- int invisibleState = accessibilityEnabled ? View.GONE : View.INVISIBLE;
- if (view.getAlpha() < ALPHA_CUTOFF_THRESHOLD && view.getVisibility() != invisibleState) {
- view.setVisibility(invisibleState);
- } else if (view.getAlpha() > ALPHA_CUTOFF_THRESHOLD
- && view.getVisibility() != View.VISIBLE) {
- view.setVisibility(View.VISIBLE);
- }
+ updateVisibility(mView);
}
@Override
- public void onAnimationCancel(Animator animation) {
- mCanceled = true;
- }
-
- @Override
- public void onAnimationEnd(Animator arg0) {
- if (mCanceled) return;
- updateVisibility(mView, mAccessibilityEnabled);
+ public void onAnimationSuccess(Animator animator) {
+ updateVisibility(mView);
}
@Override
@@ -70,4 +49,13 @@ public class AlphaUpdateListener extends AnimatorListenerAdapter implements Anim
// We want the views to be visible for animation, so fade-in/out is visible
mView.setVisibility(View.VISIBLE);
}
+
+ public static void updateVisibility(View view) {
+ if (view.getAlpha() < ALPHA_CUTOFF_THRESHOLD && view.getVisibility() != View.INVISIBLE) {
+ view.setVisibility(View.INVISIBLE);
+ } else if (view.getAlpha() > ALPHA_CUTOFF_THRESHOLD
+ && view.getVisibility() != View.VISIBLE) {
+ view.setVisibility(View.VISIBLE);
+ }
+ }
} \ No newline at end of file
diff --git a/src/com/android/launcher3/anim/PropertySetter.java b/src/com/android/launcher3/anim/PropertySetter.java
index 1f11f7e63..757edff74 100644
--- a/src/com/android/launcher3/anim/PropertySetter.java
+++ b/src/com/android/launcher3/anim/PropertySetter.java
@@ -16,8 +16,6 @@
package com.android.launcher3.anim;
-import static com.android.launcher3.compat.AccessibilityManagerCompat.isAccessibilityEnabled;
-
import android.animation.Animator;
import android.animation.ObjectAnimator;
import android.animation.TimeInterpolator;
@@ -34,7 +32,7 @@ public class PropertySetter {
public void setViewAlpha(View view, float alpha, TimeInterpolator interpolator) {
if (view != null) {
view.setAlpha(alpha);
- AlphaUpdateListener.updateVisibility(view, isAccessibilityEnabled(view.getContext()));
+ AlphaUpdateListener.updateVisibility(view);
}
}
@@ -64,8 +62,7 @@ public class PropertySetter {
return;
}
ObjectAnimator anim = ObjectAnimator.ofFloat(view, View.ALPHA, alpha);
- anim.addListener(new AlphaUpdateListener(
- view, isAccessibilityEnabled(view.getContext())));
+ anim.addListener(new AlphaUpdateListener(view));
anim.setDuration(mDuration).setInterpolator(interpolator);
mStateAnimator.play(anim);
}