Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 221ffc2b authored by Brad Hinegardner's avatar Brad Hinegardner
Browse files

Adjust dateview linearlayout orientation in proper location

addViews isn't always called on blueprint refresh, whereas
applyConstraints is

Bug: 406343970
Test: atest SmartspaceSectionTest
Flag: com.android.systemui.shared.clock_reactive_smartspace_layout
Change-Id: Ie42b88a277e92974e38441711af2eadb32d812ae
parent 4c21197c
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -91,7 +91,8 @@ class SmartspaceSectionTest : SysuiTestCase() {
            .thenReturn(smartspaceView)
        whenever(lockscreenSmartspaceController.buildAndConnectWeatherView(any(), any()))
            .thenReturn(weatherView)
        whenever(lockscreenSmartspaceController.buildAndConnectDateView(any(), any())).thenReturn(dateView)
        whenever(lockscreenSmartspaceController.buildAndConnectDateView(any(), any()))
            .thenReturn(dateView)
        whenever(keyguardClockViewModel.hasCustomWeatherDataDisplay)
            .thenReturn(hasCustomWeatherDataDisplay)
        whenever(keyguardClockViewModel.clockShouldBeCentered).thenReturn(clockShouldBeCentered)
@@ -123,6 +124,7 @@ class SmartspaceSectionTest : SysuiTestCase() {
    }

    @Test
    @DisableFlags(com.android.systemui.shared.Flags.FLAG_CLOCK_REACTIVE_SMARTSPACE_LAYOUT)
    fun testAddViews_smartspaceEnabled_notDateWeatherDecoupled() {
        whenever(keyguardSmartspaceViewModel.isDateWeatherDecoupled).thenReturn(false)
        underTest.addViews(constraintLayout)
+16 −8
Original line number Diff line number Diff line
@@ -126,7 +126,8 @@ class KeyguardSmartspaceViewModelTest : SysuiTestCase() {
    @Test
    @DisableFlags(com.android.systemui.shared.Flags.FLAG_CLOCK_REACTIVE_SMARTSPACE_LAYOUT)
    fun dateWeatherBelowSmallClock_smartspacelayoutflag_off_true() {
        val result = KeyguardSmartspaceViewModel.dateWeatherBelowSmallClock(mockConfiguration)
        val result =
            KeyguardSmartspaceViewModel.dateWeatherBelowSmallClock(mockConfiguration, false)

        assertThat(result).isTrue()
    }
@@ -139,7 +140,8 @@ class KeyguardSmartspaceViewModelTest : SysuiTestCase() {
        mockConfiguration.fontScale = fontScale
        mockConfiguration.screenWidthDp = screenWidthDp

        val result = KeyguardSmartspaceViewModel.dateWeatherBelowSmallClock(mockConfiguration)
        val result =
            KeyguardSmartspaceViewModel.dateWeatherBelowSmallClock(mockConfiguration, false)

        assertThat(result).isFalse()
    }
@@ -149,17 +151,20 @@ class KeyguardSmartspaceViewModelTest : SysuiTestCase() {
    fun dateWeatherBelowSmallClock_variousFontAndDisplaySize_false() {
        mockConfiguration.fontScale = 1.0f
        mockConfiguration.screenWidthDp = 347
        val result1 = KeyguardSmartspaceViewModel.dateWeatherBelowSmallClock(mockConfiguration)
        val result1 =
            KeyguardSmartspaceViewModel.dateWeatherBelowSmallClock(mockConfiguration, false)
        assertThat(result1).isFalse()

        mockConfiguration.fontScale = 1.2f
        mockConfiguration.screenWidthDp = 347
        val result2 = KeyguardSmartspaceViewModel.dateWeatherBelowSmallClock(mockConfiguration)
        val result2 =
            KeyguardSmartspaceViewModel.dateWeatherBelowSmallClock(mockConfiguration, false)
        assertThat(result2).isFalse()

        mockConfiguration.fontScale = 1.7f
        mockConfiguration.screenWidthDp = 412
        val result3 = KeyguardSmartspaceViewModel.dateWeatherBelowSmallClock(mockConfiguration)
        val result3 =
            KeyguardSmartspaceViewModel.dateWeatherBelowSmallClock(mockConfiguration, false)
        assertThat(result3).isFalse()
    }

@@ -168,17 +173,20 @@ class KeyguardSmartspaceViewModelTest : SysuiTestCase() {
    fun dateWeatherBelowSmallClock_variousFontAndDisplaySize_true() {
        mockConfiguration.fontScale = 1.0f
        mockConfiguration.screenWidthDp = 310
        val result1 = KeyguardSmartspaceViewModel.dateWeatherBelowSmallClock(mockConfiguration)
        val result1 =
            KeyguardSmartspaceViewModel.dateWeatherBelowSmallClock(mockConfiguration, false)
        assertThat(result1).isTrue()

        mockConfiguration.fontScale = 1.5f
        mockConfiguration.screenWidthDp = 347
        val result2 = KeyguardSmartspaceViewModel.dateWeatherBelowSmallClock(mockConfiguration)
        val result2 =
            KeyguardSmartspaceViewModel.dateWeatherBelowSmallClock(mockConfiguration, false)
        assertThat(result2).isTrue()

        mockConfiguration.fontScale = 2.0f
        mockConfiguration.screenWidthDp = 411
        val result3 = KeyguardSmartspaceViewModel.dateWeatherBelowSmallClock(mockConfiguration)
        val result3 =
            KeyguardSmartspaceViewModel.dateWeatherBelowSmallClock(mockConfiguration, false)
        assertThat(result3).isTrue()
    }
}
+1 −5
Original line number Diff line number Diff line
@@ -143,11 +143,7 @@ object KeyguardSmartspaceViewBinder {
                                        view.top = (clockBounds.bottom + yBuffer + offset).toInt()
                                        view.bottom = view.top + viewHeight
                                    }
                                } else if (
                                    !KeyguardSmartspaceViewModel.dateWeatherBelowSmallClock(
                                        keyguardRootView.resources.configuration
                                    )
                                ) {
                                } else if (!clockViewModel.dateWeatherBelowSmallClock()) {
                                    keyguardRootView.findViewById<View>(smallViewId)?.let { view ->
                                        val viewWidth = view.width
                                        if (view.isLayoutRtl()) {
+2 −7
Original line number Diff line number Diff line
@@ -121,11 +121,7 @@ constructor(
            setAlpha(getNonTargetClockFace(clock).views, 0F)

            if (!keyguardClockViewModel.isLargeClockVisible.value) {
                if (
                    KeyguardSmartspaceViewModel.dateWeatherBelowSmallClock(
                        context.resources.configuration
                    )
                ) {
                if (keyguardClockViewModel.dateWeatherBelowSmallClock()) {
                    connect(
                        sharedR.id.bc_smartspace_view,
                        TOP,
@@ -191,8 +187,7 @@ constructor(
        val guideline =
            if (keyguardClockViewModel.clockShouldBeCentered.value) PARENT_ID
            else R.id.split_shade_guideline
        val dateWeatherBelowSmallClock =
            KeyguardSmartspaceViewModel.dateWeatherBelowSmallClock(context.resources.configuration)
        val dateWeatherBelowSmallClock = keyguardClockViewModel.dateWeatherBelowSmallClock()
        constraints.apply {
            connect(customR.id.lockscreen_clock_view_large, START, PARENT_ID, START)
            connect(customR.id.lockscreen_clock_view_large, END, guideline, END)
+9 −13
Original line number Diff line number Diff line
@@ -58,7 +58,7 @@ constructor(
    private val keyguardRootViewModel: KeyguardRootViewModel,
) : KeyguardSection() {
    private var smartspaceView: View? = null
    private var dateView: ViewGroup? = null
    private var dateView: LinearLayout? = null
    private var dateViewLargeClock: ViewGroup? = null

    private var smartspaceVisibilityListener: OnGlobalLayoutListener? = null
@@ -77,7 +77,7 @@ constructor(
        if (!keyguardSmartspaceViewModel.isSmartspaceEnabled) return
        smartspaceView = smartspaceController.buildAndConnectView(constraintLayout)
        dateView =
            smartspaceController.buildAndConnectDateView(constraintLayout, false) as? ViewGroup
            smartspaceController.buildAndConnectDateView(constraintLayout, false) as? LinearLayout
        var weatherViewLargeClock: View? = null
        val weatherView: View? =
            smartspaceController.buildAndConnectWeatherView(constraintLayout, false)
@@ -98,17 +98,6 @@ constructor(
                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) {
@@ -153,6 +142,13 @@ constructor(
                context.resources.configuration,
                keyguardClockViewModel.hasCustomWeatherDataDisplay.value,
            )
        if (com.android.systemui.shared.Flags.clockReactiveSmartspaceLayout()) {
            if (dateWeatherBelowSmallClock) {
                dateView?.orientation = LinearLayout.HORIZONTAL
            } else {
                dateView?.orientation = LinearLayout.VERTICAL
            }
        }
        constraintSet.apply {
            constrainHeight(sharedR.id.date_smartspace_view, ConstraintSet.WRAP_CONTENT)
            constrainWidth(sharedR.id.date_smartspace_view, ConstraintSet.WRAP_CONTENT)
Loading