Skip to content

Repository files navigation

Tapback

An Android distraction blocker. Uses an AccessibilityService to detect when you open a distracting screen (WhatsApp Status, Instagram Reels, YouTube Shorts, etc.) and automatically redirects you away — or shows a blocking overlay over infinite-scroll feeds.

Sideloaded only. Not for Play Store distribution.


Work in progress. Tapback is functional but actively developed. Some rules may break when target apps update their UI, edge cases exist, and rough edges are expected. If something isn't working for you, please open an issue — bug reports and feedback are welcome.


What it blocks

Rule App What it does
WhatsApp Status / Updates WhatsApp Clicks Chats when the Status or Updates tab opens
WhatsApp Status Viewer WhatsApp Goes to home screen when a status is playing
WhatsApp Communities WhatsApp Clicks Chats when the Communities tab opens
WhatsApp Calls WhatsApp Clicks Chats when the Calls tab opens
Instagram Reels Instagram Goes to home screen when the Reels tab opens
Instagram Explore Instagram Goes to home screen when the Explore/Search tab opens
Instagram Home Feed Instagram Shows a blocking overlay over the Home feed
Instagram Stories Instagram Navigates to Home after a configurable story limit (default 5)
YouTube Shorts YouTube Goes to home screen when the Shorts tab opens
YouTube Home Feed YouTube Shows a blocking overlay over the Home feed
Snapchat Spotlight Snapchat Goes to home screen when the Spotlight tab opens
TikTok For You TikTok Shows a blocking overlay over the For You feed
Facebook Watch Facebook Goes to home screen when the Watch/Video tab opens
X For You feed X (Twitter) Shows a blocking overlay over the For You home feed

Each rule can be toggled on/off independently from the app.


Requirements

  • Android 8.0+ (API 26), tested on Android 13+
  • ADB or Android Studio for sideloading
  • The target apps installed (WhatsApp, Instagram, YouTube, Snapchat, TikTok, Facebook, X) — only apps you have installed are affected

Setup

1. Build and install

Open the project in Android Studio. It will download the Gradle wrapper automatically on first sync. Then build and install:

Build → Make Project
Run → Run 'app'   (or adb install)

Or from the command line:

./gradlew assembleDebug
adb install app/build/outputs/apk/debug/app-debug.apk

If Android Studio complains about the Gradle wrapper .jar being missing, run once:

gradle wrapper --gradle-version=8.6

2. Grant overlay permission

The overlay feature (Instagram/YouTube Home feed blocking) requires the "Display over other apps" permission.

Open Tapback → tap Grant Overlay Permission if the button appears → grant it in Settings.

Or manually: Settings → Apps → Special app access → Display over other apps → Tapback → ON.

3. Enable the Accessibility Service

Settings → Accessibility → Installed apps → Tapback → toggle ON.

Android will show a permission dialog describing what the service can observe. Accept it.

The service must be re-enabled after a forced-stop or reinstall.


Using the app

The main screen shows the current service status and a toggle for each blocking rule.

Status indicators

  • Green — service is active and rules are running
  • Orange — service is paused (shows time remaining)
  • Red — accessibility service is not enabled

Pause — temporarily disable all blocking for 15 min / 30 min / 1 h / 2 h / 24 h. While paused, any active overlays are hidden.

Lock — same as Pause but the timer cannot be cancelled. Useful as a commitment device when you don't trust yourself to just un-pause it.

While paused and locked, the Pause button shows "Locked — timer running" and is disabled until the timer expires.


How it works

The BlockerAccessibilityService listens for all window change events. For each event from a watched package (WhatsApp, Instagram, YouTube, Snapchat, TikTok, Facebook, X), it inspects the accessibility node tree and checks it against RuleConfig. Events from other apps are used only to detect when the user has navigated away, so overlays can be dismissed.

Each rule defines:

  • signatures — one or more sets of node IDs / content-descriptions that identify the screen
  • action — what to do when a match is found: press Back, click a specific node, or show an overlay

The service uses a 1.5-second debounce per rule to avoid firing repeatedly on rapid layout changes.

The overlay (OverlayManager) is a TYPE_APPLICATION_OVERLAY full-screen view drawn over the target app. It disappears automatically when the blocked screen is left, or when the service is paused.

Settings (rule toggles, pause state, lock state) are stored in SharedPreferences via PrefsManager and persist across restarts.


Updating rules after a target app update

Detection is based on accessibility node IDs and content-descriptions, which can change when a supported app updates its UI. When a rule stops working:

  1. Open the target app and navigate to the screen you want to block.
  2. Dump the UI tree:
    adb shell uiautomator dump /sdcard/dump.xml && adb pull /sdcard/dump.xml
  3. Open dump.xml in a text editor. Search for keywords like Reels, Status, Shorts, Home.
  4. Find the relevant node. Note its resource-id and content-desc attributes.
  5. Update the matching ScreenSignature in app/src/main/kotlin/com/tapback/config/RuleConfig.kt.
  6. Rebuild and reinstall.

Known fragile points per app are documented in comments inside RuleConfig.kt.


Project structure

app/src/main/
├── AndroidManifest.xml
├── kotlin/com/tapback/
│   ├── BlockerAccessibilityService.kt   # Core engine — event handling, rule matching
│   ├── OverlayManager.kt                # System overlay for feed-blocking rules
│   ├── WindowUtils.kt                   # Utility for identifying transient system windows
│   ├── MainActivity.kt                  # Toggle UI, pause/lock, permission checks
│   ├── PrefsManager.kt                  # SharedPreferences wrapper
│   ├── config/
│   │   └── RuleConfig.kt               # All blocking rules — edit this to update signatures
│   └── model/
│       └── BlockRule.kt                 # BlockRule, BlockAction, and ScreenSignature definitions
└── res/
    ├── layout/activity_main.xml
    ├── values/                          # strings, colors, themes
    └── xml/accessibility_service_config.xml

ToS note

This app only reads the public accessibility node tree (passive observation) and sends standard navigation gestures. It does not hook into, decompile, or modify any target app's code. Account-level flags from passive accessibility reads are extremely unlikely, but no official ToS explicitly permits third-party tools triggering navigation actions. Use at your own risk.


Issues and feedback

Tapback is a work in progress. Rules break when target apps update, some features have rough edges, and there are likely bugs I haven't found yet.

If something isn't working or you run into a problem, please open an issue. Include your Android version, target app version, and a description of what happened — it helps a lot.

About

Android distraction blocker — redirects away from WhatsApp Status, Instagram Reels, YouTube Shorts, and more using an AccessibilityService

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages