Commit Graph

1775 Commits

Author SHA1 Message Date
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
Justin Ghan
8b5d4bd91e TextView implementation of select and delete gestures
Bug: 240435922
Test: atest android.text.LayoutGetRangeForRectTest
Test: atest android.widget.cts.TextViewHandwritingGestureTest
Change-Id: I6ceaa4555b82f1c2650d2db3bf39674641d53b8f
2022-08-26 23:18:00 -07:00
Haoyu Zhang
852de827fc Optimize TextLine#measureAllOffset performance
Bug: 238954768
Bug: 235353864
Test: atest StaticLayoutGetOffsetForHorizontalPerfTest
Change-Id: Ic3a1a8fc5ef5d160401d390b920f3f2a409528f0
2022-08-26 00:23:07 -07:00
TreeHugger Robot
d9131a60b5 Merge "Implement paragraph cursor movement and selection extension" 2022-08-03 23:41:22 +00:00
Haoyu Zhang
e7422024fe Introduce Layout#fillCharacterBounds
Introduce Layout#fillCharacterBounds to compute character bounds faster.
This change makes TextView#populateCharacter 5 times faster.

After:
        populateCharacterBounds[mTextLength (100))]_min (ns): 52361
        populateCharacterBounds[mTextLength (300))]_min (ns): 148941
        populateCharacterBounds[mTextLength (1,000))]_min (ns): 463237
        populateCharacterBounds[mTextLength (3,000))]_min (ns): 1388081
        populateCharacterBounds[mTextLength (10,000))]_min (ns): 1165867

Before:
        populateCharacterBounds[mTextLength (100))]_min (ns): 204065
        populateCharacterBounds[mTextLength (300))]_min (ns): 653159
        populateCharacterBounds[mTextLength (1,000))]_min (ns): 2184327
        populateCharacterBounds[mTextLength (3,000))]_min (ns): 6770318
        populateCharacterBounds[mTextLength (10,000))]_min (ns): 22777530

Bug: 233922052
Test: atest android.text.TextViewPopulateCharacterBoundsTest
Test: atest android.text.TextViewCursorAnchorInfoPerfTest
Change-Id: I68a47cf3099b89e0a10604b7706fa7a3dea66d32
2022-08-02 09:39:12 -07:00
Seigo Nonaka
c7053c6587 Implement paragraph cursor movement and selection extension
Bug: 240624037
Test: atest BaseMovementMethodTest SelectionParagraphTest
Change-Id: I75161fc88975736fe26395959bafba661c590f66
2022-08-02 17:22:17 +09:00
Haoyu Zhang
c8abba4907 Introduce TextLine#measureAllbounds
This new method computes the horizontal character bounds by making
use of the character advances returned from native layer. It'll be
used in TextView to populate character bounds, and it's much efficent
compared to calling getPrimaryHorizontal for each character.

Bug: 233922052
Test: atest android.text.TextLineTest
Change-Id: Icdd53e61e2d1513b2231affb19bb00ea5d938d48
2022-07-08 12:50:32 -07:00
TreeHugger Robot
106145fc27 Merge "Add descriptive toString method and missing accessors" 2022-07-01 01:27:28 +00:00
Victor Chang
1accb533b3 Merge "Re-land "Switch file size formatters to use ICU's MeasureFormat"" am: b284c36224 am: 6d5f7f22c4 am: fe5155786f am: 6ea4660db1 am: d2a1e4bd0a
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/2100171

Change-Id: I06a6648e1d6574199bbf8ccf69d62b0bbbee2418
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-05-24 11:43:19 +00: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
Seigo Nonaka
5f2c67b89c Remove hyphens at the ellipsized start/end position
Bug: 232438922
Test: atest CtsTextTestCases
Change-Id: I937732945a99d4b390d9d8986338b13d0c843353
2022-05-23 12:03:46 -07:00
Seigo Nonaka
0561027f9a Add descriptive toString method and missing accessors
Bug: N/A
Test: compile
Change-Id: I15411d8bf67dba9745f4f2e02114099612b9a844
2022-05-19 01:29:16 +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
e2496f8601 Merge changes from topic "truncate operator name" am: ffa0f982b6 am: 9cf73e369d am: eb897b1d85 am: 8827b92855 am: 8ec131c2a2
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/2004810

Change-Id: Iba13c4d338b95ba2da57f60b79acd077979185ad
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-04-01 23:27:38 +00: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
TreeHugger Robot
193ec53542 Merge "Set useFallbackLineSPacing into member value" into tm-dev am: ee06c56645
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/17288890

Change-Id: I14aafca4d40f7035c14b015b55befcdc96b5ec6d
2022-03-22 06:04:26 +00:00
Allen Su
508818fc58 Merge "Text Wrapping automation" 2022-03-22 05:44:23 +00:00
allenwtsu
f70429088a Text Wrapping automation
Bug: 220836284
Test: atest StaticLayoutTest
Change-Id: I2aead872b0b472b3c625e075348e46da768ff3be
2022-03-22 11:16:57 +08: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
c93d6b49b5 Fix wrong Nullability of BoringLayout new API introduced in API33
Bug: 225695033
Test: N/A
Change-Id: I93d3fc3041e862ad5f6064ac517e9cdbd23f1599
2022-03-20 23:01:51 -07: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
josephpv
12781c1548 Fix typo in TextUtils and remove unused import
Bug: 222479601
Test: Manual

Change-Id: I7790d1e9b782743141bf1714a51763ff47ca8565
2022-03-14 20:08:47 +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
James.cf Lin
e5aad7a752 Fix performance regression create_PrecomputedText_NoStyled_Greedy_NoHyphenation_DirDifferent_min
The LineBreakConfig instance in the StaticLayout is null as default.

Because the LineBreakConfig in StaticLayout was not initialized, the null instance was brought to PrecomputedText and caused the function PrecomputedText.Builder#checkResultUsable to return UNUSABLE.

Bug: b/220992481
Test: atest StaticLayoutTest; atest StaticLayoutPerfTest
Change-Id: I93bcb6ebc35344e34e9bb8a24df375aa7b3a8d81
2022-03-09 03:25:06 +08:00
James Lin
2d26f03f3a Merge "Update the text wrapping API." 2022-02-19 01:31:52 +00:00