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

Commit 2883606c authored by Sherry Zhou's avatar Sherry Zhou
Browse files

Fix clock slightly upward in preview

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

Change-Id: Id6b25c0af5ff06c10300d4f4265abde1d3b3fe2e
parent f5a43e55
Loading
Loading
Loading
Loading
+25 −2
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@
package com.android.systemui.keyguard.ui.binder

import android.content.Context
import android.util.DisplayMetrics
import android.view.View
import android.view.View.INVISIBLE
import android.view.View.VISIBLE
@@ -109,7 +110,7 @@ object KeyguardPreviewClockViewBinder {
    private fun applyClockDefaultConstraints(context: Context, constraints: ConstraintSet) {
        constraints.apply {
            constrainWidth(R.id.lockscreen_clock_view_large, ConstraintSet.WRAP_CONTENT)
            constrainHeight(R.id.lockscreen_clock_view_large, ConstraintSet.WRAP_CONTENT)
            constrainHeight(R.id.lockscreen_clock_view_large, ConstraintSet.MATCH_CONSTRAINT)
            val largeClockTopMargin =
                context.resources.getDimensionPixelSize(R.dimen.status_bar_height) +
                    context.resources.getDimensionPixelSize(
@@ -129,7 +130,29 @@ object KeyguardPreviewClockViewBinder {
                ConstraintSet.END
            )

            // In preview, we'll show UDFPS icon for UDFPS devices
            // and nothing for non-UDFPS devices,
            // but we need position of device entry icon to constrain clock
            if (getConstraint(R.id.lock_icon_view) != null) {
                connect(R.id.lockscreen_clock_view_large, BOTTOM, R.id.lock_icon_view, TOP)
            } else {
                // Copied calculation codes from applyConstraints in DefaultDeviceEntrySection
                val bottomPaddingPx =
                    context.resources.getDimensionPixelSize(R.dimen.lock_icon_margin_bottom)
                val defaultDensity =
                    DisplayMetrics.DENSITY_DEVICE_STABLE.toFloat() /
                        DisplayMetrics.DENSITY_DEFAULT.toFloat()
                val lockIconRadiusPx = (defaultDensity * 36).toInt()
                val clockBottomMargin = bottomPaddingPx + 2 * lockIconRadiusPx
                connect(
                    R.id.lockscreen_clock_view_large,
                    BOTTOM,
                    PARENT_ID,
                    BOTTOM,
                    clockBottomMargin
                )
            }

            constrainWidth(R.id.lockscreen_clock_view, WRAP_CONTENT)
            constrainHeight(
                R.id.lockscreen_clock_view,