Merge "Update LS/AOD clock" into sc-dev

This commit is contained in:
TreeHugger Robot
2021-02-10 00:19:32 +00:00
committed by Android (Google) Code Review
11 changed files with 148 additions and 121 deletions

View File

@@ -76,7 +76,6 @@
android:textSize="100dp"
android:includeFontPadding="false"
android:fontFamily="@font/clock"
android:lineSpacingMultiplier=".7"
android:typeface="monospace"
android:elegantTextHeight="false"
dozeWeight="200"
@@ -97,7 +96,6 @@
android:gravity="center_horizontal"
android:textSize="@dimen/large_clock_text_size"
android:includeFontPadding="false"
android:lineSpacingMultiplier=".7"
android:fontFamily="@font/clock"
android:typeface="monospace"
android:elegantTextHeight="false"

View File

@@ -688,6 +688,11 @@
<!-- The amount to shift the clocks during a small/large transition -->
<dimen name="keyguard_clock_switch_y_shift">10dp</dimen>
<!-- Default line spacing multiplier between hours and minutes of the keyguard clock -->
<item name="keyguard_clock_line_spacing_scale" type="dimen" format="float">.7</item>
<!-- Burmese line spacing multiplier between hours and minutes of the keyguard clock -->
<item name="keyguard_clock_line_spacing_scale_burmese" type="dimen" format="float">1</item>
<item name="scrim_behind_alpha" format="float" type="dimen">0.62</item>
<!-- The minimum amount the user needs to swipe to go to the camera / phone. -->

View File

@@ -16,37 +16,72 @@
package com.android.keyguard;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.graphics.Color;
import android.graphics.Paint;
import android.icu.text.NumberFormat;
import android.util.MathUtils;
import com.android.settingslib.Utils;
import com.android.systemui.R;
import com.android.systemui.broadcast.BroadcastDispatcher;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.util.ViewController;
import java.util.Locale;
import java.util.Objects;
import java.util.TimeZone;
/**
* Controls the color of a GradientTextClock.
* Controller for an AnimatableClockView.
*/
public class AnimatableClockController extends ViewController<AnimatableClockView> {
private static final int FORMAT_NUMBER = 1234567890;
private final StatusBarStateController mStatusBarStateController;
private final int[] mDozingColors = new int[] {Color.WHITE, Color.WHITE};
private int[] mLockScreenColors = new int[2];
private final BroadcastDispatcher mBroadcastDispatcher;
private final int mDozingColor = Color.WHITE;
private int mLockScreenColor;
private boolean mIsDozing;
private Locale mLocale;
private final NumberFormat mBurmeseNf = NumberFormat.getInstance(Locale.forLanguageTag("my"));
private final String mBurmeseNumerals;
private final float mBurmeseLineSpacing;
private final float mDefaultLineSpacing;
public AnimatableClockController(
AnimatableClockView view,
StatusBarStateController statusBarStateController) {
StatusBarStateController statusBarStateController,
BroadcastDispatcher broadcastDispatcher) {
super(view);
mStatusBarStateController = statusBarStateController;
mIsDozing = mStatusBarStateController.isDozing();
mBroadcastDispatcher = broadcastDispatcher;
mBurmeseNumerals = mBurmeseNf.format(FORMAT_NUMBER);
mBurmeseLineSpacing = getContext().getResources().getFloat(
R.dimen.keyguard_clock_line_spacing_scale_burmese);
mDefaultLineSpacing = getContext().getResources().getFloat(
R.dimen.keyguard_clock_line_spacing_scale);
}
private BroadcastReceiver mLocaleBroadcastReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
updateLocale();
}
};
@Override
protected void onViewAttached() {
updateLocale();
mBroadcastDispatcher.registerReceiver(mLocaleBroadcastReceiver,
new IntentFilter(Intent.ACTION_LOCALE_CHANGED));
mStatusBarStateController.addCallback(mStatusBarStateListener);
mIsDozing = mStatusBarStateController.isDozing();
refreshTime();
@@ -55,6 +90,7 @@ public class AnimatableClockController extends ViewController<AnimatableClockVie
@Override
protected void onViewDetached() {
mBroadcastDispatcher.unregisterReceiver(mLocaleBroadcastReceiver);
mStatusBarStateController.removeCallback(mStatusBarStateListener);
}
@@ -84,11 +120,23 @@ public class AnimatableClockController extends ViewController<AnimatableClockVie
mView.refreshFormat();
}
private void updateLocale() {
Locale currLocale = Locale.getDefault();
if (!Objects.equals(currLocale, mLocale)) {
mLocale = currLocale;
NumberFormat nf = NumberFormat.getInstance(mLocale);
if (nf.format(FORMAT_NUMBER).equals(mBurmeseNumerals)) {
mView.setLineSpacingScale(mBurmeseLineSpacing);
} else {
mView.setLineSpacingScale(mDefaultLineSpacing);
}
}
}
private void initColors() {
mLockScreenColors[0] = Utils.getColorAttrDefaultColor(getContext(),
mLockScreenColor = Utils.getColorAttrDefaultColor(getContext(),
com.android.systemui.R.attr.wallpaperTextColor);
mLockScreenColors[1] = mLockScreenColors[0]; // same color
mView.setColors(mDozingColors, mLockScreenColors);
mView.setColors(mDozingColor, mLockScreenColor);
mView.animateDoze(mIsDozing, false);
}

View File

@@ -44,12 +44,13 @@ public class AnimatableClockView extends TextView {
private final Calendar mTime = Calendar.getInstance();
private CharSequence mFormat;
private CharSequence mDescFormat;
private int[] mDozingColors;
private int[] mLockScreenColors;
private final int mDozingWeight;
private final int mLockScreenWeight;
private CharSequence mFormat;
private CharSequence mDescFormat;
private int mDozingColor;
private int mLockScreenColor;
private float mLineSpacingScale = 1f;
private TextAnimator mTextAnimator = null;
private Runnable mOnTextAnimatorInitialized;
@@ -111,8 +112,7 @@ public class AnimatableClockView extends TextView {
() -> {
invalidate();
return Unit.INSTANCE;
},
2 /* number of lines (each can have a unique Paint) */);
});
if (mOnTextAnimatorInitialized != null) {
mOnTextAnimatorInitialized.run();
mOnTextAnimatorInitialized = null;
@@ -127,15 +127,20 @@ public class AnimatableClockView extends TextView {
mTextAnimator.draw(canvas);
}
void setColors(int[] dozingColors, int[] lockScreenColors) {
mDozingColors = dozingColors;
mLockScreenColors = lockScreenColors;
void setLineSpacingScale(float scale) {
mLineSpacingScale = scale;
setLineSpacing(0, mLineSpacingScale);
}
void setColors(int dozingColor, int lockScreenColor) {
mDozingColor = dozingColor;
mLockScreenColor = lockScreenColor;
}
void animateDoze(boolean isDozing, boolean animate) {
setTextStyle(isDozing ? mDozingWeight : mLockScreenWeight /* weight */,
-1,
isDozing ? mDozingColors : mLockScreenColors,
isDozing ? mDozingColor : mLockScreenColor,
animate);
}
@@ -152,15 +157,15 @@ public class AnimatableClockView extends TextView {
private void setTextStyle(
@IntRange(from = 0, to = 1000) int weight,
@FloatRange(from = 0) float textSize,
int[] colors,
int color,
boolean animate) {
if (mTextAnimator != null) {
mTextAnimator.setTextStyle(weight, textSize, colors, animate, ANIM_DURATION, null);
mTextAnimator.setTextStyle(weight, textSize, color, animate, ANIM_DURATION, null);
} else {
// when the text animator is set, update its start values
mOnTextAnimatorInitialized =
() -> mTextAnimator.setTextStyle(
weight, textSize, colors, false, ANIM_DURATION, null);
weight, textSize, color, false, ANIM_DURATION, null);
}
}

View File

@@ -28,6 +28,7 @@ import android.widget.FrameLayout;
import com.android.internal.colorextraction.ColorExtractor;
import com.android.keyguard.clock.ClockManager;
import com.android.systemui.R;
import com.android.systemui.broadcast.BroadcastDispatcher;
import com.android.systemui.colorextraction.SysuiColorExtractor;
import com.android.systemui.dagger.qualifiers.Main;
import com.android.systemui.plugins.ClockPlugin;
@@ -56,6 +57,7 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS
private final ClockManager mClockManager;
private final KeyguardSliceViewController mKeyguardSliceViewController;
private final NotificationIconAreaController mNotificationIconAreaController;
private final BroadcastDispatcher mBroadcastDispatcher;
/**
* Gradient clock for usage when mode != KeyguardUpdateMonitor.LOCK_SCREEN_MODE_NORMAL.
@@ -101,7 +103,8 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS
SysuiColorExtractor colorExtractor, ClockManager clockManager,
KeyguardSliceViewController keyguardSliceViewController,
NotificationIconAreaController notificationIconAreaController,
ContentResolver contentResolver) {
ContentResolver contentResolver,
BroadcastDispatcher broadcastDispatcher) {
super(keyguardClockSwitch);
mResources = resources;
mStatusBarStateController = statusBarStateController;
@@ -109,6 +112,7 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS
mClockManager = clockManager;
mKeyguardSliceViewController = keyguardSliceViewController;
mNotificationIconAreaController = notificationIconAreaController;
mBroadcastDispatcher = broadcastDispatcher;
mTimeFormat = Settings.System.getString(contentResolver, Settings.System.TIME_12_24);
}
@@ -231,12 +235,14 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS
mNewLockScreenClockViewController =
new AnimatableClockController(
mView.findViewById(R.id.animatable_clock_view),
mStatusBarStateController);
mStatusBarStateController,
mBroadcastDispatcher);
mNewLockScreenClockViewController.init();
mNewLockScreenLargeClockViewController =
new AnimatableClockController(
mView.findViewById(R.id.animatable_clock_view_large),
mStatusBarStateController);
mStatusBarStateController,
mBroadcastDispatcher);
mNewLockScreenLargeClockViewController.init();
}
} else {

View File

@@ -54,11 +54,10 @@ private const val DEFAULT_ANIMATION_DURATION: Long = 300
*/
class TextAnimator(
layout: Layout,
private val invalidateCallback: () -> Unit,
private val numLines: Int = 1
private val invalidateCallback: () -> Unit
) {
// Following two members are for mutable for testing purposes.
internal var textInterpolator: TextInterpolator = TextInterpolator(layout, numLines)
internal var textInterpolator: TextInterpolator = TextInterpolator(layout)
internal var animator: ValueAnimator = ValueAnimator.ofFloat(1f).apply {
duration = DEFAULT_ANIMATION_DURATION
addUpdateListener {
@@ -99,7 +98,7 @@ class TextAnimator(
fun setTextStyle(
weight: Int = -1,
textSize: Float = -1f,
colors: IntArray? = null,
color: Int? = null,
animate: Boolean = true,
duration: Long = -1L,
interpolator: TimeInterpolator? = null
@@ -110,21 +109,13 @@ class TextAnimator(
}
if (textSize >= 0) {
for (targetPaint in textInterpolator.targetPaint)
targetPaint.textSize = textSize
textInterpolator.targetPaint.textSize = textSize
}
if (weight >= 0) {
for (targetPaint in textInterpolator.targetPaint)
targetPaint.fontVariationSettings = "'$TAG_WGHT' $weight"
textInterpolator.targetPaint.fontVariationSettings = "'$TAG_WGHT' $weight"
}
if (colors != null) {
require(colors.size == textInterpolator.targetPaint.size) {
"colors size (${colors.size}) must be the same size as" +
" targetPaints size (${textInterpolator.targetPaint.size})," +
" which was initialized as numLines ($numLines)"
}
for ((index, targetPaint) in textInterpolator.targetPaint.withIndex())
targetPaint.color = colors[index]
if (color != null) {
textInterpolator.targetPaint.color = color
}
textInterpolator.onTargetPaintModified()

View File

@@ -30,8 +30,7 @@ import java.lang.Math.max
* Provide text style linear interpolation for plain text.
*/
class TextInterpolator(
layout: Layout,
lines: Int = 1
layout: Layout
) {
/**
@@ -40,11 +39,9 @@ class TextInterpolator(
* Once you modified the style parameters, you have to call reshapeText to recalculate base text
* layout.
*
* @return an array list of paint objects representing one paint per line of text. If this
* list has a smaller size than the number of lines, all extra lines will use the Paint an
* index 0.
* @return a paint object
*/
val basePaint = createDefaultPaint(layout.paint, lines)
val basePaint = TextPaint(layout.paint)
/**
* Returns target paint used for interpolation.
@@ -52,18 +49,9 @@ class TextInterpolator(
* Once you modified the style parameters, you have to call reshapeText to recalculate target
* text layout.
*
* @return an array list of paint objects representing one paint per line of text. If this
* list has a smaller size than the number of lines, all extra lines will use the Paint an
* index 0.
* @return a paint object
*/
val targetPaint = createDefaultPaint(layout.paint, lines)
private fun createDefaultPaint(paint: TextPaint, lines: Int): ArrayList<TextPaint> {
val paintList = ArrayList<TextPaint>()
for (i in 0 until lines)
paintList.add(TextPaint(paint))
return paintList
}
val targetPaint = TextPaint(layout.paint)
/**
* A class represents a single font run.
@@ -102,7 +90,7 @@ class TextInterpolator(
private val fontInterpolator = FontInterpolator()
// Recycling object for glyph drawing. Will be extended for the longest font run if needed.
private val tmpDrawPaints = ArrayList<TextPaint>()
private val tmpDrawPaint = TextPaint()
private var tmpPositionArray = FloatArray(20)
/**
@@ -216,10 +204,10 @@ class TextInterpolator(
if (progress == 0f) {
return
} else if (progress == 1f) {
updatePaint(basePaint, targetPaint)
basePaint.set(targetPaint)
} else {
lerp(basePaint, targetPaint, progress, tmpDrawPaints)
updatePaint(basePaint, tmpDrawPaints)
lerp(basePaint, targetPaint, progress, tmpDrawPaint)
basePaint.set(tmpDrawPaint)
}
lines.forEach { line ->
@@ -237,21 +225,13 @@ class TextInterpolator(
progress = 0f
}
companion object {
fun updatePaint(toUpdate: ArrayList<TextPaint>, newValues: ArrayList<TextPaint>) {
toUpdate.clear()
for (paint in newValues)
toUpdate.add(TextPaint(paint))
}
}
/**
* Draws interpolated text at the given progress.
*
* @param canvas a canvas.
*/
fun draw(canvas: Canvas) {
lerp(basePaint, targetPaint, progress, tmpDrawPaints)
lerp(basePaint, targetPaint, progress, tmpDrawPaint)
lines.forEachIndexed { lineNo, line ->
line.runs.forEach { run ->
canvas.save()
@@ -261,10 +241,7 @@ class TextInterpolator(
canvas.translate(origin, layout.getLineBaseline(lineNo).toFloat())
run.fontRuns.forEach { fontRun ->
if (lineNo >= tmpDrawPaints.size)
drawFontRun(canvas, run, fontRun, tmpDrawPaints[0])
else
drawFontRun(canvas, run, fontRun, tmpDrawPaints[lineNo])
drawFontRun(canvas, run, fontRun, tmpDrawPaint)
}
} finally {
canvas.restore()
@@ -430,27 +407,19 @@ class TextInterpolator(
}
// Linear interpolate the paint.
private fun lerp(
from: ArrayList<TextPaint>,
to: ArrayList<TextPaint>,
progress: Float,
out: ArrayList<TextPaint>
) {
out.clear()
private fun lerp(from: Paint, to: Paint, progress: Float, out: Paint) {
out.set(from)
// Currently only font size & colors are interpolated.
// TODO(172943390): Add other interpolation or support custom interpolator.
for (index in from.indices) {
val paint = TextPaint(from[index])
paint.textSize = MathUtils.lerp(from[index].textSize, to[index].textSize, progress)
paint.color = ColorUtils.blendARGB(from[index].color, to[index].color, progress)
out.add(paint)
}
out.textSize = MathUtils.lerp(from.textSize, to.textSize, progress)
out.color = ColorUtils.blendARGB(from.color, to.color, progress)
}
// Shape the text and stores the result to out argument.
private fun shapeText(
layout: Layout,
paints: ArrayList<TextPaint>
paint: TextPaint
): List<List<PositionedGlyphs>> {
val out = mutableListOf<List<PositionedGlyphs>>()
for (lineNo in 0 until layout.lineCount) { // Shape all lines.
@@ -458,7 +427,7 @@ class TextInterpolator(
val count = layout.getLineEnd(lineNo) - lineStart
val runs = mutableListOf<PositionedGlyphs>()
TextShaper.shapeText(layout.text, lineStart, count, layout.textDirectionHeuristic,
paints[lineNo]) { _, _, glyphs, _ ->
paint) { _, _, glyphs, _ ->
runs.add(glyphs)
}
out.add(runs)

View File

@@ -289,7 +289,8 @@ public class KeyguardIndicationRotateTextViewController extends
if (hasIndications()) {
pw.println(" All messages:");
for (int type : mIndicationMessages.keySet()) {
pw.println(" type=" + type + " message=" + mIndicationMessages.get(type));
pw.println(" type=" + type
+ " message=" + mIndicationMessages.get(type).getMessage());
}
}
}

View File

@@ -34,6 +34,7 @@ import android.widget.FrameLayout;
import com.android.internal.colorextraction.ColorExtractor;
import com.android.keyguard.clock.ClockManager;
import com.android.systemui.SysuiTestCase;
import com.android.systemui.broadcast.BroadcastDispatcher;
import com.android.systemui.colorextraction.SysuiColorExtractor;
import com.android.systemui.plugins.ClockPlugin;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
@@ -75,6 +76,8 @@ public class KeyguardClockSwitchControllerTest extends SysuiTestCase {
NotificationIconAreaController mNotificationIconAreaController;
@Mock
ContentResolver mContentResolver;
@Mock
BroadcastDispatcher mBroadcastDispatcher;
private KeyguardClockSwitchController mController;
@@ -94,7 +97,8 @@ public class KeyguardClockSwitchControllerTest extends SysuiTestCase {
mClockManager,
mKeyguardSliceViewController,
mNotificationIconAreaController,
mContentResolver);
mContentResolver,
mBroadcastDispatcher);
when(mStatusBarStateController.getState()).thenReturn(StatusBarState.SHADE);
when(mColorExtractor.getColors(anyInt())).thenReturn(mGradientColors);

View File

@@ -34,9 +34,9 @@ import org.mockito.Mockito.verify
import kotlin.math.ceil
private val PAINT = arrayListOf(TextPaint().apply {
private val PAINT = TextPaint().apply {
textSize = 32f
})
}
@RunWith(AndroidTestingRunner::class)
@SmallTest
@@ -49,10 +49,10 @@ class TextAnimatorTest : SysuiTestCase() {
@Test
fun testAnimationStarted() {
val layout = makeLayout("Hello, World", PAINT[0])
val layout = makeLayout("Hello, World", PAINT)
val valueAnimator = mock(ValueAnimator::class.java)
val textInterpolator = mock(TextInterpolator::class.java)
val paint = arrayListOf(mock(TextPaint::class.java))
val paint = mock(TextPaint::class.java)
`when`(textInterpolator.targetPaint).thenReturn(paint)
val textAnimator = TextAnimator(layout, {}).apply {
@@ -81,10 +81,10 @@ class TextAnimatorTest : SysuiTestCase() {
@Test
fun testAnimationNotStarted() {
val layout = makeLayout("Hello, World", PAINT[0])
val layout = makeLayout("Hello, World", PAINT)
val valueAnimator = mock(ValueAnimator::class.java)
val textInterpolator = mock(TextInterpolator::class.java)
val paint = arrayListOf(mock(TextPaint::class.java))
val paint = mock(TextPaint::class.java)
`when`(textInterpolator.targetPaint).thenReturn(paint)
val textAnimator = TextAnimator(layout, {}).apply {

View File

@@ -21,9 +21,9 @@ import android.graphics.Canvas
import android.testing.AndroidTestingRunner
import android.text.Layout
import android.text.StaticLayout
import android.text.TextPaint
import android.text.TextDirectionHeuristic
import android.text.TextDirectionHeuristics
import android.text.TextPaint
import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase
import com.google.common.truth.Truth.assertThat
@@ -40,13 +40,13 @@ private val PAINT = TextPaint().apply {
textSize = 32f
}
private val START_PAINT = arrayListOf(TextPaint(PAINT).apply {
private val START_PAINT = TextPaint(PAINT).apply {
fontVariationSettings = "'wght' 400"
})
}
private val END_PAINT = arrayListOf(TextPaint(PAINT).apply {
private val END_PAINT = TextPaint(PAINT).apply {
fontVariationSettings = "'wght' 700"
})
}
@RunWith(AndroidTestingRunner::class)
@SmallTest
@@ -67,16 +67,16 @@ class TextInterpolatorTest : SysuiTestCase() {
val layout = makeLayout(TEXT, PAINT)
val interp = TextInterpolator(layout)
TextInterpolator.updatePaint(interp.basePaint, START_PAINT)
interp.basePaint.set(START_PAINT)
interp.onBasePaintModified()
TextInterpolator.updatePaint(interp.targetPaint, END_PAINT)
interp.targetPaint.set(END_PAINT)
interp.onTargetPaintModified()
// Just after created TextInterpolator, it should have 0 progress.
assertThat(interp.progress).isEqualTo(0f)
val actual = interp.toBitmap(BMP_WIDTH, BMP_HEIGHT)
val expected = makeLayout(TEXT, START_PAINT[0]).toBitmap(BMP_WIDTH, BMP_HEIGHT)
val expected = makeLayout(TEXT, START_PAINT).toBitmap(BMP_WIDTH, BMP_HEIGHT)
assertThat(expected.sameAs(actual)).isTrue()
}
@@ -86,15 +86,15 @@ class TextInterpolatorTest : SysuiTestCase() {
val layout = makeLayout(TEXT, PAINT)
val interp = TextInterpolator(layout)
TextInterpolator.updatePaint(interp.basePaint, START_PAINT)
interp.basePaint.set(START_PAINT)
interp.onBasePaintModified()
TextInterpolator.updatePaint(interp.targetPaint, END_PAINT)
interp.targetPaint.set(END_PAINT)
interp.onTargetPaintModified()
interp.progress = 1f
val actual = interp.toBitmap(BMP_WIDTH, BMP_HEIGHT)
val expected = makeLayout(TEXT, END_PAINT[0]).toBitmap(BMP_WIDTH, BMP_HEIGHT)
val expected = makeLayout(TEXT, END_PAINT).toBitmap(BMP_WIDTH, BMP_HEIGHT)
assertThat(expected.sameAs(actual)).isTrue()
}
@@ -104,10 +104,10 @@ class TextInterpolatorTest : SysuiTestCase() {
val layout = makeLayout(TEXT, PAINT)
val interp = TextInterpolator(layout)
TextInterpolator.updatePaint(interp.basePaint, START_PAINT)
interp.basePaint.set(START_PAINT)
interp.onBasePaintModified()
TextInterpolator.updatePaint(interp.targetPaint, END_PAINT)
interp.targetPaint.set(END_PAINT)
interp.onTargetPaintModified()
// We cannot expect exact text layout of the middle position since we don't use text shaping
@@ -115,9 +115,9 @@ class TextInterpolatorTest : SysuiTestCase() {
// end state.
interp.progress = 0.5f
val actual = interp.toBitmap(BMP_WIDTH, BMP_HEIGHT)
assertThat(actual.sameAs(makeLayout(TEXT, START_PAINT[0])
assertThat(actual.sameAs(makeLayout(TEXT, START_PAINT)
.toBitmap(BMP_WIDTH, BMP_HEIGHT))).isFalse()
assertThat(actual.sameAs(makeLayout(TEXT, END_PAINT[0])
assertThat(actual.sameAs(makeLayout(TEXT, END_PAINT)
.toBitmap(BMP_WIDTH, BMP_HEIGHT))).isFalse()
}
@@ -126,10 +126,10 @@ class TextInterpolatorTest : SysuiTestCase() {
val layout = makeLayout(TEXT, PAINT)
val interp = TextInterpolator(layout)
TextInterpolator.updatePaint(interp.basePaint, START_PAINT)
interp.basePaint.set(START_PAINT)
interp.onBasePaintModified()
TextInterpolator.updatePaint(interp.targetPaint, END_PAINT)
interp.targetPaint.set(END_PAINT)
interp.onTargetPaintModified()
interp.progress = 0.5f
@@ -148,16 +148,16 @@ class TextInterpolatorTest : SysuiTestCase() {
val layout = makeLayout(BIDI_TEXT, PAINT, TextDirectionHeuristics.LTR)
val interp = TextInterpolator(layout)
TextInterpolator.updatePaint(interp.basePaint, START_PAINT)
interp.basePaint.set(START_PAINT)
interp.onBasePaintModified()
TextInterpolator.updatePaint(interp.targetPaint, END_PAINT)
interp.targetPaint.set(END_PAINT)
interp.onTargetPaintModified()
// Just after created TextInterpolator, it should have 0 progress.
assertThat(interp.progress).isEqualTo(0f)
val actual = interp.toBitmap(BMP_WIDTH, BMP_HEIGHT)
val expected = makeLayout(BIDI_TEXT, START_PAINT[0], TextDirectionHeuristics.LTR)
val expected = makeLayout(BIDI_TEXT, START_PAINT, TextDirectionHeuristics.LTR)
.toBitmap(BMP_WIDTH, BMP_HEIGHT)
assertThat(expected.sameAs(actual)).isTrue()
@@ -168,16 +168,16 @@ class TextInterpolatorTest : SysuiTestCase() {
val layout = makeLayout(BIDI_TEXT, PAINT, TextDirectionHeuristics.RTL)
val interp = TextInterpolator(layout)
TextInterpolator.updatePaint(interp.basePaint, START_PAINT)
interp.basePaint.set(START_PAINT)
interp.onBasePaintModified()
TextInterpolator.updatePaint(interp.targetPaint, END_PAINT)
interp.targetPaint.set(END_PAINT)
interp.onTargetPaintModified()
// Just after created TextInterpolator, it should have 0 progress.
assertThat(interp.progress).isEqualTo(0f)
val actual = interp.toBitmap(BMP_WIDTH, BMP_HEIGHT)
val expected = makeLayout(BIDI_TEXT, START_PAINT[0], TextDirectionHeuristics.RTL)
val expected = makeLayout(BIDI_TEXT, START_PAINT, TextDirectionHeuristics.RTL)
.toBitmap(BMP_WIDTH, BMP_HEIGHT)
assertThat(expected.sameAs(actual)).isTrue()