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

Commit 016671fb authored by Chet Haase's avatar Chet Haase Committed by Android (Google) Code Review
Browse files

Merge "Tweaks to NotificationPanel animation"

parents d9facff5 41bff38d
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -111,9 +111,12 @@ public class ColorDrawable extends Drawable {
        alpha += alpha >> 7;   // make it 0..256
        int baseAlpha = mState.mBaseColor >>> 24;
        int useAlpha = baseAlpha * alpha >> 8;
        int oldUseColor = mState.mUseColor;
        mState.mUseColor = (mState.mBaseColor << 8 >>> 8) | (useAlpha << 24);
        if (oldUseColor != mState.mUseColor) {
            invalidateSelf();
        }
    }

    /**
     * Setting a color filter on a ColorDrawable has no effect.
+31 −12
Original line number Diff line number Diff line
@@ -28,6 +28,10 @@ import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.view.animation.AccelerateInterpolator;
import android.view.animation.DecelerateInterpolator;
import android.view.animation.Interpolator;
import android.widget.RelativeLayout;

import com.android.systemui.R;
@@ -52,6 +56,8 @@ public class NotificationPanel extends RelativeLayout implements StatusBarPanel,
    ViewGroup mContentParent;
    TabletStatusBar mBar;
    View mClearButton;
    static Interpolator sAccelerateInterpolator = new AccelerateInterpolator();
    static Interpolator sDecelerateInterpolator = new DecelerateInterpolator();

    // amount to slide mContentParent down by when mContentFrame is missing
    float mContentFrameMissingTranslation;
@@ -117,15 +123,34 @@ public class NotificationPanel extends RelativeLayout implements StatusBarPanel,
                mShowing = show;
                if (show) {
                    setVisibility(View.VISIBLE);
                }
                    // Don't start the animation until we've created the layer, which is done
                    // right before we are drawn
                    mContentParent.setLayerType(View.LAYER_TYPE_HARDWARE, null);
                    getViewTreeObserver().addOnPreDrawListener(mPreDrawListener);
                } else {
                    mChoreo.startAnimation(show);
                }
            }
        } else {
            mShowing = show;
            setVisibility(show ? View.VISIBLE : View.GONE);
        }
    }

    /**
     * This is used only when we've created a hardware layer and are waiting until it's
     * been created in order to start the appearing animation.
     */
    private ViewTreeObserver.OnPreDrawListener mPreDrawListener =
            new ViewTreeObserver.OnPreDrawListener() {
        @Override
        public boolean onPreDraw() {
            getViewTreeObserver().removeOnPreDrawListener(this);
            mChoreo.startAnimation(true);
            return true;
        }
    };

    /**
     * Whether the panel is showing, or, if it's animating, whether it will be
     * when the animation is done.
@@ -330,8 +355,8 @@ public class NotificationPanel extends RelativeLayout implements StatusBarPanel,
        AnimatorSet mContentAnim;

        // should group this into a multi-property animation
        final static int OPEN_DURATION = 300;
        final static int CLOSE_DURATION = 300;
        final static int OPEN_DURATION = 250;
        final static int CLOSE_DURATION = 250;

        // the panel will start to appear this many px from the end
        final int HYPERSPACE_OFFRAMP = 200;
@@ -362,19 +387,15 @@ public class NotificationPanel extends RelativeLayout implements StatusBarPanel,

            Animator posAnim = ObjectAnimator.ofFloat(mContentParent, "translationY",
                    start, end);
            posAnim.setInterpolator(appearing
                    ? new android.view.animation.DecelerateInterpolator(1.0f)
                    : new android.view.animation.AccelerateInterpolator(1.0f));
            posAnim.setInterpolator(appearing ? sDecelerateInterpolator : sAccelerateInterpolator);

            if (mContentAnim != null && mContentAnim.isRunning()) {
                mContentAnim.cancel();
            }

            Animator fadeAnim = ObjectAnimator.ofFloat(mContentParent, "alpha",
                                mContentParent.getAlpha(), appearing ? 1.0f : 0.0f);
            fadeAnim.setInterpolator(appearing
                    ? new android.view.animation.AccelerateInterpolator(2.0f)
                    : new android.view.animation.DecelerateInterpolator(2.0f));
                    appearing ? 1.0f : 0.0f);
            fadeAnim.setInterpolator(appearing ? sAccelerateInterpolator : sDecelerateInterpolator);

            mContentAnim = new AnimatorSet();
            mContentAnim
@@ -389,8 +410,6 @@ public class NotificationPanel extends RelativeLayout implements StatusBarPanel,
            if (DEBUG) Slog.d(TAG, "startAnimation(appearing=" + appearing + ")");

            createAnimation(appearing);

            mContentParent.setLayerType(View.LAYER_TYPE_HARDWARE, null);
            mContentAnim.start();

            mVisible = appearing;