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

Commit 22d41f48 authored by Sherry Zhou's avatar Sherry Zhou Committed by Android (Google) Code Review
Browse files

Merge "Fix default clock text moving right in larger display size" into main

parents e59390f1 10192fb9
Loading
Loading
Loading
Loading
+15 −2
Original line number Diff line number Diff line
@@ -531,8 +531,10 @@ constructor(
        moveFraction: Float,
    ) {
        val isMovingToCenter = if (isLayoutRtl) clockMoveDirection < 0 else clockMoveDirection > 0
        // The sign of moveAmountDeltaForDigit is already set here
        // we can interpret (left - clockStartLeft) as (destinationPosition - originPosition)
        // so we no longer need to multiply direct sign to moveAmountDeltaForDigit
        val currentMoveAmount = left - clockStartLeft
        val digitOffsetDirection = if (isLayoutRtl) -1 else 1
        for (i in 0 until NUM_DIGITS) {
            val digitFraction =
                getDigitFraction(
@@ -542,7 +544,7 @@ constructor(
                )
            val moveAmountForDigit = currentMoveAmount * digitFraction
            val moveAmountDeltaForDigit = moveAmountForDigit - currentMoveAmount
            glyphOffsets[i] = digitOffsetDirection * moveAmountDeltaForDigit
            glyphOffsets[i] = moveAmountDeltaForDigit
        }
        invalidate()
    }
@@ -582,6 +584,17 @@ constructor(
        invalidate()
    }

    override fun onRtlPropertiesChanged(layoutDirection: Int) {
        if (migratedClocks) {
            if (layoutDirection == LAYOUT_DIRECTION_RTL) {
                textAlignment = TEXT_ALIGNMENT_TEXT_END
            } else {
                textAlignment = TEXT_ALIGNMENT_TEXT_START
            }
        }
        super.onRtlPropertiesChanged(layoutDirection)
    }

    private fun getDigitFraction(digit: Int, isMovingToCenter: Boolean, fraction: Float): Float {
        // The delay for the digit, in terms of fraction.
        // (i.e. the digit should not move during 0.0 - 0.1).