-
Notifications
You must be signed in to change notification settings - Fork 188
Add support to recive MotionEvent.ACTION_OUTSIDE #170
Copy link
Copy link
Open
Description
This is useful to dismiss overlay windows when the user taps something outside the overlay window(like google translate overlay).
I patched the package this way to make my use-case work, but it's not a general solution.
diff --git a/android/src/main/java/flutter/overlay/window/flutter_overlay_window/OverlayService.java b/android/src/main/java/flutter/overlay/window/flutter_overlay_window/OverlayService.java
index f50d6a3..6a613cd 100644
--- a/android/src/main/java/flutter/overlay/window/flutter_overlay_window/OverlayService.java
+++ b/android/src/main/java/flutter/overlay/window/flutter_overlay_window/OverlayService.java
@@ -167,7 +167,8 @@ public class OverlayService extends Service implements View.OnTouchListener {
WindowSetup.flag | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS
| WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN
| WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR
- | WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED,
+ | WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED
+ | WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH,
PixelFormat.TRANSLUCENT
);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S && WindowSetup.flag == clickableFlag) {
@@ -407,6 +408,12 @@ public class OverlayService extends Service implements View.OnTouchListener {
}
dragging = true;
break;
+ case MotionEvent.ACTION_OUTSIDE:
+ if (OverlayService.isRunning) {
+ Context context = getApplicationContext();
+ final Intent i = new Intent(context, OverlayService.class);
+ context.stopService(i);
+ }
case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_CANCEL:
lastYPosition = params.y;
@@ -468,4 +475,4 @@ public class OverlayService extends Service implements View.OnTouchListener {
}
-}
\ No newline at end of file
+}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels