Logo

Command Palette

Search for a command to run...

Aegis

Aegis: Gamifying Android Digital Wellbeing & Discipline

Most app blockers fail because they rely on simple timers. You hit a button, the app locks, but you can easily disable it in settings. I wanted to build an app that couples productivity with RPG gamification, making discipline something you earn.

Aegis is a native Android productivity application built with Kotlin and Jetpack Compose that tracks habits and gamifies screen lockouts using Accessibility Services and wagers.

dYO? Visit the repository


🎮 The Gamified Economy

Instead of a basic schedule blocker, Aegis runs a fully integrated focus economy:

  • Focus Wallet: Successfully completing deep work blocks rewards you with Focus Coins.
  • Time Passes: Distracting apps (like Instagram or Twitter) can only be unlocked by purchasing 15-minute passes with your earned Focus Coins.
  • High-Stakes Wagers: Wager focus coins when setting up morning routines. Completing the routine doubles your coins; missing or deleting it forfeits them entirely.
  • RPG Progression: Accumulating Focus Coins increases your lifetime XP, unlocking permanent levels and custom titles (Novice up to Grandmaster).

🎨 Layout & Animations

Productivity apps should inspire focus through their look and feel:

  • Organic Design System: Built with modern beige/pastel background variables (#FAF9F6), soft rounded cards, and clean typography.
  • Morning Briefings: Features a full-screen custom curtain overlay greeting you on your first launch of the day, summarizing stats with smooth exit animations.
  • Radar & Heatmap Charts: Custom Canvas drawing streams paint dynamic, clean charts summarizing weekly performance and habit cycles.
  • Floating pill bottom navbar: A persistent, lag-free bottom navigational interface implementing custom layout translations.

🛠️ The Tech Stack

  • UI Toolkit: 100% Jetpack Compose for native declarative UI elements.
  • Language: Kotlin, utilizing coroutines and flows for async status handlers.
  • Local Persistence: Room Database mapping user routines, wagers, and transaction ledgers.
  • Android APIs: Accessibility Services, UsageStatsManager APIs for usage event detection, and Jetpack Glance for home screen widgets.
  • Cloud Integrations: Scheduled WorkManager rules triggering automatic database back-ups to the user's hidden Google Drive App Data folder.

🚀 Key Engineering Challenges

Direct Usage Tracking & Lockout Latency

Standard Android background workers check active apps periodically, creating lock latency that lets users view apps briefly. To build an unbreakable shield, Aegis registers a dedicated AegisAccessibilityService. It directly intercepts Android window status updates in real-time, matching active package IDs and overlaying a deep red BlockActivity lockout screen instantly with zero leakage.

Thread and Performance Optimization

Redrawing charts and list changes on every transaction caused rendering lags in early alpha releases. I resolved this by caching static mathematical variables (like canvas grid offsets, radar paths, and color lists) using Kotlin remember state blocks, preventing garbage collection bottlenecks.


🎓 What I Learned

Building Aegis taught me the power of custom Android system services and local data models. It helped me master:

  • Building performant accessibility and background services in native Android.
  • Implementing Glance homescreen widgets and background worker schedules with WorkManager.
  • Rendering custom visualizations directly using Android Compose Canvas.
  • Scaling complex offline-first database structures with robust migration support.