Commit Graph

1413 Commits

Author SHA1 Message Date
Siyamed Sinir
4636cc848e Merge "Add UrlSpanFactory to Linkify" 2018-07-10 23:32:27 +00:00
Aaron Heuckroth
09d6bd8a66 Merge "Move channel logging to dump method and redact name." 2018-07-10 18:05:34 +00:00
Aaron Heuckroth
51d3288431 Move channel logging to dump method and redact name.
Test: Generate bug report and confirm that NotificationChannel logs contain redacted name strings.
Change-Id: Iebaf7b165de0276e69ead862aa7ec864ef912282
Fixes: 78326066
2018-07-09 13:26:48 -04:00
Siyamed Sinir
9c6c097604 Add UrlSpanFactory to Linkify
Enable API user to create their own URLSpan for Linkify operations.

Test: atest android.text.util.cts.LinkifyTest
Test: atest android.text.util.LinkifyTest

Bug: 28536972
Bug: 32613009
Bug: 29150779
Change-Id: I9a2f995656bd1510502e5517ac737b47ebd33130
2018-07-08 12:41:38 -07:00
Ian Pedowitz
0a35c20bc3 Revert "Add UrlSpanFactory to Linkify"
This reverts commit ad4883bb1b.

Reason for revert: b/111218263

Bug: 28536972
Bug: 32613009
Bug: 29150779
Change-Id: Idc1621d472d742929f56d10d72b077b774b9e56e
2018-07-07 22:02:29 +00:00
Siyamed Sinir
ad4883bb1b Add UrlSpanFactory to Linkify
Enable API user to create their own URLSpan for Linkify operations.

Test: atest android.text.util.cts.LinkifyTest
Test: atest android.text.util.LinkifyTest

Bug: 28536972
Bug: 32613009
Bug: 29150779

Change-Id: Ia4495dc7e656044b91a79804d3b50a30cae98225
2018-07-03 10:53:16 -07:00
Tobias Thierer
13b96fc1a1 Merge "TextUtils: track behavior change of Pattern.split() when targeting > 28." am: b5f35aeaf3 am: 5442964205
am: e4449497ed

Change-Id: I3bbb854c61f476caaef20eeae2bbcc9473c49469
2018-06-27 08:40:26 -07:00
Tobias Thierer
5442964205 Merge "TextUtils: track behavior change of Pattern.split() when targeting > 28."
am: b5f35aeaf3

Change-Id: I55ba23bfae8f578eb75a4cbfeb2ed4ad1492867d
2018-06-27 08:14:58 -07:00
Tobias Thierer
3e76c04c96 TextUtils: track behavior change of Pattern.split() when targeting > 28.
Another CL in this topic changes the behavior of String.split() and
Pattern.split() to omit a "" generated by a leading zero-width match.
TextUtils.split() is implemented on top of these methods and therefore
adopts the behavior change by default.

The behavior change only affects apps targeting API versions > 28.

Test: cts-tradefed run singleCommand cts-dev -m CtsTextTestCases \
      -t android.text.cts.TextUtilsTest
Test: cts-tradefed run singleCommand cts-dev -m CtsLibcoreTestCases
Bug: 109659282

Change-Id: I8abe251353f8eacf1429ac9a8e272d50a0944c29
2018-06-26 14:48:47 +01:00
TreeHugger Robot
4291ea0c3c Merge "Cleanup: Remove unused padding arguments" 2018-06-08 16:57:55 +00:00
Seigo Nonaka
9155fa6e41 Cleanup: Remove unused padding arguments
Bug: N/A
Test: N/A
Change-Id: I05f5a7d45fcbdc5aacee3e2e915b62017b9cd178
2018-06-05 18:22:03 -07:00
Aurimas Liutikas
7f6641b890 Merge "Fix broken links in @see tags in framework docs." 2018-06-04 19:51:34 +00:00
TreeHugger Robot
232e558006 Merge "Annotate Parcel param/return reference types." 2018-06-04 19:33:59 +00:00
Aurimas Liutikas
e701dc1799 Fix broken links in @see tags in framework docs.
doclava was accidentally suppressing all these broken links
in @see tags. This CL fixes issues so we can start enfocing
checks for broken @see links.

Test: make docs
Change-Id: If7830ece85f8d1f27c991eae282230814726e115
Exempt-From-Owner-Approval: Fixing @see javadoc link issues that are currently completely broken
2018-06-04 10:15:22 -07:00
Jake Wharton
b1f474c066 Annotate Parcel param/return reference types.
Bug: 78245676
Test: atest ParcelNullabilityTest
Change-Id: I7bb844164d4b417445ff2d6f2f99c8a88d7f7f48
2018-06-04 12:47:45 -04:00
Mihai Popa
138b106402 Optimise the hit test algorithm
Layout#getOffsetForHorizontal was running in O(n^2) time, where n is the
length of the current line. The method is used when a touch event
happens on a text line, to compute the cursor offset (and the character)
where it happened. Although this is not an issue in common usecases,
where the number of characters on a line is relatively small, this can
be very inefficient as a consequence of Unicode containing 0-width
(invisible) characters. Specifically, there are characters defining the
text direction (LTR or RTL), which cause our algorithm to touch the
worst case quadratic runtime. For example, a person is able to send a
message containing a few visible characters, and also a lot of these
direction changing invisible ones. When the receiver touches the message
(causing the Layout#getOffsetForHorizontal method to be called), the
receiver's application would become not responsive.

This CL optimizes the method to run in O(n) worst case. This is achieved
by computing the measurements of all line prefixes at first, which can
be done in a single pass. Then, all the prefix measurement queries will
be answered in O(1), rather than O(n) as it was happening before.

Bug: 79215201
Test: manual testing
Change-Id: Ib66ef392c19c937718e7101f6d48fac3abe51ad0
Merged-In: Ib66ef392c19c937718e7101f6d48fac3abe51ad0
2018-05-31 19:14:17 +01:00
Mihai Popa
ce642dc2ff Supress text replacement spans for ellipsis
When a sequence of characters belonging to a text is ellipsized, we
usually replace the first characters with ... and then all the others
with a 0 width character, knowing that they will be drawn, but will be
invisible. However, these positions could have had ReplacementSpans
attached to them, such as EmojiTypefaceSpan when the EmojiCompat library
is used. When this happened, all the ellipsized out characters were
invisible, apart from emojis, which were still drawn as usual (as they
were replacing sequences of 0 width characters).
This CL fixes this behaviour, by skipping those ReplacementSpans that
were completely included in ellipsis. Please check the bug for a more
detailed explanation.

Bug: 69802699
Test: manual testing
Test: atest FrameworksCoreTests:android.text.TextLineTest
Change-Id: If9758537948abaa0226fe6b551a703110c5457b9
2018-05-30 12:52:50 +01:00
Mihai Popa
7626c86ad7 Optimise the hit test algorithm
Layout#getOffsetForHorizontal was running in O(n^2) time, where n is the
length of the current line. The method is used when a touch event
happens on a text line, to compute the cursor offset (and the character)
where it happened. Although this is not an issue in common usecases,
where the number of characters on a line is relatively small, this can
be very inefficient as a consequence of Unicode containing 0-width
(invisible) characters. Specifically, there are characters defining the
text direction (LTR or RTL), which cause our algorithm to touch the
worst case quadratic runtime. For example, a person is able to send a
message containing a few visible characters, and also a lot of these
direction changing invisible ones. When the receiver touches the message
(causing the Layout#getOffsetForHorizontal method to be called), the
receiver's application would become not responsive.

This CL optimizes the method to run in O(n) worst case. This is achieved
by computing the measurements of all line prefixes at first, which can
be done in a single pass. Then, all the prefix measurement queries will
be answered in O(1), rather than O(n) as it was happening before.

Bug: 79215201
Test: manual testing
Change-Id: Ib66ef392c19c937718e7101f6d48fac3abe51ad0
2018-05-22 23:44:00 +00:00
Seigo Nonaka
50fe78805d Reorder the drawing of underline/stroke and text
The underline and stroke should be top of the text.
This regression happens on O-MR1 and the root cause is still unknown,
but the drawning underline/stroke should do before drawing text.

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

Change-Id: Idc2f99b9c0fa125af331e496da8daa326d14bfac
2018-05-21 14:56:40 -07:00
TreeHugger Robot
ff63291986 Merge "Add test cases for Layout.primaryIsTrailingPrevious" 2018-05-17 17:30:21 +00:00
Seigo Nonaka
32afe26a00 Add TextLayout.measure test cases
Bug: 78464361
Test: atest android.text.TextLineTest
Change-Id: I62e05d4fe18c115060da918a2c9105f0e94fe4b0
2018-05-16 22:20:57 -07:00
Seigo Nonaka
19e75a6a42 Add test cases for Layout.primaryIsTrailingPrevious
Bug: 78464361
Test: atest FrameworksCoreTests:android.text.LayoutTest
Change-Id: Id2735e993849bced47f9b361c99e13f91fe88070
2018-05-16 17:00:02 -07:00
Mihai Popa
a875271fcc Check against null text in TextView constructor
It is common for TextView subclasses to override the #setText method,
and there is nothing preventing the new implementations from leaving
mText and mTransformed unchanged. On the other hand, TextView assumes
mText and mTransformed will be non null at all times after the first
overridden implementations, these can remain null, causing null pointer
exceptions later.

Bug: 74411872
Test: atest FrameworksCoreTests:android.widget.TextViewTest
Test: atest FrameworksCoreTests:android.widget.TextViewActivityTest
Test: atest CtsWidgetTestCases:android.widget.cts.TextViewTest
Change-Id: Ifaddb46d156c495a371789c6f32cfd67ffaaaef2
2018-05-14 16:54:00 +01:00
Jake Wharton
fe16dfe76d Avoid internal method call and its branching.
This is a simple check that can be done locally.

Test: TextUtilsTest.java
Change-Id: I00f2a4fd087aa98ece2c3aa032e106496663b13f
2018-04-23 15:34:57 -04:00
Siyamed Sinir
5ee0f5c1d7 Merge "Update Emoji.java for emoji 11" into pi-dev 2018-04-23 18:19:22 +00:00
Abodunrinwa Toki
85767df8cf Merge "SmartLinkify - handle keyboard clicks" into pi-dev am: 686fab1464
am: f8a770a515

Change-Id: I534794c28c13fc44829427a1d4dd567fe683c6b9
2018-04-20 12:25:43 -07: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
Siyamed Sinir
213388d254 Update utility class 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
2018-04-13 14:00:15 -07:00
Jeff Sharkey
266ee2b1f1 Merge "Fix broken target SDK checks." into pi-dev am: aab3304a22
am: 87caa7b9ad

Change-Id: I2d0d813284e483b05bf73d5d91fcfa13bce967d8
2018-04-11 21:58:49 -07:00
Siyamed Sinir
90b3147dd8 Remove Linkify.addAsync functions
Smart Linkify changed their interface to use TextClassifier and
previously @hide addLinksAsync functions. Currently the core tests fail
and the functions are not being used.

Test: N/A
Bug: 77641809
Change-Id: Id1f595bf3e0c4d8c77da4d52e6699a8bb3117659
2018-04-11 11:51:44 -07: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
Seigo Nonaka
f418d345c9 Merge "Update JNI interface of GetBounds in PrecomputedText" into pi-dev am: 42c686861c
am: 0b860336cc

Change-Id: I3462041a85b8dec647f60479e768b92a874472b9
2018-04-10 12:35:14 -07: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
7fa50c393d Merge "Offer to format data sizes in either IEC or SI." into pi-dev am: 52b4692192
am: da28d3d2e5

Change-Id: Id49d518271783b1622e89bcefd55b58c40b5b1a3
2018-04-10 08:27:39 -07: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
Clara Bayarri
536720ab31 Merge "Fix crash when modifying Selection" into pi-dev am: 1f2c6dea41
am: 82b8682922

Change-Id: I092f67aa3422b9a09ab969c3a2a794e62222dcc8
2018-04-09 02:48:41 -07: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
92556299ff Merge "Add deprecation notice to Linkify MAP_ADDRESSES" into pi-dev am: 28709538fe
am: 44249c227f

Change-Id: I778ae94b99cf88ec0f6d943195f0074bdbdca5b2
2018-04-06 08:11:06 -07: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
3a458c3fe8 Merge "Make getText hidden and getWidth/getBounds public" into pi-dev am: 3a2d4143ee
am: 88226e2e3e

Change-Id: I63df61818bef595c9d2e83c5bfe9c678471291c1
2018-04-03 09:26:38 -07:00
Seigo Nonaka
3a2d4143ee Merge "Make getText hidden and getWidth/getBounds public" into pi-dev 2018-04-03 15:54:49 +00:00
Abodunrinwa Toki
dd5bc6f127 Merge "Merge "TextClassifier API updates." into pi-dev am: bf9dfb16be" into pi-dev-plus-aosp
am: 008a5d01af

Change-Id: I4efb43ab74ac98244c6f4145855a75480e2c85b0
2018-04-02 22:20:45 +00:00
Seigo Nonaka
40a1890d31 Merge "Fills font metrics before passing to ReplacementSpan" into pi-dev am: 138148425c
am: f0a302f119

Change-Id: I30e9dfd37853001f77f655b74445d2861f05e12b
2018-04-02 21:21:59 +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