Loading packages/SystemUI/compose/features/src/com/android/systemui/keyguard/ui/composable/blueprint/DefaultBlueprint.kt +22 −4 Original line number Diff line number Diff line Loading @@ -17,13 +17,16 @@ package com.android.systemui.keyguard.ui.composable.blueprint import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.layout.Layout import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.unit.IntRect import com.android.compose.animation.scene.SceneScope import com.android.compose.modifiers.padding import com.android.systemui.keyguard.domain.interactor.KeyguardClockInteractor import com.android.systemui.keyguard.ui.composable.LockscreenLongPress import com.android.systemui.keyguard.ui.composable.section.AmbientIndicationSection Loading Loading @@ -66,6 +69,7 @@ constructor( override fun SceneScope.Content(modifier: Modifier) { val isUdfpsVisible = viewModel.isUdfpsVisible val burnIn = rememberBurnIn(clockInteractor) val resources = LocalContext.current.resources LockscreenLongPress( viewModel = viewModel.longPress, Loading @@ -88,13 +92,27 @@ constructor( SmartSpace( burnInParams = burnIn.parameters, onTopChanged = burnIn.onSmartspaceTopChanged, modifier = Modifier.fillMaxWidth(), modifier = Modifier.fillMaxWidth() .padding( top = { viewModel.getSmartSpacePaddingTop(resources) } ), ) } if (viewModel.isLargeClockVisible) { Spacer(modifier = Modifier.weight(weight = 1f)) with(clockSection) { LargeClock(modifier = Modifier.fillMaxWidth()) } } if (viewModel.areNotificationsVisible) { with(notificationSection) { Notifications(modifier = Modifier.fillMaxWidth().weight(1f)) Notifications( modifier = Modifier.fillMaxWidth().weight(weight = 1f) ) } } if (!isUdfpsVisible && ambientIndicationSectionOptional.isPresent) { with(ambientIndicationSectionOptional.get()) { AmbientIndication(modifier = Modifier.fillMaxWidth()) Loading packages/SystemUI/compose/features/src/com/android/systemui/keyguard/ui/composable/blueprint/ShortcutsBesideUdfpsBlueprint.kt +22 −4 Original line number Diff line number Diff line Loading @@ -17,13 +17,16 @@ package com.android.systemui.keyguard.ui.composable.blueprint import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.layout.Layout import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.unit.IntRect import com.android.compose.animation.scene.SceneScope import com.android.compose.modifiers.padding import com.android.systemui.keyguard.domain.interactor.KeyguardClockInteractor import com.android.systemui.keyguard.ui.composable.LockscreenLongPress import com.android.systemui.keyguard.ui.composable.section.AmbientIndicationSection Loading Loading @@ -66,6 +69,7 @@ constructor( override fun SceneScope.Content(modifier: Modifier) { val isUdfpsVisible = viewModel.isUdfpsVisible val burnIn = rememberBurnIn(clockInteractor) val resources = LocalContext.current.resources LockscreenLongPress( viewModel = viewModel.longPress, Loading @@ -88,13 +92,27 @@ constructor( SmartSpace( burnInParams = burnIn.parameters, onTopChanged = burnIn.onSmartspaceTopChanged, modifier = Modifier.fillMaxWidth(), modifier = Modifier.fillMaxWidth() .padding( top = { viewModel.getSmartSpacePaddingTop(resources) } ), ) } if (viewModel.isLargeClockVisible) { Spacer(modifier = Modifier.weight(weight = 1f)) with(clockSection) { LargeClock(modifier = Modifier.fillMaxWidth()) } } if (viewModel.areNotificationsVisible) { with(notificationSection) { Notifications(modifier = Modifier.fillMaxWidth().weight(1f)) Notifications( modifier = Modifier.fillMaxWidth().weight(weight = 1f) ) } } if (!isUdfpsVisible && ambientIndicationSectionOptional.isPresent) { with(ambientIndicationSectionOptional.get()) { AmbientIndication(modifier = Modifier.fillMaxWidth()) Loading packages/SystemUI/compose/features/src/com/android/systemui/keyguard/ui/composable/section/ClockSection.kt +3 −5 Original line number Diff line number Diff line Loading @@ -30,10 +30,10 @@ import com.android.compose.animation.scene.ElementKey import com.android.compose.animation.scene.SceneScope import com.android.compose.modifiers.padding import com.android.keyguard.KeyguardClockSwitch import com.android.systemui.customization.R as customizationR import com.android.systemui.keyguard.domain.interactor.KeyguardClockInteractor import com.android.systemui.keyguard.ui.composable.modifier.onTopPlacementChanged import com.android.systemui.keyguard.ui.viewmodel.KeyguardClockViewModel import com.android.systemui.res.R import javax.inject.Inject class ClockSection Loading Loading @@ -79,7 +79,7 @@ constructor( modifier = Modifier.padding( horizontal = dimensionResource(R.dimen.keyguard_affordance_horizontal_offset) dimensionResource(customizationR.dimen.clock_padding_start) ) .padding(top = { viewModel.getSmallClockTopMargin(view.context) }) .onTopPlacementChanged(onTopChanged), Loading Loading @@ -117,9 +117,7 @@ constructor( content { AndroidView( factory = { checkNotNull(currentClock).largeClock.view }, modifier = Modifier.fillMaxWidth() .padding(top = { viewModel.getLargeClockTopMargin(view.context) }) modifier = Modifier.fillMaxWidth() ) } } Loading packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/LockscreenContentViewModelTest.kt 0 → 100644 +106 −0 Original line number Diff line number Diff line /* * Copyright (C) 2024 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.systemui.keyguard.ui.viewmodel import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.keyguard.KeyguardClockSwitch import com.android.systemui.SysuiTestCase import com.android.systemui.biometrics.authController import com.android.systemui.flags.Flags import com.android.systemui.flags.fakeFeatureFlagsClassic import com.android.systemui.keyguard.data.repository.fakeKeyguardClockRepository import com.android.systemui.kosmos.Kosmos import com.android.systemui.kosmos.testScope import com.android.systemui.testKosmos import com.android.systemui.util.mockito.whenever import com.google.common.truth.Truth.assertThat import kotlinx.coroutines.test.runTest import org.junit.Before import org.junit.Test import org.junit.runner.RunWith @SmallTest @RunWith(AndroidJUnit4::class) class LockscreenContentViewModelTest : SysuiTestCase() { private val kosmos: Kosmos = testKosmos() lateinit var underTest: LockscreenContentViewModel @Before fun setup() { with(kosmos) { fakeFeatureFlagsClassic.set(Flags.LOCK_SCREEN_LONG_PRESS_ENABLED, true) underTest = lockscreenContentViewModel } } @Test fun isUdfpsVisible_withUdfps_true() = with(kosmos) { testScope.runTest { whenever(kosmos.authController.isUdfpsSupported).thenReturn(true) assertThat(underTest.isUdfpsVisible).isTrue() } } @Test fun isUdfpsVisible_withoutUdfps_false() = with(kosmos) { testScope.runTest { whenever(kosmos.authController.isUdfpsSupported).thenReturn(false) assertThat(underTest.isUdfpsVisible).isFalse() } } @Test fun isLargeClockVisible_withLargeClock_true() = with(kosmos) { testScope.runTest { kosmos.fakeKeyguardClockRepository.setClockSize(KeyguardClockSwitch.LARGE) assertThat(underTest.isLargeClockVisible).isTrue() } } @Test fun isLargeClockVisible_withSmallClock_false() = with(kosmos) { testScope.runTest { kosmos.fakeKeyguardClockRepository.setClockSize(KeyguardClockSwitch.SMALL) assertThat(underTest.isLargeClockVisible).isFalse() } } @Test fun areNotificationsVisible_withSmallClock_true() = with(kosmos) { testScope.runTest { kosmos.fakeKeyguardClockRepository.setClockSize(KeyguardClockSwitch.SMALL) assertThat(underTest.areNotificationsVisible).isTrue() } } @Test fun areNotificationsVisible_withLargeClock_false() = with(kosmos) { testScope.runTest { kosmos.fakeKeyguardClockRepository.setClockSize(KeyguardClockSwitch.LARGE) assertThat(underTest.areNotificationsVisible).isFalse() } } } packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardClockViewModel.kt +0 −30 Original line number Diff line number Diff line Loading @@ -99,34 +99,4 @@ constructor( context.resources.getDimensionPixelSize(R.dimen.keyguard_clock_top_margin) + Utils.getStatusBarHeaderHeightKeyguard(context) } fun getLargeClockTopMargin(context: Context): Int { var largeClockTopMargin = context.resources.getDimensionPixelSize(R.dimen.status_bar_height) + context.resources.getDimensionPixelSize( com.android.systemui.customization.R.dimen.small_clock_padding_top ) + context.resources.getDimensionPixelSize(R.dimen.keyguard_smartspace_top_offset) largeClockTopMargin += getDimen(context, DATE_WEATHER_VIEW_HEIGHT) largeClockTopMargin += getDimen(context, ENHANCED_SMARTSPACE_HEIGHT) if (!useLargeClock) { largeClockTopMargin -= context.resources.getDimensionPixelSize( com.android.systemui.customization.R.dimen.small_clock_height ) } return largeClockTopMargin } private fun getDimen(context: Context, name: String): Int { val res = context.packageManager.getResourcesForApplication(context.packageName) val id = res.getIdentifier(name, "dimen", context.packageName) return res.getDimensionPixelSize(id) } companion object { private const val DATE_WEATHER_VIEW_HEIGHT = "date_weather_view_height" private const val ENHANCED_SMARTSPACE_HEIGHT = "enhanced_smartspace_height" } } Loading
packages/SystemUI/compose/features/src/com/android/systemui/keyguard/ui/composable/blueprint/DefaultBlueprint.kt +22 −4 Original line number Diff line number Diff line Loading @@ -17,13 +17,16 @@ package com.android.systemui.keyguard.ui.composable.blueprint import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.layout.Layout import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.unit.IntRect import com.android.compose.animation.scene.SceneScope import com.android.compose.modifiers.padding import com.android.systemui.keyguard.domain.interactor.KeyguardClockInteractor import com.android.systemui.keyguard.ui.composable.LockscreenLongPress import com.android.systemui.keyguard.ui.composable.section.AmbientIndicationSection Loading Loading @@ -66,6 +69,7 @@ constructor( override fun SceneScope.Content(modifier: Modifier) { val isUdfpsVisible = viewModel.isUdfpsVisible val burnIn = rememberBurnIn(clockInteractor) val resources = LocalContext.current.resources LockscreenLongPress( viewModel = viewModel.longPress, Loading @@ -88,13 +92,27 @@ constructor( SmartSpace( burnInParams = burnIn.parameters, onTopChanged = burnIn.onSmartspaceTopChanged, modifier = Modifier.fillMaxWidth(), modifier = Modifier.fillMaxWidth() .padding( top = { viewModel.getSmartSpacePaddingTop(resources) } ), ) } if (viewModel.isLargeClockVisible) { Spacer(modifier = Modifier.weight(weight = 1f)) with(clockSection) { LargeClock(modifier = Modifier.fillMaxWidth()) } } if (viewModel.areNotificationsVisible) { with(notificationSection) { Notifications(modifier = Modifier.fillMaxWidth().weight(1f)) Notifications( modifier = Modifier.fillMaxWidth().weight(weight = 1f) ) } } if (!isUdfpsVisible && ambientIndicationSectionOptional.isPresent) { with(ambientIndicationSectionOptional.get()) { AmbientIndication(modifier = Modifier.fillMaxWidth()) Loading
packages/SystemUI/compose/features/src/com/android/systemui/keyguard/ui/composable/blueprint/ShortcutsBesideUdfpsBlueprint.kt +22 −4 Original line number Diff line number Diff line Loading @@ -17,13 +17,16 @@ package com.android.systemui.keyguard.ui.composable.blueprint import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.layout.Layout import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.unit.IntRect import com.android.compose.animation.scene.SceneScope import com.android.compose.modifiers.padding import com.android.systemui.keyguard.domain.interactor.KeyguardClockInteractor import com.android.systemui.keyguard.ui.composable.LockscreenLongPress import com.android.systemui.keyguard.ui.composable.section.AmbientIndicationSection Loading Loading @@ -66,6 +69,7 @@ constructor( override fun SceneScope.Content(modifier: Modifier) { val isUdfpsVisible = viewModel.isUdfpsVisible val burnIn = rememberBurnIn(clockInteractor) val resources = LocalContext.current.resources LockscreenLongPress( viewModel = viewModel.longPress, Loading @@ -88,13 +92,27 @@ constructor( SmartSpace( burnInParams = burnIn.parameters, onTopChanged = burnIn.onSmartspaceTopChanged, modifier = Modifier.fillMaxWidth(), modifier = Modifier.fillMaxWidth() .padding( top = { viewModel.getSmartSpacePaddingTop(resources) } ), ) } if (viewModel.isLargeClockVisible) { Spacer(modifier = Modifier.weight(weight = 1f)) with(clockSection) { LargeClock(modifier = Modifier.fillMaxWidth()) } } if (viewModel.areNotificationsVisible) { with(notificationSection) { Notifications(modifier = Modifier.fillMaxWidth().weight(1f)) Notifications( modifier = Modifier.fillMaxWidth().weight(weight = 1f) ) } } if (!isUdfpsVisible && ambientIndicationSectionOptional.isPresent) { with(ambientIndicationSectionOptional.get()) { AmbientIndication(modifier = Modifier.fillMaxWidth()) Loading
packages/SystemUI/compose/features/src/com/android/systemui/keyguard/ui/composable/section/ClockSection.kt +3 −5 Original line number Diff line number Diff line Loading @@ -30,10 +30,10 @@ import com.android.compose.animation.scene.ElementKey import com.android.compose.animation.scene.SceneScope import com.android.compose.modifiers.padding import com.android.keyguard.KeyguardClockSwitch import com.android.systemui.customization.R as customizationR import com.android.systemui.keyguard.domain.interactor.KeyguardClockInteractor import com.android.systemui.keyguard.ui.composable.modifier.onTopPlacementChanged import com.android.systemui.keyguard.ui.viewmodel.KeyguardClockViewModel import com.android.systemui.res.R import javax.inject.Inject class ClockSection Loading Loading @@ -79,7 +79,7 @@ constructor( modifier = Modifier.padding( horizontal = dimensionResource(R.dimen.keyguard_affordance_horizontal_offset) dimensionResource(customizationR.dimen.clock_padding_start) ) .padding(top = { viewModel.getSmallClockTopMargin(view.context) }) .onTopPlacementChanged(onTopChanged), Loading Loading @@ -117,9 +117,7 @@ constructor( content { AndroidView( factory = { checkNotNull(currentClock).largeClock.view }, modifier = Modifier.fillMaxWidth() .padding(top = { viewModel.getLargeClockTopMargin(view.context) }) modifier = Modifier.fillMaxWidth() ) } } Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/LockscreenContentViewModelTest.kt 0 → 100644 +106 −0 Original line number Diff line number Diff line /* * Copyright (C) 2024 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.systemui.keyguard.ui.viewmodel import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.keyguard.KeyguardClockSwitch import com.android.systemui.SysuiTestCase import com.android.systemui.biometrics.authController import com.android.systemui.flags.Flags import com.android.systemui.flags.fakeFeatureFlagsClassic import com.android.systemui.keyguard.data.repository.fakeKeyguardClockRepository import com.android.systemui.kosmos.Kosmos import com.android.systemui.kosmos.testScope import com.android.systemui.testKosmos import com.android.systemui.util.mockito.whenever import com.google.common.truth.Truth.assertThat import kotlinx.coroutines.test.runTest import org.junit.Before import org.junit.Test import org.junit.runner.RunWith @SmallTest @RunWith(AndroidJUnit4::class) class LockscreenContentViewModelTest : SysuiTestCase() { private val kosmos: Kosmos = testKosmos() lateinit var underTest: LockscreenContentViewModel @Before fun setup() { with(kosmos) { fakeFeatureFlagsClassic.set(Flags.LOCK_SCREEN_LONG_PRESS_ENABLED, true) underTest = lockscreenContentViewModel } } @Test fun isUdfpsVisible_withUdfps_true() = with(kosmos) { testScope.runTest { whenever(kosmos.authController.isUdfpsSupported).thenReturn(true) assertThat(underTest.isUdfpsVisible).isTrue() } } @Test fun isUdfpsVisible_withoutUdfps_false() = with(kosmos) { testScope.runTest { whenever(kosmos.authController.isUdfpsSupported).thenReturn(false) assertThat(underTest.isUdfpsVisible).isFalse() } } @Test fun isLargeClockVisible_withLargeClock_true() = with(kosmos) { testScope.runTest { kosmos.fakeKeyguardClockRepository.setClockSize(KeyguardClockSwitch.LARGE) assertThat(underTest.isLargeClockVisible).isTrue() } } @Test fun isLargeClockVisible_withSmallClock_false() = with(kosmos) { testScope.runTest { kosmos.fakeKeyguardClockRepository.setClockSize(KeyguardClockSwitch.SMALL) assertThat(underTest.isLargeClockVisible).isFalse() } } @Test fun areNotificationsVisible_withSmallClock_true() = with(kosmos) { testScope.runTest { kosmos.fakeKeyguardClockRepository.setClockSize(KeyguardClockSwitch.SMALL) assertThat(underTest.areNotificationsVisible).isTrue() } } @Test fun areNotificationsVisible_withLargeClock_false() = with(kosmos) { testScope.runTest { kosmos.fakeKeyguardClockRepository.setClockSize(KeyguardClockSwitch.LARGE) assertThat(underTest.areNotificationsVisible).isFalse() } } }
packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardClockViewModel.kt +0 −30 Original line number Diff line number Diff line Loading @@ -99,34 +99,4 @@ constructor( context.resources.getDimensionPixelSize(R.dimen.keyguard_clock_top_margin) + Utils.getStatusBarHeaderHeightKeyguard(context) } fun getLargeClockTopMargin(context: Context): Int { var largeClockTopMargin = context.resources.getDimensionPixelSize(R.dimen.status_bar_height) + context.resources.getDimensionPixelSize( com.android.systemui.customization.R.dimen.small_clock_padding_top ) + context.resources.getDimensionPixelSize(R.dimen.keyguard_smartspace_top_offset) largeClockTopMargin += getDimen(context, DATE_WEATHER_VIEW_HEIGHT) largeClockTopMargin += getDimen(context, ENHANCED_SMARTSPACE_HEIGHT) if (!useLargeClock) { largeClockTopMargin -= context.resources.getDimensionPixelSize( com.android.systemui.customization.R.dimen.small_clock_height ) } return largeClockTopMargin } private fun getDimen(context: Context, name: String): Int { val res = context.packageManager.getResourcesForApplication(context.packageName) val id = res.getIdentifier(name, "dimen", context.packageName) return res.getDimensionPixelSize(id) } companion object { private const val DATE_WEATHER_VIEW_HEIGHT = "date_weather_view_height" private const val ENHANCED_SMARTSPACE_HEIGHT = "enhanced_smartspace_height" } }