Skip to content

Proposal: Rewrite Android app in Jetpack Compose #61

@salmon-21

Description

@salmon-21

Summary

I've rewritten the HCGateway Android app from React Native/Expo to native Jetpack Compose + Kotlin. The rewrite addresses several open issues and brings significant improvements to sync reliability, performance, and UI.

Branch: compose-rewrite

Motivation

The React Native implementation has several fundamental issues:

  • Material 3 compliance requires workarounds (custom Switch, SVG icon hacks, color token mapping)
  • Expo version compatibility and native rebuild cycles for every dependency
  • Android-only app deeply integrated with Android APIs (Health Connect, foreground services, FCM) — React Native bridge layer adds unnecessary complexity

What changed

Architecture

  • Jetpack Compose + Kotlin with MVVM, Hilt DI, StateFlow
  • DataStore replaces AsyncStorage
  • WorkManager replaces rn-foreground-service (OS-managed, Doze-aware)
  • OkHttp Authenticator for automatic 403 token refresh
  • Health Connect Jetpack SDK directly (no bridge layer)

Sync Performance Improvements

Problem (RN) Solution (Compose)
Full 30-day re-read every sync Health Connect Changes API (delta sync)
34 types processed sequentially Coroutines async/awaitAll (parallel)
HR/Sleep/Speed: 1 POST per record + 3s delay Batch POST (delay removed)
setTimeout-based queue (unreliable) Structured coroutines (reliable)

Bug Fixes

UI/UX

  • Material You dynamic colors + light/dark/system theme (instant switch via AppCompatDelegate)
  • M3 Expressive components (wavy progress, loading indicator, button shapes)
  • Material Shared Axis X transitions (via material-motion-compose)
  • Predictive back gesture support
  • Sync card with New vs Server record count comparison
  • Pull-to-refresh with periodic auto-refresh
  • Settings screen: sync mode, interval, auto sync toggle, theme, boot start, Sentry toggle
  • Permission onboarding flow (Health Connect, notifications, battery optimization)
  • Open source licenses screen
  • Connection status card with network monitoring and auto-retry

API Addition

  • GET /api/v2/counts endpoint — returns record counts per type for the authenticated user
  • API-side bulk_write optimization for handling large record batches without timeout

Screenshots

Setup Login Home (not synced)
Setup Login Home not synced
Syncing Synced New data detected
Syncing Synced New data detected
Date Picker Settings Custom Interval
Date Picker Settings Custom Interval

Compatibility

  • Same package name (dev.shuchir.hcgateway)
  • Same API endpoints (v2) — fully backward compatible
  • Same Health Connect permissions (34 record types)
  • Same Firebase FCM integration
  • Same Sentry error reporting (with opt-out toggle)

Open for discussion

I'd love to hear your thoughts on this rewrite. Happy to submit a PR if you're interested in merging it.


🤖 Generated with Claude Code

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions