Commit Graph

969 Commits

Author SHA1 Message Date
Keisuke Kuroyanagi
97af673e1f Move mouse selection handling logic to Editor.
- 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
2015-12-10 05:13:40 +00:00
Neil Fuller
568f4de11a Merge "Fix @code escapes" 2015-12-03 09:44:01 +00:00
Roozbeh Pournader
c7dcec43d6 Make Hyphenator load Spanish hyphenation patterns
The pattern files themselves are added to the
external/hyphenation-patterns repo.

Change-Id: Icf37191f1217b7869f49f8ea63174341662caacf
2015-12-02 12:25:07 -08:00
Neil Fuller
71fbb81b14 Fix @code escapes
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
2015-12-02 14:24:11 +00:00
Keisuke Kuroyanagi
ead6ba3a63 Stop making a reversed selection with mice.
Bug: 24889605
Bug: 24475013
Change-Id: I6d39e050656dc28e523fab862c84054169e6300b
2015-10-27 17:26:07 +09:00
Keisuke Kuroyanagi
742bd40328 Merge "Fix: Last char can be excluded from mouse selection." 2015-10-27 05:46:47 +00:00
Roozbeh Pournader
ca9dbf596d am ebdf60e7: am 0221328c: am b3538082: am 5362f273: Merge "Fix line height problem with inline images in StaticLayout." into mnc-dr-dev
* commit 'ebdf60e7c800b2ccda01887a304ddc0edce0361d':
  Fix line height problem with inline images in StaticLayout.
2015-10-16 22:20:01 +00:00
Roozbeh Pournader
431e506b53 Fix line height problem with inline images in StaticLayout.
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
2015-10-16 02:49:13 -07:00
Roozbeh Pournader
63aa02e47f Merge "Load binary hyphen data files" into mnc-dr-dev 2015-10-15 00:18:36 +00:00
Raph Levien
35e026929b Load binary hyphen data files
Support for loading the pre-compiled binary format for hyphenation
patterns.

Bug: 21562869
Bug: 21826930
Bug: 24570591
Change-Id: Iaeaa9c9ac9dac236af6b0d7894c2e2396bc8447d
(cherry picked from commit 091dba2de1)
2015-10-14 19:11:33 +00:00
Roozbeh Pournader
0453112de6 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
Bug: 24570591
Change-Id: I745bd88e6e8c86078fffb07f90f8d8f24215410c
(cherry picked from commit e7eac6f540)
2015-10-14 19:10:44 +00:00
Keisuke Kuroyanagi
45a60d1a43 Fix: Last char can be excluded from mouse selection.
When a mouse is used, isTouchSelecting for ACTION_UP always
returns false with current implementation because all
DragState spans have been removed in Touch#onTouchEvent.

Change-Id: Ie27a2bb860e9ddeb71dafff361c734a7c727102d
2015-10-13 11:02:26 +00:00
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