Commit Graph

7821 Commits

Author SHA1 Message Date
Mihai Popa
f03b7543c7 Allow 0sp text size in xml for TextView
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
2018-07-02 12:58:22 +00:00
Seigo Nonaka
b06144c5ed Add textFontWeight attribute to documentation
Bug: N/A
Test: m docs and manually verified
Change-Id: Ic2aca1503789c9ce426b3de3b887983ade292afe
2018-06-26 14:30:42 -07:00
Laura Davis
95aa3e124e Merge "docs: fixed broken link" into pi-dev am: e07aeea926
am: d3f3a2354a

Change-Id: I410789175ec49489bb60ca36c7ebb87e5090ccdc
2018-06-25 14:47:56 -07:00
TreeHugger Robot
4c51b7c057 Merge "Tweak some RenderNode API surfaces" 2018-06-21 19:05:27 +00:00
Laura Davis
3175696a46 docs: fixed broken link
Test: make ds-docs

Bug: 76021493
Change-Id: Ide61b82925270896e373083fdc1d5c27c9bdc819
2018-06-19 10:11:36 -07:00
Android Build Merger (Role)
93135a37b7 [automerger] Merge "Abbreviate permission labels less aggressively" into pi-dev am: af76df93e3 am: 3dce361445
Change-Id: Iea45f6992477e090e0f7ecaf2c4689354ad24786
2018-06-15 17:48:50 +00:00
Philip P. Moltmann
004e489a25 Abbreviate permission labels less aggressively
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
2018-06-14 11:52:14 -07:00
Yohei Yukawa
6008106a64 Lazily request spell checker session
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
2018-06-11 17:41:45 -07:00
Mihai Popa
c390e51b45 [Magnifier-44] Fix memory leak caused by callback
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
2018-06-08 10:15:04 +00:00
TreeHugger Robot
7231e7b6ce Merge "More conservative dark text calculation" 2018-06-08 04:33:50 +00:00
Lucas Dupin
a291d19e47 More conservative dark text calculation
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
2018-06-07 16:33:09 -07:00
Selim Cinek
ca30a349ed Merge "Fix exception from DateTimeView unregisters receiver again" into pi-dev am: a2537b7269
am: 96bc1cada2

Change-Id: If514fce8446cfb0a10380ce2db2b324575b13fd8
2018-06-06 13:41:40 -07:00
Selim Cinek
a2537b7269 Merge "Fix exception from DateTimeView unregisters receiver again" into pi-dev 2018-06-06 18:18:27 +00:00
Clara Bayarri
d85e32f31e Merge "Fix repeated calls into reportExtractedText" into pi-dev am: bcbdeb29c9
am: 1cf7c2e604

Change-Id: I467c01bbc66de8d5bf4ab9e6f97ecdc266b940ca
2018-06-06 08:04:04 -07:00
Riddle Hsu
e8f0fe3140 Fix exception from DateTimeView unregisters receiver again
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
2018-06-06 07:54:21 +08:00
Clara Bayarri
038f7a8b09 Fix repeated calls into reportExtractedText
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
2018-06-05 13:41:58 +01:00
John Reck
568b2a64f0 Tweak some RenderNode API surfaces
* 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
2018-06-04 17:02:02 -07:00
Aurimas Liutikas
e701dc1799 Fix broken links in @see tags in framework docs.
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
2018-06-04 10:15:22 -07:00
Mihai Popa
6e8e27bf9a Fix monkey crash in smart selection animation
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
2018-05-25 14:01:23 +00:00
Mihai Popa
a9d27ea869 Fix monkey crash in smart selection animation
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
2018-05-25 11:57:17 +01:00
TreeHugger Robot
26595a7f8f Merge "Cheaper crash check post smart selection animation" 2018-05-22 14:33:28 +00:00
Abodunrinwa Toki
140ac5b2b5 Merge "End the TC session on terminal selection event actions" into pi-dev am: d0a4dddb9b
am: 6826a4ab53

Change-Id: Ifca422285ca1faa681e0b761efedc0a2bfb31561
2018-05-22 07:15:32 -07:00
TreeHugger Robot
d0a4dddb9b Merge "End the TC session on terminal selection event actions" into pi-dev 2018-05-22 13:56:22 +00:00
Mihai Popa
6df95fa087 Merge "Fix crash after smart selection animation" into pi-dev 2018-05-22 11:19:24 +00:00
Abodunrinwa Toki
f299fc0397 End the TC session on terminal selection event actions
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
2018-05-22 12:15:34 +01:00
Mihai Popa
6748ff37db Fix crash after smart selection animation
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
2018-05-22 10:42:16 +01:00
Mihai Popa
6849bd3296 Cheaper crash check post smart selection animation
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
2018-05-21 18:58:03 +01:00
Abodunrinwa Toki
228460c709 Merge "Refresh TCM settings when they change" into pi-dev am: 3fa564030f
am: f08646f13e

Change-Id: I2a7fc61dac52817b053a680b82c18514f76ec6b8
2018-05-17 11:13:47 -07:00
Mihai Popa
5b3a42319c Fix TextView#setText misplaced documentation
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
2018-05-17 16:42:22 +01:00
Abodunrinwa Toki
c2449b8361 Refresh TCM settings when they change
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
2018-05-17 11:29:29 +01:00
Mihai Popa
a875271fcc Check against null text in TextView constructor
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
2018-05-14 16:54:00 +01:00
android-build-team Robot
d364bcff96 Merge "Fix a typo in the API doc of TextView#setKeyListener()" into pi-dev am: 643d9256d9
am: 4a85bd7cfa

Change-Id: I50a49febfb87712d316dc96f1c9bc8c8c6fca727
2018-05-09 10:38:10 -07:00
Mihai Popa
cce6e82d35 Fix crash after smart selection animation
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
2018-05-09 10:33:02 +00:00
Yohei Yukawa
3128ebd880 Fix a typo in the API doc of TextView#setKeyListener()
Fix: 79436805
Test: make -j docs
      Then check out/target/common/docs/offline-sdk/reference/android/widget/TextView.html#setKeyListener(android.text.method.KeyListener)
Change-Id: I6c0d2a3af9434240c4e6e931185bc4f21b2e2b52
2018-05-08 17:11:33 -07:00
Selim Cinek
edf1f85ba4 Merge "Fix new notification showing timestamp "now" after turning off DND" into pi-dev am: 929ea36157
am: d48aca89b0

Change-Id: I93d5eb4291dcb13e417629f6abb008dc3217e3d0
2018-05-03 08:39:26 -07:00
Selim Cinek
929ea36157 Merge "Fix new notification showing timestamp "now" after turning off DND" into pi-dev 2018-05-03 15:15:42 +00:00
shawnlin
ea19d32a9b Fix new notification showing timestamp "now" after turning off DND
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
2018-05-03 11:06:52 +08:00
Mihai Popa
f86a6e94da Merge "[Magnifier-43] Refactor to remove code duplication" into pi-dev am: 90f197efe5
am: c184c0a7c6

Change-Id: I6fa2652be36d503432723a6eb03ddf60aa0eec0e
2018-05-02 13:29:40 -07:00
Daniel Santiago Rivera
a1b06eba14 Add setter and getter for Toolbar's collapse icon.
Bug: 78187236
Test: make java
Change-Id: Id0faacaa95c8c4ee54b3dec66e3b16e589ebd370
2018-05-02 18:17:55 +00:00
Mihai Popa
90f197efe5 Merge "[Magnifier-43] Refactor to remove code duplication" into pi-dev 2018-05-02 14:50:41 +00:00
Mihai Popa
5ab52b5740 Merge changes I63f2b185,I0d749c1a into pi-dev am: 724990d5ff
am: 0838228dff

Change-Id: Ieccbc53a8e859c36ed589a34fabe35650324c5fb
2018-05-02 05:22:19 -07:00
Mihai Popa
724990d5ff Merge changes I63f2b185,I0d749c1a into pi-dev
* changes:
  [Magnifier-42] Fix bug in window positioning
  [Magnifier-41] Fix behavior in windows with insets
2018-05-02 12:02:18 +00:00
Mihai Popa
f298068a7f [Magnifier-43] Refactor to remove code duplication
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
2018-05-02 10:30:40 +00:00
Mihai Popa
227034b863 [Magnifier-42] Fix bug in window positioning
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
2018-05-02 10:30:29 +00:00
Mihai Popa
0450a16759 [Magnifier-41] Fix behavior in windows with insets
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
2018-05-02 10:29:19 +00:00
Phil Weaver
220fc4f3b1 Merge "Fix bug and docs assuming progressBar min is 0 instead of getMin()" into pi-dev 2018-05-01 17:12:40 +00:00
Abodunrinwa Toki
049932ac0d Merge "FloatingActionMode.setOutsideTouchable" into pi-dev am: 8e7f8ad3ce
am: 3ebb4719d8

Change-Id: I994b5fff9f4a560bd000687020a3e41a1c2e04f9
2018-04-27 13:32:32 -07:00
Abodunrinwa Toki
8e7f8ad3ce Merge "FloatingActionMode.setOutsideTouchable" into pi-dev 2018-04-27 19:46:10 +00:00
Dake Gu
cc24386a86 Merge "Autofill: new UX for TV and support themes" into pi-dev am: 9ea13ca0b6
am: 1c62e1ef27

Change-Id: Iefa843e82fdc4093b478b2a16ecf407d6a46a888
2018-04-26 10:10:58 -07:00
TreeHugger Robot
9ea13ca0b6 Merge "Autofill: new UX for TV and support themes" into pi-dev 2018-04-26 16:40:40 +00:00