125 Commits

Author SHA1 Message Date
Amir Hardon
345ae7d373
Delegate a11y events and action to/from embedded Android platform views. (#8250)
Delegate a11y events and action to/from embedded Android platfrom views.

This handles delegation of:
  * AccessibilityNodeProvider#performAction
  * ViewGroup#requestSendAccessibilityEvent
  * View#onHoverEvent

Additionally updates the currently input accessibility focused node state that is
tracked by the a11y bridge when an embedded view's node is focused.
2019-03-25 14:26:49 -07:00
Amir Hardon
06635d38a9
Mirror Android platform views a11y tree in the Flutter a11y tree. (#8237)
This PR mirrors virtual a11y tree of embedded platform views in the Flutter
a11y tree.

Non virtual hierarchies are not currently supported.

Only works on Android versions earlier than Android P as it relies on
reflection access to hidden system APIs which cannot be done starting
Android P.

A11y is not yet working as we also need to delegate a11y events from the
platform view to the FlutterView. This will be done in a following PR to
keep the change size a little saner.
2019-03-21 15:26:44 -07:00
Amir Hardon
6a8a45fc4f
Have the AccessibilityBridge attach/detach itself to the (#8229)
PlatformViewsDelegate.

Since onDetachedFromWindow can be called after the activity was
destroyed, the previous call to detach the accessibility bridge could
have crash as the NativeFlutterView was already null.
2019-03-20 12:26:30 -07:00
Amir Hardon
45f69ac471
Plumb a reference of PlatformViewsController and AccessibilityBridge to each other (#8208)
This is in preparation for implementing platform views a11y on Android.

And e2e working prototype is available here: https://github.com/amirh/engine/tree/a11y_hacks

flutter/flutter#19418
2019-03-19 15:48:45 -07:00
Michael Klimushyn
1d10e0eb67
Guard against NewAPI failures (#8048)
Adds minimum SDK checks around minimum APIs.

flutter/flutter#28848
2019-03-08 13:33:58 -08:00
Matt Carroll
6145e9046a
Android Embedding PR 13: Integrated text input, keyevent input, and some other channel comms in FlutterView. (#7979) 2019-02-28 15:02:56 -08:00
Matt Carroll
18ad03d49d
Fixed an Android keyboard entry bug that was introduced by the embedding refactor. (#28438) (#7954) 2019-02-25 19:15:49 -08:00
Matt Carroll
2f4a38dbd3
Android embedding refactor pr3 add remaining systemchannels (#7892)
Merging back in after reversion. Fixed some messaging issues in FlutterNativeView and corrected some message parsing.
2019-02-20 17:05:31 -08:00
Dan Field
6d7eb52185
Revert "Android embedding refactor pr3 add remaining systemchannels (#7874)" (#7886)
This reverts commit f4fba6d7110338caf3878cf42e26e17744108d00.
2019-02-20 11:18:12 -08:00
Matt Carroll
f4fba6d711
Android embedding refactor pr3 add remaining systemchannels (#7874) 2019-02-19 15:51:13 -08:00
Chris Bracken
163a2fd5e1
Revert "Android embedding refactor pr3 add remaining systemchannels (#7738)" (#7849)
From build log:
```
../../flutter/shell/platform/android/io/flutter/view/FlutterView.java:95: error: cannot find symbol
    private final LocalizationChannel localizationChannel;
                  ^
  symbol:   class LocalizationChannel
  location: class FlutterView
../../flutter/shell/platform/android/io/flutter/view/FlutterView.java:172: error: cannot find symbol
        localizationChannel = new LocalizationChannel(dartExecutor);
                                  ^
  symbol:   class LocalizationChannel
  location: class FlutterView
2 errors
```

This reverts commit 256db4bc23b7931509233df0dc04e44e16608229.
2019-02-15 15:03:19 -08:00
Matt Carroll
256db4bc23
Android embedding refactor pr3 add remaining systemchannels (#7738) 2019-02-15 13:45:24 -08:00
Matt Carroll
211adeac3a
Introduced a number of Java system channels in io/flutter/embedding/engine/systemchannels/ (#7500) 2019-02-06 17:07:30 -08:00
Jason Simmons
395937380c
Log errors returned from method channel invocations in the text input plugin (#7476)
See https://github.com/flutter/flutter/issues/25715
2019-01-14 17:26:05 -08:00
Jason Simmons
41222d0555
Update usage of some Android APIs that are deprecated in API level 28 (#7261) 2018-12-19 17:39:53 -08:00
Dan Field
8b73b9d42c
Fix javadoc for Android-28 (#7254)
* Fix javadoc for Android-28

* build javadoc as part of pre-submit
2018-12-19 09:24:02 -08:00
Todd Volkert
f79f7f6312
Allow inferred types using diamond syntax (#7237) 2018-12-17 16:35:10 -08:00
Ian Hickson
8a7ae957ff
Undeprecated BigInteger support, but document what it actually does. (#6903) 2018-12-15 08:32:20 -08:00
Rafael Ring
9071a39dd2 Fix keyboard not showing for targetSdk 28 (#6985)
After bumping the targetSdk of Flutter apps to 28, the keyboard doesn't open anymore when inputting text on an Android Pie devices. The problem is caused by a change on the way the focus in handled: when the call `mImm.showSoftInput(view, 0);` is made, the currently focused view is the `DecorView` from the `Activity` hosting Flutter but the passed view reference (`view` argument) is the `FlutterView`. As the `InputMethodManager` checks if both views are the same before showing the keyboard, it never appears because the `FlutterView` never has focus.
As Flutter doesn't have any input views as far as the Android side is concerned, the focus should always stay on the `FlutterView` itself and thus, this PR changes the `TextInputPlugin` to focus on the `FlutterView` as soon as it's created, fixing the keyboard issue.

Co-authored-by: Igor Borges <igorborges12@gmail.com>
2018-12-10 21:01:12 -08:00
Michael Goderbauer
1e7e676e4d
Remove unused import (#6854) 2018-11-13 23:31:56 -08:00
Amir Hardon
266b0986de
Release the surface texture entry when the platform view is disposed. (#6829)
We were leaking the texture after the view was disposed.
2018-11-12 14:23:25 -08:00
Michael Goderbauer
70a1106b50
Unify copyright lines (#6757) 2018-11-07 12:24:35 -08:00
Shaoxing Wang
26f437f377 Fix crash when removeViewImmediate invoked from platform view (#6266)
* Fix crash when removeViewImmediate invoked from platform view

* Clear animation before remove view from mFakeWindowRootView
2018-10-15 16:09:10 -07:00
Kirill Nikolaev
68a42e3f47 Add nullability annotations to MethodChannel/MethodCall. (#6393)
This works towards resolving https://github.com/flutter/flutter/issues/19888.
2018-10-02 15:02:16 -07:00
Kirill Nikolaev
27f77cbef5 Document that all MethodChannel callbacks must be called on the main thread. (#6245)
This further addresses https://github.com/flutter/flutter/issues/14568.
2018-09-27 15:48:29 -07:00
Gary Qian
8247ce26ba
Implement restore functions on Android and iOS (#6322)
This will not be active on the Framework until https://github.com/flutter/flutter/pull/22221 lands.
2018-09-25 13:46:38 -07:00
Amir Hardon
02901b78c6
Decouple PlatformViewsController from FlutterView. (#6303)
Decouple PlatformViewsController from FlutterView.

Instead of getting a FlutterView instance, depend on the specific interfaces required by
PlatformViewsController (BinaryMessenger, TextureRegistry, and Context).

This allows using PlatformViewsControlling in the flutter/embedding
code.
2018-09-21 15:40:17 -07:00
Simon Lightfoot
9f0ad8b794 Fixes negative end selection offset. (#6171) 2018-09-05 12:12:21 -07:00
jslavitz
1c76824186
entering a character with a selection deletes the selection (#6113) 2018-08-30 10:29:04 -07:00
Amir Hardon
ad4e87d07d
Convert synthesized Android motion events to long and not to int. (#6103) 2018-08-28 12:12:47 -07:00
amirh
0914926014
Allow passing extra creation parameters for embedded Android views. (#6081)
This allows plugins to pass extra parameters from the Dart side to the
platform view constructor.
2018-08-24 11:15:14 -07:00
amirh
2ff1626335
Support LTR/RTL layout directions for embedded Android views. (#6057) 2018-08-20 16:22:38 -07:00
amirh
c06432da47
Delay the removal of the onDrawListener. (#6052)
In Android O removing the ViewTreeObserver.onDrawListener from the
listener call crashes. Instead we post a runnable to remove it.
2018-08-20 12:13:26 -07:00
amirh
be0c3143c5
Add views added to the WindowManager into the presentation view tree. (#6043)
The default WindowManager implementation in Android's Presentation is
delegating addView/removeView/updateViewLayout calls to the global
WindowManager.
This can result in a crash when an embedded view is trying to e.g show a
PopupWindow.

This change adds a custom WindowManager that overrides
addView (and removeView/updateViewLayout) and adds the view to the
presentation's view tree.

Note that views might keep a reference to the window manager which
might be an issue when we move a view from one virtual display to
another (due to a resize). For this reason when re-sizing we are not
creating a new window manager for the new presentation, but updating the
window manager's references to be relevant for the new presentation and
re-use it.
2018-08-17 17:01:42 -07:00
amirh
a389dc595f
Cast MotionEvent timestamps to Number. (#5994)
Dart might choose to marshall the timestamps to a Java Long or Integer.
Casting directly to int was crashing when the timestamp wass a Long.
2018-08-10 12:46:49 -07:00
amirh
14af0348bc
Complete the AndroidView resize call only after a new frame is ready. (#5968)
This allows the framework to know that a frame with the resized view is
ready and to behave deterministically to workaround the jank issue
described in flutter/flutter/19572
2018-08-07 18:56:34 -07:00
amirh
ffbafc852d
Flush all embedded Android views on hot restart. (#5929)
* Flush all embedded Android view on hot restart.

Adds an OnEngineRestarted method to PlatformView, this is currently only
implemented for Android where we need to use it for embedded views.

* review comments followup

* rename to OnPreEngineRestart, call before Clone
2018-08-03 08:54:12 -07:00
Amir Hardon
d2d8bf3941 Pass touch events to embedded Android views with dispatchTouchEvents.
Was previously calling onTouchEvent directly which doesn't make the
event go through the full pipeline (e.g onInterceptTouchEvent is not
called).
2018-07-25 12:21:51 -07:00
Amir Hardon
2169086529 Synthesize Android MotionEvents with the long form obtain method.
The simple form MotionEvent.obtain method I used before does not allow
to synthesize multi pointer events.
2018-07-25 12:21:51 -07:00
amirh
42bd86d6db
Make the virtual display's presentation window non focusable. (#5845)
When the FlutterView's window loses focus Flutter cannot bring up the
keyboard (so e.g tapping on text fields doesn't work).

This workaround makes sure that Flutter text fields are working but
unfortunately now the embedded Android view cannot bring up the keyboard
as it's window is not focused.

Submitting this until as a stop gap while we're trying to figure out if
it's possible to allow both windows to bring up the keyboard.
2018-07-25 08:51:56 -07:00
Jonah Williams
d1c71e5206
add text capitalization support to ios and android (#5752) 2018-07-19 18:07:18 -07:00
amirh
3054f31837
Add touch events to the platform views method channel API. (#5796) 2018-07-18 15:20:59 -07:00
amirh
80a85e4a17
Implement PlatformViewsController. (#5722)
Each platform view created (by a plugin supplied factory) is attached to
a virtual display.
The virtual displays are controlled by VirtualDisplayController objects.
The PlatformViewsController maintains a mapping from a platform view's
id to its VirtualDisplayController, which allows it to operate on the
virtual display for a given platform view ID when asked so over the
method channel.

This is using API level 20 APIs, on lower API levels all platform views
method channel calls are noops.
We can make this work on API 19 with some refactoring to the
TextureRegistry (allow the engine Java code to recycle a texture entry
id).

This CL also adds a platform view id parameter to the
PlatformViewFactory#create() method. This allows plugins to route
platform channel messages to specific instances of a platform view.

TBD in future CLs:
  * Forward touch events to the platform views.
  * Support accessibility for platform views.

flutter/flutter#19030
2018-07-13 14:08:24 -07:00
Jonah Williams
c5a63d28bf
rollback chrome change (#5721) 2018-07-11 15:28:33 -07:00
amirh
68d81a31f4
Platform Views: Android and MethodChannel APIs, and implementation skeleton. (#5684)
To keep the scope of this CL as small of possible I'm leaving the actual
implementation of the platform view mechanics to a following CL.

This CL introduces:
  * A PlatformViewsController class which will be responsible for creating,
    resizing, and disposing platform views.
  * A PlatformViewRegistry which is exposed through the PluginRegistry
    and allows plugins to register factories for platform views.

Android plugin code will add support for a new platform view type by
implementing PlatformViewFactory, and registering a factory with the
registry, e.g:
```java
registrar.platformViewRegistry().registerViewFactory(
  'webview',
  new FlutterWebViewFactory()
);
```
On the Dart side, the framework will ask the engine to create new
platform views by sending a create message over the platformviews method
channel with the unique platform view type id, dimensions, and a unique
id allocated by the framework for the new platform view instance.
The platformviews method channel is also used for resizing and disposing
platform views.
2018-07-11 14:11:15 -07:00
Jonah Williams
e89d843497
Swap definitions of SystemChrome apis to match iOS (requires framework change when rolling) (#5609) 2018-07-10 17:36:31 -07:00
amirh
51785d244d
Remove unused Java imports (#5663) 2018-07-03 09:21:03 -07:00
matthew-carroll
061e899b55
Support all keyboard actions. (#11344) (#5620)
* Support all keyboard actions. (#11344)
2018-07-02 06:58:01 +00:00
Mehmet Fidanboylu
d7e3f2d6e7
Fix lint errors to prepare for building Android files in Google (#5440) 2018-06-01 10:16:50 -07:00
Simon Lightfoot
abd74ed5ed Add support for physical keyboards on Android (#5324)
* Fixes flutter/flutter#7943
* Fixes flutter/flutter#9347
* Fixes flutter/flutter#11177
2018-05-24 15:21:33 -07:00