Loading packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/view/layout/sections/SmartspaceSectionTest.kt +4 −2 Original line number Original line Diff line number Diff line Loading @@ -37,8 +37,6 @@ import com.android.systemui.plugins.clocks.ClockViewIds import com.android.systemui.res.R import com.android.systemui.res.R import com.android.systemui.shared.R as sharedR import com.android.systemui.shared.R as sharedR import com.android.systemui.statusbar.lockscreen.LockscreenSmartspaceController import com.android.systemui.statusbar.lockscreen.LockscreenSmartspaceController import com.android.systemui.util.mockito.any import com.android.systemui.util.mockito.whenever import com.google.common.truth.Truth.assertThat import com.google.common.truth.Truth.assertThat import dagger.Lazy import dagger.Lazy import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.MutableStateFlow Loading @@ -47,6 +45,8 @@ import org.junit.Test import org.junit.runner.RunWith import org.junit.runner.RunWith import org.mockito.Mock import org.mockito.Mock import org.mockito.MockitoAnnotations import org.mockito.MockitoAnnotations import org.mockito.kotlin.any import org.mockito.kotlin.whenever @RunWith(AndroidJUnit4::class) @RunWith(AndroidJUnit4::class) @SmallTest @SmallTest Loading @@ -72,6 +72,7 @@ class SmartspaceSectionTest : SysuiTestCase() { private val shouldDateWeatherBeBelowSmallClock = MutableStateFlow(true) private val shouldDateWeatherBeBelowSmallClock = MutableStateFlow(true) private val isWeatherVisibleFlow = MutableStateFlow(false) private val isWeatherVisibleFlow = MutableStateFlow(false) private val isShadeLayoutWide = MutableStateFlow(false) private val isShadeLayoutWide = MutableStateFlow(false) private val isLargeClockVisible = MutableStateFlow(true) @Before @Before fun setup() { fun setup() { Loading @@ -96,6 +97,7 @@ class SmartspaceSectionTest : SysuiTestCase() { .thenReturn(dateView) .thenReturn(dateView) whenever(keyguardClockViewModel.hasCustomWeatherDataDisplay) whenever(keyguardClockViewModel.hasCustomWeatherDataDisplay) .thenReturn(hasCustomWeatherDataDisplay) .thenReturn(hasCustomWeatherDataDisplay) whenever(keyguardClockViewModel.isLargeClockVisible).thenReturn(isLargeClockVisible) whenever(keyguardClockViewModel.shouldDateWeatherBeBelowSmallClock) whenever(keyguardClockViewModel.shouldDateWeatherBeBelowSmallClock) .thenReturn(shouldDateWeatherBeBelowSmallClock) .thenReturn(shouldDateWeatherBeBelowSmallClock) whenever(keyguardClockViewModel.clockShouldBeCentered).thenReturn(clockShouldBeCentered) whenever(keyguardClockViewModel.clockShouldBeCentered).thenReturn(clockShouldBeCentered) Loading packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardSmartspaceViewModelTest.kt +85 −0 Original line number Original line Diff line number Diff line Loading @@ -68,6 +68,21 @@ class KeyguardSmartspaceViewModelTest : SysuiTestCase() { assertThat(isWeatherVisible).isEqualTo(true) assertThat(isWeatherVisible).isEqualTo(true) } } @Test fun testWhenWeatherEnabled_notCustomWeatherDataDisplay_isWeatherVisible_smallClock_shouldBeTrue() = testScope.runTest { val isWeatherVisible by collectLastValue(underTest.isWeatherVisible) whenever(clockController.smallClock.config.hasCustomWeatherDataDisplay) .thenReturn(false) with(kosmos) { keyguardSmartspaceRepository.setIsWeatherEnabled(true) keyguardClockRepository.setClockSize(ClockSize.SMALL) } assertThat(isWeatherVisible).isEqualTo(true) } @Test @Test fun testWhenWeatherEnabled_hasCustomWeatherDataDisplay_isWeatherVisible_shouldBeFalse() = fun testWhenWeatherEnabled_hasCustomWeatherDataDisplay_isWeatherVisible_shouldBeFalse() = testScope.runTest { testScope.runTest { Loading @@ -82,6 +97,20 @@ class KeyguardSmartspaceViewModelTest : SysuiTestCase() { assertThat(isWeatherVisible).isEqualTo(false) assertThat(isWeatherVisible).isEqualTo(false) } } @Test fun testWhenWeatherEnabled_hasCustomWeatherDataDisplay_isWeatherVisible_smallClock_shouldBeTrue() = testScope.runTest { val isWeatherVisible by collectLastValue(underTest.isWeatherVisible) whenever(clockController.smallClock.config.hasCustomWeatherDataDisplay).thenReturn(true) with(kosmos) { keyguardSmartspaceRepository.setIsWeatherEnabled(true) keyguardClockRepository.setClockSize(ClockSize.SMALL) } assertThat(isWeatherVisible).isEqualTo(true) } @Test @Test fun testWhenWeatherEnabled_notCustomWeatherDataDisplay_notIsWeatherVisible_shouldBeFalse() = fun testWhenWeatherEnabled_notCustomWeatherDataDisplay_notIsWeatherVisible_shouldBeFalse() = testScope.runTest { testScope.runTest { Loading @@ -97,6 +126,62 @@ class KeyguardSmartspaceViewModelTest : SysuiTestCase() { assertThat(isWeatherVisible).isEqualTo(false) assertThat(isWeatherVisible).isEqualTo(false) } } @Test fun isDateVisible_notCustomWeatherDataDisplay_largeClock_shouldBeTrue() = testScope.runTest { val isDateVisible by collectLastValue(underTest.isDateVisible) whenever(clockController.largeClock.config.hasCustomWeatherDataDisplay) .thenReturn(false) with(kosmos) { keyguardClockRepository.setClockSize(ClockSize.LARGE) } assertThat(isDateVisible).isEqualTo(true) } @Test fun isDateVisible_hasCustomWeatherDataDisplay_largeClock_shouldBeFalse() = testScope.runTest { val isDateVisible by collectLastValue(underTest.isDateVisible) whenever(clockController.largeClock.config.hasCustomWeatherDataDisplay) .thenReturn(true) with(kosmos) { keyguardClockRepository.setClockSize(ClockSize.LARGE) } assertThat(isDateVisible).isEqualTo(false) } @Test fun isDateVisible_hasCustomWeatherDataDisplay_smallClock_shouldBeTrue() = testScope.runTest { val isDateVisible by collectLastValue(underTest.isDateVisible) whenever(clockController.smallClock.config.hasCustomWeatherDataDisplay) .thenReturn(true) with(kosmos) { keyguardClockRepository.setClockSize(ClockSize.SMALL) } assertThat(isDateVisible).isEqualTo(true) } @Test fun isDateVisible_notCustomWeatherDataDisplay_smallClock_shouldBeTrue() = testScope.runTest { val isDateVisible by collectLastValue(underTest.isDateVisible) whenever(clockController.smallClock.config.hasCustomWeatherDataDisplay) .thenReturn(false) with(kosmos) { keyguardClockRepository.setClockSize(ClockSize.SMALL) } assertThat(isDateVisible).isEqualTo(true) } @Test @Test fun isShadeLayoutWide_withConfigTrue_true() = fun isShadeLayoutWide_withConfigTrue_true() = with(kosmos) { with(kosmos) { Loading packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardSmartspaceViewBinder.kt +17 −24 Original line number Original line Diff line number Diff line Loading @@ -53,7 +53,9 @@ object KeyguardSmartspaceViewBinder { ::Pair, ::Pair, ) ) .collect { .collect { if (!com.android.systemui.shared.Flags.clockReactiveSmartspaceLayout()) { if ( !com.android.systemui.shared.Flags.clockReactiveSmartspaceLayout() ) { updateDateWeatherToBurnInLayer( updateDateWeatherToBurnInLayer( keyguardRootView, keyguardRootView, clockViewModel, clockViewModel, Loading Loading @@ -97,15 +99,9 @@ object KeyguardSmartspaceViewBinder { val largeViewId = sharedR.id.date_smartspace_view_large val largeViewId = sharedR.id.date_smartspace_view_large launch("$TAG#smartspaceViewModel.burnInLayerVisibility") { launch("$TAG#smartspaceViewModel.isLargeClockVisible") { combine( clockViewModel.isLargeClockVisible.collect { isLargeClock -> keyguardRootViewModel.burnInLayerVisibility, if (isLargeClock) { clockViewModel.isLargeClockVisible, clockViewModel.hasCustomWeatherDataDisplay, ::Triple, ) .collect { (visibility, isLargeClock, hasCustomWeatherDataDisplay) -> if (isLargeClock || hasCustomWeatherDataDisplay) { // hide small clock date/weather // hide small clock date/weather keyguardRootView.findViewById<View>(smallViewId)?.let { keyguardRootView.findViewById<View>(smallViewId)?.let { it.visibility = View.GONE it.visibility = View.GONE Loading @@ -115,10 +111,7 @@ object KeyguardSmartspaceViewBinder { smartspaceViewModel, smartspaceViewModel, ) ) } else { } else { addDateWeatherToBurnInLayer( addDateWeatherToBurnInLayer(keyguardRootView, smartspaceViewModel) keyguardRootView, smartspaceViewModel, ) } } clockViewModel.burnInLayer?.updatePostLayout(keyguardRootView) clockViewModel.burnInLayer?.updatePostLayout(keyguardRootView) } } Loading packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/SmartspaceSection.kt +17 −17 Original line number Original line Diff line number Diff line Loading @@ -38,6 +38,7 @@ import com.android.systemui.keyguard.ui.viewmodel.KeyguardSmartspaceViewModel import com.android.systemui.plugins.clocks.ClockViewIds import com.android.systemui.plugins.clocks.ClockViewIds import com.android.systemui.res.R as R import com.android.systemui.res.R as R import com.android.systemui.shade.ShadeDisplayAware import com.android.systemui.shade.ShadeDisplayAware import com.android.systemui.shared.Flags.clockReactiveSmartspaceLayout import com.android.systemui.shared.R as sharedR import com.android.systemui.shared.R as sharedR import com.android.systemui.statusbar.lockscreen.LockscreenSmartspaceController import com.android.systemui.statusbar.lockscreen.LockscreenSmartspaceController import dagger.Lazy import dagger.Lazy Loading Loading @@ -80,7 +81,7 @@ constructor( smartspaceController.buildAndConnectDateView(constraintLayout, false) as? LinearLayout smartspaceController.buildAndConnectDateView(constraintLayout, false) as? LinearLayout pastVisibility = smartspaceView?.visibility ?: View.GONE pastVisibility = smartspaceView?.visibility ?: View.GONE constraintLayout.addView(smartspaceView) constraintLayout.addView(smartspaceView) if (com.android.systemui.shared.Flags.clockReactiveSmartspaceLayout()) { if (clockReactiveSmartspaceLayout()) { val weatherViewLargeClock = val weatherViewLargeClock = smartspaceController.buildAndConnectWeatherView(constraintLayout, true) smartspaceController.buildAndConnectWeatherView(constraintLayout, true) dateViewLargeClock = dateViewLargeClock = Loading Loading @@ -136,7 +137,8 @@ constructor( KeyguardSmartspaceViewModel.getSmartspaceHorizontalMargin(context) KeyguardSmartspaceViewModel.getSmartspaceHorizontalMargin(context) val dateWeatherBelowSmallClock = val dateWeatherBelowSmallClock = keyguardClockViewModel.shouldDateWeatherBeBelowSmallClock.value keyguardClockViewModel.shouldDateWeatherBeBelowSmallClock.value if (com.android.systemui.shared.Flags.clockReactiveSmartspaceLayout()) { val isLargeClockVisible = keyguardClockViewModel.isLargeClockVisible.value if (clockReactiveSmartspaceLayout()) { if (dateWeatherBelowSmallClock) { if (dateWeatherBelowSmallClock) { dateView?.orientation = LinearLayout.HORIZONTAL dateView?.orientation = LinearLayout.HORIZONTAL } else { } else { Loading Loading @@ -173,7 +175,7 @@ constructor( ConstraintSet.END, ConstraintSet.END, smartspaceHorizontalPadding, smartspaceHorizontalPadding, ) ) if (keyguardClockViewModel.hasCustomWeatherDataDisplay.value) { if (keyguardClockViewModel.hasCustomWeatherDataDisplay.value && isLargeClockVisible) { clear(sharedR.id.date_smartspace_view, ConstraintSet.TOP) clear(sharedR.id.date_smartspace_view, ConstraintSet.TOP) connect( connect( sharedR.id.date_smartspace_view, sharedR.id.date_smartspace_view, Loading @@ -183,7 +185,7 @@ constructor( ) ) } else { } else { clear(sharedR.id.date_smartspace_view, ConstraintSet.BOTTOM) clear(sharedR.id.date_smartspace_view, ConstraintSet.BOTTOM) if (com.android.systemui.shared.Flags.clockReactiveSmartspaceLayout()) { if (clockReactiveSmartspaceLayout()) { if (dateWeatherBelowSmallClock) { if (dateWeatherBelowSmallClock) { connect( connect( sharedR.id.date_smartspace_view, sharedR.id.date_smartspace_view, Loading Loading @@ -221,8 +223,8 @@ constructor( } } } } if (com.android.systemui.shared.Flags.clockReactiveSmartspaceLayout()) { if (clockReactiveSmartspaceLayout()) { if (keyguardClockViewModel.isLargeClockVisible.value) { if (isLargeClockVisible) { setVisibility(sharedR.id.date_smartspace_view, GONE) setVisibility(sharedR.id.date_smartspace_view, GONE) constrainHeight( constrainHeight( sharedR.id.date_smartspace_view_large, sharedR.id.date_smartspace_view_large, Loading Loading @@ -302,7 +304,7 @@ constructor( } } } } if (com.android.systemui.shared.Flags.clockReactiveSmartspaceLayout()) { if (clockReactiveSmartspaceLayout()) { if (dateWeatherBelowSmallClock) { if (dateWeatherBelowSmallClock) { createBarrier( createBarrier( R.id.smart_space_barrier_bottom, R.id.smart_space_barrier_bottom, Loading Loading @@ -345,14 +347,14 @@ constructor( ) ) } } } } updateVisibility(constraintSet) updateVisibility(constraintSet, isLargeClockVisible) } } override fun removeViews(constraintLayout: ConstraintLayout) { override fun removeViews(constraintLayout: ConstraintLayout) { if (!keyguardSmartspaceViewModel.isSmartspaceEnabled) return if (!keyguardSmartspaceViewModel.isSmartspaceEnabled) return val list = val list = if (com.android.systemui.shared.Flags.clockReactiveSmartspaceLayout()) { if (clockReactiveSmartspaceLayout()) { listOf(smartspaceView, dateView, dateViewLargeClock) listOf(smartspaceView, dateView, dateViewLargeClock) } else { } else { listOf(smartspaceView, dateView) listOf(smartspaceView, dateView) Loading @@ -370,16 +372,13 @@ constructor( disposableHandle?.dispose() disposableHandle?.dispose() } } private fun updateVisibility(constraintSet: ConstraintSet) { private fun updateVisibility(constraintSet: ConstraintSet, isLargeClockVisible: Boolean) { // This may update the visibility of the smartspace views // This may update the visibility of the smartspace views smartspaceController.requestSmartspaceUpdate() smartspaceController.requestSmartspaceUpdate() val weatherId: Int val weatherId: Int val dateId: Int val dateId: Int if ( if (clockReactiveSmartspaceLayout() && isLargeClockVisible) { com.android.systemui.shared.Flags.clockReactiveSmartspaceLayout() && keyguardClockViewModel.isLargeClockVisible.value ) { weatherId = sharedR.id.weather_smartspace_view_large weatherId = sharedR.id.weather_smartspace_view_large dateId = sharedR.id.date_smartspace_view_large dateId = sharedR.id.date_smartspace_view_large } else { } else { Loading @@ -392,12 +391,13 @@ constructor( setVisibility(weatherId, if (showWeather) VISIBLE else GONE) setVisibility(weatherId, if (showWeather) VISIBLE else GONE) setAlpha(weatherId, if (showWeather) 1f else 0f) setAlpha(weatherId, if (showWeather) 1f else 0f) val showDateView = !keyguardClockViewModel.hasCustomWeatherDataDisplay.value val showDateView = !keyguardClockViewModel.hasCustomWeatherDataDisplay.value || !isLargeClockVisible setVisibility(dateId, if (showDateView) VISIBLE else GONE) setVisibility(dateId, if (showDateView) VISIBLE else GONE) setAlpha(dateId, if (showDateView) 1f else 0f) setAlpha(dateId, if (showDateView) 1f else 0f) if (com.android.systemui.shared.Flags.clockReactiveSmartspaceLayout()) { if (clockReactiveSmartspaceLayout()) { if (keyguardClockViewModel.isLargeClockVisible.value) { if (isLargeClockVisible) { setVisibility(sharedR.id.date_smartspace_view, GONE) setVisibility(sharedR.id.date_smartspace_view, GONE) } else { } else { setVisibility(sharedR.id.date_smartspace_view_large, GONE) setVisibility(sharedR.id.date_smartspace_view_large, GONE) Loading packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/transitions/ClockSizeTransition.kt +1 −1 Original line number Original line Diff line number Diff line Loading @@ -408,7 +408,7 @@ class ClockSizeTransition( override fun mutateTargets(from: Target, to: Target) { override fun mutateTargets(from: Target, to: Target) { if (to.view.id == sharedR.id.date_smartspace_view) { if (to.view.id == sharedR.id.date_smartspace_view) { to.isVisible = !viewModel.hasCustomWeatherDataDisplay.value to.isVisible = !viewModel.hasCustomWeatherDataDisplay.value || !isLargeClock to.visibility = if (to.isVisible) View.VISIBLE else View.GONE to.visibility = if (to.isVisible) View.VISIBLE else View.GONE to.alpha = if (to.isVisible) 1f else 0f to.alpha = if (to.isVisible) 1f else 0f } } Loading Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/view/layout/sections/SmartspaceSectionTest.kt +4 −2 Original line number Original line Diff line number Diff line Loading @@ -37,8 +37,6 @@ import com.android.systemui.plugins.clocks.ClockViewIds import com.android.systemui.res.R import com.android.systemui.res.R import com.android.systemui.shared.R as sharedR import com.android.systemui.shared.R as sharedR import com.android.systemui.statusbar.lockscreen.LockscreenSmartspaceController import com.android.systemui.statusbar.lockscreen.LockscreenSmartspaceController import com.android.systemui.util.mockito.any import com.android.systemui.util.mockito.whenever import com.google.common.truth.Truth.assertThat import com.google.common.truth.Truth.assertThat import dagger.Lazy import dagger.Lazy import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.MutableStateFlow Loading @@ -47,6 +45,8 @@ import org.junit.Test import org.junit.runner.RunWith import org.junit.runner.RunWith import org.mockito.Mock import org.mockito.Mock import org.mockito.MockitoAnnotations import org.mockito.MockitoAnnotations import org.mockito.kotlin.any import org.mockito.kotlin.whenever @RunWith(AndroidJUnit4::class) @RunWith(AndroidJUnit4::class) @SmallTest @SmallTest Loading @@ -72,6 +72,7 @@ class SmartspaceSectionTest : SysuiTestCase() { private val shouldDateWeatherBeBelowSmallClock = MutableStateFlow(true) private val shouldDateWeatherBeBelowSmallClock = MutableStateFlow(true) private val isWeatherVisibleFlow = MutableStateFlow(false) private val isWeatherVisibleFlow = MutableStateFlow(false) private val isShadeLayoutWide = MutableStateFlow(false) private val isShadeLayoutWide = MutableStateFlow(false) private val isLargeClockVisible = MutableStateFlow(true) @Before @Before fun setup() { fun setup() { Loading @@ -96,6 +97,7 @@ class SmartspaceSectionTest : SysuiTestCase() { .thenReturn(dateView) .thenReturn(dateView) whenever(keyguardClockViewModel.hasCustomWeatherDataDisplay) whenever(keyguardClockViewModel.hasCustomWeatherDataDisplay) .thenReturn(hasCustomWeatherDataDisplay) .thenReturn(hasCustomWeatherDataDisplay) whenever(keyguardClockViewModel.isLargeClockVisible).thenReturn(isLargeClockVisible) whenever(keyguardClockViewModel.shouldDateWeatherBeBelowSmallClock) whenever(keyguardClockViewModel.shouldDateWeatherBeBelowSmallClock) .thenReturn(shouldDateWeatherBeBelowSmallClock) .thenReturn(shouldDateWeatherBeBelowSmallClock) whenever(keyguardClockViewModel.clockShouldBeCentered).thenReturn(clockShouldBeCentered) whenever(keyguardClockViewModel.clockShouldBeCentered).thenReturn(clockShouldBeCentered) Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardSmartspaceViewModelTest.kt +85 −0 Original line number Original line Diff line number Diff line Loading @@ -68,6 +68,21 @@ class KeyguardSmartspaceViewModelTest : SysuiTestCase() { assertThat(isWeatherVisible).isEqualTo(true) assertThat(isWeatherVisible).isEqualTo(true) } } @Test fun testWhenWeatherEnabled_notCustomWeatherDataDisplay_isWeatherVisible_smallClock_shouldBeTrue() = testScope.runTest { val isWeatherVisible by collectLastValue(underTest.isWeatherVisible) whenever(clockController.smallClock.config.hasCustomWeatherDataDisplay) .thenReturn(false) with(kosmos) { keyguardSmartspaceRepository.setIsWeatherEnabled(true) keyguardClockRepository.setClockSize(ClockSize.SMALL) } assertThat(isWeatherVisible).isEqualTo(true) } @Test @Test fun testWhenWeatherEnabled_hasCustomWeatherDataDisplay_isWeatherVisible_shouldBeFalse() = fun testWhenWeatherEnabled_hasCustomWeatherDataDisplay_isWeatherVisible_shouldBeFalse() = testScope.runTest { testScope.runTest { Loading @@ -82,6 +97,20 @@ class KeyguardSmartspaceViewModelTest : SysuiTestCase() { assertThat(isWeatherVisible).isEqualTo(false) assertThat(isWeatherVisible).isEqualTo(false) } } @Test fun testWhenWeatherEnabled_hasCustomWeatherDataDisplay_isWeatherVisible_smallClock_shouldBeTrue() = testScope.runTest { val isWeatherVisible by collectLastValue(underTest.isWeatherVisible) whenever(clockController.smallClock.config.hasCustomWeatherDataDisplay).thenReturn(true) with(kosmos) { keyguardSmartspaceRepository.setIsWeatherEnabled(true) keyguardClockRepository.setClockSize(ClockSize.SMALL) } assertThat(isWeatherVisible).isEqualTo(true) } @Test @Test fun testWhenWeatherEnabled_notCustomWeatherDataDisplay_notIsWeatherVisible_shouldBeFalse() = fun testWhenWeatherEnabled_notCustomWeatherDataDisplay_notIsWeatherVisible_shouldBeFalse() = testScope.runTest { testScope.runTest { Loading @@ -97,6 +126,62 @@ class KeyguardSmartspaceViewModelTest : SysuiTestCase() { assertThat(isWeatherVisible).isEqualTo(false) assertThat(isWeatherVisible).isEqualTo(false) } } @Test fun isDateVisible_notCustomWeatherDataDisplay_largeClock_shouldBeTrue() = testScope.runTest { val isDateVisible by collectLastValue(underTest.isDateVisible) whenever(clockController.largeClock.config.hasCustomWeatherDataDisplay) .thenReturn(false) with(kosmos) { keyguardClockRepository.setClockSize(ClockSize.LARGE) } assertThat(isDateVisible).isEqualTo(true) } @Test fun isDateVisible_hasCustomWeatherDataDisplay_largeClock_shouldBeFalse() = testScope.runTest { val isDateVisible by collectLastValue(underTest.isDateVisible) whenever(clockController.largeClock.config.hasCustomWeatherDataDisplay) .thenReturn(true) with(kosmos) { keyguardClockRepository.setClockSize(ClockSize.LARGE) } assertThat(isDateVisible).isEqualTo(false) } @Test fun isDateVisible_hasCustomWeatherDataDisplay_smallClock_shouldBeTrue() = testScope.runTest { val isDateVisible by collectLastValue(underTest.isDateVisible) whenever(clockController.smallClock.config.hasCustomWeatherDataDisplay) .thenReturn(true) with(kosmos) { keyguardClockRepository.setClockSize(ClockSize.SMALL) } assertThat(isDateVisible).isEqualTo(true) } @Test fun isDateVisible_notCustomWeatherDataDisplay_smallClock_shouldBeTrue() = testScope.runTest { val isDateVisible by collectLastValue(underTest.isDateVisible) whenever(clockController.smallClock.config.hasCustomWeatherDataDisplay) .thenReturn(false) with(kosmos) { keyguardClockRepository.setClockSize(ClockSize.SMALL) } assertThat(isDateVisible).isEqualTo(true) } @Test @Test fun isShadeLayoutWide_withConfigTrue_true() = fun isShadeLayoutWide_withConfigTrue_true() = with(kosmos) { with(kosmos) { Loading
packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardSmartspaceViewBinder.kt +17 −24 Original line number Original line Diff line number Diff line Loading @@ -53,7 +53,9 @@ object KeyguardSmartspaceViewBinder { ::Pair, ::Pair, ) ) .collect { .collect { if (!com.android.systemui.shared.Flags.clockReactiveSmartspaceLayout()) { if ( !com.android.systemui.shared.Flags.clockReactiveSmartspaceLayout() ) { updateDateWeatherToBurnInLayer( updateDateWeatherToBurnInLayer( keyguardRootView, keyguardRootView, clockViewModel, clockViewModel, Loading Loading @@ -97,15 +99,9 @@ object KeyguardSmartspaceViewBinder { val largeViewId = sharedR.id.date_smartspace_view_large val largeViewId = sharedR.id.date_smartspace_view_large launch("$TAG#smartspaceViewModel.burnInLayerVisibility") { launch("$TAG#smartspaceViewModel.isLargeClockVisible") { combine( clockViewModel.isLargeClockVisible.collect { isLargeClock -> keyguardRootViewModel.burnInLayerVisibility, if (isLargeClock) { clockViewModel.isLargeClockVisible, clockViewModel.hasCustomWeatherDataDisplay, ::Triple, ) .collect { (visibility, isLargeClock, hasCustomWeatherDataDisplay) -> if (isLargeClock || hasCustomWeatherDataDisplay) { // hide small clock date/weather // hide small clock date/weather keyguardRootView.findViewById<View>(smallViewId)?.let { keyguardRootView.findViewById<View>(smallViewId)?.let { it.visibility = View.GONE it.visibility = View.GONE Loading @@ -115,10 +111,7 @@ object KeyguardSmartspaceViewBinder { smartspaceViewModel, smartspaceViewModel, ) ) } else { } else { addDateWeatherToBurnInLayer( addDateWeatherToBurnInLayer(keyguardRootView, smartspaceViewModel) keyguardRootView, smartspaceViewModel, ) } } clockViewModel.burnInLayer?.updatePostLayout(keyguardRootView) clockViewModel.burnInLayer?.updatePostLayout(keyguardRootView) } } Loading
packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/SmartspaceSection.kt +17 −17 Original line number Original line Diff line number Diff line Loading @@ -38,6 +38,7 @@ import com.android.systemui.keyguard.ui.viewmodel.KeyguardSmartspaceViewModel import com.android.systemui.plugins.clocks.ClockViewIds import com.android.systemui.plugins.clocks.ClockViewIds import com.android.systemui.res.R as R import com.android.systemui.res.R as R import com.android.systemui.shade.ShadeDisplayAware import com.android.systemui.shade.ShadeDisplayAware import com.android.systemui.shared.Flags.clockReactiveSmartspaceLayout import com.android.systemui.shared.R as sharedR import com.android.systemui.shared.R as sharedR import com.android.systemui.statusbar.lockscreen.LockscreenSmartspaceController import com.android.systemui.statusbar.lockscreen.LockscreenSmartspaceController import dagger.Lazy import dagger.Lazy Loading Loading @@ -80,7 +81,7 @@ constructor( smartspaceController.buildAndConnectDateView(constraintLayout, false) as? LinearLayout smartspaceController.buildAndConnectDateView(constraintLayout, false) as? LinearLayout pastVisibility = smartspaceView?.visibility ?: View.GONE pastVisibility = smartspaceView?.visibility ?: View.GONE constraintLayout.addView(smartspaceView) constraintLayout.addView(smartspaceView) if (com.android.systemui.shared.Flags.clockReactiveSmartspaceLayout()) { if (clockReactiveSmartspaceLayout()) { val weatherViewLargeClock = val weatherViewLargeClock = smartspaceController.buildAndConnectWeatherView(constraintLayout, true) smartspaceController.buildAndConnectWeatherView(constraintLayout, true) dateViewLargeClock = dateViewLargeClock = Loading Loading @@ -136,7 +137,8 @@ constructor( KeyguardSmartspaceViewModel.getSmartspaceHorizontalMargin(context) KeyguardSmartspaceViewModel.getSmartspaceHorizontalMargin(context) val dateWeatherBelowSmallClock = val dateWeatherBelowSmallClock = keyguardClockViewModel.shouldDateWeatherBeBelowSmallClock.value keyguardClockViewModel.shouldDateWeatherBeBelowSmallClock.value if (com.android.systemui.shared.Flags.clockReactiveSmartspaceLayout()) { val isLargeClockVisible = keyguardClockViewModel.isLargeClockVisible.value if (clockReactiveSmartspaceLayout()) { if (dateWeatherBelowSmallClock) { if (dateWeatherBelowSmallClock) { dateView?.orientation = LinearLayout.HORIZONTAL dateView?.orientation = LinearLayout.HORIZONTAL } else { } else { Loading Loading @@ -173,7 +175,7 @@ constructor( ConstraintSet.END, ConstraintSet.END, smartspaceHorizontalPadding, smartspaceHorizontalPadding, ) ) if (keyguardClockViewModel.hasCustomWeatherDataDisplay.value) { if (keyguardClockViewModel.hasCustomWeatherDataDisplay.value && isLargeClockVisible) { clear(sharedR.id.date_smartspace_view, ConstraintSet.TOP) clear(sharedR.id.date_smartspace_view, ConstraintSet.TOP) connect( connect( sharedR.id.date_smartspace_view, sharedR.id.date_smartspace_view, Loading @@ -183,7 +185,7 @@ constructor( ) ) } else { } else { clear(sharedR.id.date_smartspace_view, ConstraintSet.BOTTOM) clear(sharedR.id.date_smartspace_view, ConstraintSet.BOTTOM) if (com.android.systemui.shared.Flags.clockReactiveSmartspaceLayout()) { if (clockReactiveSmartspaceLayout()) { if (dateWeatherBelowSmallClock) { if (dateWeatherBelowSmallClock) { connect( connect( sharedR.id.date_smartspace_view, sharedR.id.date_smartspace_view, Loading Loading @@ -221,8 +223,8 @@ constructor( } } } } if (com.android.systemui.shared.Flags.clockReactiveSmartspaceLayout()) { if (clockReactiveSmartspaceLayout()) { if (keyguardClockViewModel.isLargeClockVisible.value) { if (isLargeClockVisible) { setVisibility(sharedR.id.date_smartspace_view, GONE) setVisibility(sharedR.id.date_smartspace_view, GONE) constrainHeight( constrainHeight( sharedR.id.date_smartspace_view_large, sharedR.id.date_smartspace_view_large, Loading Loading @@ -302,7 +304,7 @@ constructor( } } } } if (com.android.systemui.shared.Flags.clockReactiveSmartspaceLayout()) { if (clockReactiveSmartspaceLayout()) { if (dateWeatherBelowSmallClock) { if (dateWeatherBelowSmallClock) { createBarrier( createBarrier( R.id.smart_space_barrier_bottom, R.id.smart_space_barrier_bottom, Loading Loading @@ -345,14 +347,14 @@ constructor( ) ) } } } } updateVisibility(constraintSet) updateVisibility(constraintSet, isLargeClockVisible) } } override fun removeViews(constraintLayout: ConstraintLayout) { override fun removeViews(constraintLayout: ConstraintLayout) { if (!keyguardSmartspaceViewModel.isSmartspaceEnabled) return if (!keyguardSmartspaceViewModel.isSmartspaceEnabled) return val list = val list = if (com.android.systemui.shared.Flags.clockReactiveSmartspaceLayout()) { if (clockReactiveSmartspaceLayout()) { listOf(smartspaceView, dateView, dateViewLargeClock) listOf(smartspaceView, dateView, dateViewLargeClock) } else { } else { listOf(smartspaceView, dateView) listOf(smartspaceView, dateView) Loading @@ -370,16 +372,13 @@ constructor( disposableHandle?.dispose() disposableHandle?.dispose() } } private fun updateVisibility(constraintSet: ConstraintSet) { private fun updateVisibility(constraintSet: ConstraintSet, isLargeClockVisible: Boolean) { // This may update the visibility of the smartspace views // This may update the visibility of the smartspace views smartspaceController.requestSmartspaceUpdate() smartspaceController.requestSmartspaceUpdate() val weatherId: Int val weatherId: Int val dateId: Int val dateId: Int if ( if (clockReactiveSmartspaceLayout() && isLargeClockVisible) { com.android.systemui.shared.Flags.clockReactiveSmartspaceLayout() && keyguardClockViewModel.isLargeClockVisible.value ) { weatherId = sharedR.id.weather_smartspace_view_large weatherId = sharedR.id.weather_smartspace_view_large dateId = sharedR.id.date_smartspace_view_large dateId = sharedR.id.date_smartspace_view_large } else { } else { Loading @@ -392,12 +391,13 @@ constructor( setVisibility(weatherId, if (showWeather) VISIBLE else GONE) setVisibility(weatherId, if (showWeather) VISIBLE else GONE) setAlpha(weatherId, if (showWeather) 1f else 0f) setAlpha(weatherId, if (showWeather) 1f else 0f) val showDateView = !keyguardClockViewModel.hasCustomWeatherDataDisplay.value val showDateView = !keyguardClockViewModel.hasCustomWeatherDataDisplay.value || !isLargeClockVisible setVisibility(dateId, if (showDateView) VISIBLE else GONE) setVisibility(dateId, if (showDateView) VISIBLE else GONE) setAlpha(dateId, if (showDateView) 1f else 0f) setAlpha(dateId, if (showDateView) 1f else 0f) if (com.android.systemui.shared.Flags.clockReactiveSmartspaceLayout()) { if (clockReactiveSmartspaceLayout()) { if (keyguardClockViewModel.isLargeClockVisible.value) { if (isLargeClockVisible) { setVisibility(sharedR.id.date_smartspace_view, GONE) setVisibility(sharedR.id.date_smartspace_view, GONE) } else { } else { setVisibility(sharedR.id.date_smartspace_view_large, GONE) setVisibility(sharedR.id.date_smartspace_view_large, GONE) Loading
packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/transitions/ClockSizeTransition.kt +1 −1 Original line number Original line Diff line number Diff line Loading @@ -408,7 +408,7 @@ class ClockSizeTransition( override fun mutateTargets(from: Target, to: Target) { override fun mutateTargets(from: Target, to: Target) { if (to.view.id == sharedR.id.date_smartspace_view) { if (to.view.id == sharedR.id.date_smartspace_view) { to.isVisible = !viewModel.hasCustomWeatherDataDisplay.value to.isVisible = !viewModel.hasCustomWeatherDataDisplay.value || !isLargeClock to.visibility = if (to.isVisible) View.VISIBLE else View.GONE to.visibility = if (to.isVisible) View.VISIBLE else View.GONE to.alpha = if (to.isVisible) 1f else 0f to.alpha = if (to.isVisible) 1f else 0f } } Loading