Commit Graph

957 Commits

Author SHA1 Message Date
John Reck
44e8d60f53 Super-fast getLineWidth for BL
Bug: 24678704
Change-Id: I952964f450d19b1e127753d00833eb7b34473bba
2015-10-05 15:44:04 -07:00
Raph Levien
091dba2de1 Load binary hyphen data files
Support for loading the pre-compiled binary format for hyphenation
patterns.

Bug: 21562869
Bug: 21826930
Change-Id: Iaeaa9c9ac9dac236af6b0d7894c2e2396bc8447d
2015-09-30 17:37:54 -07:00
Keisuke Kuroyanagi
9f18132aae Merge "Fix: Cursor can be at an invalid offset in EditText." 2015-08-28 06:57:22 +00:00
Keisuke Kuroyanagi
00ad16d1cd Fix: Cursor can be at an invalid offset in EditText.
"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
2015-08-27 18:15:48 +09:00
Roozbeh Pournader
4bae2038cd Merge "Cleanup android.text.TextUtils a little." 2015-08-21 19:04:29 +00:00
Roozbeh Pournader
4059d7dbfa Update tests and support negative values in formatBytes().
This updates the tests to match the older commit
f723017481 and also adds support for
negative values.

Bug: 23191381
Bug: 11237727
Change-Id: Ib9a1f10031b730ee460658949b388c779cefa041
2015-08-20 17:59:30 -07:00
Roozbeh Pournader
3efda95072 Cleanup android.text.TextUtils a little.
- Clarify that getTrimmedLength() only considers ASCII control
  characters as control characters.

- Deprecate getReverse() instead of trying to fix it, as it's really
  not meaningful for internationalized text.

- Support non-BMP characters in isDigitsOnly().

Change-Id: I947c449b48c252ecc7f7299145f6f8fbad86004f
2015-08-18 14:04:43 -07:00
Roozbeh Pournader
692adf6ae6 Merge "Fix unintentional NPE in SpannableStringBuilder." 2015-08-13 04:41:48 +00:00
Roozbeh Pournader
cd217b8ace Fix unintentional NPE in SpannableStringBuilder.
Previously, when getSpans() was called with a null parameter, an
unintentional NullPointerException would be thrown.

Now, we explicitly return an empty array of Objects.

Bug: 19805521
Change-Id: I52f3ae08c2bcf62f6a4d0c01f0fe08ad1134abb8
2015-08-12 20:14:43 -07:00
Roozbeh Pournader
5e9ed365ad Support strikethrough text in Html.fromHtml().
All the three tags, <del>, <s>, and <strike> are now converted to
strikethrough text.

Bug: 21025743
Change-Id: I62dc9793223e266f6e2181169766fde8be0e2aa7
2015-08-12 19:34:47 -07:00
Roozbeh Pournader
f723017481 Make FormatBytes() not use decimal points for size <= 900.
Previously, values like 0 were being formatted like "0.00 B".

Bug: 11237727
Change-Id: Ia90ae0a2cde9fa5993fa9b5b131f38b56f9dc34a
2015-08-11 14:35:09 -07:00
Roozbeh Pournader
1cc2acf7fa Use Character.codePointAt().
We were mistakenly using CharSequence#codePointAt().

Change-Id: Id655fd4993f70140cde54ea8e5b4d39111402046
2015-08-11 10:37:07 -07:00
Roozbeh Pournader
a93880ee77 Support non-BMP chars in TextUtils.isGraphic(CharSequence).
Also deprecate TextUtils.isGraphic(char), since one-code-unit APIS
should not be used for anything in the modern Unicode era.

Bug: 7381642
Change-Id: If4dc573fe5ac870152374ded64fc83594e8dd37e
2015-08-10 17:23:05 -07:00
Roozbeh Pournader
c42363ad30 Avoid creating unnecessary builder objects in BidiFormatter.
Previously, BidiFormatter.getInstance() created an unnecessary
pass-through builder object, which was used to return a static
already existing BidiFormatter.

Now, we just return the same static BidiFormatter, without going
through a builder, so we can save some extra allocations.

Bug: 10022222

Change-Id: Ibcb6aac1c1e16d9ec00e93824fa063f8dccdf8cb
2015-08-10 14:06:07 -07:00
Roozbeh Pournader
feaa7c2734 Merge "Remove TextUtils.join(Iterable<CharSequence>)." 2015-08-10 18:54:59 +00:00
Roozbeh Pournader
707d363174 Merge "Make Hyphenator#get() return an object." 2015-08-10 18:54:24 +00:00
Roozbeh Pournader
085419b1ec Remove TextUtils.join(Iterable<CharSequence>).
The method was deprecated and had only one caller, which is being
replaced with an inline copy of this at the same time.

Bug: 6823087
Change-Id: I7c5b9840ba50c1a9f167102966de63ef1040ab88
2015-08-10 11:36:03 -07:00
Roozbeh Pournader
bd87e94100 Fix and deprecate TextUtils.join(Iterable<CharSequence>).
There seems to be only one caller of this signature, and even that is
in a deprecated method, so it should be safe to deprecate this.

The new implementation uses ICU for the format string and so removes
the need for a localized string, although it's still a hack and is
probably slower. It's added here since we may actually want to clean
it up later and use it for an improved simple list formatter.

Bug: 6823087
Change-Id: I2aa1af9b170e41da840d9d7bc663df06fb96d136
2015-08-07 16:44:33 -07:00
Roozbeh Pournader
e7eac6f540 Make Hyphenator#get() return an object.
Previously, a native pointer was returned. After this change, callers
should call getNativePtr() if they want to get the native pointer instead.

Bug: 21492297
Change-Id: I745bd88e6e8c86078fffb07f90f8d8f24215410c
2015-08-07 15:13:30 -07:00
Roozbeh Pournader
1e872ec0d6 Merge "Support all RTL scripts in getLayoutDirectionFromLocale()." 2015-08-07 21:05:14 +00:00
Roozbeh Pournader
463b48203a Support all RTL scripts in getLayoutDirectionFromLocale().
Previously, only the languages written in Arabic and Hebrew were
considered right-to-left. Now, ICU is used to return the direction
of the language, which not only support other right-to-left scripts
(such as Thaana), but also has better logic to determine the
direction of the locale and uses caching to improve the speed.

Bug: 22559274
Change-Id: I760be7984a9b35ea77d59ca84a220798e205af36
2015-08-07 13:56:54 -07:00
Roozbeh Pournader
112d9c7f11 Remove EmojiFactory and its mentions from frameworks.
Bug: 18134313
Bug: 20158206
Change-Id: If46cdbd9d558e6592280b2b95f00b87d04de70a2
2015-08-07 12:57:01 -07:00
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