Commit Graph

1039 Commits

Author SHA1 Message Date
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
Andreas Gampe
06f0e41ebd Frameworks/base: Remove unused field
Remove an unused field in BoringLayout. This has also the positive
side effect of allowing static initialization in the boot image.

Bug: 27248115
Change-Id: I9d6beec5f5e045ef899e8979ece96e0239f82076
2016-02-26 14:47:39 -08:00
Siyamed Sinir
0716d5f499 Email address autolink regex updates.
This CL updates the email address pattern with:
* Local-part should be max 64 characters, and domain should be max 255
  characters (it was the opposite before).
* Labels in the domain name should be at most 63 characters.
* Support non-ascii unicode characters.
* Add tests for email address pattern.

Bug:9585450
Change-Id: I983f269904ef014ef625417dd08b6509084e6879
2016-02-25 17:02:43 -08:00
Ben Kwa
2cecbb2408 Merge "Return true when keystrokes are handled in BaseKeyListener." into nyc-dev 2016-02-25 21:10:07 +00:00
Ben Kwa
b23ce29b8f Return true when keystrokes are handled in BaseKeyListener.
BUG=27340791

Change-Id: If9a61c19eea2c1c1833f7ec45c8a474048470aaa
2016-02-24 15:47:08 -08:00
Raph Levien
ccb4b5c078 Update data for emoji modifier bases to Unicode 9
This patch updates the set of emoji modifier bases to Unicode 9,
using data from:
http://www.unicode.org/Public/emoji/3.0/emoji-data.txt

Bug: 27039487
Change-Id: I94c09113753c0595e72f403ba01b3e7fa78c5627
2016-02-24 13:05:55 -08:00
Siyamed Sinir
c7ff969b47 JavaDoc for ReplacementSpan getSize & draw functions.
Added JavaDoc for ReplacementSpan’s getSize and draw functions.

Bug: 20616288
Change-Id: I033ae82b5de672c508d8cbcd69e942c236b2e674
2016-02-19 11:15:09 -08:00
Seigo Nonaka
ff3bfd5a79 Improve backspace for emoji and variation sequences.
This CL makes backspace handling aware of variation selector, combining
enclosing keycaps, zero width joiner, regional indicator symbols and
emoji modifiers.

BUG: 25737208

Change-Id: I740578bfee955cc623e2831778e5b7ec4b8cb627
2016-02-17 15:29:52 +09:00
Siyamed Sinir
afe3cd1aaf Merge "Ellipsized and Non-ellipsized baselines should be same." into nyc-dev 2016-02-16 22:37:54 +00:00
Siyamed Sinir
715589fb46 Ellipsized and Non-ellipsized baselines should be same.
This CL make sure that ellipsized and non-ellipsized text have the
same baseline.
- TextView did not set the maxLines for StaticLayout when ellipsized
is false. This resulted in height and baseline calculation
discrepancies between ellipsized and non-ellipsized TextViews using
StaticLayout.
- For single line TextViews when a text is not ellipsized
BoringLayout is used, and when text is ellipsized StaticLayout is
used. Because of the bottom padding added to the last line of
StaticLayout, those two did not have the same baseline.

Bug: 18864800
Change-Id: I5dbc48a6c7f0f4ac4c693d5c95f0a99b989e07f4
2016-02-12 18:23:37 -08:00
Daniel U
43bb0a0643 Merge "Adopt HTML/CSS color values in fromHtml()" into nyc-dev 2016-02-12 11:24:56 +00:00
Raph Levien
7004c4407f Merge "Allow null string to BidiFormatter#unicodeWrap" into nyc-dev 2016-02-11 18:35:36 +00:00
Daniel U
1eab97ac8e Adopt HTML/CSS color values in fromHtml()
- "green", "gray/grey", "lightgray/lightgrey", and
  "darkgray/darkgrey" have different values in HTML/CSS.

- Adopt HTML/CSS color values according to user specified
  option flag.

- Remove support to "@color" notation as it is not standard
  HTML/CSS.

- Replace SPAN_MARK_MARK with SPAN_INCLUSIVE_EXCLUSIVE
  consistency.

BUG:26950749
Change-Id: I5b33282368042f74f1b4768e096aae3e5bf45de6
2016-02-11 18:32:30 +00:00
Daniel U
4a70f09e39 Tweak toHtml() paragraph conversion behavior
For mode TO_HTML_PARAGRAPH_LINES_INDIVIDUAL:
1) Empty line outputs <br> instead of <p><br></p>

2) A <ul> element is closed if it is followed by a <br>

3) Explicit zero vertical margin is applied to <ul> instead of <li>'s

4) More deterministic way to encode AlignmentSpans: only spans with
   SPAN_PARAGRAPH flag is used. If multiple spans exist, the last one
   (which is added most recently) is used.

BUG: 26224878
Change-Id: I86a2aeced9965ae465daac1ace64e5e41cf45caf
2016-02-11 12:11:44 +00:00
Raph Levien
b68d147b86 Allow null string to BidiFormatter#unicodeWrap
The BidiFormatter#unicodeWrap() methods allow null string, but the
toString() call on the result in the refactored code was crashing.
Also adds @Nullable annotations.

Bug: 27124532
Change-Id: I25922d104587af4a850c3640987af9315c3d3bde
2016-02-10 17:00:22 -08:00
Daniel U
8b36c0bbd1 Handle <span>, <ul>, and <li> tags in fromHtml()
The vertical spacing of <ul> and <li> are determined by the
FROM_HTML_SEPARATOR_* flags. Foreground color, background color,
and text-decoration CSS attributes are parsed and converted into
the corresponding spans.

Change-Id: I93b232de15753ae510392cbacf45e7453d1ae067
2016-02-10 19:18:09 +00:00
Daniel U
cf1fa60331 Allow different paragraph breaks in fromHtml()
- Separate block-level elements with different numbers of newline
  characters according to the user specified option flag.

- Parse the ALIGN attribute and the CSS TEXT-ALIGN property to handle text
  alignment.

- Rename "header" to the correct term "heading"

Change-Id: I446fa97155e761623a1da6632a0d872a5e47e8af
2016-02-10 18:28:07 +00:00
Roozbeh Pournader
fee4484637 Various LocaleList cleanups
- Remove the LocaleList#getPrimary() API. It had become confusing
  after locale negotiation was completely implemented. For example,
  it could create the confusion that calling getPrimary() on the
  default locale list would provide the default locale, etc.
- Use the adjusted locale list from LocaleList.getAdjustedDefault()
  in Paints created with no locale list provided.
- Change LocaleList#get() to treat out of bound indexes from both
  negative indexes and too large indexes the same way.

Bug: 26984092
Bug: 26193251
Bug: 26834387
Change-Id: I75f77aea6b75e38793ed8477e5e5a4420d5e6d85
2016-02-04 15:44:03 -08:00
Roozbeh Pournader
2f35c6405e Add CharSequence interfaces for BidiFormatter
The previous code just supported strings, but there were requests for
using BidiFormatter while keeping the spans.

Bug: 26967041
Change-Id: If2a1eeaf2cf1eedff3a83b79a105ea79ed1b85c1
2016-02-03 18:44:15 -08:00
Daniel U
ca124ab1e2 Encode BulletSpan in toHtml() conversion
Changes in toHtml() conversion with TO_HTML_PARAGRAPH_LINES_INDIVIDUAL:

- Wrap each paragraph inside a block-level element
Each paragraph delimited by '\n' is now wrapped individually inside either
a <p> or a <li> block to allow per-paragraph formatting.

- Wrap paragraphs covered by BulletSpans as <li> instead of <p> blocks

- Encode text alignment at paragraph level
Instead of creating <div> blocks outside of the block quote level.

- Encode AlignmentSpan as CSS style instead of the ALIGN attribute
The ALIGN attribute is obsolete.

Change-Id: I3a8b315224b762af99eda69cb19f5cf6b3f05dac
2016-01-27 16:41:33 +00:00
Daniel U
b138e28778 Enhance support to text size spans in toHtml()
Convert AbsoluteSizeSpan to <span> with CSS font-size property with CSS
px as the unit of measurement. Sizes measured in Android px are converted
to dip, since there is no CSS unit which conveys the idea of a device
pixel.

Add support to RelativeSizeSpan, which converts to <span> with CSS
font-size property with em as the unit of measurement.

Change-Id: I9104cc5f9b00ab1a31929565dc49e0026466cc75
2016-01-27 14:37:44 +00:00