Skip to main content

Data Strategy

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.

Key Repositories

  • SettingsRepository: The primary interface for all user-facing toggles, theme selections, and calibration data.
  • HapticsManager: A mediator that combines system-level haptic settings with user preferences to trigger tactile feedback.

Schema & Performance (Data Engineering)

Data is stored using a approach.

Persistent Keys

The following data points are managed within the ScrollTrackAppSettings file:
CategoryKey/FieldData TypeDescription
UI/UXselected_theme_paletteString (Enum)Current active .
UI/UXis_dark_modeBooleanForce dark/light mode override.
Calibrationscreen_dpiIntThe of the device for accurate physical scaling.
Behaviornudges_enabledBooleanMaster toggle for intervention notifications.
Behaviornudge_intervalIntFrequency of interventions in minutes.
Privacynotifications_retention_daysIntTTL (Time-to-Live) for stored notification metadata.
Batchingnotification_batch_timesSet<String>Scheduled times (HH:mm) for the “Post Box” feature.

Performance Optimization

  • 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.

Storage & Caching

  • 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.

Threading & Concurrency

  • 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.

Haptic Feedback Architecture

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.
Last modified on January 22, 2026