From 7e440e0eceaed0c1667ee63abd15c0deb4269687 Mon Sep 17 00:00:00 2001 From: Ibrahim Yilmaz Date: Tue, 8 Aug 2023 17:45:19 +0000 Subject: [PATCH] Use breakstrategy and hypenation properties in ImageFloatingTextView Hypenation and break strategy are 2 important configuration parameters for PrecomputedText. We have to use the same hypenation and break strategy in both PrecomputedText and StaticLayout creation to make use of the power of the PrecomputedText. Instead of using hard coded in StaticLayout creation, this CL sets these parameters in the constructor and use the properties. Bug: 289250881 Test: run ImageFloatingTextViewTest and Manual. Post a bigtext notification with this change and without and compare the result. Result should be the same. Change-Id: I65576ed822f32622d44d30a689531a9b8fa2ba07 --- .../com/android/internal/widget/ImageFloatingTextView.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/core/java/com/android/internal/widget/ImageFloatingTextView.java b/core/java/com/android/internal/widget/ImageFloatingTextView.java index de10bd2f47d7d..0704cb8094d73 100644 --- a/core/java/com/android/internal/widget/ImageFloatingTextView.java +++ b/core/java/com/android/internal/widget/ImageFloatingTextView.java @@ -63,6 +63,8 @@ public class ImageFloatingTextView extends TextView { public ImageFloatingTextView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { super(context, attrs, defStyleAttr, defStyleRes); + setHyphenationFrequency(Layout.HYPHENATION_FREQUENCY_FULL_FAST); + setBreakStrategy(Layout.BREAK_STRATEGY_HIGH_QUALITY); } @Override @@ -83,8 +85,8 @@ public class ImageFloatingTextView extends TextView { .setLineSpacing(getLineSpacingExtra(), getLineSpacingMultiplier()) .setIncludePad(getIncludeFontPadding()) .setUseLineSpacingFromFallbacks(true) - .setBreakStrategy(Layout.BREAK_STRATEGY_HIGH_QUALITY) - .setHyphenationFrequency(Layout.HYPHENATION_FREQUENCY_FULL_FAST); + .setBreakStrategy(getBreakStrategy()) + .setHyphenationFrequency(getHyphenationFrequency()); int maxLines; if (mMaxLinesForHeight > 0) { maxLines = mMaxLinesForHeight;