Commit Graph

7449 Commits

Author SHA1 Message Date
Abodunrinwa Toki
2b6020fc80 Optional parameters for TextClassifier APIs.
TextClassifier methods now take a @Nullable Options parameter which
is a container for optional parameters to its methods.
This way, if we need to pass an optional parameter to one of
TextClassifier's methods, we won't have to overload the method.
Instead, we'll introduce a new Options field.

This CL also adds a hidden optional field for suggestSelection.
This is used to make sure that "dark launched" models do not return
new selection indices to clients. Clients e.g. TextView that are
dark-launch aware may use the field to explicitly request for
dark-launch results.

Test: bit FrameworksCoreTests:android.widget.TextViewActivityTest
Test: bit CtsWidgetTestCases:android.widget.cts.TextViewTest
Test: Also see I843eadff8a2b674388055364c1f25c8d4ccea771
Change-Id: I58e44451ac8a8e3a5bc3959198447f5549870902
2017-11-03 14:02:38 +00:00
Andrew Solovay
ff9216a7c9 Merge "docs: Typo fixes" into oc-mr1-dev am: ab9449561e
am: 54e351b3cb

Change-Id: I522c023e03a9e49cb5d02b3d84d486dec16a8fba
2017-10-28 02:19:18 +00:00
Andrew Solovay
237c189723 docs: Typo fixes
See first comment for doc stage location.

Change-Id: I29661ffab0ff10021671df0b725c9f9b12430960

Bug: 67886596
Bug: 67932414
Test: make ds-docs
2017-10-27 15:29:57 -07:00
Evan Rosky
9e1c6328d2 Merge "Fixed several core and CTS tests" 2017-10-27 21:33:52 +00:00
TreeHugger Robot
bfc6a2bc36 Merge "Notification: Fix PendingIntent whitelisting" 2017-10-27 15:34:49 +00:00
Adrian Roos
fb92184ebc Notification: Fix PendingIntent whitelisting
Fixes several issues with the way PendingIntents are being whitelisted
from background check with Notifications. Most visibly, this causes the
whitelisting not to work on Notifications that use the DecoratedContentViewStyle,
but there are some conditions where the whitelisting breaks for regular
notifications too.

- After a Notification is rebuilt with Notification.Builder, the set
  of PendingIntents in the notification was not rebuilt.
  This broke the whitelisting whenever a PendingIntent is added after
  the Notification was already sent once. Workaround for broken platform
  releases: always use  a fresh Notification object, or clone before
  sending.

- Fixes PendingIntent.writePendingIntentOrNullToParcel to invoke the
  OnMarshalListener.
  This broke whitelisting for any PendingIntents attached to custom
  RemoteViews. Workaround for broken platform releases: Also attach
  the PendingIntent to the Notification's extras.

- Changes RemoteViews to keep the parcel cookies that were present
  during unparceling, such that they can be reapplied when it gets
  cloned.
  This broke whitelisting for any PendingIntents attached to a
  DecoratedContentViewStyle *even if added to extras*. Workaround
  for broken platform releases: none.

- Fixes Notification.whitelistToken mistakenly being static.
  There's an unlikely race condition where the field could be
  overriden with null by an incoming notification right as another
  notification is sent out. Workaround for broken platform releases:
  none.

Test: runtest -x core/tests/coretests/src/android/app/NotificationTest.java && runtest -x core/tests/coretests/src/android/widget/RemoteViewsTest.java
Bug: 68218899
Change-Id: I02e44040604a1d24422340611ae9e0332a611800
2017-10-27 15:46:40 +02:00
TreeHugger Robot
5a6a5417ec Merge "TextView: Support multiple textAssist menu items." 2017-10-25 00:03:21 +00:00
Abodunrinwa Toki
3049d8c1c0 TextView: Support multiple textAssist menu items.
Bug: 68049162
Test: bit FrameworksCoreTests:android.widget.TextViewActivityTest
Test: bit CtsWidgetTestCases:android.widget.cts.TextViewTest
Change-Id: I831e6933b584a2999f159dc2d80113ea9ba717f8
2017-10-24 21:28:56 +01:00
Andrei Stingaceanu
d27c36b870 [Magnifier - 6] Simplify API and configuration
* removed "scale" from the show(...) API
* made the zoom scale a dimension => the widget is
  fully self-configured
* fixed the magnifier not always scaling the content
  to the full pop-up window size

Bug: 63531115
Test: bit FrameworksCoreTests:android.widget.TextViewActivityTest
Test: bit CtsWidgetTestCases:android.widget.cts.TextViewTest
Test: manual test that shows the magnifier working
Change-Id: Ibf5c571970c8f6bd3cdbc6d46fbe57d08291783c
2017-10-24 11:17:35 +01:00
TreeHugger Robot
1eb19a3b87 Merge "[Magnifier - 5] Auto invalidate and misc" 2017-10-23 14:09:01 +00:00
Andrei Stingaceanu
ca189fe0fa [Magnifier - 5] Auto invalidate and misc
* due to having to make the API public, drop the
  invalidate_by_client strategy in favor of self invalidation
  by polling
* in Magnifier#show(...) stop sending screen coordinates in favor
  of view coordinates
* UI/UX:
** width from 200dp to 164dp
** fixed the shadow depth (elevation)
** fixed the rounded corners (2dp)

Bug: 63531115
Test: bit FrameworksCoreTests:android.widget.TextViewActivityTest
Test: bit CtsWidgetTestCases:android.widget.cts.TextViewTest
Test: manual test that shows the magnifier working
Change-Id: I6451767b0a618c0c4ea396ba3ee3144523dadc57
2017-10-23 12:25:15 +01:00
Sunny Goyal
9372ca079f Merge "Binding to the RemoteViewsService directly from the host" 2017-10-21 02:19:53 +00:00
Sunny Goyal
e1273ebbb7 Binding to the RemoteViewsService directly from the host
The host passes an IServiceConnection to the AppWidgetManager which
is used to bind to the RemoteViewsService. This allows the host to
recieve the connection callbacks directly instead of proxying it via
the AppWidgetManager. The host is also responsible for unbinding to
the service.

Bug: 26481160
Test: adb shell \
  am instrument -w -e class android.widget.RemoteViewsAdapterTest \
  com.android.frameworks.coretests/android.support.test.runner.AndroidJUnitRunner

Change-Id: Iac400095a319c3a43714c82fda7516be1ccc68af
2017-10-20 16:43:23 -07:00
Evan Rosky
adf5bec523 Fixed several core and CTS tests
Fixes in framework include:
- ListPopupWindow requests focus for itself so it can receive
  MENU key.
- PopupWindow uses setTransitionVisibility to avoid losing
  focus upon enter transition.
- First-traversal will explicitly handle FOCUS_AFTER_DESCENDANTS
  on the current focus if applicable -- details in code comment.

Fixes in tests usually just required focusing what they expected
to have initial focus; however, there were a couple tests that
had been broken for other reasons for a long time.

app.cts.ActionBarTest
app.cts.ToolbarActionBarTest
android.view.DisabledLongpressTest
android.widget.scroll.arrowscroll.ShortButtonsTest
android.view.VisibilityTest
android.widget.listview.ListScrollListenerTest
android.widget.listview.arrowscroll.ListOfThinItemsTest
andorid.widget.listview.arrowscroll.ListWithNoFadingEdgeTest
android.view.LongpressTest
android.widget.focus.ScrollingThroughListOfFocusablesTest
android.widget.gridview.GridScrollListenerTest

Bug: 67467972
Test: Failing tests should pass now.
Change-Id: I9e2fbfeb183eb777f35c67eca53e1f70809b7670
2017-10-20 11:10:05 -07:00
TreeHugger Robot
a18447dd4b Merge "FloatingToolbar updates" 2017-10-20 17:16:59 +00:00
Sunny Goyal
bbe20b0d49 Merge "Optimizing memory for RemoteViewsAdapter caches." 2017-10-20 16:36:58 +00:00
Sunny Goyal
dd60f4d28a Optimizing memory for RemoteViewsAdapter caches.
The cache holds large number of remoteViews each of which have a
separate copy of applicationInfo.
Also simplifying some cache objects

Test: Manually tested on device
Change-Id: I353239354d329d3b0219ade55d39fe3b89e3bb02
2017-10-19 14:42:05 -07:00
Andrei Stingaceanu
15af561efd [Magnifier - 3] Reduce number of calls to PixelCopy
* Magnifier#show() takes snapshots of the content and displays
  them in the Magnifier bitmap
* calling show(...) consecutive times with the same arguments is
  a no-op if already showing (to cater with the miriad of motion
  events produced by touch which end up calling show(...))
* introduced Magnifier#invalidate(...) which, if currently
  showing, forces updating the content using the last configuration
* clamped the start horizontal value of the Rect which delimits the
  content to show in order to avoid distorting the rendering of the
  magnifier content
* fixed invalidating the magnifier (invalidate() does not
  automatically call invalidate(RectF) !)

Bug: 63531115
Bug: 67296158
Test: bit FrameworksCoreTests:android.widget.TextViewActivityTest
Test: bit CtsWidgetTestCases:android.widget.cts.TextViewTest
Test: manual test that shows the magnifier working
Change-Id: I8e53dfb6582d541922fe05b60311658fb07ca880
2017-10-17 12:33:34 +01:00
Abodunrinwa Toki
9c881f227b FloatingToolbar updates
- Replace SHOW_AS_OVERFLOW_ALWAYS with SHOW_AS_ACTION_NEVER
 - MenuItem ordering
 - Allow textAssist items in overflow to show text with images
 - MenuItem label text now standard case (not allcaps)

Bug: 62447250
Test: bit FrameworksCoreTests:android.widget.TextViewActivityTest
Test: bit CtsWidgetTestCases:android.widget.cts.TextViewTest
Change-Id: I07fa06f433a34adfad20b371417c95ce76422456
2017-10-16 21:27:54 +01:00
TreeHugger Robot
0b57d2f561 Merge "[Magnifier - 4] Batch of tweaks" 2017-10-16 16:10:19 +00:00
Andrei Stingaceanu
451f947ffa [Magnifier - 4] Batch of tweaks
* magnifier zoom from 1.5 to 1.25
* max scale from 10 to 4
* magnifier shows over the text if there is no more space above
  instead of showing underneath the cursor
* paused the blink while showing the magnifier and resumed when
  dismissing

Bug: 63531115
Test: bit FrameworksCoreTests:android.widget.TextViewActivityTest
Test: bit CtsWidgetTestCases:android.widget.cts.TextViewTest
Test: manual test that shows the magnifier working
Change-Id: Ief3e0b7dc9e287e7dd1a9102548b1861598b69c4
2017-10-16 11:53:52 +01:00
TreeHugger Robot
02a20b7025 Merge "Added new ViewNode properties for Autofill (minEms, maxEms, maxLength)." 2017-10-13 18:13:04 +00:00
Abodunrinwa Toki
ba60ab604c Flags to enable/disable smart selection in EditText
1. smart_selection_enabled_for_edit_text
   Disables smart selection for editable text.
2. smart_selection_dark_launch
   Dark launch TextClassifierImpl.suggestSelection(...)
   In this mode we run the method, but never change the user's
   selection to measure the quality of the results based on what
   the user actually wanted.

Bug: 65959640
Test: Manually tested flags turn on/off feature with 'adb shell
settings put global' and GServices override.
Test: bit FrameworksCoreTests:android.provider.SettingsBackupTest
Merged-In: Iacc561c8ee004b0123de66ad1ee06b1f56b4e4b4
Change-Id: Iacc561c8ee004b0123de66ad1ee06b1f56b4e4b4
2017-10-13 16:45:31 +01:00
TreeHugger Robot
f055302a73 Merge "Flags to enable/disable smart selection in EditText" 2017-10-13 00:33:44 +00:00
Abodunrinwa Toki
0e6b43ed58 Flags to enable/disable smart selection in EditText
1. smart_selection_enabled_for_edit_text
   Disables smart selection for editable text.
2. smart_selection_dark_launch
   Dark launch TextClassifierImpl.suggestSelection(...)
   In this mode we run the method, but never change the user's
   selection to measure the quality of the results based on what
   the user actually wanted.

Bug: 65959640
Test: Manually tested flags turn on/off feature with 'adb shell
settings put global' and GServices override.
Test: bit FrameworksCoreTests:android.provider.SettingsBackupTest
Change-Id: Iacc561c8ee004b0123de66ad1ee06b1f56b4e4b4
2017-10-12 23:50:53 +01:00
Sunny Goyal
d7d0c691bf Updating documentation for setOnClickPendingIntent
Bug: 65464277
Test: N/A
Change-Id: I7bdc397375e6c49d47d24868a5427dd3990057cf
2017-10-12 12:36:19 -07:00
Felipe Leme
aa7e2294be Added new ViewNode properties for Autofill (minEms, maxEms, maxLength).
Test: cts-tradefed run commandAndExit cts-dev -m CtsAutoFillServiceTestCases -t android.autofillservice.cts.LoginActivityTest#testNewTextAttributes
Test: cts-tradefed run commandAndExit cts-dev -m CtsAutoFillServiceTestCases

Fixes: 38323227

Change-Id: I6d8606f2d0668644ae1bd33e982edef0ec1e8e63
2017-10-06 15:55:19 -07:00
Abodunrinwa Toki
98d3f0a820 Improve starting offset calculation
The previous implementation did not take into account the various
expansions that happen for OVERSHOOT and LEFT and RIGHT rectangles, thus
causing the initial shape to be an oval instead of a circle.

Test: manual - triggered smart select and verified that the intial shape
is a circle under the touch point for both single line and multiline
scenarios

Change-Id: I75175bc3972db3f0608ef364109e0571268da4af
2017-10-06 17:31:16 +01:00
Andrei Stingaceanu
060b3d7b5c [Magnifier - 2] Turn magnifier ON
Flip the flag for turning ON the magnifier attached
to Editor's handles.

Bug: 66657373
Test: bit FrameworksCoreTests:android.widget.TextViewActivityTest
Test: bit CtsWidgetTestCases:android.widget.cts.TextViewTest
Test: manual test that shows the magnifier working
Change-Id: I644c2b834a0c630e5a84a0b948b8667ea988eea6
2017-10-04 11:27:08 +01:00
Andrei Stingaceanu
6c591dd3c3 Merge "[Magnifier - 1] Initial implementation and wiring" 2017-10-04 09:38:53 +00:00
Roozbeh Pournader
e06eebf480 Rename mCursorDrawble to mDrawableForCursor
To go around app bugs caused by assuming that mCursorDrawable is an
array. The apps try to manipulate mCursorDrawable by using
reflection, but crash since they access it incorrectly after it
changed from an array to a single Drawable in
I249befaf70630bef435c8db9039e8aacf233bf7c.

Bug: 66988832
Test: mmm -j frameworks/base
Change-Id: I04fc930d786dd4c74b560d7a25d17353f49ea25b
2017-10-03 12:13:46 -07:00
Andrei Stingaceanu
d2eadfa4b1 [Magnifier - 1] Initial implementation and wiring
* implementation of a magnifier which can be attached to any view
* important APIs:
** show(float centerXOnScreen, float centerYOnScreen, float scale)
** dismiss()
* smart offset => shows below if there is no space above
* controlled by boolean flag (easy to turn off)
* attached the magnifier to Editor's handles
* vertically snaps to the middle of the line containing the
  selection
* horizontally snaps to the offset of the character where
  the selection starts/ends

Bug: 66657373
Test: bit FrameworksCoreTests:android.widget.TextViewActivityTest
Test: bit CtsWidgetTestCases:android.widget.cts.TextViewTest
Test: manual test that shows the magnifier working
Change-Id: I1d4616b8bb1210d869ac47dca137ea9636355250
2017-10-03 16:45:54 +01:00
TreeHugger Robot
d96b97b855 Merge "Do not draw rectangles with the same left and right boundaries" 2017-09-29 21:05:46 +00:00
Abodunrinwa Toki
be60f06a1b Increase the duration allowed for a TC result.
Increase the duration allowed for a TextClassifier (TC) result when
it is being initialized for the first time.
Initialization typically takes more time that other calls to the TC.
A timeout during initialization means the user doesn't see the
effect of running the TC the first time. Subsequent calls typically
work fine as they're less likely to timeout.
We increase this value only slightly because we don't want the user
waiting too long for a slow TC's result. Finding the right balance
is an art and most likely depends on the TC being used.

Note that although a TextView's TC can change for each individual
call to the TC, such a situation does not benefit from the bump in
the timeout. Again, we really want to discourage larger timeouts.

Fixes: 66217281
Test: bit FrameworksCoreTests:android.widget.TextViewActivityTest
Test: bit CtsWidgetTestCases:android.widget.cts.TextViewTest
Test: Manual test:
  - Delayed TextClassifier response by about 150ms (allowing only 50ms for initialization)
  - Before cl: Sometimes the result is not shown to the user the
    first time the textclassifier runs
  - After cl: Results consistently show for even for first
    textclassifier call
Merged-In: Iabc8279fa57ef6a9a2db0c7e9c7e3ab8c131bf02
Change-Id: Iabc8279fa57ef6a9a2db0c7e9c7e3ab8c131bf02
2017-09-29 21:41:54 +01:00
Petar Šegina
c1950a0052 Do not draw rectangles with the same left and right boundaries
These should not be drawn at all, but the expansion logic for OVERSHOOT
and LEFT and RIGHT rectangles will expand the rectangle into something
that gets drawn.

Test: manual - triggered smart selection and verified that rectangles on
non-primary lines do not get prematurely shown

Change-Id: I5235e4b214401e6ceee3f07bc5cc937907c261ba
2017-09-29 18:39:40 +01:00
TreeHugger Robot
7d208271e5 Merge "Invert the animation over RTL selections" 2017-09-29 15:04:53 +00:00
Abodunrinwa Toki
cbf064d3bc Merge "Increase the duration allowed for a TC result." 2017-09-29 14:21:32 +00:00
Petar Šegina
7c8196f1dc Invert the animation over RTL selections
When smart select is performed over right-to-left text (either
standalone or mixed with left-to-right text), the animation should flow
in from the opposite side than what it does over left-to-right text.

Test: manual - verify smart select still works
Test: manual - manually set the layout flags to RTL and verify the
animation behaves as expected
Test: bit FrameworksCoreTests:android.widget.SelectionActionModeHelperTest

Change-Id: I2e7766e7dfe74e0861e91fc50b061da74432aee0
2017-09-28 20:06:32 +01:00
TreeHugger Robot
0debe0b7f5 Merge "Replace stream operation with simple iteration" 2017-09-28 18:43:56 +00:00
Petar Šegina
59c41b2323 Merge "Fix clip expansion amount" 2017-09-28 16:17:30 +00:00
Petar Šegina
df2ff2bbf4 Merge "Do not specify the unchecked exception in the method signature" 2017-09-28 16:14:29 +00:00
Petar Šegina
18f3c3820f Do not specify the unchecked exception in the method signature
Test: manual - compile the framework to verify everything still works
Change-Id: Ifa69f824fcaa78c62f9be9bb9c281d2bf2716995
2017-09-27 20:27:24 +01:00
TreeHugger Robot
c014a7f1fb Merge "Simplifying writeToParcel for various actions" 2017-09-27 19:18:18 +00:00
Petar Šegina
cb2fdb8bb2 Replace stream operation with simple iteration
Although the stream approach is elegant, we already have a simple loop
iterating over the rectangles which we can reuse for finding the
starting rectangle and save the overhead of the stream / additional
iteration over the rectangles.

Test: manual - verify smart select still works
Change-Id: I4e4195ded4268a7c18ad1b0bc352a9c273396932
2017-09-27 20:18:03 +01:00
Abodunrinwa Toki
3521f3f430 Increase the duration allowed for a TC result.
Increase the duration allowed for a TextClassifier (TC) result when
it is being initialized for the first time.
Initialization typically takes more time that other calls to the TC.
A timeout during initialization means the user doesn't see the
effect of running the TC the first time. Subsequent calls typically
work fine as they're less likely to timeout.
We increase this value only slightly because we don't want the user
waiting too long for a slow TC's result. Finding the right balance
is an art and most likely depends on the TC being used.

Note that although a TextView's TC can change for each individual
call to the TC, such a situation does not benefit from the bump in
the timeout. Again, we really want to discourage larger timeouts.

Bug: 66217281
Test: bit FrameworksCoreTests:android.widget.TextViewActivityTest
Test: bit CtsWidgetTestCases:android.widget.cts.TextViewTest
Test: Manual test:
  - Delayed TextClassifier response by about 150ms (allowing only 50ms for initialization)
  - Before cl: Sometimes the result is not shown to the user the
    first time the textclassifier runs
  - After cl: Results consistently show for even for first
    textclassifier call
Change-Id: Iabc8279fa57ef6a9a2db0c7e9c7e3ab8c131bf02
2017-09-27 17:16:51 +01:00
Sunny Goyal
5b15392c9a Simplifying writeToParcel for various actions
> Using helper methods when writing and reading typed objects
> Moving the tag write outside the action, as it is read outside
  the action as well
> Removing usused tags

Test: am instrument -w -e class android.widget.RemoteViewsTest com.android.frameworks.coretests/android.support.test.runner.AndroidJUnitRunner
Bug: 65574108
Change-Id: Iaf51cae6ef9f82b70dc1f19c2f019af40c4424a2
2017-09-27 08:52:30 -07:00
TreeHugger Robot
6e408b2ad1 Merge "Fix crash due to TextView.getText() returning null." 2017-09-27 11:54:12 +00:00
Abodunrinwa Toki
8f22de0e7f Fix crash due to TextView.getText() returning null.
This CL ensures that a null text is not passed to
TextClassificationHelper.reset(...)

This CL does not handle the issue of TextView.getText() being null.

Bug: 65682674
Test: none
Merged-In: Id8bdc062ecf21cc14810586580fef9052672cfd8
Change-Id: Id8bdc062ecf21cc14810586580fef9052672cfd8
2017-09-27 11:52:21 +00:00
Abodunrinwa Toki
7c1e425838 Fix crash due to TextView.getText() returning null.
This CL ensures that a null text is not passed to
TextClassificationHelper.reset(...)

This CL does not handle the issue of TextView.getText() being null.

Bug: 65682674
Test: none
Change-Id: Id8bdc062ecf21cc14810586580fef9052672cfd8
2017-09-26 20:09:06 +01:00
Sunny Goyal
0ebf88133a Fixing wrong actions were written to parcel when copying
Bug: 66901470
Test: Manual and CTS
Change-Id: I292e0e7d890d4da522045f434982aeeae35eb0fe
2017-09-26 16:44:12 +00:00