Skip to content

Profile and settings branch - #17

Merged
Aredarn merged 5 commits into
mainfrom
profile_and_settings_branch
Jul 31, 2026
Merged

Profile and settings branch#17
Aredarn merged 5 commits into
mainfrom
profile_and_settings_branch

Conversation

@Aredarn

@Aredarn Aredarn commented Jul 31, 2026

Copy link
Copy Markdown
Owner

No description provided.

Aredarn added 5 commits July 30, 2026 18:37
…uested format.

---

### Refine GPS data handling, lap time precision, and MapLibre visualizations

This commit improves the accuracy and reliability of GPS data processing, refines lap time formatting, and enhances track/session map visualizations.

**Key Changes:**

*   **GPS Data Providers (`PhoneGpsProvider.kt`, `ESPTcpClient.kt`):**
    *   Updated `timestamp` assignment to use `System.currentTimeMillis()` upon receipt. This ensures consistent relative precision for elapsed-time calculations (e.g., 0-60 mph) compared to relying on variable-resolution hardware timestamps.
    *   Updated default `ip_address` in `config.json` to `192.168.4.1`.
*   **Time Utilities (`TimeUtils.kt`):**
    *   Updated lap time formatting and parsing to use hundredths of a second (`MM:SS.hh`) instead of milliseconds (`MM:SS.mmm`) to maintain consistency across the UI and storage.
*   **Map Visualizations (`TrackScreen.kt`, `TrackBuilderScreen.kt`):**
    *   **`TrackScreen.kt`:** Refactored static track rendering to handle single-point tracks gracefully (centering the camera without drawing degenerate lines).
    *   **`TrackBuilderScreen.kt`:** Added camera following logic to the track builder; the map now automatically eases to the latest recorded point at a fixed zoom level.
    *   Standardized MapLibre imports and utilized `CameraUpdateFactory` for smoother transitions.
*   **Drag Session UI (`DragScreenListItem.kt`):**
    *   Introduced a `smoothSpeeds` utility using a centered moving average to reduce GPS jitter in speed graphs and "Max Accel" calculations.
    *   Applied smoothed speed data to both the `GraphScreen` entries and the `DragSessionMapView`.
    *   Updated acceleration logic to calculate change in speed over change in time using smoothed values.
…unit support

This commit introduces a continuously updating live delta for TimeAttack sessions, adds the ability to automatically slice tracks into sectors, and implements a centralized `UnitFormatter` to support both Metric and Imperial units across the application.

**Key Changes:**

*   **Live Delta Timing:**
    *   **`CircuitTiming.kt`:** Now records a distance-based trace of the best lap. It calculates a real-time delta by comparing the current lap's elapsed time against the best lap at the same distance point.
    *   **`TimeAttackScreen.kt` & `TimeAttackViewModel.kt`:** Exposed and integrated `liveDelta` into the UI with a "● LIVE" indicator.
*   **Track Sector Management:**
    *   **`TrackGeometry.kt`:** Added `autoSliceSectors` to divide a track into equal distance intervals (2 to 6 sectors).
    *   **`TrackScreen.kt`:** Introduced a `SectorSlicerCard` allowing users to re-slice or clear sectors on existing tracks.
    *   **`TrackCoordinatesDataDAO.kt`:** Added `updateTrackCoordinates` for bulk-updating sector markers.
*   **Dynamic Units & Formatting:**
    *   Integrated `UnitFormatter` across `DragScreen`, `TimeAttackListItem`, `CarViewScreen`, and `TrackListView` to dynamically toggle between KM/H (Metric) and MPH (Imperial) based on user preference.
    *   Updated `CarCreatorScreen` to handle unit-aware input for top speed and acceleration.
*   **Map Enhancements:**
    *   **`TrackScreen.kt`:** Refactored `TrackStaticMapView` to support dynamic re-renders when sector markers change and added visual markers for sectors (Amber circles).
*   **Bug Fixes & Refactoring:**
    *   **`TrackBuilderScreen.kt`:** Corrected track length calculation to store values in kilometers to maintain consistency with database defaults.
    *   **`ESPConnectionTestScreen.kt`:** Applied unit conversion to the speedometer display.
This commit fixes a potential race condition during track saving and improves performance by offloading heavy track processing tasks to background threads.

**Key Changes:**

*   **`TrackBuilderScreen.kt`:**
    *   **Race Condition Fix:** The recording state (`isLiveRecording`) is now set to `false` and a snapshot of the `gpsPointsList` is created *before* launching the database insertion coroutine. This prevents Room from encountering concurrent modification exceptions if new GPS points arrive while the database transaction is being prepared.
    *   **Threading Optimization:** In `endTrackBuilder`, the CPU-intensive track post-processing, coordinate mapping, and distance calculations have been wrapped in `withContext(Dispatchers.Default)` to prevent blocking the UI thread during long recordings.
    *   Updated the database update call within `endTrackBuilder` to ensure it remains on the `IO` dispatcher.
    *   Minor code cleanup and improved commenting regarding thread safety and performance.
This commit introduces a more robust mechanism for syncing premade tracks and expands the built-in track database. It also improves the reliability of track rendering on the map.

**Key Changes:**

*   **Track Data Updates (`tracks.json`):**
    *   Added comprehensive coordinate data for **Hungaroring** (Hungary), **Mugello** (Italy), and **Circuit Paul Ricard** (France).
*   **Database & Seeding Logic:**
    *   **`TrackSeeder.kt` & `MainActivity.kt`:** Moved track seeding out of the `RoomDatabase.Callback` into a dedicated `TrackSeeder`. The app now syncs bundled tracks on every launch (using name-based deduplication) to ensure existing users receive new track updates.
    *   **`TrackMainDataDAO.kt`:** Added `getAllTrackNames()` to facilitate idempotent seeding.
    *   **`ESPDatabase.kt`:** Removed the legacy `onCreate` seeding logic in favor of the new `TrackSeeder` approach and enabled `fallbackToDestructiveMigration`.
*   **UI & Rendering Improvements:**
    *   **`TrackScreen.kt`:** Updated `LaunchedEffect` keys in the map rendering logic to include `mapRef` and `styleRef`. This ensures tracks are correctly drawn even if the data loads before the map interface is fully initialized.
    *   **`SettingsScreen.kt`:** Added an attribution notice for OpenStreetMap contributors.
*   **General:**
    *   Cleaned up unused imports and logging in `ESPDatabase.kt`.
…g a new centralized theme and component system. This update replaces hand-rolled styling and hardcoded layouts with reusable components like `AppTopBar`, `StatCell`, `AppCard`, and `SectionLabel`, ensuring visual consistency and improved readability across all screens.

**Key Changes:**

*   **Global Theme & Styling:**
    *   Updated `DarkTrackProColors` and `LightTrackProColors` with refined, desaturated accent colors and improved semantic color names (e.g., `danger`, `textFaint`).
    *   Integrated centralized `Spacing`, `TrackProShapes`, and `TrackProType` (typography) definitions across all screens.
    *   Standardized data visualization colors (gauges, charts, map markers) in a new `DataVizColors` object.

*   **Component Migration:**
    *   Replaced custom top bars with the `AppTopBar` component in `TrackScreen`, `TimeAttackListView`, `TrackListView`, `SettingsScreen`, and all list item details.
    *   Standardized statistics display using `StatCell` and `StatCellDivider`, replacing custom column/row implementations in vehicle, track, and session detail screens.
    *   Migrated specific UI patterns to `EmptyState`, `ToggleChip`, and `ExpandableGroup` components.
    *   Introduced `AppDropdownField` as a generic replacement for specialized dropdown implementations.
    *   Unified button styling using a new `PrimaryButton` component.

*   **Screen-Specific Improvements:**
    *   **`TrackScreen.kt` & `TrackBuilderScreen.kt`:** Standardized layout spacing and replaced manual borders/shapes with theme-defined values. Updated MapLibre colors to use `DataVizColors`.
    *   **`DragScreen.kt` & `DragScreenListItem.kt`:** Overhauled the speed gauge and telemetry charts to use theme-consistent colors. Refactored the metric grid using `StatCell`.
    *   **`LapDetailScreen.kt`:** Improved the heatmap mode switcher styling and unified the comparison statistics panel.
    *   **`CarViewScreen.kt` & `CarCreatorScreen.kt`:** Standardized performance stat grids and form fields.
    *   **`SettingsScreen.kt`:** Simplified the settings layout using a unified `SettingsToggleRow`.

*   **UI/UX Refinement:**
    *   Replaced all-caps text with sentence-case in several labels for better readability.
    *   Adjusted icon sizes and padding across the main dashboard drawer and action cards for a cleaner look.
    *   Updated delete confirmation dialogs to use standardized typography and danger colors.
@Aredarn
Aredarn merged commit 2b97618 into main Jul 31, 2026
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant