Commit Graph

1733 Commits

Author SHA1 Message Date
Victor Chang
0d34d850fd Enable DISALLOW_DUPLICATE_FIELD_IN_SKELETON since U
It was supposed to be enabled in S, but we missed it due to
https://r.android.com/1490737

Test: android.text.format.DateFormatTest
Change-Id: I0f6495bf2e4434396606743da1e32a39a54a0b19
2022-09-13 15:49:09 +01:00
Victor Chang
fe5155786f Merge "Re-land "Switch file size formatters to use ICU's MeasureFormat"" am: b284c36224 am: 6d5f7f22c4
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/2100171

Change-Id: I1dacfb85cbc5886c8fd8f917085a2ebd943170cd
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-05-24 11:20:54 +00:00
Roozbeh Pournader
988cb5a32d Re-land "Switch file size formatters to use ICU's MeasureFormat"
Re-land http://ag/2443141 because the over-translation issue should be
resolved now.

Use ICU's MeasureFormat to the degree possible for formatting file
sizes.

Bug: 36994779
Bug: 71580745
Bug: 217592956
Test: atest FrameworksCoreTests:android.text
Test: atest CtsTextTestCases
Change-Id: If3416ec38cf18c0441576643bfab850148e18c8e
2022-05-17 17:05:48 +01:00
Ling Ma
8827b92855 Merge changes from topic "truncate operator name" am: ffa0f982b6 am: 9cf73e369d am: eb897b1d85
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/2004810

Change-Id: Ie1a67a1a9fae4dbbc321755f7ec9bde8bb84613f
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-04-01 22:54:46 +00:00
Ling Ma
58d9786a64 Add truncateStringForUtf8Storage()
Test: manual
Bug: 210502588
Change-Id: I5d4ded0cb30151bc567cfedcdb1bbbdb9abdca9b
2022-03-31 18:57:05 -07:00
TreeHugger Robot
90b2bfd4bc Merge "Fix wrong Nullability of BoringLayout new API introduced in API33" into tm-dev 2022-03-22 17:00:27 +00:00
Seigo Nonaka
5cc42bcb59 Fix wrong Nullability of BoringLayout new API introduced in API33
Bug: 225695033
Test: N/A
Change-Id: I93d3fc3041e862ad5f6064ac517e9cdbd23f1599
(cherry picked from commit c93d6b49b5)
2022-03-21 23:28:01 +00:00
Seigo Nonaka
418393399c Set useFallbackLineSPacing into member value
Bug: 225727260
Test: atest BoringLayoutTest
Change-Id: Ifc7b2e3920d770a6b59cc4ea191560db057d2363
2022-03-21 05:50:31 +00:00
James.cf Lin
396c789426 Update the text wrapping API.
1) Update the LineBreakConfig class to be immutable.
2) Do not return null in the PrecomputedText.Params#getLineBreaiConfig API

Bug: 216638444
Test: atest TextViewTest; atest MeasuredTextTest; atest PrecomputedTextTest; atest TextViewPrecomputedTextTest; atest StaticLayoutLineBreakingVariantsTest
Merged-In: I93bcb6ebc35344e34e9bb8a24df375aa7b3a8d81
Merged-In: I07766137ff6639c7d4acaad07dbcf11a2841cdb0
Change-Id: I07766137ff6639c7d4acaad07dbcf11a2841cdb0
2022-03-10 09:58:40 +00:00
Seigo Nonaka
9babbc0c59 Merge "Improve BoringLayout#isBoring for PrecomputedText" 2022-02-16 01:20:03 +00:00
Xin Li
5ad6db7742 Merge sc-v2-dev-plus-aosp-without-vendor@8084891
Bug: 214455710
Merged-In: I8cfa435bb6233818adb9cc99dadeeb06a03443d5
Change-Id: Ib93992d88fd1704179009a3872798b9e7b83a6d1
2022-02-11 07:25:43 +00:00
TreeHugger Robot
1a2dee2c84 Merge "Recycle obtained TypedArrays" 2022-02-10 22:11:25 +00:00
Nikolas Havrikov
4407d1f383 Recycle obtained TypedArrays
Bug: 218835043
Test: make
Change-Id: I27c679c164920dc4b1096a316432f64501a85ae5
2022-02-10 15:04:20 +01:00
Alan Viverette
406e0f6553 Migrate frameworks/base javadocs references to androidx
Does not remove Support Library artifacts from docs classpath (ApiDocs.bp)
because they are still used in development/samples, which is not as easy
to migrate as javadoc.

Bug: 158779503
Test: make docs
Exempt-From-Owner-Approval: Mass find/replace for androidx migration
Change-Id: Icf7f53ec36a0e970413352e2ebf40ce9d60ed17e
2022-02-09 22:25:14 +00:00
Seigo Nonaka
6b9b5167e1 Improve BoringLayout#isBoring for PrecomputedText
Bug: 216736786
Test: atest PrecomputedTextTest
Test: perf score becomes 758,071 -> 110,755
Change-Id: I57d3eb9d1e896ed1c847733c4e96ac52dd97d2c4
2022-02-03 15:25:59 +09:00
Calvin Pan
2801e6de4f Merge changes Ib484fc0c,I2b9ff69c,I0a31b117,I888c65c8,I03723cfe, ...
* changes:
  Clean <plurals> in DateTimeView
  Clean <plurals> in CertificateMonitor
  Clean <plurals> in FillUi
  Clean <plurals> in BugreportProgressService
  Clean <plurals> in keyguard
  Clean <plurals> in ChooserActivity
  Clear <plurals> in TextUtils
  Clean <plurals> in FindActionModeCallback
  Clean <plurals> in ZenModeConfig
  Add util class for plurals
2022-01-27 06:31:58 +00:00
Hans Boehm
1350cb73d7 Merge "Prefer WeakReference.refersTo() to get()" am: 63e3c2c709 am: aca7bb4b9f am: a2e1dc8b9a am: db7bb39fb9
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1956816

Change-Id: I8f190ce1b3c9fc97a4efd8f3d90178db6ab362da
2022-01-27 01:18:15 +00:00
Hans Boehm
db7bb39fb9 Merge "Prefer WeakReference.refersTo() to get()" am: 63e3c2c709 am: aca7bb4b9f am: a2e1dc8b9a
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1956816

Change-Id: I449eec7c2bc21bfa5c7909a4508fbf899a59040d
2022-01-27 01:01:31 +00:00
Calvin Pan
436659396c Clear <plurals> in TextUtils
Bug: 199230228
Test: make
Change-Id: I3c0422b588a954a9e32fdcc94ea3946dbccddcd0
2022-01-26 11:55:03 +08:00
James Lin
b0429656ad Merge "Add line break word style parameter in the LineBreakConfig" 2022-01-24 17:27:12 +00:00
James.cf Lin
664a75b407 Add line break word style parameter in the LineBreakConfig
The line break word style(lw) provides the phrase-based breaking opportunities. When the line break word style is set, it will be brought to ICU for calculation.

Bug: 183780874
Test: atest minikin_tests; atest TextViewTest; atest MeasuredTextTest; atest PrecomputedTextTest
Change-Id: Idd851497e46c1fca87ff590230d93f8bb5c9afae
2022-01-22 12:27:51 +08:00
Hans Boehm
3492061b6d Prefer WeakReference.refersTo() to get()
This is an initial pass over frameworks/core to avoid WeakReference
get(), since that can cause the referent to be unnecessarily retained.
Most of these were found by searching for "get() == null".

Bug: 215259836
Test: Treehugger
Change-Id: I5227b05ca22e83b886ccf6713989961076df3f8c
2022-01-20 17:57:02 -08:00
Bernardo Rufino
1a5cb387d6 Revert "Revert "Migrate unsafe parcel APIs in framework-minus-apex""
This reverts commit 331be9a643.

Reintroducing ag/16366278 since it seems unrelated to b/214053959 (more details on b/214053959#comment55).

Original commit message:

Migrate unsafe parcel APIs in framework-minus-apex

Migrate the following unsafe parcel APIs in framework-minus-apex:
* Parcel.readSerializable()
* Parcel.readArrayList()
* Parcel.readList()
* Parcel.readParcelable()
* Parcel.readParcelableList()
* Parcel.readSparseArray()

This CL was generated by applying lint fixes that infer the expected
type from the caller code and provide that as the type parameter
(ag/16365240).

A few observations:
* In some classes we couldn't migrate because the class also belonged to
another build module whose min SDK wasn't current (as is the case for
framework-minus-apex), hence I suppressed the lint check
(since I'll eventually submit the lint check to the tree).
* In some cases, I needed to do the cast in
https://stackoverflow.com/a/1080525/5765705 to make the compiler happy
since there isn't another way of providing a class of type
Class<MyClassWithGenerics<T>>.
* In the readSerializable() case, the new API also requires the class
loader, that was inferred to by InferredClass.class.getClassLoader().
* Note that automatic formatting and import rely on running hooked up
to the IDE, which wasn't the case here.

Bug: 195622897
Change-Id: I272432e6e082a973f7a50492ec35d79c2b577c93
Test: TH passes
2022-01-19 11:13:18 +00:00
Seigo Nonaka
94904647a4 Add setLineBreakConfig API
Add new API to allow applications to specify the line break word style. The line break style is one of the locale extension. When the line break style is set, it will be brought to ICU for calculation.

Bug: 183780874
Test: atest minikin_tests; atest TextViewTest; atest MeasuredTextTest; atest PrecomputedTextTest
Change-Id: Ia9cdb5b83e346f96ae22abbb1bcce05c43207bba
2022-01-15 14:28:40 +08:00
TreeHugger Robot
7f635e3d3b Merge "Implement fallback line spacing for BoringLayout" 2022-01-12 23:14:26 +00:00
Ashwini Oruganti
776b439703 Merge "Revert "Migrate unsafe parcel APIs in framework-minus-apex"" 2022-01-12 23:07:08 +00:00
Bernardo Rufino
331be9a643 Revert "Migrate unsafe parcel APIs in framework-minus-apex"
This reverts commit 90bb3709dc.

Reason for revert: b/214053959

Change-Id: Ic271bab1d3eaf677a5989dda9deb944ee2ad6850
2022-01-12 17:44:44 +00:00
Seigo Nonaka
78c774defb Implement fallback line spacing for BoringLayout
The fallback line spacing is a feature of extending the line height
when the fallback font has taller glyph. This was implemented to
StaticLayout in Android P but not yet implemented in BoringLayout.

This CL enables this feature to the BoringLayout as well.

Not to break existing apps, change this behavior only if the
targetSdk version is T or later.

This is a 2nd attempt of Ia6d6f9f44e73ddaf5e8fe9a8aead7a53efbddd44
The root cause of SystemUI crash was wrong API usage. (start, end) was
passed instead of (start, count).

Bug: 210923482
Test: atest FallbackLineSpacingTest BoringLayoutFallbackLineSpacingTest
Test: atest CtsGraphicsTestCases
Test: atest CtsTextTestCases
Test: atest SystemUITests
Change-Id: I9137607b0120934f7ad2a12c0f0b8aaa52915831
2022-01-12 00:00:53 -08:00
Shubham Dubey
da511945c3 Revert "Implement fallback line spacing for BoringLayout"
Revert "Add font extent calculation"

Revert "Add test case for fallback line spacing"

Revert submission 16486662-fallback_line_spacing

Reason for revert: Investigate test failures on master


BUGID: b/213826416
BUGID: b/213829920

Reverted Changes:
I06cd7ab71:Add font extent calculation
I6214d52cd:Implement fallback line spacing for BoringLayout
Ia5825c474:Add test case for fallback line spacing

Change-Id: Ia6d6f9f44e73ddaf5e8fe9a8aead7a53efbddd44
2022-01-10 08:58:04 +00:00
Seigo Nonaka
a1b7ced11c Implement fallback line spacing for BoringLayout
The fallback line spacing is a feature of extending the line height
when the fallback font has taller glyph. This was implemented to
StaticLayout in Android P but not yet implemented in BoringLayout.

This CL enables this feature to the BoringLayout as well.

Not to break existing apps, change this behavior only if the
targetSdk version is T or later.

Bug: 210923482
Test: atest FallbackLineSpacingTest BoringLayoutFallbackLineSpacingTest
Test: atest CtsGraphicsTestCases
Test: atest CtsTextTestCases
Change-Id: I6214d52cde25a044bc6e246d2118e35d3a243c9d
2022-01-06 23:03:28 -08:00
Jeff DeCew
1a5de0a925 Bold StyleSpan further for auto-bold
StyleSpan with Typeface.BOLD will only bold if the text doesn't already
have a BOLD style. But auto-bolded text needs to be further bolded.
If the Typeface style is BOLD, bold more for auto-bold.
(The fake bold works for Typefaces with weight < 700)

NOTE: This backports a public API change from master
 but hides the public methods, so that we can use the new
 feature in SystemUI, which has access to hidden APIs.
This does NOT backport the changes to HTML or StringBlock
 as those changes may have broad affects that we do not
 have time to validate before release.

Test: manual - settings page, example StyleSpans,
atest StyleSpanTest TextViewTests
Bug: 175177807
Bug: 208592419

Merged-In: Iec7db7eadd18ed6a2efc6ee39b49c1d6cb15d870
Change-Id: I8da1d3f903b265e0331e7166a0afa0720c0eaa01
2021-12-16 15:47:01 -05:00
Calvin Pan
f72a53e8df Rename TextAttributeBuilder
Bug: 210923838
Test: atest CtsInputMethodTestCases:InputConnectionEndToEndTest
Change-Id: I65b058c9353483749321a0cb79ba5033767eacaf
2021-12-17 00:29:43 +08:00
Bernardo Rufino
90bb3709dc Migrate unsafe parcel APIs in framework-minus-apex
Migrate the following unsafe parcel APIs in framework-minus-apex:
* Parcel.readSerializable()
* Parcel.readArrayList()
* Parcel.readList()
* Parcel.readParcelable()
* Parcel.readParcelableList()
* Parcel.readSparseArray()

This CL was generated by applying lint fixes that infer the expected
type from the caller code and provide that as the type parameter
(ag/16365240).

A few observations:
* In some classes we couldn't migrate because the class also belonged to
another build module whose min SDK wasn't current (as is the case for
framework-minus-apex), hence I suppressed the lint check
(since I'll eventually submit the lint check to the tree).
* In some cases, I needed to do the cast in
https://stackoverflow.com/a/1080525/5765705 to make the compiler happy
since there isn't another way of providing a class of type
Class<MyClassWithGenerics<T>>.
* In the readSerializable() case, the new API also requires the class
loader, that was inferred to by InferredClass.class.getClassLoader().
* Note that automatic formatting and import rely on running hooked up
to the IDE, which wasn't the case here.

Bug: 195622897
Test: TH passes
Change-Id: I11a27b9bdab7959ee86e90aa1e1cbebd7aaf883c
2021-12-15 18:21:38 +00:00
Seigo Nonaka
d2980207d2 Fix top/bottom to adjust fallback ascent/descent.
The fallback ascent/descent can be larger than default font top/bottom
height. Not to clip the bottom of the view, adjust the top/bottom with
fallback ascent/descent.

Bug: 210163467
Test: atest StaticLayoutFallbackLineSpacingTest
Change-Id: Ifbf64f6d281d3324a926a6f0b45941824d499179
2021-12-10 18:13:30 -08:00
sallyyuen
ab82647bac Update font weight adjustment docs for StyleSpan
Test: NA
Bug: 209688245
Change-Id: I79f8f586bc4fc80ed7a6d05e4e8986116d82f70c
2021-12-07 15:56:03 -08:00
Sally Yuen
beb5cef12f Merge "Bold StyleSpan further for auto-bold" 2021-12-07 22:40:10 +00:00
James Lin
97e43c3bc9 Merge "Add the new Text input type TYPE_TEXT_FLAG_ENABLE_TEXT_CONVERSION_SUGGESTIONS" 2021-12-07 16:35:09 +00:00
James.cf Lin
9a45178ff4 Add the new Text input type TYPE_TEXT_FLAG_ENABLE_TEXT_CONVERSION_SUGGESTIONS
Add the new input type to indicate that the text conversion suggestions are required by the application. IME should provide the TextAttribute with the text conversion suggestions.

Bug: 194878427
Test: atest android.widget.cts.EditTextTest
Change-Id: Ib37a9816bbf594a5405ea6cd8943fd92491c005b
2021-12-07 14:09:07 +08:00
sallyyuen
0a674a8a44 Bold StyleSpan further for auto-bold
StyleSpan with Typeface.BOLD will only bold if the text doesn't already
have a BOLD style. But auto-bolded text needs to be further bolded.
If the Typeface style is BOLD, bold more for auto-bold.
(The fake bold works for Typefaces with weight < 700)

Test: manual - settings page, example StyleSpans,
atest StyleSpanTest TextViewTests
Bug: 175177807

Change-Id: Iec7db7eadd18ed6a2efc6ee39b49c1d6cb15d870
2021-12-06 15:46:27 -08:00
yingleiw
dd5ca6bf56 Make SuggestionRangeSpan public
when we have overlapped SuggestionSpans, the
range of text being replaced can change depends on
the number of suggestions in the SuggestionSpans, so
accessibility services need to know the text being replaced.
We send text change event with the before text doesn't have the
SuggestionRangeSpan and after text has the SuggestionRangeSpan,
so a11y services can inform the user about the text being
replaced.
Other ui toolkits like compose can convert their style indicating
text being replaced to SuggestionRangeSpan.

Bug: b/143378480

Test: tested the event is sent.

Change-Id: I6d0d33e46f7c8ac9dbcc177ab54718184e715fb6
2021-12-06 12:42:53 -08:00
Seigo Nonaka
0f761404af Implement fast hyphenation algorithm
RandomText Balanced Hyphenation ON
	min: 2,312,291
	mean: 2,320,574
	median: 2,320,112

RandomText Balanced Hyphenation ON(Fast)
	min: 985,850
	mean: 990,922
	median: 986,586

RandomText Balanced Hyphenation OFF
	min: 909,060
	median: 923,585
	mean: 930,052

Bug: 201096525
Test: TreeHugger and minikin_tests
Change-Id: Ide2d73acb3de85e91018e524c89df2c949235a4e
2021-11-10 23:19:43 -08:00
Kevin Jeon
2c0171fedf Deprecate Linkify.ALL
This change deprecates Linkify.ALL because it uses
Linkify.MAP_ADDRESSES, which is deprecated. The deprecation message is
the same as the one for MAP_ADDRESSES; users are directed to use
TextClassifier.generateLinks() instead.

Bug: 202556787
Test: N/A

Change-Id: I40a344410d2794f590d72faa6fcd9bf4582449bf
2021-10-08 23:01:51 +00:00
TreeHugger Robot
ed447b38fb Merge "Early exit if the target region is empty" into sc-dev am: 47d7cbaf87 am: ddda404a7e
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15391846

Change-Id: I0a368d5bb144aa182747c04687b6b23404f2329b
2021-10-05 03:29:20 +00:00
Seigo Nonaka
f47ac3cf1d Merge "Early exit if the target region is empty" into sc-v2-dev 2021-10-05 03:02:01 +00:00
Joanne Chung
0a8e3c16b5 Merge "Fix the existing translation doesn't update for new translated result." into sc-qpr1-dev am: 0287b4722c am: 2b55842700 am: 8b7eb90c86
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15853776

Change-Id: I85232df3ddb496fcdb7709804e9dc94f75b5193a
2021-09-23 07:04:41 +00:00
Joanne Chung
7672bbc915 Fix the existing translation doesn't update for new translated result.
It is possible the existing text is changed that triggers a new
translation. We cache the translation response when onShowTransltion
is called. We should keep the translation response is updated if this
is a new translation result.

Bug: 200232741
Test: atest CtsTranslationTestCases
Test: manual. The issue app works fine.
Change-Id: Iaf7423cd35d4484e33de84e478256b77a000f390
2021-09-19 15:16:57 +00:00
Seigo Nonaka
3520d84795 Early exit if the target region is empty
Bug: 193849901
Test: atest StaticLayoutBidiTouchTest
Change-Id: I55f04068a6e5b353867d50742356c272d28886b3
2021-07-27 19:02:38 +00:00
Seigo Nonaka
3582d26e2a Early exit if the target region is empty
Bug: 193849901
Test: atest StaticLayoutBidiTouchTest
Change-Id: I55f04068a6e5b353867d50742356c272d28886b3
2021-07-27 18:49:20 +00:00
Seigo Nonaka
17e666c235 Early exit if the target region is empty
Bug: 193849901
Test: atest StaticLayoutBidiTouchTest
Change-Id: I55f04068a6e5b353867d50742356c272d28886b3
2021-07-23 15:43:22 -07:00
Seigo Nonaka
50b67699e1 Improve ellipsize performance
Instead of iterate all ellipsized characters, only iterate the necessary
ranges for copying.

Bug: 188913943
Test: atest CtsTextTestCases CtsGraphicsTestCases CtsWidgetTestCases
Change-Id: I3d03b1e3897e427c23fbe51315f412c57a4ce9e9
(cherry picked from commit 2c6121f3e3)
2021-06-08 19:37:57 +00:00