Skip to content

Repository files navigation

FocusLock 🔒

Lock your phone. Lock in your focus.

FocusLock is a minimalist Android "digital lockbox" app. Set a timer, and your phone becomes a black screen with only a countdown — you can't exit, switch apps, or doom-scroll. When the timer ends, it vibrates and unlocks automatically. Perfect for studying, deep work, and breaking phone addiction.

Main Focus Stats Pomodoro

✨ Features

  • Hard lock — intercepts Back / Home / Recents / app-switching / recents-gestures during a focus session. Watches window-layer changes (so gesture-nav "swipe up and hold" can't slip through), closes the Overview screen and yanks you back to the focus screen; if you swipe the app away from Recents, it relaunches instantly. Only a reboot gets you out.
  • Notification bar stays usable — read and reply to messages while locked. Incoming calls always work.
  • 🍅 Pomodoro mode — work → short break → work… auto-looping, with a long break every 4 rounds. Breaks unlock automatically.
  • 📊 Stats — a calendar heatmap of daily focus time, a 14-day bar chart, and streaks.
  • Whitelist — pick the apps you're still allowed to open (e.g. WeChat).
  • Backup & restore — an offline "recovery code" bundles your whitelist, history, settings, and Pro license so you can restore everything after reinstalling or switching devices.
  • Pro upgrade — one-time purchase unlocks Pomodoro, full stats, and unlimited whitelist. Device-bound activation code.
  • End reminders — multi-burst vibration + sound + notification when a session / stage finishes.

🆓 Free vs Pro

Feature Free Pro
Black-screen focus lock
Whitelist up to 3 apps unlimited
🍅 Pomodoro loops
📊 Full stats

🛠️ Tech Stack

  • Kotlin + Jetpack Compose (Material 3)
  • 100% offline — no network permission, no data leaves the device
  • minSdk 26 (Android 8.0+) · targetSdk 35
  • No third-party runtime dependencies

🇨🇳 中文说明见 README_zh.md

🔧 Build

Requirements: JDK 17 + Android SDK (platform 35, build-tools 35).

# clone
git clone https://github.com/<your-name>/focuslock.git
cd focuslock

# build debug APK (no signing config needed)
./gradlew assembleDebug

# build signed release APK — first create keystore.properties in the project root:
#   storeFile=keystore/release.keystore
#   storePassword=YOUR_PASSWORD
#   keyAlias=focuslock
#   keyPassword=YOUR_PASSWORD
./gradlew assembleRelease

Output APKs are under app/build/outputs/apk/.

🧠 How the lock works

Android won't let a normal app fully trap the user, so FocusLock stacks four layers:

  1. Accessibility Service — swallows Back / Recents keys, and watches both WINDOW_STATE_CHANGED and WINDOWS_CHANGED events. Gesture-nav's "swipe up and hold" opens Overview without a key event, so the window-layer listener is what catches it.
  2. Recents / launcher interception — when the Overview screen appears, the service closes it and relaunches the focus screen; the Launcher (home) is not whitelisted, so pressing Home bounces straight back.
  3. Task-removal recovery — if you swipe the app away from Recents, the foreground service (START_STICKY) notices via onTaskRemoved and pulls the focus screen back immediately.
  4. Screen Pinning (startLockTask) — with the system's Screen pinning switch on, Android itself disables Home and the recents gesture: the strongest layer. The app shows a warning (and a shortcut) when that system switch is off.

Plus: Foreground Service + WakeLock keeps the countdown accurate with the screen off and fires vibration/sound at the end.

⚠️ Honest limit: rebooting, force-stopping, or adb uninstall can always bypass any app. A 100%-kiosk lock needs Device Owner mode (a separate provisioning setup).

📦 Backup & restore

Settings → Data backup → generate a recovery code (copy it to your notes / cloud). After reinstalling or on a new phone, paste the code to restore your whitelist, history, settings, and Pro license.

💰 For sellers / commercial use

See SELLER-GUIDE.md (Chinese) for the full selling guide: pricing, activation-code flow, and buyer-facing scripts.

📄 License

MIT — free to use, modify, and learn from.


⭐ If FocusLock helped you, give it a star! ⭐

Every ⭐ motivates the next feature. Thank you for your support! 🙏

About

Lock your phone. Lock in your focus. A minimalist Android focus & screen-lock app (Kotlin + Jetpack Compose).

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages