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

Commit 8d0c6e2d authored by Hawkwood Glazier's avatar Hawkwood Glazier
Browse files

Update lastUnconstraintedTextSize from setTextSize

Flag: N/A
Bug: 330185860
Bug: 331808964
Test: Manually checked default clock size
Change-Id: I2e9e35d0b3c5cea4d6d61b380cc203bb073b5950
parent 7db86120
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -190,12 +190,20 @@ class AnimatableClockView @JvmOverloads constructor(
        refreshFormat()
    }

    override fun setTextSize(type: Int, size: Float) {
        super.setTextSize(type, size)
        if (type == TypedValue.COMPLEX_UNIT_PX) {
            lastUnconstrainedTextSize = size
        }
    }

    @SuppressLint("DrawAllocation")
    override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
        logger.d("onMeasure")
        if (migratedClocks && !isSingleLineInternal &&
                MeasureSpec.getMode(heightMeasureSpec) == EXACTLY) {
            setTextSize(TypedValue.COMPLEX_UNIT_PX,
            // Call straight into TextView.setTextSize to avoid setting lastUnconstrainedTextSize
            super.setTextSize(TypedValue.COMPLEX_UNIT_PX,
                    min(lastUnconstrainedTextSize, MeasureSpec.getSize(heightMeasureSpec) / 2F))
        }
        super.onMeasure(widthMeasureSpec, heightMeasureSpec)