Loading packages/SystemUI/customization/src/com/android/systemui/shared/clocks/view/SimpleDigitalClockTextView.kt +41 −41 Original line number Diff line number Diff line Loading @@ -197,7 +197,43 @@ open class SimpleDigitalClockTextView( ) } setInterpolatedViewBounds(getInterpolatedTextBounds(), widthMeasureSpec, heightMeasureSpec) var expectedWidth: Int var expectedHeight: Int if (MeasureSpec.getMode(heightMeasureSpec) == EXACTLY) { // For view which has fixed height, e.g. small clock, // we should always return the size required from parent view expectedHeight = heightMeasureSpec } else { expectedHeight = MeasureSpec.makeMeasureSpec( if (isSingleDigit()) { maxSingleDigitHeight } else { textBounds.height() + 2 * lockScreenPaint.strokeWidth.toInt() }, MeasureSpec.getMode(measuredHeightAndState), ) } if (MeasureSpec.getMode(widthMeasureSpec) == EXACTLY) { expectedWidth = widthMeasureSpec } else { expectedWidth = MeasureSpec.makeMeasureSpec( if (isSingleDigit()) { maxSingleDigitWidth } else { max( textBounds.width() + 2 * lockScreenPaint.strokeWidth.toInt(), MeasureSpec.getSize(measuredWidthAndState), ) }, MeasureSpec.getMode(measuredWidthAndState), ) } setMeasuredDimension(expectedWidth, expectedHeight) } override fun onDraw(canvas: Canvas) { Loading Loading @@ -323,7 +359,7 @@ open class SimpleDigitalClockTextView( id == R.id.MINUTE_SECOND_DIGIT } private fun getInterpolatedTextBounds(): Rect { private fun updateInterpolatedTextBounds(): Rect { val interpolatedTextBounds = Rect() if (textAnimator.animator.animatedFraction != 1.0f && textAnimator.animator.isRunning) { interpolatedTextBounds.left = Loading Loading @@ -363,41 +399,7 @@ open class SimpleDigitalClockTextView( return interpolatedTextBounds } private fun setInterpolatedViewBounds( interpBounds: Rect, widthMeasureSpec: Int = measuredWidthAndState, heightMeasureSpec: Int = measuredHeightAndState, ) { val heightMode = MeasureSpec.getMode(heightMeasureSpec) val widthMode = MeasureSpec.getMode(widthMeasureSpec) val heightSpec = if (heightMode == EXACTLY) { heightMeasureSpec } else { MeasureSpec.makeMeasureSpec( if (isSingleDigit()) maxSingleDigitHeight else interpBounds.height() + 2 * lockScreenPaint.strokeWidth.toInt(), heightMode, ) } val widthSpec = if (widthMode == EXACTLY) { widthMeasureSpec } else { MeasureSpec.makeMeasureSpec( if (isSingleDigit()) maxSingleDigitWidth else interpBounds.width() + 2 * lockScreenPaint.strokeWidth.toInt(), widthMode, ) } setMeasuredDimension(widthSpec, heightSpec) parent?.requestLayout() } private fun updateXTranslation(inPoint: Point, interpolatedTextBounds: Rect): Point { private fun updateXtranslation(inPoint: Point, interpolatedTextBounds: Rect): Point { when (horizontalAlignment) { HorizontalAlignment.LEFT -> { inPoint.x = lockScreenPaint.strokeWidth.toInt() - interpolatedTextBounds.left Loading @@ -420,9 +422,7 @@ open class SimpleDigitalClockTextView( // translation of reference point of text // used for translation when calling textInterpolator private fun getLocalTranslation(): Point { val interpolatedTextBounds = getInterpolatedTextBounds() setInterpolatedViewBounds(interpolatedTextBounds) val interpolatedTextBounds = updateInterpolatedTextBounds() val localTranslation = Point(0, 0) val correctedBaseline = if (baseline != -1) baseline else baselineFromMeasure // get the change from current baseline to expected baseline Loading Loading @@ -452,7 +452,7 @@ open class SimpleDigitalClockTextView( } } return updateXTranslation(localTranslation, interpolatedTextBounds) return updateXtranslation(localTranslation, interpolatedTextBounds) } fun applyStyles(textStyle: FontTextStyle, aodStyle: FontTextStyle?) { Loading Loading
packages/SystemUI/customization/src/com/android/systemui/shared/clocks/view/SimpleDigitalClockTextView.kt +41 −41 Original line number Diff line number Diff line Loading @@ -197,7 +197,43 @@ open class SimpleDigitalClockTextView( ) } setInterpolatedViewBounds(getInterpolatedTextBounds(), widthMeasureSpec, heightMeasureSpec) var expectedWidth: Int var expectedHeight: Int if (MeasureSpec.getMode(heightMeasureSpec) == EXACTLY) { // For view which has fixed height, e.g. small clock, // we should always return the size required from parent view expectedHeight = heightMeasureSpec } else { expectedHeight = MeasureSpec.makeMeasureSpec( if (isSingleDigit()) { maxSingleDigitHeight } else { textBounds.height() + 2 * lockScreenPaint.strokeWidth.toInt() }, MeasureSpec.getMode(measuredHeightAndState), ) } if (MeasureSpec.getMode(widthMeasureSpec) == EXACTLY) { expectedWidth = widthMeasureSpec } else { expectedWidth = MeasureSpec.makeMeasureSpec( if (isSingleDigit()) { maxSingleDigitWidth } else { max( textBounds.width() + 2 * lockScreenPaint.strokeWidth.toInt(), MeasureSpec.getSize(measuredWidthAndState), ) }, MeasureSpec.getMode(measuredWidthAndState), ) } setMeasuredDimension(expectedWidth, expectedHeight) } override fun onDraw(canvas: Canvas) { Loading Loading @@ -323,7 +359,7 @@ open class SimpleDigitalClockTextView( id == R.id.MINUTE_SECOND_DIGIT } private fun getInterpolatedTextBounds(): Rect { private fun updateInterpolatedTextBounds(): Rect { val interpolatedTextBounds = Rect() if (textAnimator.animator.animatedFraction != 1.0f && textAnimator.animator.isRunning) { interpolatedTextBounds.left = Loading Loading @@ -363,41 +399,7 @@ open class SimpleDigitalClockTextView( return interpolatedTextBounds } private fun setInterpolatedViewBounds( interpBounds: Rect, widthMeasureSpec: Int = measuredWidthAndState, heightMeasureSpec: Int = measuredHeightAndState, ) { val heightMode = MeasureSpec.getMode(heightMeasureSpec) val widthMode = MeasureSpec.getMode(widthMeasureSpec) val heightSpec = if (heightMode == EXACTLY) { heightMeasureSpec } else { MeasureSpec.makeMeasureSpec( if (isSingleDigit()) maxSingleDigitHeight else interpBounds.height() + 2 * lockScreenPaint.strokeWidth.toInt(), heightMode, ) } val widthSpec = if (widthMode == EXACTLY) { widthMeasureSpec } else { MeasureSpec.makeMeasureSpec( if (isSingleDigit()) maxSingleDigitWidth else interpBounds.width() + 2 * lockScreenPaint.strokeWidth.toInt(), widthMode, ) } setMeasuredDimension(widthSpec, heightSpec) parent?.requestLayout() } private fun updateXTranslation(inPoint: Point, interpolatedTextBounds: Rect): Point { private fun updateXtranslation(inPoint: Point, interpolatedTextBounds: Rect): Point { when (horizontalAlignment) { HorizontalAlignment.LEFT -> { inPoint.x = lockScreenPaint.strokeWidth.toInt() - interpolatedTextBounds.left Loading @@ -420,9 +422,7 @@ open class SimpleDigitalClockTextView( // translation of reference point of text // used for translation when calling textInterpolator private fun getLocalTranslation(): Point { val interpolatedTextBounds = getInterpolatedTextBounds() setInterpolatedViewBounds(interpolatedTextBounds) val interpolatedTextBounds = updateInterpolatedTextBounds() val localTranslation = Point(0, 0) val correctedBaseline = if (baseline != -1) baseline else baselineFromMeasure // get the change from current baseline to expected baseline Loading Loading @@ -452,7 +452,7 @@ open class SimpleDigitalClockTextView( } } return updateXTranslation(localTranslation, interpolatedTextBounds) return updateXtranslation(localTranslation, interpolatedTextBounds) } fun applyStyles(textStyle: FontTextStyle, aodStyle: FontTextStyle?) { Loading