Commit Graph

9414 Commits

Author SHA1 Message Date
Sean McQuillan
782e063d25 Mark nullability for TextView.setText(char[])
Add @NonNull to TextView.setText(@NonNull char[], ...)

This has always thrown a NPE since API 1.

Bug: b/227218386
Test: atest android.widget.TextViewTest
Relnote: "TextView.setText(@NonNull char[], ...) added nullability
annotation."

Change-Id: I212bb5b73d00185f83adb5e74d4acd07a1410ca8
2022-07-12 15:18:47 -07:00
Sean McQuillan
166c7217f4 Don't crash after unsetting char[] in TextView
TextView.setText(char[]) is from API 1 and follows a running with
scissors API style of not copying the passed array.

To avoid a leak, in TextView.setText(String), the char[] would be nulled
out. However, an internal object could have been read using .getText()
prior to this second setText would immmediatly become a
CharSequence that crashed when you called any methods on it.

After this change, the CharWrapper will stay valid if had been
previously retrieved. The general shape of the API will be maintained.

Fixes: b/227218386
Test: atest android.widget.TextViewTest
Relnote: "Calling TextView.getText() after calling TextView.setText(char[])
will now return a valid CharSequence. The char[] pointed to by this char
sequnece may still be mutated by future calls to setText(char[]), but it
will no longer allow a (char[]) null to be set, which lead to crashes
when reading CharSequence returned from getText on TextView."

Change-Id: I35a2a76d58ec1946dace2f615cacf6a6085efdeb
2022-07-12 15:05:59 -07:00
joneckenrode
1173840230 Fixed the reference to the compat version of the widget. Revised the class description.
Fixes: 234585459
Test: Built API documentation
Signed-off-by: joneckenrode <joneckenrode@google.com>
Change-Id: I0215c1e19983e85431fb8a9b0b600d9c18765f3d
2022-07-08 00:18:47 +00:00
TreeHugger Robot
828bff7d95 Merge "Support fling back in scrolling containers" 2022-06-28 23:03:09 +00:00
George Mount
28b3b51c4e Support fling back in scrolling containers
Bug: 232903223

When a user flings the overscroll toward the scrolling
content, the user might think that any left-over velocity
should apply to scrolling the content. This CL makes that
happen. If the fling is less than the overscroll distance,
then the normal spring is applied.

This CL changes ListView, ScrollView, and HorizontalScrollView.

Test: manual testing and new CTS tests
Change-Id: I1a759377f5183eec805598a6b016515297191624
2022-06-28 13:55:27 -07:00
Yohei Yukawa
7c4912ba08 Deprecate mRequestUpdateCursorAnchorInfoMonitorMode part 3
This is the third step towards deprecating

 InputMethodManager#mRequestUpdateCursorAnchorInfoMonitorMode,

which was introduced as a minimum implementation to support
CursorAnchorInfo API in EditText [1].

With this CL, mRequestUpdateCursorAnchorInfoMonitorMode is effectively
deprecated and does nothing except for methods marked with
@UnsupportedAppUsage.

All the remaining valid usages will be handled by the following newly
introduced fields:

 - Editor.InputMethodState#mUpdateCursorAnchorInfoMode
 - Editor.InputMethodState#mUpdateCursorAnchorInfoFilter

 [1]: I3c6b69bd9d79b199afe68d838f25effa6048e5cc
      cf8421df856a5950729ff1d0e73f21d480aa98fb

Bug: 236713697
Test: atest CtsInputMethodTestCases:InputMethodServiceTest#testOnUpdateCursorAnchorInfo
Test: atest CtsInputMethodTestCases:StylusHandwritingTest
Change-Id: I9fc930fbe39c3bdf913e3d7012fdd22805564d3b
2022-06-22 21:41:48 +00:00
Neil Fuller
135079a38d Merge "Use CAPITALIZATION_FOR_BEGINNING_OF_SENTENCE..." 2022-06-14 07:48:58 +00:00
TreeHugger Robot
67818f9fbe Merge "Explain the difference between setBreakStragegy() and setLineBreakStyle() in API doc" into tm-dev am: 2b868683ad am: 4e9b6a3839 am: e0d6f903b9 am: 3c7b2c3fe0
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/18769766

Change-Id: I93eefec1b916f5fcfcf98815b2b68c881bf0e5a0
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-06-09 08:10:56 +00:00
TreeHugger Robot
3c7b2c3fe0 Merge "Explain the difference between setBreakStragegy() and setLineBreakStyle() in API doc" into tm-dev am: 2b868683ad am: 4e9b6a3839 am: e0d6f903b9
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/18769766

Change-Id: I530759c97e64b8be4254b411b1e9021857db3d64
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-06-09 07:50:25 +00:00
Neil Fuller
8fc8607cb7 Use CAPITALIZATION_FOR_BEGINNING_OF_SENTENCE...
Use CAPITALIZATION_FOR_BEGINNING_OF_SENTENCE in place of
CAPITALIZATION_FOR_STANDALONE for date formats, since ICU does not
capitalize (at least) month names correctly today according to
https://unicode-org.atlassian.net/browse/ICU-21631. The motivating
example is the DatePicker/SimpleMonthView for Vietnam with "{month}
{year}" (as used in the manual date selection in the Date & Time screen
of the System settings): it does not capitalize the month without this
change.

It's difficult to know which formats will be affected, so this change
modifies all the formats found in frameworks/base/ that currently
express a preference for STANDALONE. The fix may be available by ICU 72,
at which point this change can presumably be reverted as signified in
the TODOs.

Bug: 229287642
Test: Inspection of Date & Time settings + compilation only
Change-Id: Iea753d0318aef55c6dd4f7e09068a0362ac970d8
2022-06-08 14:34:45 +00:00
allenwtsu
289d576548 Explain the difference between setBreakStragegy() and setLineBreakStyle() in API doc
Bug: 217951279
Test: build pass
Change-Id: Ida98327a656edc4878f7ce1c7f2bc99b72cd91d6
2022-06-07 13:06:52 +08:00
Treehugger Robot
87e108d038 Merge "Fix owner files in text components in the widget directory" am: 5078370e5f am: a375a95fd4 am: 9942758628 am: 5e951a2d41 am: 4104637d65
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/2115546

Change-Id: I8e377ae123f8333983e34dbf4c1a9867ef8b52ef
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-06-07 00:31:20 +00:00
Treehugger Robot
9942758628 Merge "Fix owner files in text components in the widget directory" am: 5078370e5f am: a375a95fd4
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/2115546

Change-Id: I275376ed1252beb7bb26d27de6d435c5c2760407
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-06-06 23:21:20 +00:00
Treehugger Robot
a375a95fd4 Merge "Fix owner files in text components in the widget directory" am: 5078370e5f
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/2115546

Change-Id: I10ff5646a9168fa2a4737a680fd539bf8a3b4b60
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-06-06 22:53:37 +00:00
Seigo Nonaka
fa29f96603 Fix owner files in text components in the widget directory
Text team owns the text related module in widget.
The previous per-file line was not working due to extra spaces between
files list.
Fixed by removing white spaces and also change to refer the text team
OWNERS file.

Bug: 234759754
Test: N/A

Change-Id: I3302de8fd90a12e7745f15d07c8c53c900bb3a14
2022-06-03 21:16:55 +00:00
TreeHugger Robot
1a8d6458e7 Merge "Always dismiss magnifier when cursor is detached." 2022-06-02 20:50:51 +00:00
Seigo Nonaka
d8a61e8a9d Always dismiss magnifier when cursor is detached.
Bug: 182484248
Test: atest CtsWidgetTestCases
Test: atest CtsTextTestCases
Test: Manually done
Change-Id: I79b5b8b7d000bbab114ef341327d3d0c21bab697
2022-06-02 11:01:42 -07:00
Mark Punzalan
89f3d4968d Merge "Translate selectable TextViews by temporarily disabling selectable." into tm-dev am: 8bbc7f6554 am: 8f85334591 am: 905979b385 am: af0c004e46
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/18490753

Change-Id: I4d327ef4f8ff677a338df1a4be488d3e452da4d6
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-05-27 20:39:01 +00:00
Haoyu Zhang
99e6506d13 Merge "Optimize TextView#populateCharacterBounds" 2022-05-26 21:29:41 +00:00
Haoyu Zhang
bc317e642c Optimize TextView#populateCharacterBounds
Avoid unnecessary calls of getPrimaryHorizontal/getSecondaryHorizontal,
this will make the method around 2 times faster.
Also avoid repeat calls of isPositionVisible, which reduces the
computation time around 5%.

Before:
	populateCharacterBounds[mTextLength (100))]_min (ns): 416685
	populateCharacterBounds[mTextLength (300))]_min (ns): 1315209
	populateCharacterBounds[mTextLength (1,000))]_min (ns): 4480508
	populateCharacterBounds[mTextLength (3,000))]_min (ns): 13526504
	populateCharacterBounds[mTextLength (10,000))]_min (ns): 44841361

After:
        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.TextViewCursorAnchorInfoPerfTest
Change-Id: I24a470e204e4a2e52f881828c707adfcca21f890
2022-05-26 09:27:32 -07:00
Mark Punzalan
6758b3f7e7 Translate selectable TextViews by temporarily disabling selectable.
The text is not selectable while translated. Making translated text
selectable requires many more changes.

This was tested in Nextdoor in the feed/posts activity. When there is a
"Read more" link in the post, the link doesn't work while translated,
and doesn't behave the same way after translation is paused.

Bug: 202966891
Test: atest CtsTranslationTestCases
Test: Manually - with Nextdoor on feed and chat activities
Change-Id: I6e8f532d427d85ff22df0deb248d8416a15f4821
2022-05-25 20:03:10 +00:00
TreeHugger Robot
19d57551fc Merge "Migrate AutoCompleteTextView to use OnBackInvokedDispatcher." into tm-dev am: d1263fb5ce am: b97f7b4760 am: cb69608f94 am: 218a9a7a7c
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/18432995

Change-Id: I7f94a47997d06f4d3fd5469090cd6e485e505514
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-05-19 09:03:14 +00:00
Shan Huang
7caa2c1c6b Migrate AutoCompleteTextView to use OnBackInvokedDispatcher.
With ag/17952046 we now actively intercept KEYCODE_BACK before they are
sent to IME when new back flow is used. This requires us to migrate
AutoCompleteTextView#onKeyPreIme, and is also what causes the test
failure in b/231960630.

Test: atest AutoCompleteTextView test.
Test: Test back behavior of AutoCompleteTextView in BackTestApp.
Bug: 231960630
Change-Id: I1a5e01c9a4f8f0e762b493284650854a230aecd3
2022-05-18 19:08:59 +00:00
Justin Ghan
d49d0fe228 Merge "Move setHandwritingArea call to View#sizeChanged" 2022-04-29 15:42:08 +00:00
Haoyu Zhang
abbb1d9969 Merge "Scribe: Introduce setHandwritingBoundsOffset API" 2022-04-28 22:04:41 +00:00
Haoyu Zhang
8b4aacab1e Scribe: Introduce setHandwritingBoundsOffset API
Introduced View#setHandwritingBoundsOffset and xml attributes to
enlarge the view's stylus handwriting bounds. With this API, it's
possible to make handwriting bounds larger than the view's visible
bounds, and makes handwriting easier to trigger.

Bug: 211764956
Test: atest android.view.stylus.HandwritingInitiatorTest
Test: atest android.view.cts.HandwritingBoundsOffsetTest
Change-Id: I7a3749f78df82eee08ad29761cd52d7452114873
2022-04-27 17:11:04 -07:00
Justin Ghan
dd482fe91e Move setHandwritingArea call to View#sizeChanged
This enables handwriting to be started before the input connection is created for custom text editor views which are not EditTexts.

Fix: 218907674
Test: atest CtsInputMethodTestCases:android.view.inputmethod.cts.StylusHandwritingTest
Change-Id: I1ff3b0ffd609e1ec9f1efc477d00fee998ac9966
2022-04-26 13:22:01 -07:00
Lucas Dupin
b5b1807a3c Merge "Don't trigger full relayout if DateTimeView doesn't change" into tm-dev am: 06ac74c54f am: e2c8005b11
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/17606881

Change-Id: If6d59f47507f1c6e17b853e3635976e1bb0b1d00
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-04-22 15:45:21 +00:00
Lucas Dupin
06ac74c54f Merge "Don't trigger full relayout if DateTimeView doesn't change" into tm-dev 2022-04-22 15:21:23 +00:00
Tim Murray
395ebcc9e2 Merge "RemoteViews: make bitmaps immutable" into tm-dev am: e9a0acdfda am: 5a06b288ea
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/17803201

Change-Id: If65d33b0ce7d9918e73f11ff3599aac0d7d9ecec
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-04-21 19:05:19 +00:00
Tim Murray
e9a0acdfda Merge "RemoteViews: make bitmaps immutable" into tm-dev 2022-04-21 18:32:21 +00:00
Jernej Virag
8d056ab409 Don't trigger full relayout if DateTimeView doesn't change
Right now, when an update is triggered, DateTimeView will trigger a full
relayout of its parents because it always calls setText, even if it
doesn't change the contents (later down the line, TextView will call
requestLayout() for wrap_content, even if size didn't change).

Checking if the content actually changed avoids that extra layout pass
which avoids needless relayouts in e.g. SystemUI Notifications.

Bug:220712538

Test: atest DateTimeView (new test failed before fix / passes after fix)

Change-Id: Ib391d6715136b64b98f0bda3b3d4a3f991809c89
2022-04-21 11:56:42 +00:00
TYM Tsai
8a938b948d Merge "Auto append password hint for TextView" into tm-dev am: 2ab23eed06 am: c1a483379b
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/17750671

Change-Id: I806e9b7127a8f76f230302e8bb14932c66a975af
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-04-21 09:40:34 +00:00
TYM Tsai
2ab23eed06 Merge "Auto append password hint for TextView" into tm-dev 2022-04-21 08:13:10 +00:00
TYM Tsai
1f5c147eb5 Auto append password hint for TextView
Some TextViews are made as password via input type but does not
contain autofill password hint. This change auto append a hint
for autofill to identify.

Bug: 219844915
Test: atest android.autofillservice.cts.dialog.LoginActivityTest
Change-Id: Ifd18c56ffe788a601821d178ace41413f9e0454e
2022-04-20 03:55:33 +08:00
Tim Murray
21a8baaeb1 RemoteViews: make bitmaps immutable
Because mutability is propagated across Parcel and Binder, any mutable
Bitmaps passed to RemoteViews will end up mutable on the other side
even though those Bitmaps can't be modified from the RemoteViews
recipient.

Make all Bitmaps passed to RemoteViews immutable in order to ensure
that they can be sent without additional copies instead of the one
ashmem object.

Test: TH, RemoteViews work for widgets
Bug: 227920378

Change-Id: I477e7132f9ff78333c1eda56b9d0fc6ac520abd0
2022-04-18 18:36:02 +00:00
Vadim Caen
0b1c7631f3 Merge "Migrate PopupWindow to use OnBackInvokedDispatcher" into tm-dev am: 0ba48fea68 am: db68b7db77
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/17105464

Change-Id: Ib7520afafe9e3b8fabb824cf2ed3c00fba374f6b
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-04-11 18:48:39 +00:00
Vadim Caen
a2173652a0 Migrate PopupWindow to use OnBackInvokedDispatcher
Bug: 219968356
Test: In BackTestApp, show popup window and swipe back to close it.
Test: CTS: android.widget.cts.BackInvokedOnWidgetsTest#popupWindowDismissedOnBackGesture
Change-Id: Ic22c12e2ed9f1c961f6e0abfdaf3d2a9a7bd2934
2022-04-04 16:02:38 +02:00
Vadim Caen
49c0dc04c5 Merge "Split animation methods out of OnBackInvokedCallback" into tm-dev am: d0923a2197 am: ce4cdf7989
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/17523886

Change-Id: I13b53084f418b286b60ceffb3ab35a83bd44fa0c
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-04-01 20:28:11 +00:00
Vadim Caen
d0923a2197 Merge "Split animation methods out of OnBackInvokedCallback" into tm-dev 2022-04-01 20:13:30 +00:00
Vadim Caen
c627777dda Split animation methods out of OnBackInvokedCallback
This makes OnBackInvokedCallback SAM compatible

Bug: 227789359
Test: atest \
        CtsWindowManagerDeviceTestCases:android.server.wm.BackNavigationLegacyTest \
        CtsWindowManagerDeviceTestCases:android.server.wm.BackNavigationTests \
        WmTests:com.android.server.wm.BackNavigationControllerTests \
        FrameworksCoreTests:android.window.BackNavigationTest \
        FrameworksCoreTests:android.window.WindowOnBackInvokedDispatcherTest \
        CtsViewTestCases:android.view.cts.OnBackInvokedDispatcherTest
Change-Id: Iab86b0488f1b3048eb02042191acaeb6a645a0bc
2022-04-01 20:09:26 +00:00
Sally Yuen
8157012a66 Merge "Revert "Fixes for a11y selection". Reverts hiding some selection UI" into tm-dev am: b9d928eae3 am: cc2975c503
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/17510341

Change-Id: I6775cdef5a4ebb926ba7db1dfced4f489ecb9da8
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-04-01 18:30:46 +00:00
Sally Yuen
b9d928eae3 Merge "Revert "Fixes for a11y selection". Reverts hiding some selection UI" into tm-dev 2022-04-01 18:14:37 +00:00
TYM Tsai
b0e4d5d743 Merge "Make TextView do not show IME when fill dialog popup" into tm-dev am: e6ae224102
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/16984943

Change-Id: I3b892e4a120719e572908df4569d655addab38f2
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-03-31 14:14:21 +00:00
TYM Tsai
e6ae224102 Merge "Make TextView do not show IME when fill dialog popup" into tm-dev 2022-03-31 14:09:17 +00:00
Sally Yuen
8021a8fb09 Revert "Fixes for a11y selection". Reverts hiding some selection UI
This reverts commit 55022a5880.

Reason for revert: b/226418848
Test: builds

Change-Id: Id709d131754e14a67805ee981bc5ad0bc759121f
2022-03-30 22:12:57 +00:00
Shan Huang
9d4a7ed133 Merge "Migrate MediaController to use OnBackInvokedDispatcher" into tm-dev am: 116b6300d0
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/17344424

Change-Id: I9919101df820a276588194f6a3d2e2c83cfc6cda
2022-03-24 18:37:47 +00:00
Shan Huang
116b6300d0 Merge "Migrate MediaController to use OnBackInvokedDispatcher" into tm-dev 2022-03-24 18:14:27 +00:00
Joanne Chung
af1fff3994 Merge "Fix the translation not work if the animation is off" into tm-dev am: 8121a43efd
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/17240423

Change-Id: I99c3e48c94e6dc27cd3da3d996643c83ba9f405b
2022-03-24 13:24:42 +00:00
Joanne Chung
8121a43efd Merge "Fix the translation not work if the animation is off" into tm-dev 2022-03-24 13:15:40 +00:00