diff options
3 files changed, 14 insertions, 45 deletions
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 6b11dc57e096..191056c5578a 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 @@ -121,10 +121,7 @@ object KeyguardSmartspaceViewBinder { ) { val dateView = constraintLayout.requireViewById<View>(sharedR.id.date_smartspace_view) - val weatherView = - constraintLayout.requireViewById<View>(sharedR.id.weather_smartspace_view) addView(dateView) - addView(weatherView) } } } @@ -141,9 +138,6 @@ object KeyguardSmartspaceViewBinder { ) { val dateView = constraintLayout.requireViewById<View>(sharedR.id.date_smartspace_view) - val weatherView = - constraintLayout.requireViewById<View>(sharedR.id.weather_smartspace_view) - removeView(weatherView) removeView(dateView) } } 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 0435531bb87c..8a751f05e102 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 @@ -18,6 +18,7 @@ package com.android.systemui.keyguard.ui.view.layout.sections import android.content.Context import android.view.View +import android.view.ViewGroup import android.view.ViewTreeObserver.OnGlobalLayoutListener import androidx.constraintlayout.widget.Barrier import androidx.constraintlayout.widget.ConstraintLayout @@ -51,7 +52,7 @@ constructor( ) : KeyguardSection() { private var smartspaceView: View? = null private var weatherView: View? = null - private var dateView: View? = null + private var dateWeatherView: ViewGroup? = null private var smartspaceVisibilityListener: OnGlobalLayoutListener? = null private var pastVisibility: Int = -1 @@ -69,12 +70,15 @@ constructor( if (!keyguardSmartspaceViewModel.isSmartspaceEnabled) return smartspaceView = smartspaceController.buildAndConnectView(constraintLayout) weatherView = smartspaceController.buildAndConnectWeatherView(constraintLayout) - dateView = smartspaceController.buildAndConnectDateView(constraintLayout) + dateWeatherView = + smartspaceController.buildAndConnectDateView(constraintLayout) as ViewGroup pastVisibility = smartspaceView?.visibility ?: View.GONE constraintLayout.addView(smartspaceView) if (keyguardSmartspaceViewModel.isDateWeatherDecoupled) { - constraintLayout.addView(weatherView) - constraintLayout.addView(dateView) + constraintLayout.addView(dateWeatherView) + // Place weather right after the date, before the extras (alarm and dnd) + val index = if (dateWeatherView?.childCount == 0) 0 else 1 + dateWeatherView?.addView(weatherView, index) } keyguardUnlockAnimationController.lockscreenSmartspace = smartspaceView smartspaceVisibilityListener = OnGlobalLayoutListener { @@ -116,26 +120,6 @@ constructor( ConstraintSet.START, horizontalPaddingStart ) - constrainWidth(sharedR.id.weather_smartspace_view, ConstraintSet.WRAP_CONTENT) - connect( - sharedR.id.weather_smartspace_view, - ConstraintSet.TOP, - sharedR.id.date_smartspace_view, - ConstraintSet.TOP - ) - connect( - sharedR.id.weather_smartspace_view, - ConstraintSet.BOTTOM, - sharedR.id.date_smartspace_view, - ConstraintSet.BOTTOM - ) - connect( - sharedR.id.weather_smartspace_view, - ConstraintSet.START, - sharedR.id.date_smartspace_view, - ConstraintSet.END, - 4 - ) // migrate addSmartspaceView from KeyguardClockSwitchController constrainHeight(sharedR.id.bc_smartspace_view, ConstraintSet.WRAP_CONTENT) @@ -186,7 +170,6 @@ constructor( *intArrayOf( sharedR.id.bc_smartspace_view, sharedR.id.date_smartspace_view, - sharedR.id.weather_smartspace_view, ) ) } @@ -196,7 +179,7 @@ constructor( override fun removeViews(constraintLayout: ConstraintLayout) { if (!MigrateClocksToBlueprint.isEnabled) return if (!keyguardSmartspaceViewModel.isSmartspaceEnabled) return - listOf(smartspaceView, dateView, weatherView).forEach { + listOf(smartspaceView, dateWeatherView).forEach { it?.let { if (it.parent == constraintLayout) { constraintLayout.removeView(it) @@ -220,7 +203,7 @@ constructor( setVisibility(sharedR.id.weather_smartspace_view, weatherVisibility) setAlpha( sharedR.id.weather_smartspace_view, - if (weatherVisibility == ConstraintSet.VISIBLE) 1f else 0f + if (weatherVisibility == View.VISIBLE) 1f else 0f ) val dateVisibility = if (keyguardClockViewModel.hasCustomWeatherDataDisplay.value) ConstraintSet.GONE diff --git a/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/view/layout/sections/SmartspaceSectionTest.kt b/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/view/layout/sections/SmartspaceSectionTest.kt index 7d4f03453fa7..201ee88cdd80 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/view/layout/sections/SmartspaceSectionTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/view/layout/sections/SmartspaceSectionTest.kt @@ -18,6 +18,7 @@ package com.android.systemui.keyguard.ui.view.layout.sections import android.view.View +import android.widget.LinearLayout import androidx.constraintlayout.widget.ConstraintLayout import androidx.constraintlayout.widget.ConstraintSet import androidx.constraintlayout.widget.ConstraintSet.GONE @@ -58,7 +59,7 @@ class SmartspaceSectionTest : SysuiTestCase() { private val smartspaceView = View(mContext).also { it.id = sharedR.id.bc_smartspace_view } private val weatherView = View(mContext).also { it.id = sharedR.id.weather_smartspace_view } - private val dateView = View(mContext).also { it.id = sharedR.id.date_smartspace_view } + private val dateView = LinearLayout(mContext).also { it.id = sharedR.id.date_smartspace_view } private lateinit var constraintLayout: ConstraintLayout private lateinit var constraintSet: ConstraintSet @@ -109,7 +110,7 @@ class SmartspaceSectionTest : SysuiTestCase() { whenever(keyguardSmartspaceViewModel.isDateWeatherDecoupled).thenReturn(true) underTest.addViews(constraintLayout) assert(smartspaceView.parent == constraintLayout) - assert(weatherView.parent == constraintLayout) + assertThat(weatherView.parent).isEqualTo(dateView) assert(dateView.parent == constraintLayout) } @@ -127,7 +128,7 @@ class SmartspaceSectionTest : SysuiTestCase() { whenever(keyguardSmartspaceViewModel.isDateWeatherDecoupled).thenReturn(true) underTest.addViews(constraintLayout) underTest.applyConstraints(constraintSet) - assertWeatherSmartspaceConstrains(constraintSet) + assertThat(weatherView.parent).isEqualTo(dateView) val smartspaceConstraints = constraintSet.getConstraint(smartspaceView.id) assertThat(smartspaceConstraints.layout.topToBottom).isEqualTo(dateView.id) @@ -141,7 +142,6 @@ class SmartspaceSectionTest : SysuiTestCase() { hasCustomWeatherDataDisplay.value = true underTest.addViews(constraintLayout) underTest.applyConstraints(constraintSet) - assertWeatherSmartspaceConstrains(constraintSet) val dateConstraints = constraintSet.getConstraint(dateView.id) assertThat(dateConstraints.layout.bottomToTop).isEqualTo(smartspaceView.id) @@ -168,12 +168,4 @@ class SmartspaceSectionTest : SysuiTestCase() { assertThat(constraintSet.getVisibility(weatherView.id)).isEqualTo(GONE) assertThat(constraintSet.getVisibility(dateView.id)).isEqualTo(GONE) } - - private fun assertWeatherSmartspaceConstrains(cs: ConstraintSet) { - val weatherConstraints = cs.getConstraint(weatherView.id) - assertThat(weatherConstraints.layout.topToTop).isEqualTo(dateView.id) - assertThat(weatherConstraints.layout.bottomToBottom).isEqualTo(dateView.id) - assertThat(weatherConstraints.layout.startToEnd).isEqualTo(dateView.id) - assertThat(weatherConstraints.layout.startMargin).isEqualTo(4) - } } |