Commit Graph

1801 Commits

Author SHA1 Message Date
Victor Chang
d3bffa0ce8 Merge "a.t.f.DateFormat behaves consistently with j.t.DateFormat in en, en-US locale" am: db93b81cf5 am: 178591073d am: 7e767cc923
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/2519640

Change-Id: I50578dd65a8d3e1959a93148d9b50ee78954a82b
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-04-04 14:38:21 +00:00
Victor Chang
7e767cc923 Merge "a.t.f.DateFormat behaves consistently with j.t.DateFormat in en, en-US locale" am: db93b81cf5 am: 178591073d
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/2519640

Change-Id: If945e58e4b75c55c4caa508d6a43a3de91a5de0c
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-04-04 14:08:50 +00:00
Victor Chang
14539d35bc a.t.f.DateFormat behaves consistently with j.t.DateFormat in en, en-US locale
DateUtils.formatSameDayTime() test is also updated, because the javadoc
refers to j.t.DateFormat directly. It makes sense to follow
j.t.DateFormat behavior.

The rest of a.t.f.DateUtils is not updated because it's used for
different purposes, e.g. date/time interval, relative date/time, duration, etc.
'\u202f' NNBS character use is acceptable in this case because
it's unlikely being parsed.

Bug: 266731719
Test: atest FrameworksCoreTests:android.text.format
Test: atest CtsTextTestCases:android.text.format
Change-Id: Ib5c916e2b7a66a5faef7bf214be25db88213d91d
2023-04-04 11:59:44 +01:00
Seigo Nonaka
43748ce328 Merge "Connect TextFlag feature flag to the application process" into udc-dev 2023-03-15 11:10:28 +00:00
Josep del Río
a7b390fe6e Merge "Exit active mode on Escape key" into udc-dev 2023-03-14 11:46:57 +00:00
Josep del Rio
20900a788f Exit active mode on Escape key
Any key that outputs a Unicode character will allow the user to
exit the "active mode" that allows them to compose special
characters. However, pressing Escape doesn't do anything, as it
will not output any Unicode character.

This change adds an extra condition to exit active mode by pressing
the Escape key.

Bug: 271671045
Test: Flashed phone, confirmed that pressing Escape will cancel the
input of an accented character

Change-Id: Id3d04758c9fd4cdb65016cca3af30f611b7011e4
2023-03-04 15:18:04 +00:00
Haoyu Zhang
043d23a8a8 Optimize GraphemeClusterSegmentFinder performance
This CL utilized minikin:isGraphemeBreak to compute all grapheme break indices when creating GraphemeClusterSegmentFinder. This makes all methods (such as #nextStartBoundary) of GraphemeClusterSegmentFinder O(1) instead of O(n).

Bug: 271004887
Test: atest TextViewHandwritingGestureTest
Change-Id: I61c1f2c45123a584456b4860b72cd4fdc84c5f1c
2023-03-04 05:55:34 -08:00
Seigo Nonaka
1a0efbedf7 Connect TextFlag feature flag to the application process
Bug: 240385199
Test: Manually done
Change-Id: I906260c2bd122bbf5fcad1e2231c643d77bbed8c
2023-03-03 18:29:50 +09:00
Sean McQuillan
3e0d49084f Merge "Add codepoint exclusions API" am: 84d3ca061f am: 905fa5f6b6
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/2372427

Change-Id: Ib95f2e7e3544dcb0fb466a7d295ffeb1442f75d7
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-03-01 03:33:20 +00:00
Haoyu Zhang
9ebb0ec4af Merge "[Scribe] Support setTransformationMethod in insert mode" 2023-02-16 20:41:53 +00:00
Seigo Nonaka
e94bf55619 Revisit API comment again with code example
Bug: 266591082
Test: N/A
Change-Id: I90635b488d807526e782e6d7d82436ccbde14e91
2023-02-14 09:31:29 +09:00
Haoyu Zhang
ace5b65475 [Scribe] Support setTransformationMethod in insert mode
Bug:265871733
Test: atest TextViewHandwritingGestureTest

Change-Id: Ic7cbbc55930613ceeae3c3a2be732322982e9116
2023-02-08 17:01:44 -08:00
Seigo Nonaka
65c45fc029 Fix documentation errors
Bug: 266591082
Test: N/A
Change-Id: Iec8493a6ed43d2186da92207fa1f16ac7f882dd9
2023-01-31 16:35:11 +09:00
Josep del Rio
b2c551e36d Don't insert dead key glyphs repeatedly
At the moment, holding a dead key will result in the insertion of
multiple characters. However, it's likely that was not the user
intention, so this CL addresses that.

Test: Built and tested on a test device
Bug: 266536908
Change-Id: I10b2d1865a3e789a3ee7c27a0358bfc8b9bd4d71
2023-01-24 11:47:13 +00:00
Haoyu Zhang
8eb57870d2 Introduce InsertModeTransformationMethod
Bug: 242089987
Test: atest InsertionModeTransformationMethodTest
Change-Id: Id0afe2281632356551e3067ffdc1cc004c1d7278
2023-01-18 14:30:50 -08:00
Haoyu Zhang
8793d67a70 Merge "Introduce OffsetMapping for TextView TransformationMethod" 2023-01-17 06:12:08 +00:00
Haoyu Zhang
c3d7b4e751 Introduce OffsetMapping for TextView TransformationMethod
This CL supports OffsetMapping internally for the TextView's
TransformationMethod. It make it possible for TransformationMethod to
alter the original text's length. It'll be mainly used for the insertion
mode feature requested by stylus handwriting.

This CL checked all index access to Layout from Editor, TextView and
MovementMethod. And make sure they are aware of the text transformation.

When there isn't a TransformationMethod or the TransformationMethod
returns a text that's not an instance of OffsetMapping, the existing
behavior is not impacted.

The following classes will support a transformed text with OffsetMapping:
- InsertionPointCursorController, SelectionModifierCursorController
- InsertionHandleView, SelectionHandleView, HandleView
- PinnedPopupWindow, EasyEditPopupWindow, SuggestionsPopupWindow
- SelectionActionModeHelper

The following parts don't support OffsetMapping, but instead will
direclty return false/null or become no-op when OffsetMapping is used:
- CursorAnchorInfoNotifier, CursorAnchorInfo
- TextBoundsInfo
- TextView HandwritingGesture
- Selection move methods
- LinkMovementMethod
- BaseKeyListener

Bug: 242089987
Test: atest DynamicLayoutTransformedTextTest
Test: manually test
Change-Id: I2ad2c2148353e69214efd9aae04a69a6367d0981
2023-01-11 21:48:43 -08:00
Haoyu Zhang
cf19ed31fe Merge "Address API feedbacks for TextBoundsInfo" 2023-01-12 02:12:35 +00:00
Andrew Solovay
b8bbb8e665 Merge "docs: Fix typo ("An consumer" -> "A consumer")" into tm-dev am: 4cfb823dc5 am: 31f604ef0f am: 099134803f am: c627d18d6e
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/20845430

Change-Id: I851f2967ec8607034c6fd60139c2f77405ba5b24
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-01-11 15:55:49 +00:00
Andrew Solovay
c627d18d6e Merge "docs: Fix typo ("An consumer" -> "A consumer")" into tm-dev am: 4cfb823dc5 am: 31f604ef0f am: 099134803f
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/20845430

Change-Id: If74904563788155b0973d0f155f80f349d639d9a
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-01-11 15:32:16 +00:00
Haoyu Zhang
3b47b24850 Address API feedbacks for TextBoundsInfo
Bug: 262452997
Bug: 265068032
Test: atest TextBoundsInfoTest
Test: atest TextBoundsInfoMethodTest
Test: atest TextViewTextBoundsInfoTest
Change-Id: I2105efc8a90fee7f11d5c534c18e659d821abf1c
2023-01-10 16:41:59 -08:00
Sean McQuillan
5f1172f54e Add codepoint exclusions API
To be used by unbundled glyph drawing code to filter codepoint sequences
excluded on this platform.

Bug: b/242678495
Test: CodepointExclusionsTest
Merged-In: If928e35a162f5c9bda506a641ce6595855e3e399

(cherry-pick)


Change-Id: I5d43adddba59619b479fe096a656c796380fc97d
2023-01-03 19:58:06 +00:00
Andrew Solovay
c0e75056cf docs: Fix typo ("An consumer" -> "A consumer")
CommonTypos linter complained about this in the generated reference doc.
No changes to source code, just doc comment.

Bug: 263824202
Change-Id: I715f841f1d8d5680472bca1d92f754781f1c8bf9
Test: [go/abtd test]
2023-01-03 16:50:12 +00:00
TreeHugger Robot
a2305d8911 Merge "Add family-list tag element to fonts_customization.xml" 2022-12-18 03:12:14 +00:00
Sean McQuillan
d50eac0e02 Add codepoint exclusions API
To be used by unbundled glyph drawing code to filter codepoint sequences
excluded on this platform.

Bug: b/242678495
Test: CodepointExclusionsTest
Change-Id: If928e35a162f5c9bda506a641ce6595855e3e399
2022-12-16 13:09:59 -08:00
Seigo Nonaka
9e233cd563 Add family-list tag element to fonts_customization.xml
family-list can be used as a named font family definition.
Multiple families can be used as a fallback for the named
family.

Bug: 249787583
Test: atest TypefaceSystemFallbackTest FontListParserTest
Test: atest UpdatableFontDirTest UpdatableSystemFontTest
Test: atest GtsFontHostTestCases FontManagerTest
Change-Id: Ic459a533ac4b5081660c0a4a7519ef7e87a6b628
2022-12-15 23:50:13 +09:00
Seigo Nonaka
16ad1f7b08 Add highlight APIs into TextView and Layout
Bug: 244502332
Test: atest LayoutDrawOrderTest
Change-Id: If625a1f2866c524ab709e69cd9f19212c60a8e34
2022-12-02 13:41:33 +09:00
Cole Faust
e4abcbec1d [conflict] Merge "Fix errorprone warnings that should be errors" am: 677d6cd780 am: f9df26ae3c am: d3c499dabc
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/2256563

Change-Id: I84d67fdfcc99f9f6fca218d4264ab8e0bc1f1653
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-11-15 19:47:41 +00:00
Cole Faust
7da659bb6c Fix errorprone warnings that should be errors
This commit is part of a large scale change to fix errorprone
errors that have been downgraded to warnings in the android
source tree, so that they can be promoted to errors again.
The full list of changes include the following, but not all
will be present in any one individual commit:

BadAnnotationImplementation
BadShiftAmount
BanJNDI
BoxedPrimitiveEquality
ComparableType
ComplexBooleanConstant
CollectionToArraySafeParameter
ConditionalExpressionNumericPromotion
DangerousLiteralNull
DoubleBraceInitialization
DurationFrom
DurationTemporalUnit
EmptyTopLevelDeclaration
EqualsNull
EqualsReference
FormatString
FromTemporalAccessor
GetClassOnAnnotation
GetClassOnClass
HashtableContains
IdentityBinaryExpression
IdentityHashMapBoxing
InstantTemporalUnit
InvalidTimeZoneID
InvalidZoneId
IsInstanceIncompatibleType
JUnitParameterMethodNotFound
LockOnBoxedPrimitive
MathRoundIntLong
MislabeledAndroidString
MisusedDayOfYear
MissingSuperCall
MisusedWeekYear
ModifyingCollectionWithItself
NoCanIgnoreReturnValueOnClasses
NonRuntimeAnnotation
NullableOnContainingClass
NullTernary
OverridesJavaxInjectableMethod
ParcelableCreator
PeriodFrom
PreconditionsInvalidPlaceholder
ProtoBuilderReturnValueIgnored
ProtoFieldNullComparison
RandomModInteger
RectIntersectReturnValueIgnored
ReturnValueIgnored
SelfAssignment
SelfComparison
SelfEquals
SizeGreaterThanOrEqualsZero
StringBuilderInitWithChar
TreeToString
TryFailThrowable
UnnecessaryCheckNotNull
UnusedCollectionModifiedInPlace
XorPower

See https://errorprone.info/bugpatterns for more
information on the checks.

Bug: 253827323
Test: m RUN_ERROR_PRONE=true javac-check
Change-Id: I8446f9076a45ebf7e7ffa06cb0d4ddb1001b6c00
2022-11-14 17:57:30 -08:00
czq
2111954aaa Introduce FontStyle.FONT_WEIGHT_UNSPECIFIED constant
Introduce a new constant FontStyle.FONT_WEIGHT_UNSPECIFIED = -1, which is used when text weight is not specified. Also replace -1 with it in TextView, TextAppearanceSpan.

Bug: 256995042

Test: manually test
Change-Id: Ia8334f5513cc3e5b7383b67b24b27bf2866d05ad
2022-11-08 13:27:17 +08:00
Haoyu Zhang
bfdf3ddb5f Support TextBoundsInfo for TextView
Bug: 239843501
Test: atest TextViewTextBoundsInfoTest
Change-Id: Id3e46e8c8a9df294dc449064d7dfd68eafbd578d
2022-11-01 09:48:17 +00:00
Haoyu Zhang
167691ce12 Merge "Introduce TextBoundsInfo" 2022-11-01 05:00:28 +00:00
Koki Ryu
617c83bce4 Merge "Handle emojis with emoji-modifier and zwj properly on backspace" 2022-10-28 01:55:30 +00:00
Koki Ryu
5aedeaf8a9 Handle emojis with emoji-modifier and zwj properly on backspace
Since Unicode 12, emoji modifier sequences (such as human + light skin
tone) can be combined with zwj. However, current backspace state machine
ignores that and stops when one emoji modifier sequence is found. This
CL make the state machine continue exploration as long as a zwj is found
before an emoji modifier sequence.
BYPASS_INCLUSIVE_LANGUAGE_REASON="man" is the name of the emoji

Bug: 171495034
Test: Do the following:
 - Enter an emoji from the "family" subgroup with different skin tones
   combined such as 1F468 1F3FE 200D 2764 FE0F 200D 1F48B 200D 1F468
   "kiss: man, man, medium-dark skin tone, light skin tone"
 - Press the backspace key and confirm that the entire emoji is deleted.
Change-Id: I260f509832cb24486665019d68a25db0ad089d7e
2022-10-27 17:05:32 +09:00
Haoyu Zhang
43aae6ff6d Introduce TextBoundsInfo
This is an API for IME to request text bounds information from editor to
perform handwriting rich gestures. It's useful for IMEs to create custom
handwriting gesture that's not supported the HandwritingGesture. And
it can also be used to provide default rich gesture implementation for
handwriting gesture compatibility.

Bug: 239843501
Test: atest TextBoundsInfoTest
Change-Id: Ia7522371976a4e1fcdff4cc0d244ea427ad3d7c9
2022-10-26 13:51:45 -07:00
Justin Ghan
9d0b39c24a Update Layout#getRangeForRect to not use Range
android.util.Range is not suitable for text ranges since it uses
inclusive boundaries, whereas the convention in text is to represent
ranges with an inclusive start boundary and exclusive end boundary. So
the API is updated to use an array of two ints to represent the text
range.

Bug: 251085162
Test: atest android.text.cts.LayoutGetRangeForRectTest
Change-Id: I54ab6d2741d1cfbbb743e477de4fa7299382fcfb
2022-10-20 17:02:18 -07:00
Justin Ghan
4212ebb0e9 Layout#getRangeForRect API changes
- Layout#getRangeForRect returns Range<Integer> instead of int[].
- WordSegmentFinder takes ULocale instead of Locale
- Additional Javadoc

Bug: 251085162
Test: atest android.text.cts.LayoutGetRangeForRectTest
Change-Id: Id51f5b23885dc93addc44b81d641c963c58505c8
2022-10-07 14:41:39 -07:00
Justin Ghan
2ea18b462b Make Layout#getRangeForRect public
To avoid making WordIterator public, WordSegmentFinder has a public
constructor taking a Locale parameter. The constructor taking a
WordIterator parameter is kept but hidden so TextView can use it.

LayoutGetRangeForRectTest is moved to CTS.

Bug: 243969224
Test: atest android.text.cts.LayoutGetRangeForRectTest
Test: atest android.widget.cts.TextViewHandwritingGestureTest
Change-Id: Ibb829af0324c47e4d275b0ccd69d0f95601e3c08
2022-10-03 22:31:44 -07:00
Justin Ghan
3cc4fa15eb Merge changes from topics "inclusion-strategy", "segment-finder"
* changes:
  Rename SegmentIterator to SegmentFinder
  Layout#getRangeForRect support different text inclusion strategies
2022-10-03 23:24:00 +00:00
Justin Ghan
88cd111ca8 Rename SegmentIterator to SegmentFinder
Also clean up some helper methods by inlining the logic.

These APIs will be made public in a follow up change.

Bug: 243969224
Test: atest android.text.LayoutGetRangeForRectTest
Test: atest android.widget.cts.TextViewHandwritingGestureTest
Change-Id: I7991ef1f3abdf575b9adc0c5dc971f0cdd09fc87
2022-10-03 12:17:06 -07:00
Justin Ghan
339e9492d5 Layout#getRangeForRect support different text inclusion strategies
These APIs will be made public in a follow up change.

Bug: 243969224
Test: atest android.text.LayoutGetRangeForRectTest
Test: atest android.widget.cts.TextViewHandwritingGestureTest
Change-Id: I65ddda9d60c486ca8f53bbd9f0d97209d56bec62
2022-10-03 12:14:54 -07:00
Treehugger Robot
67457fc6c1 Merge "Reorganize text related owners" am: 5e89e54398 am: 95ea173c85 am: 38eb872609 am: a35e8a8e8d am: 0605a3c8b6
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/2226540

Change-Id: I4df8d1492e2e8727896a674460f77e99e7779909
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-09-29 19:42:10 +00:00
TreeHugger Robot
08b9eefa9a Merge "Add Layout#getLineBottom with includeLineSpacing parameter" 2022-09-26 20:53:57 +00:00
Justin Ghan
5bfd33e89c Add Layout#getLineBottom with includeLineSpacing parameter
Bug: 247609599
Test: atest android.text.cts.StaticLayoutTest
Test: atest android.text.LayoutGetRangeForRectTest
Change-Id: I7363fe3974d712f992bca5aaefa5ca76499656d2
2022-09-26 09:25:26 -07:00
Justin Ghan
e51ef4024c Delete gesture: remove extra whitespace around deleted text
Bug: 243983058
Test: atest android.widget.cts.TextViewHandwritingGestureTest
Change-Id: I759bbb99e94a373390c77cb28fb71aa641c63560
2022-09-23 01:06:09 -07:00
Seigo Nonaka
5916f347b3 Reorganize text related owners
Update list of owners of the text team.

Bug: N/A
Test: N/A
Change-Id: Iae227284d69b1251f26f549850909f44c7639c8f
2022-09-22 16:12:23 +09:00
Treehugger Robot
7815cd1c99 Merge "Enable DISALLOW_DUPLICATE_FIELD_IN_SKELETON since U" am: 643e586072 am: de4ea8f38b am: e47e8ec3f6 am: 15390ccf1d am: 913f632490
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/2216581

Change-Id: I26336026ab0c7c92f4cbfe1c937be04fcf19d380
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-09-17 12:37:50 +00:00
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
Seigo Nonaka
66260c6045 Implement Ctrl+B/I/U shorcut
These shortcut works as follows:

- If the selected region is empty, do nothing.
- If the selected region has at least one character that is not styled,
  e.g. bold, apply bold style.
- If the selected region is fully styled, e.g. bold, remove bold style
  from the region.

The default TextView/EditText supports styled editing, but it is used
commonly as plain text fields, e.g. email address in the form, etc.
So, not to style the text in such places, disable styled shortcut by
 default and let developers to enable it when necessary.

Bug: 240628246
Test: TextViewStyleShortcutTest
Change-Id: Id0f1cd85eb198553a852c5c2b628f5d03a2741e1
2022-09-08 13:41:42 +09:00
Justin Ghan
28b4da5b75 Merge changes from topics "insert-impl", "select-delete-impl"
* changes:
  TextView implementation of insert gesture
  TextView implementation of select and delete gestures
2022-08-29 20:11:17 +00:00