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

Commit 40376570 authored by Mady Mellor's avatar Mady Mellor Committed by Android (Google) Code Review
Browse files

Merge "New bits for showing the dot & flyout on NotificationEntry" into qt-r1-bubbles-dev

parents 79f3c312 df48d0a6
Loading
Loading
Loading
Loading
+27 −0
Original line number Diff line number Diff line
@@ -69,6 +69,11 @@ class Bubble {
     */
    private boolean mShowInShadeWhenBubble = true;

    /**
     * Whether the bubble should show a dot for the notification indicating updated content.
     */
    private boolean mShowBubbleUpdateDot = true;

    public static String groupId(NotificationEntry entry) {
        UserHandle user = entry.notification.getUser();
        return user.getIdentifier() + "|" + entry.notification.getPackageName();
@@ -225,6 +230,7 @@ class Bubble {
    void markAsAccessedAt(long lastAccessedMillis) {
        mLastAccessed = lastAccessedMillis;
        setShowInShadeWhenBubble(false);
        setShowBubbleDot(false);
    }

    /**
@@ -244,6 +250,27 @@ class Bubble {
        mShowInShadeWhenBubble = showInShade;
    }

    /**
     * Sets whether the bubble for this notification should show a dot indicating updated content.
     */
    void setShowBubbleDot(boolean showDot) {
        mShowBubbleUpdateDot = showDot;
    }

    /**
     * Whether the bubble for this notification should show a dot indicating updated content.
     */
    boolean showBubbleDot() {
        return mShowBubbleUpdateDot && !mEntry.shouldSuppressNotificationDot();
    }

    /**
     * Whether the flyout for the bubble should be shown.
     */
    boolean showFlyoutForBubble() {
        return !mEntry.shouldSuppressPeek() && !mEntry.shouldSuppressNotificationList();
    }

    /**
     * Returns whether the notification for this bubble is a foreground service. It shows that this
     * is an ongoing bubble.
+7 −35
Original line number Diff line number Diff line
@@ -17,9 +17,6 @@
package com.android.systemui.bubbles;

import static android.app.Notification.FLAG_BUBBLE;
import static android.app.NotificationManager.Policy.SUPPRESSED_EFFECT_BADGE;
import static android.app.NotificationManager.Policy.SUPPRESSED_EFFECT_NOTIFICATION_LIST;
import static android.app.NotificationManager.Policy.SUPPRESSED_EFFECT_PEEK;
import static android.content.pm.ActivityInfo.DOCUMENT_LAUNCH_ALWAYS;
import static android.service.notification.NotificationListenerService.REASON_APP_CANCEL;
import static android.service.notification.NotificationListenerService.REASON_APP_CANCEL_ALL;
@@ -212,12 +209,16 @@ public class BubbleController implements ConfigurationController.ConfigurationLi
        mZenModeController.addCallback(new ZenModeController.Callback() {
            @Override
            public void onZenChanged(int zen) {
                updateStackViewForZenConfig();
                if (mStackView != null) {
                    mStackView.updateDots();
                }
            }

            @Override
            public void onConfigChanged(ZenModeConfig config) {
                updateStackViewForZenConfig();
                if (mStackView != null) {
                    mStackView.updateDots();
                }
            }
        });

@@ -263,8 +264,6 @@ public class BubbleController implements ConfigurationController.ConfigurationLi
            if (mExpandListener != null) {
                mStackView.setExpandListener(mExpandListener);
            }

            updateStackViewForZenConfig();
        }
    }

@@ -449,6 +448,7 @@ public class BubbleController implements ConfigurationController.ConfigurationLi
                        && userRemovedNotif;
                if (bubbleExtended) {
                    bubble.setShowInShadeWhenBubble(false);
                    bubble.setShowBubbleDot(false);
                    if (mStackView != null) {
                        mStackView.updateDotVisibility(entry.key);
                    }
@@ -584,34 +584,6 @@ public class BubbleController implements ConfigurationController.ConfigurationLi
        }
    };

    /**
     * Updates the stack view's suppression flags from the latest config from the zen (do not
     * disturb) controller.
     */
    private void updateStackViewForZenConfig() {
        final ZenModeConfig zenModeConfig = mZenModeController.getConfig();

        if (zenModeConfig == null || mStackView == null) {
            return;
        }

        final int suppressedEffects = zenModeConfig.suppressedVisualEffects;
        final boolean hideNotificationDotsSelected =
                (suppressedEffects & SUPPRESSED_EFFECT_BADGE) != 0;
        final boolean dontPopNotifsOnScreenSelected =
                (suppressedEffects & SUPPRESSED_EFFECT_PEEK) != 0;
        final boolean hideFromPullDownShadeSelected =
                (suppressedEffects & SUPPRESSED_EFFECT_NOTIFICATION_LIST) != 0;

        final boolean dndEnabled = mZenModeController.getZen() != Settings.Global.ZEN_MODE_OFF;

        mStackView.setSuppressNewDot(
                dndEnabled && hideNotificationDotsSelected);
        mStackView.setSuppressFlyout(
                dndEnabled && (dontPopNotifsOnScreenSelected
                        || hideFromPullDownShadeSelected));
    }

    /**
     * Lets any listeners know if bubble state has changed.
     * Updates the visibility of the bubbles based on current state.
+1 −0
Original line number Diff line number Diff line
@@ -188,6 +188,7 @@ public class BubbleData {
            setSelectedBubbleInternal(bubble);
        }
        bubble.setShowInShadeWhenBubble(!mExpanded || mSelectedBubble != bubble);
        bubble.setShowBubbleDot(true);
        dispatchPendingChanges();
    }

+19 −44
Original line number Diff line number Diff line
@@ -162,6 +162,11 @@ public class BubbleStackView extends FrameLayout {
    private BubbleFlyoutView mFlyout;
    /** Runnable that fades out the flyout and then sets it to GONE. */
    private Runnable mHideFlyout = () -> animateFlyoutCollapsed(true, 0 /* velX */);
    /**
     * Callback to run after the flyout hides. Also called if a new flyout is shown before the
     * previous one animates out.
     */
    private Runnable mAfterFlyoutHides;

    /** Layout change listener that moves the stack to the nearest valid position on rotation. */
    private OnLayoutChangeListener mOrientationChangedListener;
@@ -287,9 +292,6 @@ public class BubbleStackView extends FrameLayout {
    private BubbleDismissView mDismissContainer;
    private Runnable mAfterMagnet;

    private boolean mSuppressNewDot = false;
    private boolean mSuppressFlyout = false;

    private int mOrientation = Configuration.ORIENTATION_UNDEFINED;

    public BubbleStackView(Context context, BubbleData data,
@@ -693,9 +695,6 @@ public class BubbleStackView extends FrameLayout {
        mBubbleContainer.addView(bubble.getIconView(), 0,
                new FrameLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT));
        ViewClippingUtil.setClippingDeactivated(bubble.getIconView(), true, mClippingParameters);
        if (bubble.getIconView() != null) {
            bubble.getIconView().setSuppressDot(mSuppressNewDot, false /* animate */);
        }
        animateInFlyoutForBubble(bubble);
        requestUpdate();
        logBubbleEvent(bubble, StatsLog.BUBBLE_UICHANGED__ACTION__POSTED);
@@ -1294,47 +1293,23 @@ public class BubbleStackView extends FrameLayout {
                        : 0f);
    }

    /**
     * Calculates the y position of the expanded view when it is expanded.
     */
    float getExpandedViewY() {
        return getStatusBarHeight() + mBubbleSize + mBubblePaddingTop + mPointerHeight;
    }

    /**
     * Called when the height of the currently expanded view has changed (not via an
     * update to the bubble's desired height but for some other reason, e.g. permission view
     * goes away).
     */
    void onExpandedHeightChanged() {
        if (mIsExpanded) {
            requestUpdate();
        }
    }

    /** Sets whether all bubbles in the stack should not show the 'new' dot. */
    void setSuppressNewDot(boolean suppressNewDot) {
        mSuppressNewDot = suppressNewDot;

        for (int i = 0; i < mBubbleContainer.getChildCount(); i++) {
    /** Updates the dot visibility, this is used in response to a zen mode config change. */
    void updateDots() {
        int bubbsCount = mBubbleContainer.getChildCount();
        for (int i = 0; i < bubbsCount; i++) {
            BubbleView bv = (BubbleView) mBubbleContainer.getChildAt(i);
            bv.setSuppressDot(suppressNewDot, true /* animate */);
            // If nothing changed the animation won't happen
            bv.updateDotVisibility(true /* animate */);
        }
    }

    /**
     * Sets whether the flyout should not appear, even if the notif otherwise would generate one.
     * Calculates the y position of the expanded view when it is expanded.
     */
    void setSuppressFlyout(boolean suppressFlyout) {
        mSuppressFlyout = suppressFlyout;
    float getExpandedViewY() {
        return getStatusBarHeight() + mBubbleSize + mBubblePaddingTop + mPointerHeight;
    }

    /**
     * Callback to run after the flyout hides. Also called if a new flyout is shown before the
     * previous one animates out.
     */
    private Runnable mAfterFlyoutHides;

    /**
     * Animates in the flyout for the given bubble, if available, and then hides it after some time.
     */
@@ -1347,7 +1322,7 @@ public class BubbleStackView extends FrameLayout {
                && !isExpanded()
                && !mIsExpansionAnimating
                && !mIsGestureInProgress
                && !mSuppressFlyout) {
                && bubble.showFlyoutForBubble()) {
            if (bubble.getIconView() != null) {
                // Temporarily suppress the dot while the flyout is visible.
                bubble.getIconView().setSuppressDot(
@@ -1365,20 +1340,20 @@ public class BubbleStackView extends FrameLayout {
                        return;
                    }

                    final boolean suppressDot = !bubble.showBubbleDot();
                    // If we're going to suppress the dot, make it visible first so it'll
                    // visibly animate away.
                    if (mSuppressNewDot) {
                    if (suppressDot) {
                        bubble.getIconView().setSuppressDot(
                                false /* suppressDot */, false /* animate */);
                    }

                    // Reset dot suppression. If we're not suppressing due to DND, then
                    // stop suppressing it with no animation (since the flyout has
                    // transformed into the dot). If we are suppressing due to DND, animate
                    // it away.
                    bubble.getIconView().setSuppressDot(
                            mSuppressNewDot /* suppressDot */,
                            mSuppressNewDot /* animate */);
                            suppressDot /* suppressDot */,
                            suppressDot /* animate */);
                };

                // Post in case layout isn't complete and getWidth returns 0.
+1 −1
Original line number Diff line number Diff line
@@ -176,7 +176,7 @@ public class BubbleView extends FrameLayout {
     * after animation if requested.
     */
    private void updateDotVisibility(boolean animate, Runnable after) {
        boolean showDot = mBubble.showInShadeWhenBubble() && !mSuppressDot;
        boolean showDot = mBubble.showBubbleDot() && !mSuppressDot;

        if (animate) {
            animateDot(showDot, after);
Loading