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

Commit 9458b19f authored by Selim Cinek's avatar Selim Cinek
Browse files

Used different curve for the icons when expanding

The icon animation has now a different interpolator when
expanding compared to when fully expanded. this makes sure
that its moving nicely linear when fully expanded, but in
an accelerate decelerated manner when not.

Test: Add notifications, observe interpolators
Bug: 32437839
Change-Id: I3efcaf54e012f8462bc21ff819903c22d8a1af21
parent 0cfbef45
Loading
Loading
Loading
Loading
+19 −2
Original line number Diff line number Diff line
@@ -23,7 +23,9 @@ import android.content.res.Configuration;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.Interpolator;

import com.android.systemui.Interpolators;
import com.android.systemui.R;
import com.android.systemui.ViewInvertHelper;
import com.android.systemui.statusbar.notification.NotificationUtils;
@@ -57,6 +59,7 @@ public class NotificationShelf extends ActivatableNotificationView {
    private int mStatusBarPaddingStart;
    private AmbientState mAmbientState;
    private NotificationStackScrollLayout mHostLayout;
    private int mMaxLayoutHeight;

    public NotificationShelf(Context context, AttributeSet attrs) {
        super(context, attrs);
@@ -192,8 +195,18 @@ public class NotificationShelf extends ActivatableNotificationView {
        float viewEnd = viewStart + row.getIntrinsicHeight();
        if (viewEnd > maxShelfStart) {
            if (viewStart < maxShelfStart) {
                iconState.iconAppearAmount = 1.0f - ((maxShelfStart - viewStart) /
                        row.getIntrinsicHeight());
                float linearAmount = (maxShelfStart - viewStart) / row.getIntrinsicHeight();
                float interpolatedAmount =  Interpolators.ACCELERATE_DECELERATE.getInterpolation(
                        linearAmount);
                float interpolationStart = mMaxLayoutHeight - getIntrinsicHeight() * 2;
                float expandAmount = 0.0f;
                if (getTranslationY() >= interpolationStart) {
                    expandAmount = (getTranslationY() - interpolationStart) / getIntrinsicHeight();
                    expandAmount = Math.min(1.0f, expandAmount);
                }
                interpolatedAmount = NotificationUtils.interpolate(
                        interpolatedAmount, linearAmount, expandAmount);
                iconState.iconAppearAmount = 1.0f - interpolatedAmount;
            } else {
                iconState.iconAppearAmount = 1.0f;
            }
@@ -292,6 +305,10 @@ public class NotificationShelf extends ActivatableNotificationView {
        mNotificationIconContainer.setTranslationX(iconContainerTranslation);
    }

    public void setMaxLayoutHeight(int maxLayoutHeight) {
        mMaxLayoutHeight = maxLayoutHeight;
    }

    private class ShelfState extends ExpandableViewState {
        private float iconContainerTranslation;

+1 −0
Original line number Diff line number Diff line
@@ -563,6 +563,7 @@ public class NotificationStackScrollLayout extends ViewGroup

    private void setMaxLayoutHeight(int maxLayoutHeight) {
        mMaxLayoutHeight = maxLayoutHeight;
        mShelf.setMaxLayoutHeight(maxLayoutHeight);
        updateAlgorithmHeightAndPadding();
    }