Skip to content

Commit 58ad14e

Browse files
pubiqqdsn5ft
authored andcommitted
[TopAppBar] Make letter spacing dependent on text size in CollapsingTextHelper
Resolves #4640 GIT_ORIGIN_REV_ID=587f81fd992281152fb9a0c83ae74d47cde4c3a0 PiperOrigin-RevId: 854203889
1 parent 00e5eda commit 58ad14e

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

lib/java/com/google/android/material/internal/CollapsingTextHelper.java

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -696,6 +696,17 @@ private void calculateOffsets(final float fraction) {
696696
currentDrawY = lerp(expandedDrawY, collapsedDrawY, fraction, positionInterpolator);
697697

698698
setInterpolatedTextSize(fraction);
699+
700+
if (collapsedLetterSpacing != expandedLetterSpacing) {
701+
textPaint.setLetterSpacing(
702+
lerp(
703+
expandedLetterSpacing,
704+
collapsedLetterSpacing,
705+
fraction,
706+
AnimationUtils.FAST_OUT_SLOW_IN_INTERPOLATOR));
707+
} else {
708+
textPaint.setLetterSpacing(collapsedLetterSpacing);
709+
}
699710
}
700711

701712
setCollapsedTextBlend(
@@ -712,17 +723,6 @@ private void calculateOffsets(final float fraction) {
712723
textPaint.setColor(getCurrentCollapsedTextColor());
713724
}
714725

715-
if (collapsedLetterSpacing != expandedLetterSpacing) {
716-
textPaint.setLetterSpacing(
717-
lerp(
718-
expandedLetterSpacing,
719-
collapsedLetterSpacing,
720-
fraction,
721-
AnimationUtils.FAST_OUT_SLOW_IN_INTERPOLATOR));
722-
} else {
723-
textPaint.setLetterSpacing(collapsedLetterSpacing);
724-
}
725-
726726
// Calculates paint parameters for shadow layer.
727727
currentShadowRadius = lerp(expandedShadowRadius, collapsedShadowRadius, fraction, null);
728728
currentShadowDx = lerp(expandedShadowDx, collapsedShadowDx, fraction, null);
@@ -1320,11 +1320,11 @@ public void setStaticLayoutBuilderConfigurer(
13201320
}
13211321

13221322
/**
1323-
* Returns true if {@code value} is 'close' to it's closest decimal value. Close is currently
1323+
* Returns true if {@code value1} is 'close' to {@code value2}. Close is currently
13241324
* defined as it's difference being < 0.00001.
13251325
*/
1326-
private static boolean isClose(float value, float targetValue) {
1327-
return Math.abs(value - targetValue) < 0.00001f;
1326+
private static boolean isClose(float value1, float value2) {
1327+
return Math.abs(value1 - value2) < 0.00001f;
13281328
}
13291329

13301330
public ColorStateList getExpandedTextColor() {

0 commit comments

Comments
 (0)