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

Commit a3e59dc9 authored by Brad Hinegardner's avatar Brad Hinegardner Committed by Android (Google) Code Review
Browse files

Merge "Move Date and Weather on Lockscreen and AOD" into main

parents 3bd05102 1b4be9b4
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -159,7 +159,7 @@ constructor(
            factory = { context ->
                FrameLayout(context).apply {
                    addView(
                        lockscreenSmartspaceController.buildAndConnectWeatherView(this).apply {
                        lockscreenSmartspaceController.buildAndConnectWeatherView(this, false).apply {
                            layoutParams =
                                FrameLayout.LayoutParams(
                                    FrameLayout.LayoutParams.WRAP_CONTENT,
@@ -184,7 +184,7 @@ constructor(
            factory = { context ->
                FrameLayout(context).apply {
                    addView(
                        lockscreenSmartspaceController.buildAndConnectDateView(this).apply {
                        lockscreenSmartspaceController.buildAndConnectDateView(this, false).apply {
                            layoutParams =
                                FrameLayout.LayoutParams(
                                    FrameLayout.LayoutParams.WRAP_CONTENT,
+99 −1
Original line number Diff line number Diff line
@@ -19,6 +19,8 @@ package com.android.systemui.keyguard.ui.view.layout.sections

import android.content.pm.PackageManager
import android.content.res.Resources
import android.platform.test.annotations.DisableFlags
import android.platform.test.annotations.EnableFlags
import android.view.View.GONE
import android.view.View.VISIBLE
import androidx.constraintlayout.widget.ConstraintSet
@@ -128,6 +130,7 @@ class ClockSectionTest : SysuiTestCase() {
    }

    @Test
    @DisableFlags(com.android.systemui.shared.Flags.FLAG_CLOCK_REACTIVE_VARIANTS)
    fun testApplyDefaultConstraints_LargeClock_SplitShade() =
        kosmos.testScope.runTest {
            with(kosmos) {
@@ -144,6 +147,25 @@ class ClockSectionTest : SysuiTestCase() {
        }

    @Test
    @EnableFlags(com.android.systemui.shared.Flags.FLAG_CLOCK_REACTIVE_VARIANTS)
    fun testApplyDefaultConstraints_LargeClock_SplitShade_ReactiveVariantsOn() =
        kosmos.testScope.runTest {
            with(kosmos) {
                shadeRepository.setShadeLayoutWide(true)
                keyguardClockInteractor.setClockSize(ClockSize.LARGE)
                advanceUntilIdle()
            }

            val cs = ConstraintSet()
            underTest.applyDefaultConstraints(cs)

            assertLargeClockTop(cs, LARGE_CLOCK_TOP_WITHOUT_SMARTSPACE +
                    ENHANCED_SMART_SPACE_HEIGHT)
            assertSmallClockTop(cs)
        }

    @Test
    @DisableFlags(com.android.systemui.shared.Flags.FLAG_CLOCK_REACTIVE_VARIANTS)
    fun testApplyDefaultConstraints_LargeClock_NonSplitShade() =
        kosmos.testScope.runTest {
            with(kosmos) {
@@ -166,6 +188,31 @@ class ClockSectionTest : SysuiTestCase() {
            }
        }

    @Test
    @EnableFlags(com.android.systemui.shared.Flags.FLAG_CLOCK_REACTIVE_VARIANTS)
    fun testApplyDefaultConstraints_LargeClock_NonSplitShade_reactiveVariantsOn() =
        kosmos.testScope.runTest {
            with(kosmos) {
                val isShadeLayoutWide by collectLastValue(shadeRepository.isShadeLayoutWide)
                val isLargeClockVisible by
                    collectLastValue(keyguardClockViewModel.isLargeClockVisible)

                shadeRepository.setShadeLayoutWide(false)
                keyguardClockInteractor.setClockSize(ClockSize.LARGE)
                notificationsKeyguardInteractor.setNotificationsFullyHidden(true)
                keyguardSmartspaceInteractor.setBcSmartspaceVisibility(VISIBLE)
                fakeConfigurationController.notifyConfigurationChanged()
                advanceUntilIdle()

                val cs = ConstraintSet()
                underTest.applyDefaultConstraints(cs)

                assertLargeClockTop(cs, LARGE_CLOCK_TOP_WITHOUT_SMARTSPACE +
                        ENHANCED_SMART_SPACE_HEIGHT)
                assertSmallClockTop(cs)
            }
        }

    @Test
    fun testApplyDefaultConstraints_LargeClock_MissingSmartspace_SplitShade() =
        kosmos.testScope.runTest {
@@ -215,6 +262,7 @@ class ClockSectionTest : SysuiTestCase() {
        }

    @Test
    @DisableFlags(com.android.systemui.shared.Flags.FLAG_CLOCK_REACTIVE_VARIANTS)
    fun testApplyDefaultConstraints_SmallClock_SplitShade() =
        kosmos.testScope.runTest {
            with(kosmos) {
@@ -238,6 +286,32 @@ class ClockSectionTest : SysuiTestCase() {
        }

    @Test
    @EnableFlags(com.android.systemui.shared.Flags.FLAG_CLOCK_REACTIVE_VARIANTS)
    fun testApplyDefaultConstraints_SmallClock_SplitShade_ReactiveVariantsOn() =
        kosmos.testScope.runTest {
            with(kosmos) {
                val isShadeLayoutWide by collectLastValue(shadeRepository.isShadeLayoutWide)
                val isLargeClockVisible by
                collectLastValue(keyguardClockViewModel.isLargeClockVisible)

                shadeRepository.setShadeLayoutWide(true)
                keyguardClockInteractor.setClockSize(ClockSize.SMALL)
                notificationsKeyguardInteractor.setNotificationsFullyHidden(true)
                keyguardSmartspaceInteractor.setBcSmartspaceVisibility(VISIBLE)
                fakeConfigurationController.notifyConfigurationChanged()
                advanceUntilIdle()

                val cs = ConstraintSet()
                underTest.applyDefaultConstraints(cs)

                assertLargeClockTop(cs, LARGE_CLOCK_TOP_WITHOUT_SMARTSPACE +
                        ENHANCED_SMART_SPACE_HEIGHT)
                assertSmallClockTop(cs)
            }
        }

    @Test
    @DisableFlags(com.android.systemui.shared.Flags.FLAG_CLOCK_REACTIVE_VARIANTS)
    fun testApplyDefaultConstraints_SmallClock_NonSplitShade() =
        kosmos.testScope.runTest {
            with(kosmos) {
@@ -259,6 +333,30 @@ class ClockSectionTest : SysuiTestCase() {
            }
        }

    @Test
    @EnableFlags(com.android.systemui.shared.Flags.FLAG_CLOCK_REACTIVE_VARIANTS)
    fun testApplyDefaultConstraints_SmallClock_NonSplitShade_ReactiveVariantsOn() =
        kosmos.testScope.runTest {
            with(kosmos) {
                val isShadeLayoutWide by collectLastValue(shadeRepository.isShadeLayoutWide)
                val isLargeClockVisible by
                collectLastValue(keyguardClockViewModel.isLargeClockVisible)

                shadeRepository.setShadeLayoutWide(false)
                keyguardClockInteractor.setClockSize(ClockSize.SMALL)
                notificationsKeyguardInteractor.setNotificationsFullyHidden(true)
                keyguardSmartspaceInteractor.setBcSmartspaceVisibility(VISIBLE)
                fakeConfigurationController.notifyConfigurationChanged()
                advanceUntilIdle()

                val cs = ConstraintSet()
                underTest.applyDefaultConstraints(cs)
                assertLargeClockTop(cs, LARGE_CLOCK_TOP_WITHOUT_SMARTSPACE +
                        ENHANCED_SMART_SPACE_HEIGHT)
                assertSmallClockTop(cs)
            }
        }

    @Test
    fun testSmartspaceVisible_weatherClockDateAndIconsBarrierBottomBelowBCSmartspace() =
        kosmos.testScope.runTest {
+15 −2
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@

package com.android.systemui.keyguard.ui.view.layout.sections

import android.platform.test.annotations.DisableFlags
import android.view.View
import android.widget.LinearLayout
import androidx.constraintlayout.widget.ConstraintLayout
@@ -31,6 +32,7 @@ import com.android.systemui.keyguard.KeyguardUnlockAnimationController
import com.android.systemui.keyguard.domain.interactor.KeyguardBlueprintInteractor
import com.android.systemui.keyguard.domain.interactor.KeyguardSmartspaceInteractor
import com.android.systemui.keyguard.ui.viewmodel.KeyguardClockViewModel
import com.android.systemui.keyguard.ui.viewmodel.KeyguardRootViewModel
import com.android.systemui.keyguard.ui.viewmodel.KeyguardSmartspaceViewModel
import com.android.systemui.res.R
import com.android.systemui.shared.R as sharedR
@@ -48,6 +50,7 @@ import org.mockito.MockitoAnnotations

@RunWith(AndroidJUnit4::class)
@SmallTest
@DisableFlags(com.android.systemui.shared.Flags.FLAG_CLOCK_REACTIVE_VARIANTS)
class SmartspaceSectionTest : SysuiTestCase() {
    private lateinit var underTest: SmartspaceSection
    @Mock private lateinit var keyguardClockViewModel: KeyguardClockViewModel
@@ -56,6 +59,7 @@ class SmartspaceSectionTest : SysuiTestCase() {
    @Mock private lateinit var keyguardUnlockAnimationController: KeyguardUnlockAnimationController
    @Mock private lateinit var keyguardSmartspaceInteractor: KeyguardSmartspaceInteractor
    @Mock private lateinit var blueprintInteractor: Lazy<KeyguardBlueprintInteractor>
    @Mock private lateinit var keyguardRootViewModel: KeyguardRootViewModel

    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 }
@@ -80,13 +84,14 @@ class SmartspaceSectionTest : SysuiTestCase() {
                lockscreenSmartspaceController,
                keyguardUnlockAnimationController,
                blueprintInteractor,
                keyguardRootViewModel,
            )
        constraintLayout = ConstraintLayout(mContext)
        whenever(lockscreenSmartspaceController.buildAndConnectView(any()))
            .thenReturn(smartspaceView)
        whenever(lockscreenSmartspaceController.buildAndConnectWeatherView(any()))
        whenever(lockscreenSmartspaceController.buildAndConnectWeatherView(any(), any()))
            .thenReturn(weatherView)
        whenever(lockscreenSmartspaceController.buildAndConnectDateView(any())).thenReturn(dateView)
        whenever(lockscreenSmartspaceController.buildAndConnectDateView(any(), any())).thenReturn(dateView)
        whenever(keyguardClockViewModel.hasCustomWeatherDataDisplay)
            .thenReturn(hasCustomWeatherDataDisplay)
        whenever(keyguardClockViewModel.clockShouldBeCentered).thenReturn(clockShouldBeCentered)
@@ -97,6 +102,7 @@ class SmartspaceSectionTest : SysuiTestCase() {
    }

    @Test
    @DisableFlags(com.android.systemui.shared.Flags.FLAG_CLOCK_REACTIVE_VARIANTS)
    fun testAddViews_notSmartspaceEnabled() {
        whenever(keyguardSmartspaceViewModel.isSmartspaceEnabled).thenReturn(false)
        val constraintLayout = ConstraintLayout(mContext)
@@ -107,6 +113,7 @@ class SmartspaceSectionTest : SysuiTestCase() {
    }

    @Test
    @DisableFlags(com.android.systemui.shared.Flags.FLAG_CLOCK_REACTIVE_VARIANTS)
    fun testAddViews_smartspaceEnabled_dateWeatherDecoupled() {
        whenever(keyguardSmartspaceViewModel.isDateWeatherDecoupled).thenReturn(true)
        underTest.addViews(constraintLayout)
@@ -125,6 +132,7 @@ class SmartspaceSectionTest : SysuiTestCase() {
    }

    @Test
    @DisableFlags(com.android.systemui.shared.Flags.FLAG_CLOCK_REACTIVE_VARIANTS)
    fun testConstraintsWhenShadeLayoutIsNotWide() {
        underTest.addViews(constraintLayout)
        underTest.applyConstraints(constraintSet)
@@ -134,6 +142,7 @@ class SmartspaceSectionTest : SysuiTestCase() {
    }

    @Test
    @DisableFlags(com.android.systemui.shared.Flags.FLAG_CLOCK_REACTIVE_VARIANTS)
    fun testConstraintsWhenShadeLayoutIsWide() {
        isShadeLayoutWide.value = true

@@ -145,6 +154,7 @@ class SmartspaceSectionTest : SysuiTestCase() {
    }

    @Test
    @DisableFlags(com.android.systemui.shared.Flags.FLAG_CLOCK_REACTIVE_VARIANTS)
    fun testConstraintsWhenNotHasCustomWeatherDataDisplay() {
        whenever(keyguardSmartspaceViewModel.isDateWeatherDecoupled).thenReturn(true)
        underTest.addViews(constraintLayout)
@@ -159,6 +169,7 @@ class SmartspaceSectionTest : SysuiTestCase() {
    }

    @Test
    @DisableFlags(com.android.systemui.shared.Flags.FLAG_CLOCK_REACTIVE_VARIANTS)
    fun testConstraintsWhenHasCustomWeatherDataDisplay() {
        hasCustomWeatherDataDisplay.value = true
        underTest.addViews(constraintLayout)
@@ -169,6 +180,7 @@ class SmartspaceSectionTest : SysuiTestCase() {
    }

    @Test
    @DisableFlags(com.android.systemui.shared.Flags.FLAG_CLOCK_REACTIVE_VARIANTS)
    fun testNormalDateWeatherVisibility() {
        isWeatherVisibleFlow.value = true
        underTest.addViews(constraintLayout)
@@ -182,6 +194,7 @@ class SmartspaceSectionTest : SysuiTestCase() {
    }

    @Test
    @DisableFlags(com.android.systemui.shared.Flags.FLAG_CLOCK_REACTIVE_VARIANTS)
    fun testCustomDateWeatherVisibility() {
        hasCustomWeatherDataDisplay.value = true
        underTest.addViews(constraintLayout)
+2 −2
Original line number Diff line number Diff line
@@ -846,7 +846,7 @@ class LockscreenSmartspaceControllerTest : SysuiTestCase() {
    }

    private fun connectSession() {
        val dateView = controller.buildAndConnectDateView(fakeParent)
        val dateView = controller.buildAndConnectDateView(fakeParent, false)
        dateSmartspaceView = dateView as SmartspaceView
        fakeParent.addView(dateView)
        controller.stateChangeListener.onViewAttachedToWindow(dateView)
@@ -860,7 +860,7 @@ class LockscreenSmartspaceControllerTest : SysuiTestCase() {
        verify(dateSmartspaceView).setPrimaryTextColor(anyInt())
        verify(dateSmartspaceView).setDozeAmount(0.5f)

        val weatherView = controller.buildAndConnectWeatherView(fakeParent)
        val weatherView = controller.buildAndConnectWeatherView(fakeParent, false)
        weatherSmartspaceView = weatherView as SmartspaceView
        fakeParent.addView(weatherView)
        controller.stateChangeListener.onViewAttachedToWindow(weatherView)
+4 −0
Original line number Diff line number Diff line
@@ -85,6 +85,10 @@ public interface BcSmartspaceDataPlugin extends Plugin {
        throw new UnsupportedOperationException("Not implemented by " + getClass());
    }

    default SmartspaceView getLargeClockView(ViewGroup parent) {
        throw new UnsupportedOperationException("Not implemented by " + getClass());
    }

    /**
     * As the smartspace view becomes available, allow listeners to receive an event.
     */
Loading