The application employs a Local-First strategy for configuration. The for user preferences is the device’s local storage. There is currently no cloud synchronization for these settings; they are persisted immediately upon change to ensure a experience.
Reactive Updates: All settings are exposed as objects. This ensures that UI components automatically recompose when a setting changes without manual polling.
Sanitization: The repository performs input validation (e.g., parsing LocalTime for batch schedules) before persistence to prevent or malformed data states.
Implementation: Uses SharedPreferences for lightweight persistence.
Theme Generation: Instead of static XML themes, the app uses a dynamic engine to generate from a seed color. This is calculated at runtime and cached in memory during the session.
HCT Logic: Uses Hue-Chroma-Tone (HCT) color space logic (similar to the engine) to ensure high-contrast accessibility in both light and dark modes.
Non-Blocking Reads: SharedPreferences reads are wrapped in callbackFlow, which registers a listener on the background and emits updates to the UI thread safely.
Asynchronous Writes: All “set” operations are .
Dispatcher Policy: Writes are executed using Dispatchers.IO via the edit { ... } extension to ensure the remains responsive during disk I/O.
The HapticsManager acts as a specialized data consumer. It monitors the hapticsEnabled Flow from the SettingsRepository and the system’s HAPTIC_FEEDBACK_ENABLED setting.
Hardware Abstraction: It abstracts the complexity of Android’s evolving vibration APIs, using VibrationEffect.Composition on API 30+ for rich primitives and falling back to OneShot vibrations on older hardware.
Amplitude Control: For features like the calibration slider, it uses to provide tactile “ticks” that vary in strength based on user interaction.