Loading packages/SystemUI/compose/features/src/com/android/systemui/keyguard/ui/composable/elements/ClockRegionElementProvider.kt +23 −3 Original line number Diff line number Diff line Loading @@ -24,17 +24,19 @@ import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.heightIn import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.widthIn import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.platform.LocalDensity import androidx.compose.ui.res.dimensionResource import androidx.lifecycle.compose.collectAsStateWithLifecycle import com.android.compose.animation.scene.ElementContentScope import com.android.compose.modifiers.padding import com.android.systemui.customization.clocks.R as clocksR import com.android.systemui.keyguard.ui.viewmodel.KeyguardClockViewModel import com.android.systemui.plugins.keyguard.VRectF import com.android.systemui.plugins.keyguard.ui.composable.elements.LockscreenElement import com.android.systemui.plugins.keyguard.ui.composable.elements.LockscreenElementKeys import com.android.systemui.plugins.keyguard.ui.composable.elements.LockscreenElementKeys.Clock Loading Loading @@ -67,6 +69,9 @@ constructor( val shouldDateWeatherBeBelowSmallClock: Boolean by keyguardClockViewModel.shouldDateWeatherBeBelowSmallClock .collectAsStateWithLifecycle() val clockBounds: VRectF by keyguardClockViewModel.clockEventController.smallClockBounds .collectAsStateWithLifecycle() // Horizontal Padding is handled internally within the SmartspaceCards element. This // makes the application here to other elements in the hierarchy slightly awkward. Loading @@ -79,7 +84,13 @@ constructor( Modifier.padding(horizontal = xPadding) .padding(top = dimensionResource(R.dimen.keyguard_clock_top_margin)), ) { LockscreenElement(Clock.Small) with(LocalDensity.current) { LockscreenElement( Clock.Small, Modifier.widthIn(min = clockBounds.width.toDp()) .heightIn(min = clockBounds.height.toDp()), ) } if (!shouldDateWeatherBeBelowSmallClock) { LockscreenElement( Loading Loading @@ -113,6 +124,9 @@ constructor( val shouldDateWeatherBeBelowLargeClock: Boolean by keyguardClockViewModel.shouldDateWeatherBeBelowLargeClock .collectAsStateWithLifecycle() val clockBounds: VRectF by keyguardClockViewModel.clockEventController.largeClockBounds .collectAsStateWithLifecycle() // Horizontal Padding is handled internally within the SmartspaceCards element. This // makes the application here to other elements in the hierarchy slightly awkward. Loading Loading @@ -157,7 +171,13 @@ constructor( ), modifier = Modifier.padding(horizontal = xPadding).fillMaxWidth().weight(1f), ) { LockscreenElement(Clock.Large) with(LocalDensity.current) { LockscreenElement( Clock.Large, Modifier.widthIn(min = clockBounds.width.toDp()) .heightIn(min = clockBounds.height.toDp()), ) } if (shouldDateWeatherBeBelowLargeClock) { LockscreenElement(Smartspace.DWA.LargeClock.Below) } Loading packages/SystemUI/customization/src/com/android/systemui/shared/clocks/ClockRegistry.kt +1 −1 Original line number Diff line number Diff line Loading @@ -314,7 +314,7 @@ open class ClockRegistry( val onComplete = endChangeTrace?.also { endChangeTrace = null } ?: return clock.eventListeners.attach( object : ClockEventListener { override fun onBoundsChanged(current: VRectF) {} override fun onBoundsChanged(currentBounds: VRectF, isLargeClock: Boolean) {} override fun onMaxSizeChanged(maxSize: VPointF, isLargeClock: Boolean) {} Loading packages/SystemUI/customization/src/com/android/systemui/shared/clocks/FlexClockController.kt +6 −2 Original line number Diff line number Diff line Loading @@ -112,7 +112,9 @@ class FlexClockController( override fun initialize(isDarkTheme: Boolean, dozeFraction: Float, foldFraction: Float) { smallClock.run { layerController.onViewBoundsChanged = { eventListeners.fire { onBoundsChanged(it) } } layerController.onViewBoundsChanged = { eventListeners.fire { onBoundsChanged(it, isLargeClock = false) } } layerController.onViewMaxSizeChanged = { eventListeners.fire { onMaxSizeChanged(it, isLargeClock = false) } } Loading @@ -124,7 +126,9 @@ class FlexClockController( } largeClock.run { layerController.onViewBoundsChanged = { eventListeners.fire { onBoundsChanged(it) } } layerController.onViewBoundsChanged = { eventListeners.fire { onBoundsChanged(it, isLargeClock = true) } } layerController.onViewMaxSizeChanged = { eventListeners.fire { onMaxSizeChanged(it, isLargeClock = true) } } Loading packages/SystemUI/plugin/src/com/android/systemui/plugins/keyguard/ui/clocks/ClockEvents.kt +1 −1 Original line number Diff line number Diff line Loading @@ -82,7 +82,7 @@ class ClockEventListeners { } interface ClockEventListener { fun onBoundsChanged(currentBounds: VRectF) fun onBoundsChanged(currentBounds: VRectF, isLargeClock: Boolean) fun onMaxSizeChanged(maxSize: VPointF, isLargeClock: Boolean) Loading packages/SystemUI/src/com/android/keyguard/ClockEventController.kt +4 −3 Original line number Diff line number Diff line Loading @@ -247,7 +247,8 @@ constructor( private var largeClockOnSecondaryDisplay = false val dozeAmount = MutableStateFlow(0f) val onClockBoundsChanged = MutableStateFlow<VRectF>(VRectF.ZERO) val smallClockBounds = MutableStateFlow<VRectF>(VRectF.ZERO) val largeClockBounds = MutableStateFlow<VRectF>(VRectF.ZERO) val smallClockMaxSize = MutableStateFlow<VPointF>(VPointF.ZERO) val largeClockMaxSize = MutableStateFlow<VPointF>(VPointF.ZERO) Loading Loading @@ -316,8 +317,8 @@ constructor( object : ClockEventListener { override fun onChangeComplete() {} override fun onBoundsChanged(currentBounds: VRectF) { onClockBoundsChanged.value = currentBounds override fun onBoundsChanged(currentBounds: VRectF, isLargeClock: Boolean) { (if (isLargeClock) largeClockBounds else smallClockBounds).value = currentBounds } override fun onMaxSizeChanged(maxSize: VPointF, isLargeClock: Boolean) { Loading Loading
packages/SystemUI/compose/features/src/com/android/systemui/keyguard/ui/composable/elements/ClockRegionElementProvider.kt +23 −3 Original line number Diff line number Diff line Loading @@ -24,17 +24,19 @@ import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.heightIn import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.widthIn import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.platform.LocalDensity import androidx.compose.ui.res.dimensionResource import androidx.lifecycle.compose.collectAsStateWithLifecycle import com.android.compose.animation.scene.ElementContentScope import com.android.compose.modifiers.padding import com.android.systemui.customization.clocks.R as clocksR import com.android.systemui.keyguard.ui.viewmodel.KeyguardClockViewModel import com.android.systemui.plugins.keyguard.VRectF import com.android.systemui.plugins.keyguard.ui.composable.elements.LockscreenElement import com.android.systemui.plugins.keyguard.ui.composable.elements.LockscreenElementKeys import com.android.systemui.plugins.keyguard.ui.composable.elements.LockscreenElementKeys.Clock Loading Loading @@ -67,6 +69,9 @@ constructor( val shouldDateWeatherBeBelowSmallClock: Boolean by keyguardClockViewModel.shouldDateWeatherBeBelowSmallClock .collectAsStateWithLifecycle() val clockBounds: VRectF by keyguardClockViewModel.clockEventController.smallClockBounds .collectAsStateWithLifecycle() // Horizontal Padding is handled internally within the SmartspaceCards element. This // makes the application here to other elements in the hierarchy slightly awkward. Loading @@ -79,7 +84,13 @@ constructor( Modifier.padding(horizontal = xPadding) .padding(top = dimensionResource(R.dimen.keyguard_clock_top_margin)), ) { LockscreenElement(Clock.Small) with(LocalDensity.current) { LockscreenElement( Clock.Small, Modifier.widthIn(min = clockBounds.width.toDp()) .heightIn(min = clockBounds.height.toDp()), ) } if (!shouldDateWeatherBeBelowSmallClock) { LockscreenElement( Loading Loading @@ -113,6 +124,9 @@ constructor( val shouldDateWeatherBeBelowLargeClock: Boolean by keyguardClockViewModel.shouldDateWeatherBeBelowLargeClock .collectAsStateWithLifecycle() val clockBounds: VRectF by keyguardClockViewModel.clockEventController.largeClockBounds .collectAsStateWithLifecycle() // Horizontal Padding is handled internally within the SmartspaceCards element. This // makes the application here to other elements in the hierarchy slightly awkward. Loading Loading @@ -157,7 +171,13 @@ constructor( ), modifier = Modifier.padding(horizontal = xPadding).fillMaxWidth().weight(1f), ) { LockscreenElement(Clock.Large) with(LocalDensity.current) { LockscreenElement( Clock.Large, Modifier.widthIn(min = clockBounds.width.toDp()) .heightIn(min = clockBounds.height.toDp()), ) } if (shouldDateWeatherBeBelowLargeClock) { LockscreenElement(Smartspace.DWA.LargeClock.Below) } Loading
packages/SystemUI/customization/src/com/android/systemui/shared/clocks/ClockRegistry.kt +1 −1 Original line number Diff line number Diff line Loading @@ -314,7 +314,7 @@ open class ClockRegistry( val onComplete = endChangeTrace?.also { endChangeTrace = null } ?: return clock.eventListeners.attach( object : ClockEventListener { override fun onBoundsChanged(current: VRectF) {} override fun onBoundsChanged(currentBounds: VRectF, isLargeClock: Boolean) {} override fun onMaxSizeChanged(maxSize: VPointF, isLargeClock: Boolean) {} Loading
packages/SystemUI/customization/src/com/android/systemui/shared/clocks/FlexClockController.kt +6 −2 Original line number Diff line number Diff line Loading @@ -112,7 +112,9 @@ class FlexClockController( override fun initialize(isDarkTheme: Boolean, dozeFraction: Float, foldFraction: Float) { smallClock.run { layerController.onViewBoundsChanged = { eventListeners.fire { onBoundsChanged(it) } } layerController.onViewBoundsChanged = { eventListeners.fire { onBoundsChanged(it, isLargeClock = false) } } layerController.onViewMaxSizeChanged = { eventListeners.fire { onMaxSizeChanged(it, isLargeClock = false) } } Loading @@ -124,7 +126,9 @@ class FlexClockController( } largeClock.run { layerController.onViewBoundsChanged = { eventListeners.fire { onBoundsChanged(it) } } layerController.onViewBoundsChanged = { eventListeners.fire { onBoundsChanged(it, isLargeClock = true) } } layerController.onViewMaxSizeChanged = { eventListeners.fire { onMaxSizeChanged(it, isLargeClock = true) } } Loading
packages/SystemUI/plugin/src/com/android/systemui/plugins/keyguard/ui/clocks/ClockEvents.kt +1 −1 Original line number Diff line number Diff line Loading @@ -82,7 +82,7 @@ class ClockEventListeners { } interface ClockEventListener { fun onBoundsChanged(currentBounds: VRectF) fun onBoundsChanged(currentBounds: VRectF, isLargeClock: Boolean) fun onMaxSizeChanged(maxSize: VPointF, isLargeClock: Boolean) Loading
packages/SystemUI/src/com/android/keyguard/ClockEventController.kt +4 −3 Original line number Diff line number Diff line Loading @@ -247,7 +247,8 @@ constructor( private var largeClockOnSecondaryDisplay = false val dozeAmount = MutableStateFlow(0f) val onClockBoundsChanged = MutableStateFlow<VRectF>(VRectF.ZERO) val smallClockBounds = MutableStateFlow<VRectF>(VRectF.ZERO) val largeClockBounds = MutableStateFlow<VRectF>(VRectF.ZERO) val smallClockMaxSize = MutableStateFlow<VPointF>(VPointF.ZERO) val largeClockMaxSize = MutableStateFlow<VPointF>(VPointF.ZERO) Loading Loading @@ -316,8 +317,8 @@ constructor( object : ClockEventListener { override fun onChangeComplete() {} override fun onBoundsChanged(currentBounds: VRectF) { onClockBoundsChanged.value = currentBounds override fun onBoundsChanged(currentBounds: VRectF, isLargeClock: Boolean) { (if (isLargeClock) largeClockBounds else smallClockBounds).value = currentBounds } override fun onMaxSizeChanged(maxSize: VPointF, isLargeClock: Boolean) { Loading