summaryrefslogtreecommitdiff
path: root/core/java/android/text/DynamicLayout.java
Commit message (Collapse)AuthorAgeFilesLines
* Fix DynamicLayout init to use transformed text length.Ahaan Ugale2021-02-051-3/+3
| | | | | | | | | | | | | | | | | It already uses the transformed text characters, but uses the length of the base text. This does not account for TransformationMethod2, which can change length, including AllCapsTransformationMethod ("ß" becomes "SS") and TranslationTransformationMethod (arbitrary length changes). This change does not fix updates that happens through DynamicLayout.ChangeWatcher; those will be fixed in separate change(s). Bug: 178650596 Test: atest DynamicLayoutBlocksTest DynamicLayoutTest TextLayoutTest \ TextViewTest Test: manually on a sample app with AllCaps Test: manually with Translate on a real app Change-Id: Iec4699c8d9967cb4622fe59ba91849642d72b52e
* Add maxTargetSdk restriction to unused APIs.Mathew Inwood2020-10-291-2/+2
| | | | | | | | | | | | | | | | | | | These are APIs that have @UnsupportedAppUsage but for which we don't have any evidence of them currently being used, so should be safe to remove from the unsupported list. This is a resubmit of ag/12929664 with some APIs excluded that caused test failures; see bugs 171886397, 171888296, 171864568. APIs excluded: Landroid/bluetooth/le/ScanRecord;->parseFromBytes([B)Landroid/bluetooth/le/ScanRecord; Landroid/os/Process;->myPpid()I Landroid/os/SharedMemory;->getFd()I Landroid/hardware/input/InputManager;->INJECT_INPUT_EVENT_MODE_WAIT_FOR_FINISH:I Bug: 170729553 Test: Treehugger Change-Id: I8285daa8530260251ecad6f3f38f98e263629ca7
* Revert "Add maxTargetSdk restriction to unused APIs."Hongwei Wang2020-10-281-2/+2
| | | | | | | | | This reverts commit 72f07d6a8a32db4a0dedd7682a0b3385be2b9cd6. Reason for revert: Droidcop-triggered revert due to breakage https://android-build.googleplex.com/builds/quarterdeck?testMethod=testAppZygotePreload&testClass=android.app.cts.ServiceTest&atpConfigName=suite%2Ftest-mapping-presubmit-retry_cloud-tf&testModule=CtsAppTestCases&fkbb=6936597&lkbb=6936969&lkgb=6936551&testResults=true&branch=git_master&target=cf_x86_phone-userdebug>, bug b/171886397 Bug: 171886397 Change-Id: Ibe0f0430a3451477c1ee8ef56a596e91ea1e7672
* Add maxTargetSdk restriction to unused APIs.Mathew Inwood2020-10-271-2/+2
| | | | | | | | | | These are APIs that have @UnsupportedAppUsage but for which we don't have any evidence of them currently being used, so should be safe to remove from the unsupported list. Bug: 170729553 Test: Treehugger Change-Id: I4c8fd0006f950de9955242e93968fb0996ceb372
* Use new UnsupportedAppUsage annotation.Artur Satayev2020-01-071-1/+1
| | | | | | | | Existing annotations in libcore/ and frameworks/ will deleted after the migration. This also means that any java library that compiles @UnsupportedAppUsage requires a direct dependency on "unsupportedappusage" java_library. Bug: 145132366 Test: m && diff unsupportedappusage_index.csv Change-Id: I288969b0c22fa3a63bc2e71bb5009fe4a927e154
* Hide packing structure from public APISeigo Nonaka2019-03-111-3/+12
| | | | | | | | | | | | | | | | | | | The hyphen edit is packed into 8bit integer in native library, but this should not be exposed to public API as API council suggested. This CL includes: - Removing packing structure from HyphenEdit and move constants from Hyphenator to Paint. - Replace LineBreaker's getLineHyphenEdit with two separate start/end function. - Replace Paint's getHyphenEdit with two separate start/end function. - StaticLayout still relies on this packing mechanism but no longer need to be the same packing structure as in Minikin. Bug: 124794844 Test: atest CtsGraphicsTestCases Test: atest CtsTextTestCases Change-Id: I8206061f554cf6e119b2b565162f54317eac630a
* Move some members to the "Q blacklist".Mathew Inwood2018-09-141-1/+2
| | | | | | | | | | | | | | Based on some analysis, these fields/methods are likely false positives. Set maxTargetSdk=P so that any apps using them are required to migrate off them in future. See the bug for more details. Exempted-From-Owner-Approval: Automatic changes to the codebase affecting only @UnsupportedAppUsage annotations, themselves added without requiring owners approval earlier. Bug: 115609023 Test: m Change-Id: I719b5c94e5b1f4fa562dd5d655953422958ad37e
* Add @UnsupportedAppUsage annotationsMathew Inwood2018-08-151-0/+8
| | | | | | | | | | | | | | | | | | | | For packages: android.text.util android.text.style android.text.method android.text.format android.text This is an automatically generated CL. See go/UnsupportedAppUsage for more details. Exempted-From-Owner-Approval: Mechanical changes to the codebase which have been approved by Android API council and announced on android-eng@ Bug: 110868826 Test: m Change-Id: I9afbd4ca8826c37cb70db43252e39b9a674e5ae0
* Make PrecomputedText Spannable for supporting selectionSeigo Nonaka2018-03-201-1/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Revert "Make PrecomputedText Spannable for supporting selection"Seigo Nonaka2018-03-191-6/+1
| | | | | | | | | Crash on Sheets APp This reverts commit 80ed5a35a90b62b8070d861b9755e230bd679951. Bug: 75652829 Change-Id: I40ddd1b9754e74fbd90d7a029cce9c6a7ede0777 Test: Manual
* Make PrecomputedText Spannable for supporting selectionSeigo Nonaka2018-03-151-1/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Revert "Reorganize MeasuredText API"Seigo Nonaka2018-02-141-1/+1
| | | | | | | | | | 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
* Reorganize MeasuredText APISeigo Nonaka2018-02-121-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Prevent crash for Span change eventsSiyamed Sinir2018-01-081-0/+5
| | | | | | | | | | | | | | 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
* Merge "Deprecate StaticLayout and DynamicLayout constructors"TreeHugger Robot2017-12-201-8/+9
|\
| * Deprecate StaticLayout and DynamicLayout constructorsClara Bayarri2017-12-191-8/+9
| | | | | | | | | | | | | | | | | | | | 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
* | Fix DynamicLayout block index calculation after editSiyamed Sinir2017-12-181-9/+17
|/ | | | | | | | | | | | | | | | 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
* Removed unused variables from text layout codeSiyamed Sinir2017-10-101-3/+3
| | | | Test: None Change-Id: I890c3d260edd0570259db5089dcb37f79c2e56e9
* Pass text direction from DynamicLayout to LayoutRoozbeh Pournader2017-09-201-1/+1
| | | | | | | | | | | 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
* Support fallback linespacing in DynamicLayoutRoozbeh Pournader2017-08-231-3/+28
| | | | | | Bug: 28963299 Test: bit FrameworksCoreTests:android.text. Change-Id: I132499d5927b26fb45522ffee99bac12aca3721f
* Add a builder for DynamicLayout and switch TextView to itRoozbeh Pournader2017-08-231-82/+356
| | | | | | | | | | | | | | | | 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
* Fix DynamicLayout last line spacingSiyamed Sinir2017-07-271-1/+2
| | | | | | | | | | | | | | | | | | | | | | | 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
* Fix EditText line spacingSiyamed Sinir2017-07-261-2/+3
| | | | | | | | | | | | | | | | | | | 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
* Store line extra in layoutsSiyamed Sinir2017-07-251-5/+15
| | | | | | | | | | | | | | | | | | | | | | | | | 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
* Set up empty lines for DynamicLayout#updateBlocks() testsRoozbeh Pournader2017-05-231-4/+6
| | | | | | | | | | | | | | | | | 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
* Change justification parameter from boolean to int.Seigo Nonaka2017-04-031-5/+5
| | | | | | | Bug: 35766005 Bug: 35764323 Test: Manually done Change-Id: Ic6d78bb9a3213160cd013f1ca8294307872bf0d0
* Introduce full justification.Seigo Nonaka2017-01-051-3/+7
| | | | | | | | | | | | 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
* Always redraw text that protrude from line bounds.Keisuke Kuroyanagi2016-09-051-8/+99
| | | | | | | | | | | | | | 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
* Visibility fixes for text related tests.Siyamed Sinir2016-06-291-2/+5
| | | | | | | | | 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
* Rename setTextDir to setTextDirectionRaph Levien2015-06-031-1/+1
| | | | | | | | StaticLayout.Builder used "setTextDir" as a shorthand, but it's not as clear as spelling it out. So, setTextDirection. Bug: 21572282 Change-Id: Ia94476562d70678f963196b87bb63511d30836b6
* Add hyphenationFrequency attribute to TextView and StaticLayout.Roozbeh Pournader2015-05-121-3/+7
| | | | | | | | 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
* Expose StaticLayout.Builder publiclyRaph Levien2015-05-011-2/+1
| | | | | | | | | | | | | | 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
* Make Paint a required field of StaticLayout BuilderRaph Levien2015-04-301-1/+1
| | | | | | | | | | | | | | | 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
* Add breakStrategy attribute to TextViewRaph Levien2015-04-011-5/+8
| | | | | | | | | | | | | | | | 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
* Revert "Fix build: Revert "Record hyphens from Minikin and draw them""Raph Levien2015-03-301-4/+15
| | | | | | | | | 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
* Fix build: Revert "Record hyphens from Minikin and draw them"Ed Heyl2015-03-301-12/+4
| | | | | | This reverts commit 27fb878c04e18d3bdd6c42ed347194a7c816ed97. Change-Id: I2b3390cb0b258a2e1a38ad72ae9686177d6ffdb8
* Record hyphens from Minikin and draw themRaph Levien2015-03-271-4/+12
| | | | | | | | | | | | 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
* Some refactoring of StaticLayoutRaph Levien2015-03-041-10/+20
| | | | | | | | | | | | | | | | 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
* Uses VMRuntime.newUnpaddedArray for ideal array sizesAdam Lesinski2014-03-271-11/+6
| | | | | | Bug:13028925 Change-Id: I0a9301248b10a339afbdc5e4ffe3310ac4fa1fb7
* Fix Text appears on top of existing text when composing in gmail.Raph Levien2013-10-031-3/+5
| | | | | | | | | 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
* Optimize drawHardwareAccelerated method in Editor classSangkyu Lee2013-01-081-2/+25
| | | | | | | | | | | | | | | | | | | | 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>
* Cut long text into multiple DL at startGilles Debunne2012-05-111-8/+65
| | | | | | | | | | | | | | 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
* TextView's sub display lists have tighten boundsGilles Debunne2012-04-191-26/+26
| | | | | | | | | | | | | | | | | | | | 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
* Added a unit test for DynamicLayout#updateBlocksGilles Debunne2012-03-261-1/+17
| | | | Change-Id: I1824ebeae2bbb5c60a65de36fe1696bf003347c9
* Fix the buildRomain Guy2012-03-151-1/+1
| | | | Change-Id: I6de62c7bfaecd85810178f58707157466291eca3
* Multiple display lists for editable textGilles Debunne2012-03-151-3/+142
| | | | | | | | | | | | | | | | | | | | | | | | | 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
* Wrong word cut at end of lines with spacesGilles Debunne2011-10-181-3/+3
| | | | | | | | | | | | | 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
* Revert "Fix bug #5387832 [UI/Visual] Address of the website is not displayed ↵Fabrice Di Meglio2011-10-041-7/+3
| | | | | properly(second line of the address is partly shown)" This reverts commit a130e5f59dc6b2117e4c1a8ffef54828e9ea44c7
* Fix bug #5387832 [UI/Visual] Address of the website is not displayed ↵Fabrice Di Meglio2011-09-291-3/+7
| | | | | | | | | 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
* Fix bug #5344067 android.text.DynamicLayout.sStaticLayout can hold onto an ↵Fabrice Di Meglio2011-09-251-2/+2
| | | | | | | | 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