Commit Graph

1367 Commits

Author SHA1 Message Date
Siyamed Sinir
5ee0f5c1d7 Merge "Update Emoji.java for emoji 11" into pi-dev 2018-04-23 18:19:22 +00:00
TreeHugger Robot
686fab1464 Merge "SmartLinkify - handle keyboard clicks" into pi-dev 2018-04-20 18:44:02 +00:00
Abodunrinwa Toki
33fa382b8f SmartLinkify - handle keyboard clicks
Bug: 77998709
Test: bit FrameworksCoreTests:android.widget.TextViewActivityTest
Test: bit CtsWidgetTestCases:android.widget.cts.TextViewTest
Change-Id: Ibb95a736248643949a7b521368374084f9f133ca
2018-04-20 14:37:23 +01:00
Siyamed Sinir
adcb6cac12 Update Emoji.java for emoji 11
This CL removes the Emoji 5.0 info from Emoji.java since they are
supported by ICU. It adds emoji added in Emoji 11.

Test: atest android.text.EmojiTest
Test: Verified that ICU handles Emoji 5.0 emoji
Test: Verified hardware keyboard backspace with hair color emoji
Test: Visually verified cursor moves with hardware keyboard

Bug: 77148691
Change-Id: I40b290fcea201cf5e35ad4c461f8d8056b8c3739
(cherry picked from commit 213388d254)
2018-04-19 19:19:39 +00:00
Jeff Sharkey
aa1a911d9a Fix broken target SDK checks.
Consider an app targeting the final API 28, but running on an older
build where "P" is still API 10000.  Those apps need to be treated as
legacy apps.

In general, the logical pattern that should be used when enforcing
target SDK behaviors is below.

For applying behavior to legacy apps:
    // BROKEN
    if (targetSdkVersion <= Build.VERSION_CODES.N_MR1) {
    // CORRECT
    if (targetSdkVersion < Build.VERSION_CODES.O) {

For applying behavior to new apps:
    // BROKEN
    if (targetSdkVersion > Build.VERSION_CODES.N_MR1) {
    // CORRECT
    if (targetSdkVersion >= Build.VERSION_CODES.O) {

Bug: 77865751
Test: builds, boots
Change-Id: Ia83bd446a940751d51a6542c7a5b9cca174c5296
2018-04-10 15:18:15 -06:00
TreeHugger Robot
42c686861c Merge "Update JNI interface of GetBounds in PrecomputedText" into pi-dev 2018-04-10 19:06:51 +00:00
Jeff Sharkey
415716915e Offer to format data sizes in either IEC or SI.
Add flags to let callers specify if they want IEC (power-of-two) or
SI (power-of-ten) units when formatting bytes.

Continue using SI units by default, since certain folks seem to have
strong opinions about that.

Bug: 76159924
Test: atest android.text.format.FormatterTest
Exempt-From-Owner-Approval: previous PS approved
Change-Id: I0074bb2578c2230e938b3f39c2564b1083feb825
2018-04-09 20:23:54 -06:00
TreeHugger Robot
1f2c6dea41 Merge "Fix crash when modifying Selection" into pi-dev 2018-04-09 09:26:42 +00:00
Clara Bayarri
4e51877f5c Fix crash when modifying Selection
The root of this bug was in the fact that Selection.removeSelection
removes two spans, the start index and end index of the selection.
Each span removal triggers Editor#onSpanRemoved, which in turn tries
to set a selection. This meant that if we started with selection
(100, 120), then removeSpan(start) was called, so we had (-1, 120),
then the onSpanRemoved code tried to set a selection so set it to
(120, 120), then removeSpan(end) was called, ending up in (120, -1).

There are two stages to this fix
1. A lot of our code assumes that when either start or end selection
are larger than -1, both are valid. Therefore when we have one of them
out of sync, we crash. Fixed this assumption in all the places I found

2. We didn't have a mechanism to use FLAG_INTERMEDIATE when removing
spans, only when adding them, so this CL adds a remove with flags. This
allows us to not trigger onSpanRemoved when only one of the selection
indexes is removed.
Because this is an added method to an interface, the default just
calls the existing method. The new method is implemented in
SpannableStringInternal and SpannableStringBuilder to read
FLAG_INTERMEDIATE and avoid sending a spans changed event.
Selection.removeSelection then uses FLAG_INTERMEDIATE when removing
the first of the two selection spans.

Note that 2. would be enough to fix the current bug, but we want to
avoid other implementations of Spannable from crashing in the wild.
In general, it seems like a good idea to verify both selection indexes
are valid whenever they are used.

Bug: 72101848
Test: atest FrameworksCoreTests:SpannableStringBuilderTest
Test: atest FrameworksCoreTests:SpannableStringTest
Test: atest CtsWidgetTestCases:TextViewTest
Test: atest CtsWidgetTestCases:EditTextTest
Test: atest android.text.cts.SelectionTest (note new test as well)
Test: atest android.view.inputmethod.cts.BaseInputConnectionTest
Test: atest android.text.DynamicLayoutTest
Change-Id: I0d647fad152d0bef0f2115a46c3d17ebd8642281
2018-04-06 16:51:53 +01:00
Jan Althaus
003889a275 Add deprecation notice to Linkify MAP_ADDRESSES
Bug: 22362008
Test: N/A
Change-Id: Ib70e0cbdd8c454a96e5e75b906ace7b6f1e21cba
2018-04-05 19:04:26 +02:00
Seigo Nonaka
fb0abe1feb Update JNI interface of GetBounds in PrecomputedText
Bug: 77495049
Test: atest CtsWidgetTestCases:EditTextTest
    CtsWidgetTestCases:TextViewFadingEdgeTest
    FrameworksCoreTests:TextViewFallbackLineSpacingTest
    FrameworksCoreTests:TextViewTest FrameworksCoreTests:TypefaceTest
    CtsGraphicsTestCases:TypefaceTest CtsWidgetTestCases:TextViewTest
    CtsTextTestCases FrameworksCoreTests:android.text
    CtsWidgetTestCases:TextViewPrecomputedTextTest

Change-Id: I54a70a91f6fba90720b702b52ed6ad430e17c87d
2018-04-04 18:25:12 +00:00
Seigo Nonaka
3a2d4143ee Merge "Make getText hidden and getWidth/getBounds public" into pi-dev 2018-04-03 15:54:49 +00:00
Seigo Nonaka
151108a2c6 Make getText hidden and getWidth/getBounds public
This is from advice from API review.
- make getText() hidden
- make getWidth()/getBounds() public.

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

Change-Id: Ic22a266a932cda60de6d8b37b8bbf5704291b953
2018-04-02 09:58:47 -07:00
TreeHugger Robot
bf9dfb16be Merge "TextClassifier API updates." into pi-dev 2018-04-02 09:08:52 +00:00
Abodunrinwa Toki
080c8542b6 TextClassifier API updates.
1. Wraps TC queries in Request objects
2. Adds create/destroyTextClassificationSession system APIs
3. Adds the session Ids to system API calls
4. Change setSignature() to setId() on result objects
5. Plumbing to make the API updates work as things currently work
6. Hide Linkify.addLinksAsync APIs

Bug: 74461129

Test: bit FrameworksCoreTests:android.view.textclassifier.TextClassificationManagerTest
Test: bit CtsViewTestCases:android.view.textclassifier.cts.TextClassificationManagerTest
Test: bit CtsWidgetTestCases:android.widget.cts.TextViewTest
Test: bit FrameworksCoreTests:android.widget.TextViewActivityTest
Test: bit FrameworksCoreTests:android.view.textclassifier.TextClassificationTest
Test: bit FrameworksCoreTests:android.view.textclassifier.TextSelectionTest
Test: bit FrameworksCoreTests:android.view.textclassifier.TextLinksTest

Change-Id: I933ada8b37ef9893331a265e3b4fc08e043f1029
2018-04-01 20:04:47 +01:00
Seigo Nonaka
0903665f97 Fills font metrics before passing to ReplacementSpan
Bug: 74518333
Test: atest CtsWidgetTestCases:EditTextTest
    CtsWidgetTestCases:TextViewFadingEdgeTest
    FrameworksCoreTests:TextViewFallbackLineSpacingTest
    FrameworksCoreTests:TextViewTest FrameworksCoreTests:TypefaceTest
    CtsGraphicsTestCases:TypefaceTest CtsWidgetTestCases:TextViewTest
    CtsTextTestCases FrameworksCoreTests:android.text
    CtsWidgetTestCases:TextViewPrecomputedTextTest
    Change-Id: Ifbc8625882919e6498a2758433e80f059a797fd4

Change-Id: I6181fd712aae38e0bba702374e01a40ee3b522dd
2018-03-30 12:30:56 -07:00
Joshua Baxter
2ae75ba1ab docs: fixed typo
am: eb5d2d96ad

Change-Id: I60e1befd90c14fe0ef6b3b8813bb2a791f8a7399
2018-03-28 00:33:50 +00:00
Joshua Baxter
eb5d2d96ad docs: fixed typo
Test: make ds-docs

Bug: 36944055
Change-Id: I52c6d6404340ada5a18b99fd37a2f1d75af00677
2018-03-27 10:28:05 -07:00
TreeHugger Robot
d982f561cc Merge "Fix random SmartLinkify-related TextView bugs." into pi-dev 2018-03-26 23:21:37 +00:00
Abodunrinwa Toki
520969191b Fix random SmartLinkify-related TextView bugs.
1. Preserve selection when the TC times out. (See: SelectionActionModeHelper)

2. Fix highlight/toolbar flicker when tapping on a smart link.
   - Highlight flicker happening because we reset the selection while in
     the process of starting a link action mode.
     i.e. onLinkDown: show highlight
          onLinkUp: start the link action mode asynchronously
	  onLinkUp: reset the selection to an insertion cursor*
	  onLinkActionModeStarted: reset the highlight
	  *Fix: Don't reset selection while starting a link action mode.
   - Toolbar flicker happening because the toolbar positions itself over
     the current selection. The way link highlights have traditionally
     been done is to set the selection to the links bounds*
     *Fix: Hide the toolbar for a few milliseconds when changing
     selection for smoother transition.

3. Fix Paste menu overriding link action mode toolbar after a recent
   "Copy" action. The Paste menu appearing is a feature. Whenever the
   user inserts a cursor after just copying some text, we show the Paste
   menu as a way to make it easy for the user to select the text.
   Because of the problem described in (2) above, changing the selection
   to an insertion triggers the Paste menu feature. Fixing (2) fixes
   this.

4. Fix IME popping up on non-selectable + focusable TextViews.
   See: imm.showSoftInput(...) in Editor. And see comment in the code
   around that. We should only pop up the IME for editable text.

Fixes: 73872461
Fixes: 75985239
Fixes: 76011461

Test: bit CtsWidgetTestCases:android.widget.cts.TextViewTest
Test: bit FrameworksCoreTests:android.widget.TextViewActivityTest
Change-Id: If9ddb7f4e6d4db480ba4a495a22f7f2924ab937e
2018-03-26 18:11:03 +01:00
Seigo Nonaka
53145635e4 Fix BoringLayout with PrecomputedText
The special logic for PrecomputedText in BoringLayout has problem.
The special logic is no longer necessary since TextLine is now aware of
PrecomputedText. So, just removing special logic from BoringLayout.

On the other hand, the metrics parameters check in TextLine has removed
Ie73bce52c6c673cda58973ddad04627a7cf2e5e9, but that was wrong. TextLine
can be used by BoringLayout too. Thus, need to reject PrecomputedText
if the given TextPaint is not compatible with given param.

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

Change-Id: I172b5f655402e797b53b9667b49cb4ab89ec0dc0
2018-03-23 18:19:06 -07:00
TreeHugger Robot
02c8d1b07f Merge "Make PrecomputedText Spannable for supporting selection" into pi-dev 2018-03-22 23:21:54 +00:00
TreeHugger Robot
e9a7cb8158 Merge "Fix smart_linkify_enabled flag." into pi-dev 2018-03-22 22:56:58 +00:00
Abodunrinwa Toki
6563833cf3 Fix smart_linkify_enabled flag.
The flag should only ensure that smart linkify calls behave in the
legacy way instead of totally disabling linkify.
Also, to keep the flag consistent with smart_selection_enabled and
smart_text_share_enabled flags, the flag should only disable the
SmartLinkify (i.e. Linkify.addLinksAsync) feature not TextClassifier
APIs (i.e. TextClassifier.generateLinks).

Also fixes issue with non-focusable TextViews by firing the primary
action instead of showing the floating toolbar. (b/73156794)

Bug: 75967597
Bug: 73156794
Test: bit FrameworksCoreTests:android.text.util.LinkifyTest
Test: bit CtsTextTestCases:android.text.util.cts.LinkifyTest
Test: bit FrameworksCoreTests:android.view.textclassifier.TextClassificationManagerTest
Test: bit CtsWidgetTestCases:android.widget.cts.TextViewTest
Test: bit FrameworksCoreTests:android.widget.TextViewActivityTest
Test: manual - checked behaviour turning flag on/off
Test: manual - checked behaviour with TextView.setFocusableInTouchMode(true/false)
Change-Id: I541f60161b9cd63ce7e57235607500f2fb0841e7
2018-03-22 19:25:14 +00:00
Seigo Nonaka
a553477ddf 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
2018-03-20 22:22:30 -07:00
Seigo Nonaka
c3328d648e Stop creating PrecomputedText in StaticLayout
No performance regressions are expected

android.text.PrecomputedTextPerfTest:
  create NoStyled Hyphenation                  : 17,849,966 -> 17,858,570: (+0.0%)
  create NoStyled Hyphenation WidthOnly        : 17,814,338 -> 17,801,205: (-0.1%)
  create NoStyled NoHyphenation                :  7,123,449 ->  7,068,308: (-0.8%)
  create NoStyled NoHyphenation WidthOnly      :  7,108,169 ->  7,074,908: (-0.5%)
  create Styled Hyphenation                    : 12,179,203 -> 12,131,020: (-0.4%)
  create Styled Hyphenation WidthOnly          : 12,112,347 -> 12,241,311: (+1.1%)
  create Styled NoHyphenation                  : 11,870,126 -> 11,880,442: (+0.1%)
  create Styled NoHyphenation WidthOnly        : 11,836,742 -> 11,860,292: (+0.2%)

android.text.StaticLayoutPerfTest:
  create PrecomputedText Balanced Hyphenation  :    697,713 ->    691,148: (-0.9%)
  create PrecomputedText Balanced NoHyphenation:    517,113 ->    498,106: (-3.7%)
  create PrecomputedText Greedy Hyphenation    :    468,243 ->    455,015: (-2.8%)
  create PrecomputedText Greedy NoHyphenation  :    479,514 ->    461,617: (-3.7%)
  create RandomText Balanced Hyphenation       : 17,183,044 -> 17,049,811: (-0.8%)
  create RandomText Balanced NoHyphenation     :  7,183,745 ->  7,025,070: (-2.2%)
  create RandomText Greedy Hyphenation         :  7,130,841 ->  6,995,785: (-1.9%)
  create RandomText Greedy NoHyphenation       :  7,122,398 ->  7,037,074: (-1.2%)

  draw PrecomputedText NoStyled                :    520,306 ->    551,465: (+6.0%)
  draw PrecomputedText NoStyled WithoutCache   :    545,773 ->    566,956: (+3.9%)
  draw PrecomputedText Styled                  :    826,044 ->    838,979: (+1.6%)
  draw PrecomputedText Styled WithoutCache     :    829,958 ->    841,749: (+1.4%)
  draw RandomText NoStyled                     :    537,079 ->    545,428: (+1.6%)
  draw RandomText NoStyled WithoutCache        :  6,473,166 ->  6,445,194: (-0.4%)
  draw RandomText Styled                       :    995,033 ->  1,015,913: (+2.1%)
  draw RandomText Styled WithoutCache          :  2,725,313 ->  2,770,604: (+1.7%)

android.widget.TextViewPrecomputedTextPerfTest:
  newLayout PrecomputedText                    :    754,311 ->    718,130: (-4.8%)
  newLayout PrecomputedText Selectable         : 17,716,239 -> 17,484,046: (-1.3%)
  newLayout RandomText                         : 16,657,952 -> 16,511,625: (-0.9%)
  newLayout RandomText Selectable              : 17,675,222 -> 17,520,653: (-0.9%)
  onDraw PrecomputedText                       :  1,307,123 ->  1,280,009: (-2.1%)
  onDraw PrecomputedText Selectable            : 17,613,031 -> 17,404,379: (-1.2%)
  onDraw RandomText                            : 17,369,256 -> 17,295,363: (-0.4%)
  onDraw RandomText Selectable                 : 18,207,392 -> 18,077,660: (-0.7%)
  onMeasure PrecomputedText                    :    748,537 ->    739,128: (-1.3%)
  onMeasure PrecomputedText Selectable         : 17,842,953 -> 17,784,459: (-0.3%)
  onMeasure RandomText                         : 16,633,454 -> 16,549,182: (-0.5%)
  onMeasure RandomText Selectable              : 18,022,286 -> 17,873,919: (-0.8%)
  setText PrecomputedText                      :    120,769 ->    119,496: (-1.1%)
  setText PrecomputedText Selectable           :    162,411 ->    150,809: (-7.1%)
  setText RandomText                           :     11,096 ->     10,956: (-1.3%)
  setText RandomText Selectable                :     48,852 ->     48,593: (-0.5%)

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: I3af758ecc5a15975c4e59c6378faf7c14c3bd65b
2018-03-20 18:57:38 -07:00
Seigo Nonaka
3483bc7d64 Introduce new constructor for not copying NoCopySpan
To hold the original text in PrecomputedText, need to create
SpannableString, but copying NoCopySpan causes some side effect.
This CL introduces a way of copying SpannableString/SpannedString
with all spans other than NoCopySpan.

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

Change-Id: I20dea2114ccaa54b16ff679c97682a5003f9a4c1
2018-03-20 14:33:35 -07:00
Seigo Nonaka
e887f4d2c1 Revert "Make PrecomputedText Spannable for supporting selection"
Crash on Sheets APp
This reverts commit 80ed5a35a9.

Bug: 75652829
Change-Id: I40ddd1b9754e74fbd90d7a029cce9c6a7ede0777
Test: Manual
2018-03-19 17:04:30 +00:00
Seigo Nonaka
80ed5a35a9 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
2018-03-15 14:09:08 -07:00
Seigo Nonaka
e1ffb54167 Throw an exception in case of parameter mismatch of precomputed text
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)
2018-03-07 18:30:27 +00:00
Przemyslaw Szczepaniak
ec374b371a Merge "Tweak DateFormat.is24HourFormat javadoc to be more explicit." am: 093c509c40 am: 031b91574d
am: 54ebb3e0b7

Change-Id: Ie218259d09539ec004ccf9fca88133227323d6e2
2018-03-01 16:55:45 +00:00
Przemyslaw Szczepaniak
170d9b8ceb Tweak DateFormat.is24HourFormat javadoc to be more explicit.
Bug: 32761394
Test: make docs
Change-Id: If10da5b9d63e6e88774e333d5c266e423e6bc7c8
2018-03-01 10:35:57 +00:00
Seigo Nonaka
beafa1f9d2 Reorganize MeasuredText API (2nd)
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
2018-02-16 19:42:00 -08:00
TreeHugger Robot
961b465ac4 Merge "Allowing Typeface as a param in TypefaceSpan." 2018-02-16 19:06:53 +00:00
TreeHugger Robot
1d84b1734d Merge "Adding maximum input size checks" 2018-02-16 18:46:50 +00:00
Siyamed Sinir
813d17d67e Update text OWNERS with set noparent
Test: N/A
Change-Id: Ic3d83909a780ae3e3bac81d39719ad60435d95f2
2018-02-15 15:14:50 -08:00
Seigo Nonaka
4e90fa262d 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 7fd36d19e3.

Change-Id: I89ff52a70cf6a5d6c553afa20f83719e1f9eb726
2018-02-14 17:03:16 +00:00
Seigo Nonaka
7fd36d19e3 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
2018-02-12 20:50:41 -08:00
Siyamed Sinir
bc48bd8f61 Merge "Remove Toki from text OWNERS files" 2018-02-08 18:55:17 +00:00
Clara Bayarri
d293d6d4b6 Remove Toki from text OWNERS files
Test: none
Change-Id: I9e444318df4a77ee06949d5141667f6c00d9a508
2018-02-08 11:14:10 +00:00
Jan Althaus
108aad3c30 Adding maximum input size checks
Bug: 67629726
Test: Added tests and ran core tests
Change-Id: Ib6ca53b068731fa0eabcabaed230d7f3ccde1288
2018-02-07 12:00:45 +01:00
Jeff Sharkey
ad357d1839 Pass in the user defined by Context.
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
2018-02-03 02:11:45 +00:00
Florina Muntenescu
57c8b961db Allowing Typeface as a param in TypefaceSpan.
Test: TypefaceSpanTest.java
Bug: 26946279
Change-Id: I99a46fbc41ada567731f034f515998654ce77cb2
2018-02-03 00:45:52 +00:00
TreeHugger Robot
85d8a99310 Merge "Updating more spans" 2018-02-02 00:26:48 +00:00
Florina Muntenescu
139e1b5c01 Updating more spans
Test: N/A
Bug: 72092996
Change-Id: Iecd3595a03cde2a1d58e4be00b7cf9b6783d4e2a
2018-01-31 18:25:02 +00:00
Abodunrinwa Toki
fe20cdd910 Smart Linkify API
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
2018-01-31 09:42:36 +00:00
David Ogutu
321ef3a5af Merge "Fix TimePicker separator l10n issue." 2018-01-30 20:57:58 +00:00
David Ogutu
628bb61c30 Fix TimePicker separator l10n issue.
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
2018-01-30 12:44:45 -05:00
TreeHugger Robot
ea3ca9d720 Merge "Introduce MeasuredText related perf tests" 2018-01-29 19:30:42 +00:00
Florina Muntenescu
8ec69a628b Merge "Making QuoteSpan more flexible." 2018-01-26 03:19:11 +00:00