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

Commit f896c7a1 authored by Hawkwood Glazier's avatar Hawkwood Glazier Committed by Android (Google) Code Review
Browse files

Merge "Move back to using 4 TextViews" into main

parents fd9046a0 ea4eb872
Loading
Loading
Loading
Loading
+14 −4
Original line number Diff line number Diff line
@@ -55,7 +55,6 @@ class ComposedDigitalLayerController(private val clockCtx: ClockContext) :
        val layerCfg =
            LayerConfig(
                style = FontTextStyle(lineHeight = 147.25f),
                timespec = DigitalTimespec.DIGIT_PAIR,
                alignment = DigitalAlignment(HorizontalAlignment.CENTER, VerticalAlignment.CENTER),
                aodStyle =
                    FontTextStyle(
@@ -63,12 +62,23 @@ class ComposedDigitalLayerController(private val clockCtx: ClockContext) :
                        transitionDuration = 750,
                    ),

                // Placeholder
                // Placeholders
                timespec = DigitalTimespec.TIME_FULL_FORMAT,
                dateTimeFormat = "hh:mm",
            )

        createController(layerCfg.copy(dateTimeFormat = "hh"))
        createController(layerCfg.copy(dateTimeFormat = "mm"))
        createController(
            layerCfg.copy(timespec = DigitalTimespec.FIRST_DIGIT, dateTimeFormat = "hh")
        )
        createController(
            layerCfg.copy(timespec = DigitalTimespec.SECOND_DIGIT, dateTimeFormat = "hh")
        )
        createController(
            layerCfg.copy(timespec = DigitalTimespec.FIRST_DIGIT, dateTimeFormat = "mm")
        )
        createController(
            layerCfg.copy(timespec = DigitalTimespec.SECOND_DIGIT, dateTimeFormat = "mm")
        )
    }

    private fun refreshTime() {
+10 −5
Original line number Diff line number Diff line
@@ -124,8 +124,10 @@ class FlexClockView(clockCtx: ClockContext) : ViewGroup(clockCtx.context) {
            maxChildSize.y * AOD_VERTICAL_TRANSLATE_RATIO
        )
        */

        val xScale = if (childViews.size < 4) 1f else 2f
        val yBuffer = context.resources.getDimensionPixelSize(R.dimen.clock_vertical_digit_buffer)
        return (maxChildSize + aodTranslate.abs()) * VPointF(1f, 2f) + VPointF(0f, yBuffer)
        return (maxChildSize + aodTranslate.abs()) * VPointF(xScale, 2f) + VPointF(0f, yBuffer)
    }

    override fun onViewAdded(child: View?) {
@@ -226,19 +228,22 @@ class FlexClockView(clockCtx: ClockContext) : ViewGroup(clockCtx.context) {
                    when (child.id) {
                        R.id.HOUR_FIRST_DIGIT -> VPointF.ZERO
                        R.id.HOUR_SECOND_DIGIT -> VPointF(x, 0f)
                        R.id.MINUTE_FIRST_DIGIT -> VPointF(0f, y + yBuffer)
                        R.id.MINUTE_SECOND_DIGIT -> this
                        R.id.HOUR_DIGIT_PAIR -> VPointF.ZERO
                        // Add a small vertical buffer for the second digit pair
                        // Add a small vertical buffer for second line views
                        R.id.MINUTE_DIGIT_PAIR -> VPointF(0f, y + yBuffer)
                        R.id.MINUTE_FIRST_DIGIT -> VPointF(0f, y + yBuffer)
                        R.id.MINUTE_SECOND_DIGIT -> VPointF(x, y + yBuffer)
                        else -> VPointF.ZERO
                    }
                }

            val childSize = child.measuredSize
            offset += VPointF((measuredWidth - childSize.x) / 2f, 0f)
            offset += aodTranslate.abs()

            // Horizontal offset to center each view in the available space
            val midX = if (childViews.size < 4) measuredWidth / 2f else measuredWidth / 4f
            offset += VPointF(midX - childSize.x / 2f, 0f)

            val setPos = if (isLayout) child::layout else child::setLeftTopRightBottom
            setPos(
                offset.x.roundToInt(),
+0 −2
Original line number Diff line number Diff line
@@ -425,12 +425,10 @@ open class SimpleDigitalClockTextView(
        return VPointF(
            when {
                mode.x == EXACTLY -> MeasureSpec.getSize(widthMeasureSpec).toFloat()
                isSingleDigit() -> maxSingleDigitWidth
                else -> interpBounds.width() + 2 * lockScreenPaint.strokeWidth
            },
            when {
                mode.y == EXACTLY -> MeasureSpec.getSize(heightMeasureSpec).toFloat()
                isSingleDigit() -> maxSingleDigitHeight
                else -> interpBounds.height() + 2 * lockScreenPaint.strokeWidth
            },
        )