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

Commit 821f8fe1 authored by Roman Birg's avatar Roman Birg Committed by Steve Kondik
Browse files

SystemUI: make sure to expand all the way when flinging



If the panel height changes while an accessibility service pulls down
the status bar (or first time user pulls statusbar down WITH QS tiles
immediately after boot), the height may dynamically change and the
height animator will continue animating down to the original calculated
height.

While expanding the stautsbar down, add a layout listener which ensures
that the height animator's final target is properly set so it smoothly
animates all the way down.

Ref: CYNGNOS-1644

Change-Id: I08f03d9aa556622b5bd39ddcb65a74019dd599e4
Signed-off-by: default avatarRoman Birg <roman@cyngn.com>
Signed-off-by: default avatarChet Kener <Cl3Kener@gmail.com>
parent 4746e9c5
Loading
Loading
Loading
Loading
+24 −1
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.systemui.statusbar.phone;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.ObjectAnimator;
import android.animation.PropertyValuesHolder;
import android.animation.ValueAnimator;
import android.content.Context;
import android.content.res.Configuration;
@@ -27,6 +28,7 @@ import android.util.AttributeSet;
import android.util.Log;
import android.view.InputDevice;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewConfiguration;
import android.view.ViewTreeObserver;
import android.view.animation.Interpolator;
@@ -88,6 +90,20 @@ public abstract class PanelView extends FrameLayout {
    private FlingAnimationUtils mFlingAnimationUtils;
    private FalsingManager mFalsingManager;

    private boolean mUpdateExpandOnLayout;
    private View.OnLayoutChangeListener mLayoutChangeListener = new OnLayoutChangeListener() {
        @Override
        public void onLayoutChange(View v, int left, int top, int right, int bottom,
                int oldLeft, int oldTop, int oldRight, int oldBottom) {
            // update expand height
            if (mHeightAnimator != null && mExpanding && mUpdateExpandOnLayout) {
                final int maxPanelHeight = getMaxPanelHeight();
                final PropertyValuesHolder[] values = mHeightAnimator.getValues();
                values[0].setFloatValues(maxPanelHeight);
            }
        }
    };

    /**
     * Whether an instant expand request is currently pending and we are just waiting for layout.
     */
@@ -631,7 +647,7 @@ public abstract class PanelView extends FrameLayout {
        flingToHeight(vel, expand, target, collapseSpeedUpFactor, expandBecauseOfFalsing);
    }

    protected void flingToHeight(float vel, boolean expand, float target,
    protected void flingToHeight(float vel, final boolean expand, float target,
            float collapseSpeedUpFactor, boolean expandBecauseOfFalsing) {
        // Hack to make the expand transition look nice when clear all button is visible - we make
        // the animation only to the last notification, and then jump to the maximum panel height so
@@ -652,6 +668,7 @@ public abstract class PanelView extends FrameLayout {
            if (expandBecauseOfFalsing) {
                vel = 0;
            }
            mUpdateExpandOnLayout = isFullyCollapsed();
            mFlingAnimationUtils.apply(animator, mExpandedHeight, target, vel, getHeight());
            if (expandBecauseOfFalsing) {
                animator.setDuration(350);
@@ -670,6 +687,11 @@ public abstract class PanelView extends FrameLayout {
        animator.addListener(new AnimatorListenerAdapter() {
            private boolean mCancelled;

            @Override
            public void onAnimationStart(Animator animation) {
                if (expand) PanelView.this.addOnLayoutChangeListener(mLayoutChangeListener);
            }

            @Override
            public void onAnimationCancel(Animator animation) {
                mCancelled = true;
@@ -677,6 +699,7 @@ public abstract class PanelView extends FrameLayout {

            @Override
            public void onAnimationEnd(Animator animation) {
                if (expand) PanelView.this.removeOnLayoutChangeListener(mLayoutChangeListener);
                if (clearAllExpandHack && !mCancelled) {
                    setExpandedHeightInternal(getMaxPanelHeight());
                }