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

Commit e5c60980 authored by Sherry Zhou's avatar Sherry Zhou
Browse files

Fix position of smartspace in preview not aligned with actual lockscreen

Test: manual
Flag: ACONFIG com.android.systemui.migrate_clocks_to_blueprint STAGING
Bug: 328497514

Change-Id: I9b05fff1b719f8595a920863ecda51f822316397
parent c45260fb
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -110,4 +110,6 @@
    <dimen name="controls_content_padding">24dp</dimen>
    <dimen name="control_list_vertical_spacing">8dp</dimen>
    <dimen name="control_list_horizontal_spacing">16dp</dimen>
    <!-- For portrait direction in unfold foldable device, we don't need keyguard_smartspace_top_offset-->
    <dimen name="keyguard_smartspace_top_offset">0dp</dimen>
</resources>
+20 −2
Original line number Diff line number Diff line
@@ -17,10 +17,12 @@

package com.android.systemui.keyguard.ui.binder

import android.content.Context
import android.view.View
import androidx.core.view.isInvisible
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.repeatOnLifecycle
import com.android.systemui.keyguard.shared.model.SettingsClockSize
import com.android.systemui.keyguard.ui.viewmodel.KeyguardPreviewSmartspaceViewModel
import com.android.systemui.lifecycle.repeatWhenAttached
import kotlinx.coroutines.launch
@@ -30,13 +32,29 @@ object KeyguardPreviewSmartspaceViewBinder {

    @JvmStatic
    fun bind(
        context: Context,
        smartspace: View,
        splitShadePreview: Boolean,
        viewModel: KeyguardPreviewSmartspaceViewModel,
    ) {
        smartspace.repeatWhenAttached {
            repeatOnLifecycle(Lifecycle.State.STARTED) {
                launch { viewModel.smartspaceTopPadding.collect { smartspace.setTopPadding(it) } }

                launch {
                    viewModel.selectedClockSize.collect {
                        val topPadding =
                            when (it) {
                                SettingsClockSize.DYNAMIC ->
                                    viewModel.getLargeClockSmartspaceTopPadding(
                                        splitShadePreview,
                                    )
                                SettingsClockSize.SMALL ->
                                    viewModel.getSmallClockSmartspaceTopPadding(
                                        splitShadePreview,
                                    )
                            }
                        smartspace.setTopPadding(topPadding)
                    }
                }
                launch { viewModel.shouldHideSmartspace.collect { smartspace.isInvisible = it } }
            }
        }
+20 −9
Original line number Diff line number Diff line
@@ -46,7 +46,6 @@ import androidx.constraintlayout.widget.ConstraintSet
import androidx.constraintlayout.widget.ConstraintSet.PARENT_ID
import androidx.constraintlayout.widget.ConstraintSet.START
import androidx.constraintlayout.widget.ConstraintSet.TOP
import androidx.constraintlayout.widget.ConstraintSet.WRAP_CONTENT
import androidx.core.view.isInvisible
import com.android.keyguard.ClockEventController
import com.android.keyguard.KeyguardClockSwitch
@@ -325,13 +324,9 @@ constructor(
        smartSpaceView = lockscreenSmartspaceController.buildAndConnectDateView(parentView)

        val topPadding: Int =
            KeyguardPreviewSmartspaceViewModel.getLargeClockSmartspaceTopPadding(
                previewContext.resources,
            )
        val startPadding: Int =
            previewContext.resources.getDimensionPixelSize(R.dimen.below_clock_padding_start)
        val endPadding: Int =
            previewContext.resources.getDimensionPixelSize(R.dimen.below_clock_padding_end)
            smartspaceViewModel.getLargeClockSmartspaceTopPadding(previewInSplitShade())
        val startPadding: Int = smartspaceViewModel.getSmartspaceStartPadding()
        val endPadding: Int = smartspaceViewModel.getSmartspaceEndPadding()

        smartSpaceView?.let {
            it.setPaddingRelative(startPadding, topPadding, endPadding, 0)
@@ -426,7 +421,15 @@ constructor(
        }

        setUpSmartspace(previewContext, rootView)
        smartSpaceView?.let { KeyguardPreviewSmartspaceViewBinder.bind(it, smartspaceViewModel) }

        smartSpaceView?.let {
            KeyguardPreviewSmartspaceViewBinder.bind(
                context,
                it,
                previewInSplitShade(),
                smartspaceViewModel
            )
        }
        setupCommunalTutorialIndicator(keyguardRootView)
    }

@@ -705,6 +708,14 @@ constructor(
        smallClockHostView.addView(clock.smallClock.view)
    }

    /*
     * When multi_crop_preview_ui_flag is on, we can preview portrait in split shadow direction
     * or vice versa. So we need to decide preview direction by width and height
     */
    private fun previewInSplitShade(): Boolean {
        return width > height
    }

    companion object {
        private const val TAG = "KeyguardPreviewRenderer"
        private const val OVERLAY_CATEGORY_THEME_STYLE = "android.theme.customization.theme_style"
+2 −17
Original line number Diff line number Diff line
@@ -43,8 +43,6 @@ import com.android.systemui.plugins.clocks.ClockController
import com.android.systemui.plugins.clocks.ClockFaceLayout
import com.android.systemui.res.R
import com.android.systemui.shared.R as sharedR
import com.android.systemui.statusbar.policy.SplitShadeStateController
import com.android.systemui.util.Utils
import dagger.Lazy
import javax.inject.Inject

@@ -64,7 +62,6 @@ constructor(
    private val clockInteractor: KeyguardClockInteractor,
    protected val keyguardClockViewModel: KeyguardClockViewModel,
    private val context: Context,
    private val splitShadeStateController: SplitShadeStateController,
    val smartspaceViewModel: KeyguardSmartspaceViewModel,
    val blueprintInteractor: Lazy<KeyguardBlueprintInteractor>,
) : KeyguardSection() {
@@ -162,12 +159,7 @@ constructor(
            connect(R.id.lockscreen_clock_view_large, START, PARENT_ID, START)
            connect(R.id.lockscreen_clock_view_large, END, guideline, END)
            connect(R.id.lockscreen_clock_view_large, BOTTOM, R.id.device_entry_icon_view, TOP)
            var largeClockTopMargin =
                context.resources.getDimensionPixelSize(R.dimen.status_bar_height) +
                    context.resources.getDimensionPixelSize(
                        customizationR.dimen.small_clock_padding_top
                    ) +
                    context.resources.getDimensionPixelSize(R.dimen.keyguard_smartspace_top_offset)
            var largeClockTopMargin = KeyguardClockViewModel.getLargeClockTopMargin(context)
            largeClockTopMargin += getDimen(DATE_WEATHER_VIEW_HEIGHT)
            largeClockTopMargin += getDimen(ENHANCED_SMARTSPACE_HEIGHT)

@@ -187,14 +179,7 @@ constructor(
                context.resources.getDimensionPixelSize(customizationR.dimen.clock_padding_start) +
                    context.resources.getDimensionPixelSize(R.dimen.status_view_margin_horizontal)
            )
            val smallClockTopMargin =
                if (splitShadeStateController.shouldUseSplitNotificationShade(context.resources)) {
                    context.resources.getDimensionPixelSize(R.dimen.keyguard_split_shade_top_margin)
                } else {
                    context.resources.getDimensionPixelSize(R.dimen.keyguard_clock_top_margin) +
                        Utils.getStatusBarHeaderHeightKeyguard(context)
                }

            val smallClockTopMargin = keyguardClockViewModel.getSmallClockTopMargin(context)
            create(R.id.small_clock_guideline_top, ConstraintSet.HORIZONTAL_GUIDELINE)
            setGuidelineBegin(R.id.small_clock_guideline_top, smallClockTopMargin)
            connect(R.id.lockscreen_clock_view, TOP, R.id.small_clock_guideline_top, BOTTOM)
+2 −6
Original line number Diff line number Diff line
@@ -96,12 +96,8 @@ constructor(
    override fun applyConstraints(constraintSet: ConstraintSet) {
        if (!MigrateClocksToBlueprint.isEnabled) return
        if (!keyguardSmartspaceViewModel.isSmartspaceEnabled) return
        val horizontalPaddingStart =
            context.resources.getDimensionPixelSize(R.dimen.below_clock_padding_start) +
                context.resources.getDimensionPixelSize(R.dimen.status_view_margin_horizontal)
        val horizontalPaddingEnd =
            context.resources.getDimensionPixelSize(R.dimen.below_clock_padding_end) +
                context.resources.getDimensionPixelSize(R.dimen.status_view_margin_horizontal)
        val horizontalPaddingStart = KeyguardSmartspaceViewModel.getSmartspaceStartMargin(context)
        val horizontalPaddingEnd = KeyguardSmartspaceViewModel.getSmartspaceEndMargin(context)
        constraintSet.apply {
            // migrate addDateWeatherView, addWeatherView from KeyguardClockSwitchController
            constrainHeight(sharedR.id.date_smartspace_view, ConstraintSet.WRAP_CONTENT)
Loading