Commit Graph

1079 Commits

Author SHA1 Message Date
Roozbeh Pournader
f6952b8331 Expand characters temporarily skipped in spellchecking
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
2016-12-19 11:31:07 -08:00
Roozbeh Pournader
ff53f923e9 Merge "Use TextDirectionHeuristics to detect text direction in Html" 2016-12-15 22:00:38 +00:00
Roozbeh Pournader
2beaa2e45e Merge "Use ICU for formatting in DateUtils.formatDuration" 2016-12-15 21:59:46 +00:00
TreeHugger Robot
04b2be42c3 Merge "Deprecate android.text.AndroidCharacter" 2016-12-14 22:20:58 +00:00
Roozbeh Pournader
aa0af8e862 Use TextDirectionHeuristics to detect text direction in Html
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
2016-12-14 14:10:46 -08:00
Roozbeh Pournader
c6bffbf603 Use ICU for formatting in DateUtils.formatDuration
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
2016-12-14 11:59:30 -08:00
Derek Sollenberger
3eda170b77 Merge "Remove Rasterizer and its subclasses from the public API." 2016-12-14 17:16:04 +00:00
Roozbeh Pournader
9559c20a39 Deprecate android.text.AndroidCharacter
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
2016-12-14 17:08:56 +00:00
Abodunrinwa Toki
8158af53e8 Introduce TextClassificationManager.
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
2016-12-12 19:52:31 +00:00
Derek Sollenberger
dcc3630100 Remove Rasterizer and its subclasses from the public API.
Test: compile
Bug: 14650725
Change-Id: I99e1942d4d1b85f4efdcb3faf3fee1aa6c839b7e
2016-12-12 10:53:58 -05:00
Abodunrinwa Toki
d0d9ceb30c Introduce TextAssistant for Smart Text Share feature.
Bug: 30982298
Test: CTS tests to be added in a follow up CL.
Future CLs will add implementation detail.

Change-Id: Iad550447a4b3552340c0ada75fda60f97f0913aa
2016-11-22 14:41:16 +00:00
Siyamed Sinir
302d57c649 Merge "Update TextView ApiDocs." 2016-11-11 23:31:15 +00:00
Siyamed Sinir
9c3af5ab20 Merge "TextLine.handleRun should throw exception for invalid index" 2016-11-08 00:57:38 +00:00
Siyamed Sinir
9aba698bd1 Merge "StaticLayout visual fix for maxLines" 2016-11-08 00:56:18 +00:00
John Reck
caa08ff5e9 The bigger update to Canvas
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
2016-10-17 11:33:28 -07:00
Aurimas Liutikas
4037d51b13 Fix imports in android.text package.
This change also removes trailing whitespaces.

Test: code still compiles
Change-Id: I65f79a34288d01616808fa9cd6732ae4ef0f1377
2016-10-11 17:25:05 -07:00
Keisuke Kuroyanagi
82d1c44333 Make ellipsis START and MIDDLE grapheme cluster aware.
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
2016-09-14 14:30:14 +09:00
Keisuke Kuroyanagi
f5af4a344e Always redraw text that protrude from line bounds.
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
2016-09-05 17:45:37 +09:00
Siyamed Sinir
9f3958cc2b TextLine.handleRun should throw exception for invalid index
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
2016-08-30 14:27:22 -07:00
Siyamed Sinir
28caf6a8da Update TextView ApiDocs.
Update/add ApiDocs for setText, BufferType, Editable.Factory and
Scannable.Factory.

Bug: 30670270
Bug: 30290798
Change-Id: I2ff1f79cfb4c0c3c955ce42326670cf266e1e404
2016-08-26 16:41:36 -07:00
Andrei Stingaceanu
3df24c31bb TextView - fix ClickableSpans always triggering on touch up
* 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
2016-08-12 10:21:08 +00:00
Raph Levien
575284af7c 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 10:10:15 -07:00
Seigo Nonaka
beb21afc2e Treat U+2695, U+2640, U+2642 as emoji characters.
Bug: 29885295
Change-Id: If187a08574b86ab775b0a4594d21bc9e26f84e2f
2016-07-11 15:48:47 +09:00
TreeHugger Robot
ca132ca6a1 Merge "Refactor WordIterator to avoid copying to internal buffers" 2016-07-01 00:03:59 +00:00
Roozbeh Pournader
b08a07165f Refactor WordIterator to avoid copying to internal buffers
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
2016-06-30 15:29:38 -07:00
Siyamed Sinir
fcef4a3b62 Merge "Visibility fixes for text related tests." 2016-06-30 17:54:58 +00:00
Siyamed Sinir
ed09ae1fcc Visibility fixes for text related tests.
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
2016-06-29 22:44:29 +00:00
Roozbeh Pournader
875446698c Merge "Get failing WordIterator unit tests to pass again" 2016-06-29 22:03:29 +00:00
Roozbeh Pournader
9dad5811d7 Get failing WordIterator unit tests to pass again
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
2016-06-29 13:14:13 -07:00
Siyamed Sinir
24ae4b6d1b Merge "Fix bidi desired width calculation" 2016-06-29 01:42:34 +00:00
Siyamed Sinir
79bf9d19f2 Fix bidi desired width calculation
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
2016-06-28 14:01:18 -07:00
TreeHugger Robot
c8fc16ca1c Merge "Delete gender-balanced emoji sequence by one backspace key event." 2016-06-28 06:54:58 +00:00
Seigo Nonaka
bba8d97c36 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
2016-06-28 13:54:19 +09:00
Siyamed Sinir
0745c72965 StaticLayout visual fix for maxLines
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
2016-06-27 16:36:57 -07:00
Roozbeh Pournader
3bfce33993 Introduce listEllipsize() and deprecate commaEllipsize()
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
2016-06-24 16:45:21 -07:00
Seigo Nonaka
33fac38ba9 Need break to stop unexpected fall through
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
2016-06-20 05:20:22 +00:00
Roozbeh Pournader
547b74394a Merge "Switch to standard SI prefixes for kilobyte etc" 2016-06-13 23:09:00 +00:00
Roozbeh Pournader
36bd3b86a1 Switch to standard SI prefixes for kilobyte etc
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
2016-06-10 18:39:12 -07:00
Roozbeh Pournader
8823c85f0a Clean up TextUtils.doesNotNeedBidi()
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
2016-06-09 18:46:31 -07:00
Siyamed Sinir
a4cbaa30e1 Merge \\\"Fix int overflow in SpannableStringBuilder.replace\\\" into nyc-dev am: 96c3e5504b am: 9eddf7ae8e
am: bb05c332b1

Change-Id: I3ff5cb7dbf6ceccf212d65fcb8b06eb5c087cc5e
2016-06-08 00:59:49 +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
36cd87d04e Unhide CharSequence APIs to BidiFormatter
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
2016-06-02 13:01:19 -07:00
Roozbeh Pournader
5536c4fdee Use bidi heuristics correctly in BoringLayout#isBoring()
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
2016-06-01 17:29:23 -07:00
Roozbeh Pournader
a0b920f4da Merge "Support ellipsizing LocaleHelper.getDisplayLocaleList()" into nyc-dev am: fe524c0e24 am: 5f55e2c43d
am: bbed32a63b

* commit 'bbed32a63b420126850767ae5cf2484bea11c1d4':
  Support ellipsizing LocaleHelper.getDisplayLocaleList()

Change-Id: Ibead4334a7797320d6ae7c5792482416b4a7e2d0
2016-05-31 01:32:39 +00: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
Aurimas Liutikas
514c5ef8d5 Add missing @Deprecated annotations.
Add missing @Deprecated annotations for methods with @deprecated tag
in javadoc.

Change-Id: I35b78ccb97832d86b914c21a300444ba29e33844
2016-05-24 15:22:55 -07: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