Commit Graph

9027 Commits

Author SHA1 Message Date
Ahaan Ugale
df75689d4d Translate: Text alpha animation on toggling translated state.
Apply a simple text alpha animation when toggling between original and
translated text. The text is fully faded out, then swapped to the new
text, then the fading is reversed.

Quick toggles are handled by ending the previous animation (which resets
the alpha value) when starting a new one. If the toggle is extremely
fast (<250ms for the currently defined animation duration), the text
stays in it's original state instead of swapping back-and-forth. This is
arguably not ideal, but anyway not worth the complexity for fixing.

There is an unhandled edge case where if the color is changed by the app
during the animation, the app's change would get overridden. It should
be rare and doesn't seem very important to fix.

Bug: 178651829
Test: atest CtsTranslationTestCases
Test: manual - across several apps, while scrolling, concurrently
 interacting with the app, concurrently closing the app, selecting text
 during the animation (with animation speed slowed down to see the
 effect).
Change-Id: I08a26de2253bb345f01186a6748b2d0ff6c2a419
2021-05-27 09:34:18 -07:00
TreeHugger Robot
87d4c9a9ca Merge "Fix a bug in sentence detection when input is too long." into sc-dev 2021-05-25 18:25:52 +00:00
TreeHugger Robot
7568c8cd9a Merge "Fix a bug in SpellCheckSpan update logic." into sc-dev 2021-05-25 18:00:58 +00:00
Stevie Kideckel
ef1e1dfb44 Merge "Add a flag for the fps of the AnalogClock" into sc-dev 2021-05-25 09:58:28 +00:00
George Mount
ebde5e48e6 Merge "Fix overscroll doesn't affect scrolling when released" into sc-dev 2021-05-24 15:19:49 +00:00
TreeHugger Robot
2fdb6bd709 Merge "Revert "Do not invoke textclassifier when dimissing the selection"" into sc-dev 2021-05-24 11:48:28 +00:00
Tony Mak
c103424e3a Revert "Do not invoke textclassifier when dimissing the selection"
Reverting ag/13435448.

The bug that the change fixed was that TextView invokes classifyText
when the selection is going to be dimissed due to an ACTION_UP event.
The fix was that we only  call showFloatingToolbar() if users are
dragging the selection curosr when we get an ACTION_UP event.

QA has found a bug recently.
When user selects some text and then scrolls the TextView, we hide the
floating toolbar temporarily. When user finishes scrolling, TextView
does not reshow the toolbar immediately due to the fix.

I don't have a fix that I feel comfortable to get into S given
that we are pretty late in the process, so reverting the fix.

Some more details:
IMO, the fix should be calling showFloatingToolbar() only if
TextView has a selection(i.e. TextView.hasSelection()) when we are
processing the ACTION_UP event in updateFloatingToolbarVisibility().
Sadly, it does not work because the selection is not actually dismissed
yet when we are trying to update the visiblity of
the floating toolbar in updateFloatingToolbarVisibility().
The selection is actually dismissed when Editor.onTouchUpEvent is
called to handle the UP event, but updateFloatingToolbarVisibility() is
called before that :/

Moving around the code so that updateFloatingToolbarVisibility() is
called after Editor.onTouchEvent() may work, but I am not comfortable
to get in a risky change like this at the moment.

Reason for revert: b/187862341

Bug: 187862341

Change-Id: Ic49c6792dc86c01fcc78a4d3bc5bfd85b7772197
2021-05-24 11:47:56 +00:00
Nikita Dubrovsky
75dc1f16e3 Merge "Remove verbose logcat messages in TextViewOnReceiveContentListener" into sc-dev 2021-05-23 22:58:38 +00:00
Nikita Dubrovsky
5175c12a13 Remove verbose logcat messages in TextViewOnReceiveContentListener
Bug: 170163502
Test: Manual
Change-Id: Ib34a4375294a2a696cbf26e110602b5de2825184
2021-05-21 16:35:13 -07:00
George Mount
d2cbe50f18 Fix overscroll doesn't affect scrolling when released
Bug: 188531406

When an EdgeEffect is flung past 0 into negative values, it
shows a stretch from the other side. To prevent this, the EdgeEffect
animation is now terminated when it reaches 0. I also made it so
that dragging to a value of 0 releases the EdgeEffect.

I also fixed the nested scrolling so that the stretch release
of ListView occurs before the onNestedPreScroll().

Test: new tests and manual testing
Change-Id: Ia20a6b96d25cf31ef143511828ddce5c33cee804
2021-05-21 18:28:23 +00:00
Joanne Chung
18b1d3bde4 Refine the ViewTranslationCallback usage.
Currently, TextView uses its default implementation even developers
uses setViewTranslationCallback() to set their customized
ViewTranslationCallback, we should only set default TextView
implementation if developers don't set it.

The onViewTranslationResponse() will call getViewTranslationCallback
instead of getting TextView default implementation directly. This can
make sure we can get the expected ViewTranslationCallback.

Bug: 183467275
Test: manual
Test: atest CtsTranslationTestCases

Change-Id: I41417140f8985aec6c80f1bca3cfba804727d5df
2021-05-21 19:11:14 +08:00
Qi Wang
2648035bda Fix a bug in sentence detection when input is too long.
When the unchecked length of the current sentence is too long, the
spell checker should check the first MAX_SENTENCE_LGNTH characters of
the unchecked part. In this case, detectSentenceBOundary should return
[textChangesStart, textChangeStart + MAX_SENTENCE_LENGTH)

Fix: 188875278

Test: manual test
Change-Id: I31847aed2d564f7bc1ff43c83adae3bb7c99c0d1
2021-05-21 17:58:31 +08:00
Qi Wang
7f2343de99 Fix a bug in SpellCheckSpan update logic.
The the text is changed, we need to remove all affected SpellCheckSpan.
However, the previous check logic can not work correctly, and may
leave some out-of-date SpellCheckSpan, which causes problem when the
SpellChecker tries to apply suggestions on those spans later.

Also fixed the bug that the offset is not calculated correctly when we
validate spell checker suggestions.

Fix: 188107864
Change-Id: I8dc806d96b6a75255277d6de013305557835cb6d
Test: atest CtsInputMethodTestCases:SpellCheckerTest
Test: atest android.widget.cts.TextViewTest
2021-05-21 15:15:06 +08:00
TreeHugger Robot
27500d78b3 Merge "Attaching broadcast receiver on attach/detach instead of everytime visibility changes" into sc-dev 2021-05-21 01:11:50 +00:00
Stevie Kideckel
697a23f0cb Add a flag for the fps of the AnalogClock
Bug: 188414386
Test: tested locally
Change-Id: I3e28f63bea6aafa0760c6938b706e44643fc12f3
2021-05-20 15:06:53 +00:00
Joanne Chung
86d3f3deae Merge "Translate TextView content description if exist" into sc-dev 2021-05-20 06:00:56 +00:00
Sunny Goyal
2d3879ea2d Attaching broadcast receiver on attach/detach
instead of everytime visibility changes

> Adding a broadcast receiver makes a synchronous system API call
  which can delay draw pass
> Also removing TIME_TICK broadcast, instead using an internal timer
  to aboud unnecessary calls while app is stopped

Bug: 188574817
Test: Manual
Change-Id: I37677aa40189bf4fb75e7e2372bda81ea3e6fda3
2021-05-19 12:51:15 -07:00
TreeHugger Robot
ee438f960a Merge "Deprecate Context#createApplicationContext" into sc-dev 2021-05-19 15:35:09 +00:00
Ryan Mitchell
c54ebba25b Deprecate Context#createApplicationContext
If an application caches an ApplicationInfo and uses it to call
Context#createApplicationContext, the app will not get the most recent
version of the overlays for that application. To make things worse, the
LoadedApk stored in ActivityThread#mResourcePackages is updated using
the old ApplicationInfo causing further uses of the cached LoadedApk to
return outdated information.

Deprecate Context#createApplicationContext, convert all internal uses
to Context#createPackageContext(String packageName, ...) and log
whenever any one calls Context#createApplicationContext with an
outdated ApplicationInfo to detect debug issues in using old infos.

Bug: 188059515
Test: change wallpaper and observe widgets get reloaded with most
      recent overlays
Change-Id: I2aeefa8c0e66264859109975a54c4f73f76ad710
2021-05-18 09:07:58 -07:00
George Mount
290fcdde7d Merge "Fixes minimum date in DatePicker" into sc-dev 2021-05-17 20:50:56 +00:00
Joanne Chung
9753899a97 Translate TextView content description if exist
Screen reader(Talkback) will read content description first if the
developers set. We only translate TextView text, this may cause the
screen reader will not read the translated text if the developers set
content description.

To fix the issue, we also send the content description to translate.
When the translated text is shown, we also set content description
with translated content description and reset to original content
description if show original text.

Bug: 187134784
Test: atest CtsTranslationTestCases
Change-Id: I6986384260627a0539780b7293d47666c442d852
2021-05-17 14:05:52 +08:00
George Mount
4f2b9ad2bd Fixes minimum date in DatePicker
Fixes: 158448787

When the day is earlier in than the minimum date, but
the year is later, then the year is changed, the date
gets set to a day that is earlier than the minimum date.
This CL ensures that the year change can't bring the
date outside of the range of minimum to maximum dates.

Test: manual testing
Change-Id: I0034bd513275267ecf9554f673533852e68dd854
2021-05-14 20:23:37 +00:00
Stevie Kideckel
4a787a1839 Performance/jank improvements to AnalogClock
This addresses rounding of the seconds hand fraction to avoid
advancing by inconsistent amounts.

It also moves to a less janky 30FPS update rate.

This also optimizes seconds ticking to only schedule callbacks as needed
and avoids spurious updates to the content description.

Also, potential NPE fix and dead code removed.

Bug: 186099601
Test: Local testing with sample app
Change-Id: I771b4c3f1d18f7836cd42202810a1495d25a9db5
2021-05-12 16:55:25 +00:00
Nikita Dubrovsky
4b2ab9bba3 Merge "Make drop consistent with paste for multiple text items in a ClipData" into sc-dev 2021-05-07 16:57:02 +00:00
Pierre Barbier de Reuille
6d82bd39e7 Merge "Save/restore view states when reapplying RemoteViews for color changes" into sc-dev 2021-05-06 18:54:54 +00:00
Nikita Dubrovsky
e480958234 Make drop consistent with paste for multiple text items in a ClipData
A ClipData can contain multiple items, for example:
```
ClipData clip = ClipData.newPlainText("label", "ONE");
clip.addItem(new ClipData.Item("TWO"));
clip.addItem(new ClipData.Item("THREE"));
```

When a clip like this is pasted, the TextView impl inserts a newline
between each item. When the same clip is inserted via drag-and-drop,
no newlines are inserted.

This change makes the behavior of drop and paste consistent by updating
drop to match the paste behavior (since pasting has been around longer
and is more common).

Bug: 187428338
Test: atest CtsWidgetTestCases:TextViewReceiveContentTest
Change-Id: I08f30e619b858a4586ab9b4ed287be28b218231e
2021-05-06 11:50:52 -07:00
George Mount
9d7658ac57 Merge "Allow fling during stretch in ListView" into sc-dev 2021-05-05 15:50:08 +00:00
Nader Jawad
603d612707 Merge "Update hole punch logic in HWUI" into sc-dev 2021-05-05 02:59:18 +00:00
Stevie Kideckel
691ff96db6 Save/restore view states when reapplying RemoteViews for color changes
This ensures that adapters have their caches filles and other benefits
such as lists maintaining their scroll positions

Bug: 183503469
Test: validated with local app that service is not called on drag for
colors changing and that flicker is removed

Change-Id: I043d1d7a547b012f7a12eb555b35854a9bb7109b
2021-05-04 23:18:45 +01:00
George Mount
d317ef65a8 Allow fling during stretch in ListView
Bug: 186430321

ListView should accept a fling while stretching.

Test: New test
Test: manual testing
Change-Id: I67221e06818d9953882e16d1c72f2d9e6b191ebb
2021-05-04 15:15:10 +00:00
Nader Jawad
197743ff9c Update hole punch logic in HWUI
--Updated HWUI holepunch logic for SurfaceView to
also apply the stretch to the hole punch
--Updated RenderNode callbacks to also include
an offset from the ancestor RenderNode that also
has a stretch configured on it
--Added new test activity to verify hole punch
logic

Bug: 179047472
Test: manual
Change-Id: Ibbaf8248a31839ba9dc352ecb9fef54e1276918e
2021-05-03 18:08:47 -07:00
George Mount
07406f3642 Allow EdgeEffect to fling during pull
Bug: 186430321

EdgeEffect was restarting the fling from the start if onAbsorb()
was called after onPullDistance(). This CL does not reset
the distance in onAbsorb().

Test: new test
Change-Id: I0657059c275f42cfe229a3aaa8bf37c87e0394f1
2021-05-03 22:45:10 +00:00
George Mount
b1aee44bea Remove edge effect type from the API.
Fixes: 186758538

Relnote: "Removes edge effect type from the API -- EdgeEffect now
supports only stretch edge effect for all applications."

Test: existing tests, modified to work with stretch
Change-Id: Iec7a9d4a0316ff3ba7297c4565bb881a1adcf949
2021-05-03 22:45:10 +00:00
TreeHugger Robot
7b0989f35d Merge "Dismiss magnifier correctly in concurrent editing scenario" into sc-dev 2021-05-03 15:44:37 +00:00
George Mount
02843213c0 Fling while overscrolled: ScrollView/HorizontalScrollView
Bug: 186430321

ScrollView and HorizontalScrollView was not allowing a fling
effect while overscrolling. This adds the ability to fling
while overscrolling.

Test: new test
Test: manual ApiDemos
Change-Id: Iebd402ff0f5b6f16518ecc5403e085cb58de5976
2021-04-29 20:37:56 +00:00
George Mount
a4b222f48d Merge "Allow intercept touch event while animating edge glow." into sc-dev 2021-04-29 15:21:51 +00:00
Mihai Popa
d32571e9b5 Dismiss magnifier correctly in concurrent editing scenario
Fixes: 186505600
Test: manual testing
Change-Id: I864f03e976be92c232f51a576043cb49731cda26
2021-04-29 11:04:59 +00:00
George Mount
109e474959 Allow intercept touch event while animating edge glow.
Bug: 185906621

During overscroll animation, there is no need to call
disallowInterceptTouchEvents(). This removed the
call so that parents can intercept touch events.

Test: Ia9ac6d81a5b60222f489ea87f31ecba0c1d48cea
Test: manual testing

Change-Id: Ie5d9428d95b86d7a976c2f3c519547151a45cec5
2021-04-28 21:47:12 +00:00
Yohei Yukawa
a35ebcf88e Fix stale EditorInfo upon EditText#setText()
This is a follow up to our previous CL [1], which added initial
surrounding text support into EditorInfo and let TextView support it.

What we overlooked was that calling TextView#setText() would trigger

  TextView#onCreateInputConnection()

before TextView#mText is updated to the new value.  As a result,
EditorInfo is initialized with a stale surrounding text information.

With this CL, EditorInfo will correctly be initialized with the new
text specified to TextView#setText().

One complicated thing in this CL is InputMethodManager also has some
issues about how to drop spurious

  InputMethodService#onUpdateSelection()

while InputConnection is being replaced with a new instance.  I ended
up having to introduce a hacky boolean

  Editor#mHasPendingRestartInputForSetText

to work around this in the TextView/EditText. This workaround is
expected to be removed/revisited as part of Bug 186582769.

 [1]: Ie04f2349b1157408aa8ed9044aea12ce99132cb4
      c486acc4d2

Fix: 161330778
Test: atest CtsInputMethodTestCases:EditTextImeSupportTest
Change-Id: Iee3b754eea319861b2eb955d6cc95ba13006b55e
2021-04-27 19:20:16 -07:00
TreeHugger Robot
1700fa9e5c Merge "Reduce animation completion epsilon to avoid early end." into sc-dev 2021-04-28 00:08:30 +00:00
Stevie Kideckel
cda49ca089 Merge "Fix some potential nullability issues in RemoteViews" into sc-dev 2021-04-27 20:10:27 +00:00
Stevie Kideckel
957a33fe0a Fix some potential nullability issues in RemoteViews
Test: Ran locally on device, all sample widgets still worked
Test: atest RemoteViewsTest
Bug: 185316709

Change-Id: I60c235ea196dd106325e79962e545c582a975168
2021-04-27 13:44:26 +00:00
Qi Wang
0ebb4d88a1 Merge "Validate spell checker suggestions before applying." into sc-dev 2021-04-27 06:26:43 +00:00
TreeHugger Robot
400dc92ebe Merge "Fix Magnifier position updates" into sc-dev 2021-04-26 22:27:40 +00:00
Vishnu Nair
f752c800d3 Fix Magnifier position updates
When the magnifier content moves relative to the parent surface,
it will call setPosition on the content surface control. This conflicts
with position updates called by the BlastBufferQueue adapter
causing a flicker on screen. Fix this by providing a wrapper surface
to BlastBufferQueue adapater to send buffer updates.

Fixes: 186072574
Test: Select text and see magnifier surface does not flicker or move
around

Change-Id: Idfcc06a5d90f400f69e5cbe91008a0cb59fd4646
2021-04-26 10:27:50 -07:00
Qi Wang
cfa318ee4d Validate spell checker suggestions before applying.
Fix: 185786752
Test: atest CtsInputMethodTestCases:SpellCheckerTest
Change-Id: Icf447fc3ab174bc17af0e823b830f5abef6071df
2021-04-26 10:06:37 +08:00
George Mount
e4f9d4f632 Reduce animation completion epsilon to avoid early end.
Fixes: 184892316

Changed the animation termination epsilons to make sure
that the animation doesn't end early and cause a jerky
end.

Test: visual inspection
Change-Id: I56e4ccb50cee95e713e92ffb659eff4dd026dd12
2021-04-22 16:20:25 +00:00
Chun-Yi Lee
6a213319a8 Merge "Move CtsAutoFillServiceTestCases to group presubmit-large" into sc-dev 2021-04-22 11:11:55 +00:00
Stevie Kideckel
32b16fa4fc Merge "Expose GridView/Layout APIs via @RemotableViewMethod" into sc-dev 2021-04-22 09:33:43 +00:00
easoncylee
e9f67379be Move CtsAutoFillServiceTestCases to group presubmit-large
The test config takes longer than 15mins to run. Move it to a dedicated
group for running slow presubmit Test Mapping test.

Some more context is in the referenced bug, e.g, b/174495337
The group will work exactly the same as presubmit for now.

Bug: 174654670
Bug: 174495337
Test: none
Change-Id: I946061e2c5a75b12ca370d172db32a8f7e8e8f68
2021-04-21 13:24:07 +00:00