summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardSmartspaceViewModelTest.kt64
-rw-r--r--packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardBlueprintViewBinder.kt8
-rw-r--r--packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardRootViewBinder.kt2
-rw-r--r--packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardSmartspaceViewBinder.kt70
-rw-r--r--packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/ClockSection.kt22
-rw-r--r--packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/SmartspaceSection.kt244
-rw-r--r--packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/transitions/ClockSizeTransition.kt6
-rw-r--r--packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/transitions/DefaultClockSteppingTransition.kt1
-rw-r--r--packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardClockViewModel.kt3
-rw-r--r--packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardSmartspaceViewModel.kt39
10 files changed, 262 insertions, 197 deletions
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 adce9d65cbe0..e89c05f3a84d 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
@@ -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
@@ -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
@@ -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()
+ }
}
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardBlueprintViewBinder.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardBlueprintViewBinder.kt
index fc5914b02e05..f38a2430b8fc 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardBlueprintViewBinder.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardBlueprintViewBinder.kt
@@ -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)
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardRootViewBinder.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardRootViewBinder.kt
index 60460bf68c12..2fdca6bc68d9 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardRootViewBinder.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardRootViewBinder.kt
@@ -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
@@ -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
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardSmartspaceViewBinder.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardSmartspaceViewBinder.kt
index 5ef2d6fd3256..39fe588d8b6b 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardSmartspaceViewBinder.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardSmartspaceViewBinder.kt
@@ -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(
@@ -109,10 +104,8 @@ object KeyguardSmartspaceViewBinder {
.collect { (visibility, isLargeClock) ->
if (isLargeClock) {
// hide small clock date/weather
- for (viewId in smallViewIds) {
- keyguardRootView.findViewById<View>(viewId)?.let {
- it.visibility = View.GONE
- }
+ keyguardRootView.findViewById<View>(smallViewId)?.let {
+ it.visibility = View.GONE
}
}
}
@@ -130,10 +123,9 @@ object KeyguardSmartspaceViewBinder {
::Pair,
)
.collect { (isLargeClock, clockBounds) ->
- for (id in (if (isLargeClock) smallViewIds else largeViewIds)) {
- keyguardRootView.findViewById<View>(id)?.let {
- it.visibility = View.GONE
- }
+ val viewId = if (isLargeClock) smallViewId else largeViewId
+ keyguardRootView.findViewById<View>(viewId)?.let {
+ it.visibility = View.GONE
}
if (clockBounds == VRectF.ZERO) return@collect
@@ -144,26 +136,26 @@ object KeyguardSmartspaceViewBinder {
sharedR.id.date_smartspace_view_large
)
?.height ?: 0
- for (id in largeViewIds) {
- keyguardRootView.findViewById<View>(id)?.let { view ->
- val viewHeight = view.height
- val offset = (largeDateHeight - viewHeight) / 2
- view.top =
- (clockBounds.bottom + yBuffer + offset).toInt()
- view.bottom = view.top + viewHeight
- }
+
+ keyguardRootView.findViewById<View>(largeViewId)?.let { view ->
+ val viewHeight = view.height
+ val offset = (largeDateHeight - viewHeight) / 2
+ view.top = (clockBounds.bottom + yBuffer + offset).toInt()
+ view.bottom = view.top + viewHeight
}
- } else {
- for (id in smallViewIds) {
- keyguardRootView.findViewById<View>(id)?.let { view ->
- val viewWidth = view.width
- if (view.isLayoutRtl()) {
- view.right = (clockBounds.left - xBuffer).toInt()
- view.left = view.right - viewWidth
- } else {
- view.left = (clockBounds.right + xBuffer).toInt()
- view.right = view.left + viewWidth
- }
+ } 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()
+ view.left = view.right - viewWidth
+ } else {
+ view.left = (clockBounds.right + xBuffer).toInt()
+ view.right = view.left + viewWidth
}
}
}
@@ -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)
- }
}
}
}
@@ -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)
- }
}
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/ClockSection.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/ClockSection.kt
index 8a33c6471326..9c6f46570b1d 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/ClockSection.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/ClockSection.kt
@@ -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,
)
}
@@ -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)
@@ -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(
@@ -266,6 +268,10 @@ constructor(
dateWeatherSmartspaceHeight +
marginBetweenSmartspaceAndNotification
)
+ } else {
+ clockInteractor.setNotificationStackDefaultTop(
+ (smallClockBottom + marginBetweenSmartspaceAndNotification).toFloat()
+ )
}
}
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 d0b5f743c277..d9652b590678 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
@@ -20,6 +20,7 @@ import android.content.Context
import android.view.View
import android.view.ViewGroup
import android.view.ViewTreeObserver.OnGlobalLayoutListener
+import android.widget.LinearLayout
import androidx.constraintlayout.widget.Barrier
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.constraintlayout.widget.ConstraintSet
@@ -57,10 +58,8 @@ constructor(
private val keyguardRootViewModel: KeyguardRootViewModel,
) : KeyguardSection() {
private var smartspaceView: View? = null
- private var weatherView: View? = null
private var dateView: ViewGroup? = null
- private var weatherViewLargeClock: View? = null
- private var dateViewLargeClock: View? = null
+ private var dateViewLargeClock: ViewGroup? = null
private var smartspaceVisibilityListener: OnGlobalLayoutListener? = null
private var pastVisibility: Int = -1
@@ -77,34 +76,47 @@ constructor(
override fun addViews(constraintLayout: ConstraintLayout) {
if (!keyguardSmartspaceViewModel.isSmartspaceEnabled) return
smartspaceView = smartspaceController.buildAndConnectView(constraintLayout)
- weatherView = smartspaceController.buildAndConnectWeatherView(constraintLayout, false)
dateView =
smartspaceController.buildAndConnectDateView(constraintLayout, false) as? ViewGroup
+ var weatherViewLargeClock: View? = null
+ val weatherView: View? =
+ smartspaceController.buildAndConnectWeatherView(constraintLayout, false)
if (com.android.systemui.shared.Flags.clockReactiveSmartspaceLayout()) {
weatherViewLargeClock =
smartspaceController.buildAndConnectWeatherView(constraintLayout, true)
dateViewLargeClock =
- smartspaceController.buildAndConnectDateView(constraintLayout, true)
+ smartspaceController.buildAndConnectDateView(constraintLayout, true) as? ViewGroup
}
pastVisibility = smartspaceView?.visibility ?: View.GONE
constraintLayout.addView(smartspaceView)
if (com.android.systemui.shared.Flags.clockReactiveSmartspaceLayout()) {
dateView?.visibility = View.GONE
- weatherView?.visibility = View.GONE
dateViewLargeClock?.visibility = View.GONE
- weatherViewLargeClock?.visibility = View.GONE
- constraintLayout.addView(dateView)
- constraintLayout.addView(weatherView)
- constraintLayout.addView(weatherViewLargeClock)
constraintLayout.addView(dateViewLargeClock)
- } else {
if (keyguardSmartspaceViewModel.isDateWeatherDecoupled) {
- constraintLayout.addView(dateView)
// Place weather right after the date, before the extras (alarm and dnd)
- val index = if (dateView?.childCount == 0) 0 else 1
- dateView?.addView(weatherView, index)
+ val index = if (dateViewLargeClock?.childCount == 0) 0 else 1
+ dateViewLargeClock?.addView(weatherViewLargeClock, index)
+ }
+
+ if (
+ KeyguardSmartspaceViewModel.dateWeatherBelowSmallClock(
+ context.resources.configuration,
+ keyguardClockViewModel.hasCustomWeatherDataDisplay.value,
+ )
+ ) {
+ (dateView as? LinearLayout)?.orientation = LinearLayout.HORIZONTAL
+ } else {
+ (dateView as? LinearLayout)?.orientation = LinearLayout.VERTICAL
}
}
+
+ if (keyguardSmartspaceViewModel.isDateWeatherDecoupled) {
+ constraintLayout.addView(dateView)
+ // Place weather right after the date, before the extras (alarm and dnd)
+ val index = if (dateView?.childCount == 0) 0 else 1
+ dateView?.addView(weatherView, index)
+ }
keyguardUnlockAnimationController.lockscreenSmartspace = smartspaceView
smartspaceVisibilityListener = OnGlobalLayoutListener {
smartspaceView?.let {
@@ -136,10 +148,15 @@ constructor(
val dateWeatherPaddingStart = KeyguardSmartspaceViewModel.getDateWeatherStartMargin(context)
val smartspaceHorizontalPadding =
KeyguardSmartspaceViewModel.getSmartspaceHorizontalMargin(context)
+ val dateWeatherBelowSmallClock =
+ KeyguardSmartspaceViewModel.dateWeatherBelowSmallClock(
+ context.resources.configuration,
+ keyguardClockViewModel.hasCustomWeatherDataDisplay.value,
+ )
constraintSet.apply {
constrainHeight(sharedR.id.date_smartspace_view, ConstraintSet.WRAP_CONTENT)
constrainWidth(sharedR.id.date_smartspace_view, ConstraintSet.WRAP_CONTENT)
- if (!com.android.systemui.shared.Flags.clockReactiveSmartspaceLayout()) {
+ if (dateWeatherBelowSmallClock) {
connect(
sharedR.id.date_smartspace_view,
ConstraintSet.START,
@@ -167,7 +184,7 @@ constructor(
smartspaceHorizontalPadding,
)
if (keyguardClockViewModel.hasCustomWeatherDataDisplay.value) {
- if (!com.android.systemui.shared.Flags.clockReactiveSmartspaceLayout()) {
+ if (dateWeatherBelowSmallClock) {
clear(sharedR.id.date_smartspace_view, ConstraintSet.TOP)
connect(
sharedR.id.date_smartspace_view,
@@ -179,12 +196,27 @@ constructor(
} else {
clear(sharedR.id.date_smartspace_view, ConstraintSet.BOTTOM)
if (com.android.systemui.shared.Flags.clockReactiveSmartspaceLayout()) {
- connect(
- sharedR.id.bc_smartspace_view,
- ConstraintSet.TOP,
- customR.id.lockscreen_clock_view,
- ConstraintSet.BOTTOM,
- )
+ if (dateWeatherBelowSmallClock) {
+ connect(
+ sharedR.id.date_smartspace_view,
+ ConstraintSet.TOP,
+ customR.id.lockscreen_clock_view,
+ ConstraintSet.BOTTOM,
+ )
+ connect(
+ sharedR.id.bc_smartspace_view,
+ ConstraintSet.TOP,
+ sharedR.id.date_smartspace_view,
+ ConstraintSet.BOTTOM,
+ )
+ } else {
+ connect(
+ sharedR.id.bc_smartspace_view,
+ ConstraintSet.TOP,
+ customR.id.lockscreen_clock_view,
+ ConstraintSet.BOTTOM,
+ )
+ }
} else {
connect(
sharedR.id.date_smartspace_view,
@@ -203,7 +235,6 @@ constructor(
if (com.android.systemui.shared.Flags.clockReactiveSmartspaceLayout()) {
if (keyguardClockViewModel.isLargeClockVisible.value) {
- setVisibility(sharedR.id.weather_smartspace_view, GONE)
setVisibility(sharedR.id.date_smartspace_view, GONE)
constrainHeight(
sharedR.id.date_smartspace_view_large,
@@ -238,118 +269,79 @@ constructor(
connect(
sharedR.id.date_smartspace_view_large,
ConstraintSet.END,
- sharedR.id.weather_smartspace_view_large,
- ConstraintSet.START,
- )
-
- connect(
- sharedR.id.weather_smartspace_view_large,
- ConstraintSet.BOTTOM,
- sharedR.id.date_smartspace_view_large,
- ConstraintSet.BOTTOM,
- )
-
- connect(
- sharedR.id.weather_smartspace_view_large,
- ConstraintSet.TOP,
- sharedR.id.date_smartspace_view_large,
- ConstraintSet.TOP,
- )
-
- connect(
- sharedR.id.weather_smartspace_view_large,
- ConstraintSet.START,
- sharedR.id.date_smartspace_view_large,
- ConstraintSet.END,
- )
-
- connect(
- sharedR.id.weather_smartspace_view_large,
- ConstraintSet.END,
customR.id.lockscreen_clock_view_large,
ConstraintSet.END,
)
-
- setHorizontalChainStyle(
- sharedR.id.weather_smartspace_view_large,
- ConstraintSet.CHAIN_PACKED,
- )
setHorizontalChainStyle(
sharedR.id.date_smartspace_view_large,
ConstraintSet.CHAIN_PACKED,
)
} else {
- setVisibility(sharedR.id.weather_smartspace_view_large, GONE)
- setVisibility(sharedR.id.date_smartspace_view_large, GONE)
- constrainHeight(sharedR.id.date_smartspace_view, ConstraintSet.WRAP_CONTENT)
- constrainWidth(sharedR.id.date_smartspace_view, ConstraintSet.WRAP_CONTENT)
- constrainHeight(sharedR.id.weather_smartspace_view, ConstraintSet.WRAP_CONTENT)
- constrainWidth(sharedR.id.weather_smartspace_view, ConstraintSet.WRAP_CONTENT)
+ if (dateWeatherBelowSmallClock) {
+ connect(
+ sharedR.id.date_smartspace_view,
+ ConstraintSet.START,
+ ConstraintSet.PARENT_ID,
+ ConstraintSet.START,
+ dateWeatherPaddingStart,
+ )
+ } else {
+ setVisibility(sharedR.id.date_smartspace_view_large, GONE)
+ constrainHeight(sharedR.id.date_smartspace_view, ConstraintSet.WRAP_CONTENT)
+ constrainWidth(sharedR.id.date_smartspace_view, ConstraintSet.WRAP_CONTENT)
+ connect(
+ sharedR.id.date_smartspace_view,
+ ConstraintSet.START,
+ customR.id.lockscreen_clock_view,
+ ConstraintSet.END,
+ context.resources.getDimensionPixelSize(
+ R.dimen.smartspace_padding_horizontal
+ ),
+ )
+ connect(
+ sharedR.id.date_smartspace_view,
+ ConstraintSet.TOP,
+ customR.id.lockscreen_clock_view,
+ ConstraintSet.TOP,
+ )
+ connect(
+ sharedR.id.date_smartspace_view,
+ ConstraintSet.BOTTOM,
+ customR.id.lockscreen_clock_view,
+ ConstraintSet.BOTTOM,
+ )
+ }
+ }
+ }
- connect(
- sharedR.id.date_smartspace_view,
- ConstraintSet.START,
- customR.id.lockscreen_clock_view,
- ConstraintSet.END,
- context.resources.getDimensionPixelSize(
- R.dimen.smartspace_padding_horizontal
- ),
- )
- connect(
- sharedR.id.date_smartspace_view,
- ConstraintSet.TOP,
- customR.id.lockscreen_clock_view,
- ConstraintSet.TOP,
- )
- connect(
- sharedR.id.date_smartspace_view,
- ConstraintSet.BOTTOM,
- sharedR.id.weather_smartspace_view,
- ConstraintSet.TOP,
- )
- connect(
- sharedR.id.weather_smartspace_view,
- ConstraintSet.START,
- sharedR.id.date_smartspace_view,
- ConstraintSet.START,
- )
- connect(
- sharedR.id.weather_smartspace_view,
- ConstraintSet.TOP,
- sharedR.id.date_smartspace_view,
- ConstraintSet.BOTTOM,
+ if (com.android.systemui.shared.Flags.clockReactiveSmartspaceLayout()) {
+ if (dateWeatherBelowSmallClock) {
+ createBarrier(
+ R.id.smart_space_barrier_bottom,
+ Barrier.BOTTOM,
+ 0,
+ *intArrayOf(sharedR.id.bc_smartspace_view, sharedR.id.date_smartspace_view),
)
- connect(
- sharedR.id.weather_smartspace_view,
- ConstraintSet.BOTTOM,
- customR.id.lockscreen_clock_view,
- ConstraintSet.BOTTOM,
+ createBarrier(
+ R.id.smart_space_barrier_top,
+ Barrier.TOP,
+ 0,
+ *intArrayOf(sharedR.id.bc_smartspace_view, sharedR.id.date_smartspace_view),
)
-
- setVerticalChainStyle(
- sharedR.id.weather_smartspace_view,
- ConstraintSet.CHAIN_PACKED,
+ } else {
+ createBarrier(
+ R.id.smart_space_barrier_bottom,
+ Barrier.BOTTOM,
+ 0,
+ sharedR.id.bc_smartspace_view,
)
- setVerticalChainStyle(
- sharedR.id.date_smartspace_view,
- ConstraintSet.CHAIN_PACKED,
+ createBarrier(
+ R.id.smart_space_barrier_top,
+ Barrier.TOP,
+ 0,
+ sharedR.id.bc_smartspace_view,
)
}
- }
-
- if (com.android.systemui.shared.Flags.clockReactiveSmartspaceLayout()) {
- createBarrier(
- R.id.smart_space_barrier_bottom,
- Barrier.BOTTOM,
- 0,
- sharedR.id.bc_smartspace_view,
- )
- createBarrier(
- R.id.smart_space_barrier_top,
- Barrier.TOP,
- 0,
- sharedR.id.bc_smartspace_view,
- )
} else {
createBarrier(
R.id.smart_space_barrier_bottom,
@@ -373,13 +365,7 @@ constructor(
val list =
if (com.android.systemui.shared.Flags.clockReactiveSmartspaceLayout()) {
- listOf(
- smartspaceView,
- dateView,
- weatherView,
- weatherViewLargeClock,
- dateViewLargeClock,
- )
+ listOf(smartspaceView, dateView, dateViewLargeClock)
} else {
listOf(smartspaceView, dateView)
}
@@ -424,10 +410,8 @@ constructor(
if (com.android.systemui.shared.Flags.clockReactiveSmartspaceLayout()) {
if (keyguardClockViewModel.isLargeClockVisible.value) {
- setVisibility(sharedR.id.weather_smartspace_view, GONE)
setVisibility(sharedR.id.date_smartspace_view, GONE)
} else {
- setVisibility(sharedR.id.weather_smartspace_view_large, GONE)
setVisibility(sharedR.id.date_smartspace_view_large, GONE)
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/transitions/ClockSizeTransition.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/transitions/ClockSizeTransition.kt
index 434d7eadd742..d830a8456d66 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/transitions/ClockSizeTransition.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/transitions/ClockSizeTransition.kt
@@ -299,14 +299,12 @@ class ClockSizeTransition(
}
if (com.android.systemui.shared.Flags.clockReactiveSmartspaceLayout()) {
addTarget(sharedR.id.date_smartspace_view_large)
- addTarget(sharedR.id.weather_smartspace_view_large)
}
} else {
logger.i("Adding small clock")
addTarget(customR.id.lockscreen_clock_view)
- if (com.android.systemui.shared.Flags.clockReactiveSmartspaceLayout()) {
+ if (!viewModel.dateWeatherBelowSmallClock()) {
addTarget(sharedR.id.date_smartspace_view)
- addTarget(sharedR.id.weather_smartspace_view)
}
}
}
@@ -386,7 +384,7 @@ class ClockSizeTransition(
duration =
if (isLargeClock) STATUS_AREA_MOVE_UP_MILLIS else STATUS_AREA_MOVE_DOWN_MILLIS
interpolator = Interpolators.EMPHASIZED
- if (!com.android.systemui.shared.Flags.clockReactiveSmartspaceLayout()) {
+ if (viewModel.dateWeatherBelowSmallClock()) {
addTarget(sharedR.id.date_smartspace_view)
}
addTarget(sharedR.id.bc_smartspace_view)
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/transitions/DefaultClockSteppingTransition.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/transitions/DefaultClockSteppingTransition.kt
index 0874b6da180e..9faca7567279 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/transitions/DefaultClockSteppingTransition.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/transitions/DefaultClockSteppingTransition.kt
@@ -32,7 +32,6 @@ class DefaultClockSteppingTransition(private val clock: ClockController) : Trans
addTarget(clock.largeClock.view)
if (com.android.systemui.shared.Flags.clockReactiveSmartspaceLayout()) {
addTarget(sharedR.id.date_smartspace_view_large)
- addTarget(sharedR.id.weather_smartspace_view_large)
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardClockViewModel.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardClockViewModel.kt
index dcbf7b5a9335..cf6845354f44 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardClockViewModel.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardClockViewModel.kt
@@ -180,6 +180,9 @@ constructor(
val largeClockTextSize: Flow<Int> =
configurationInteractor.dimensionPixelSize(customR.dimen.large_clock_text_size)
+ fun dateWeatherBelowSmallClock() =
+ KeyguardSmartspaceViewModel.dateWeatherBelowSmallClock(context.resources.configuration)
+
enum class ClockLayout {
LARGE_CLOCK,
SMALL_CLOCK,
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 5cc34e749b46..a00d0ced2c07 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
@@ -17,6 +17,8 @@
package com.android.systemui.keyguard.ui.viewmodel
import android.content.Context
+import android.content.res.Configuration
+import android.util.Log
import com.android.systemui.customization.R as customR
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Application
@@ -94,6 +96,43 @@ constructor(
val isShadeLayoutWide: StateFlow<Boolean> = shadeModeInteractor.isShadeLayoutWide
companion object {
+ private const val TAG = "KeyguardSmartspaceVM"
+
+ fun dateWeatherBelowSmallClock(
+ configuration: Configuration,
+ customDateWeather: Boolean = false,
+ ): Boolean {
+ return if (
+ com.android.systemui.shared.Flags.clockReactiveSmartspaceLayout() &&
+ !customDateWeather
+ ) {
+ // font size to display size
+ // These values come from changing the font size and display size on a non-foldable.
+ // Visually looked at which configs cause the date/weather to push off of the screen
+ val breakingPairs =
+ listOf(
+ 0.85f to 320, // tiny font size but large display size
+ 1f to 346,
+ 1.15f to 346,
+ 1.5f to 376,
+ 1.8f to 411, // large font size but tiny display size
+ )
+ val screenWidthDp = configuration.screenWidthDp
+ val fontScale = configuration.fontScale
+ var fallBelow = false
+ for ((font, width) in breakingPairs) {
+ if (fontScale >= font && screenWidthDp <= width) {
+ fallBelow = true
+ break
+ }
+ }
+ Log.d(TAG, "Width: $screenWidthDp, Font: $fontScale, BelowClock: $fallBelow")
+ return fallBelow
+ } else {
+ true
+ }
+ }
+
fun getDateWeatherStartMargin(context: Context): Int {
return context.resources.getDimensionPixelSize(R.dimen.below_clock_padding_start) +
context.resources.getDimensionPixelSize(customR.dimen.status_view_margin_horizontal)