Loading packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardSmartspaceViewBinder.kt +0 −6 Original line number Diff line number Diff line Loading @@ -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) } } } Loading @@ -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) } } Loading packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/SmartspaceSection.kt +10 −27 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -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 Loading @@ -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 { Loading Loading @@ -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) Loading Loading @@ -186,7 +170,6 @@ constructor( *intArrayOf( sharedR.id.bc_smartspace_view, sharedR.id.date_smartspace_view, sharedR.id.weather_smartspace_view, ) ) } Loading @@ -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) Loading @@ -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 Loading packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/view/layout/sections/SmartspaceSectionTest.kt +4 −12 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -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 Loading Loading @@ -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) } Loading @@ -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) Loading @@ -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) Loading @@ -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) } } Loading
packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardSmartspaceViewBinder.kt +0 −6 Original line number Diff line number Diff line Loading @@ -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) } } } Loading @@ -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) } } Loading
packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/SmartspaceSection.kt +10 −27 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -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 Loading @@ -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 { Loading Loading @@ -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) Loading Loading @@ -186,7 +170,6 @@ constructor( *intArrayOf( sharedR.id.bc_smartspace_view, sharedR.id.date_smartspace_view, sharedR.id.weather_smartspace_view, ) ) } Loading @@ -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) Loading @@ -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 Loading
packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/view/layout/sections/SmartspaceSectionTest.kt +4 −12 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -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 Loading Loading @@ -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) } Loading @@ -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) Loading @@ -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) Loading @@ -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) } }