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

Commit 01a73f9d authored by Selim Cinek's avatar Selim Cinek
Browse files

Don't translate the notification content while scrolling

While scrolling we don't translate the notification content
anymore and only have it while expanding.

Test: add notifications, scroll
Bug: 32437839
Change-Id: I21037b40ec92c20f2cd775815dcf5d8399348223
parent 0e39fac3
Loading
Loading
Loading
Loading
+18 −15
Original line number Diff line number Diff line
@@ -20,8 +20,6 @@ import android.content.Context;
import android.content.res.Configuration;
import android.os.SystemProperties;
import android.util.AttributeSet;
import android.util.FloatProperty;
import android.util.Property;
import android.view.View;
import android.view.ViewGroup;

@@ -287,49 +285,50 @@ public class NotificationShelf extends ActivatableNotificationView {
        }
        float viewEnd = viewStart + fullHeight;
        float fullTransitionAmount;
        float iconTransitonAmount;
        if (viewEnd >= getTranslationY() && (mAmbientState.isShadeExpanded()
        float iconTransitionAmount;
        float shelfStart = getTranslationY();
        if (viewEnd >= shelfStart && (mAmbientState.isShadeExpanded()
                || (!row.isPinned() && !row.isHeadsUpAnimatingAway()))) {
            if (viewStart < getTranslationY()) {
            if (viewStart < shelfStart) {

                float fullAmount = (getTranslationY() - viewStart) / fullHeight;
                float fullAmount = (shelfStart - viewStart) / fullHeight;
                float interpolatedAmount =  Interpolators.ACCELERATE_DECELERATE.getInterpolation(
                        fullAmount);
                interpolatedAmount = NotificationUtils.interpolate(
                        interpolatedAmount, fullAmount, expandAmount);
                fullTransitionAmount = 1.0f - interpolatedAmount;

                iconTransitonAmount = (getTranslationY() - viewStart) / iconTransformDistance;
                iconTransitonAmount = Math.min(1.0f, iconTransitonAmount);
                iconTransitonAmount = 1.0f - iconTransitonAmount;
                iconTransitionAmount = (shelfStart - viewStart) / iconTransformDistance;
                iconTransitionAmount = Math.min(1.0f, iconTransitionAmount);
                iconTransitionAmount = 1.0f - iconTransitionAmount;

            } else {
                fullTransitionAmount = 1.0f;
                iconTransitonAmount = 1.0f;
                iconTransitionAmount = 1.0f;
            }
        } else {
            fullTransitionAmount = 0.0f;
            iconTransitonAmount = 0.0f;
            iconTransitionAmount = 0.0f;
        }
        row.setContentTransformationAmount(iconTransitonAmount, isLastChild);
        updateIconPositioning(row, iconTransitonAmount, fullTransitionAmount);
        updateIconPositioning(row, iconTransitionAmount, fullTransitionAmount, isLastChild);
        return fullTransitionAmount;
    }

    private void updateIconPositioning(ExpandableNotificationRow row, float iconTransitionAmount,
            float fullTransitionAmount) {
            float fullTransitionAmount, boolean isLastChild) {
        StatusBarIconView icon = row.getEntry().expandedIcon;
        NotificationIconContainer.IconState iconState = getIconState(icon);
        if (iconState == null) {
            return;
        }
        float clampedAmount = iconTransitionAmount > 0.5f ? 1.0f : 0.0f;
        boolean isLastChild = isLastChild(row);
        if (clampedAmount == iconTransitionAmount) {
            iconState.keepClampedPosition = false;
        }
        if (clampedAmount == fullTransitionAmount) {
            iconState.useFullTransitionAmount = fullTransitionAmount == 0.0f;
            iconState.translateContent = mMaxLayoutHeight - getTranslationY()
                    - getIntrinsicHeight() > 0;
        }
        float transitionAmount;
        boolean needCannedAnimation = iconState.clampedAppearAmount == 1.0f
@@ -358,6 +357,10 @@ public class NotificationShelf extends ActivatableNotificationView {
                : transitionAmount;
        iconState.clampedAppearAmount = clampedAmount;
        setIconTransformationAmount(row, transitionAmount);
        float contentTransformationAmount = isLastChild || iconState.translateContent
                ? iconTransitionAmount
                : 0.0f;
        row.setContentTransformationAmount(contentTransformationAmount, isLastChild);
    }

    private boolean isLastChild(ExpandableNotificationRow row) {
+3 −1
Original line number Diff line number Diff line
@@ -515,7 +515,9 @@ public class StatusBarIconView extends AnimatedImageView {
                }
            } else {
                setIconAppearAmount(visibleState == STATE_ICON ? 1.0f : 0.0f);
                setDotAppearAmount(visibleState == STATE_DOT ? 1.0f : 0.0f);
                setDotAppearAmount(visibleState == STATE_DOT ? 1.0f
                        : visibleState == STATE_ICON ? 2.0f
                        : 0.0f);
            }
        }
        if (!runnableAdded) {
+1 −0
Original line number Diff line number Diff line
@@ -411,6 +411,7 @@ public class NotificationIconContainer extends AlphaOptimizedFrameLayout {
        public boolean needsCannedAnimation;
        public boolean keepClampedPosition;
        public boolean useFullTransitionAmount;
        public boolean translateContent;

        @Override
        public void applyToView(View view) {