Loading packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardSmartspaceViewModelTest.kt +63 −1 Original line number Diff line number Diff line Loading @@ -16,6 +16,9 @@ package com.android.systemui.keyguard.ui.viewmodel import android.content.res.Configuration import android.platform.test.annotations.DisableFlags import android.platform.test.annotations.EnableFlags import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase Loading Loading @@ -44,7 +47,7 @@ class KeyguardSmartspaceViewModelTest : SysuiTestCase() { val kosmos = testKosmos() val testScope = kosmos.testScope val underTest = kosmos.keyguardSmartspaceViewModel val res = context.resources @Mock private lateinit var mockConfiguration: Configuration @Mock(answer = Answers.RETURNS_DEEP_STUBS) private lateinit var clockController: ClockController Loading Loading @@ -119,4 +122,63 @@ class KeyguardSmartspaceViewModelTest : SysuiTestCase() { assertThat(isShadeLayoutWide).isFalse() } } @Test @DisableFlags(com.android.systemui.shared.Flags.FLAG_CLOCK_REACTIVE_SMARTSPACE_LAYOUT) fun dateWeatherBelowSmallClock_smartspacelayoutflag_off_true() { val result = KeyguardSmartspaceViewModel.dateWeatherBelowSmallClock(mockConfiguration) assertThat(result).isTrue() } @Test @EnableFlags(com.android.systemui.shared.Flags.FLAG_CLOCK_REACTIVE_SMARTSPACE_LAYOUT) fun dateWeatherBelowSmallClock_defaultFontAndDisplaySize_false() { val fontScale = 1.0f val screenWidthDp = 347 mockConfiguration.fontScale = fontScale mockConfiguration.screenWidthDp = screenWidthDp val result = KeyguardSmartspaceViewModel.dateWeatherBelowSmallClock(mockConfiguration) assertThat(result).isFalse() } @Test @EnableFlags(com.android.systemui.shared.Flags.FLAG_CLOCK_REACTIVE_SMARTSPACE_LAYOUT) fun dateWeatherBelowSmallClock_variousFontAndDisplaySize_false() { mockConfiguration.fontScale = 1.0f mockConfiguration.screenWidthDp = 347 val result1 = KeyguardSmartspaceViewModel.dateWeatherBelowSmallClock(mockConfiguration) assertThat(result1).isFalse() mockConfiguration.fontScale = 1.2f mockConfiguration.screenWidthDp = 347 val result2 = KeyguardSmartspaceViewModel.dateWeatherBelowSmallClock(mockConfiguration) assertThat(result2).isFalse() mockConfiguration.fontScale = 1.7f mockConfiguration.screenWidthDp = 412 val result3 = KeyguardSmartspaceViewModel.dateWeatherBelowSmallClock(mockConfiguration) assertThat(result3).isFalse() } @Test @EnableFlags(com.android.systemui.shared.Flags.FLAG_CLOCK_REACTIVE_SMARTSPACE_LAYOUT) fun dateWeatherBelowSmallClock_variousFontAndDisplaySize_true() { mockConfiguration.fontScale = 1.0f mockConfiguration.screenWidthDp = 310 val result1 = KeyguardSmartspaceViewModel.dateWeatherBelowSmallClock(mockConfiguration) assertThat(result1).isTrue() mockConfiguration.fontScale = 1.5f mockConfiguration.screenWidthDp = 347 val result2 = KeyguardSmartspaceViewModel.dateWeatherBelowSmallClock(mockConfiguration) assertThat(result2).isTrue() mockConfiguration.fontScale = 2.0f mockConfiguration.screenWidthDp = 411 val result3 = KeyguardSmartspaceViewModel.dateWeatherBelowSmallClock(mockConfiguration) assertThat(result3).isTrue() } } packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardBlueprintViewBinder.kt +1 −7 Original line number Diff line number Diff line Loading @@ -128,13 +128,7 @@ object KeyguardBlueprintViewBinder { cs: ConstraintSet, constraintLayout: ConstraintLayout, ) { val ids = listOf( sharedR.id.date_smartspace_view, sharedR.id.date_smartspace_view_large, sharedR.id.weather_smartspace_view, sharedR.id.weather_smartspace_view_large, ) val ids = listOf(sharedR.id.date_smartspace_view, sharedR.id.date_smartspace_view_large) for (i in ids) { constraintLayout.getViewById(i)?.visibility = cs.getVisibility(i) Loading packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardRootViewBinder.kt +0 −2 Original line number Diff line number Diff line Loading @@ -193,7 +193,6 @@ object KeyguardRootViewBinder { childViews[largeClockId]?.translationY = y if (com.android.systemui.shared.Flags.clockReactiveSmartspaceLayout()) { childViews[largeClockDateId]?.translationY = y childViews[largeClockWeatherId]?.translationY = y } childViews[aodPromotedNotificationId]?.translationY = y childViews[aodNotificationIconContainerId]?.translationY = y Loading Loading @@ -584,7 +583,6 @@ object KeyguardRootViewBinder { private val aodNotificationIconContainerId = R.id.aod_notification_icon_container private val largeClockId = customR.id.lockscreen_clock_view_large private val largeClockDateId = sharedR.id.date_smartspace_view_large private val largeClockWeatherId = sharedR.id.weather_smartspace_view_large private val smallClockId = customR.id.lockscreen_clock_view private val indicationArea = R.id.keyguard_indication_area private val startButton = R.id.start_button Loading packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardSmartspaceViewBinder.kt +26 −44 Original line number Diff line number Diff line Loading @@ -91,14 +91,9 @@ object KeyguardSmartspaceViewBinder { R.dimen.smartspace_padding_vertical ) val smallViewIds = listOf(sharedR.id.date_smartspace_view, sharedR.id.weather_smartspace_view) val smallViewId = sharedR.id.date_smartspace_view val largeViewIds = listOf( sharedR.id.date_smartspace_view_large, sharedR.id.weather_smartspace_view_large, ) val largeViewId = sharedR.id.date_smartspace_view_large launch("$TAG#smartspaceViewModel.burnInLayerVisibility") { combine( Loading @@ -109,14 +104,12 @@ object KeyguardSmartspaceViewBinder { .collect { (visibility, isLargeClock) -> if (isLargeClock) { // hide small clock date/weather for (viewId in smallViewIds) { keyguardRootView.findViewById<View>(viewId)?.let { keyguardRootView.findViewById<View>(smallViewId)?.let { it.visibility = View.GONE } } } } } launch("$TAG#clockEventController.onClockBoundsChanged") { // Whenever the doze amount changes, the clock may update it's view bounds. Loading @@ -130,11 +123,10 @@ object KeyguardSmartspaceViewBinder { ::Pair, ) .collect { (isLargeClock, clockBounds) -> for (id in (if (isLargeClock) smallViewIds else largeViewIds)) { keyguardRootView.findViewById<View>(id)?.let { val viewId = if (isLargeClock) smallViewId else largeViewId keyguardRootView.findViewById<View>(viewId)?.let { it.visibility = View.GONE } } if (clockBounds == VRectF.ZERO) return@collect if (isLargeClock) { Loading @@ -144,18 +136,19 @@ object KeyguardSmartspaceViewBinder { sharedR.id.date_smartspace_view_large ) ?.height ?: 0 for (id in largeViewIds) { keyguardRootView.findViewById<View>(id)?.let { view -> keyguardRootView.findViewById<View>(largeViewId)?.let { view -> val viewHeight = view.height val offset = (largeDateHeight - viewHeight) / 2 view.top = (clockBounds.bottom + yBuffer + offset).toInt() view.top = (clockBounds.bottom + yBuffer + offset).toInt() view.bottom = view.top + viewHeight } } } else { for (id in smallViewIds) { keyguardRootView.findViewById<View>(id)?.let { view -> } else if ( !KeyguardSmartspaceViewModel.dateWeatherBelowSmallClock( keyguardRootView.resources.configuration ) ) { keyguardRootView.findViewById<View>(smallViewId)?.let { view -> val viewWidth = view.width if (view.isLayoutRtl()) { view.right = (clockBounds.left - xBuffer).toInt() Loading @@ -172,7 +165,6 @@ object KeyguardSmartspaceViewBinder { } } } } private fun updateBCSmartspaceInBurnInLayer( keyguardRootView: ConstraintLayout, Loading Loading @@ -218,11 +210,6 @@ object KeyguardSmartspaceViewBinder { val dateView = constraintLayout.requireViewById<View>(sharedR.id.date_smartspace_view) addView(dateView) if (com.android.systemui.shared.Flags.clockReactiveSmartspaceLayout()) { val weatherView = constraintLayout.requireViewById<View>(sharedR.id.weather_smartspace_view) addView(weatherView) } } } } Loading @@ -240,11 +227,6 @@ object KeyguardSmartspaceViewBinder { val dateView = constraintLayout.requireViewById<View>(sharedR.id.date_smartspace_view) removeView(dateView) if (com.android.systemui.shared.Flags.clockReactiveSmartspaceLayout()) { val weatherView = constraintLayout.requireViewById<View>(sharedR.id.weather_smartspace_view) removeView(weatherView) } } } } Loading packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/ClockSection.kt +14 −8 Original line number Diff line number Diff line Loading @@ -121,18 +121,22 @@ constructor( setAlpha(getNonTargetClockFace(clock).views, 0F) if (!keyguardClockViewModel.isLargeClockVisible.value) { if (com.android.systemui.shared.Flags.clockReactiveSmartspaceLayout()) { if ( KeyguardSmartspaceViewModel.dateWeatherBelowSmallClock( context.resources.configuration ) ) { connect( sharedR.id.bc_smartspace_view, TOP, customR.id.lockscreen_clock_view, sharedR.id.date_smartspace_view, BOTTOM, ) } else { connect( sharedR.id.bc_smartspace_view, TOP, sharedR.id.date_smartspace_view, customR.id.lockscreen_clock_view, BOTTOM, ) } Loading Loading @@ -187,6 +191,8 @@ constructor( val guideline = if (keyguardClockViewModel.clockShouldBeCentered.value) PARENT_ID else R.id.split_shade_guideline val dateWeatherBelowSmallClock = KeyguardSmartspaceViewModel.dateWeatherBelowSmallClock(context.resources.configuration) constraints.apply { connect(customR.id.lockscreen_clock_view_large, START, PARENT_ID, START) connect(customR.id.lockscreen_clock_view_large, END, guideline, END) Loading Loading @@ -254,11 +260,7 @@ constructor( 0 } if (com.android.systemui.shared.Flags.clockReactiveSmartspaceLayout()) { clockInteractor.setNotificationStackDefaultTop( (smallClockBottom + marginBetweenSmartspaceAndNotification).toFloat() ) } else { if (dateWeatherBelowSmallClock) { val dateWeatherSmartspaceHeight = getDimen(context, DATE_WEATHER_VIEW_HEIGHT).toFloat() clockInteractor.setNotificationStackDefaultTop( Loading @@ -266,6 +268,10 @@ constructor( dateWeatherSmartspaceHeight + marginBetweenSmartspaceAndNotification ) } else { clockInteractor.setNotificationStackDefaultTop( (smallClockBottom + marginBetweenSmartspaceAndNotification).toFloat() ) } } Loading Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardSmartspaceViewModelTest.kt +63 −1 Original line number Diff line number Diff line Loading @@ -16,6 +16,9 @@ package com.android.systemui.keyguard.ui.viewmodel import android.content.res.Configuration import android.platform.test.annotations.DisableFlags import android.platform.test.annotations.EnableFlags import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase Loading Loading @@ -44,7 +47,7 @@ class KeyguardSmartspaceViewModelTest : SysuiTestCase() { val kosmos = testKosmos() val testScope = kosmos.testScope val underTest = kosmos.keyguardSmartspaceViewModel val res = context.resources @Mock private lateinit var mockConfiguration: Configuration @Mock(answer = Answers.RETURNS_DEEP_STUBS) private lateinit var clockController: ClockController Loading Loading @@ -119,4 +122,63 @@ class KeyguardSmartspaceViewModelTest : SysuiTestCase() { assertThat(isShadeLayoutWide).isFalse() } } @Test @DisableFlags(com.android.systemui.shared.Flags.FLAG_CLOCK_REACTIVE_SMARTSPACE_LAYOUT) fun dateWeatherBelowSmallClock_smartspacelayoutflag_off_true() { val result = KeyguardSmartspaceViewModel.dateWeatherBelowSmallClock(mockConfiguration) assertThat(result).isTrue() } @Test @EnableFlags(com.android.systemui.shared.Flags.FLAG_CLOCK_REACTIVE_SMARTSPACE_LAYOUT) fun dateWeatherBelowSmallClock_defaultFontAndDisplaySize_false() { val fontScale = 1.0f val screenWidthDp = 347 mockConfiguration.fontScale = fontScale mockConfiguration.screenWidthDp = screenWidthDp val result = KeyguardSmartspaceViewModel.dateWeatherBelowSmallClock(mockConfiguration) assertThat(result).isFalse() } @Test @EnableFlags(com.android.systemui.shared.Flags.FLAG_CLOCK_REACTIVE_SMARTSPACE_LAYOUT) fun dateWeatherBelowSmallClock_variousFontAndDisplaySize_false() { mockConfiguration.fontScale = 1.0f mockConfiguration.screenWidthDp = 347 val result1 = KeyguardSmartspaceViewModel.dateWeatherBelowSmallClock(mockConfiguration) assertThat(result1).isFalse() mockConfiguration.fontScale = 1.2f mockConfiguration.screenWidthDp = 347 val result2 = KeyguardSmartspaceViewModel.dateWeatherBelowSmallClock(mockConfiguration) assertThat(result2).isFalse() mockConfiguration.fontScale = 1.7f mockConfiguration.screenWidthDp = 412 val result3 = KeyguardSmartspaceViewModel.dateWeatherBelowSmallClock(mockConfiguration) assertThat(result3).isFalse() } @Test @EnableFlags(com.android.systemui.shared.Flags.FLAG_CLOCK_REACTIVE_SMARTSPACE_LAYOUT) fun dateWeatherBelowSmallClock_variousFontAndDisplaySize_true() { mockConfiguration.fontScale = 1.0f mockConfiguration.screenWidthDp = 310 val result1 = KeyguardSmartspaceViewModel.dateWeatherBelowSmallClock(mockConfiguration) assertThat(result1).isTrue() mockConfiguration.fontScale = 1.5f mockConfiguration.screenWidthDp = 347 val result2 = KeyguardSmartspaceViewModel.dateWeatherBelowSmallClock(mockConfiguration) assertThat(result2).isTrue() mockConfiguration.fontScale = 2.0f mockConfiguration.screenWidthDp = 411 val result3 = KeyguardSmartspaceViewModel.dateWeatherBelowSmallClock(mockConfiguration) assertThat(result3).isTrue() } }
packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardBlueprintViewBinder.kt +1 −7 Original line number Diff line number Diff line Loading @@ -128,13 +128,7 @@ object KeyguardBlueprintViewBinder { cs: ConstraintSet, constraintLayout: ConstraintLayout, ) { val ids = listOf( sharedR.id.date_smartspace_view, sharedR.id.date_smartspace_view_large, sharedR.id.weather_smartspace_view, sharedR.id.weather_smartspace_view_large, ) val ids = listOf(sharedR.id.date_smartspace_view, sharedR.id.date_smartspace_view_large) for (i in ids) { constraintLayout.getViewById(i)?.visibility = cs.getVisibility(i) Loading
packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardRootViewBinder.kt +0 −2 Original line number Diff line number Diff line Loading @@ -193,7 +193,6 @@ object KeyguardRootViewBinder { childViews[largeClockId]?.translationY = y if (com.android.systemui.shared.Flags.clockReactiveSmartspaceLayout()) { childViews[largeClockDateId]?.translationY = y childViews[largeClockWeatherId]?.translationY = y } childViews[aodPromotedNotificationId]?.translationY = y childViews[aodNotificationIconContainerId]?.translationY = y Loading Loading @@ -584,7 +583,6 @@ object KeyguardRootViewBinder { private val aodNotificationIconContainerId = R.id.aod_notification_icon_container private val largeClockId = customR.id.lockscreen_clock_view_large private val largeClockDateId = sharedR.id.date_smartspace_view_large private val largeClockWeatherId = sharedR.id.weather_smartspace_view_large private val smallClockId = customR.id.lockscreen_clock_view private val indicationArea = R.id.keyguard_indication_area private val startButton = R.id.start_button Loading
packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardSmartspaceViewBinder.kt +26 −44 Original line number Diff line number Diff line Loading @@ -91,14 +91,9 @@ object KeyguardSmartspaceViewBinder { R.dimen.smartspace_padding_vertical ) val smallViewIds = listOf(sharedR.id.date_smartspace_view, sharedR.id.weather_smartspace_view) val smallViewId = sharedR.id.date_smartspace_view val largeViewIds = listOf( sharedR.id.date_smartspace_view_large, sharedR.id.weather_smartspace_view_large, ) val largeViewId = sharedR.id.date_smartspace_view_large launch("$TAG#smartspaceViewModel.burnInLayerVisibility") { combine( Loading @@ -109,14 +104,12 @@ object KeyguardSmartspaceViewBinder { .collect { (visibility, isLargeClock) -> if (isLargeClock) { // hide small clock date/weather for (viewId in smallViewIds) { keyguardRootView.findViewById<View>(viewId)?.let { keyguardRootView.findViewById<View>(smallViewId)?.let { it.visibility = View.GONE } } } } } launch("$TAG#clockEventController.onClockBoundsChanged") { // Whenever the doze amount changes, the clock may update it's view bounds. Loading @@ -130,11 +123,10 @@ object KeyguardSmartspaceViewBinder { ::Pair, ) .collect { (isLargeClock, clockBounds) -> for (id in (if (isLargeClock) smallViewIds else largeViewIds)) { keyguardRootView.findViewById<View>(id)?.let { val viewId = if (isLargeClock) smallViewId else largeViewId keyguardRootView.findViewById<View>(viewId)?.let { it.visibility = View.GONE } } if (clockBounds == VRectF.ZERO) return@collect if (isLargeClock) { Loading @@ -144,18 +136,19 @@ object KeyguardSmartspaceViewBinder { sharedR.id.date_smartspace_view_large ) ?.height ?: 0 for (id in largeViewIds) { keyguardRootView.findViewById<View>(id)?.let { view -> keyguardRootView.findViewById<View>(largeViewId)?.let { view -> val viewHeight = view.height val offset = (largeDateHeight - viewHeight) / 2 view.top = (clockBounds.bottom + yBuffer + offset).toInt() view.top = (clockBounds.bottom + yBuffer + offset).toInt() view.bottom = view.top + viewHeight } } } else { for (id in smallViewIds) { keyguardRootView.findViewById<View>(id)?.let { view -> } else if ( !KeyguardSmartspaceViewModel.dateWeatherBelowSmallClock( keyguardRootView.resources.configuration ) ) { keyguardRootView.findViewById<View>(smallViewId)?.let { view -> val viewWidth = view.width if (view.isLayoutRtl()) { view.right = (clockBounds.left - xBuffer).toInt() Loading @@ -172,7 +165,6 @@ object KeyguardSmartspaceViewBinder { } } } } private fun updateBCSmartspaceInBurnInLayer( keyguardRootView: ConstraintLayout, Loading Loading @@ -218,11 +210,6 @@ object KeyguardSmartspaceViewBinder { val dateView = constraintLayout.requireViewById<View>(sharedR.id.date_smartspace_view) addView(dateView) if (com.android.systemui.shared.Flags.clockReactiveSmartspaceLayout()) { val weatherView = constraintLayout.requireViewById<View>(sharedR.id.weather_smartspace_view) addView(weatherView) } } } } Loading @@ -240,11 +227,6 @@ object KeyguardSmartspaceViewBinder { val dateView = constraintLayout.requireViewById<View>(sharedR.id.date_smartspace_view) removeView(dateView) if (com.android.systemui.shared.Flags.clockReactiveSmartspaceLayout()) { val weatherView = constraintLayout.requireViewById<View>(sharedR.id.weather_smartspace_view) removeView(weatherView) } } } } Loading
packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/ClockSection.kt +14 −8 Original line number Diff line number Diff line Loading @@ -121,18 +121,22 @@ constructor( setAlpha(getNonTargetClockFace(clock).views, 0F) if (!keyguardClockViewModel.isLargeClockVisible.value) { if (com.android.systemui.shared.Flags.clockReactiveSmartspaceLayout()) { if ( KeyguardSmartspaceViewModel.dateWeatherBelowSmallClock( context.resources.configuration ) ) { connect( sharedR.id.bc_smartspace_view, TOP, customR.id.lockscreen_clock_view, sharedR.id.date_smartspace_view, BOTTOM, ) } else { connect( sharedR.id.bc_smartspace_view, TOP, sharedR.id.date_smartspace_view, customR.id.lockscreen_clock_view, BOTTOM, ) } Loading Loading @@ -187,6 +191,8 @@ constructor( val guideline = if (keyguardClockViewModel.clockShouldBeCentered.value) PARENT_ID else R.id.split_shade_guideline val dateWeatherBelowSmallClock = KeyguardSmartspaceViewModel.dateWeatherBelowSmallClock(context.resources.configuration) constraints.apply { connect(customR.id.lockscreen_clock_view_large, START, PARENT_ID, START) connect(customR.id.lockscreen_clock_view_large, END, guideline, END) Loading Loading @@ -254,11 +260,7 @@ constructor( 0 } if (com.android.systemui.shared.Flags.clockReactiveSmartspaceLayout()) { clockInteractor.setNotificationStackDefaultTop( (smallClockBottom + marginBetweenSmartspaceAndNotification).toFloat() ) } else { if (dateWeatherBelowSmallClock) { val dateWeatherSmartspaceHeight = getDimen(context, DATE_WEATHER_VIEW_HEIGHT).toFloat() clockInteractor.setNotificationStackDefaultTop( Loading @@ -266,6 +268,10 @@ constructor( dateWeatherSmartspaceHeight + marginBetweenSmartspaceAndNotification ) } else { clockInteractor.setNotificationStackDefaultTop( (smallClockBottom + marginBetweenSmartspaceAndNotification).toFloat() ) } } Loading