Loading packages/SystemUI/src/com/android/systemui/statusbar/notification/domain/interactor/HeadsUpNotificationInteractor.kt +59 −36 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ import com.android.systemui.shade.domain.interactor.ShadeInteractor import com.android.systemui.statusbar.notification.data.repository.HeadsUpRepository import com.android.systemui.statusbar.notification.data.repository.HeadsUpRowRepository import com.android.systemui.statusbar.notification.shared.HeadsUpRowKey import com.android.systemui.statusbar.notification.shared.NotificationsHeadsUpRefactor import javax.inject.Inject import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.FlowPreview Loading @@ -50,11 +51,16 @@ constructor( val topHeadsUpRow: Flow<HeadsUpRowKey?> = headsUpRepository.topHeadsUpRow /** Set of currently pinned top-level heads up rows to be displayed. */ val pinnedHeadsUpRows: Flow<Set<HeadsUpRowKey>> = val pinnedHeadsUpRows: Flow<Set<HeadsUpRowKey>> by lazy { if (NotificationsHeadsUpRefactor.isUnexpectedlyInLegacyMode()) { flowOf(emptySet()) } else { headsUpRepository.activeHeadsUpRows.flatMapLatest { repositories -> if (repositories.isNotEmpty()) { val toCombine: List<Flow<Pair<HeadsUpRowRepository, Boolean>>> = repositories.map { repo -> repo.isPinned.map { isPinned -> repo to isPinned } } repositories.map { repo -> repo.isPinned.map { isPinned -> repo to isPinned } } combine(toCombine) { pairs -> pairs.filter { (_, isPinned) -> isPinned }.map { (repo, _) -> repo }.toSet() } Loading @@ -63,9 +69,14 @@ constructor( flowOf(emptySet()) } } } } /** Are there any pinned heads up rows to display? */ val hasPinnedRows: Flow<Boolean> = val hasPinnedRows: Flow<Boolean> by lazy { if (NotificationsHeadsUpRefactor.isUnexpectedlyInLegacyMode()) { flowOf(false) } else { headsUpRepository.activeHeadsUpRows.flatMapLatest { rows -> if (rows.isNotEmpty()) { combine(rows.map { it.isPinned }) { pins -> pins.any { it } } Loading @@ -74,8 +85,13 @@ constructor( flowOf(false) } } } } val isHeadsUpOrAnimatingAway: Flow<Boolean> = val isHeadsUpOrAnimatingAway: Flow<Boolean> by lazy { if (NotificationsHeadsUpRefactor.isUnexpectedlyInLegacyMode()) { flowOf(false) } else { combine(hasPinnedRows, headsUpRepository.isHeadsUpAnimatingAway) { hasPinnedRows, animatingAway -> Loading @@ -92,6 +108,8 @@ constructor( } .onStart { emit(false) } // emit false, so we don't wait for the initial update .distinctUntilChanged() } } private val canShowHeadsUp: Flow<Boolean> = combine( Loading @@ -109,10 +127,15 @@ constructor( } } val showHeadsUpStatusBar: Flow<Boolean> = val showHeadsUpStatusBar: Flow<Boolean> by lazy { if (NotificationsHeadsUpRefactor.isUnexpectedlyInLegacyMode()) { flowOf(false) } else { combine(hasPinnedRows, canShowHeadsUp) { hasPinnedRows, canShowHeadsUp -> hasPinnedRows && canShowHeadsUp } } } fun headsUpRow(key: HeadsUpRowKey): HeadsUpRowInteractor = HeadsUpRowInteractor(key as HeadsUpRowRepository) Loading packages/SystemUI/tests/src/com/android/systemui/statusbar/ui/viewmodel/KeyguardStatusBarViewModelTest.kt +3 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.systemui.statusbar.ui.viewmodel import android.platform.test.annotations.EnableFlags import android.platform.test.flag.junit.FlagsParameterization import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase Loading @@ -32,6 +33,7 @@ import com.android.systemui.scene.domain.interactor.sceneInteractor import com.android.systemui.scene.shared.model.Scenes import com.android.systemui.statusbar.domain.interactor.keyguardStatusBarInteractor import com.android.systemui.statusbar.notification.data.repository.FakeHeadsUpRowRepository import com.android.systemui.statusbar.notification.shared.NotificationsHeadsUpRefactor import com.android.systemui.statusbar.notification.stack.data.repository.headsUpNotificationRepository import com.android.systemui.statusbar.notification.stack.data.repository.setNotifications import com.android.systemui.statusbar.notification.stack.domain.interactor.headsUpNotificationInteractor Loading Loading @@ -126,6 +128,7 @@ class KeyguardStatusBarViewModelTest(flags: FlagsParameterization) : SysuiTestCa } @Test @EnableFlags(NotificationsHeadsUpRefactor.FLAG_NAME) fun isVisible_headsUpStatusBarShown_false() = testScope.runTest { val latest by collectLastValue(underTest.isVisible) Loading Loading
packages/SystemUI/src/com/android/systemui/statusbar/notification/domain/interactor/HeadsUpNotificationInteractor.kt +59 −36 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ import com.android.systemui.shade.domain.interactor.ShadeInteractor import com.android.systemui.statusbar.notification.data.repository.HeadsUpRepository import com.android.systemui.statusbar.notification.data.repository.HeadsUpRowRepository import com.android.systemui.statusbar.notification.shared.HeadsUpRowKey import com.android.systemui.statusbar.notification.shared.NotificationsHeadsUpRefactor import javax.inject.Inject import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.FlowPreview Loading @@ -50,11 +51,16 @@ constructor( val topHeadsUpRow: Flow<HeadsUpRowKey?> = headsUpRepository.topHeadsUpRow /** Set of currently pinned top-level heads up rows to be displayed. */ val pinnedHeadsUpRows: Flow<Set<HeadsUpRowKey>> = val pinnedHeadsUpRows: Flow<Set<HeadsUpRowKey>> by lazy { if (NotificationsHeadsUpRefactor.isUnexpectedlyInLegacyMode()) { flowOf(emptySet()) } else { headsUpRepository.activeHeadsUpRows.flatMapLatest { repositories -> if (repositories.isNotEmpty()) { val toCombine: List<Flow<Pair<HeadsUpRowRepository, Boolean>>> = repositories.map { repo -> repo.isPinned.map { isPinned -> repo to isPinned } } repositories.map { repo -> repo.isPinned.map { isPinned -> repo to isPinned } } combine(toCombine) { pairs -> pairs.filter { (_, isPinned) -> isPinned }.map { (repo, _) -> repo }.toSet() } Loading @@ -63,9 +69,14 @@ constructor( flowOf(emptySet()) } } } } /** Are there any pinned heads up rows to display? */ val hasPinnedRows: Flow<Boolean> = val hasPinnedRows: Flow<Boolean> by lazy { if (NotificationsHeadsUpRefactor.isUnexpectedlyInLegacyMode()) { flowOf(false) } else { headsUpRepository.activeHeadsUpRows.flatMapLatest { rows -> if (rows.isNotEmpty()) { combine(rows.map { it.isPinned }) { pins -> pins.any { it } } Loading @@ -74,8 +85,13 @@ constructor( flowOf(false) } } } } val isHeadsUpOrAnimatingAway: Flow<Boolean> = val isHeadsUpOrAnimatingAway: Flow<Boolean> by lazy { if (NotificationsHeadsUpRefactor.isUnexpectedlyInLegacyMode()) { flowOf(false) } else { combine(hasPinnedRows, headsUpRepository.isHeadsUpAnimatingAway) { hasPinnedRows, animatingAway -> Loading @@ -92,6 +108,8 @@ constructor( } .onStart { emit(false) } // emit false, so we don't wait for the initial update .distinctUntilChanged() } } private val canShowHeadsUp: Flow<Boolean> = combine( Loading @@ -109,10 +127,15 @@ constructor( } } val showHeadsUpStatusBar: Flow<Boolean> = val showHeadsUpStatusBar: Flow<Boolean> by lazy { if (NotificationsHeadsUpRefactor.isUnexpectedlyInLegacyMode()) { flowOf(false) } else { combine(hasPinnedRows, canShowHeadsUp) { hasPinnedRows, canShowHeadsUp -> hasPinnedRows && canShowHeadsUp } } } fun headsUpRow(key: HeadsUpRowKey): HeadsUpRowInteractor = HeadsUpRowInteractor(key as HeadsUpRowRepository) Loading
packages/SystemUI/tests/src/com/android/systemui/statusbar/ui/viewmodel/KeyguardStatusBarViewModelTest.kt +3 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.systemui.statusbar.ui.viewmodel import android.platform.test.annotations.EnableFlags import android.platform.test.flag.junit.FlagsParameterization import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase Loading @@ -32,6 +33,7 @@ import com.android.systemui.scene.domain.interactor.sceneInteractor import com.android.systemui.scene.shared.model.Scenes import com.android.systemui.statusbar.domain.interactor.keyguardStatusBarInteractor import com.android.systemui.statusbar.notification.data.repository.FakeHeadsUpRowRepository import com.android.systemui.statusbar.notification.shared.NotificationsHeadsUpRefactor import com.android.systemui.statusbar.notification.stack.data.repository.headsUpNotificationRepository import com.android.systemui.statusbar.notification.stack.data.repository.setNotifications import com.android.systemui.statusbar.notification.stack.domain.interactor.headsUpNotificationInteractor Loading Loading @@ -126,6 +128,7 @@ class KeyguardStatusBarViewModelTest(flags: FlagsParameterization) : SysuiTestCa } @Test @EnableFlags(NotificationsHeadsUpRefactor.FLAG_NAME) fun isVisible_headsUpStatusBarShown_false() = testScope.runTest { val latest by collectLastValue(underTest.isVisible) Loading