summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Sherry Zhou <yuandizhou@google.com> 2024-04-09 19:00:03 +0000
committer Sherry Zhou <yuandizhou@google.com> 2024-04-09 20:19:50 +0000
commit2846c58b16a421ac4d166cbcf94d1e3bb239ab97 (patch)
tree4098894894d596ad838d415da3c994c353e515b7
parenta6c4eca01d201afd306cf87f9a95506ff36eb9cb (diff)
Fix clock/smartspace uses wrong dimension resources in multi-crop preview
For preview, we should use previewContext to load correct dimension Test: manual Flag: ACONFIG com.android.systemui.migrate_clocks_to_blueprint STAGING Bug: 331817016 Change-Id: I28de295136b064cebe19fb7ed29b8b3ac9603a70
-rw-r--r--packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardPreviewSmartspaceViewBinder.kt4
-rw-r--r--packages/SystemUI/src/com/android/systemui/keyguard/ui/preview/KeyguardPreviewRenderer.kt13
-rw-r--r--packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardPreviewClockViewModel.kt5
-rw-r--r--packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardPreviewSmartspaceViewModel.kt16
4 files changed, 18 insertions, 20 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardPreviewSmartspaceViewBinder.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardPreviewSmartspaceViewBinder.kt
index 49ae35a43c23..88d907469f69 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardPreviewSmartspaceViewBinder.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardPreviewSmartspaceViewBinder.kt
@@ -32,7 +32,7 @@ object KeyguardPreviewSmartspaceViewBinder {
@JvmStatic
fun bind(
- context: Context,
+ previewContext: Context,
smartspace: View,
splitShadePreview: Boolean,
viewModel: KeyguardPreviewSmartspaceViewModel,
@@ -46,10 +46,12 @@ object KeyguardPreviewSmartspaceViewBinder {
SettingsClockSize.DYNAMIC ->
viewModel.getLargeClockSmartspaceTopPadding(
splitShadePreview,
+ previewContext,
)
SettingsClockSize.SMALL ->
viewModel.getSmallClockSmartspaceTopPadding(
splitShadePreview,
+ previewContext,
)
}
smartspace.setTopPadding(topPadding)
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/preview/KeyguardPreviewRenderer.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/preview/KeyguardPreviewRenderer.kt
index ce1aed08ab49..40ea44537a84 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/preview/KeyguardPreviewRenderer.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/preview/KeyguardPreviewRenderer.kt
@@ -327,9 +327,12 @@ constructor(
smartSpaceView = lockscreenSmartspaceController.buildAndConnectDateView(parentView)
val topPadding: Int =
- smartspaceViewModel.getLargeClockSmartspaceTopPadding(previewInSplitShade())
- val startPadding: Int = smartspaceViewModel.getSmartspaceStartPadding()
- val endPadding: Int = smartspaceViewModel.getSmartspaceEndPadding()
+ smartspaceViewModel.getLargeClockSmartspaceTopPadding(
+ previewInSplitShade(),
+ previewContext,
+ )
+ val startPadding: Int = smartspaceViewModel.getSmartspaceStartPadding(previewContext)
+ val endPadding: Int = smartspaceViewModel.getSmartspaceEndPadding(previewContext)
smartSpaceView?.let {
it.setPaddingRelative(startPadding, topPadding, endPadding, 0)
@@ -411,7 +414,7 @@ constructor(
setUpClock(previewContext, rootView)
if (MigrateClocksToBlueprint.isEnabled) {
KeyguardPreviewClockViewBinder.bind(
- context,
+ previewContext,
keyguardRootView,
clockViewModel,
::updateClockAppearance
@@ -429,7 +432,7 @@ constructor(
smartSpaceView?.let {
KeyguardPreviewSmartspaceViewBinder.bind(
- context,
+ previewContext,
it,
previewInSplitShade(),
smartspaceViewModel
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardPreviewClockViewModel.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardPreviewClockViewModel.kt
index 4f2c6f576904..730015202a21 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardPreviewClockViewModel.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardPreviewClockViewModel.kt
@@ -16,13 +16,10 @@
package com.android.systemui.keyguard.ui.viewmodel
-import android.content.Context
-import com.android.systemui.dagger.qualifiers.Application
import com.android.systemui.keyguard.domain.interactor.KeyguardClockInteractor
import com.android.systemui.keyguard.shared.model.SettingsClockSize
import com.android.systemui.plugins.clocks.ClockController
import javax.inject.Inject
-import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.map
@@ -31,9 +28,7 @@ import kotlinx.coroutines.flow.map
class KeyguardPreviewClockViewModel
@Inject
constructor(
- @Application private val context: Context,
interactor: KeyguardClockInteractor,
- @Application private val applicationScope: CoroutineScope,
) {
var shouldHighlightSelectedAffordance: Boolean = false
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardPreviewSmartspaceViewModel.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardPreviewSmartspaceViewModel.kt
index b57e3ecbe05b..528b14c6bbd7 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardPreviewSmartspaceViewModel.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardPreviewSmartspaceViewModel.kt
@@ -17,7 +17,6 @@
package com.android.systemui.keyguard.ui.viewmodel
import android.content.Context
-import com.android.systemui.dagger.qualifiers.Application
import com.android.systemui.keyguard.domain.interactor.KeyguardClockInteractor
import com.android.systemui.keyguard.shared.model.SettingsClockSize
import com.android.systemui.res.R
@@ -31,7 +30,6 @@ import kotlinx.coroutines.flow.map
class KeyguardPreviewSmartspaceViewModel
@Inject
constructor(
- @Application private val context: Context,
interactor: KeyguardClockInteractor,
val smartspaceViewModel: KeyguardSmartspaceViewModel,
val clockViewModel: KeyguardClockViewModel,
@@ -55,29 +53,29 @@ constructor(
}
}
- fun getSmartspaceStartPadding(): Int {
+ fun getSmartspaceStartPadding(context: Context): Int {
return KeyguardSmartspaceViewModel.getSmartspaceStartMargin(context)
}
- fun getSmartspaceEndPadding(): Int {
+ fun getSmartspaceEndPadding(context: Context): Int {
return KeyguardSmartspaceViewModel.getSmartspaceEndMargin(context)
}
- fun getSmallClockSmartspaceTopPadding(splitShadePreview: Boolean): Int {
- return getSmallClockTopPadding(splitShadePreview) +
+ fun getSmallClockSmartspaceTopPadding(splitShadePreview: Boolean, context: Context): Int {
+ return getSmallClockTopPadding(splitShadePreview, context) +
context.resources.getDimensionPixelSize(
com.android.systemui.customization.R.dimen.small_clock_height
)
}
- fun getLargeClockSmartspaceTopPadding(splitShadePreview: Boolean): Int {
- return getSmallClockTopPadding(splitShadePreview)
+ fun getLargeClockSmartspaceTopPadding(splitShadePreview: Boolean, context: Context): Int {
+ return getSmallClockTopPadding(splitShadePreview, context)
}
/*
* SmallClockTopPadding decides the top position of smartspace
*/
- private fun getSmallClockTopPadding(splitShadePreview: Boolean): Int {
+ private fun getSmallClockTopPadding(splitShadePreview: Boolean, context: Context): Int {
return with(context.resources) {
if (splitShadePreview) {
getDimensionPixelSize(R.dimen.keyguard_split_shade_top_margin)