@@ -696,17 +696,6 @@ private void calculateOffsets(final float fraction) {
696696 textPaint .setColor (getCurrentCollapsedTextColor ());
697697 }
698698
699- if (collapsedLetterSpacing != expandedLetterSpacing ) {
700- textPaint .setLetterSpacing (
701- lerp (
702- expandedLetterSpacing ,
703- collapsedLetterSpacing ,
704- fraction ,
705- AnimationUtils .FAST_OUT_SLOW_IN_INTERPOLATOR ));
706- } else {
707- textPaint .setLetterSpacing (collapsedLetterSpacing );
708- }
709-
710699 // Calculates paint parameters for shadow layer.
711700 currentShadowRadius = lerp (expandedShadowRadius , collapsedShadowRadius , fraction , null );
712701 currentShadowDx = lerp (expandedShadowDx , collapsedShadowDx , fraction , null );
@@ -1068,7 +1057,6 @@ private void calculateUsingTextSize(final float fraction, boolean forceRecalcula
10681057 newTypeface = collapsedTypeface ;
10691058 } else {
10701059 newTextSize = expandedTextSize ;
1071- newLetterSpacing = expandedLetterSpacing ;
10721060 newTypeface = expandedTypeface ;
10731061 if (isClose (fraction , /* targetValue= */ 0 )) {
10741062 // If we're close to the expanded text size, snap to it and use a scale of 1
@@ -1080,6 +1068,11 @@ private void calculateUsingTextSize(final float fraction, boolean forceRecalcula
10801068 / expandedTextSize ;
10811069 }
10821070
1071+ newLetterSpacing = lerp (
1072+ expandedLetterSpacing , collapsedLetterSpacing ,
1073+ 1f , collapsedTextSize / expandedTextSize ,
1074+ scale );
1075+
10831076 float textSizeRatio = collapsedTextSize / expandedTextSize ;
10841077 // This is the size of the expanded bounds when it is scaled to match the
10851078 // collapsed text size
@@ -1289,11 +1282,11 @@ public void setStaticLayoutBuilderConfigurer(
12891282 }
12901283
12911284 /**
1292- * Returns true if {@code value } is 'close' to it's closest decimal value . Close is currently
1285+ * Returns true if {@code value1 } is 'close' to {@code value2} . Close is currently
12931286 * defined as it's difference being < 0.00001.
12941287 */
1295- private static boolean isClose (float value , float targetValue ) {
1296- return Math .abs (value - targetValue ) < 0.00001f ;
1288+ private static boolean isClose (float value1 , float value2 ) {
1289+ return Math .abs (value1 - value2 ) < 0.00001f ;
12971290 }
12981291
12991292 public ColorStateList getExpandedTextColor () {
@@ -1336,6 +1329,22 @@ private static float lerp(
13361329 return AnimationUtils .lerp (startValue , endValue , fraction );
13371330 }
13381331
1332+ private static float lerp (
1333+ float outputStart , float outputEnd ,
1334+ float inputStart , float inputEnd ,
1335+ float inputValue ) {
1336+ if (isClose (inputEnd , inputStart )) {
1337+ if (isClose (outputEnd , outputStart )) {
1338+ return outputStart ;
1339+ } else {
1340+ throw new RuntimeException ("\" input\" range is empty, but \" output\" is not" );
1341+ }
1342+ }
1343+
1344+ float value = (inputValue - inputStart ) / (inputEnd - inputStart );
1345+ return outputStart + (outputEnd - outputStart ) * value ;
1346+ }
1347+
13391348 private static boolean rectEquals (@ NonNull Rect r , int left , int top , int right , int bottom ) {
13401349 return !(r .left != left || r .top != top || r .right != right || r .bottom != bottom );
13411350 }
0 commit comments