Commit Graph

1059 Commits

Author SHA1 Message Date
Android Build Merger (Role)
126189263d [automerger] Fix Layout.primaryIsTrailingPreviousAllLineOffsets am: 2778b1e49d am: 77b7393e7d
Change-Id: I2a5373fa2ea348adde8e5592a5a9fa489c7fe12b
2019-07-10 18:02:32 +00:00
Mihai Popa
2778b1e49d Fix Layout.primaryIsTrailingPreviousAllLineOffsets
The CL fixes a crash in Layout.primaryIsTrailingPreviousAllLineOffsets.
The crash was happening when the method was called for a line beginning
with an empty bidi run. This could happen, for example, for empty text -
I was unable to find any other case. The CL improves the existing test
for the method with this case, which was previously crashing.

The CL also fixes a potential crash in getLineHorizontals. However, this
bug could never happen as in the current code path clamped is always
false (and kept as parameter for parity with getHorizontal).

Bug: 135444178
Bug: 78464361
Test: atest FrameworksCoreTests:android.text.LayoutTest\#testPrimaryIsTrailingPrevious
Change-Id: I47157abe1d74675884734e3810628a566e40c1b4
(cherry picked from commit 7ad499d007)
2019-07-10 18:02:25 +00:00
Android Build Merger (Role)
3823545fee [automerger] RESTRICT AUTOMERGE Do not linkify text with RLO/LRO characters. am: 73f398d306 am: 363e47e676 am: efb165f557 am: b2b98a008b
Change-Id: I29c3f97af12987c8a1dd8a69529641d32d2dd172
2019-01-03 14:07:59 +00:00
Android Build Merger (Role)
efb165f557 [automerger] RESTRICT AUTOMERGE Do not linkify text with RLO/LRO characters. am: 73f398d306 am: 363e47e676
Change-Id: I828e0c99ab41935d20033c970b5131f2fcbf9085
2019-01-03 14:07:43 +00:00
Android Build Merger (Role)
363e47e676 [automerger] RESTRICT AUTOMERGE Do not linkify text with RLO/LRO characters. am: 73f398d306
Change-Id: I423ddd8df74bee8dbf7cd96009bbdffebf81b93a
2019-01-03 14:07:33 +00:00
Tony Mak
73f398d306 RESTRICT AUTOMERGE Do not linkify text with RLO/LRO characters.
Also don't show smart actions for selections in text with unsupported
characters.

Bug: 116321860
Test: runtest -x cts/tests/tests/text/src/android/text/util/cts/LinkifyTest.java

Change-Id: Id271cab8aef6b9b13ef17f1a8654c7616f75cf13
2019-01-03 14:07:30 +00:00
Android Build Merger (Role)
8f85f5ffd2 [automerger] Fix crash during cursor moving on BiDi text am: 82c84d5fbb am: 12baaa2bc3 am: 99e3f649b4 am: a959ee227a
Change-Id: I7cb6623befc84f76e783b8800aa18ce28a8cc2b7
2018-08-15 19:13:10 +00:00
Android Build Merger (Role)
99e3f649b4 [automerger] Fix crash during cursor moving on BiDi text am: 82c84d5fbb am: 12baaa2bc3
Change-Id: Iaf0aded3004f33fdb52dd0c19779329991b24746
2018-08-15 19:12:59 +00:00
Android Build Merger (Role)
12baaa2bc3 [automerger] Fix crash during cursor moving on BiDi text am: 82c84d5fbb
Change-Id: I221d974ba9402c088235d5bdb3c94e91cf4167ba
2018-08-15 19:12:52 +00:00
Seigo Nonaka
82c84d5fbb Fix crash during cursor moving on BiDi text
The crash was introduced by Ib66ef392c19c937718e7101f6d48fac3abe51ad0
The root cause of the crashing is requesting out-of-line access for the
horizontal width. This invalid access is silently ignored by
TextLine#measure() method but new implementation end up with out of
bounds access.

To makes behavior as old implementation, calling getHorizontal instead
of accessing measured result array.

Bug: 78464361, 111580019
Test: Manually done
Change-Id: I5c5778718f6b397adbb1e4f2cf95e9f635f6e5c8
(cherry picked from commit 960647d582)
Merged-In: I5c5778718f6b397adbb1e4f2cf95e9f635f6e5c8
2018-08-15 19:12:50 +00:00
Android Build Merger (Role)
94bc67f03c [automerger] Optimise the hit test algorithm am: 71ecf5bd5c am: 42eaa8f932 am: a72cb45f89 am: f5d69aa775
Change-Id: Ic2d4d3ead4926ff0f8021725e28aee4ebfc369f3
Merged-In: Ib66ef392c19c937718e7101f6d48fac3abe51ad0
2018-06-05 13:12:31 +00:00
Android Build Merger (Role)
a72cb45f89 [automerger] Optimise the hit test algorithm am: 71ecf5bd5c am: 42eaa8f932
Change-Id: I2ac44759ff615b32724f5235d3e5e8dc8c9b4ced
2018-05-31 16:46:27 +00:00
Android Build Merger (Role)
42eaa8f932 [automerger] Optimise the hit test algorithm am: 71ecf5bd5c
Change-Id: If1c91f3bc1e785434f153c5bc0d14befbc75e6cb
2018-05-31 16:46:17 +00:00
Mihai Popa
71ecf5bd5c 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 17:45:42 +01:00
Elliot Waite
de2557f369 Fix @links in reference docs. am: 54de77470d
am: ab978c035e

Change-Id: Ibec2b85708f9ff923156f4d867c9c2f71c75d41c
2017-01-26 04:39:53 +00:00
Elliot Waite
54de77470d Fix @links in reference docs.
Change-Id: I40cea46efd80c448640ff69753698fe8404da40b
2017-01-25 17:00:55 -08:00
Siyamed Sinir
9e1f4e8891 Merge "Make SpannableStringBuilder.getSpans thread-safe" into nyc-mr2-dev 2017-01-24 22:20:04 +00:00
Siyamed Sinir
4234144a2b Make SpannableStringBuilder.getSpans thread-safe
Add cached int buffers for sorting.

Test: All CtsTextTestCases

Merged-In: Ice0b3c3fffc541b26aca94c93fd01e30e13efe2e

Bug: 33609774
Change-Id: Ib728654a384cfc072d1c190611e4553aa8957fa8
2017-01-23 14:39:35 -08:00
Siyamed Sinir
051caedcaa Fix SpannableStringBuilder getSpans sort
Sort function was broken for odd number of elements.

Test: Added new CTS tests.

Bug: 33567024
Change-Id: I7457dee6ac279c6aab5b92431b347dc1f16a8fa0
2017-01-19 13:10:36 -08:00
Raph Levien
9cde7244b6 Enforce consistent sizes for arrays in SpannableStringInternal
The grow logic in SpannableStringInternal#setSpan assumes that the
size of mSpanData is consistent with that of mSpans, in particular
that if the latter doesn't need to grow, neither does the former.
The copySpans() method didn't enforce this, creating an mSpanData
array only big enough to hold the data.

This patch documents the invariant in a comment and enforces it.

Bug: 30359314
Change-Id: Ie25db70a76836e97af8476a7f5c10cb4b976c1cf
(cherry picked from commit 83549088c6)
2016-08-26 23:44:47 +00:00
Raph Levien
83549088c6 Enforce consistent sizes for arrays in SpannableStringInternal
The grow logic in SpannableStringInternal#setSpan assumes that the
size of mSpanData is consistent with that of mSpans, in particular
that if the latter doesn't need to grow, neither does the former.
The copySpans() method didn't enforce this, creating an mSpanData
array only big enough to hold the data.

This patch documents the invariant in a comment and enforces it.

Bug: 30359314
Change-Id: Ie25db70a76836e97af8476a7f5c10cb4b976c1cf
2016-07-25 18:19:00 +00:00
Raph Levien
c0ab2e83ac Merge "Treat U+2695, U+2640, U+2642 as emoji characters." into nyc-mr1-dev 2016-07-14 22:25:40 +00:00
Seigo Nonaka
3c7a0a0af4 Treat U+2695, U+2640, U+2642 as emoji characters.
Bug: 29885295
Change-Id: If187a08574b86ab775b0a4594d21bc9e26f84e2f
(cherry picked from commit beb21afc2e)
2016-07-13 21:10:56 +00:00
Seigo Nonaka
f20ca2cb15 Delete gender-balanced emoji sequence by one backspace key event.
The gender-balanced emojis are made with ZWJ sequence and emoji
modifiers.  For example, U+1F469 U+1F3FD U+200D U+1F4BC should be
deleted at the same time by single backsapce key event.  Here, U+1F469
is WOMAN, U+1F3FD is EMOJI MODIFIER FITZPATRICK TYPE-4, U+200D is ZERO
WIDTH JOINER, U+1F4BC is BRIEFCASE.

This CL also renames the state name from STATE_BEFORE_ZWJ_EMOJI to
STATE_BEFORE_EMOJI since now all emoji can be a part of ZWJ sequence
after I572dad42ee108476962d4b3fe9f3a6019cb50098

BUG: 29728397
Change-Id: Ib114295db45c6592f1c65a0773ab236f8bf35209
(cherry picked from commit bba8d97c36)
2016-07-13 21:08:10 +00:00
Siyamed Sinir
eb4df8a822 Fix int overflow in SpannableStringBuilder.replace
During the offset calculation for selection, SpannableStringBuilder
had an overflow while multiplying two int values. This CL uses long to
calculate the multiplication, and also checks for overflow after
casting the final result into int again.

Bug: 29108549
Change-Id: I11eff4677916701074b38bc5214730fe704707c4
2016-06-03 18:11:45 -07:00
Roozbeh Pournader
0ad4dccf88 Support ellipsizing LocaleHelper.getDisplayLocaleList()
Add an extra parameter to LocaleHelper.getDisplayLocaleList()
specifying the maximum number of locales to output, as callers
probably won't need the whole list.

Bug: 28872122
Change-Id: Ief136bc1af2841e76ed4d8e65932a9a30821eae3
2016-05-27 06:46:26 +00:00
Andreas Gampe
a8a58ffdee Frameworks/base: Optimize LoadedApk
Preallocate storage lists and avoid TextUtils and its string
builder for a common code path.

Optimize list join helper to not have a check in the loop.

Bug: 28801010
Change-Id: Iafc582031f973d718252b34bcda6405a77425628
2016-05-18 15:48:12 -07:00
Yohei Yukawa
23cbe85610 Move LocaleList to avoid layering violation.
Since LocaleList needs to depend on android.os.Parcelable, we cannot let
that class belong to "android.util" package, which causes layering
violation.

Bug: 28819696
Change-Id: Ia8de2ee9df3dd0a42b1fe84574439519b680fe18
2016-05-17 16:42:58 -07:00
Keisuke Kuroyanagi
78f0d83550 Sum up character widths to get the last line width for ellipsis.
To properly apply ellipsis, we virtually concatenate the last line and
overflowed lines after line breaking for a paragraph.
Previously, width of the concatenated line was computed by summing up all
line's width.  However, the width is wrong when there are any trailing
white  spaces that can be normal white spaces by concatenating lines.
With this CL, we sum up widths of all characters in lines except the last
overflowed line.

Bug: 28599066
Change-Id: I41d828ee8eb8a702cd5096d626b307cbb3467047
2016-05-10 12:21:33 -07:00
Raph Levien
10ea92aefa Make LocaleList constructor non-nullable
This commit makes the LocaleList constructor require non-null
arguments in all cases, and fixes all uses of LocaleList that could
previously pass a null to use getEmptyLocaleList() instead (which is
preferred anyway becaues it avoids an allocation.

Bug: 28460668
Change-Id: I4b8b3cfa82914412731c2b79003951c46cb2afa1
2016-05-02 12:57:56 -07:00
Clara Bayarri
d608a0adcb Fix TextUtils#getReverse deprecated doc
Note there is no alternative method to use.

Bug: 28296055
Change-Id: I1e44c1dad6009434a92c6a53862e6f061114bc56
2016-04-27 10:28:03 -07:00
Trevor Johns
59c9a93fc2 Merge changes from topic 'merge_docs_nyc-dev' into nyc-dev
* changes:
  Remove links to createAndInitializeUser() and createUser()
  Resolve merge conflicts of a5060ee to nyc-dev
2016-04-20 18:35:57 +00:00
Seigo Nonaka
3675d3cd84 Delete emojis before and after ZWJ at the same time.
Vendor may want to introduce their own ZWJ emoji sequence. To delete
them by one back space as the same behavior of Unicode emoji sequence,
use all emoji as the zwj emoji.

Bug: 28248662
Change-Id: I572dad42ee108476962d4b3fe9f3a6019cb50098
2016-04-19 18:54:50 +09:00
Trevor Johns
682c24e228 Resolve merge conflicts of a5060ee to nyc-dev
This undoes the automerger skip which occured in
commit e740c84dc3 and
replays it as a standard (NOT -s ours) merge.

Change-Id: If5a47be26f73d6a0735c425cd66310a3e2a89086
2016-04-19 02:03:59 -07:00
Siyamed Sinir
9dba546d9a Merge "Fix StaticLayout left/right indent" into nyc-dev 2016-04-13 17:29:22 +00:00
Siyamed Sinir
f9a0886da0 Fix StaticLayout left/right indent
Because of a min/max issue, while processing each paragraph StaticLayout
would trim the left/right indent arrays incorrectly. 

Bug: 28090810
Change-Id: Ib2b9b48963861e0952bd45a079179e3cca86ffcf
2016-04-12 19:30:44 -07:00
Seigo Nonaka
4d19160ef1 Delete CR LF at the same time with one backspace key.
Bug: 27847705
Change-Id: I9ad640f2586adc705a854fac69a77f940be1dc25
2016-04-12 14:10:56 +09:00
Raph Levien
07e6c237d3 Apply correct bottom padding to layouts
The returned descender value for BoringLayout and StaticLayout should
be equal to the font's "bottom" metric in the includePadding case.
Previously, the calculation incorrectly included an addition
mBottomPadding value in some cases (which was an attempt to work
around the case where maxLines was set on TextView but not the
corresponding StaticLayout, no longer the case).

Bug: 27901763
Change-Id: I008c5974b979087725a9bb9104e4771b0caac01c
2016-04-04 12:34:06 -07:00
Siyamed Sinir
70f660f2d6 Reset FontMetrics at each new measurement in BoringLayout
Reset FontMetrics object used in BoringLayout.isBoring to get updated
and correct FontMetrics as a result of measurement.

Bug: 26704088
Change-Id: If77b0edba8dc4b5b1738a802c5f49e112e47b4f2
2016-03-30 17:17:05 -07:00
Jungshik Shin
3b262793a0 Merge "Load hyphenator for 22 new languages" into nyc-dev 2016-03-29 00:06:36 +00:00
Jungshik Shin
31445528c0 Load hyphenator for 22 new languages
In addition, all English locales other than those explicitly mapped
to en-US are mapped to en-GB.

BUG: 26405413
Change-Id: Ie5b77af164c95a6ed5639da5752ddf21f92181bc
2016-03-28 16:05:22 -07:00
Keisuke Kuroyanagi
1e632ba426 Merge "Improve selection handle behavior for bidi text." into nyc-dev 2016-03-28 06:06:02 +00:00
Siyamed Sinir
6eccafd339 New Linkify.addLinks function with set of known schemes
A new addLinks function is added that accepts a default scheme and a
set of known schemes. Default scheme is applied whenever the link found
does not start with one of the given known schemes.

Moreover, previously JavaDoc for addLinks functions with a single scheme
parameter described that the scheme attribute will be prepended to the
links that do not have 'a' scheme. The code actually checks if the link
starts with the given scheme and prepends if not. JavaDoc updated
accordingly.

Bug: 26985901
Change-Id: I94ea81dcf83ba7a6b6cd47c10fe8fb277964eb15
2016-03-21 10:27:31 -07:00
Keisuke Kuroyanagi
f0bb87b7c4 Improve selection handle behavior for bidi text.
A point on a direction boundary can be mapped to two offset and
one offset on a direction boundary can be mapped to two points.
Previously, paragraph's primary direction is always used for deciding
offset and coordinates; thus, handle movement around a direction
boundary is often nonintuitive.

With this CL:
1. For selection end handle, direction of character at offset - 1 is
used for deciding handle shape and position.
2. For getting offset from coordinates, previous offset is used to
minimize the offset delta and primary .
3. For getting coordinates form offset, new logic chooses primary or
secondary horizontal coordinate depending on the current run
direction and paragraph direction.
4. When a handle passes another one because it passes a direction
boundary, new logic keeps the handle at the run boundary instead of
minimizing the selection.

Bug: 19199637
Bug: 21480356
Bug: 21649994


Change-Id: I2a7e87ad08416f4bd01a5f68e006240f77d9036b
2016-03-18 14:39:09 +09:00
Keisuke Kuroyanagi
17db42cbac Merge "Fix: setIntegerPart(long) doesn't set ARG_INTEGER_PART." into nyc-dev 2016-03-17 06:42:24 +00:00
Roozbeh Pournader
3cf8208a62 Clean up BoringLayout#isBoring() a little
No functional change. Just some renames and clarifications.

Bug: 23641693
Bug: 27702584
Change-Id: I14efe290a27c695ab79bbb18f9f069c8a2d3ffd6
2016-03-16 14:48:39 -07:00
Keisuke Kuroyanagi
1c68853fbb Fix: setIntegerPart(long) doesn't set ARG_INTEGER_PART.
Bug: 27689119
Change-Id: I749a1698cda552a0841d6905b81486bf2d74a296
2016-03-16 21:27:20 +09:00
Roozbeh Pournader
217a86c709 Remove Basque hyphenation patterns
Change-Id: Ib59de7c96fe19da9534fe65c3d553dc7c5399a1f
2016-03-12 20:56:23 -08:00
Siyamed Sinir
84d0f8775b Merge "Email address autolink regex updates." into nyc-dev 2016-03-03 18:42:59 +00:00
Seigo Nonaka
23a67678e3 Improve forward delete key handling.
Forward delete key now deletes characters until the next grapheme
cluster boundary.

Bug: 25737208
Bug: 27035430
Change-Id: Ie2fb510fefa115657cc48063be5319b1eecb30b9
2016-03-02 17:21:36 -08:00