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

Commit dd51de71 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Fix clock/smartspace uses wrong dimension resources in multi-crop preview" into main

parents 6d6097a3 2846c58b
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -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)
+8 −5
Original line number Diff line number Diff line
@@ -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)
@@ -410,7 +413,7 @@ constructor(
            setUpClock(previewContext, rootView)
            if (MigrateClocksToBlueprint.isEnabled) {
                KeyguardPreviewClockViewBinder.bind(
                    context,
                    previewContext,
                    keyguardRootView,
                    clockViewModel,
                    ::updateClockAppearance
@@ -428,7 +431,7 @@ constructor(

        smartSpaceView?.let {
            KeyguardPreviewSmartspaceViewBinder.bind(
                context,
                previewContext,
                it,
                previewInSplitShade(),
                smartspaceViewModel
+0 −5
Original line number Diff line number Diff line
@@ -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
+7 −9
Original line number Diff line number Diff line
@@ -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)