Loading packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/icon/ui/viewmodel/NotificationIconContainerStatusBarViewModelTest.kt +21 −42 Original line number Diff line number Diff line Loading @@ -110,14 +110,10 @@ class NotificationIconContainerStatusBarViewModelTest(flags: FlagsParameterizati lastSleepReason = WakeSleepReason.OTHER, ) keyguardTransitionRepository.sendTransitionStep( TransitionStep( transitionState = TransitionState.STARTED, ) TransitionStep(transitionState = TransitionState.STARTED) ) keyguardRepository.setDozeTransitionModel( DozeTransitionModel( to = DozeStateModel.DOZE_AOD, ) DozeTransitionModel(to = DozeStateModel.DOZE_AOD) ) val animationsEnabled by collectLastValue(underTest.animationsEnabled) runCurrent() Loading @@ -133,14 +129,10 @@ class NotificationIconContainerStatusBarViewModelTest(flags: FlagsParameterizati lastSleepReason = WakeSleepReason.OTHER, ) keyguardTransitionRepository.sendTransitionStep( TransitionStep( transitionState = TransitionState.STARTED, ) TransitionStep(transitionState = TransitionState.STARTED) ) keyguardRepository.setDozeTransitionModel( DozeTransitionModel( to = DozeStateModel.DOZE_PULSING, ) DozeTransitionModel(to = DozeStateModel.DOZE_PULSING) ) val animationsEnabled by collectLastValue(underTest.animationsEnabled) runCurrent() Loading Loading @@ -201,9 +193,7 @@ class NotificationIconContainerStatusBarViewModelTest(flags: FlagsParameterizati lastSleepReason = WakeSleepReason.OTHER, ) keyguardTransitionRepository.sendTransitionStep( TransitionStep( transitionState = TransitionState.STARTED, ) TransitionStep(transitionState = TransitionState.STARTED) ) val animationsEnabled by collectLastValue(underTest.animationsEnabled) runCurrent() Loading @@ -216,9 +206,7 @@ class NotificationIconContainerStatusBarViewModelTest(flags: FlagsParameterizati val animationsEnabled by collectLastValue(underTest.animationsEnabled) keyguardTransitionRepository.sendTransitionStep( TransitionStep( transitionState = TransitionState.STARTED, ) TransitionStep(transitionState = TransitionState.STARTED) ) keyguardRepository.setKeyguardShowing(true) runCurrent() Loading @@ -234,13 +222,10 @@ class NotificationIconContainerStatusBarViewModelTest(flags: FlagsParameterizati @Test fun iconColors_testsDarkBounds() = testScope.runTest { darkIconRepository.darkState.value = SysuiDarkIconDispatcher.DarkChange( emptyList(), 0f, 0xAABBCC, ) val iconColorsLookup by collectLastValue(underTest.iconColors) val displayId = 123 darkIconRepository.darkState(displayId).value = SysuiDarkIconDispatcher.DarkChange(emptyList(), 0f, 0xAABBCC) val iconColorsLookup by collectLastValue(underTest.iconColors(displayId)) assertThat(iconColorsLookup).isNotNull() val iconColors = iconColorsLookup?.iconColors(Rect()) Loading @@ -257,13 +242,10 @@ class NotificationIconContainerStatusBarViewModelTest(flags: FlagsParameterizati @Test fun iconColors_staticDrawableColor_notInDarkTintArea() = testScope.runTest { darkIconRepository.darkState.value = SysuiDarkIconDispatcher.DarkChange( listOf(Rect(0, 0, 5, 5)), 0f, 0xAABBCC, ) val iconColorsLookup by collectLastValue(underTest.iconColors) val displayId = 321 darkIconRepository.darkState(displayId).value = SysuiDarkIconDispatcher.DarkChange(listOf(Rect(0, 0, 5, 5)), 0f, 0xAABBCC) val iconColorsLookup by collectLastValue(underTest.iconColors(displayId)) val iconColors = iconColorsLookup?.iconColors(Rect(1, 1, 4, 4)) val staticDrawableColor = iconColors?.staticDrawableColor(Rect(6, 6, 7, 7)) assertThat(staticDrawableColor).isEqualTo(DarkIconDispatcher.DEFAULT_ICON_TINT) Loading @@ -272,13 +254,10 @@ class NotificationIconContainerStatusBarViewModelTest(flags: FlagsParameterizati @Test fun iconColors_notInDarkTintArea() = testScope.runTest { darkIconRepository.darkState.value = SysuiDarkIconDispatcher.DarkChange( listOf(Rect(0, 0, 5, 5)), 0f, 0xAABBCC, ) val iconColorsLookup by collectLastValue(underTest.iconColors) val displayId = 987 darkIconRepository.darkState(displayId).value = SysuiDarkIconDispatcher.DarkChange(listOf(Rect(0, 0, 5, 5)), 0f, 0xAABBCC) val iconColorsLookup by collectLastValue(underTest.iconColors(displayId)) val iconColors = iconColorsLookup?.iconColors(Rect(6, 6, 7, 7)) assertThat(iconColors).isNull() } Loading @@ -295,7 +274,7 @@ class NotificationIconContainerStatusBarViewModelTest(flags: FlagsParameterizati activeNotificationModel( key = "notif1", groupKey = "group", statusBarIcon = icon statusBarIcon = icon, ) ) } Loading @@ -322,7 +301,7 @@ class NotificationIconContainerStatusBarViewModelTest(flags: FlagsParameterizati activeNotificationModel( key = "notif1", groupKey = "group", statusBarIcon = icon statusBarIcon = icon, ) ) } Loading Loading @@ -354,7 +333,7 @@ class NotificationIconContainerStatusBarViewModelTest(flags: FlagsParameterizati activeNotificationModel( key = "notif1", groupKey = "group", statusBarIcon = icon statusBarIcon = icon, ) ) } Loading packages/SystemUI/src/com/android/systemui/statusbar/notification/icon/ui/viewbinder/NotificationIconContainerStatusBarViewBinder.kt +2 −1 Original line number Diff line number Diff line Loading @@ -40,11 +40,12 @@ constructor( private val failureTracker: StatusBarIconViewBindingFailureTracker, private val viewStore: StatusBarNotificationIconViewStore, ) { fun bindWhileAttached(view: NotificationIconContainer): DisposableHandle { fun bindWhileAttached(view: NotificationIconContainer, displayId: Int): DisposableHandle { return traceSection("NICStatusBar#bindWhileAttached") { view.repeatWhenAttached { lifecycleScope.launch { NotificationIconContainerViewBinder.bind( displayId = displayId, view = view, viewModel = viewModel, configuration = configuration, Loading packages/SystemUI/src/com/android/systemui/statusbar/notification/icon/ui/viewbinder/NotificationIconContainerViewBinder.kt +11 −15 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ import android.widget.FrameLayout import androidx.annotation.ColorInt import androidx.collection.ArrayMap import androidx.lifecycle.lifecycleScope import com.android.app.tracing.coroutines.launchTraced as launch import com.android.app.tracing.traceSection import com.android.internal.R as RInternal import com.android.internal.statusbar.StatusBarIcon Loading Loading @@ -54,12 +55,12 @@ import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.combine import kotlinx.coroutines.flow.mapNotNull import kotlinx.coroutines.flow.stateIn import com.android.app.tracing.coroutines.launchTraced as launch /** Binds a view-model to a [NotificationIconContainer]. */ object NotificationIconContainerViewBinder { suspend fun bind( displayId: Int, view: NotificationIconContainer, viewModel: NotificationIconContainerStatusBarViewModel, configuration: ConfigurationState, Loading @@ -70,7 +71,10 @@ object NotificationIconContainerViewBinder { launch { val contrastColorUtil = ContrastColorUtil.getInstance(view.context) val iconColors: StateFlow<NotificationIconColors> = viewModel.iconColors.mapNotNull { it.iconColors(view.viewBounds) }.stateIn(this) viewModel .iconColors(displayId) .mapNotNull { it.iconColors(view.viewBounds) } .stateIn(this) viewModel.icons.bindIcons( logTag = "statusbar", view = view, Loading @@ -79,11 +83,7 @@ object NotificationIconContainerViewBinder { notifyBindingFailures = { failureTracker.statusBarFailures = it }, viewStore = viewStore, ) { _, sbiv -> StatusBarIconViewBinder.bindIconColors( sbiv, iconColors, contrastColorUtil, ) StatusBarIconViewBinder.bindIconColors(sbiv, iconColors, contrastColorUtil) } } launch { viewModel.bindIsolatedIcon(view, viewStore) } Loading Loading @@ -194,8 +194,7 @@ object NotificationIconContainerViewBinder { combine(iconSizeFlow, iconHorizontalPaddingFlow, systemBarUtilsState.statusBarHeight) { iconSize, iconHPadding, statusBarHeight, -> statusBarHeight -> FrameLayout.LayoutParams(iconSize + 2 * iconHPadding, statusBarHeight) } .stateIn(this) Loading Loading @@ -251,10 +250,7 @@ object NotificationIconContainerViewBinder { traceSection("addIcon") { (sbiv.parent as? ViewGroup)?.run { if (this !== view) { Log.wtf( TAG, "[$logTag] SBIV($notifKey) has an unexpected parent", ) Log.wtf(TAG, "[$logTag] SBIV($notifKey) has an unexpected parent") } // If the container was re-inflated and re-bound, then SBIVs might still // be attached to the prior view. Loading @@ -271,7 +267,7 @@ object NotificationIconContainerViewBinder { launch { launch { layoutParams.collectTracingEach( tag = { "[$logTag] SBIV#bindLayoutParams" }, tag = { "[$logTag] SBIV#bindLayoutParams" } ) { if (it != sbiv.layoutParams) { sbiv.layoutParams = it Loading Loading @@ -344,7 +340,7 @@ object NotificationIconContainerViewBinder { // a single SBIV instance for the group. Then this whole concept can go away. private inline fun <R> NotificationIconContainer.withIconReplacements( replacements: ArrayMap<String, StatusBarIcon>, block: () -> R block: () -> R, ): R { setReplacingIcons(replacements) return block().also { setReplacingIcons(null) } Loading packages/SystemUI/src/com/android/systemui/statusbar/notification/icon/ui/viewmodel/NotificationIconContainerStatusBarViewModel.kt +10 −12 Original line number Diff line number Diff line Loading @@ -45,8 +45,8 @@ import kotlinx.coroutines.flow.map class NotificationIconContainerStatusBarViewModel @Inject constructor( @Background bgContext: CoroutineContext, darkIconInteractor: DarkIconInteractor, @Background private val bgContext: CoroutineContext, private val darkIconInteractor: DarkIconInteractor, iconsInteractor: StatusBarNotificationIconsInteractor, headsUpIconInteractor: HeadsUpNotificationIconInteractor, keyguardInteractor: KeyguardInteractor, Loading @@ -58,10 +58,9 @@ constructor( /** Are changes to the icon container animated? */ val animationsEnabled: Flow<Boolean> = combine( shadeInteractor.isShadeTouchable, keyguardInteractor.isKeyguardShowing, ) { panelTouchesEnabled, isKeyguardShowing -> combine(shadeInteractor.isShadeTouchable, keyguardInteractor.isKeyguardShowing) { panelTouchesEnabled, isKeyguardShowing -> panelTouchesEnabled && !isKeyguardShowing } .flowOn(bgContext) Loading @@ -69,8 +68,9 @@ constructor( .distinctUntilChanged() /** The colors with which to display the notification icons. */ val iconColors: Flow<NotificationIconColorLookup> = darkIconInteractor.darkState fun iconColors(displayId: Int): Flow<NotificationIconColorLookup> = darkIconInteractor .darkState(displayId) .map { (areas: Collection<Rect>, tint: Int) -> NotificationIconColorLookup { viewBounds: Rect -> if (DarkIconDispatcher.isInAreas(areas, viewBounds)) { Loading Loading @@ -125,10 +125,8 @@ constructor( val isolatedIconLocation: Flow<Rect> = headsUpIconInteractor.isolatedIconLocation.filterNotNull().conflate().distinctUntilChanged() private class IconColorsImpl( override val tint: Int, private val areas: Collection<Rect>, ) : NotificationIconColors { private class IconColorsImpl(override val tint: Int, private val areas: Collection<Rect>) : NotificationIconColors { override fun staticDrawableColor(viewBounds: Rect): Int { return if (DarkIconDispatcher.isInAreas(areas, viewBounds)) { tint Loading packages/SystemUI/src/com/android/systemui/statusbar/phone/data/repository/DarkIconRepository.kt +6 −6 Original line number Diff line number Diff line Loading @@ -16,7 +16,7 @@ package com.android.systemui.statusbar.phone.data.repository import com.android.systemui.dagger.SysUISingleton import com.android.systemui.statusbar.phone.SysuiDarkIconDispatcher import com.android.systemui.statusbar.data.repository.SysuiDarkIconDispatcherStore import com.android.systemui.statusbar.phone.SysuiDarkIconDispatcher.DarkChange import dagger.Binds import dagger.Module Loading @@ -25,16 +25,16 @@ import kotlinx.coroutines.flow.StateFlow /** Dark-mode state for tinting icons. */ interface DarkIconRepository { val darkState: StateFlow<DarkChange> fun darkState(displayId: Int): StateFlow<DarkChange> } @SysUISingleton class DarkIconRepositoryImpl @Inject constructor( darkIconDispatcher: SysuiDarkIconDispatcher, ) : DarkIconRepository { override val darkState: StateFlow<DarkChange> = darkIconDispatcher.darkChangeFlow() constructor(private val darkIconDispatcherStore: SysuiDarkIconDispatcherStore) : DarkIconRepository { override fun darkState(displayId: Int): StateFlow<DarkChange> = darkIconDispatcherStore.forDisplay(displayId).darkChangeFlow() } @Module Loading Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/icon/ui/viewmodel/NotificationIconContainerStatusBarViewModelTest.kt +21 −42 Original line number Diff line number Diff line Loading @@ -110,14 +110,10 @@ class NotificationIconContainerStatusBarViewModelTest(flags: FlagsParameterizati lastSleepReason = WakeSleepReason.OTHER, ) keyguardTransitionRepository.sendTransitionStep( TransitionStep( transitionState = TransitionState.STARTED, ) TransitionStep(transitionState = TransitionState.STARTED) ) keyguardRepository.setDozeTransitionModel( DozeTransitionModel( to = DozeStateModel.DOZE_AOD, ) DozeTransitionModel(to = DozeStateModel.DOZE_AOD) ) val animationsEnabled by collectLastValue(underTest.animationsEnabled) runCurrent() Loading @@ -133,14 +129,10 @@ class NotificationIconContainerStatusBarViewModelTest(flags: FlagsParameterizati lastSleepReason = WakeSleepReason.OTHER, ) keyguardTransitionRepository.sendTransitionStep( TransitionStep( transitionState = TransitionState.STARTED, ) TransitionStep(transitionState = TransitionState.STARTED) ) keyguardRepository.setDozeTransitionModel( DozeTransitionModel( to = DozeStateModel.DOZE_PULSING, ) DozeTransitionModel(to = DozeStateModel.DOZE_PULSING) ) val animationsEnabled by collectLastValue(underTest.animationsEnabled) runCurrent() Loading Loading @@ -201,9 +193,7 @@ class NotificationIconContainerStatusBarViewModelTest(flags: FlagsParameterizati lastSleepReason = WakeSleepReason.OTHER, ) keyguardTransitionRepository.sendTransitionStep( TransitionStep( transitionState = TransitionState.STARTED, ) TransitionStep(transitionState = TransitionState.STARTED) ) val animationsEnabled by collectLastValue(underTest.animationsEnabled) runCurrent() Loading @@ -216,9 +206,7 @@ class NotificationIconContainerStatusBarViewModelTest(flags: FlagsParameterizati val animationsEnabled by collectLastValue(underTest.animationsEnabled) keyguardTransitionRepository.sendTransitionStep( TransitionStep( transitionState = TransitionState.STARTED, ) TransitionStep(transitionState = TransitionState.STARTED) ) keyguardRepository.setKeyguardShowing(true) runCurrent() Loading @@ -234,13 +222,10 @@ class NotificationIconContainerStatusBarViewModelTest(flags: FlagsParameterizati @Test fun iconColors_testsDarkBounds() = testScope.runTest { darkIconRepository.darkState.value = SysuiDarkIconDispatcher.DarkChange( emptyList(), 0f, 0xAABBCC, ) val iconColorsLookup by collectLastValue(underTest.iconColors) val displayId = 123 darkIconRepository.darkState(displayId).value = SysuiDarkIconDispatcher.DarkChange(emptyList(), 0f, 0xAABBCC) val iconColorsLookup by collectLastValue(underTest.iconColors(displayId)) assertThat(iconColorsLookup).isNotNull() val iconColors = iconColorsLookup?.iconColors(Rect()) Loading @@ -257,13 +242,10 @@ class NotificationIconContainerStatusBarViewModelTest(flags: FlagsParameterizati @Test fun iconColors_staticDrawableColor_notInDarkTintArea() = testScope.runTest { darkIconRepository.darkState.value = SysuiDarkIconDispatcher.DarkChange( listOf(Rect(0, 0, 5, 5)), 0f, 0xAABBCC, ) val iconColorsLookup by collectLastValue(underTest.iconColors) val displayId = 321 darkIconRepository.darkState(displayId).value = SysuiDarkIconDispatcher.DarkChange(listOf(Rect(0, 0, 5, 5)), 0f, 0xAABBCC) val iconColorsLookup by collectLastValue(underTest.iconColors(displayId)) val iconColors = iconColorsLookup?.iconColors(Rect(1, 1, 4, 4)) val staticDrawableColor = iconColors?.staticDrawableColor(Rect(6, 6, 7, 7)) assertThat(staticDrawableColor).isEqualTo(DarkIconDispatcher.DEFAULT_ICON_TINT) Loading @@ -272,13 +254,10 @@ class NotificationIconContainerStatusBarViewModelTest(flags: FlagsParameterizati @Test fun iconColors_notInDarkTintArea() = testScope.runTest { darkIconRepository.darkState.value = SysuiDarkIconDispatcher.DarkChange( listOf(Rect(0, 0, 5, 5)), 0f, 0xAABBCC, ) val iconColorsLookup by collectLastValue(underTest.iconColors) val displayId = 987 darkIconRepository.darkState(displayId).value = SysuiDarkIconDispatcher.DarkChange(listOf(Rect(0, 0, 5, 5)), 0f, 0xAABBCC) val iconColorsLookup by collectLastValue(underTest.iconColors(displayId)) val iconColors = iconColorsLookup?.iconColors(Rect(6, 6, 7, 7)) assertThat(iconColors).isNull() } Loading @@ -295,7 +274,7 @@ class NotificationIconContainerStatusBarViewModelTest(flags: FlagsParameterizati activeNotificationModel( key = "notif1", groupKey = "group", statusBarIcon = icon statusBarIcon = icon, ) ) } Loading @@ -322,7 +301,7 @@ class NotificationIconContainerStatusBarViewModelTest(flags: FlagsParameterizati activeNotificationModel( key = "notif1", groupKey = "group", statusBarIcon = icon statusBarIcon = icon, ) ) } Loading Loading @@ -354,7 +333,7 @@ class NotificationIconContainerStatusBarViewModelTest(flags: FlagsParameterizati activeNotificationModel( key = "notif1", groupKey = "group", statusBarIcon = icon statusBarIcon = icon, ) ) } Loading
packages/SystemUI/src/com/android/systemui/statusbar/notification/icon/ui/viewbinder/NotificationIconContainerStatusBarViewBinder.kt +2 −1 Original line number Diff line number Diff line Loading @@ -40,11 +40,12 @@ constructor( private val failureTracker: StatusBarIconViewBindingFailureTracker, private val viewStore: StatusBarNotificationIconViewStore, ) { fun bindWhileAttached(view: NotificationIconContainer): DisposableHandle { fun bindWhileAttached(view: NotificationIconContainer, displayId: Int): DisposableHandle { return traceSection("NICStatusBar#bindWhileAttached") { view.repeatWhenAttached { lifecycleScope.launch { NotificationIconContainerViewBinder.bind( displayId = displayId, view = view, viewModel = viewModel, configuration = configuration, Loading
packages/SystemUI/src/com/android/systemui/statusbar/notification/icon/ui/viewbinder/NotificationIconContainerViewBinder.kt +11 −15 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ import android.widget.FrameLayout import androidx.annotation.ColorInt import androidx.collection.ArrayMap import androidx.lifecycle.lifecycleScope import com.android.app.tracing.coroutines.launchTraced as launch import com.android.app.tracing.traceSection import com.android.internal.R as RInternal import com.android.internal.statusbar.StatusBarIcon Loading Loading @@ -54,12 +55,12 @@ import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.combine import kotlinx.coroutines.flow.mapNotNull import kotlinx.coroutines.flow.stateIn import com.android.app.tracing.coroutines.launchTraced as launch /** Binds a view-model to a [NotificationIconContainer]. */ object NotificationIconContainerViewBinder { suspend fun bind( displayId: Int, view: NotificationIconContainer, viewModel: NotificationIconContainerStatusBarViewModel, configuration: ConfigurationState, Loading @@ -70,7 +71,10 @@ object NotificationIconContainerViewBinder { launch { val contrastColorUtil = ContrastColorUtil.getInstance(view.context) val iconColors: StateFlow<NotificationIconColors> = viewModel.iconColors.mapNotNull { it.iconColors(view.viewBounds) }.stateIn(this) viewModel .iconColors(displayId) .mapNotNull { it.iconColors(view.viewBounds) } .stateIn(this) viewModel.icons.bindIcons( logTag = "statusbar", view = view, Loading @@ -79,11 +83,7 @@ object NotificationIconContainerViewBinder { notifyBindingFailures = { failureTracker.statusBarFailures = it }, viewStore = viewStore, ) { _, sbiv -> StatusBarIconViewBinder.bindIconColors( sbiv, iconColors, contrastColorUtil, ) StatusBarIconViewBinder.bindIconColors(sbiv, iconColors, contrastColorUtil) } } launch { viewModel.bindIsolatedIcon(view, viewStore) } Loading Loading @@ -194,8 +194,7 @@ object NotificationIconContainerViewBinder { combine(iconSizeFlow, iconHorizontalPaddingFlow, systemBarUtilsState.statusBarHeight) { iconSize, iconHPadding, statusBarHeight, -> statusBarHeight -> FrameLayout.LayoutParams(iconSize + 2 * iconHPadding, statusBarHeight) } .stateIn(this) Loading Loading @@ -251,10 +250,7 @@ object NotificationIconContainerViewBinder { traceSection("addIcon") { (sbiv.parent as? ViewGroup)?.run { if (this !== view) { Log.wtf( TAG, "[$logTag] SBIV($notifKey) has an unexpected parent", ) Log.wtf(TAG, "[$logTag] SBIV($notifKey) has an unexpected parent") } // If the container was re-inflated and re-bound, then SBIVs might still // be attached to the prior view. Loading @@ -271,7 +267,7 @@ object NotificationIconContainerViewBinder { launch { launch { layoutParams.collectTracingEach( tag = { "[$logTag] SBIV#bindLayoutParams" }, tag = { "[$logTag] SBIV#bindLayoutParams" } ) { if (it != sbiv.layoutParams) { sbiv.layoutParams = it Loading Loading @@ -344,7 +340,7 @@ object NotificationIconContainerViewBinder { // a single SBIV instance for the group. Then this whole concept can go away. private inline fun <R> NotificationIconContainer.withIconReplacements( replacements: ArrayMap<String, StatusBarIcon>, block: () -> R block: () -> R, ): R { setReplacingIcons(replacements) return block().also { setReplacingIcons(null) } Loading
packages/SystemUI/src/com/android/systemui/statusbar/notification/icon/ui/viewmodel/NotificationIconContainerStatusBarViewModel.kt +10 −12 Original line number Diff line number Diff line Loading @@ -45,8 +45,8 @@ import kotlinx.coroutines.flow.map class NotificationIconContainerStatusBarViewModel @Inject constructor( @Background bgContext: CoroutineContext, darkIconInteractor: DarkIconInteractor, @Background private val bgContext: CoroutineContext, private val darkIconInteractor: DarkIconInteractor, iconsInteractor: StatusBarNotificationIconsInteractor, headsUpIconInteractor: HeadsUpNotificationIconInteractor, keyguardInteractor: KeyguardInteractor, Loading @@ -58,10 +58,9 @@ constructor( /** Are changes to the icon container animated? */ val animationsEnabled: Flow<Boolean> = combine( shadeInteractor.isShadeTouchable, keyguardInteractor.isKeyguardShowing, ) { panelTouchesEnabled, isKeyguardShowing -> combine(shadeInteractor.isShadeTouchable, keyguardInteractor.isKeyguardShowing) { panelTouchesEnabled, isKeyguardShowing -> panelTouchesEnabled && !isKeyguardShowing } .flowOn(bgContext) Loading @@ -69,8 +68,9 @@ constructor( .distinctUntilChanged() /** The colors with which to display the notification icons. */ val iconColors: Flow<NotificationIconColorLookup> = darkIconInteractor.darkState fun iconColors(displayId: Int): Flow<NotificationIconColorLookup> = darkIconInteractor .darkState(displayId) .map { (areas: Collection<Rect>, tint: Int) -> NotificationIconColorLookup { viewBounds: Rect -> if (DarkIconDispatcher.isInAreas(areas, viewBounds)) { Loading Loading @@ -125,10 +125,8 @@ constructor( val isolatedIconLocation: Flow<Rect> = headsUpIconInteractor.isolatedIconLocation.filterNotNull().conflate().distinctUntilChanged() private class IconColorsImpl( override val tint: Int, private val areas: Collection<Rect>, ) : NotificationIconColors { private class IconColorsImpl(override val tint: Int, private val areas: Collection<Rect>) : NotificationIconColors { override fun staticDrawableColor(viewBounds: Rect): Int { return if (DarkIconDispatcher.isInAreas(areas, viewBounds)) { tint Loading
packages/SystemUI/src/com/android/systemui/statusbar/phone/data/repository/DarkIconRepository.kt +6 −6 Original line number Diff line number Diff line Loading @@ -16,7 +16,7 @@ package com.android.systemui.statusbar.phone.data.repository import com.android.systemui.dagger.SysUISingleton import com.android.systemui.statusbar.phone.SysuiDarkIconDispatcher import com.android.systemui.statusbar.data.repository.SysuiDarkIconDispatcherStore import com.android.systemui.statusbar.phone.SysuiDarkIconDispatcher.DarkChange import dagger.Binds import dagger.Module Loading @@ -25,16 +25,16 @@ import kotlinx.coroutines.flow.StateFlow /** Dark-mode state for tinting icons. */ interface DarkIconRepository { val darkState: StateFlow<DarkChange> fun darkState(displayId: Int): StateFlow<DarkChange> } @SysUISingleton class DarkIconRepositoryImpl @Inject constructor( darkIconDispatcher: SysuiDarkIconDispatcher, ) : DarkIconRepository { override val darkState: StateFlow<DarkChange> = darkIconDispatcher.darkChangeFlow() constructor(private val darkIconDispatcherStore: SysuiDarkIconDispatcherStore) : DarkIconRepository { override fun darkState(displayId: Int): StateFlow<DarkChange> = darkIconDispatcherStore.forDisplay(displayId).darkChangeFlow() } @Module Loading