When text contains 2 emojis and each emoji has 2-code units,
the width array will be like [10, 0, 10, 0]. In this case,
without this CL, just the first code unit can be replaced
with the ellipsis marker. This CL makes ellipsis START and
MIDDLE grapheme cluster aware.
Note that ellipsis END is working properly even without
this CL.
Bug: 30613917
Change-Id: I38ff9793f2ea381460c50465c5470e0ad9a405b9
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
* introduce GestureDetector to TextView
* completely remove link click functionality from
LinkMovementMethod (the interface does not state it
provides click functionality)
* intercept onSingleTapConfirmed and trigger onClick on the
link if it exists (simplified duplicated functionality)
* renamed a bunch of LinkMovementMethod variables because
eyes hurt
Bug: 23692690
Change-Id: Idaf3f3391328207f42521235fb5deb1a11c66aaa
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
Previously, since the assumption was that the string is passed down
to ICU4C for the iteration to run, a window of text was copied and
maintained. But now, we can just pass an iterator to the input
CharSequence directly to ICU4J.
Bug: 21832431
Change-Id: Ife5dfdb1d90b3eda2817d4d75747b7abc34a2299
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
WordIterator is now following the pattern in java.text.BreakIterator,
throwing an IllegalArgumentException when receiving an invalid argument.
Previously, it failed inconsistently.
Also add @SmallTest annotations to the WordIterator tests.
Bug: 29868991
Change-Id: I8158f2f419c8c4467205031655c0e62cc9ef5c1c
Layout.getDesiredWidth measured text with TextDirectionHeuristics.LTR,
whereas the real calculations used the active direction heuristic set
in the TextView instance. This CL uses the same heuristics for both of
them by passing the value to Layout.getDesiredWidth function.
Bug: 28845953
Change-Id: I68d23f55fe5a86255d62e83bc62df38a047e4bca
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
The commaEllipsize() method was beyond repair. It couldn't support
several needed internationalization features, and its API depended on
splitting a string and the language having only one plural form.
Bug: 24097278
Change-Id: I85217e4eadac971c58bb001b62ba386fb1297a24
STATE_LF should finish without processing next case but unexpected fall
through happens due to missing of "break".
Fortunately, this unexpected fall through doesn't cause any problems
since STATE_ODD_NUMBERED_RIS case always finishes without doing anything
when unexpected fall through happens.
Bug: 29491345
Change-Id: I23c673ccfc4a2c786fa41f0f7bacb0885896a509
Previously, powers of 1024 were used in formatting human-readable
strings for file sizes, in contrast with international and industry
standards. With this change, we switch to powers of 1000, as
standardized in SI and others.
Bug: 27672362
Change-Id: I34ae16bb68a28e60b09a7c17ac3b1d5ab9ddbeea
One of the signatures of the method that used CharSequence was
unused. The other's implementation was too crude, resulting in too
many false negatives.
The new code now shares logic with BoringLayout in order to detect
potential bidi-affecting characters. The logic is intentionally
rough in order to be efficient: we still have false negatives, but
not as many as before.
Bug: 29254696
Change-Id: I106133369e93e49d7b2fe82ffc433e4556740ee8
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
The APIs are useful in avoiding the unnecessary creation of strings
when you have a CharSequence that's not a String.
Bug: 26979409
Change-Id: I27cd157ca53edb5f44a1e69085a1882af3cc7c6a
in order to determine if the text is RTL, the previous code ran
chunks of the text (in code units) through the TextDirectionHeuristic
instead of the whole text, which could result in misdetection as RTL
in various cases, or missing some cases due to RTL characters getting
split across chunks. Now we look at the whole text instead.
This also refactors the code to make it clearer to understand and
removes an unused signature for isBoring.
Bug: 27702584
Change-Id: I8d98614a0af28c0d4e61af5ab4a27a8a3ab8c9dc
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
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
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
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
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
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
This undoes the automerger skip which occured in
commit e740c84dc3 and
replays it as a standard (NOT -s ours) merge.
Change-Id: If5a47be26f73d6a0735c425cd66310a3e2a89086
Because of a min/max issue, while processing each paragraph StaticLayout
would trim the left/right indent arrays incorrectly.
Bug: 28090810
Change-Id: Ib2b9b48963861e0952bd45a079179e3cca86ffcf
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
Reset FontMetrics object used in BoringLayout.isBoring to get updated
and correct FontMetrics as a result of measurement.
Bug: 26704088
Change-Id: If77b0edba8dc4b5b1738a802c5f49e112e47b4f2
In addition, all English locales other than those explicitly mapped
to en-US are mapped to en-GB.
BUG: 26405413
Change-Id: Ie5b77af164c95a6ed5639da5752ddf21f92181bc
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
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