Before this CL, when TextView's textSize attribute was set to 0sp in
XML, the text would still be visible on the screen, as the actual
textSize set was non zero. On the other hand, if the text size was set
to 0sp programmatically, the text would not be visible. This was a P
regression, as on O the text would be invisible in both cases.
This CL fixes the attribute reading stage in TextView, allowing the
application of a 0 text size on the view.
Bug: 110251171
Test: atest CtsWidgetTestCases:android.widget.cts.TextViewTest
Change-Id: I3798361e182f45a67cd0a69d40e09e559375aa20
We switched the package installer app to always abbreviate all labels
loaded from foreign packages. This is done so that a foreign app cannot
crorrupt the UI via super-long strings.
The default abbreviation is very aggressive and abbreviates to ~5 cm.
When an app with a targetSDK <= M gets installed, all permissions will
get auto-granted. Hence when a user side-loads such an app, we show the
permissions during install so that the user is aware of this.
Unfortunately most permission labels and restrictions do not fit into a
single line.
This change allows much longer strings for permissions names and
descriptions. It still abbreviates eventually and handles permission
descriptions with weird characters (such as back-space) correctly.
Fixes: 110209410
Test: Side-loaded old app and verified that permission labels and
descriptions are not abbreviated.
Change-Id: Ie1db240883c9f5cb9c1b74ca7bdcb80625e3f7f2
Currently when an EditText is attached to a Window, one spell checker
session will be immediately requested even when that EditText is
empty. This is not efficient, especially for notification with direct
reply.
With this CL, EditText does not request spell checker session while it
is empty. Basically this doesn't cause any user-visible behavior
change.
Bug: 109701487
Fix: 37434131
Test: Run 'adb shell dumpsys textservices' to make that a new spell
checker session is established not when a notification with
direct reply is posted but when the user actually starts
replying on that notification.
Change-Id: Iee04f4c0e2d248041d01c528344b191b9875d122
Before this CL, the magnifier could have caused a memory leak when:
- in Editor we give the magnifier a callback that updates the visibility
of the handles after the magnifier is drawn. This holds a reference to
the HandleView, which in turn has a reference to the containing Activity
- the callback is set on the InternalPopupWindow, in order to be run
after the next #doDraw call
- #doDraw is post'd as a runnable to the UI thread
- the magnifier is dismissed and the activity is destroyed
- when the garbage collection happens, the InternalPopupWindow cannot be
collected, because either:
-- there is still a reference to the job expected to run #doDraw
-- there is still a pixel copy that has to finish. We keep a reference
to the InternalPopupWindow in use when the pixel copy was requested
in order to compare it with the current one, and dismiss the pixel
copy result if the instance has changed
- both options above mean that we will still have a reference to the
callback that sets the visibility of the handles, so a reference to the
containing Activity. The Activity is, therefore, leaked.
This CL cleares the handle visibility callback when the magnifier is
dismissed, such that the unnecessary reference to the Activity will not
be held.
Bug: 80279783
Test: verified with leakcanary that the memory leak no longer exists
Change-Id: I65c77eb12d2778c76fe631b55e6a7164fbf487f1
Refactored WallpaperColors to use constrast ratio instead of luminance
for detecting dark pixels. Also using a contrast more conservative than
what GAR requires while decreasing the dark area threshold.
Change-Id: I67b799be4b7ccd50bb3e63c6179d513b9b76446b
Fixes: 76435920
Test: manually set various wallpapers
Test: use new debug flag to verify which pixel is actually dark
Although parent view may invoke onDetachedFromWindow incorrectly,
itself should guarantee to unregister receiver only when removing
the last attached view.
Change-Id: I4b701c223c6aa354896a4067f77aad9c98d88dfd
Fixes: 78506836
Test: atest FrameworksCoreTests:DateTimeViewTest
As part of adding the hint text feature in
I357dd5c74b61d149cf8612d1f52c7118ec70c696 I refactored
the code inside reportExtractedText to avoid nesting but lost one
of the condition checks in the process. Since onDraw calls into
this method on each frame, the missing check was causing calls to be
made into the IME even when no content or selection changes have
happened.
Test: CtsWidgetTestCases:.TextViewTest
Bug: 73613936
Change-Id: If56e3f1d45e64dccd052e4cff4d742f0cbecc07c
* no-arg #start()
* remove no-op #destroy method
* fix a Java-imposed quirk that you can't draw a
currently invalid RenderNode, forcing bottom-up
recording for no particular reason
Test: builds
Change-Id: I28b41c83b4f7f9ddced843b0d57e9ac510d40ae5
doclava was accidentally suppressing all these broken links
in @see tags. This CL fixes issues so we can start enfocing
checks for broken @see links.
Test: make docs
Change-Id: If7830ece85f8d1f27c991eae282230814726e115
Exempt-From-Owner-Approval: Fixing @see javadoc link issues that are currently completely broken
In Id65443e93d277c106ea955c867d39e94192cc55d we fixed a monkey crash
happening when the smart selected text had changed while the smart
selection animation was running. However, the change introduced a new
crash, happening when the smart selection result was null. This CL fixes
it, and lets startSelectionActionMode run even when the result is null,
as there seems to be some logic there which should happen in this case.
Bug: 80244201
Test: none
Change-Id: I7f0304446dec85578bdcd5011d2e9ea2737d3c36
(cherry picked from commit a9d27ea869)
Merged-in: I7f0304446dec85578bdcd5011d2e9ea2737d3c36
In Id65443e93d277c106ea955c867d39e94192cc55d we fixed a monkey crash
happening when the smart selected text had changed while the smart
selection animation was running. However, the change introduced a new
crash, happening when the smart selection result was null. This CL fixes
it, and lets startSelectionActionMode run even when the result is null,
as there seems to be some logic there which should happen in this case.
Bug: 80244201
Test: none
Change-Id: I7f0304446dec85578bdcd5011d2e9ea2737d3c36
This regressed when introducing TC sessions in
I3c9ceea0863099fc4f0a5ce5e823c648ee9c4521
When the user triggers a terminal selection event such as "Copy",
we should immediately end the session instead of waiting for the
"Abandon" event (i.e. selection dismissed) to be included in the
logs. Terminal selection events implicitly dismiss a selection and
we'd rather distiguish between an actual "selection dismiss" from
one that happened because of a "terminal" selection event.
This cl also removes the "*" marker used to distinguish the new
logging from the old ones. The code for the old logging has already
been deleted so no more need for a marker.
Bug: 78541105
Test: bit CtsWidgetTestCases:android.widget.cts.TextViewTest
Test: bit FrameworksCoreTests:android.widget.TextViewActivityTest
Change-Id: Iac7d45dbc63e7076683742bd045766a1d927cfc9
At the end of the smart selection animation, we run a callback that sets
the selection on the TextView (subsequently starting the action mode
toolbar and showing the handles). However, when the text changes before
the animation finishes, the selection might not be valid, and might get
out of the text bounds, which was producing a crash. This was observed
in a monkey crash. This CL fixes this bug by refusing to set the
selection when it goes outside the text bounds, corresponding to the
case when text has changed between the time the animation has started
and the time it ended.
Bug: 69919777
Test: manual testing before and after the fix
Change-Id: Iea043f320004d45ad16dd7e9e5b47e5256e6d9fa
(cherry picked from commit cce6e82d35)
Merged-in: Iea043f320004d45ad16dd7e9e5b47e5256e6d9fa
At the end of the smart selection animation, we run a callback that sets
the selection on the TextView (subsequently starting the action mode
toolbar and showing the handles). However, when the text changes before
the animation finishes, the selection might not be valid, and might get
out of the text bounds, which was producing a crash.
This was initially fixed in Iea043f320004d45ad16dd7e9e5b47e5256e6d9fa,
by checking whether the text has not changed since the animation
started. The fix was implying one text copy and a potentially full text
comparison, being unnecessary costly. This CL instead only checks
whether the selection is still within the text bounds when animation
ends.
Bug: 69919777
Test: manual testing before and after the fix
Change-Id: Id65443e93d277c106ea955c867d39e94192cc55d
In Ifaddb46d156c495a371789c6f32cfd67ffaaaef2, we improved the
documentation of TextView#setText to state an assumption that should
hold when subclasses override the method. However, the new phrase was
put in the wrong place. This CL fixes this.
Bug: none
Test: none
Change-Id: I918a6c533b9e4b34b3977a20e979a10db9741ebc
Approach here is to register a content observer that invalidates the
TC settings whenever updates to the settings happen.
This CL also ensures that the TC is invalidated when a settings
update happens. This is because the settings may change what
TC the system returns.
TextView's SelectionActionModeHelper has been updated to not cache
the settings and get them directly from TCM (which caches the settings).
NOTE that we expect TC settings to rarely change.
Bug: 77539576
Test: bit FrameworksCoreTests:android.view.textclassifier.TextClassificationManagerTest
Test: bit CtsViewTestCases:android.view.textclassifier.cts.TextClassificationManagerTest
Test: bit CtsWidgetTestCases:android.widget.cts.TextViewTest
Test: bit FrameworksCoreTests:android.widget.TextViewActivityTest
Test: manual - Made changes to TC settings and observed logs / app behaviour
Change-Id: I88bbb6f951708b17323fac1a72385fe808d270a5
It is common for TextView subclasses to override the #setText method,
and there is nothing preventing the new implementations from leaving
mText and mTransformed unchanged. On the other hand, TextView assumes
mText and mTransformed will be non null at all times after the first
overridden implementations, these can remain null, causing null pointer
exceptions later.
Bug: 74411872
Test: atest FrameworksCoreTests:android.widget.TextViewTest
Test: atest FrameworksCoreTests:android.widget.TextViewActivityTest
Test: atest CtsWidgetTestCases:android.widget.cts.TextViewTest
Change-Id: Ifaddb46d156c495a371789c6f32cfd67ffaaaef2
At the end of the smart selection animation, we run a callback that sets
the selection on the TextView (subsequently starting the action mode
toolbar and showing the handles). However, when the text changes before
the animation finishes, the selection might not be valid, and might get
out of the text bounds, which was producing a crash. This was observed
in a monkey crash. This CL fixes this bug by refusing to set the
selection when the text has changed between the time the animation has
started and the time it ends.
Bug: 69919777
Test: manual testing before and after the fix
Change-Id: Iea043f320004d45ad16dd7e9e5b47e5256e6d9fa
DateTimeView won't update timestamp until the view is attached to
window and received TIME_TICK intent.
Update timestamp on onAttachedToWindow().
Test: manual 1) turn on DND 2) send a notification and wait some time 3)
turn off DND and check the timestamp
Fixes: 77970557
Change-Id: Ia8420aacf5b91b0bb9cbec561629ddbfc8de4f67
Since Ic5b5f6ca687db8b5d842f0ab20eac70f1fd2f85e, the magnifier can be
the child of a diffent surface than the one its content is copied from.
This initially led to much code duplication accross different methods,
making the code quite difficult to understand. This CL performs a small
refactoring, removing some of the TODOs and making the code a bit
cleaner.
Bug: 78876353
Test: atest CtsWidgetTestCases:android.widget.cts.MagnifierTest
Change-Id: Ifa26f94ba2e4983446f058f016af6010c1017ea7
The position of the magnifier surface is always clamped inside its
parent surface. As of Ic5b5f6ca687db8b5d842f0ab20eac70f1fd2f85e, we are
always trying to make the magnifier surface a child of the main
application window, if possible (before, if the magnified view was a
SurfaceView, we were making the magnifier a child of the SurfaceView's
surface). However, the CL did not also update the clamping, continuing
to clamp to the SurfaceView space when the magnified view was a
SurfaceView (even if the magnifier was child of the main window). This
was making the magnifier window to be wrongly positioned on the screen
when the magnified view is a SurfaceView. The current CL fixes this.
Bug: 78876353
Test: manual testing
Test: atest CtsWidgetTestCases:android.widget.cts.MagnifierTest
Change-Id: I63f2b185f58e62e8ad6eadf788e641fb1de07b04
The CL fixes the magnifier's behavior when its parent window has
positive insets in its surface:
- we compute the content copy coordinates sent to the pixel copy request
relative to the surface the content is copied from. We were clamping
them inside the visible region of the magnified view as returned by
belonging to the view which is magnified. However, the method returns
coordinates relative to the window. Therefore, the CL offsets the
visible rectangle with the window insets, to account for them.
Otherwise, when the insets were non-zero, on a text line we were
allowing the magnifier to display content from the left outside of the
text line, while a certain region at the end of the text line could have
never been magnified
- when clamping against the visible view region, when the surface we
copy from is a SurfaceView, #getGlobalVisibleRect is still returning
coordinates relative to the main window, whereas the coordinates we are
trying to clamp are relative to the surface of the SurfaceView. In order
to make the visible rectangle relative to the surface of the SurfaceView
instead, this CL negatively offsets the visible rectangle with the
SurfaceView position in the parent surface
- the selection/insertion handles are hidden when they overlap the
magnifier. To check this, we intersect the magnifier rectangle with the
rectangle of each handle. However, when we were performing this check,
the magnifier rectangle was relative to the surface, whereas the
handles' rectangle was relative to the main window. The CL negatively
offsets the magnifier position with the surface insets, to make both
rectangles relative to the window.
Bug: 78621162
Test: manual testing
Test: atest CtsWidgetTestCases:android.widget.cts.MagnifierTest
Change-Id: I0d749c1abb38520fe8fc477d22d6523f470e9abc