At line break, one offset can be mapped to two phisical
position: previous line end and next line start.
Previously, all cursor handles are placed at next line
start.
With this CL, selection end handle is placed at the
previous line end in such cases.
Test: FrameworksCoreTests
Bug: 21305922
Change-Id: I00d9f9a0cd417ca92534e93b3d3f655cd62f25d3
Adds a new get/setJustify API to TextView and StaticLayout.Builder for
justification, and fully justifies text when it's enabled.
This is based on a patch by Raph Levien (raph@google.com).
Bug: 31707212
Test: Manually done and CTS will introduced with
I0f3bbf39d60a66b71b30e1351f7c741208f05dce passes.
Change-Id: Icbfab2faa11a6a0b52e6f0a77a9c9b5ef6e191da
An earlier patch (I4d09576a31df551c96f820242fd2cbc675506dae)
special-cased apostrophe as a character to defer spellchecking on,
since it could cause a word break which could later get removed.
This patch updates that earlier patch to include all characters that
could cause such a behavior according the Unicode word breaking
algorithm defined in UAX #29.
Bug: 17641350
Bug: 17673522
Test: manual
Change-Id: I4029e3d91dfcf96665b003f6fdd30d1208b0ac7c
Previously, AndroidBidi was used instead, whch did a lot of extra work
just to detect a paragraph's direction. TextDirectionHeuristics stops as
soon as the direction is found, and avoids JNI too.
Bug: 21455837
Test: cts-tradefed run cts-dev --module CtsTextTestCases --test android.text.cts.HtmlTest
Change-Id: Iea196fb5ca43dca99e65a367a2da701b1c1b98b8
Previously, we were using native strings. ICU has higher quality and
more comprehensive data.
Also adds parameters for specifying the format width (e.g. "2 hrs" vs
"2 hours").
Bug: 31526474
Test: adb shell am instrument -w -e class android.text.format.DateUtilsTest com.android.frameworks.coretests/android.support.test.runner.AndroidJUnitRunner
Change-Id: I754f6c761c2ed3853046796c57ff2d86a6ccd43e
AndroidCharacter was added to compensate for limitations in
java.lang.Character, but it has been outdated and its functionality
is provided with a much better API by android.icu.lang.UCharacter.
Bug: 32551718
Test: cts-tradefed run cts-dev --module CtsTextTestCases --test android.text.cts.AndroidCharacterTest
Change-Id: Iec1969dc5787a4ebb0e68cdc213d3d0cdc3b2d0d
This handles smart selection and language detection features.
This CL only contains code to integrate the TextClassificationManager.
Implementation will be added in a follow up CL.
Test: Test will be added when TextClassificationManager is added.
Bug:32503402
Change-Id: I5f22150ff998156fbc91b51c733d93478efaa51f
Bug: 30982298
Test: CTS tests to be added in a follow up CL.
Future CLs will add implementation detail.
Change-Id: Iad550447a4b3552340c0ada75fda60f97f0913aa
All draw* calls in Canvas are regular JNI
All draw* calls in DisplayListCanvas are FastNative
Unifies Canvas JNI on nMethodName naming
CanvasPerf results before:
INSTRUMENTATION_STATUS: basicViewGroupDraw_min=12492
INSTRUMENTATION_STATUS: recordSimpleBitmapView_min=13912
and after:
INSTRUMENTATION_STATUS: basicViewGroupDraw_min=11945
INSTRUMENTATION_STATUS: recordSimpleBitmapView_min=13318
Test: refactor, makes & boots
Change-Id: I06000df1d125e17d60c6498865be7a7638a4a13e
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
TextLine.handleRun caused infinite loop if measureLimit is out of bounds
of start and end parameters (for Spannables). For regular String it used
to throw a similar exception in handleText. This CL verifies what is
written in ApiDoc: measureLimit should be between start and limit
inclusive.
Bug: 30985145
Change-Id: I0659e8887f7b43ed2047d08b99bf86d8df80a21c
* 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
When maxLines is set on StaticLayout, the height calculation includes
the lineSpacing for the lastLine, which causes the ellipsized version
and non-ellipsized version to have different heights. With this CL:
* maxLines is always set on StaticLayout
* the correct line count for a given text is preserved, in other words a
text that would be n lines will not be cut at maxLines.
* The visual height for StaticLayout for ellipsized and non-ellipsized
cases are the same when maxLines is set.
Bug: 28988744
Bug: 18864800
Change-Id: I1e1cae31cf33d503a8cf1c942f422893efc480bb
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