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

Commit e326d0fe authored by Jorim Jaggi's avatar Jorim Jaggi Committed by Android (Google) Code Review
Browse files

Merge "Animate clock position on Keyguard."

parents acb4eb8e 75c95044
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -302,6 +302,6 @@
    <!-- The margin between the clock and the notifications on Keyguard. See
         keyguard_clock_height_fraction_* for the difference between min and max.-->
    <dimen name="keyguard_clock_notifications_margin_min">22dp</dimen>
    <dimen name="keyguard_clock_notifications_margin_max">28dp</dimen>
    <dimen name="keyguard_clock_notifications_margin_max">36dp</dimen>

</resources>
+50 −5
Original line number Diff line number Diff line
@@ -18,6 +18,8 @@ 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.util.AttributeSet;
@@ -25,7 +27,10 @@ import android.view.MotionEvent;
import android.view.VelocityTracker;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.view.accessibility.AccessibilityEvent;
import android.view.animation.AnimationUtils;
import android.view.animation.Interpolator;
import android.widget.LinearLayout;

import com.android.systemui.R;
@@ -34,6 +39,7 @@ import com.android.systemui.statusbar.FlingAnimationUtils;
import com.android.systemui.statusbar.GestureRecorder;
import com.android.systemui.statusbar.StatusBarState;
import com.android.systemui.statusbar.stack.NotificationStackScrollLayout;
import com.android.systemui.statusbar.stack.StackStateAnimator;

public class NotificationPanelView extends PanelView implements
        ExpandableView.OnHeightChangedListener, ObservableScrollView.Listener,
@@ -80,6 +86,9 @@ public class NotificationPanelView extends PanelView implements
    private int mClockNotificationsMarginMax;
    private float mClockYFractionMin;
    private float mClockYFractionMax;
    private Interpolator mFastOutSlowInInterpolator;
    private ObjectAnimator mClockAnimator;
    private int mClockAnimationTarget = -1;

    /**
     * The number (fractional) of notifications the "more" card counts when calculating how many
@@ -120,6 +129,8 @@ public class NotificationPanelView extends PanelView implements
        mNotificationStackScroller = (NotificationStackScrollLayout)
                findViewById(R.id.notification_stack_scroller);
        mNotificationStackScroller.setOnHeightChangedListener(this);
        mFastOutSlowInInterpolator = AnimationUtils.loadInterpolator(getContext(),
                android.R.interpolator.fast_out_slow_in);
    }

    @Override
@@ -164,21 +175,55 @@ public class NotificationPanelView extends PanelView implements
     * showing.
     */
    private void positionClockAndNotifications() {
        boolean animateClock = mNotificationStackScroller.isAddOrRemoveAnimationPending();
        if (mStatusBar.getBarState() != StatusBarState.KEYGUARD) {
            mStackScrollerIntrinsicPadding = mHeader.getBottom() + mNotificationTopPadding;
        } else {
            int notificationCount = mNotificationStackScroller.getNotGoneChildCount();
            int y = getClockY(notificationCount);
            int y = getClockY(notificationCount) - mKeyguardStatusView.getHeight()/2;
            int padding = getClockNotificationsPadding(notificationCount);
            mKeyguardStatusView.setY(y - mKeyguardStatusView.getHeight()/2);
            mStackScrollerIntrinsicPadding =
                    (int) (mKeyguardStatusView.getY() + mKeyguardStatusView.getHeight() + padding);
            if (animateClock || mClockAnimator != null) {
                startClockAnimation(y);
            } else {
                mKeyguardStatusView.setY(y);
            }
            mStackScrollerIntrinsicPadding = y + mKeyguardStatusView.getHeight() + padding;
        }
        mNotificationStackScroller.setTopPadding(mStackScrollerIntrinsicPadding,
                mAnimateNextTopPaddingChange);
                mAnimateNextTopPaddingChange || animateClock);
        mAnimateNextTopPaddingChange = false;
    }

    private void startClockAnimation(int y) {
        if (mClockAnimationTarget == y) {
            return;
        }
        mClockAnimationTarget = y;
        getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
            @Override
            public boolean onPreDraw() {
                getViewTreeObserver().removeOnPreDrawListener(this);
                if (mClockAnimator != null) {
                    mClockAnimator.removeAllListeners();
                    mClockAnimator.cancel();
                }
                mClockAnimator =
                        ObjectAnimator.ofFloat(mKeyguardStatusView, View.Y, mClockAnimationTarget);
                mClockAnimator.setInterpolator(mFastOutSlowInInterpolator);
                mClockAnimator.setDuration(StackStateAnimator.ANIMATION_DURATION_STANDARD);
                mClockAnimator.addListener(new AnimatorListenerAdapter() {
                    @Override
                    public void onAnimationEnd(Animator animation) {
                        mClockAnimator = null;
                        mClockAnimationTarget = -1;
                    }
                });
                StackStateAnimator.startInstantly(mClockAnimator);
                return true;
            }
        });
    }

    private int getClockNotificationsPadding(int notificationCount) {
        float t = notificationCount
                / (mStatusBar.getMaxKeyguardNotifications() + mMoreCardNotificationAmount);
+8 −0
Original line number Diff line number Diff line
@@ -2922,4 +2922,12 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
    public void reattachSystemIcons() {
        mSystemIconArea.addView(mSystemIcons, 0);
    }

    public void onScreenTurnedOff() {
        mStackScroller.setAnimationsEnabled(false);
    }

    public void onScreenTurnedOn() {
        mStackScroller.setAnimationsEnabled(true);
    }
}
+2 −0
Original line number Diff line number Diff line
@@ -125,11 +125,13 @@ public class StatusBarKeyguardViewManager {

    public void onScreenTurnedOff() {
        mScreenOn = false;
        mPhoneStatusBar.onScreenTurnedOff();
        mBouncer.onScreenTurnedOff();
    }

    public void onScreenTurnedOn(final IKeyguardShowCallback callback) {
        mScreenOn = true;
        mPhoneStatusBar.onScreenTurnedOn();
        if (callback != null) {
            callbackAfterDraw(callback);
        }
+26 −11
Original line number Diff line number Diff line
@@ -108,6 +108,7 @@ public class NotificationStackScrollLayout extends ViewGroup
            = new ArrayList<AnimationEvent>();
    private ArrayList<View> mSwipedOutViews = new ArrayList<View>();
    private final StackStateAnimator mStateAnimator = new StackStateAnimator(this);
    private boolean mAnimationsEnabled;

    /**
     * The raw amount of the overScroll on the top, which is not rubber-banded.
@@ -352,7 +353,7 @@ public class NotificationStackScrollLayout extends ViewGroup
            mTopPadding = topPadding;
            updateAlgorithmHeightAndPadding();
            updateContentHeight();
            if (animate) {
            if (animate && mAnimationsEnabled && mIsExpanded) {
                mTopPaddingNeedsAnimation = true;
                mNeedsAnimation =  true;
            }
@@ -440,9 +441,11 @@ public class NotificationStackScrollLayout extends ViewGroup
    public void onChildSnappedBack(View animView) {
        mAmbientState.onDragFinished(animView);
        if (!mDragAnimPendingChildren.contains(animView)) {
            if (mAnimationsEnabled) {
                mSnappedBackChildren.add(animView);
            requestChildrenUpdate();
                mNeedsAnimation = true;
            }
            requestChildrenUpdate();
        } else {
            // We start the swipe and snap back in the same frame, we don't want any animation
            mDragAnimPendingChildren.remove(animView);
@@ -451,11 +454,13 @@ public class NotificationStackScrollLayout extends ViewGroup

    public void onBeginDrag(View v) {
        setSwipingInProgress(true);
        mDragAnimPendingChildren.add(v);
        mAmbientState.onBeginDrag(v);
        requestChildrenUpdate();
        if (mAnimationsEnabled) {
            mDragAnimPendingChildren.add(v);
            mNeedsAnimation = true;
        }
        requestChildrenUpdate();
    }

    public void onDragCancelled(View v) {
        setSwipingInProgress(false);
@@ -1082,8 +1087,7 @@ public class NotificationStackScrollLayout extends ViewGroup
    }

    private void generateRemoveAnimation(View child) {
        if (mIsExpanded) {

        if (mIsExpanded && mAnimationsEnabled) {
            if (!mChildrenToAddAnimated.contains(child)) {
                // Generate Animations
                mChildrenToRemoveAnimated.add(child);
@@ -1141,8 +1145,17 @@ public class NotificationStackScrollLayout extends ViewGroup
        }
    }

    public void setAnimationsEnabled(boolean animationsEnabled) {
        mAnimationsEnabled = animationsEnabled;
    }

    public boolean isAddOrRemoveAnimationPending() {
        return mNeedsAnimation
                && (!mChildrenToAddAnimated.isEmpty() || !mChildrenToRemoveAnimated.isEmpty());
    }

    public void generateAddAnimation(View child) {
        if (mIsExpanded) {
        if (mIsExpanded && mAnimationsEnabled) {

            // Generate Animations
            mChildrenToAddAnimated.add(child);
@@ -1447,7 +1460,7 @@ public class NotificationStackScrollLayout extends ViewGroup
        mStackScrollAlgorithm.setDimmed(dimmed);
        mAmbientState.setDimmed(dimmed);
        updatePadding(dimmed);
        if (animate) {
        if (animate && mAnimationsEnabled) {
            mDimmedNeedsAnimation = true;
            mNeedsAnimation =  true;
        }
@@ -1459,8 +1472,10 @@ public class NotificationStackScrollLayout extends ViewGroup
     */
    public void setActivatedChild(View activatedChild) {
        mAmbientState.setActivatedChild(activatedChild);
        if (mAnimationsEnabled) {
            mActivateNeedsAnimation = true;
            mNeedsAnimation =  true;
        }
        requestChildrenUpdate();
    }

Loading