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

Commit 7e0f9486 authored by Selim Cinek's avatar Selim Cinek
Browse files

Fixed that pinned huns could become clipped

Huns could become clipped and their actions hidden
after they were posted the first time.
They are now only pushed in if they are above the shelf

Test: manual, add huns, observe correct clipping
Change-Id: I3277da30397e7424c000098b822e571620dd1e08
Fixes: 	38017936
parent 605351c5
Loading
Loading
Loading
Loading
+11 −5
Original line number Diff line number Diff line
@@ -227,7 +227,7 @@ public class NotificationShelf extends ActivatableNotificationView implements
            }
            ExpandableNotificationRow row = (ExpandableNotificationRow) child;
            float notificationClipEnd;
            boolean aboveShelf = row.getTranslationZ() > baseZHeight;
            boolean aboveShelf = ViewState.getFinalTranslationZ(row) > baseZHeight;
            boolean isLastChild = child == lastChild;
            float rowTranslationY = row.getTranslationY();
            if (isLastChild || aboveShelf || backgroundForceHidden) {
@@ -284,10 +284,15 @@ public class NotificationShelf extends ActivatableNotificationView implements
    private void updateNotificationClipHeight(ExpandableNotificationRow row,
            float notificationClipEnd) {
        float viewEnd = row.getTranslationY() + row.getActualHeight();
        boolean isPinned = row.isPinned() || row.isHeadsUpAnimatingAway();
        if (viewEnd > notificationClipEnd
                && (mAmbientState.isShadeExpanded()
                        || (!row.isPinned() && !row.isHeadsUpAnimatingAway()))) {
            row.setClipBottomAmount((int) (viewEnd - notificationClipEnd));
                && (mAmbientState.isShadeExpanded() || !isPinned)) {
            int clipBottomAmount = (int) (viewEnd - notificationClipEnd);
            if (isPinned) {
                clipBottomAmount = Math.min(row.getIntrinsicHeight() - row.getCollapsedHeight(),
                        clipBottomAmount);
            }
            row.setClipBottomAmount(clipBottomAmount);
        } else {
            row.setClipBottomAmount(0);
        }
@@ -381,7 +386,8 @@ public class NotificationShelf extends ActivatableNotificationView implements
                ? fullTransitionAmount
                : transitionAmount;
        iconState.clampedAppearAmount = clampedAmount;
        float contentTransformationAmount = isLastChild || iconState.translateContent
        float contentTransformationAmount = !row.isAboveShelf()
                    && (isLastChild || iconState.translateContent)
                ? iconTransitionAmount
                : 0.0f;
        row.setContentTransformationAmount(contentTransformationAmount, isLastChild);
+8 −4
Original line number Diff line number Diff line
@@ -410,7 +410,7 @@ public class StackScrollAlgorithm {
            if (mIsExpanded) {
                // Ensure that the heads up is always visible even when scrolled off
                clampHunToTop(ambientState, row, childState);
                if (i == 0) {
                if (i == 0 && row.isAboveShelf()) {
                    // the first hun can't get off screen.
                    clampHunToMaxTranslation(ambientState, row, childState);
                }
@@ -447,10 +447,14 @@ public class StackScrollAlgorithm {
    private void clampHunToMaxTranslation(AmbientState ambientState, ExpandableNotificationRow row,
            ExpandableViewState childState) {
        float newTranslation;
        float bottomPosition = ambientState.getMaxHeadsUpTranslation() - row.getCollapsedHeight();
        float maxHeadsUpTranslation = ambientState.getMaxHeadsUpTranslation();
        float maxShelfPosition = ambientState.getInnerHeight() + ambientState.getTopPadding()
                + ambientState.getStackTranslation();
        maxHeadsUpTranslation = Math.min(maxHeadsUpTranslation, maxShelfPosition);
        float bottomPosition = maxHeadsUpTranslation - row.getCollapsedHeight();
        newTranslation = Math.min(childState.yTranslation, bottomPosition);
        childState.height = (int) Math.max(childState.height
                - (childState.yTranslation - newTranslation), row.getCollapsedHeight());
        childState.height = (int) Math.min(childState.height, maxHeadsUpTranslation
                - newTranslation);
        childState.yTranslation = newTranslation;
    }

+16 −0
Original line number Diff line number Diff line
@@ -657,6 +657,22 @@ public class ViewState {
        }
    }

    /**
     * Get the end value of the zTranslation animation running on a view or the zTranslation
     * if no animation is running.
     */
    public static float getFinalTranslationZ(View view) {
        if (view == null) {
            return 0;
        }
        ValueAnimator zAnimator = getChildTag(view, TAG_ANIMATOR_TRANSLATION_Z);
        if (zAnimator == null) {
            return view.getTranslationZ();
        } else {
            return getChildTag(view, TAG_END_TRANSLATION_Z);
        }
    }

    public static boolean isAnimatingY(View child) {
        return getChildTag(child, TAG_ANIMATOR_TRANSLATION_Y) != null;
    }