A Minimalist Approach to Digital Detox

I built FocusLock because I found myself mindlessly scrolling through apps like Instagram and WhatsApp, wasting hours without realizing it. Existing blockers were either too easy to bypass or too bloated with features I didn’t need.

I decided to build my own solution with a specific goal: create high-friction access to distracting apps. To make it interesting, I developed the entire project on a minimal Arch Linux setup, without using the heavy Android Studio environment.

The “No-IDE” Workflow

Most Android apps are built using Android Studio, a massive piece of software that can be slow on older machines. I wanted to see if I could build a functional app using just a text editor and the terminal.

  • The Setup: I used a simple text editor to write code and the command line to compile it.
  • The Automation: I wrote a custom script that handles everything with one command. It compiles the code, installs it on my phone, launches the app, and starts showing the logs immediately.

This approach forced me to understand exactly how the Android build system works under the hood, stripping away the magic of complex development tools.

Seeing the Truth (Usage Tracking)

Before I could block the distractions, I needed to know the extent of the problem.

Android phones usually show you your screen time for the day or week. However, the system actually keeps data for much longer, but most apps don’t show it to you. I wrote a custom engine that digs into Android’s history logs.

  • The Challenge: Phone manufacturers often delete old data to save space, and the system splits usage into “buckets” (daily, weekly, monthly) that can be hard to combine.
  • The Solution: Instead of asking for a monthly summary, my code pulls 365 days of individual daily records and sums them up manually. This allowed me to visualize a full year of usage history, revealing exactly how many hours I had sunk into social media over the last 12 months.

The “Loser” Lock

The core feature of FocusLock is the blocker. I didn’t just want a “time limit” that I could ignore. I wanted a psychological barrier.

I used two powerful Android permissions to achieve this:

  1. The Watcher: A background service that monitors which app is currently on the screen.
  2. The Overlay: A permission that allows my app to draw over other apps.

How it works: When I open a blocked app (like TikTok), FocusLock detects it instantly. Before the app can load, FocusLock throws a solid black screen over it.

This screen cannot be swiped away. It contains a text box and a prompt. To access the app, I am forced to type a humiliating phrase: “i am a loser”.

If I type it incorrectly, or if I try to close the keyboard, the app kicks me back to the home screen. If I type it correctly, the blocker grants me temporary access. The friction of having to type that phrase every time breaks the dopamine loop of unconscious scrolling.

Overcoming Technical Challenges

Building this wasn’t straightforward.

The Keyboard Problem: At first, the overlay screen was “unfocusable,” meaning I couldn’t type in the text box. I had to adjust the window settings to allow the keyboard to appear on top of my overlay while still blocking the app underneath.

The Infinite Loop: The first version had a major bug. When I typed the password and the overlay disappeared, the “Watcher” immediately saw the distracting app again and instantly re-blocked it. I had to implement a memory system where the app remembers that I just unlocked it, allowing a temporary “snooze” period.

Conclusion

FocusLock started as a way to control my phone usage, but it became a lesson in minimalist development. By bypassing standard heavy tools and interacting directly with Android’s system services, I built a highly effective, lightweight tool that solves a real problem with a unique psychological twist.