$ show pachi81/GlucoDataHandler
GlucoDataHandler is a multi-platform Android application (phone, Wear OS, Android Auto) that aggregates continuous glucose monitoring (CGM) data from numerous sources including LibreLinkUp, Dexcom Share, Medtrum, Nightscout, xDrip+, Juggluco, AndroidAPS, and notification reading from other diabetes apps. It presents glucose values, trends, deltas, IOB/COB, and historical charts via home screen widgets, lock screen overlays, Always-On Display, Wear OS complications and tiles, and Android Auto media player. The app features a highly configurable alarm system with per-type sound/vibration/snooze settings and full-screen notifications. The codebase is organized into four Gradle modules: `common` (shared library), `mobile` (phone app), `wear` (Wear OS app), and `auto` (Android Auto companion). The common module contains core data handling, a Room database for glucose history, a custom event bus (InternalNotifier), an abstract background task framework (BackgroundTask/BackgroundTaskService), and a chart rendering pipeline with bitmap caching (ChartBitmapHandler, BitmapPool). The mobile and wear modules provide platform-specific services, activities, preferences, and UI components. Health Connect integration and a local xDrip-compatible HTTP server are also included. The application demonstrates solid engineering with reusable patterns: the notifier pattern decouples data sources from UI updates; the background task framework abstracts periodic polling with alarm-based scheduling; and the bitmap pool reduces allocation pressure for frequent widget/complication renders. However, the codebase carries significant integration surface with third-party CGM services and deprecated API usages, posing medium technical drift risk. Test coverage is limited. The project is actively maintained with recent commits and open issue triage.
The LLM identified 3 files worth highlighting for reuse:
Implements an internal publish-subscribe event bus (`NotifierInterface` + `InternalNotifier`) that decouples data sources, alarm logic, and UI updates. Components register with a `NotifySource` filter to receive only relevant events (data change, alarm, time tick). This pattern is cleanly isolated and could be extracted as a lightweight event system for any Android app needing intra-process communication without framework dependency.
Provides an abstract framework for periodic background tasks (`BackgroundTask` base class with `start()`/`stop()`/`alarmReceived()` and `doTask()`). Concrete tasks (e.g., `DexcomShareSourceTask`, `NightscoutSourceTask`) extend this to implement data fetching. The framework uses `AlarmManager.setExactAndAllowWhileIdle` for precise scheduling and supports dynamic interval changes. This pattern is reusable for any Android app requiring reliable periodic work with minimal battery impact.
Manages the creation and caching of chart bitmaps for widgets and complications. It uses a `BitmapPool` to reuse bitmap objects, reducing allocation overhead. The handler coordinates rendering via `ChartCreator` and stores rendered bitmaps indexed by key (e.g., time range). This pattern is directly reusable in any Android app that renders dynamic images (graphs, icons) for remote views or Wear OS tiles, where memory efficiency is critical.