If the given precomputed text is not compatible with the TextView,
reject the text by throwing IllegalArgumentException.
Bug: 73091756
Test: atest CtsWidgetTestCases:EditTextTest
CtsWidgetTestCases:TextViewFadingEdgeTest
FrameworksCoreTests:TextViewFallbackLineSpacingTest
FrameworksCoreTests:TextViewTest FrameworksCoreTests:TypefaceTest
CtsGraphicsTestCases:TypefaceTest CtsWidgetTestCases:TextViewTest
CtsTextTestCases FrameworksCoreTests:android.text
CtsWidgetTestCases:TextViewPrecomputedTextTest
Change-Id: I4fbf89a5f1409e8eefdeb9f208f9a3758220fe1a
(cherry picked from commit 3a0787af5e)
This is 2nd attempt of I7db9e2ca4db68a16648cfb8fcf63555f501304c2
This CL changes the MeasuredText API:
- Rename MeasuredText to PrecomputedText.
- Introduce PrecomputedText.Param which holds all text layout parameters.
- Add API to get PrecomputedText.Param from TextView.
- Remove MeasuredText.Builder and add PrecomputedText.create method instead.
- Remove setRange from MeasuredText since it is not for normal use case.
(It can not be used for TextView)
Bug: 67504091
Bug: 72861572
Test: bit FrameworksCoreTests:android.text.
Test: atest CtsWidgetTestCases:EditTextTest \
CtsWidgetTestCases:TextViewFadingEdgeTest \
FrameworksCoreTests:TextViewFallbackLineSpacingTest \
FrameworksCoreTests:TextViewTest FrameworksCoreTests:TypefaceTest \
CtsGraphicsTestCases:TypefaceTest CtsWidgetTestCases:TextViewTest \
CtsTextTestCases
Change-Id: Ie73bce52c6c673cda58973ddad04627a7cf2e5e9
The last change needs more discussion and found some edge cases. Revert and make small step-by-step changes.
Bug: 73091756
This reverts commit 7fd36d19e3.
Change-Id: I89ff52a70cf6a5d6c553afa20f83719e1f9eb726
The majority of Manager-style classes already use Context.getUserId()
when making calls into the OS, so clean up the remaining callers to
unify behind this strategy.
This gives @SystemApi developers a nice clean interface to interact
across user boundaries, instead of manually adding "AsUser" or
"ForUser" method variants, which would quickly become unsustainable.
Test: builds, boots
Bug: 72863821
Exempt-From-Owner-Approval: trivial changes
Change-Id: Ib772ec4438e57a2ad4950821b9432f9842998451
Uses the TextClassifier to generate links on a background thread.
The links are applied on the calling thread.
Test: see topic
Bug: 67629726
Change-Id: I0f1940a2ffbf19f4436c0a20b0c62e6bbc03cd7a
This was surfacing in the android clock with certain locales e.g. fr_CA.
Fixed for all unqiue locale patterns.
Bug: 71572309
Test: manual - changed locale to Fr_CA and made sure clock seperator WAI
Test: atest CtsWidgetTestCases:TextViewTest CtsWidgetTestCases:EditTextTest CtsWidgetTestCases:TextViewFadingEdgeTest FrameworksCoreTests:TextViewFallbackLineSpacingTest FrameworksCoreTests:TextViewTest
Change-Id: Ie43bf9428e8c5ef2fe2e9545cb5a6dada25d6e52
There is already MeasuredText, so renamed existing MeasuredText to
MeasuredParagraph, then renamed PremeasuredText to MeasuredText.
Bug: 67504091
Test: bit CtsWidgetTestCases:android.widget.cts.TextViewTest
Test: bit CtsTextTestCases:*
Change-Id: Ie20bea9501b18fabb36f64d388a7851c4643d4c3
For some spans, SpannableStringBuilder cannot determine the previous
start and previous end values correctly. In some cases, previous end
value is smaller than previous start value, and this causes
DynamicLayout to access negative index values. This CL updates
DynamicLayout to reflow from index 0 if such a case occurs.
Test: Added a CTS test
Test: bit CtsTextTestCases:android.text.cts.DynamicLayoutTest#testReflow_afterSpanChangedShouldNotThrowException
Bug: 67926915
Change-Id: Ibc55edfd5e49a7782cdd807e2465f4f21577b68d
The Builders should be used instead.
Also remove a StaticLayout constructor only used in tests in favor
of the Builder.
Bug: 64985428
Test: adb shell am instrument -w -e class android.text.StaticLayoutTest com.android.frameworks.coretests/android.support.test.runner.AndroidJUnitRunner
Change-Id: Ief6839d2c6bb0969bdeb30359eae00d38a2bdb09
DynamicLayout made wrong adjustments to the block indices set to be
redrawn. Every indice after the first change was being added the
diff count in the blocks. However this meant when there are 2 deletes
and an index as 1, it would become -1 (wrong array index). The change
should be applied to indices outside of [firstBlock, lastBlock].
Test: Added android.text.DynamicLayoutTest#testReflow_afterSpannableEdit
Test: bit FrameworksCoreTests:android.text.DynamicLayoutTest
Test: bit FrameworksCoreTests:android.text.DynamicLayoutBlocksTest
Test: bit CtsTextTestCases:android.text.cts.DynamicLayoutTest
Bug: 67405337
Change-Id: Ie5e5658ffca4293f32f7b574d22d307e9e8d52dc
By measuring the character widths beforehand, we can save at least 40%
of the StaticLayout construction time which typically happens on UI
thread.
Also verified this doesn't cause performance regression for not
premeasured text.
Raw performance score (Not premeasured -> premeasured, median, N=100)
No Style, Greedy, Hyphenation OFF: 7,812,975 -> 503,245 (-93.6%)
No Style, Balanced, Hyphenation OFF: 7,843,254 -> 396,892 (-95.0%)
No Style, Greedy, Hyphenation ON : 19,134,214 -> 11,658,928 (-39.1%)
No Style, Balanced, Hyphenation ON : 19,348,062 -> 11,634,942 (-39.9%)
Styled, Greedy, Hyphenation OFF: 14,353,673 -> 572,840 (-96.0%)
Raw performance score (w/o patch -> w/ patch, median, N=100):
No Style, Greedy, Hyphenation OFF: 7,732,894 -> 7,812,975 (+1.04%)
No Style, Balanced, Hyphenation OFF: 7,884,510 -> 7,843,254 (-0.52%)
No Style, Greedy, Hyphenation ON : 18,986,958 -> 19,134,214 (+0.78%)
No Style, Balanced, Hyphenation ON : 19,232,791 -> 19,348,062 (+0.60%)
Styled, Greedy, Hyphenation OFF: 14,319,690 -> 14,353,673 (+0.24%)
Bug: 67504091
Test: bit CtsTextTestCases:*
Test: bit CtsGraphicsTestCases:*
Test: bit CtsWidgetTestCases:*
Test: FrameworksCoreTests:android.text.MeasuredTextTest
Change-Id: I0b46f04b42cc012606a9c722eca0d51147a0dcc7
This is partial revert of Ie932903845645e50cfa0cb428babb31a44babc47
The root cause is MeasuredText.getParagraphDir respect requsted text
direction even if it is an empty text. Ideally we don't need to create
MeasuredText object for empty string but for safety, reverted to the
original code.
Bug: 70384435
Test: bit FrameworksCoreTests:android.widget.EditorCursorTest
Change-Id: Id24405f476c50fa27743589a640281d96de1c9ce
To measure text beforehand, remove static layout dependency from
MeasuredText. Now MeasuredText can compute native measured text
by itself and StaticLayout use it for line breaking.
This CL introduce one additional JNI method call per paragraph during
line breaking but looks negligible cost.
Here is a raw performance test result on walleye-userdebug.
StaticLayoutPerfTest (median, N=100):
createRandom: 7,879,440 -> 7,964,789 (+1.08%)
createRandom Balanced: 7,835,192 -> 7,848,151 (+0.17%)
TextViewOnMeasurePerfTest (median, N=100):
measure_AtMost: 92,599,175 -> 93,027,121 (+0.47%)
measure_Exactly: 89,949,922 -> 90,439,886 (+0.54%)
measure_Unspecified: 148,645,916 -> 150,047,694 (+0.94%)
Bug: 67504091
Test: bit CtsTextTestCases:*
Test: bit CtsWidgetTestCases:*
Test: bit CtsGraphicsTestCases:*
Test: bit FrameworksCoreTests:android.text.StaticLayoutTest
Change-Id: Ie932903845645e50cfa0cb428babb31a44babc47