pGestures guide

The full reference. For an overview, see the README. Android app that adds thin, invisible touch zones on the screen edges and runs an action when you swipe, tap, double-tap or long-press them: back, home, recents, previous app, notifications, quick settings, power menu, split screen, lock screen, screenshot, flashlight, volume, media keys, assistant, camera, search, keyboard picker, auto-rotation, or launch any app.

How it works

 Edge zone window (TYPE_ACCESSIBILITY_OVERLAY)
   └─ EdgeZoneView ─ MotionEvents ─▶ EdgeGestureDetector ─▶ (zone, gesture)
                                          └─ SwipeClassifier            │
 GestureAccessibilityService ◀──────────────────────────────────────────┘
   ├─ SettingsRepository (StateFlow<AppSettings>, SharedPreferences)
   ├─ EdgeOverlayManager  (adds/positions one window per enabled edge, re-layouts on rotation)
   └─ ActionExecutor      (performGlobalAction, torch, audio, launch intents)
 MainActivity (Compose) ── edits the same SettingsRepository; the service picks changes up live.

Why the overlay lives inside the accessibility service. The zones are added with TYPE_ACCESSIBILITY_OVERLAY from the service's own WindowManager. Compared with a SYSTEM_ALERT_WINDOW overlay this needs no "Display over other apps" permission, draws above regular overlays, and Android 12+ treats it as a trusted window (no untrusted-touch blocking). The service is needed anyway to run the global actions, so it is the only thing the user enables.

The service uses app package names for app exclusions and previous-app tracking. Optional keyboard detection uses window types, which Android requires canRetrieveWindowContent="true" to expose. Interactive-window retrieval is enabled only while keyboard detection is on. The app never requests node trees or reads screen text, and has no network permission.

Settings

Automation broadcasts

Enable Broadcasts → Allow automation control first (off by default). Any other app can then change the master switch through the following actions; accessibility must already be enabled by the user:

x.vladgba.gestures.TURN_GESTURES_ON
x.vladgba.gestures.TURN_GESTURES_OFF
x.vladgba.gestures.TOGGLE_GESTURES

Set package x.vladgba.gestures and receiver x.vladgba.gestures.service.GestureControlReceiver in Tasker or another automation app, or use an explicit ADB broadcast:

adb shell am broadcast -n x.vladgba.gestures/.service.GestureControlReceiver -a x.vladgba.gestures.TOGGLE_GESTURES

While automation is allowed, master-switch changes emit x.vladgba.gestures.GESTURES_STATE_CHANGED with boolean extra gestures_enabled. These broadcasts report the saved switch, not whether the service is currently bound or temporarily paused by an exclusion.

Previous app. The service listens to window-state events and keeps only their package name (RecentAppTracker): the last two real apps, ignoring system UI and the keyboard, and noting when the user is on the home screen (then "previous" means the app just left). The action relaunches that app. The two package names are saved, so the history survives a service restart (app update, reboot). With no history yet it shows "No previous app yet" rather than guessing.

Gestures

EdgeGestures offered
Leftswipe right / up / down, tap, double tap, long press
Rightswipe left / up / down, tap, double tap, long press
Bottomswipe up / left / right, tap, double tap, long press (off by default)

Panels. Each edge can be split into equal panels (up to 5 on the left and right edges, 3 on the bottom), and every panel has its own bindings, so the same gesture can do something different depending on where along the edge it starts. Panels are numbered from the top (side edges) or from the left (bottom edge). Each panel is its own overlay window, so a swipe always belongs to the panel it started on. With Show touch zones on, neighbouring panels are tinted in alternating colours.

A single tap fires on release unless a double tap is bound on the same panel; only then does it wait for the configured double-tap timeout. Long press uses the configured hold time: it vibrates when recognised and runs when you lift the finger.

Actions run as soon as the finger lifts. The one exception is Home, Recents or split screen bound on the bottom edge, which waits 150 ms: with gesture navigation the launcher also watches touches in the bottom gesture area, and it cancels a transition it drives that starts before it has finished handling that touch (Recents would open and close at once). Side edges are not affected. When you assign one of those actions to the bottom edge, the app asks whether to keep the short delay or run at once, and the gesture list shows the choice under the action. With 3-button or 2-button navigation there is no conflict: these actions run at once and the question and warning are not shown.

Build & run

Requirements: Android Studio Ladybug or newer (JDK 17), Android SDK 35.

./gradlew :app:assembleDebug        # build
./gradlew :app:testDebugUnitTest    # unit tests (classifier, actions, panel layout, settings codec)
adb install -r app/build/outputs/apk/debug/app-debug.apk

Then open the app, tap Open accessibility settings and turn on pGestures.

Android 13+ sideloaded APKs: the accessibility switch is greyed out ("Restricted setting") until you open App info → ⋮ → Allow restricted settings. The app links to App info for that.

Enable Show touch zones in the app to tint the zones while you tune thickness, length and position.

Rotation and fullscreen regression check (debug builds)

Panels stay on the physical left/right/bottom edges as the display rotates. Length and position percentages use the live display dimensions, including in immersive apps, rather than app content bounds. Display changes are observed independently of service configuration callbacks, and panel windows ignore system-bar/keyboard inset fitting. Bindings keep their panel index: top to bottom on side edges, left to right on the bottom edge, in the current orientation.

A debug-only activity provides a repeatable fullscreen test without opening another app:

adb shell am start --activity-single-top -n x.vladgba.gestures/.debug.OverlayTestActivity --ei orientation 0 --ez immersive true
adb shell dumpsys window windows

Use orientation 1 for portrait, 0 for landscape or 8 for reverse landscape; use immersive false to restore visible bars. Check each pGestures:<EDGE>:<panel> window's mFrame against the display dimensions and saved zone percentages. Tap the center to close the test activity. The activity is excluded from release builds and does not change gesture preferences.

Project layout

app/src/main/java/x/vladgba/gestures/
  gesture/   EdgeZone, GestureType, SwipeClassifier (pure), EdgeGestureDetector
  action/    GestureAction (+ stable persistence keys), ActionExecutor
  data/      AppSettings + ZoneConfig (panel layout, pure), SettingsCodec (pure), SettingsRepository
  overlay/   EdgeOverlayManager, EdgeZoneView
  service/   GestureAccessibilityService
  ui/        MainActivity, SettingsScreen, Pickers, MainViewModel, Theme, Labels

Known limits / next steps