Skip to content

Profile and settings branch - #16

Merged
Aredarn merged 4 commits into
mainfrom
profile_and_settings_branch
Jul 30, 2026
Merged

Profile and settings branch#16
Aredarn merged 4 commits into
mainfrom
profile_and_settings_branch

Conversation

@Aredarn

@Aredarn Aredarn commented Jul 30, 2026

Copy link
Copy Markdown
Owner

No description provided.

Aredarn added 4 commits July 30, 2026 09:29
This commit improves the accuracy of drag racing and track session calculations, adds permission safety to GPS providers, and standardizes ID types in DAOs.

**Key Changes:**

*   **`DragTimeCalculation.kt`:**
    *   Improved quarter-mile accuracy by measuring distance relative to the run's start (`runStartDistanceMeters`) rather than the total session distance.
    *   Ensures `isReadyForRun` is reset when tracking is reset.
*   **`TrackGeometry.kt`:**
    *   Refined line-crossing logic to only register "forward" crossings (`ENTERING` direction). This prevents duplicate lap triggers if a vehicle rolls backward over a start/finish line.
*   **`PhoneGpsProvider.kt`:**
    *   Added explicit permission checks for `ACCESS_FINE_LOCATION` and `ACCESS_COARSE_LOCATION` before starting location updates to prevent crashes or silent failures.
*   **`TimeAttackViewModel.kt`:**
    *   Simplified session ID assignment by directly using the return value of `sessionManager.startSession()`.
*   **DAOs (`RawGPSDataDao.kt`, `TrackCoordinatesDataDAO.kt`):**
    *   Updated `delete` methods to use `Long` for `sessionId` and `trackId` to maintain consistency with the rest of the database schema.
This commit updates the Room database schema to include proper indexing for foreign keys and upgrades the version to 2 with destructive migration enabled. It also implements lap record fetching for tracks and optimizes telemetry data insertion.

**Key Changes:**

*   **Database & Models:**
    *   Updated `ESPDatabase` to version 2 and added `fallbackToDestructiveMigration()`.
    *   Added indices to `sessionid`, `vehicleId`, and `trackId` across all data classes (`RawGPSData`, `SmoothedGPSData`, `LapTimeData`, `SessionData`, etc.) to improve query performance.
    *   Deleted unused default theme files: `Color.kt`, `Theme.kt`, and `Type.kt`.
    *   Deleted `TrackSessionViewModel.kt`.

*   **UI & Screens:**
    *   **`TrackListView.kt`:** Integrated `LapTimeDataDAO` to fetch and display the actual best lap record for each track instead of a placeholder.
    *   **`CarCreatorScreen.kt`:** Refactored styling to use the custom `TrackProTheme` colors instead of hardcoded hex values.
    *   **`DragScreen.kt`:** Optimized GPS data persistence by using `insertAll(dataBuffer)` instead of individual inserts in a loop.
    *   **`TimeAttackScreen.kt`:** Removed `DisposableEffect` that was managing ESP TCP connections.

*   **Logic & Calculations:**
    *   **`DragTimeCalculation.kt`:** Added "Half Mile" (804.672m) timing logic and refactored distance calculations to use a single `lastPoint` reference instead of a list of points.
    *   **`TrackGeometry.kt`:** Extracted constants for finish line width and latitude scaling.
    *   **`PostProcessing.kt`:** Removed debug log statements for smoothed speed.
    *   **`LapTimeDataDAO.kt`:** Added `getBestLapForTrack` query to retrieve the fastest completed lap for a specific track across all sessions.

*   **Configuration:**
    *   Updated `AndroidManifest.xml` to remove `ACCESS_BACKGROUND_LOCATION`.
    *   Updated Compose BOM to `2024.03.00` in `build.gradle.kts`.
…gration and dynamic theme switching.

**Key Changes:**

*   **Theme & Styling:**
    *   **`TrackProTheme.kt`:** Added `toMaterialColorScheme` to map custom racing-HUD colors to Material3 `ColorScheme`. Updated `TrackProTheme` to wrap content in a `MaterialTheme` provider.
    *   **`TrackProColors.kt`:** Refined color palettes for both Light and Dark modes, updating hex values for backgrounds, accents, and text for better contrast and visibility.
    *   **`MainActivity.kt`:** Implemented persistent theme selection using `SharedPreferences` and integrated it into the `TrackProTheme` call.

*   **UI Components:**
    *   **`CustomTextField.kt` & `DropDownMenuField.kt`:** Updated colors to use theme-aware attributes (`textPrimary`, `accentCyan`, `sectorLine`). Added "No tracks found" state to the track dropdown.
    *   **`CarCreatorScreen.kt`:** Redesigned the layout with a new top bar, updated card borders, and consistent typography. Switched hardcoded "Save Vehicle" button styles to theme-driven `deltaGood` colors.
    *   **`SettingsScreen.kt`:** Added an "APPEARANCE" section to toggle between Light and Dark themes.

*   **List Views:**
    *   **`DragTimesList.kt` & `TimeAttackListView.kt`:** Added empty state placeholders ("NO SESSIONS RECORDED") with specialized typography and spacing when no data is available.
    *   **`CarListView.kt` & `TrackListView.kt`:** Updated `AlertDialog` colors to use `bgCard` and themed text colors instead of hardcoded hex values.

*   **Refactoring:**
    *   Removed `DragTimesList` activity wrapper in favor of the composable view.
    *   Standardized section headers across screens to use consistent uppercase styling and letter spacing.
This commit introduces comprehensive sector split functionality for circuit timing, adds a global setting for unit preferences, and enhances the drag racing results screen with a map-based GPS trace and heatmap.

**Key Changes:**

*   **Sector Split Timing:**
    *   **`CircuitTimingManager` & `TimeAttackViewModel`:** Now support recording and tracking sector split times. Implemented logic to detect sector gate crossings and calculate deltas against the session's best.
    *   **`TrackBuilderScreen.kt`:** Added a "Mark Sector" button to allow users to define sector points during track creation.
    *   **`TrackGeometry.kt`:** Added `calculateSectorLines` to generate perpendicular gate lines for marked sector points.
    *   **`SectorTimeData`:** Added new DAO and data class to persist sector times in the database (Database version bumped to 3).
    *   **`TimeAttackScreen.kt`:** Added a `SectorSplitsRow` to display real-time sector times and deltas during a session.

*   **Unit Preferences:**
    *   **`SettingsScreen.kt` & `MainActivity.kt`:** Added a new setting to toggle between Metric (km/h, m) and Imperial (mph, mi) units.
    *   **`UnitFormatter.kt`:** (Internal utility) Integrated across `DragScreenListItem` and `LapDetailScreen` to dynamically format speeds and distances based on user preference.

*   **Drag Racing Enhancements (`DragScreenListItem.kt`):**
    *   Introduced a toggle between "Chart" and "Map" views.
    *   **`DragSessionMapView`:** Implemented a MapLibre-based view that displays the drag run path with a speed-based heatmap.
    *   Updated the speed trace chart to reflect the selected unit (km/h or mph).

*   **UI & Performance Improvements:**
    *   **`LapDetailScreen.kt`:** Enhanced the stats panel to include sector time breakdowns and unit-aware speed formatting.
    *   **`SpeedColorUtils.kt`:** Refactored speed-to-color mapping logic into a shared utility.
    *   Updated `TrackCoordinatesData` to include `isSectorPoint` and `sectorIndex` fields.
@Aredarn
Aredarn merged commit 4860969 into main Jul 30, 2026
2 of 3 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