Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 18d71849 authored by Sunny Goyal's avatar Sunny Goyal
Browse files

Removing accessibility workaround for changing View visibility

Original change-id: I9a687a39a358441afd57c0c46b57399ecbf23c36

Bug: 76418647
Change-Id: I0800bd4f521e052f0a1229fe6b7ceafd1b0429ae
parent 9025aa53
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -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;
+15 −27
Original line number Diff line number Diff line
@@ -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
+2 −5
Original line number Diff line number Diff line
@@ -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);
        }