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

Commit 21118153 authored by Gus Prevas's avatar Gus Prevas
Browse files

Draws background behind heads-up notification's menu.

Also keeps heads-up notification sticky while the menu is exposed.

Change-Id: I05d2a7c57ba496264674dae35f5b92f487c447fd
Fixes: 120048814
Test: manual
parent bb28a036
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -800,7 +800,7 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView
    }

    @Override
    public void performRemoveAnimation(long duration, long delay,
    public long performRemoveAnimation(long duration, long delay,
            float translationDirection, boolean isHeadsUpAnimation, float endLocation,
            Runnable onFinishedRunnable, AnimatorListenerAdapter animationListener) {
        enableAppearDrawing(true);
@@ -812,6 +812,7 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView
        } else if (onFinishedRunnable != null) {
            onFinishedRunnable.run();
        }
        return 0;
    }

    @Override
+23 −0
Original line number Diff line number Diff line
@@ -2607,6 +2607,29 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
        return getShowingLayout();
    }

    @Override
    public long performRemoveAnimation(long duration, long delay, float translationDirection,
            boolean isHeadsUpAnimation, float endLocation, Runnable onFinishedRunnable,
            AnimatorListenerAdapter animationListener) {
        if (mMenuRow.isMenuVisible()) {
            Animator anim = getTranslateViewAnimator(0f, null /* listener */);
            if (anim != null) {
                anim.addListener(new AnimatorListenerAdapter() {
                    @Override
                    public void onAnimationEnd(Animator animation) {
                        ExpandableNotificationRow.super.performRemoveAnimation(
                                duration, delay, translationDirection, isHeadsUpAnimation,
                                endLocation, onFinishedRunnable, animationListener);
                    }
                });
                anim.start();
                return anim.getDuration();
            }
        }
        return super.performRemoveAnimation(duration, delay, translationDirection,
                isHeadsUpAnimation, endLocation, onFinishedRunnable, animationListener);
    }

    @Override
    protected void onAppearAnimationFinished(boolean wasAppearing) {
        super.onAppearAnimationFinished(wasAppearing);
+8 −5
Original line number Diff line number Diff line
@@ -320,8 +320,11 @@ public abstract class ExpandableView extends FrameLayout implements Dumpable {
     * @param endLocation The location where the horizonal heads up disappear animation should end.
     * @param onFinishedRunnable A runnable which should be run when the animation is finished.
     * @param animationListener An animation listener to add to the animation.
     *
     * @return The additional delay, in milliseconds, that this view needs to add before the
     * animation starts.
     */
    public abstract void performRemoveAnimation(long duration,
    public abstract long performRemoveAnimation(long duration,
            long delay, float translationDirection, boolean isHeadsUpAnimation, float endLocation,
            Runnable onFinishedRunnable,
            AnimatorListenerAdapter animationListener);
+2 −1
Original line number Diff line number Diff line
@@ -190,12 +190,13 @@ public abstract class StackScrollerDecorView extends ExpandableView {
    }

    @Override
    public void performRemoveAnimation(long duration, long delay,
    public long performRemoveAnimation(long duration, long delay,
            float translationDirection, boolean isHeadsUpAnimation, float endLocation,
            Runnable onFinishedRunnable,
            AnimatorListenerAdapter animationListener) {
        // TODO: Use duration
        setContentVisible(false);
        return 0;
    }

    @Override
+38 −6
Original line number Diff line number Diff line
@@ -16,10 +16,8 @@

package com.android.systemui.statusbar.notification.stack;

import static com.android.systemui.statusbar.notification.ActivityLaunchAnimator
        .ExpandAnimationParameters;
import static com.android.systemui.statusbar.notification.stack.StackStateAnimator
        .ANIMATION_DURATION_SWIPE;
import static com.android.systemui.statusbar.notification.ActivityLaunchAnimator.ExpandAnimationParameters;
import static com.android.systemui.statusbar.notification.stack.StackStateAnimator.ANIMATION_DURATION_SWIPE;
import static com.android.systemui.statusbar.phone.NotificationIconAreaController.LOW_PRIORITY;

import android.animation.Animator;
@@ -651,6 +649,8 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd
                < mSections[NUM_SECTIONS - 1].getCurrentBounds().bottom
                || mAmbientState.isDark())) {
            drawBackground(canvas);
        } else if (mInHeadsUpPinnedMode || mHeadsUpAnimatingAway) {
            drawHeadsUpBackground(canvas);
        }

        if (DEBUG) {
@@ -749,6 +749,32 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd
                mCornerRadius, mCornerRadius, mBackgroundPaint);
    }

    private void drawHeadsUpBackground(Canvas canvas) {
        int left = mSidePaddings;
        int right = getWidth() - mSidePaddings;

        float top = getHeight();
        float bottom = 0;
        int childCount = getChildCount();
        for (int i = 0; i < childCount; i++) {
            View child = getChildAt(i);
            if (child.getVisibility() != View.GONE
                    && child instanceof ExpandableNotificationRow) {
                ExpandableNotificationRow row = (ExpandableNotificationRow) child;
                if ((row.isPinned() || row.isHeadsUpAnimatingAway()) && row.getTranslation() < 0) {
                    top = Math.min(top, row.getTranslationY());
                    bottom = Math.max(bottom, row.getTranslationY() + row.getActualHeight());
                }
            }
        }

        if (top < bottom) {
            canvas.drawRoundRect(
                    left, top, right, bottom,
                    mCornerRadius, mCornerRadius, mBackgroundPaint);
        }
    }

    @ShadeViewRefactor(RefactorComponent.SHADE_VIEW)
    private void updateBackgroundDimming() {
        // No need to update the background color if it's not being drawn.
@@ -5574,15 +5600,21 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd
            if (translatingParentView != null && row == translatingParentView) {
                mSwipeHelper.clearExposedMenuView();
                mSwipeHelper.clearTranslatingParentView();
                if (row instanceof ExpandableNotificationRow) {
                    mHeadsUpManager.setMenuShown(
                            ((ExpandableNotificationRow) row).getEntry(), false);

                }
            }
        }

        @Override
        public void onMenuShown(View row) {
            if (row instanceof ExpandableNotificationRow) {
                ExpandableNotificationRow notificationRow = (ExpandableNotificationRow) row;
                MetricsLogger.action(mContext, MetricsEvent.ACTION_REVEAL_GEAR,
                        ((ExpandableNotificationRow) row).getStatusBarNotification()
                                .getPackageName());
                        notificationRow.getStatusBarNotification().getPackageName());
                mHeadsUpManager.setMenuShown(notificationRow.getEntry(), true);
            }
            mSwipeHelper.onMenuShown(row);
        }
Loading