History log of /frameworks/base/core/java/android/text/DynamicLayout.java
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
a553477ddf55d170a66410ed325ae5e5d3005965 15-Mar-2018 Seigo Nonaka <nona@google.com> Make PrecomputedText Spannable for supporting selection

This is 2nd attempt of I072dfd70b9a687d9c47e310d8cdb34f988fbb32e

The root cause of crashing is unexpected copying of NoCopySpan by
SpannableString constructor. To prevent crashing, stop copying
NoCopySpan by passing ignoreNoCopySpan=true to SpannableString
copy constructor.

The original commit message is following:

To support selectable TextView, make PrecomputedText spannable.
By this change, TextView start using DynamicLayout instead of
StaticLayout. DynamicLayout requires boundary rectangle of the
text, so this CL also adds getBounds method to PrecomputedText
which retrieves measured boundary box from native.

By this change, the selectable TextView performance for the
precomputed text 10x faster. On the other hand, the performacne
for the non-selectable text gets 2.5x slower. However, we concluded
that we accept this performance regression since it still 10 times
faster than non precomputed text.

Here is a precomputed text performance result of TextView.
android.widget.TextViewPrecomputedTextPerfTest:
newLayout_PrecomputedText : 736,130 -> 1,648,694: (+124.0%)
newLayout_PrecomputedText_Selectable: 17,379,765 -> 1,700,146: (-90.2%)
onDraw_PrecomputedText : 1,274,921 -> 1,848,076: (+45.0%)
onDraw_PrecomputedText_Selectable : 17,367,238 -> 1,399,169: (-91.9%)
onMeasure_PrecomputedText : 752,875 -> 1,766,606: (+134.6%)
onMeasure_PrecomputedText_Selectable: 17,647,842 -> 1,810,704: (-89.7%)
setText_PrecomputedText : 92,894 -> 135,471: (+45.8%)
setText_PrecomputedText_Selectable : 145,134 -> 215,757: (+48.7%)

Bug: 72998298
Test: atest CtsWidgetTestCases:EditTextTest
CtsWidgetTestCases:TextViewFadingEdgeTest
FrameworksCoreTests:TextViewFallbackLineSpacingTest
FrameworksCoreTests:TextViewTest FrameworksCoreTests:TypefaceTest
CtsGraphicsTestCases:TypefaceTest CtsWidgetTestCases:TextViewTest
CtsTextTestCases FrameworksCoreTests:android.text
CtsWidgetTestCases:TextViewPrecomputedTextTest

Change-Id: Ie98c75d8b4ba962eaf0a544357b2ff1ade891118
/frameworks/base/core/java/android/text/DynamicLayout.java
e887f4d2c18040276ee230fdd3dadaa6610a188e 19-Mar-2018 Seigo Nonaka <nona@google.com> Revert "Make PrecomputedText Spannable for supporting selection"

Crash on Sheets APp
This reverts commit 80ed5a35a90b62b8070d861b9755e230bd679951.

Bug: 75652829
Change-Id: I40ddd1b9754e74fbd90d7a029cce9c6a7ede0777
Test: Manual
/frameworks/base/core/java/android/text/DynamicLayout.java
80ed5a35a90b62b8070d861b9755e230bd679951 15-Mar-2018 Seigo Nonaka <nona@google.com> Make PrecomputedText Spannable for supporting selection

To support selectable TextView, make PrecomputedText spannable.
By this change, TextView start using DynamicLayout instead of
StaticLayout. DynamicLayout requires boundary rectangle of the
text, so this CL also adds getBounds method to PrecomputedText
which retrieves measured boundary box from native.

By this change, the selectable TextView performance for the
precomputed text 10x faster. On the other hand, the performacne
for the non-selectable text gets 2.5x slower. However, we concluded
that we accept this performance regression since it still 10 times
faster than non precomputed text.

Here is a precomputed text performance result of TextView.
android.widget.TextViewPrecomputedTextPerfTest:
newLayout_PrecomputedText : 736,130 -> 1,648,694: (+124.0%)
newLayout_PrecomputedText_Selectable : 17,379,765 -> 1,700,146: (-90.2%)
onDraw_PrecomputedText : 1,274,921 -> 1,848,076: (+45.0%)
onDraw_PrecomputedText_Selectable : 17,367,238 -> 1,399,169: (-91.9%)
onMeasure_PrecomputedText : 752,875 -> 1,766,606: (+134.6%)
onMeasure_PrecomputedText_Selectable : 17,647,842 -> 1,810,704: (-89.7%)
setText_PrecomputedText : 92,894 -> 135,471: (+45.8%)
setText_PrecomputedText_Selectable : 145,134 -> 215,757: (+48.7%)

Verified no effects for other performance metrics:
android.widget.TextViewPrecomputedTextPerfTest:
newLayout_RandomText : 16,495,200 -> 16,450,483: (-0.3%)
newLayout_RandomText_Selectable : 17,482,439 -> 17,534,207: (+0.3%)
onDraw_RandomText : 17,224,949 -> 17,228,072: (+0.0%)
onDraw_RandomText_Selectable : 18,067,397 -> 17,958,235: (-0.6%)
onMeasure_RandomText : 16,435,649 -> 16,516,352: (+0.5%)
onMeasure_RandomText_Selectable : 17,724,819 -> 17,879,508: (+0.9%)
setText_RandomText : 11,130 -> 11,259: (+1.2%)
setText_RandomText_Selectable : 48,900 -> 48,607: (-0.6%)

android.text.PrecomputedTextPerfTest:
create_NoStyled_Hyphenation : 17,695,377 -> 17,660,233: (-0.2%)
create_NoStyled_Hyphenation_WidthOnly : 17,677,423 -> 17,541,823: (-0.8%)
create_NoStyled_NoHyphenation : 7,021,486 -> 7,030,069: (+0.1%)
create_NoStyled_NoHyphenation_WidthOnly : 7,045,453 -> 7,067,021: (+0.3%)
create_Styled_Hyphenation : 12,090,933 -> 12,267,730: (+1.5%)
create_Styled_Hyphenation_WidthOnly : 12,105,491 -> 12,277,272: (+1.4%)
create_Styled_NoHyphenation : 11,835,249 -> 11,960,278: (+1.1%)
create_Styled_NoHyphenation_WidthOnly : 11,871,765 -> 11,912,444: (+0.3%)

android.text.StaticLayoutPerfTest:
create_PrecomputedText_NoStyled_Balanced_Hyphenation : 709,839 -> 697,134: (-1.8%)
create_PrecomputedText_NoStyled_Balanced_NoHyphenation: 527,671 -> 528,928: (+0.2%)
create_PrecomputedText_NoStyled_Greedy_Hyphenation : 477,259 -> 481,966: (+1.0%)
create_PrecomputedText_NoStyled_Greedy_NoHyphenation : 479,772 -> 482,278: (+0.5%)
create_PrecomputedText_Styled_Greedy_NoHyphenation : 639,322 -> 637,790: (-0.2%)
create_RandomText_NoStyled_Balanced_Hyphenation : 17,123,681 -> 16,989,227: (-0.8%)
create_RandomText_NoStyled_Balanced_NoHyphenation : 7,040,572 -> 7,064,175: (+0.3%)
create_RandomText_NoStyled_Greedy_Hyphenation : 7,000,681 -> 7,002,322: (+0.0%)
create_RandomText_NoStyled_Greedy_NoHyphenation : 6,997,115 -> 6,996,953: (-0.0%)
create_RandomText_Styled_Greedy_NoHyphenation : 11,948,744 -> 12,052,791: (+0.9%)
draw_PrecomputedText_NoStyled : 543,623 -> 513,741: (-5.5%)
draw_PrecomputedText_NoStyled_WithoutCache : 564,742 -> 541,795: (-4.1%)
draw_PrecomputedText_Styled : 838,581 -> 837,438: (-0.1%)
draw_PrecomputedText_Styled_WithoutCache : 826,775 -> 850,586: (+2.9%)
draw_RandomText_NoStyled : 538,162 -> 533,603: (-0.8%)
draw_RandomText_NoStyled_WithoutCache : 6,401,486 -> 6,424,604: (+0.4%)
draw_RandomText_Styled : 1,024,683 -> 1,011,575: (-1.3%)
draw_RandomText_Styled_WithoutCache : 2,733,204 -> 2,722,828: (-0.4%)

Bug: 72998298
Test: atest CtsWidgetTestCases:EditTextTest
CtsWidgetTestCases:TextViewFadingEdgeTest
FrameworksCoreTests:TextViewFallbackLineSpacingTest
FrameworksCoreTests:TextViewTest FrameworksCoreTests:TypefaceTest
CtsGraphicsTestCases:TypefaceTest CtsWidgetTestCases:TextViewTest
CtsTextTestCases FrameworksCoreTests:android.text
CtsWidgetTestCases:TextViewPrecomputedTextTest

Change-Id: I072dfd70b9a687d9c47e310d8cdb34f988fbb32e
/frameworks/base/core/java/android/text/DynamicLayout.java
4e90fa262d57c1c1ee72166e2ddfce391696ca24 13-Feb-2018 Seigo Nonaka <nona@google.com> Revert "Reorganize MeasuredText API"

The last change needs more discussion and found some edge cases. Revert and make small step-by-step changes.

Bug: 73091756

This reverts commit 7fd36d19e309ea515b4048cfaabb8035ceab7baf.

Change-Id: I89ff52a70cf6a5d6c553afa20f83719e1f9eb726
/frameworks/base/core/java/android/text/DynamicLayout.java
7fd36d19e309ea515b4048cfaabb8035ceab7baf 02-Feb-2018 Seigo Nonaka <nona@google.com> Reorganize MeasuredText API

This CL changes the MeasuredText API:
- Rename MeasuredText to PrecomputedText.
- PrecomputedText is no longer a Spanned.
- 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)

Here is a performance scores: (median, walleye-userdebug, N=20)

StaticLayout creation time (w/o patch -> w/ patch)
PrecomputedText Balanced Hyphenation : 743,615 -> 737,145: (-0.9%)
PrecomputedText Balanced NoHyphenation: 551,544 -> 542,715: (-1.6%)
PrecomputedText Greedy Hyphenation : 500,343 -> 499,601: (-0.1%)
PrecomputedText Greedy NoHyphenation : 497,987 -> 492,587: (-1.1%)
RandomText Balanced Hyphenation : 19,100,592 -> 19,135,289: (+0.2%)
RandomText Balanced NoHyphenation : 8,015,088 -> 7,954,260: (-0.8%)
RandomText Greedy Hyphenation : 7,950,915 -> 7,877,424: (-0.9%)
RandomText Greedy NoHyphenation : 7,939,337 -> 7,863,471: (-1.0%)

PrecomputedText creation time (w/o patch -> w/ patch)
NoStyled Hyphenation : 18,935,638 -> 18,925,422: (-0.1%)
NoStyled Hyphenation WidthOnly : 18,469,726 -> 18,978,413: (+2.8%)
NoStyled NoHyphenation : 7,940,792 -> 7,919,127: (-0.3%)
NoStyled NoHyphenation WidthOnly : 7,463,230 -> 7,922,643: (+6.2%)
Styled Hyphenation : 14,822,501 -> 14,809,017: (-0.1%)
Styled Hyphenation WidthOnly : 13,891,770 -> 14,656,617: (+5.5%)
Styled NoHyphenation : 14,511,134 -> 14,301,503: (-1.4%)
Styled NoHyphenation WidthOnly : 13,495,345 -> 14,264,314: (+5.7%)

StaticLayout draw time (w/o patch -> w/ patch)
PrecomputedText NoStyled : 663,974 -> 661,610: (-0.4%)
PrecomputedText NoStyled WithoutCache : 648,294 -> 648,766: (+0.1%)
PrecomputedText Styled : 879,322 -> 852,770: (-3.0%)
PrecomputedText Styled WithoutCache : 1,084,570 -> 1,110,147: (+2.4%)
RandomText NoStyled : 565,682 -> 555,435: (-1.8%)
RandomText NoStyled WithoutCache : 9,070,533 -> 9,064,825: (-0.1%)
RandomText Styled : 2,955,202 -> 2,962,008: (+0.2%)
RandomText Styled WithoutCache : 12,242,325 -> 12,228,573: (-0.1%)

Bug: 67504091
Bug: 73091756
Test: bit FrameworksCoreTests:android.text.
Test: atest CtsWidgetTestCases:EditTextTest \
CtsWidgetTestCases:TextViewFadingEdgeTest \
FrameworksCoreTests:TextViewFallbackLineSpacingTest \
FrameworksCoreTests:TextViewTest FrameworksCoreTests:TypefaceTest \
CtsGraphicsTestCases:TypefaceTest CtsWidgetTestCases:TextViewTest \
CtsTextTestCases
Change-Id: I7db9e2ca4db68a16648cfb8fcf63555f501304c2
/frameworks/base/core/java/android/text/DynamicLayout.java
1fb80bbc94c3122cb8ee63d955ceec8afba72a38 08-Jan-2018 Siyamed Sinir <siyamed@google.com> Prevent crash for Span change events

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
/frameworks/base/core/java/android/text/DynamicLayout.java
df392c9a1d2ef38f7840b0e68ad403801f66eacd 20-Dec-2017 TreeHugger Robot <treehugger-gerrit@google.com> Merge "Deprecate StaticLayout and DynamicLayout constructors"
81a4f2e89d76898fa810198257681c29e60e7d26 19-Dec-2017 Clara Bayarri <clarabayarri@google.com> Deprecate StaticLayout and DynamicLayout constructors

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
/frameworks/base/core/java/android/text/DynamicLayout.java
50b585e20ce33aa795983ecc663cc444164479ce 19-Dec-2017 Siyamed Sinir <siyamed@google.com> Fix DynamicLayout block index calculation after edit

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
/frameworks/base/core/java/android/text/DynamicLayout.java
a273a70ecbb0d1aaf9aeceec7aa91591290a4871 05-Oct-2017 Siyamed Sinir <siyamed@google.com> Removed unused variables from text layout code

Test: None
Change-Id: I890c3d260edd0570259db5089dcb37f79c2e56e9
/frameworks/base/core/java/android/text/DynamicLayout.java
9fc6725428dc85a536b194d04fbb902a0a2b4343 21-Sep-2017 Roozbeh Pournader <roozbeh@google.com> Pass text direction from DynamicLayout to Layout

Previously, we were calling the wrong constructor for Layout, which
didn't have a text direction.

Bug: 65330510
Test: bit FrameworksCoreTests:android.widget.EditorCursorTest
Test: bit FrameworksCoreTests:android.text.DynamicLayoutTest
Test: bit CtsTextTestCases:android.text.cts.DynamicLayoutTest
Change-Id: Idf0ac781dc8d6641184b7deabe990cd0e451ad26
/frameworks/base/core/java/android/text/DynamicLayout.java
15b213d556e17fda8438889dad78f20b6d74c2b3 22-Aug-2017 Roozbeh Pournader <roozbeh@google.com> Support fallback linespacing in DynamicLayout

Bug: 28963299
Test: bit FrameworksCoreTests:android.text.
Change-Id: I132499d5927b26fb45522ffee99bac12aca3721f
/frameworks/base/core/java/android/text/DynamicLayout.java
22a167cac8f585ffd3ca73e40b82a26c1e09df11 21-Aug-2017 Roozbeh Pournader <roozbeh@google.com> Add a builder for DynamicLayout and switch TextView to it

The builder mostly copies the structure and the logic of
StaticLayout.

We also improve various parts of code and documentation in
StaticLayout's builder.

Bug: 28963299
Test: bit FrameworksCoreTests:android.text.
Test: bit FrameworksCoreTests:android.widget.TextViewTest
Test: bit CtsTextTestCases:*
Test: bit CtsWidgetTestCases:android.widget.cts.TextViewTest
Test: bit CtsWidgetTestCases:android.widget.cts.EditTextTest
Change-Id: I5c4a6e031bd0f41f765a3d85e0b9b7e9be42ad4b
/frameworks/base/core/java/android/text/DynamicLayout.java
fb0b2dc754fe54269dc8aac86b6e8c1458f96013 27-Jul-2017 Siyamed Sinir <siyamed@google.com> Fix DynamicLayout last line spacing

StaticLayout did not work as expected when there is a line ending with
'\n'. For those cases it would calculate 2 lines, but would
discard line spacing for both of them. This CL fixed that issue. Also
DynamicLayout asks StaticLayout not to add line spacing for the last
line of the text.

Test: Manual/Visual test
Test: bit -t FrameworksCoreTests:android.text.StaticLayoutTest
Test: bit -t FrameworksCoreTests:android.text.StaticLayoutTextMeasuringTest
Test: bit -t FrameworksCoreTests:android.text.StaticLayoutLineBreakingTest
Test: bit -t FrameworksCoreTests:android.text.DynamicLayoutTest
Test: bit -t FrameworksCoreTests:android.text.DynamicLayoutBlocksTest
Test: bit -t FrameworksCoreTests:android.widget.TextViewTest
Test: bit -t FrameworksCoreTests:android.widget.EditorCursorTest
Test: bit -t CtsTextTestCases:android.text.cts.StaticLayoutTest
Test: bit -t CtsTextTestCases:android.text.cts.DynamicLayoutTest
Test: bit -t CtsWidgetTestCases:android.widget.cts.TextViewTest
Test: bit -t CtsWidgetTestCases:android.widget.cts.EditTextTest

Bug: 25194907
Change-Id: I0d901ecf768b25faea156b73097541da4b93d6d0
/frameworks/base/core/java/android/text/DynamicLayout.java
442c151b8d0800a3f30cdfc0bbfd40af524dcf7a 24-Jul-2017 Siyamed Sinir <siyamed@google.com> Fix EditText line spacing

DynamicLayout did not include the line spacing for the newly added
lines. This CL updates StaticLayout with a parameter to force addition
of line spacing to the last line, and updates DynamicLayout to use this
parameter. With this change the last line will have the line spacing
applied, and it will provide a consistent UX.

Test: Manual/Visual test
Test: bit -t FrameworksCoreTests:android.text.StaticLayoutTest
Test: bit -t FrameworksCoreTests:android.text.StaticLayoutTextMeasuringTest
Test: bit -t FrameworksCoreTests:android.text.StaticLayoutLineBreakingTest
Test: bit -t FrameworksCoreTests:android.text.DynamicLayoutTest
Test: bit -t FrameworksCoreTests:android.text.DynamicLayoutBlocksTest
Test: bit -t CtsTextTestCases:android.text.cts.StaticLayoutTest
Test: bit -t CtsTextTestCases:android.text.cts.DynamicLayoutTest

Bug: 25194907
Change-Id: I52497fbd108538729758e842072f3ce87c6bbfdd
/frameworks/base/core/java/android/text/DynamicLayout.java
0fa89d6f62c31a033a9dece9c7cfee2d50dc063d 25-Jul-2017 Siyamed Sinir <siyamed@google.com> Store line extra in layouts

StaticLayout and Dynamic layout changes the values of line bottom and
descent according to linespacing modification attributes. This loses
information of the real line descent and bottom, which causes some
utilities not to be able to draw themselves in correct positions.
Examples are cursor drawing to the empty space, BulletSpan not being
able to vertically center itself in the line, and DynamicLayout not
being able to calculate the last line height properly.

This CL stores the extra added to bottom and descent values so that it
can be used later.

Test: bit CtsTextTestCases:android.text.cts.LayoutTest
Test: bit CtsTextTestCases:android.text.cts.StaticLayoutTest
Test: bit CtsTextTestCases:android.text.cts.DynamicLayoutTest
Test: bit FrameworksCoreTests:android.text.LayoutTest
Test: bit FrameworksCoreTests:android.text.StaticLayoutTest
Test: bit FrameworksCoreTests:android.text.DynamicLayoutTest
Test: bit FrameworksCoreTests:android.text.DynamicLayoutBlocksTest

Bug: 30870806
Bug: 33138492
Bug: 25194907
Change-Id: I7a1039e71e4999c75b5f26122fe6239e3ee24868
/frameworks/base/core/java/android/text/DynamicLayout.java
fc77869ee06c05eb5b7deea74e5ad31bd89a85bd 17-May-2017 Roozbeh Pournader <roozbeh@google.com> Set up empty lines for DynamicLayout#updateBlocks() tests

The changes in I666da5eeb39f780c341597f347bfcba21eb34295 introduced
the concept of lines that need to be always redrawn, but it broke
tests for DynamicLayout#updateBlocks() that didn't need to set up the
actual lines.

Now, during the test setup, we insert empty lines to match the number
of lines needed.

Test: adb shell am instrument -w -e class android.text.DynamicLayoutBlocksTest com.android.frameworks.coretests/android.support.test.runner.AndroidJUnitRunner
Test: adb shell am instrument -w -e class android.text.DynamicLayoutTest#testGetBlocksAlwaysNeedToBeRedrawn_thai com.android.frameworks.coretests/android.support.test.runner.AndroidJUnitRunner
Test: adb shell am instrument -w -e class android.text.DynamicLayoutTest#testGetBlocksAlwaysNeedToBeRedrawn_en com.android.frameworks.coretests/android.support.test.runner.AndroidJUnitRunner
Test: cts-tradefed run cts-dev --module CtsTextTestCases
Change-Id: I4bfc82db4beef1b740433a25a3ae29201f54d9d3
Fixes: 38029583
/frameworks/base/core/java/android/text/DynamicLayout.java
4b4730d90eef9dd4140cf750e2feba61acae9044 31-Mar-2017 Seigo Nonaka <nona@google.com> Change justification parameter from boolean to int.

Bug: 35766005
Bug: 35764323
Test: Manually done
Change-Id: Ic6d78bb9a3213160cd013f1ca8294307872bf0d0
/frameworks/base/core/java/android/text/DynamicLayout.java
09da71a6dcfe07e0efdc35933322fba16091f555 28-Nov-2016 Seigo Nonaka <nona@google.com> Introduce full justification.

Adds a new get/setJustify API to TextView and StaticLayout.Builder for
justification, and fully justifies text when it's enabled.

This is based on a patch by Raph Levien (raph@google.com).

Bug: 31707212
Test: Manually done and CTS will introduced with
I0f3bbf39d60a66b71b30e1351f7c741208f05dce passes.
Change-Id: Icbfab2faa11a6a0b52e6f0a77a9c9b5ef6e191da
/frameworks/base/core/java/android/text/DynamicLayout.java
f5af4a344e086efa87740a0154cace064465fe54 31-Aug-2016 Keisuke Kuroyanagi <ksk@google.com> Always redraw text that protrude from line bounds.

With I63af3a6ecbf92, we create RenderNode lazily, but
blocks containing contents that protrude from line top or
bottom cannot be simply lazily redrawn after edit or
scroll.
With this CL, we check if the contents protrude from line
top or bottom by comparing the text bounds with relevant
font metrics values and we always redrawn such blocks after
edit or scroll.

Bug: 27889485
Change-Id: I666da5eeb39f780c341597f347bfcba21eb34295
/frameworks/base/core/java/android/text/DynamicLayout.java
ed09ae1fccfb1c02109a0c1428ddff52daa939d5 16-Feb-2016 Siyamed Sinir <siyamed@google.com> Visibility fixes for text related tests.

Some of the text and text layout related tests fail because of the
visibility of parameters/functions they use. This CL updates
annotations and visibility of related classes.

Bug: 29871441
Change-Id: Ia06072815261379ff839c440482d94570ec05a80
/frameworks/base/core/java/android/text/DynamicLayout.java
a6a082862b9e2ea4c9e9a1a945927c4040993f6e 03-Jun-2015 Raph Levien <raph@google.com> Rename setTextDir to setTextDirection

StaticLayout.Builder used "setTextDir" as a shorthand, but it's not
as clear as spelling it out. So, setTextDirection.

Bug: 21572282
Change-Id: Ia94476562d70678f963196b87bb63511d30836b6
/frameworks/base/core/java/android/text/DynamicLayout.java
95c7a13f2ac4f31ed3aaec9b47b9a29a3dbca978 12-May-2015 Roozbeh Pournader <roozbeh@google.com> Add hyphenationFrequency attribute to TextView and StaticLayout.

This patch adds plumbing to TextView and StaticLayout to control the
frequency of automatic hyphenation used in laying out paragraphs.

Bug: 21038249
Change-Id: Ib45de190eb0a1ed738e69fd61f2b39561b11aec7
/frameworks/base/core/java/android/text/DynamicLayout.java
531c30c62b14881aab31a5133920a971b1fbb50e 01-May-2015 Raph Levien <raph@google.com> Expose StaticLayout.Builder publicly

Expose the new Builder pattern for creating StaticLayout. This allows
access to a number of features that have been available to TextView
through a hidden constructor. Some of these features have existed
for a while (mostly maxLines), while others are new (breakStrategy,
indents).

The builder is cleaner and has a better upgrade path than the old
pattern of lots of constructors with varying numbers of arguments.

Bug: 20190561
Change-Id: Ia3cd124825ab0cb469d22d1fc576ad26454545b8
/frameworks/base/core/java/android/text/DynamicLayout.java
ebd66ca600dc2c43edb0830bcf1a92fafec30a5a 01-May-2015 Raph Levien <raph@google.com> Make Paint a required field of StaticLayout Builder

This patch moves the Paint parameter from being an option set from
setPaint to being a required field passed into the obtain() method
of StaticLayout.Builder. Thus, it is now possible to get a valid
StaticLayout object just doing .build() on the Builder; all other
fields are optional.

This is in preparation for exposing the builder publicly, but that
is to be a separate CL.

Bug: 20190561

Change-Id: Iefd7800203004e565d068b0c76502cf7cf52d91f
/frameworks/base/core/java/android/text/DynamicLayout.java
39b4db73c3340ff955f67e4e5318159d19d1ab3a 25-Mar-2015 Raph Levien <raph@google.com> Add breakStrategy attribute to TextView

This patch adds plumbing to TextView to control the strategy used
for breaking paragraphs into lines.

The default for TextView is "quality", while the default for EditText
is "simple", largely to avoid too much re-layout when editing.

StaticLayout now has a builder which provides access to more
functionality and is also cleaner than the old mechanism of having
lots of constructors with varying numbers of arguments. This patch
changes TextView to use that builder, and also contains cleanups
of the Builder within StaticLayout.

Change-Id: Iee3cf3a05a3e51ba0834554e4a3ec606e9cabca5
/frameworks/base/core/java/android/text/DynamicLayout.java
26d443aee4ee5a8791417b4ca09e8c78ba8dc78b 30-Mar-2015 Raph Levien <raph@google.com> Revert "Fix build: Revert "Record hyphens from Minikin and draw them""

This reverts commit 5a6eeb3cbe0896ddf4bdccc0b1a81d7aac49821e and
fixes the underlying issue (needed to @hide getHyphen() for subclasses
of Layout, not just the base class), and layoutlib changes for
checkbuild.

Change-Id: I7a2b5f20ae014ea8e224d8c4079cf9131e17e1c1
/frameworks/base/core/java/android/text/DynamicLayout.java
5a6eeb3cbe0896ddf4bdccc0b1a81d7aac49821e 30-Mar-2015 Ed Heyl <edheyl@google.com> Fix build: Revert "Record hyphens from Minikin and draw them"

This reverts commit 27fb878c04e18d3bdd6c42ed347194a7c816ed97.

Change-Id: I2b3390cb0b258a2e1a38ad72ae9686177d6ffdb8
/frameworks/base/core/java/android/text/DynamicLayout.java
71cbc72e70a6f0e086535c51e35262eb3a4d4bd9 20-Mar-2015 Raph Levien <raph@google.com> Record hyphens from Minikin and draw them

This patch plumbs up hyphens computed in Minikin's LineBreaker,
records them in a new column in StaticLayout, and draws them.
DynamicLayout mirrors the new column, and TextLine is also changed to
make sure the hyphen is only drawn for the last run in a line.

There is a rather primitive mechanism for loading hyphenation
patterns, for testing only at this point.

Change-Id: Ib208568c0f6cff12cf834047500ec1da9ea9f430
/frameworks/base/core/java/android/text/DynamicLayout.java
d3ab692d28018825578ff05832644cfad60233fb 02-Mar-2015 Raph Levien <raph@google.com> Some refactoring of StaticLayout

This patch refactors construction of StaticLayout to use an explicit
Builder object, which is intended to hold state used for constructing
the layout but not needed for merely reading out the results.

Builder objects are allocated from a pool and explicitly recycled,
so there is insignificant additional allocation cost.

This patch has very little impact on performance (it does avoid
allocating a FontMetricsInt object) but opens the way for significant
performance and functionality improvements as more of the Builder
functionality migrates to native code.

Change-Id: I2a576643e573a38b61f895a80d5d92a85c94b6b4
/frameworks/base/core/java/android/text/DynamicLayout.java
776abc24cdd18610232a50b997cce3cffa74609b 07-Mar-2014 Adam Lesinski <adamlesinski@google.com> Uses VMRuntime.newUnpaddedArray for ideal array sizes

Bug:13028925

Change-Id: I0a9301248b10a339afbdc5e4ffe3310ac4fa1fb7
/frameworks/base/core/java/android/text/DynamicLayout.java
63b3eb65234c8a8b9224c262442816cc429560ef 03-Oct-2013 Raph Levien <raph@google.com> Fix Text appears on top of existing text when composing in gmail.

Fix for bug 6473708. This patch changes from "last update wins" to
merging together the change regions, in the logic of deciding which
blocks need to be updated for painting, so that when there are multiple
changes batched for a draw, they're all taken into account.

Change-Id: I183d453c436125e5efec7031b4d61b43989653f9
/frameworks/base/core/java/android/text/DynamicLayout.java
955beb2b96a78cf6ee990d0f20bcaf2d22ce608b 10-Dec-2012 Sangkyu Lee <sk82.lee@lge.com> Optimize drawHardwareAccelerated method in Editor class

When inserting a new line or breaking a line,
every display list was invalidated and rebuilt before.
However, we can reuse the display lists above intactly and also
reuse the display lists below with only updating drawing locations.

This patch reuses the display lists if possible.
The display lists above the inserted line are just reused
and the display lists below are reused with only updating
drawing locations not fullly rebuilt.

mIndexOfFirstChangedBlock is the index of the first block
which is moved by inserting or breaking a line.
So the display list whose index is >= mIndexOfFirstChangedBlock
only needs to update its drawing location.

Change-Id: Ica20deb0ebb5750de21356ed31fa9f86e657ff92
Signed-off-by: Sangkyu Lee <sk82.lee@lge.com>
/frameworks/base/core/java/android/text/DynamicLayout.java
71afc39d68413d125d46ea69e6c9fb077016bb9b 10-May-2012 Gilles Debunne <debunne@google.com> Cut long text into multiple DL at start

Bug 5763685

To improve performance, preventively cut the the into display
list of 3-10 lines of text. Further updates to small parts of
the text (such as adding an underline on a word) will only
invalidate and redraw the affected sub display list.

DLs are aligned with paragraphs, just like they will be during
text edition.

Change-Id: I0d60debc7fdaea8b29080a6eacb2d60205e7d547
/frameworks/base/core/java/android/text/DynamicLayout.java
157aafcbee0eabda798a3be406ccc4200ee86756 20-Apr-2012 Gilles Debunne <debunne@google.com> TextView's sub display lists have tighten bounds

An editable TextView caches text rendering inside an adaptive
number of sub display lists. The bounds of these use to be those
of the entire View.

This CL creates block display lists with tighten bounds, so that
(a still-to-be-implemented) quick rejection can occur.

Also cleaned-up the contradictory translations that were used to
handle the TextView's internal scroll and removed the invalidation
of display lists in that case.

TODO: When internal scroll sets a tighter clipping rect, quick
reject the creation and display of the clipped display lists.

Also renamed blockEnds to a more explicit blockEndLines.

Change-Id: I7d79bea78d06d19b6935aef75ff7aa7df2594050
/frameworks/base/core/java/android/text/DynamicLayout.java
1e130b2abc051081982b5a793a18a28376c945e4 15-Mar-2012 Gilles Debunne <debunne@google.com> Added a unit test for DynamicLayout#updateBlocks

Change-Id: I1824ebeae2bbb5c60a65de36fe1696bf003347c9
/frameworks/base/core/java/android/text/DynamicLayout.java
cde6adf45c90ad3fdc94446ede6a228ce264c886 16-Mar-2012 Romain Guy <romainguy@google.com> Fix the build

Change-Id: I6de62c7bfaecd85810178f58707157466291eca3
/frameworks/base/core/java/android/text/DynamicLayout.java
33b7de85b6918b7714641f12f1ba2ff03a344740 12-Mar-2012 Gilles Debunne <debunne@google.com> Multiple display lists for editable text

Bug 5763685

Long text in a ScrollView (not when the View's internal
scroll is used) is cached as a unique display list when hardware
rendering is on.

As a result, each time the text is edited, the entire display
list has to be updated, which takes a significant amount of
time (up to 500ms for a few thousand lines), proportional to the
size of the text.

This CL splits the text into multiple display lists as the
text is edited. The boundaries of the display list are aligned
with paragraphs.

There is still an issue when the number of lines changes: onLayout()
is called which invalidates all the display list. When the source
of that change is line wrapping and not a change in the view's
dimensions, we should be able to simply shift down the previous DL
instead of re-creating everything.

Change-Id: I7de49a1e5637cdfc9ef06b64b1ec4b61d9ea2415
/frameworks/base/core/java/android/text/DynamicLayout.java
d300e75eff0d5e54390400cbd3f80dc4cea8b617 17-Oct-2011 Gilles Debunne <debunne@google.com> Wrong word cut at end of lines with spaces

Bug 5185017: when the line length is exceeded at a space character,
we use the previous ok width, and the last word is wrapped to next line
although it fits.

This back-track also generates problem with the span parsing, where the
spanStart indexes are no longer monotonuously increasing.

Plus some refactoring in this code (unused parameters, calls to out())

Change-Id: Ia8cd310a732752af3bd370bf0a16db23d40e83f2
/frameworks/base/core/java/android/text/DynamicLayout.java
ad0b051b133baf92f199c96a8ac1e81b3393190c 05-Oct-2011 Fabrice Di Meglio <fdimeglio@google.com> Revert "Fix bug #5387832 [UI/Visual] Address of the website is not displayed properly(second line of the address is partly shown)"

This reverts commit a130e5f59dc6b2117e4c1a8ffef54828e9ea44c7
/frameworks/base/core/java/android/text/DynamicLayout.java
a130e5f59dc6b2117e4c1a8ffef54828e9ea44c7 29-Sep-2011 Fabrice Di Meglio <fdimeglio@google.com> Fix bug #5387832 [UI/Visual] Address of the website is not displayed properly(second line of the address is partly shown)

- make DynamicLayout honor max lines
- make StaticLayout.generate() take maxLines as a parameter instead of using the field mMaximumVisibleLineCount

Change-Id: I9eafb1be4b8bb2aa881514955a6903f559cb6a1e
/frameworks/base/core/java/android/text/DynamicLayout.java
09175735c562652be1a1b0dc0f941d36ac4f076a 26-Sep-2011 Fabrice Di Meglio <fdimeglio@google.com> Fix bug #5344067 android.text.DynamicLayout.sStaticLayout can hold onto an Activity, potential memory leak

- make the StaticLayout constructor not depending on the text as we just need the "generate()" call to be done

Change-Id: I65249e65ed6446b6ac13dbf8c8f58fcdf54046cb
/frameworks/base/core/java/android/text/DynamicLayout.java
8059e0903e36cbb5cf8b5c5d5d653acc9bbc8402 11-Aug-2011 Fabrice Di Meglio <fdimeglio@google.com> Fix bug #3388534 Long file names are improperly displayed when played

- force ellipsising when there are more lines found than maxLines
- do not care about lines when we have reached maxLines
- also fix relayouting when changing maxLines thru setMaxLines()
- do not allow START / MIDDLE ellipsis when there are multiple lines
(and print a log accordingly)

Change-Id: I90f5a7f5200a220aceee01fb7300bec2c4c3a075
/frameworks/base/core/java/android/text/DynamicLayout.java
b724c346e19d63d7ff194b2b06c4a1e0f7bc07b7 13-Aug-2011 Amith Yamasani <yamasani@google.com> Revert "Use a weakreference to prevent the static variable from holding an Activity."
Bug was fixed in a different way.

This reverts commit 352c01e2133b71918fa1cb2783a0a10e56117775.
/frameworks/base/core/java/android/text/DynamicLayout.java
352c01e2133b71918fa1cb2783a0a10e56117775 26-Jul-2011 Amith Yamasani <yamasani@google.com> Use a weakreference to prevent the static variable from holding an Activity.

Bug: 5057764

Change-Id: If734e3ef4928b21a5e31e0ad50c97da287c3c116
/frameworks/base/core/java/android/text/DynamicLayout.java
e5ea4403ce58982522554b7ff23f41e6551923c1 01-Aug-2011 Romain Guy <romainguy@google.com> Plug memory leak in EditText.

Change-Id: I0b42c23ceeaa958d02255945c35ff6807c177114
/frameworks/base/core/java/android/text/DynamicLayout.java
cb379120456d8065d742021fc5c66748fc8a11a8 07-Jul-2011 Doug Felt <dougfelt@google.com> Implement textDirection heuristic selection.

Change-Id: I2fcf18de573f2d66494fa5ed61e4273c3c6078c7
/frameworks/base/core/java/android/text/DynamicLayout.java
0a4db3c5270440eeb7e4e44a7029926e239ec3bd 14-Jan-2011 Gilles Debunne <debunne@google.com> Pixel were missing on the last line of text when using MaxLines.

Bug 3295544

Only the last line of text includes the bottomPadding (extra line
spacing below the characters' descent. When The text is clipped using
maxLines, the desired height correctly added this value, but getLineTop
and getLineDescent are also used when the layout is drawn.

The fix is to make the layout aware of its clipping so that these
values are correctly updated.

Change-Id: I703656cf45022d34a90f55f0ed8fc5e4b30f80b1
/frameworks/base/core/java/android/text/DynamicLayout.java
d6e568c4f3b30431a0086e647f38d24ffd81457a 25-Jan-2011 Gilles Debunne <debunne@google.com> Removed warnings in DynamicLayout

Change-Id: Ied1c330795412d0bdcac1236b466951112fabc7d
/frameworks/base/core/java/android/text/DynamicLayout.java
9f7a4442b89cc06cb8cae6992484e7ae795323ab 01-Mar-2010 Doug Felt <dougfelt@google.com> Enable nested bidi levels in a paragraph.

Changes the internal representation of direction information in the Directions object to be a visually-ordered list of start/length+direction pairs instead of a list of directionality inversion offsets.

Rewrite Layout.getOffsetToLeft/RightOf to use run information instead of width metrics.

Remove java Bidi, use native. Switch bidi tests to test native, expect levels instead of dirs.

Add test of directionality. Leave in switch to turn new code off and restore previous behavior for now.

Change-Id: Iea8bb46c678a18820e237c90f76007a084c83051
/frameworks/base/core/java/android/text/DynamicLayout.java
9066cfe9886ac131c34d59ed0e2d287b0e3c0087 04-Mar-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //depot/cupcake/@135843
/frameworks/base/core/java/android/text/DynamicLayout.java
d83a98f4ce9cfa908f5c54bbd70f03eec07e7553 04-Mar-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //depot/cupcake/@135843
/frameworks/base/core/java/android/text/DynamicLayout.java
54b6cfa9a9e5b861a9930af873580d6dc20f773c 21-Oct-2008 The Android Open Source Project <initial-contribution@android.com> Initial Contribution
/frameworks/base/core/java/android/text/DynamicLayout.java