Skip to content

Commit 9b73f3a

Browse files
iskakaushikpcsosinski
authored and
pcsosinski
committed
Propoagate Tap events on Android hybrid views (flutter#19608)
Translate the coordinate from global flutterview to the specific embedded sub-view.
1 parent 0dc86cd commit 9b73f3a

File tree

1 file changed

+24
-5
lines changed

1 file changed

+24
-5
lines changed

shell/platform/android/io/flutter/plugin/platform/PlatformViewsController.java

+24-5
Original file line numberDiff line numberDiff line change
@@ -309,19 +309,38 @@ private MotionEvent toMotionEvent(float density, PlatformViewsChannel.PlatformVi
309309
MotionEventTracker.MotionEventId motionEventId =
310310
MotionEventTracker.MotionEventId.from(touch.motionEventId);
311311
MotionEvent trackedEvent = motionEventTracker.pop(motionEventId);
312-
if (trackedEvent != null) {
313-
return trackedEvent;
314-
}
315312

316-
// TODO (kaushikiska) : warn that we are potentially using an untracked
317-
// event in the platform views.
313+
// Pointer coordinates in the tracked events are global to FlutterView
314+
// framework converts them to be local to a widget, given that
315+
// motion events operate on local coords, we need to replace these in the tracked
316+
// event with their local counterparts.
318317
PointerProperties[] pointerProperties =
319318
parsePointerPropertiesList(touch.rawPointerPropertiesList)
320319
.toArray(new PointerProperties[touch.pointerCount]);
321320
PointerCoords[] pointerCoords =
322321
parsePointerCoordsList(touch.rawPointerCoords, density)
323322
.toArray(new PointerCoords[touch.pointerCount]);
324323

324+
if (trackedEvent != null) {
325+
return MotionEvent.obtain(
326+
trackedEvent.getDownTime(),
327+
trackedEvent.getEventTime(),
328+
trackedEvent.getAction(),
329+
touch.pointerCount,
330+
pointerProperties,
331+
pointerCoords,
332+
trackedEvent.getMetaState(),
333+
trackedEvent.getButtonState(),
334+
trackedEvent.getXPrecision(),
335+
trackedEvent.getYPrecision(),
336+
trackedEvent.getDeviceId(),
337+
trackedEvent.getEdgeFlags(),
338+
trackedEvent.getSource(),
339+
trackedEvent.getFlags());
340+
}
341+
342+
// TODO (kaushikiska) : warn that we are potentially using an untracked
343+
// event in the platform views.
325344
return MotionEvent.obtain(
326345
touch.downTime.longValue(),
327346
touch.eventTime.longValue(),

0 commit comments

Comments
 (0)