[Android] fix hcpp gestures. (#162859)

We only need to conditionally send motion events to the platform_view_2
channel. This can be done with an override in the controller, the
existing surface classes don't need to be touched.
This commit is contained in:
Jonah Williams 2025-02-07 12:53:34 -08:00 committed by GitHub
parent d48820528c
commit 745ac10e83
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 5 additions and 21 deletions

View File

@ -888,12 +888,6 @@ abstract class AndroidViewController extends PlatformViewController {
/// call's future has completed.
bool get requiresViewComposition => false;
/// True if the experimental hybrid composition controller is enabled.
///
/// This value may change during [create], but will not change after that
/// call's future has completed.
bool get useNewHybridComposition => false;
/// Sends an Android [MotionEvent](https://developer.android.com/reference/android/view/MotionEvent)
/// to the view.
///
@ -1179,9 +1173,6 @@ class HybridAndroidViewController extends AndroidViewController {
);
}
@override
bool get useNewHybridComposition => true;
@override
int? get textureId {
return _internals.textureId;
@ -1206,6 +1197,11 @@ class HybridAndroidViewController extends AndroidViewController {
Future<void> setOffset(Offset off) {
return _internals.setOffset(off, viewId: viewId, viewState: _state);
}
@override
Future<void> sendMotionEvent(AndroidMotionEvent event) async {
await SystemChannels.platform_views.invokeMethod<dynamic>('touch', event._asList(viewId));
}
}
/// Controls an Android view that is rendered as a texture.

View File

@ -1473,14 +1473,6 @@ class _AndroidViewSurfaceState extends State<AndroidViewSurface> {
@override
Widget build(BuildContext context) {
if (widget.controller.requiresViewComposition) {
if (widget.controller.useNewHybridComposition) {
// TODO(jonahwilliams): make it actually work.
return _PlatformLayerBasedAndroidViewSurface(
controller: widget.controller,
hitTestBehavior: widget.hitTestBehavior,
gestureRecognizers: widget.gestureRecognizers,
);
}
return _PlatformLayerBasedAndroidViewSurface(
controller: widget.controller,
hitTestBehavior: widget.hitTestBehavior,

View File

@ -49,7 +49,6 @@ class FakeAndroidViewController implements AndroidViewController {
this.viewId, {
this.requiresSize = false,
this.requiresViewComposition = false,
this.useNewHybridComposition = false,
});
bool disposed = false;
@ -148,9 +147,6 @@ class FakeAndroidViewController implements AndroidViewController {
@override
bool requiresViewComposition;
@override
bool useNewHybridComposition;
}
class FakeAndroidPlatformViewsController {