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

Commit 0a6795fe authored by Selim Cinek's avatar Selim Cinek Committed by android-build-merger
Browse files

Merge "Improved the heads up experience when notifications were blocked" into qt-r1-dev

am: fc039930

Change-Id: Id9238aa220d40c2bd4405b35a889e6e78391fc10
parents 6bd2dfad fc039930
Loading
Loading
Loading
Loading
+23 −15
Original line number Diff line number Diff line
@@ -64,7 +64,6 @@ class NotificationWakeUpCoordinator @Inject constructor(
    private var mVisibilityAnimator: ObjectAnimator? = null
    private var mVisibilityAmount = 0.0f
    private var mLinearVisibilityAmount = 0.0f
    private var mWakingUp = false
    private val mEntrySetToClearWhenFinished = mutableSetOf<NotificationEntry>()
    private val mDozeParameters: DozeParameters
    private var pulseExpanding: Boolean = false
@@ -73,6 +72,25 @@ class NotificationWakeUpCoordinator @Inject constructor(

    var fullyAwake: Boolean = false

    var wakingUp = false
        set(value) {
            field = value
            willWakeUp = false
            if (value) {
                if (mNotificationsVisible && !mNotificationsVisibleForExpansion
                        && !bypassController.bypassEnabled) {
                    // We're waking up while pulsing, let's make sure the animation looks nice
                    mStackScroller.wakeUpFromPulse();
                }
                if (bypassController.bypassEnabled && !mNotificationsVisible) {
                    // Let's make sure our huns become visible once we are waking up in case
                    // they were blocked by the proximity sensor
                    updateNotificationVisibility(animate = shouldAnimateVisibility(),
                            increaseSpeed = false)
                }
            }
        }

    var willWakeUp = false
        set(value) {
            if (!value || mDozeAmount != 0.0f) {
@@ -112,7 +130,7 @@ class NotificationWakeUpCoordinator @Inject constructor(
            var canShow = pulsing
            if (bypassController.bypassEnabled) {
                // We also allow pulsing on the lock screen!
                canShow = canShow || (mWakingUp || willWakeUp || fullyAwake)
                canShow = canShow || (wakingUp || willWakeUp || fullyAwake)
                        && statusBarStateController.state == StatusBarState.KEYGUARD
            }
            return canShow
@@ -160,7 +178,7 @@ class NotificationWakeUpCoordinator @Inject constructor(
        wakeUpListeners.add(listener);
    }

    fun removeFullyHiddenChangedListener(listener: WakeUpListener) {
    fun removeListener(listener: WakeUpListener) {
        wakeUpListeners.remove(listener);
    }

@@ -169,7 +187,7 @@ class NotificationWakeUpCoordinator @Inject constructor(
        var visible = mNotificationsVisibleForExpansion || mHeadsUpManagerPhone.hasNotifications()
        visible = visible && canShowPulsingHuns

        if (!visible && mNotificationsVisible && (mWakingUp || willWakeUp) && mDozeAmount != 0.0f) {
        if (!visible && mNotificationsVisible && (wakingUp || willWakeUp) && mDozeAmount != 0.0f) {
            // let's not make notifications invisible while waking up, otherwise the animation
            // is strange
            return;
@@ -307,16 +325,6 @@ class NotificationWakeUpCoordinator @Inject constructor(
        return if (bypassController.bypassEnabled) 0.0f else overflow
    }

    fun setWakingUp(wakingUp: Boolean) {
        willWakeUp = false
        mWakingUp = wakingUp
        if (wakingUp && mNotificationsVisible && !mNotificationsVisibleForExpansion
                && !bypassController.bypassEnabled) {
            // We're waking up while pulsing, let's make sure the animation looks nice
            mStackScroller.wakeUpFromPulse();
        }
    }

    override fun onHeadsUpStateChanged(entry: NotificationEntry, isHeadsUp: Boolean) {
        var animate = shouldAnimateVisibility()
        if (!isHeadsUp) {
@@ -325,7 +333,7 @@ class NotificationWakeUpCoordinator @Inject constructor(
                    // if we animate, we see the shelf briefly visible. Instead we fully animate
                    // the notification and its background out
                    animate = false
                } else if (!mWakingUp && !willWakeUp){
                } else if (!wakingUp && !willWakeUp){
                    // TODO: look that this is done properly and not by anyone else
                    entry.setHeadsUpAnimatingAway(true)
                    mEntrySetToClearWhenFinished.add(entry)
+24 −14
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@ import com.android.systemui.statusbar.CrossFadeHelper;
import com.android.systemui.statusbar.HeadsUpStatusBarView;
import com.android.systemui.statusbar.StatusBarState;
import com.android.systemui.statusbar.SysuiStatusBarStateController;
import com.android.systemui.statusbar.notification.NotificationWakeUpCoordinator;
import com.android.systemui.statusbar.notification.collection.NotificationEntry;
import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow;
import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout;
@@ -48,7 +49,7 @@ import java.util.function.Consumer;
 * Controls the appearance of heads up notifications in the icon area and the header itself.
 */
public class HeadsUpAppearanceController implements OnHeadsUpChangedListener,
        DarkIconDispatcher.DarkReceiver {
        DarkIconDispatcher.DarkReceiver, NotificationWakeUpCoordinator.WakeUpListener {
    public static final int CONTENT_FADE_DURATION = 110;
    public static final int CONTENT_FADE_DELAY = 100;
    private final NotificationIconAreaController mNotificationIconAreaController;
@@ -67,6 +68,7 @@ public class HeadsUpAppearanceController implements OnHeadsUpChangedListener,
    private final KeyguardBypassController mBypassController;
    private final StatusBarStateController mStatusBarStateController;
    private final CommandQueue mCommandQueue;
    private final NotificationWakeUpCoordinator mWakeUpCoordinator;
    @VisibleForTesting
    float mExpandedHeight;
    @VisibleForTesting
@@ -95,9 +97,10 @@ public class HeadsUpAppearanceController implements OnHeadsUpChangedListener,
            HeadsUpManagerPhone headsUpManager,
            View statusbarView,
            SysuiStatusBarStateController statusBarStateController,
            KeyguardBypassController keyguardBypassController) {
            KeyguardBypassController keyguardBypassController,
            NotificationWakeUpCoordinator wakeUpCoordinator) {
        this(notificationIconAreaController, headsUpManager, statusBarStateController,
                keyguardBypassController,
                keyguardBypassController, wakeUpCoordinator,
                statusbarView.findViewById(R.id.heads_up_status_bar_view),
                statusbarView.findViewById(R.id.notification_stack_scroller),
                statusbarView.findViewById(R.id.notification_panel),
@@ -112,6 +115,7 @@ public class HeadsUpAppearanceController implements OnHeadsUpChangedListener,
            HeadsUpManagerPhone headsUpManager,
            StatusBarStateController stateController,
            KeyguardBypassController bypassController,
            NotificationWakeUpCoordinator wakeUpCoordinator,
            HeadsUpStatusBarView headsUpStatusBarView,
            NotificationStackScrollLayout stackScroller,
            NotificationPanelView panelView,
@@ -153,6 +157,8 @@ public class HeadsUpAppearanceController implements OnHeadsUpChangedListener,
        });
        mBypassController = bypassController;
        mStatusBarStateController = stateController;
        mWakeUpCoordinator = wakeUpCoordinator;
        wakeUpCoordinator.addListener(this);
        mCommandQueue = getComponent(headsUpStatusBarView.getContext(), CommandQueue.class);
        mKeyguardMonitor = Dependency.get(KeyguardMonitor.class);
    }
@@ -161,6 +167,7 @@ public class HeadsUpAppearanceController implements OnHeadsUpChangedListener,
    public void destroy() {
        mHeadsUpManager.removeListener(this);
        mHeadsUpStatusBarView.setOnDrawingRectChangedListener(null);
        mWakeUpCoordinator.removeListener(this);
        mPanelView.removeTrackingHeadsUpListener(mSetTrackingHeadsUp);
        mPanelView.removeVerticalTranslationListener(mUpdatePanelTranslation);
        mPanelView.setHeadsUpAppearanceController(null);
@@ -289,6 +296,11 @@ public class HeadsUpAppearanceController implements OnHeadsUpChangedListener,
                    updateParentClipping(true /* shouldClip */);
                });
            }
            // Show the status bar icons when the view gets shown / hidden
            if (mStatusBarStateController.getState() != StatusBarState.SHADE) {
                mCommandQueue.recomputeDisableFlags(
                        mHeadsUpStatusBarView.getContext().getDisplayId(), false);
            }
        }
    }

@@ -362,10 +374,12 @@ public class HeadsUpAppearanceController implements OnHeadsUpChangedListener,
     * @return if the heads up status bar view should be shown
     */
    public boolean shouldBeVisible() {
        boolean canShow = !mIsExpanded;
        boolean notificationsShown = !mWakeUpCoordinator.getNotificationsFullyHidden();
        boolean canShow = !mIsExpanded && notificationsShown;
        if (mBypassController.getBypassEnabled() &&
                (mStatusBarStateController.getState() == StatusBarState.KEYGUARD
                        || mKeyguardMonitor.isKeyguardGoingAway())) {
                        || mKeyguardMonitor.isKeyguardGoingAway())
                && notificationsShown) {
            canShow = true;
        }
        return canShow && mHeadsUpManager.hasPinnedHeadsUp();
@@ -377,15 +391,6 @@ public class HeadsUpAppearanceController implements OnHeadsUpChangedListener,
        updateHeader(entry);
    }

    @Override
    public void onHeadsUpPinnedModeChanged(boolean inPinnedMode) {
        if (mStatusBarStateController.getState() != StatusBarState.SHADE) {
            // Show the status bar icons when the pinned mode changes
            mCommandQueue.recomputeDisableFlags(
                    mHeadsUpStatusBarView.getContext().getDisplayId(), false);
        }
    }

    public void setAppearFraction(float expandedHeight, float appearFraction) {
        boolean changed = expandedHeight != mExpandedHeight;
        mExpandedHeight = expandedHeight;
@@ -451,4 +456,9 @@ public class HeadsUpAppearanceController implements OnHeadsUpChangedListener,
            mAppearFraction = oldController.mAppearFraction;
        }
    }

    @Override
    public void onFullyHiddenChanged(boolean isFullyHidden) {
        updateTopEntry();
    }
}
+1 −1
Original line number Diff line number Diff line
@@ -217,7 +217,7 @@ public class LockIcon extends KeyguardAffordanceView implements OnUserInfoChange
        mConfigurationController.removeCallback(this);
        mKeyguardUpdateMonitor.removeCallback(mUpdateMonitorCallback);
        mKeyguardMonitor.removeCallback(mKeyguardMonitorCallback);
        mWakeUpCoordinator.removeFullyHiddenChangedListener(this);
        mWakeUpCoordinator.removeListener(this);
        mUnlockMethodCache.removeListener(this);
        if (mDockManager != null) {
            mDockManager.removeListener(mDockEventListener);
+5 −0
Original line number Diff line number Diff line
@@ -453,6 +453,11 @@ public class NotificationPanelView extends PanelView implements
        mQsFrame = findViewById(R.id.qs_frame);
        mPulseExpansionHandler.setUp(mNotificationStackScroller, this, mShadeController);
        mWakeUpCoordinator.addListener(new NotificationWakeUpCoordinator.WakeUpListener() {
            @Override
            public void onFullyHiddenChanged(boolean isFullyHidden) {
                updateKeyguardStatusBarForHeadsUp();
            }

            @Override
            public void onPulseExpansionChanged(boolean expandingChanged) {
                if (mKeyguardBypassController.getBypassEnabled()) {
+2 −1
Original line number Diff line number Diff line
@@ -856,7 +856,8 @@ public class StatusBar extends SystemUI implements DemoMode,
                    }
                    mHeadsUpAppearanceController = new HeadsUpAppearanceController(
                            mNotificationIconAreaController, mHeadsUpManager, mStatusBarWindow,
                            mStatusBarStateController, mKeyguardBypassController);
                            mStatusBarStateController, mKeyguardBypassController,
                            mWakeUpCoordinator);
                    mHeadsUpAppearanceController.readFrom(oldController);
                    mStatusBarWindow.setStatusBarView(mStatusBarView);
                    updateAreThereNotifications();
Loading