diff options
5 files changed, 65 insertions, 15 deletions
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/view/layout/sections/SmartspaceSectionTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/view/layout/sections/SmartspaceSectionTest.kt index d94c97af6f14..c0db95f9e5d2 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/view/layout/sections/SmartspaceSectionTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/view/layout/sections/SmartspaceSectionTest.kt @@ -34,6 +34,7 @@ import com.android.systemui.keyguard.domain.interactor.KeyguardBlueprintInteract import com.android.systemui.keyguard.domain.interactor.KeyguardSmartspaceInteractor import com.android.systemui.keyguard.ui.viewmodel.KeyguardClockViewModel import com.android.systemui.keyguard.ui.viewmodel.KeyguardSmartspaceViewModel +import com.android.systemui.res.R import com.android.systemui.shared.R as sharedR import com.android.systemui.statusbar.lockscreen.LockscreenSmartspaceController import com.android.systemui.util.mockito.any @@ -68,6 +69,7 @@ class SmartspaceSectionTest : SysuiTestCase() { private val clockShouldBeCentered = MutableStateFlow(false) private val hasCustomWeatherDataDisplay = MutableStateFlow(false) private val isWeatherVisibleFlow = MutableStateFlow(false) + private val isShadeLayoutWide = MutableStateFlow(false) @Before fun setup() { @@ -80,7 +82,7 @@ class SmartspaceSectionTest : SysuiTestCase() { keyguardSmartspaceInteractor, lockscreenSmartspaceController, keyguardUnlockAnimationController, - blueprintInteractor + blueprintInteractor, ) constraintLayout = ConstraintLayout(mContext) whenever(lockscreenSmartspaceController.buildAndConnectView(any())) @@ -93,6 +95,7 @@ class SmartspaceSectionTest : SysuiTestCase() { whenever(keyguardClockViewModel.clockShouldBeCentered).thenReturn(clockShouldBeCentered) whenever(keyguardSmartspaceViewModel.isSmartspaceEnabled).thenReturn(true) whenever(keyguardSmartspaceViewModel.isWeatherVisible).thenReturn(isWeatherVisibleFlow) + whenever(keyguardSmartspaceViewModel.isShadeLayoutWide).thenReturn(isShadeLayoutWide) constraintSet = ConstraintSet() } @@ -125,6 +128,26 @@ class SmartspaceSectionTest : SysuiTestCase() { } @Test + fun testConstraintsWhenShadeLayoutIsNotWide() { + underTest.addViews(constraintLayout) + underTest.applyConstraints(constraintSet) + + val smartspaceConstraints = constraintSet.getConstraint(smartspaceView.id) + assertThat(smartspaceConstraints.layout.endToEnd).isEqualTo(ConstraintSet.PARENT_ID) + } + + @Test + fun testConstraintsWhenShadeLayoutIsWide() { + isShadeLayoutWide.value = true + + underTest.addViews(constraintLayout) + underTest.applyConstraints(constraintSet) + + val smartspaceConstraints = constraintSet.getConstraint(smartspaceView.id) + assertThat(smartspaceConstraints.layout.endToEnd).isEqualTo(R.id.split_shade_guideline) + } + + @Test fun testConstraintsWhenNotHasCustomWeatherDataDisplay() { whenever(keyguardSmartspaceViewModel.isDateWeatherDecoupled).thenReturn(true) underTest.addViews(constraintLayout) @@ -160,6 +183,7 @@ class SmartspaceSectionTest : SysuiTestCase() { assertThat(constraintSet.getVisibility(weatherView.id)).isEqualTo(GONE) assertThat(constraintSet.getVisibility(dateView.id)).isEqualTo(VISIBLE) } + @Test fun testCustomDateWeatherVisibility() { hasCustomWeatherDataDisplay.value = true diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardSmartspaceViewModelTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardSmartspaceViewModelTest.kt index 0c3fcb3ef759..adce9d65cbe0 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardSmartspaceViewModelTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardSmartspaceViewModelTest.kt @@ -26,6 +26,7 @@ import com.android.systemui.keyguard.data.repository.keyguardSmartspaceRepositor import com.android.systemui.keyguard.shared.model.ClockSize import com.android.systemui.kosmos.testScope import com.android.systemui.plugins.clocks.ClockController +import com.android.systemui.shade.data.repository.shadeRepository import com.android.systemui.testKosmos import com.android.systemui.util.mockito.whenever import com.google.common.truth.Truth.assertThat @@ -96,4 +97,26 @@ class KeyguardSmartspaceViewModelTest : SysuiTestCase() { assertThat(isWeatherVisible).isEqualTo(false) } + + @Test + fun isShadeLayoutWide_withConfigTrue_true() = + with(kosmos) { + testScope.runTest { + val isShadeLayoutWide by collectLastValue(underTest.isShadeLayoutWide) + shadeRepository.setShadeLayoutWide(true) + + assertThat(isShadeLayoutWide).isTrue() + } + } + + @Test + fun isShadeLayoutWide_withConfigFalse_false() = + with(kosmos) { + testScope.runTest { + val isShadeLayoutWide by collectLastValue(underTest.isShadeLayoutWide) + shadeRepository.setShadeLayoutWide(false) + + assertThat(isShadeLayoutWide).isFalse() + } + } } diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/SmartspaceSection.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/SmartspaceSection.kt index 7ad2ec5e3bf8..d54d411b7de6 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/SmartspaceSection.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/SmartspaceSection.kt @@ -124,7 +124,7 @@ constructor( ConstraintSet.START, ConstraintSet.PARENT_ID, ConstraintSet.START, - horizontalPaddingStart + horizontalPaddingStart, ) // migrate addSmartspaceView from KeyguardClockSwitchController @@ -135,15 +135,15 @@ constructor( ConstraintSet.START, ConstraintSet.PARENT_ID, ConstraintSet.START, - horizontalPaddingStart + horizontalPaddingStart, ) connect( sharedR.id.bc_smartspace_view, ConstraintSet.END, - if (keyguardClockViewModel.clockShouldBeCentered.value) ConstraintSet.PARENT_ID - else R.id.split_shade_guideline, + if (keyguardSmartspaceViewModel.isShadeLayoutWide.value) R.id.split_shade_guideline + else ConstraintSet.PARENT_ID, ConstraintSet.END, - horizontalPaddingEnd + horizontalPaddingEnd, ) if (keyguardClockViewModel.hasCustomWeatherDataDisplay.value) { @@ -152,7 +152,7 @@ constructor( sharedR.id.date_smartspace_view, ConstraintSet.BOTTOM, sharedR.id.bc_smartspace_view, - ConstraintSet.TOP + ConstraintSet.TOP, ) } else { clear(sharedR.id.date_smartspace_view, ConstraintSet.BOTTOM) @@ -160,13 +160,13 @@ constructor( sharedR.id.date_smartspace_view, ConstraintSet.TOP, customR.id.lockscreen_clock_view, - ConstraintSet.BOTTOM + ConstraintSet.BOTTOM, ) connect( sharedR.id.bc_smartspace_view, ConstraintSet.TOP, sharedR.id.date_smartspace_view, - ConstraintSet.BOTTOM + ConstraintSet.BOTTOM, ) } @@ -174,10 +174,7 @@ constructor( R.id.smart_space_barrier_bottom, Barrier.BOTTOM, 0, - *intArrayOf( - sharedR.id.bc_smartspace_view, - sharedR.id.date_smartspace_view, - ) + *intArrayOf(sharedR.id.bc_smartspace_view, sharedR.id.date_smartspace_view), ) } updateVisibility(constraintSet) @@ -212,7 +209,7 @@ constructor( setVisibility(sharedR.id.weather_smartspace_view, weatherVisibility) setAlpha( sharedR.id.weather_smartspace_view, - if (weatherVisibility == View.VISIBLE) 1f else 0f + if (weatherVisibility == View.VISIBLE) 1f else 0f, ) val dateVisibility = if (keyguardClockViewModel.hasCustomWeatherDataDisplay.value) ConstraintSet.GONE @@ -220,7 +217,7 @@ constructor( setVisibility(sharedR.id.date_smartspace_view, dateVisibility) setAlpha( sharedR.id.date_smartspace_view, - if (dateVisibility == ConstraintSet.VISIBLE) 1f else 0f + if (dateVisibility == ConstraintSet.VISIBLE) 1f else 0f, ) } } diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardSmartspaceViewModel.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardSmartspaceViewModel.kt index de0927ec27cb..3266dc45427a 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardSmartspaceViewModel.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardSmartspaceViewModel.kt @@ -22,6 +22,7 @@ import com.android.systemui.dagger.SysUISingleton import com.android.systemui.dagger.qualifiers.Application import com.android.systemui.keyguard.domain.interactor.KeyguardSmartspaceInteractor import com.android.systemui.res.R +import com.android.systemui.shade.domain.interactor.ShadeInteractor import com.android.systemui.statusbar.lockscreen.LockscreenSmartspaceController import javax.inject.Inject import kotlinx.coroutines.CoroutineScope @@ -39,6 +40,7 @@ constructor( smartspaceController: LockscreenSmartspaceController, keyguardClockViewModel: KeyguardClockViewModel, smartspaceInteractor: KeyguardSmartspaceInteractor, + shadeInteractor: ShadeInteractor, ) { /** Whether the smartspace section is available in the build. */ val isSmartspaceEnabled: Boolean = smartspaceController.isEnabled @@ -89,6 +91,8 @@ constructor( /* trigger clock and smartspace constraints change when smartspace appears */ val bcSmartspaceVisibility: StateFlow<Int> = smartspaceInteractor.bcSmartspaceVisibility + val isShadeLayoutWide: StateFlow<Boolean> = shadeInteractor.isShadeLayoutWide + companion object { fun getSmartspaceStartMargin(context: Context): Int { return context.resources.getDimensionPixelSize(R.dimen.below_clock_padding_start) + diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardSmartspaceViewModelKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardSmartspaceViewModelKosmos.kt index d33d594d9e8a..76e2cc8b7bd0 100644 --- a/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardSmartspaceViewModelKosmos.kt +++ b/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardSmartspaceViewModelKosmos.kt @@ -19,6 +19,7 @@ package com.android.systemui.keyguard.ui.viewmodel import com.android.systemui.keyguard.domain.interactor.keyguardSmartspaceInteractor import com.android.systemui.kosmos.Kosmos import com.android.systemui.kosmos.applicationCoroutineScope +import com.android.systemui.shade.domain.interactor.shadeInteractor import com.android.systemui.util.mockito.mock val Kosmos.keyguardSmartspaceViewModel by @@ -28,5 +29,6 @@ val Kosmos.keyguardSmartspaceViewModel by smartspaceController = mock(), keyguardClockViewModel = keyguardClockViewModel, smartspaceInteractor = keyguardSmartspaceInteractor, + shadeInteractor = shadeInteractor, ) } |