fix(android): pin TextView line-breaking to match measurement [SUP-1472]#5
Open
xindixu wants to merge 1 commit into
Open
fix(android): pin TextView line-breaking to match measurement [SUP-1472]#5xindixu wants to merge 1 commit into
xindixu wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
On Android, long / citation-heavy markdown messages were rendered truncated — the last paragraph(s) clipped — while identical content rendered in full on iOS and Web.
Root cause: a measure-vs-render line-breaking mismatch.
MeasurementStorebuilds aStaticLayoutthat setsbreakStrategy = HIGH_QUALITYonly on API 29+ and leaveshyphenationFrequencyat the default (NONE). The renderedTextView(setupAsMarkdownTextView) set neither, so it fell back to platform defaults (hyphenation enabled;HIGH_QUALITYeven below API 29). The two paths wrapped text differently, so the rendered text used more lines than the measured height reserved for the view — and since aTextViewclips overflow instead of scrolling, the tail was cut off. Same class of bug as the earlier Android width-clipping fix, on the line-breaking axis.Technical detail
utils/text/view/TextViewSetup.kt: pin the renderedTextViewtoBREAK_STRATEGY_HIGH_QUALITY+HYPHENATION_FREQUENCY_NONEon API 23+ (covers bothEnrichedMarkdownTextandEnrichedMarkdownInternalText, which share this setup).MeasurementStore.kt: extractapplyMarkdownLineBreaking()and apply it to all threeStaticLayoutbuilders, extending the same settings down to API 23 (previouslyHIGH_QUALITYwas set only on API 29+, so on API 23–28 measurement usedSIMPLEwhile theTextViewrenderedHIGH_QUALITY).Result: measure == render on every API level.
Test Plan