Forward delete key now deletes characters until the next grapheme
cluster boundary.
Bug: 25737208
Bug: 27035430
Change-Id: Ie2fb510fefa115657cc48063be5319b1eecb30b9
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
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
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
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
- "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
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
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
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
- 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
- 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
The previous code just supported strings, but there were requests for
using BidiFormatter while keeping the spans.
Bug: 26967041
Change-Id: If2a1eeaf2cf1eedff3a83b79a105ea79ed1b85c1
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
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
- Add support to convert BackgroundColorSpan
- Convert StrikethroughSpan to <span> with CSS styling instead of <strike>
- Convert ForegroundColorSpan to <span> with CSS styling instead of <font>
Change-Id: I05ff6b97534df9ee586a552c7e6435aabca152ac
Overload the methods to take int option flags indicating the conversion
behavior. This guards against large disruptions in legacy applications.
Change-Id: I0f47180bbb78884b67aa200fe5156e903eeaa6f6
This CL fixes the case where SpannableStringBuilder.getSpans call
forgot to check the case where sort is false, and the span priority
is not set.
Bug: 26761571
Change-Id: I3a548b9c01768e6977a0ff15d6ecb8ca9ec3c075
SpannableStringBuilder used to return the result of getSpans in the
order of start indices because of the interval tree it uses. However,
style spans has to be applied in the order of insertion to get
predictable results. Sorted the results of getSpans ordered first by
priority flag and then by insertion time. Moreover improved the
performance of SpannableStringInternal copy constructor.
Bug: 26240132
Change-Id: I0b0fa7bb30a3bd9ca37dedca66d8993718586027
This is a straightforward upgrading of LocaleSpan.
LocaleSpan was designed to be a mechanism to override text locale only
in a certain substring. Since now text locale supports multiple locales
with LocaleList, it should make sense to let LocaleSpan have the ability
to have multiple locales with LocaleList.
This CL also addresses an existing issue that LocaleSpan maintained only
Language/Country/Variant tags. Now Locale data associated with a
LocaleSpan is guaranteed to be preserved as long as each of them can be
created from a BCP 47 language tag with Locale#forLanguageTag(String).
Bug: 26567158
Change-Id: Ib754796d399cd00f9d02005df88874a5cd5c7642
This is a series of CLs to promote Java Locale object as a primary data
object to represent locale information in Android APIs.
With this CL, developers can get Locale information from SuggestionSpan
without semantically losing the original data. Possible use cases would
be:
- Emoji subtag (CLDR Ticket #9063)
- Stable and reliable 3-letter country codes handling
- Custom attributes based on private extensions.
Note that this CL does not change the current behavior of
SuggestionSpan#getLocale() as is, even if it is created with a malformed
Locale object:
new SuggestionSpan(new Locale(" a ", " b c ", " e"), new String[0], 0)
.getLocale() -> " a b c e".
Bug: 22858221
Change-Id: I96dfd4f819a236ee2e6dbd3e12903d1214223cb0
TextUtils#getOffsetAfter was used for getting the next
offset in Layout#getOffsetForHorizontal. However, this
method doesn't treat grapheme clusters properly.
Changed to use TextLine#getOffsetToLeftRightOf instead of
TextUtils#getOffsetAfter.
Bug: 25375561
Change-Id: I96c9e6e5da65adfb5266446ecab852c52628dbb5
"getLineEnd(line) - 1" is used as the return value when the
"horiz" is beyond the line end for multiple line text.
In this case, the returned value can point an invalid
offset like the middle point of a surrogate pair.
Bug: 23069901
Change-Id: I1afef7205a15079a42bb0018df73f70fe9ada862
(cherry picked from commit 00ad16d1cd)
When measuring in TextLine (important for cursor positioning), the
substring measured must neither be too short (it can't just be the
substring up to the measure limit, but must include additional
characters if they form a ligature) nor too long (it can't extend
beyond the end of the CharacterStyle span, otherwise the measurement
fails to account for the fact that the CharacterStyle span boundary
breaks the ligature). This patch gets it just right.
Bug: 25375561
Change-Id: I36e1c4bdc66424d3b611cf54031756cf54cf3fec
When SpannableStringBuilder.replace is called with a source text that
contains a span with SPAN_PARAGRAPH flag, the code tries to retain the
spans. However when the paragraph boundary constraint is not satisfied,
setSpan method throws an exception. Updated the rule as: if the source
text has a span with SPAN_PARAGRAPH flag check if it can be copied into
the target. If not, discard the span. Also updated the JavaDoc for
Spanned and Editable.
Bug: 22521443
Change-Id: Ie8541e00bfdf5b8b0115ad7b26cb9f83a6a3ee55
scrollTo in Touch#onTouchEvent was wrongly removed in
I1b29a65be3d321ac while moving mouse text selection logic
added in Iab264bb954b.
Bug: 26409193
Change-Id: Ibb0b13be9492d658785f2ac72be383e634ad96f8
Introduced a new regular expression to autolink URLs. Previous regular
expression used the protocol as an optional rule. The new expression
applies separate rules for strings that do not start with a known
protocol and strings that do start with a known protocol.
- In order to reuse previous regular expression definitions for
different parts of a URL, created constants for different parts of
WEB_URL expression.
- Separated the test cases for WEB_URL in order to remove the suppress
command and make them running again.
- Fixed failing tests for punycode urls, which were causing existing
tests to fail.
- Introduced new a regular expression for URL matching.
- Changed the protocol rule to be case insensitive.
- Updated IANA TLDs.
- Added tests for the new regular expression.
- Added tests for Linkify.
- Bug 9622849 is partially fixed.
Bug: 25727599
Bug: 9622849
Bug: 24500693
Bug: 23189367
Bug: 24543148
Change-Id: Ifd62455d342ca7adb22996246ff652e1d5944bec
This also extends the fallback locale matching algorithm to consider
language+variant before just the language, so asking for "de-AT-1901"
would result in trying "de-1901" before trying "de".
Bug: 26169902
Change-Id: I55e5a73e7ac730d0bc14204126cbb3cc6ce0e9f1
The java.text results are different from the ICU4J's results when
non-BMP characters are present, and the ICU4J's results appear to be
more correct. See also bug 26144875.
Bug: 25993844
Change-Id: Iec2e48008b2ce2147260ed3874e90a51ecf94a35
- Remove mouse selection related logic from
ArrowKeyMovementMethod and Touch.
- Extend drag accelerator to support character based
selection by dragging and use it for mouse drag selection.
- Enable word based drag accelerator even if the clicked
position is not on a word.
- Disable y-coordinate adjustment for word based drag
accelerator when the user is using a mouse.
Bug: 19544351
Change-Id: I1b29a65be3d321ac472f8c5b70ab6fee4e895964
The body of {@code} must not be HTML escaped. This is one of
several changes that fix the source in conjunction with a
doclava fix.
Bug: 25757239
Change-Id: Ib38a0fa2dd2a3d68e467f78a812071e763d7e881
Previously, paragraphs with ImageSpans in their middle would continue to
carry the height of the image into the line height of next lines. This was
a regression from L.
The bug was due to StaticLayout's out() method almost always
modifying the value of its parameter "fm", although that was only
intended when there were LineHeightSpans in the text. The method
generate() was assuming that it can restore fmTop etc to metrics of
the current span by setting them from "fm" after out() was run, while
"fm" was modified by out() and its original values was lost!
The fix makes sure to set chooseHt back to null if there were no
LineHeightSpans, so out() would not modify "fm" unless necessary.
AOSP bug: https://code.google.com/p/android/issues/detail?id=188042
Bug: 24548073
Change-Id: I0d00af384c35a9d863377972318da9db7668118f