diff options
11 files changed, 95 insertions, 11 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/data/repository/HeadsUpRepository.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/data/repository/HeadsUpRepository.kt index 069ae9381012..28e39955f0c6 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/data/repository/HeadsUpRepository.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/data/repository/HeadsUpRepository.kt @@ -44,4 +44,10 @@ interface HeadsUpRepository { /** Snooze the currently pinned HUN. */ fun snooze() + + /** Unpin all currently pinned HUNs. */ + fun unpinAll(userUnPinned: Boolean) + + /** Release entries that were waiting for a shade expansion to complete. */ + fun releaseAfterExpansion() } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/domain/interactor/HeadsUpNotificationInteractor.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/domain/interactor/HeadsUpNotificationInteractor.kt index 24b75d49ed16..74ec7edd5398 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/domain/interactor/HeadsUpNotificationInteractor.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/domain/interactor/HeadsUpNotificationInteractor.kt @@ -148,6 +148,16 @@ constructor( fun snooze() { headsUpRepository.snooze() } + + /** Unpin all currently pinned HUNs. */ + fun unpinAll(userUnPinned: Boolean) { + headsUpRepository.unpinAll(userUnPinned) + } + + /** Notifies that the current scene transition is idle. */ + fun onTransitionIdle() { + headsUpRepository.releaseAfterExpansion() + } } class HeadsUpRowInteractor(repository: HeadsUpRowRepository) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java index e8020764bce4..0e4be8ecc920 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java @@ -1721,6 +1721,19 @@ public class NotificationStackScrollLayout if (mTopHeadsUpRow == null) { return 0; } + ExpandableNotificationRow row = getTopHeadsUpRow(); + return row.getPinnedHeadsUpHeight(); + } + + private int getTopHeadsUpIntrinsicHeight() { + if (mTopHeadsUpRow == null) { + return 0; + } + ExpandableNotificationRow row = getTopHeadsUpRow(); + return row.getIntrinsicHeight(); + } + + private ExpandableNotificationRow getTopHeadsUpRow() { ExpandableNotificationRow row = mTopHeadsUpRow; if (row.isChildInGroup()) { final NotificationEntry groupSummary = @@ -1729,7 +1742,7 @@ public class NotificationStackScrollLayout row = groupSummary.getRow(); } } - return row.getPinnedHeadsUpHeight(); + return row; } /** @@ -2511,7 +2524,7 @@ public class NotificationStackScrollLayout @Override public int getTopHeadsUpHeight() { - return getTopHeadsUpPinnedHeight(); + return getTopHeadsUpIntrinsicHeight(); } /** @@ -5732,7 +5745,7 @@ public class NotificationStackScrollLayout return mDisallowScrollingInThisMotion; } - boolean isBeingDragged() { + public boolean isBeingDragged() { return mIsBeingDragged; } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutController.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutController.java index fa12bb99eac2..693e8ffa92ec 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutController.java @@ -2053,7 +2053,6 @@ public class NotificationStackScrollLayoutController implements Dumpable { hunWantsIt = mHeadsUpTouchHelper.onInterceptTouchEvent(ev); if (hunWantsIt) { mView.startDraggingOnHun(); - mHeadsUpManager.unpinAll(true); } } boolean swipeWantsIt = false; diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ui/viewbinder/NotificationScrollViewBinder.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ui/viewbinder/NotificationScrollViewBinder.kt index a30b8772c3d1..950b14d2fafc 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ui/viewbinder/NotificationScrollViewBinder.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ui/viewbinder/NotificationScrollViewBinder.kt @@ -17,6 +17,7 @@ package com.android.systemui.statusbar.notification.stack.ui.viewbinder import android.util.Log +import com.android.app.tracing.coroutines.flow.filter import com.android.systemui.common.ui.ConfigurationState import com.android.systemui.common.ui.view.onLayoutChanged import com.android.systemui.dagger.SysUISingleton @@ -86,6 +87,7 @@ constructor( } launch { viewModel.isScrollable.collect { view.setScrollingEnabled(it) } } launch { viewModel.isDozing.collect { isDozing -> view.setDozing(isDozing) } } + launch { viewModel.shouldResetStackTop.filter { it }.collect { view.setStackTop(0f) } } launchAndDispose { view.setSyntheticScrollConsumer(viewModel.syntheticScrollConsumer) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/NotificationScrollViewModel.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/NotificationScrollViewModel.kt index a20517981f77..6b95e9820a02 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/NotificationScrollViewModel.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/NotificationScrollViewModel.kt @@ -43,6 +43,7 @@ import kotlinx.coroutines.flow.combine import kotlinx.coroutines.flow.distinctUntilChanged import kotlinx.coroutines.flow.flowOf import kotlinx.coroutines.flow.map +import kotlinx.coroutines.flow.mapNotNull /** ViewModel which represents the state of the NSSL/Controller in the world of flexiglass */ class NotificationScrollViewModel @@ -117,6 +118,14 @@ constructor( .distinctUntilChanged() .dumpWhileCollecting("expandFraction") + val shouldResetStackTop: Flow<Boolean> = + sceneInteractor.transitionState + .mapNotNull { state -> + state is ObservableTransitionState.Idle && state.currentScene == Scenes.Gone + } + .distinctUntilChanged() + .dumpWhileCollecting("shouldResetStackTop") + private operator fun SceneKey.contains(scene: SceneKey) = sceneInteractor.isSceneInFamily(scene, this) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/NotificationsPlaceholderViewModel.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/NotificationsPlaceholderViewModel.kt index 2fbb23e30003..ffa1de79b7e4 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/NotificationsPlaceholderViewModel.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/NotificationsPlaceholderViewModel.kt @@ -16,10 +16,12 @@ package com.android.systemui.statusbar.notification.stack.ui.viewmodel +import com.android.compose.animation.scene.ObservableTransitionState import com.android.systemui.dump.DumpManager import com.android.systemui.flags.FeatureFlagsClassic import com.android.systemui.flags.Flags import com.android.systemui.lifecycle.SysUiViewModel +import com.android.systemui.scene.domain.interactor.SceneInteractor import com.android.systemui.scene.shared.flag.SceneContainerFlag import com.android.systemui.shade.domain.interactor.ShadeInteractor import com.android.systemui.statusbar.notification.domain.interactor.HeadsUpNotificationInteractor @@ -30,7 +32,11 @@ import com.android.systemui.util.kotlin.ActivatableFlowDumper import com.android.systemui.util.kotlin.ActivatableFlowDumperImpl import dagger.assisted.AssistedFactory import dagger.assisted.AssistedInject +import kotlinx.coroutines.coroutineScope import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.filter +import kotlinx.coroutines.flow.map +import kotlinx.coroutines.launch /** * ViewModel used by the Notification placeholders inside the scene container to update the @@ -40,7 +46,8 @@ class NotificationsPlaceholderViewModel @AssistedInject constructor( private val interactor: NotificationStackAppearanceInteractor, - shadeInteractor: ShadeInteractor, + private val sceneInteractor: SceneInteractor, + private val shadeInteractor: ShadeInteractor, private val headsUpNotificationInteractor: HeadsUpNotificationInteractor, featureFlags: FeatureFlagsClassic, dumpManager: DumpManager, @@ -58,6 +65,20 @@ constructor( val isDebugLoggingEnabled: Boolean = SceneContainerFlag.isEnabled override suspend fun onActivated(): Nothing { + coroutineScope { + launch { + shadeInteractor.isAnyExpanded + .filter { it } + .collect { headsUpNotificationInteractor.unpinAll(true) } + } + + launch { + sceneInteractor.transitionState + .map { state -> state is ObservableTransitionState.Idle } + .filter { it } + .collect { headsUpNotificationInteractor.onTransitionIdle() } + } + } activateFlowDumper() } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/ui/viewbinder/HeadsUpNotificationViewBinder.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/ui/viewbinder/HeadsUpNotificationViewBinder.kt index 8d73983e4053..dc15970b318b 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/ui/viewbinder/HeadsUpNotificationViewBinder.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/ui/viewbinder/HeadsUpNotificationViewBinder.kt @@ -51,7 +51,9 @@ constructor(private val viewModel: NotificationListViewModel) { } removed.forEach { key -> val row = obtainView(key) - parentView.generateHeadsUpAnimation(row, /* isHeadsUp= */ false) + if (!parentView.isBeingDragged()) { + parentView.generateHeadsUpAnimation(row, /* isHeadsUp= */ false) + } row.markHeadsUpSeen() } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpManagerPhone.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpManagerPhone.java index 544a8a5e5c67..720b257e4006 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpManagerPhone.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpManagerPhone.java @@ -35,6 +35,7 @@ import com.android.systemui.dagger.qualifiers.Main; import com.android.systemui.plugins.statusbar.StatusBarStateController; import com.android.systemui.plugins.statusbar.StatusBarStateController.StateListener; import com.android.systemui.res.R; +import com.android.systemui.scene.shared.flag.SceneContainerFlag; import com.android.systemui.shade.domain.interactor.ShadeInteractor; import com.android.systemui.statusbar.StatusBarState; import com.android.systemui.statusbar.notification.collection.NotificationEntry; @@ -60,6 +61,11 @@ import com.android.systemui.util.kotlin.JavaAdapter; import com.android.systemui.util.settings.GlobalSettings; import com.android.systemui.util.time.SystemClock; +import kotlinx.coroutines.flow.Flow; +import kotlinx.coroutines.flow.MutableStateFlow; +import kotlinx.coroutines.flow.StateFlow; +import kotlinx.coroutines.flow.StateFlowKt; + import java.io.PrintWriter; import java.util.ArrayList; import java.util.HashSet; @@ -70,11 +76,6 @@ import java.util.Stack; import javax.inject.Inject; -import kotlinx.coroutines.flow.Flow; -import kotlinx.coroutines.flow.MutableStateFlow; -import kotlinx.coroutines.flow.StateFlow; -import kotlinx.coroutines.flow.StateFlowKt; - /** A implementation of HeadsUpManager for phone. */ @SysUISingleton public class HeadsUpManagerPhone extends BaseHeadsUpManager implements @@ -251,6 +252,12 @@ public class HeadsUpManagerPhone extends BaseHeadsUpManager implements return entry != null && mSystemClock.elapsedRealtime() < entry.mPostTime; } + @Override + public void releaseAfterExpansion() { + if (SceneContainerFlag.isUnexpectedlyInLegacyMode()) return; + onExpandingFinished(); + } + public void onExpandingFinished() { if (mReleaseOnExpandFinish) { releaseAllImmediately(); @@ -297,6 +304,11 @@ public class HeadsUpManagerPhone extends BaseHeadsUpManager implements } } + @Override + public void unpinAll(boolean userUnPinned) { + super.unpinAll(userUnPinned); + } + /** * Notifies that a remote input textbox in notification gets active or inactive. * diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/notification/stack/data/repository/HeadsUpNotificationRepositoryKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/notification/stack/data/repository/HeadsUpNotificationRepositoryKosmos.kt index 7e8f1a9115ea..1fa623655fcb 100644 --- a/packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/notification/stack/data/repository/HeadsUpNotificationRepositoryKosmos.kt +++ b/packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/notification/stack/data/repository/HeadsUpNotificationRepositoryKosmos.kt @@ -44,6 +44,14 @@ class FakeHeadsUpNotificationRepository : HeadsUpRepository { // do nothing } + override fun unpinAll(userUnPinned: Boolean) { + // do nothing + } + + override fun releaseAfterExpansion() { + // do nothing + } + fun setNotifications(notifications: List<HeadsUpRowRepository>) { this.orderedHeadsUpRows.value = notifications.toList() } diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/NotificationsPlaceholderViewModelKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/NotificationsPlaceholderViewModelKosmos.kt index 3247525f1a36..634354b033ef 100644 --- a/packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/NotificationsPlaceholderViewModelKosmos.kt +++ b/packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/NotificationsPlaceholderViewModelKosmos.kt @@ -20,6 +20,7 @@ import com.android.systemui.dump.dumpManager import com.android.systemui.flags.featureFlagsClassic import com.android.systemui.kosmos.Kosmos import com.android.systemui.kosmos.Kosmos.Fixture +import com.android.systemui.scene.domain.interactor.sceneInteractor import com.android.systemui.shade.domain.interactor.shadeInteractor import com.android.systemui.statusbar.notification.stack.domain.interactor.headsUpNotificationInteractor import com.android.systemui.statusbar.notification.stack.domain.interactor.notificationStackAppearanceInteractor @@ -27,6 +28,7 @@ import com.android.systemui.statusbar.notification.stack.domain.interactor.notif val Kosmos.notificationsPlaceholderViewModel by Fixture { NotificationsPlaceholderViewModel( interactor = notificationStackAppearanceInteractor, + sceneInteractor = sceneInteractor, shadeInteractor = shadeInteractor, headsUpNotificationInteractor = headsUpNotificationInteractor, featureFlags = featureFlagsClassic, |