@@ -117,6 +117,7 @@ public final class CollapsingTextHelper {
117117 @ Nullable private CharSequence text ;
118118 @ Nullable private CharSequence textToDraw ;
119119 private boolean isRtl ;
120+ private boolean isRtlTextDirectionHeuristicsEnabled = true ;
120121
121122 private boolean useTexture ;
122123 @ Nullable private Bitmap expandedTitleTexture ;
@@ -522,6 +523,14 @@ public float getExpandedTextSize() {
522523 return expandedTextSize ;
523524 }
524525
526+ public void setRtlTextDirectionHeuristicsEnabled (boolean rtlTextDirectionHeuristicsEnabled ) {
527+ isRtlTextDirectionHeuristicsEnabled = rtlTextDirectionHeuristicsEnabled ;
528+ }
529+
530+ public boolean isRtlTextDirectionHeuristicsEnabled () {
531+ return isRtlTextDirectionHeuristicsEnabled ;
532+ }
533+
525534 private void calculateCurrentOffsets () {
526535 calculateOffsets (expandedFraction );
527536 }
@@ -840,16 +849,22 @@ private void drawMultilineTransition(@NonNull Canvas canvas, float currentExpand
840849
841850 private boolean calculateIsRtl (@ NonNull CharSequence text ) {
842851 final boolean defaultIsRtl = isDefaultIsRtl ();
843- return (defaultIsRtl
844- ? TextDirectionHeuristicsCompat .FIRSTSTRONG_RTL
845- : TextDirectionHeuristicsCompat .FIRSTSTRONG_LTR )
846- .isRtl (text , 0 , text .length ());
852+ return isRtlTextDirectionHeuristicsEnabled
853+ ? isTextDirectionHeuristicsIsRtl (text , defaultIsRtl )
854+ : defaultIsRtl ;
847855 }
848856
849857 private boolean isDefaultIsRtl () {
850858 return ViewCompat .getLayoutDirection (view ) == ViewCompat .LAYOUT_DIRECTION_RTL ;
851859 }
852860
861+ private boolean isTextDirectionHeuristicsIsRtl (@ NonNull CharSequence text , boolean defaultIsRtl ) {
862+ return (defaultIsRtl
863+ ? TextDirectionHeuristicsCompat .FIRSTSTRONG_RTL
864+ : TextDirectionHeuristicsCompat .FIRSTSTRONG_LTR )
865+ .isRtl (text , 0 , text .length ());
866+ }
867+
853868 private void setInterpolatedTextSize (float textSize ) {
854869 calculateUsingTextSize (textSize );
855870
0 commit comments