Commit Graph

935 Commits

Author SHA1 Message Date
Raph Levien
c3cc344d12 Merge "Release text when finishing StaticLayout.Builder" into mnc-dev 2015-07-29 19:44:21 +00:00
Raph Levien
22ba7869f6 Release text when finishing StaticLayout.Builder
DynamicLayout reuses a StaticLayout.Builder object to avoid having to
allocate. There is a "finish" method that releases any expensive
internal state of the builder object, but it didn't release a
reference to the text object (which in turn may contain references to
lots of other things, especially if it's a Spannable).

This patch releases the text, as well as a few other arrays, at time
of finish.

Bug: 22822416
Change-Id: Icc8b6cd41a9a2d11689df7bd1b9f524c6524f706
2015-07-29 12:34:13 -07:00
Raph Levien
a00896198d Allow soft hyphens in languages without patterns
This patch sets up an "empty" hyphenator, which it uses by default
for locales in which there is no hyphenation pattern data. This has
the effect of enabling soft hyphens (U+00AD), which were otherwise
disabled, because the "no-hyphen" code path didn't consider them.

Bug: 19605972
Change-Id: I4dcb95cee8edc48495f7c38736f5abf26fa04935
2015-07-27 13:06:24 -07:00
Raph Levien
1fcb6d3ae2 Merge "Respect style boundaries when measuring text" into mnc-dev 2015-07-21 16:55:39 +00:00
Raph Levien
ea2b4a40f7 Respect style boundaries when measuring text
The existing implementation of handleText() in TextLine laid out
text to the end of the context. However, in cases where the text is
broken into multiple style spans, it's only valid to lay out up to
the end of the style span. This can lead to inconsistent
measurements, especially in the presence of legitimate zero-width
characters such as bidi control characters and zero width space.

This patch changes the invocation of getRunAdvance to measure only
within the style span.

Bug: 22589743
Change-Id: I027f5e77db27ddf9596ef20adcad7e62a82b41de
2015-07-20 16:22:01 -07:00
Roozbeh Pournader
2dc6ebbea8 Merge "Fix default value of stereoReset() in the documentation." into mnc-dev 2015-07-20 21:20:02 +00:00
Roozbeh Pournader
007262e0ae Fix default value of stereoReset() in the documentation.
The default has been 'true' for eternity in the code. But the
documentation was mistakenly saying it was 'false'. Going with the
code, since there are people out there relying on the code continuing
to work the same way.

Bug: 22557371
Change-Id: I6f4e7b2052d0cc30d41e8ccf2b9a5c6111fa0ab7
2015-07-20 10:08:58 -07:00
Roozbeh Pournader
8d2e0f7898 Bidi-wrap the results of format[Short]FileSize().
Previously, users of the results of formatFileSize() and
formatShortFileSize() needed to unicodeWrap the results themselves
using BidiFormatter, which resulted in several bugs and
inconsistencies across the platform when they didn't, especially in
Hebrew and Urdu locales:

Hebrew and Urdu use Latin abbreviations like 'MB' for file sizes
which cause undesired reorderings (or incorrect detection of the
string direction when the formatted file size starts the string).

With this patch, the results are now bidi-wrapped before being
returned if the locale of the context passed in to the formatter is a
right-to-left locale.

Bug: 22237132
Bug: 22273176
Change-Id: If076636d15828fc810feef6f0fa8806ef52aed5d
2015-07-17 12:02:22 -07:00
Raph Levien
1b3d03512e Merge "Improve Html.toHtml() documentation" into mnc-dev 2015-07-11 06:09:12 +00:00
Raph Levien
c55277d689 Improve Html.toHtml() documentation
The existing documentation is very terse and users were getting
confused whether the method escapes HTML metacharacters or not. Expand
the description a bit and explicitly state that metacharacters are
escaped.

Bug: 17456925

Change-Id: Icaae7fe1344629de5c0860674f3913781de18013
2015-07-10 17:44:18 -07:00
Chris Craik
9f00492008 Merge "Reduce cost of span type checking" into mnc-dev 2015-07-10 22:44:28 +00:00
Chris Craik
fc121c2430 Reduce cost of span type checking
bug:22378829

Change-Id: I1da5154b2fb4f5032eaed44586d5470d28ceb45b
2015-07-10 13:12:35 -07:00
Raph Levien
5d1654a943 Merge "Fix StaticLayout crash when maxLines = 0" into mnc-dev 2015-07-10 18:37:49 +00:00
Raph Levien
04a84559fd Fix StaticLayout crash when maxLines = 0
An app setting maxLines = 0 is an edge case, but it can happen. We
had some logic that would index an array at -1 in that case. This
patch just skips the fixup of the ellipsis line break in that case.

Bug: 22353342
Change-Id: I940cf0782b319010f5aedf75b9291df4ac2976d8
2015-07-09 15:42:34 -07:00
John Reck
7209deedcd Delete dead code
Bug: 22378829

Every time setText is called a BoringLayout is created.
BoringLayout internally creates a new Paint called mWorkPaint.

However, creating a Paint turns out to be somewhat substantial
amount of work, and mWorkPaint is never actually used. Deleting
this shaves off roughly 50ms and 1,000 object creations during
a fling on a listview.

Change-Id: I5d03402b9027df6ce0f3e58160752c66c69a4d2d
2015-07-09 21:25:52 +00:00
Raph Levien
a0419de2a9 Slightly more precise RTL check in BoringLayout.isBoring()
This patch refines the crude check for potential RTL characters, based
on ranges containing RTL scripts and format characters that affect
bidi. This will make it much less likely that a StaticLayout will be
chosen instead of a BoringLayout.

Bug: 22328919
Change-Id: I9a0ed9b3f3373069052de21c836b3372f175430f
2015-07-09 12:43:13 -07:00
Raph Levien
441fc0fc68 Merge "Fix problems with StaticLayout indentation" into mnc-dev 2015-07-06 18:08:41 +00:00
Raph Levien
c3f2f7b93b Clean up Hyphenator file reading
The old code made invalid assumptions about read() behavior and
failed to clean up properly in case of error. This patch changes the
file reading to use IoUtils.readFileAsString, which handles that.

Bug: 21020457
Change-Id: If9b54955c20a20a4ed5e8381d0c7e9c920d0639a
2015-07-06 09:01:36 -07:00
Raph Levien
2ea5290ffb Fix problems with StaticLayout indentation
The implementation of indendataion had two issues. First, the indent
pattern would restart on a new paragraph, which created problems when
a multi-paragraph text would flow into a shape. Second, the indents
didn't affect drawing position, which is ok for centered text but not
most of the other alignments. This patch fixes both.

Bug: 21904268
Change-Id: I53a3eb1c192fc0f8f0beace304832eed61b38497
2015-07-01 15:53:23 -07:00
Mady Mellor
10f9251736 Merge "Text selection: Fix word boundaries for languages without spaces" into mnc-dev 2015-06-26 17:33:22 +00:00
Keisuke Kuroyanagi
c1bd7da990 Merge "Fix: Ellipsis is wrongly applied or not applied in TextView." into mnc-dev 2015-06-26 05:11:25 +00:00
Makoto Onuki
c7a14e442d Fix Formatter.formatBytes() crash on non-EN locales
Bug 22012651

Change-Id: I21b1834a35647527002e01d76a7eb3a6a0354512
2015-06-25 14:46:25 -07:00
Seigo Nonaka
02ebcdb911 Merge "Revive Null check for backward compatibility." into mnc-dev 2015-06-23 08:31:12 +00:00
Mady Mellor
e264ac392a Text selection: Fix word boundaries for languages without spaces
WordIterator's getEnd/getBeginning methods does not support the needs
for word boundary detection in text selection. Consider the words
AABB (where AA and BB are each words). If getEnd is given the offset
on the boundary between AA and BB, it would return that offset since
it is the end of AA. For text selection we always want the "next end"
if available.

This CL adds two methods to word iterator that return the next end
and previous beginning.

This CL also alters the code in Start/EndHandle to use the x value
and current / prev line positions to determine if the user is
expanding or contracting the selection.

Bug: 21305292
Change-Id: I6e7a83e53e245d71e43d78f1957f844f2ed1cdfb
2015-06-22 16:46:29 -07:00
Jeff Sharkey
5cc0df214b Forget private partition keys.
When we forget a private partition, ask vold to also forget the key
for that partition GUID.  This means we need to track both the
filesystem UUID and the partition GUID for a private volume.

Bug: 21782268
Change-Id: Icda1cbb65539d61dacc663428daf3d1a2e4c313e
2015-06-22 14:07:10 -07:00
Seigo Nonaka
2ac124b790 Revive Null check for backward compatibility.
Bug: 21934529
Change-Id: I18e8f01be728e0400f3218a359b0dc9fd97fbbbd
2015-06-22 16:49:52 +09:00
Jeff Sharkey
a65a1582f5 Merge "Update file size formatting." into mnc-dev 2015-06-16 04:47:21 +00:00
Jeff Sharkey
b521feaed4 Update file size formatting.
Per UX, default strings should have space between value and units
resulting in "12.3 GB".  Add a formatting variant that returns the
various components for callers who want to build their own strings.

For now there is only one mounted emulated volume at a time, and
it's always the primary storage, so give it the default rootId to
keep old Uris working.

Change-Id: Ifcc72a91a6b397ee65dc92642153286186eb64ac
2015-06-15 21:39:28 -07:00
John Spurlock
9f206bec2d am 4393a7d2: am c0d84934: am 076c599f: am 1ad5c813: Fix typo in TtsSpan.
* commit '4393a7d2645cfb9097e616016c58887b9929be55':
  Fix typo in TtsSpan.
2015-06-15 22:50:51 +00:00
John Spurlock
076c599feb am 1ad5c813: Fix typo in TtsSpan.
* commit '1ad5c813211d4d855a0d5396855c80653480aaa4':
  Fix typo in TtsSpan.
2015-06-15 22:11:30 +00:00
John Spurlock
1ad5c81321 Fix typo in TtsSpan.
Change-Id: Ic32f141f0c51ee3bee8fd71464f104ef725de880
2015-06-15 17:24:57 +00:00
Keisuke Kuroyanagi
f4a3f3a03c Fix: Ellipsis is wrongly applied or not applied in TextView.
In current implementation, ellipsis is applied after
coptuting line breaks without limiting line count. As a
result, ellipsis can be skipped or- wrongly applied because
the breaks are computed to fit with the width.
With this change, the last line and overflowed part are
treated as a single line when the number of breaks exceeds
the remaining line count.

Bug: 6615676
Bug: 18514378
Bug: 20177499

Change-Id: I1d90e299404960cdd22746bad572411b119f7360
2015-06-15 16:34:53 +09:00
Jeff Sharkey
f491c72e4a Selected count string needs plurals.
Bug: 21717427
Change-Id: Ie0db8ac30244b022ca5838969fb085230bfc4499
2015-06-11 09:19:37 -07:00
Raph Levien
7d627eb9d2 Fix documentation of nextSpanTransition off by one
Improve wording of javadoc for nextSpanTransition() to accurately
reflect the actual implementation.

Bug: 19274845
Change-Id: I8f8fb6a21a8cbcc26fefb63164a6943431d16089
2015-06-10 15:19:50 -07:00
Alan Viverette
5299968517 Merge "Prevent poorly-extended ParcelableSpans from writing to parcels" into mnc-dev 2015-06-04 16:55:57 +00:00
Raph Levien
a6a082862b Rename setTextDir to setTextDirection
StaticLayout.Builder used "setTextDir" as a shorthand, but it's not
as clear as spelling it out. So, setTextDirection.

Bug: 21572282
Change-Id: Ia94476562d70678f963196b87bb63511d30836b6
2015-06-03 13:20:45 -07:00
Roozbeh Pournader
c021632e07 Merge "Load hyphenation data for more languages." into mnc-dev 2015-06-03 00:56:24 +00:00
Alan Viverette
a70d4a90a0 Prevent poorly-extended ParcelableSpans from writing to parcels
If a developer extends an existing ParcelableSpan and overwrites
writeToParcel, TextUtils will crash when attempting to unparcel
since the span type ID is not accurate. This CL makes a separate
framework-private method for writeToParcel to ensure that even if
a developer extends a ParcelableSpan class, they won't modify the
parceling or unparceling code that's tied to the span type ID.

Bug: 21274544
Change-Id: If4c3506a55999df7a3b6d87cb8d550235d7a02c6
2015-06-02 16:11:00 -07:00
Raph Levien
edb27f14ec Revert "Revert "Use getRunAdvance to position cursor""
This reverts commit 5730c97480.
2015-06-01 14:34:47 -07:00
Raph Levien
5730c97480 Revert "Use getRunAdvance to position cursor"
This reverts commit cb5499c850.

Bug: 21549197
2015-06-01 12:40:42 -07:00
Neil Fuller
3b7f9615b7 Merge "Fix javadocs based on recent case consistency change" into mnc-dev 2015-06-01 12:04:44 +00:00
Neil Fuller
a5e389ddd2 Fix javadocs based on recent case consistency change
Commit a40d2447b6f516116135ee7f126579771ba98a2c made the
case consistently "as for the beginning of a sentence".
This updates the docs to reflect that. Previously the
result depended on the string returned (e.g. "Tomorrow"
was capitalized in English) and the casing varied
within and between locales.

Bug: 20247811
(cherry-picked from commit 0e1c0e11e4)

Change-Id: I7b48958725b32b13bee00347585472f8073e7761
2015-06-01 13:02:18 +01:00
Raph Levien
cb5499c850 Use getRunAdvance to position cursor
TextLine used to use getTextRunAdvances on a substring to compute a
cursor position, but this had a number of problems, especially when
the substring is a wider than the full string (as can happen in
certain Tamil ligatures).

This patch changes the implementation to use getRunAdvance, which was
explicitly designed for this use case.

We should also change Layout.getHorizontal to use the dual
getOffsetForAdvance, but that's basically a performance optimization,
the functionality should be basically equivalent.

Bug: 21125816
Change-Id: I669b85eaecfbf6f7aa6c6a9dddbf1a210eb94571
2015-05-28 16:36:36 -07:00
Roozbeh Pournader
4d4202bf57 Load hyphenation data for more languages.
This loads hyphenation data for the languages we currently provide at
initialization time. It also has a poor man's locale fallback
mechanism for finding hyphenation patterns where the locale doesn't
exactly match what may be available and caches the results.

Bug: 20088132
Change-Id: If7b2a8d5295df9cb2bdae7418df27bf77fb44e58
2015-05-28 13:03:26 -07:00
Roozbeh Pournader
f156cb31c0 Make unicodeWrap() return null if the input string is null.
Previously, a NullPointerException was raised if the input was null.

Bug: 12894042
Change-Id: I5c5db484e5659659c1da91079adcba773ba7d83d
2015-05-16 18:50:18 +00:00
Mady Mellor
21623faa44 Merge "Fix issue where handle is in front of word rather than end of word" into mnc-dev 2015-05-13 17:34:13 +00:00
Roozbeh Pournader
95c7a13f2a Add hyphenationFrequency attribute to TextView and StaticLayout.
This patch adds plumbing to TextView and StaticLayout to control the
frequency of automatic hyphenation used in laying out paragraphs.

Bug: 21038249
Change-Id: Ib45de190eb0a1ed738e69fd61f2b39561b11aec7
2015-05-12 14:56:57 -07:00
Mady Mellor
58c9087137 Fix issue where handle is in front of word rather than end of word
Previous getWordEnd and getWordStart functions would return a boundary
rather than a word end / start boundary in some cases. This behavior is
most evident when moving between short lines -- the handle would go to
the next boundary rather than the word end on the next line (and the
start handle would go to the word end rather than the word start on
the prev line).

This CL ensures that word or punctuation boundaries are returned and moves
most of the punctuation boundary logic into WordIterator since it makes
a bit more sense there.

Bug: 21030788
Change-Id: I96c6aff7f2c213aa3c4f66ac87ca913ca16fd347
2015-05-12 11:09:37 -07:00
Mady Mellor
6c7b4ad690 Consider punctuation treatment when selecting text.
This treats punctuation as "words", so groups of punctuation will be
selected together, i.e. "Hmm... yay!!!" would be treated as four words:
Hmm-...-yay-!!!

Bug: 19950062
Change-Id: Ic9514c524092734fad1abdf19a736bfa1406157b
2015-05-07 21:05:36 +00:00
Raph Levien
6402dc7e4a Merge "Clear all StaticLayout.Builder fields on pool recycle" into mnc-dev 2015-05-06 21:35:13 +00:00