Commit Graph

1182 Commits

Author SHA1 Message Date
TreeHugger Robot
ec8c01d767 Merge "Switch formatElapsedTime to use ICU's MeasureFormat" 2017-06-23 21:51:31 +00:00
Roozbeh Pournader
2ee9075462 Switch formatElapsedTime to use ICU's MeasureFormat
Previously, localizable strings were used instead, causing various
difficulties and inconsistencies. The formatting code also
hard-coded the pluralization rules for English and used it for all
locales.

Now we use ICU's MeasureFormat. There are some small formatting
differences with the previous code, but they are not important,
especially since the old strings were not necessarily well-thought.

Bug: 36994779
Test: adb shell am instrument -w -e package android.text com.android.frameworks.coretests/android.support.test.runner.AndroidJUnitRunner
Change-Id: Ie8cb119a76e89e2ee971353761fbd54e0d9a556c
2017-06-20 16:50:01 -07:00
Roozbeh Pournader
ef7cfa17e7 Pass all locale information down to Minikin
Previously, locale lists and LocaleSpans were ignored in deciding line
breaking and hyphenation in layouts.

Now, we pass both changing locale information and the whole locale
list to Minikin.

Fixes: 21571721
Bug: 25122192
Test: adb shell am instrument -w -e package android.text com.android.frameworks.coretests/android.support.test.runner.AndroidJUnitRunner
Change-Id: Ia93b0b7cbe54de65bb0ec4937e65cc7993559a6f
2017-06-20 14:19:24 -07:00
Roozbeh Pournader
dc8f3ef561 Make Linkify use the SIM card's country for phone numbers
Previously, it was using the locale's country code, which doesn't
make sense, since the locale's country code means which dialect of
the language the system should function in.  We should use the SIM
card's country code instead.

Change-Id: Ib942f92f3218c943669fc6150d6cc6b4e340b451
Fixes: 30000652
Test: cts-tradefed run cts-dev --module CtsTextTestCases
Test: adb shell am instrument -w -e package android.text com.android.frameworks.coretests/android.support.test.runner.AndroidJUnitRunner
Test: Manual
2017-06-13 16:39:10 -07:00
Roozbeh Pournader
aa8380fa22 Merge "Internationalize InputFilter.AllCaps" 2017-06-09 22:23:52 +00:00
Roozbeh Pournader
554585e08d Merge "Get underline position and thickness from the font" 2017-06-09 21:44:59 +00:00
Roozbeh Pournader
205a993928 Internationalize InputFilter.AllCaps
The new code support non-BMP characters, as well as locale-specific
uppercasing and fine-grained span copying.

The modern capitalization code in AllCapsTransformationMethod is
moved to TextUtils now, so InputFilter.AllCaps can share it.

Fixes: 37222101
Test: New CTS and core tests are added.
Test: cts-tradefed run cts-dev --module CtsTextTestCases
Test: adb shell am instrument -w -e package android.text com.android.frameworks.coretests/android.support.test.runner.AndroidJUnitRunner

Change-Id: I021ff2a97a60396fb1b6e4940d91d3cd6ccb6196
2017-06-08 15:38:28 -07:00
Roozbeh Pournader
ca8a04a366 Get underline position and thickness from the font
Previously, font underline position and thickness were fixed in Android.
Although a custom font may have specified a different value, such a value
would never be used. Now we use the values from the font if they are
provided and fall back to the old default values only if needed.

Bug: 62353930

Test: adb shell am instrument -w -e package android.graphics com.android.frameworks.coretests/android.support.test.runner.AndroidJUnitRunner
Test: adb shell am instrument -w -e package android.text com.android.frameworks.coretests/android.support.test.runner.AndroidJUnitRunner
Test: cts-tradefed run cts-dev --module CtsTextTestCases
Test: Manual
Change-Id: I6bf21000dd69a2780c894b231638bc0c122e41f4
2017-06-08 14:13:57 -07:00
TreeHugger Robot
e5d6838e0a Merge "Early exit if there are no spans affecting display" 2017-06-07 22:25:59 +00:00
Roozbeh Pournader
08836d4ca5 Early exit if there are no spans affecting display
In TextLine#handleRun(), exit early and shape the text as one whole
if there were spans, but none of them were a subclass of
MetricAffectingSpan or CharacterStyle.

Change-Id: I859c896ddb9c4828bfddf200e913e98262da6ea3
Fixes: 30985144
Test: cts-tradefed run cts-dev --module CtsTextTestCases
Test: adb shell am instrument -w -e package android.text com.android.frameworks.coretests/android.support.test.runner.AndroidJUnitRunner
2017-06-07 12:12:30 -07:00
Roozbeh Pournader
fd8c22d513 Move underline thickness and position computation to Paint
Also, in TextLine, fix underline color and thickness to come from the
underline info rather than the TextPaint object.

Bug: 32907446
Bug: 62353930
Test: Manual
Test: cts-tradefed run cts-dev --module CtsTextTestCases
Test: cts-tradefed run cts-dev --module CtsWidgetTestCases
Change-Id: I259e9cf635a7056ccd367baa77c03100c69e3b98
2017-06-05 15:57:14 -07:00
Roozbeh Pournader
538de5bb3b Make underlining spans independent of actual class
Previously, we had singled out UnderlineSpan for special treatment
for proper kerning at span boundaries. That had the limitation that
any other span that used underlining, or even subclasses of
UnderlineSpan were not getting the fix.

With this CL, we actually look at all the effects of applying a
span's updateDrawState() and if the changes were only in underlining,
we merge the pieces and call handleText() on the merged chunk of
text.

Change-Id: I829162c758192b80594f164d1105699224b627ba
Bug: 32907446
Test: cts-tradefed run cts-dev --module CtsTextTestCases
Test: cts-tradefed run cts-dev --module CtsWidgetTestCases
Test: manual
2017-06-01 16:45:33 -07:00
Roozbeh Pournader
6f4b6fa44d Merge "Revert "Don't let UnderlineSpans affect text width"" 2017-06-01 18:33:07 +00:00
Siyamed Sinir
702c9f92fc Revert "Don't let UnderlineSpans affect text width"
This reverts commit 203ffaa103.

Bug: 62234081
Change-Id: I8dd95dba52f268fb57f55e315431cedbc5128adc
2017-06-01 18:25:40 +00:00
Roozbeh Pournader
931ed4dab9 Merge "Don't let UnderlineSpans affect text width" 2017-05-30 21:42:24 +00:00
Roozbeh Pournader
203ffaa103 Don't let UnderlineSpans affect text width
Previously, text that was partially annotated with an UnderlineSpan
could have a different width than text without it, since underlined
text was separated into a separate piece of text and was measured
separately, causing kerning at the span boundaries to disappear.

Change-Id: I118de8524c500fb6a4b05b1bf65fe93dc67f204c
Bug: 32907446
Test: cts-tradefed run cts-dev --module CtsTextTestCases
Test: manual
2017-05-24 13:35:19 -07:00
Roozbeh Pournader
fc77869ee0 Set up empty lines for DynamicLayout#updateBlocks() tests
The changes in I666da5eeb39f780c341597f347bfcba21eb34295 introduced
the concept of lines that need to be always redrawn, but it broke
tests for DynamicLayout#updateBlocks() that didn't need to set up the
actual lines.

Now, during the test setup, we insert empty lines to match the number
of lines needed.

Test: adb shell am instrument -w -e class android.text.DynamicLayoutBlocksTest com.android.frameworks.coretests/android.support.test.runner.AndroidJUnitRunner
Test: adb shell am instrument -w -e class android.text.DynamicLayoutTest#testGetBlocksAlwaysNeedToBeRedrawn_thai com.android.frameworks.coretests/android.support.test.runner.AndroidJUnitRunner
Test: adb shell am instrument -w -e class android.text.DynamicLayoutTest#testGetBlocksAlwaysNeedToBeRedrawn_en com.android.frameworks.coretests/android.support.test.runner.AndroidJUnitRunner
Test: cts-tradefed run cts-dev --module CtsTextTestCases
Change-Id: I4bfc82db4beef1b740433a25a3ae29201f54d9d3
Fixes: 38029583
2017-05-23 16:18:58 -07:00
Eugene Susla
4a34f9c2f6 Print A11yEv. Content Change Types in DEBUG toString
Test: Enable debug, and ensure changeTypes are properly displayed
Change-Id: I1bf6a9f56a72e867a0bc967a5e3527eb4dc83952
2017-05-17 11:13:05 -07:00
Abodunrinwa Toki
3de110bbb7 Remove redundant TextClassificationService
Text classification is now being done entirely in the app's proccess.
See android.view.textclassifier.TextClassificationManager
Reverts Ic428d00f291e268211866b3fc6b7acbc3eb04e1e

Test: bit FrameworksCoreTests:android.view.textclassifier.TextClassificationManagerTest
Fixes: 36852122
Change-Id: Iffff3ab6e7d3b761576eb6bdcd5032db34b7a1b2
2017-05-09 13:51:03 +01:00
TreeHugger Robot
4972daf992 Merge "Don't crash in TextUtil.concat() with paragraph spans" into oc-dev 2017-05-06 01:41:03 +00:00
Roozbeh Pournader
e57886e659 Don't crash in TextUtil.concat() with paragraph spans
This switches TextUtils.concat() to use SpannableStringBuilder
if there are any spans in the input strings. As a result, we can
avoid crashes when concatenating two CharSequences can result in
paragraph spans that now don't happen to be at paragraph boundaries.

Also document the exact behavior of the method for edge cases based
on the previous implementation.

Change-Id: I9caffbe95ed729b9c10d63a9e7d22b1e8c7185a3
Fixes: 28271770
Test: CTS tests added and old CTS tests continue to pass.
Test: cts-tradefed run cts-dev --module CtsTextTestCases --test android.text.cts.TextUtilsTest
2017-05-05 11:04:29 -07:00
Felipe Leme
a8fce3b29e Don't copy NoCopySpans for assist and autofill
For AssistStructure, and AutofillValue, create a copy of the text in 
setText and forText methods if it is a Spanned.

Fixes: 36838999
Test: cts-tradefed run cts -m CtsAutoFillServiceTestCases
Test: cts-tradefed run cts -m CtsAssistTestCases
Test: cts-tradefed run cts --test android.widget.cts.TextViewTest -m \
      CtsWidgetTestCases

Change-Id: I52e780fa9baa17c375d3945dc714171f41fd7db5
2017-05-02 13:33:07 -07:00
Abodunrinwa Toki
ea6cb1215e Add "Paste as plain text" in TextView's toolbar.
Test: bit FrameworksCoreTests:android.widget.TextViewActivityTest
Bug: 36179795
Change-Id: Iee0502678adcfb9de58c107b9247a528718b2c40
2017-05-02 15:16:26 +01:00
Abodunrinwa Toki
3f3354e087 Undeprecate WebView.findAddress
Reverts I772961bd20bff4817a060f14a843abeceb55ac92
Until we bring back TextClassifier.getLinks
See I275a9d055ef0ab68f3ca339c37ee939257c4bd54

Test: none
Bug: 22362008
Bug: 37565246
Change-Id: I2948f22cf4c3462491f47376af48624697703969
2017-04-24 14:41:14 +00:00
Phil Weaver
23161e7170 Make a11y clickable span work after node recycle
Services recycle nodes when gathering possible actions
for users to take. It's very confusing for them if they
can't recycle the node without breaking their ability
to activate a clickable span inside it.

Making ClickableSpans used for accessibility independent
of their parent nodes.

Also adjusting the value used for invalid window ids to
come from AccessibilityWindowInfo. I must have missed this
in an earlier cleanup. I needed the value for the spans,
so I figured I might as well use the correct one.

Bug: 37004527
Test: Now recycling the node in the a11y cts test.
Change-Id: I6de4e98a182dd43c4fcd0430a3c082fcc8e458c7
2017-04-19 14:08:34 -07:00
Roozbeh Pournader
d39388219f Merge "Revert "Make selection end handle stick to selection at line end."" into oc-dev 2017-04-12 23:22:40 +00:00
Selim Gurun
c68b1a8aef Merge "Deprecate findAddress() method" into oc-dev 2017-04-12 21:05:07 +00:00
Siyamed Sinir
37bfd57ead Merge "Do not enforce paragraph constraint for copy ctr" into oc-dev 2017-04-12 18:09:58 +00:00
TreeHugger Robot
feaa8b0f01 Merge "Remove unused public APIs." into oc-dev 2017-04-12 17:31:44 +00:00
Roozbeh Pournader
7557a5a090 Revert "Make selection end handle stick to selection at line end."
This reverts commit 7c263ddd58.

Fixes: 35944608
Bug: 21305922
Test: Manual
Test: Updated CTS and core tests pass.
Change-Id: Ic840f8771c3d5850f4f6f44ea199b144cac740c0
2017-04-11 18:40:44 -07:00
Roozbeh Pournader
b2d00340fd Keep spans while transforming to uppercase
We now use ICU's new functionality for casing edits to preserve
the spans while applying AllCapsTransformationMethod.

Test: Manual
Test: CTS tests added and pass
Bug: 7198872
Bug: 19047649
Bug: 19713814
Bug: 34853618
Bug: https://code.google.com/p/android/issues/detail?id=67509
Change-Id: I0df388e79894961efb272d497f1dcc0570a6c085
2017-04-11 13:49:18 -07:00
Seigo Nonaka
042741ce4f Remove unused public APIs.
By I9ccafe7a53935960566243e2856e166878ca59ae, FontManager was gone.
So FontConfig is no longer need to be parcelable.
We can drop Parcel interface from FontVariationAxis.

Bug: N/A
Test: N/A
Change-Id: I33e92abf1e1063af312f0b7d9d6b8bd938d09c0e
2017-04-11 13:02:49 -07:00
Selim Gurun
9858e5372a Deprecate findAddress() method
FindAddress method only ever worked on US addresses and being a part
of WebView API, it required the users that did not use WebView otherwise
to pay a heavy penalty. Further, it was also used by Linkify.

The new way to find addresses is using TextClassifier.

Bug: 22362008
Test: WebView.findAddress.

Change-Id: I772961bd20bff4817a060f14a843abeceb55ac92
2017-04-11 11:18:49 -07:00
Siyamed Sinir
a6284a20b5 Do not enforce paragraph constraint for copy ctr
Update SpannableStringBuilder, SpannedString and SpannableString classes
so that they don’t enforce paragraph constraint for copy constructors.
If a paragraph constraint is not satisfied for a span, that span is not
copied. Before this change it would throw an exception.

Test: New tests added for SpannableStringBuilder and SpannableString
      cts-tradefed run cts -m CtsTextTestCases
Bug: 36511794

Change-Id: I62abf08a8d4fe7e342ed97b8e8c3a577a9397e39
2017-04-11 09:57:02 -07:00
Roozbeh Pournader
9fe1c12127 Special-case English for DateTime and Time key listeners
Because English time patterns use uppercase letters by default (and a
comma to separate date and time when both are represented), we were
concluding they need internationalized input. Although they
literally do, let's keep the world simple and assume they don't need
internationalized input.

Compared to Nougat, we will now accept uppercase AM and PM and comma
for English if the IME allows them, we just continue to not signal
that an internationalized layout is needed.

Test: CTS tests pass
Bug: https://code.google.com/p/android/issues/detail?id=2626
Bug: https://code.google.com/p/android/issues/detail?id=82993
Bug: 8319249
Bug: 33276673
Bug: 34394455
Bug: 37079150
Change-Id: I82bfde323ba49ae1a27ff5c2e729063b7d81dcc8
2017-04-06 14:48:28 -07:00
TreeHugger Robot
94b6b532c0 Merge "Use text input for various internationalized listeners" into oc-dev 2017-04-05 23:32:55 +00:00
Roozbeh Pournader
889c6503a1 Use text input for various internationalized listeners
Since the characters that need to be entered for an internationalized
input type may not be available on the old non-internationalized
layouts, switch to the full text layout if there are any such
characters.

TextView is also modified to call the locale-aware listeners if
the target SDK is set to O or later.

Test: Manual
Bug: https://code.google.com/p/android/issues/detail?id=2626
Bug: https://code.google.com/p/android/issues/detail?id=82993
Bug: 8319249
Bug: 33276673
Bug: 34394455
Change-Id: I544bf0cc893a475ab5bf88cbad01cb981c6fef91
2017-04-05 14:07:22 -07:00
TreeHugger Robot
04fc05cd66 Merge "Change justification parameter from boolean to int." into oc-dev 2017-04-04 18:29:58 +00:00
Seigo Nonaka
4b4730d90e Change justification parameter from boolean to int.
Bug: 35766005
Bug: 35764323
Test: Manually done
Change-Id: Ic6d78bb9a3213160cd013f1ca8294307872bf0d0
2017-04-03 14:52:04 -07:00
Seigo Nonaka
ff55115121 Reorganize font enumeration API.
This CL cleans up APIs around font variation settings.
- Remove FontConfig and FontManager public API.
- Remove FontManagerService from system service.
- Extract inner class FontConfig.Axis as top-level class FontVariationAxis.
  This is used by Typeface.Builder public API to create new Typeface.
- Introduce and expose FontVariationAxis utility functions from/to string.
- Throws if the invalid font variation settings is passed.

Test: android.text.cts.FontVariationAxisTest passes
Test: android.graphics.cts.TypefaceTest passes
Test: android.graphics.cts.PaintTest passes
Change-Id: I9ccafe7a53935960566243e2856e166878ca59ae
2017-04-03 13:55:07 -07:00
Roozbeh Pournader
ce93f31035 Override bidi property of new emojis
In BidiFormatter and AndroidBidi, treat emojis new to
Unicode 10.0/Emoji 5 as bidi class ON.

Test: Manual
Bug: 32952475
Change-Id: I1a40c6ee2b6e9d91c9d1e5b64faca6d16301fe93
2017-03-31 18:34:58 -07:00
Seigo Nonaka
c0cf4f09f4 Do not use many FDs in FontManagerService.
Currently there are over 170 font files are installed in system directory.
Opening 170+ files and keep them is not unacceptable. Pass URI instead.

At the same time, this CL hides full font path from FontConfig since
/system/fonts directory will be deprecated in future.

Bug: 36660849
Test: android.text.cts.FontManagerTest passed
Change-Id: I1d216dc9c6dec702a4ce3b946bfda6dcbe12b7fe
(cherry picked from commit 455f1bfc05)
2017-03-29 17:01:16 +00:00
Seigo Nonaka
3e2936413d Update setJustify API reference.
Bug: 35766005
Bug: 35764323
Test: N/A
Change-Id: I2d4b398479cdb3ac87257de95eb6a02f03c639bf
2017-03-23 10:30:55 -07:00
Seigo Nonaka
b2c20d880d Unhide Typeface construction APIs.
These APIs are necessary to construct Typeface from various combination
TTC index, variation settings, etc.

Bug: 33062398
Test: android.graphics.cts.TypefaceTest passes
Change-Id: Ie069700ed4f67efbec55331bef867f94d58e2a61
2017-03-21 19:55:38 -07:00
Seigo Nonaka
20e5d91739 Expose Typeface creation APIs with ttc and font variation.
Introduce Builder class for creating Typeface from various
sources with optional TTC index and font variation settings.

Bug: 33062398
Test: Manually verified new Builder create Typeface.
Change-Id: Ia23ee6a73516707d854c7387fe75fbb22f80673d
2017-03-21 13:27:33 -07:00
Roozbeh Pournader
1bf3ee56f0 Update Emoji.java to use ICU
Overrides have been added to update the data to Emoji 5.0, since our
version of ICU only supports Emoji 4.0.

Test: CTS tests continue to pass.
Bug: 27365282
Bug: 30874706
Change-Id: I7c791e1e75ea3510b36f258c1e1c7184051d6d3a
2017-03-17 15:15:58 -07:00
Roozbeh Pournader
16a8f3762c Remove U+1F93B MODERN PENATHLON and U+1F946 RIFLE from emoji
These had remained in Emoji.java although they were removed from Unicode
emoji. The data still needs to be updated to Emoji 5.0, but that will be
done in another CL.

Test: not needed
Bug: 28678294
Change-Id: I491c4bba107b960fb1efccbe19630ab274aa6e29
2017-03-17 14:38:46 -07:00
Seigo Nonaka
ac873c9f25 Clean up public FontConfig APIs
This CL contains following clean up:

- Hide unnecessary constructors.
- Change List<XX> to XX[] since actually all fields are immutable.
- Change font's variant type from String to int.
- Decouple resource related members to FontResourcesParser.
- Add NonNull/Nullable to all fields.

Test: ran android.content.res.FontResourcesParserTest

Change-Id: If456266ffff86d41342572a19662cc8f3cd13181
2017-03-15 10:16:55 -07:00
Selim Cinek
b18296c88f Merge "Fixed that indents on an ellipsis of a staticlayout were dropped" 2017-03-14 20:11:14 +00:00
Selim Cinek
365ec09695 Fixed that indents on an ellipsis of a staticlayout were dropped
If a layout had an ellipsis and in addition also indents,
the indents were ignored and the text would go over the indents.

Test: runtest -x cts/tests/tests/text/src/android/text/cts/StaticLayoutTest.java
Test: runtest -x cts/tests/tests/text/src/android/text/cts/DynamicLayoutTest.java
Test: runtest -x cts/tests/tests/widget/src/android/widget/cts/TextViewTest.java
Change-Id: I4cc89dad8301f6b1bb46a479395fd72c8476e477
Fixes: 36081667
2017-03-13 15:24:48 -07:00