Commit Graph

1704 Commits

Author SHA1 Message Date
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
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
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
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
Seigo Nonaka
2c6121f3e3 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
2021-06-04 16:07:23 -07:00
Adam He
b9cdc84c87 Add android: to text constant to prevent namespace conflicts.
Fixes: 187219011
Test: atest CtsTranslationTestCases
Change-Id: I980156c8653581aa5020afaa5bcb97e909d291df
2021-05-07 15:14:30 -07:00
vichang
e838a48fd8 Merge "Change the API signature of DateTimePatternGenerator.getBestPattern" am: 19fd56d767 am: a1335e23ac am: c080e7f7f9
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1662460

Change-Id: I506cc100dfb0e394948b210ba7cb0a734a0a4c26
2021-04-21 16:14:21 +00:00
Ahaan Ugale
1281143a36 Merge "AutoTranslate: Pad view text for compatibility reasons." into sc-dev 2021-04-19 05:19:53 +00:00
Seigo Nonaka
5681124abb Add FontConfig.Font.getPostScriptName API
Bug: 184003133
Bug: 185508395
Test: atest FontManagerTest#fontManager_PostScriptName
Change-Id: Ie44e0d500c61b37035a0b39039891da13cd6a5ce
2021-04-17 00:46:04 -07:00
Ahaan Ugale
7110641881 AutoTranslate: Pad view text for compatibility reasons.
Some apps operate on the view text based on layout calculations made on
the transformed text. This can cause issues (even crashes) if the
transformed text is longer than the original, as is often the case with
Translate. A previous temporary fix,
I685ae4a9752c817db81f0d736f1d746b2e4a9839, ellipsized the translated
text. This change fixes it properly by instead padding the original
text.

A followup change will make this controllable by API instead of padding
every TextView.

The en space character, U+2002, is used for the padding here. It seems
to work well in practice for multiple languages. We don't make this
configurable through API as it could make debugging harder (issues
triggered by server-side changes).

Bug: 179693024
Test: atest CtsTranslationTestCases
Test: manual - toggling between original and translated, scrolling, new
 views appearing, multiple apps
Change-Id: I9d7db5d2bc200e4042baf3267796f00cfc298f19
2021-04-16 19:38:28 -07:00
Ahaan Ugale
8c48915e42 UiTranslation: Temporary fix for crash due to length increases.
Ellipsizes the translated text if it's longer than the view text. This
fixes a crash in apps that operate on the view text based on layout
calculations made on the transformed text.

A proper fix will follow to modify the UiTranslationManger API to make
this compat behavior happen only on request, and probably change the
behavior to instead add padding to the view text to make it match the
translated text length.

Bug: 179693024
Test: atest CtsTranslationTestCases
Change-Id: I685ae4a9752c817db81f0d736f1d746b2e4a9839
2021-04-05 11:30:01 -07:00
Victor Chang
c8828ee59b Change the API signature of DateTimePatternGenerator.getBestPattern
It's a feedback from the API council.

Bug: 184018008
Test: m droid
Change-Id: I58ced6e0bc174d58008cb1874227bdc39de2d6af
2021-04-01 17:44:52 +01:00
Adam He
59716789f4 Full refactor of Translation APIs.
* Added ViewTranslationRequest/Response
* Added TranslationRequest/ResponseValue
* Removed single TranslationData.
* Moved service.TRequest -> view.TRequest.

Bug: 176208267
Bug: 177371091
Test: atst CtsTranslationTestCases
Change-Id: I25d4bce385d64a8eb9c2a316bd6b5a23e14fb14e
2021-03-05 17:51:03 -08:00
Seigo Nonaka
ecd9b0280b Add @CurrentTimeMillisLong annotation to getLastModifiedTimeMillis
Bug: 180395483
Test: N/A
Change-Id: I7e069f9d193dfbfb07501dc73ad675eb25158e21
2021-02-24 17:48:11 -08:00
Kohsuke Yatoh
5d2f4fc3b3 Merge "Add FontListParser#writeFamily()." into sc-dev 2021-02-09 07:54:43 +00:00
Kohsuke Yatoh
f91ea1b201 Add FontListParser#writeFamily().
Bug: 179103383
Test: atest FrameworksCoreTests:FontListParserTest
Change-Id: I992acd13dc5dc084a00ee9f3832c4d7111ecd4e4
2021-02-08 16:16:56 -08:00
Ahaan Ugale
dba0fb5580 Merge "Fix ellipsis reinitialization for static cached StaticLayout." into sc-dev 2021-02-08 18:08:59 +00:00
Ahaan Ugale
ed6a3111cb Fix DynamicLayout init to use transformed text length.
It already uses the transformed text characters, but uses the length of
the base text. This does not account for TransformationMethod2, which
can change length, including AllCapsTransformationMethod ("ß" becomes
"SS") and TranslationTransformationMethod (arbitrary length changes).

This change does not fix updates that happens through
DynamicLayout.ChangeWatcher; those will be fixed in separate change(s).

Bug: 178650596
Test: atest DynamicLayoutBlocksTest DynamicLayoutTest TextLayoutTest \
  TextViewTest
Test: manually on a sample app with AllCaps
Test: manually with Translate on a real app
Change-Id: Iec4699c8d9967cb4622fe59ba91849642d72b52e
2021-02-05 16:38:52 -08:00
Ahaan Ugale
5b873f1366 Fix ellipsis reinitialization for static cached StaticLayout.
DynamicLayout uses a static StaticLayout instance internally to avoid
allocations. For the specific case of multiline, TruncateAt.START, and
no ellipsization needed (may also be triggered by slightly different
params), the ellipsis results for a reused static instance are not
modified. If the instance was previously ellipsized, the new result
keeps that ellipsization result even though it shouldn't be ellipsized
(at least for some lines).

Bug: 179524847
Test: atest DynamicLayoutBlocksTest DynamicLayoutTest TextLayoutTest \
  TextViewTest
Change-Id: I1b4142648ec1b6b3fc2ece0ec55aac9539497134
2021-02-05 16:35:17 -08:00
Seigo Nonaka
ff85b932d7 Add FontManager#updateFont API
Bug: 173619554
Test: atest FontManagerTest
Change-Id: I261e55783978d9840b06c586389e2126bc6eb2ca
2021-01-29 14:28:46 -08:00
Seigo Nonaka
9387e7f4cd Add more shell command for font
Bug: 173619554
Test: atest UpdatableFontDirTest PersistentSystemFontConfigTest FontManagerTest
Change-Id: I25917fa9e8c42742f74222f25c5ba68d96a2c2fd
2021-01-27 22:59:06 +00:00
Ahaan Ugale
70f17d9f8e Merge "Add initial View's APIs for auto translation" 2021-01-25 21:08:43 +00:00
Seigo Nonaka
46d6a3f9ce Add FontManager API and font manager shell commands
FontManager is an interface of communicating with FontManaserService.
With this CL, system apps can know the primitive information about
what font files are installed and how it is configured.

This CL also adds shell command of dumping font configuration.
Example usages are:

  # dump primitive font configuration.
  adb shell dumpsys font

  # dump fallback font list
  adb shell cmd font dump serif

Bug: 173619554
Test: atest FontManagerTest
Test: Manually confirmed above commands works.
Change-Id: I5cb855308e199ac38bd7b56b60821346247bdce3
2021-01-25 08:51:41 -08:00
Joanne Chung
a5fa9bc0f7 Add initial View's APIs for auto translation
The initial APIs for auto translation flow. The implementation of
sending request and dealing spans will on the follow up changes.

Bug: 172969740
Test: manual build pass. Use a sample app to call api get expected
result.

Change-Id: Ief45190026e6205ff18366c1aaba8f424a4df00c
2021-01-25 18:57:14 +08:00
TreeHugger Robot
903dc9269f Merge "Refactor font parser for making SystemApi." 2021-01-20 04:18:20 +00:00
Seigo Nonaka
f5859819cd Refactor font parser for making SystemApi.
This CL breaks system font initialization step into three sub-steps
to be able to expose font configuration as SystemApi. The font
initialization step is now following three steps:
 1. Parse XML files. This is SystemFonts#getSystemFontConfig and
    SystemFonts#getSystemPreinstalledFontConfig. The first API gives
    you the current FontConfig and the second API gives you plain
    vanilla FontConfig without any updates.
 2. Build font family fallback list from FontConfig. The font family
    fallback is a intermediate state that can be used for custom
    Typeface. This state is kept for dumping in shell command later.
    This is useful for checking what font will be used by the fallback
    since family fallback is still printable.
 3. Build typeface mapping. The typeface mapping is the final state to
    be used by application. This is no longer printable.

Bug: 173619554
Test: atest TypefaceTest TypefaceSystemFallbackTest StaticLayoutTest
Test: atest CtsGraphicsTestCases CtsTextTestCases
Change-Id: I4e21fc7c41f2fb7975d03c1d5f5536a23e8abb09
2021-01-19 15:55:41 -08:00
Treehugger Robot
af052be27c Merge "Remove usage of hidden NetworkUtils from Formatter" am: ea47f9ee6c am: 4d36fe858c am: 7e54a837d2
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1552501

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: If7d87e3254064bfb2ceea1317c577b3e910d0452
2021-01-18 13:19:42 +00:00
Remi NGUYEN VAN
d3d76d8063 Remove usage of hidden NetworkUtils from Formatter
Use the Inet4AddressUtils common utility instead.
NetworkUtils is moving to the connectivity module, so its hidden symbols
are not accessible from the framework. Use the Inet4AddressUtils utility
instead.

NetworkUtils.intToInetAddress is also deprecated.

Bug: 174436414
Test: m

Change-Id: Ia4f4de2f23b2e2be056f78cc30259814f9a4dc91
2021-01-18 17:01:56 +09:00
Kohsuke Yatoh
e5f12abfec Add RESULT_ATTR_DONT_SHOW_UI_FOR_SUGGESTIONS.
Bug: 166304720
Test: atest CtsInputMethodTestCases:SpellCheckerTest
Change-Id: I2f5796d899c79ea1cd6795c16f2011389ae7afea
2020-12-17 00:16:36 +00:00
Jeff Sharkey
c9a074da58 Move DateFormat.zeroPad() back to upstream.
We can only safely use TextUtils.formatSimple() when formatting
strings that don't appear in UI, since locales can use different
glyphs for representing numerals.

Bug: 174576537
Test: manual
Exempt-From-Owner-Approval: revert
Change-Id: Iafba1ccde239e3053b2a462c3d0c248795fbf5fc
2020-12-03 02:40:36 +00:00
Andrei-Valentin Onea
a0fe86bf15 Merge "Update DISALLOW_DUPLICATE_FIELD_IN_SKELETON" am: 5bba56e147 am: 81eb255fa2 am: 0e6d9772c2 am: e945dc22c0
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1490737

Change-Id: I276d4f6a2d46042e1342cd4f5801e2fd107cde41
2020-11-09 16:33:13 +00:00
Andrei-Valentin Onea
5bba56e147 Merge "Update DISALLOW_DUPLICATE_FIELD_IN_SKELETON" 2020-11-09 14:58:38 +00:00
Mathew Inwood
f8abe13db4 Merge "Add maxTargetSdk restriction to unused APIs." 2020-11-09 14:41:20 +00:00