TeslamateAPI returns pressure already in the user's preferred unit.
Remove incorrect bar→PSI conversion that caused 42 PSI to display as 610 PSI.
Fixes#46
- Stats: Record cards height now scales with fontScale to prevent vertical text clipping
- Stats: Added TextOverflow.Ellipsis for horizontal overflow fallback
- Dashboard: Elevation label no longer wraps unit to next line
Fixes#47
- Move "Most Distance Day" record from Drives to Distances category
- Make gap records (Longest w/o Charging, Longest w/o Driving) tappable
- Add GapRecordDialog showing duration and start/end dates
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
* feat(stats): add new records and categorized swipeable UI
- Add new records: longest gap without charging, longest gap without
driving, longest driving streak, biggest battery gain, biggest
battery drain
- Organize records into 4 swipeable categories: Drives, Battery,
Weather & Altitude, Distances
- Add horizontal pager with emoji+label indicators
- Compute driving streak in Kotlin (Room doesn't support window
functions in CTEs)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* fix(stats): fixed page height with 6 records per page constraint
- Each page now displays exactly 6 record slots (3 rows × 2 columns)
- Categories with more than 6 records are split into multiple pages
- Added page indicator dots for multi-page categories
- Added RECORDS_PER_PAGE constant with comment documenting the hard
constraint for future updates
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* fix(stats): enforce fixed row height for consistent page size
- Set RECORD_CARD_HEIGHT = 72.dp for each row
- Each row now has fixed height regardless of content
- Empty placeholder boxes fill the same space as cards
- Prevents page resizing when swiping between categories
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* fix(stats): remove redundant category title from record pages
The swipe indicator already shows current category, no need for title
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* docs: update changelog with swipeable record categories
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
* chore: bump minSdk from API 26 to API 29
This enables SQLite window functions (LAG, LEAD, etc.) for efficient
record calculations without requiring sync pre-computation.
Android 10 (API 29) was released in September 2019 and covers 95%+
of active Android devices as of 2026.
* feat(stats): add SQL query for max distance between charges
Uses SQLite LAG window function to efficiently find the maximum
distance traveled between consecutive charges. Includes both
all-time and date-range variants for year filtering support.
* feat(stats): add MaxDistanceBetweenChargesRecord domain model
Add new record type to QuickStats for tracking the maximum distance
driven between two consecutive charging sessions.
* feat(stats): integrate max distance between charges in repository
Wire up the new DAO query to QuickStats for both all-time and
year-filtered views. No sync required - data is computed instantly
from the existing charges summary table.
* feat(stats): display max distance between charges in Records UI
Add 'Longest Range' record showing the maximum distance traveled
between two consecutive charges. Displays with battery emoji and
date range, tapping navigates to the ending charge detail.
* feat(stats): add SQL query for max distance between charges
Uses a self-join with correlated subquery to efficiently find the
maximum distance traveled between consecutive charges. Includes both
all-time and date-range variants for year filtering support.
* fix(stats): use sum of drives instead of odometer diff for longest range
The odometer difference between charges can include unlogged drives
(e.g., when TeslaMate was down). Now we sum actual logged drives
between charges, which gives accurate results even with data gaps.
* feat(stats): add popup dialog for longest range record details
When tapping the 'Longest Range' record, show a dialog with:
- Total distance and date range summary
- Scrollable list of all drives that make up the record
- Each drive is tappable to navigate to drive details
This provides full context about what drove the record instead
of just navigating to a single charge.
* docs: simplify changelog entries for users
Stats for Nerds now displays costs in the user's configured currency
instead of always showing EUR. This affects:
- Total Cost in Charges Overview
- Avg Cost/kWh in Charges Overview
- Most Expensive charge record
- Priciest/kWh charge record
Cherry-picked from hotfix/0.8.3 (v0.8.3)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* feat(dashboard): add charging glow effect around car image
When the car is charging, a glowing effect now appears around the car
image on the dashboard. The glow:
- Follows the exact shape of the car (extracted from PNG alpha channel)
- Uses the palette accent color matching the car's exterior
- Has a 70px blur radius for a soft, attractive effect
- Only appears when actively charging
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* feat(dashboard): add breathing glow animation when charging
The car image now displays a breathing glow effect when the vehicle
is charging:
- Glow pulses smoothly in opacity (30% to 90%) with sine easing
- Color shifts subtly from accent color toward AC/DC charging color
- AC charging: shifts toward green (StatusSuccess)
- DC charging: shifts toward orange (StatusWarning)
- 2 second animation cycle
- Glow follows the exact shape of the car using alpha channel extraction
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* docs: add breathing glow effect to changelog
---------
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
* feat(drives): add top speed histogram chart
Add a fourth swipeable chart to the Drives view showing maximum speed
per day/week/month. The speed is displayed in km/h or mph depending
on the user's measurement system preference.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* docs: update changelog with filter and chart improvements
- Charges AC/DC filter now applies to summary card and charts
- Drives distance filter now applies to summary card and charts
- Drives now has a fourth chart showing Top Speed per period
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
The distance filter (Commute/Day trip/Road trip) now affects all
components in the Drives view:
- Summary card shows totals for filtered distance category only
- Histogram charts display data for filtered distance category only
- Drive list continues to show filtered results
This provides a consistent view when analyzing specific trip types.
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
The AC/DC filter now affects all components in the Charges view:
- Summary card shows totals for filtered charge type only
- Histogram charts display data for filtered charge type only
- Charge list continues to show filtered results
This provides a consistent view when analyzing AC-only or DC-only
charging sessions.
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
* feat(charges): add swipeable charts for energy, cost, and count
Add HorizontalPager with three swipeable chart views:
- Energy per Day/Week/Month (existing)
- Cost per Day/Week/Month (new)
- Number of Charges per Day/Week/Month (new)
Charts are grouped by the same time granularity based on the selected
date filter. Page indicator dots below the chart show current position.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* feat(drives): add swipeable charts for count, time, and distance
Add HorizontalPager with three swipeable chart views:
- Number of Drives per Day/Week/Month (existing)
- Time Spent Driving per Day/Week/Month (new)
- Distance Travelled per Day/Week/Month (new)
Charts are grouped by the same time granularity based on the selected
date filter. Distance chart respects metric/imperial unit setting.
Page indicator dots below the chart show current position.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* fix(drives): rename time chart to 'Driving time per...'
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
Add filter chips to show only AC or DC charging sessions:
- ChargeTypeFilter enum with ALL, AC, DC options
- Toggle behavior: tap selected filter again to reset to ALL
- Filter chips use matching colors (green for AC, orange for DC)
- Filtering logic based on dcChargeIds from local database
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
Remove moshi-kotlin (reflection-based adapter) since the project uses
KSP code generation with @JsonClass(generateAdapter = true).
Benefits:
- Smaller APK size (no reflection library)
- Faster JSON parsing (generated code vs reflection)
- Cleaner dependency tree
Note: The Moshi kapt deprecation warning during hiltJavaCompileDebug
is a known Hilt bug and will persist until Hilt fixes it or Moshi 2.0
removes kapt support entirely.
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
- Add circular gauge showing charging rate relative to max capacity
- AC (green): gauge fills based on current vs max requested amps
- DC (yellow): gauge fills based on power vs max (250 kW NMC, 170 kW LFP)
- Show AC charging details below SoC bar (Voltage, Current, Phases)
- Add battery chemistry detection (LFP vs NMC) based on trim_badging
Closes#27
The charges screen histograms now display total energy charged (kWh)
per day/week/month instead of the number of charging sessions.
This is more useful for users with smart charging systems (like Octopus)
that optimize costs by splitting charging into multiple partial sessions.
Fixes#18
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
Per F-Droid reviewer feedback - use global Binaries field instead of
per-build binary field since the URL pattern is consistent.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add dependenciesInfo block to disable Google's encrypted dependency metadata
- Bump version to 0.8.2 (versionCode 13)
- Update fastlane changelog and F-Droid metadata
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Remove unnecessary submodules and sudo blocks - this is a standard
Gradle project that builds with default F-Droid infrastructure.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* chore: add Makefile for easier debug builds
Add Makefile with targets for building, installing, and running debug
builds on connected devices. Update DEVELOPMENT.md to document the
available make targets.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* feat: add F-Droid and fastlane metadata for app store publishing
- Add fastlane metadata structure (title, descriptions, changelogs, screenshots, icon)
- Add F-Droid build recipe reference (com.matedroid.yml)
- Update CLAUDE.md with fastlane maintenance instructions
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
Add Makefile with targets for building, installing, and running debug
builds on connected devices. Update DEVELOPMENT.md to document the
available make targets.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* refactor(dashboard): remove chart icon from stats button overlay
Keep only the arrow indicator for the stats navigation button
on the car image, making the UI cleaner and less cluttered.
* docs: add changelog entry for stats button simplification
- Pull-to-refresh now triggers a background sync to fetch new data
- Automatic sync every 60 seconds while Stats screen is visible
- Uses ExistingWorkPolicy.KEEP to avoid interrupting running syncs
- Skips sync if already syncing (via SyncManager.syncStatus check)
This ensures new drives/charges are synced while the app is running,
without requiring the user to close and reopen the app.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
* fix(sync): trigger initial sync automatically on first-time setup
On first run of 0.8.0, the initial sync was not triggered because:
1. DataSyncWorker ran immediately on app start, but server wasn't
configured yet, so getCars() returned "Server not configured"
2. This error caused Result.failure() - permanently failing the work
3. After user saved settings, no sync was triggered
Fixed by:
- DataSyncWorker now returns Result.success() when server is not
configured (nothing to do yet, not an error)
- SettingsViewModel.saveSettings() now triggers sync after saving,
ensuring sync starts as soon as server is configured
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* fix(stats): show sync progress in Stats screen during initial sync
The Stats screen was showing "No data available" without any progress
indicator during initial sync. Fixed by:
- StatsViewModel now observes SyncManager.syncStatus and reloads stats
whenever sync progress changes
- Empty state shows spinning indicator + sync phase + progress bar
even when no data is available yet (during summaries sync)
- UI updates reactively as new data is synced
This ensures users see sync progress feedback immediately when
opening Stats screen during initial sync.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
Add debug APK build to the release workflow:
- Build both release and debug APKs
- Rename debug APK with "-debug" suffix (e.g., matedroid-0.7.1-debug.apk)
- Upload both APKs to releases and as artifacts
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
Previously, the Avg/Year calculation divided total distance by the number
of distinct calendar years (e.g., 2023, 2024, 2025, 2026 = 4 years), which
gave incorrect results for users who started driving mid-year.
Now calculates: (total distance / days since first drive) × 365
Also adds an info icon (i) next to Avg/Year that shows a dialog explaining
the calculation method and the first drive date.
Fixes#10🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
* feat(charges): add tappable cost card to edit in Teslamate
- Add Teslamate Base URL setting in Settings (above Display Settings)
- Make "Connect to TeslamateApi" header smaller (titleMedium)
- Cost card in Charges list shows external link icon when cost is 0
- Tapping opens browser to Teslamate charge-cost endpoint
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* fix(charges): show edit icon on all costs, not just zero
* docs: update CHANGELOG with charge cost edit feature
---------
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
* docs: add Stats for Nerds implementation plan
Comprehensive plan for v0.8.0 feature that adds advanced statistics
computed from local SQLite database:
Architecture:
- Two-tier data strategy: Quick Stats (from list APIs) vs Deep Stats
(from detail APIs, background synced)
- Room database with 5 tables (~10MB for heavy users)
- WorkManager for background sync on app launch
- Incremental sync with schema versioning for future-proofing
Stats categories:
- 🚗 Driving Records (distance, speed, elevation, efficiency)
- ⚡ Charging Records (energy, cost, power, AC/DC ratio)
- 🌡️ Temperature Records (hot/cold extremes)
- 📅 Activity Stats (busiest day, averages)
- 🔋 Energy Stats (consumption metrics)
7 implementation phases defined with detailed tasks.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* feat(stats): add Room database foundation for Stats for Nerds
Phase 1 of Stats for Nerds feature - Database Foundation:
Dependencies:
- Add Room 2.6.1 for local SQLite database
- Add WorkManager 2.9.1 for background sync
- Add Hilt WorkManager integration
Entities:
- SyncState: Tracks sync progress per car with schema versioning
- DriveSummary: Drive list data for Quick Stats (~300 bytes/record)
- ChargeSummary: Charge list data for Quick Stats (~250 bytes/record)
- DriveDetailAggregate: Computed aggregates for Deep Stats (~150 bytes/record)
- ChargeDetailAggregate: Computed aggregates for Deep Stats (~120 bytes/record)
DAOs with stat queries:
- SyncStateDao: Sync progress tracking
- DriveSummaryDao: Quick stats (total distance, max speed, busiest day, etc.)
- ChargeSummaryDao: Quick stats (total energy, total cost, etc.)
- AggregateDao: Deep stats (elevation, temperature, AC/DC ratio, etc.)
Storage estimate: ~10 MB for heavy user (15k drives, 8k charges)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* feat(stats): add background sync infrastructure
Phase 2 of Stats for Nerds feature - Sync Infrastructure:
Domain Models:
- SyncProgress: Tracks sync phase and progress per car
- OverallSyncStatus: Aggregates status across all cars
Sync Components:
- SyncManager: Single source of truth for sync state
- Emits progress via StateFlow
- Tracks summaries vs details sync separately
- Supports schema versioning for future field additions
- SyncRepository: Orchestrates data fetching and storage
- syncSummaries(): Fast sync from list endpoints (Quick Stats)
- syncDriveDetails(): Slow sync for elevation/temp extremes
- syncChargeDetails(): Slow sync for AC/DC ratio, max power
- Computes aggregates from detail positions/points
- DataSyncWorker: WorkManager background worker
- Runs on app launch
- Syncs all cars in parallel
- Network constraint required
API Model Updates:
- DrivePosition: Added climate_info for temperature tracking
- DriveClimateInfo: inside_temp, outside_temp, is_climate_on
App Initialization:
- MateDroidApp: Custom WorkManager configuration with HiltWorkerFactory
- AndroidManifest: Disabled default WorkManager initializer
The sync now runs automatically when the app starts, populating
the local database with drives/charges summaries and computing
aggregates from detail data in the background.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* feat(stats): add stats domain models and repository
- Add CarStats domain model with QuickStats and DeepStats
- Add YearFilter for filtering stats by year
- Add record types (DriveElevationRecord, DriveTempRecord, etc.)
- Implement StatsRepository with year-filtered queries
- Support for checking sync progress and data availability
Part of Stats for Nerds feature (Phase 3)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* feat(stats): add Stats for Nerds screen and navigation
- Create StatsViewModel with year filter support
- Create StatsScreen with Quick Stats and Deep Stats cards
- Add Trophy icon to CustomIcons
- Add Screen.Stats route to NavGraph
- Add onNavigateToStats callback to DashboardScreen
Stats cards include:
- Drives Overview (total, distance, energy, efficiency)
- Charges Overview (total, energy added, cost)
- Records (longest drive, top speed, most efficient, etc.)
- Elevation stats (highest/lowest point, most climbing)
- Temperature extremes (driving and cabin)
- Charging power (max achieved)
- AC/DC charging ratio
Part of Stats for Nerds feature (Phase 4 & 5)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* feat(dashboard): add stats entry point from car image
- Make car image clickable to navigate to Stats screen
- Add Analytics icon overlay on top-right of car image
- Pass onNavigateToStats callback through Dashboard components
- Add Screen.Stats route navigation from Dashboard
Users can now tap the car image on the Dashboard to access
the Stats for Nerds screen.
Part of Stats for Nerds feature (Phase 6)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* docs: add Stats for Nerds feature documentation
- Add feature to CHANGELOG [Unreleased] section
- Add feature to README features list
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* fix(stats): resolve UI bugs in Stats for Nerds screen
- Fix pull-to-refresh indicator not disappearing after refresh
- Round all kWh totals to integers (Energy Used, Energy Added, Biggest Charge)
- Make records individual clickable cards that navigate to drive/charge details
- Add arrow indicator on navigable record cards
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* feat(stats): improve Records section layout and content
- Move Records section to the top of Stats screen
- Show dates instead of addresses in record subtexts
- Use standard KeyboardArrowRight icon for navigable cards
- Move "Most Climbing" from Elevation card to Records section
- Add "Most Expensive" charge record (by total cost)
- Add "Priciest per kWh" charge record (by cost/kWh ratio)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* fix(sync): run sync worker as foreground service
The background sync was being killed by Android when the app went to
background or screen turned off. This fix:
- Adds FOREGROUND_SERVICE and FOREGROUND_SERVICE_DATA_SYNC permissions
- Adds POST_NOTIFICATIONS permission for the sync notification
- Runs DataSyncWorker as a foreground service with a notification
- Creates a low-priority notification channel for sync status
This ensures the sync continues even when the app is not in foreground.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* fix(sync): use expedited work for Android 12+ compatibility
Android 12+ blocks starting foreground services from background with:
"startForegroundService() not allowed due to mAllowStartForeground false"
This fix:
- Uses setExpedited() on work request for priority execution
- Adds getForegroundInfo() override for older API level compatibility
- Falls back to regular work if quota is exhausted
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* feat(stats): add debug sync log viewer
In debug builds, tapping the sync progress card opens a dialog
showing sync logs in real-time (like adb logcat). Includes:
- SyncLogCollector singleton to capture log messages
- Updated SyncRepository and DataSyncWorker to use log collector
- Clickable SyncProgressCard in debug builds
- Monospace scrollable log dialog with timestamps
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* feat(stats): add per-item progress logging for sync
Logs now show each drive/charge as it's synced with remaining count:
- "Drive 123 synced (45 remaining)"
- "Charge 456 synced (12 remaining)"
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* feat(stats): improve records layout and climbing calculation
UI changes:
- Move stats icon to middle-right with > navigation arrow
- Display records in 2-column grid for better use of space
- Add temperature records (hottest/coldest drive/charge/cabin)
- Add highest point as a record
- Remove ElevationStatsCard (moved to records)
- More compact record cards for grid layout
Data changes:
- Add startElevation and endElevation to DriveDetailAggregate
- Calculate net climb as end - start altitude (not accumulated)
- Update driveWithMostClimbing query to use net elevation
- Bump SchemaVersion to 2 to trigger reprocessing
- Add database migration from v1 to v2
Note: Charges sync after all drives - this is by design.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* fix(sync): prevent aggregate deletion on summary refresh
Root cause: @Insert(onConflict = REPLACE) performs DELETE + INSERT,
which triggers CASCADE delete on aggregate tables, wiping all
processed deep stats data.
Fix: Use @Upsert instead of @Insert(REPLACE) for DriveSummaryDao
and ChargeSummaryDao. @Upsert does a proper UPDATE when record
exists, preserving foreign key relationships.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* fix(sync): add automatic retry on network errors
- Detect network errors (DNS, timeout, connection refused, etc.)
- Return Result.retry() instead of failing silently
- Add exponential backoff starting at 30 seconds
- Log attempt number for debugging
- Sync resumes from where it left off (not from zero)
The sync is now resilient to temporary network issues and will
automatically retry while preserving progress.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* fix(sync): use REPLACE policy to unstick waiting work
Changed ExistingWorkPolicy from KEEP to REPLACE so that opening
the app always starts a fresh sync worker, replacing any stuck
or long-waiting retry work.
The sync still resumes from where it left off because processed
aggregates are preserved in the database.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* fix(stats): apply year filter to all records
Records now properly filter by year when a year filter is selected:
- Added range queries for fastest drive, most/least efficient drive
- Added range queries for temperature records (hottest/coldest drive/charge)
- Added range queries for elevation records (highest point, most climbing)
- Added range query for max charging power record
- StatsRepository now uses range queries in getDeepStatsForYear()
- Made totalDrivingDays nullable in QuickStats for year view
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* fix(stats): multiple fixes for stats screen
- Fix sync progress stuck at 99%: check SyncPhase.COMPLETE to return 1.0
- Improve AC/DC detection: fallback to power-based detection (>22kW = DC)
- Group record cards by theme (drives, elevation, temps, charges)
- Each group starts on left column with proper alignment
- Add Peak Power as a tappable charge record
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* fix(sync): run as foreground service with persistent notification
Call setForeground() at start of doWork() to:
- Keep sync running when screen is off
- Show persistent notification during sync
- Update notification with sync progress
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* fix(manifest): add foregroundServiceType for WorkManager service
Declare SystemForegroundService with dataSync foregroundServiceType
in manifest to allow foreground service for long-running sync.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* fix(stats): use accumulated elevation gain for Most Climbing record
The Most Climbing record was incorrectly using net climb (endElevation - startElevation)
instead of accumulated elevation gain. This caused two problems:
1. Net climb doesn't capture drives that go up and down (e.g., +500m up, -400m down = +100m net vs +500m accumulated)
2. Many drives have null endElevation, causing them to be excluded from the query
Fixed by:
- Updated AggregateDao queries to ORDER BY elevationGain (accumulated) instead of (endElevation - startElevation)
- Updated queries to filter by elevationGain IS NOT NULL instead of requiring both start/end elevations
- Simplified StatsRepository to use elevationGain directly instead of recalculating net climb
* fix(db): add migration to fix AC/DC detection for existing data
Migration V2→V3 updates isFastCharger=1 for all charges where
maxChargerPower > 22kW, ensuring DC charges are correctly detected
even for data synced before the power-based detection was added.
* feat(settings): add Force Full Resync button
Adds a 'Force Full Resync' button in Settings under a new 'Data Management'
section. The button:
- Shows a confirmation dialog explaining what will happen
- Resets sync progress for all cars
- Triggers an immediate sync via WorkManager
- Shows a snackbar confirmation when started
This allows users to manually trigger a full re-download of all drive and
charge details if stats seem incorrect.
* fix(stats): use Teslamate's charger_phases logic for AC/DC detection
Teslamate determines AC vs DC based on charger_phases:
- DC: charger_phases is 0 or null (bypasses onboard charger)
- AC: charger_phases is 1, 2, or 3 (uses onboard charger phases)
Updated both:
- SyncRepository: compute isFastCharger from mode of non-zero phases
- Migration V2→V3: recalculate isFastCharger from stored chargerPhases
This matches the exact logic Teslamate uses in its Grafana dashboards.
* feat(charges): add AC/DC badges and improve charge detail charts
- Add AC/DC badge (green/orange) to charge list items in Charges screen
- Add AC/DC badge next to "Energy Added" in charge detail page
- Hide voltage chart for DC charges (not meaningful for DC fast charging)
- Add time labels (4 labels) to X axis of all charge detail graphs
- Use Teslamate's charger_phases logic for DC detection (phases=0/null is DC)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* fix(charges): fix AC/DC badge and preserve filter state on back navigation
Fixes two bugs:
1. AC/DC badge was showing AC for all charges because it relied on
pre-computed aggregates which may not exist yet. Now only shows
badge when we have aggregate data for that specific charge.
2. Filter selection was reset when navigating back from charge details.
Moved selectedFilter state from local remember to ViewModel so it
persists across navigation.
Changes:
- Add getAllProcessedChargeIds() query to AggregateDao
- Move DateFilter enum and selectedFilter state to ChargesViewModel
- Only show AC/DC badge for charges that have been processed
- ViewModel now initializes with default filter and preserves selection
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* fix(charges): preserve scroll position on back navigation
Save and restore the LazyColumn scroll position when navigating to and
from charge details:
- Add scrollPosition and scrollOffset to ChargesUiState
- Add saveScrollPosition() to ChargesViewModel
- Pass scroll state to ChargesContent and restore it via rememberLazyListState
- Save current scroll position before navigating to charge detail
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* fix(charges): restore AC/DC badges in charges list
Reverted to always showing badges based on dcChargeIds. The previous
approach of checking processedChargeIds caused badges to disappear
when sync hadn't processed charge details yet.
Badges will show DC if the charge is in dcChargeIds (sync has processed
it as DC), otherwise AC. Once sync completes processing all charge
details, all badges will be accurate.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* fix(sync): handle Android 14+ foreground service restrictions
On Android 14+, starting foreground services from background is restricted.
The sync worker now gracefully handles setForeground() failures by:
- Tracking if foreground service is available
- Skipping subsequent setForeground() calls if the initial one failed
- Logging the failure but continuing sync without the notification
This fixes sync interruptions caused by ForegroundServiceStartNotAllowedException.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* feat(stats): add "Most Distance Day" record
Shows the day with the most total distance driven, displayed in the
Records section of Stats for Nerds alongside the "Busiest Day" record.
Added:
- mostDistanceDay query to DriveSummaryDao (all-time and year range)
- MostDistanceDayResult data class
- mostDistanceDay field to QuickStats
- Display in StatsScreen Records section with 🛣️ emoji
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* feat(mileage): add day detail drill-down with drives list
Adds a fourth level to the Mileage screen drill-down:
- Year → Month → Day → Drive Detail
Day Detail screen shows:
- Summary card with total distance, avg distance, avg battery, avg energy
- List of all drives for that day with start/end time, distance, duration, energy
- Each drive links to the full Drive Detail screen
Also:
- Added arrow indicator (>) to day cards in month view
- Made day cards clickable to navigate to day detail
- Added selectedDay and selectedDayData to MileageUiState
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* feat(stats): improve AC/DC ratio bar visualization
- Change colors: green for AC, yellow/amber for DC
- Make bar thicker (20dp height with rounded corners)
- Calculate ratios based on charged kWh instead of charge count
- Show energy values (kWh) in the stats row
- Show charge counts in small text below each bar side
- Remove percentage numbers from display
Added new DAO queries to sum energy by AC/DC type:
- sumAcChargeEnergy / sumAcChargeEnergyInRange
- sumDcChargeEnergy / sumDcChargeEnergyInRange
Added acChargeEnergyKwh and dcChargeEnergyKwh fields to DeepStats.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* feat(stats): format energy as MWh when >= 1000 kWh
- Show MWh with one decimal (e.g., "1.2 MWh") for values >= 1000 kWh
- Show kWh without decimals (e.g., "850 kWh") for smaller values
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* refactor(stats): move AC/DC ratio near charges, remove power card
- Moved AC/DC Charging Ratio card right after Charges Overview
- Removed the Charging Power card (the "Peak Power" record is still in Records)
- Simplified the deep stats section to only show temperature stats
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* feat(stats): link day records to mileage day detail & format energy
- Add navigation from "Most Distance Day" and "Busiest Day" records
to their respective day detail views in Mileage screen
- Add targetDay parameter to Mileage route for deep linking
- Auto-navigate to specific day when targetDay is provided
- Apply MWh formatting (>=1000 kWh) to Drives and Charges overview
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
Use total_charges and total_drives fields from the teslamate_stats object
in the /api/v1/cars endpoint instead of fetching and counting all
individual drives/charges. This is more efficient and avoids potential
race conditions with large datasets.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
Add a new filter row in Drives screen to filter by drive length:
- Commute (< 10 km / 6 mi)
- Day trip (10-100 km / 6-60 mi)
- Road trip (> 100 km / 60 mi)
Filter labels automatically adapt to user's metric/imperial unit setting.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
- Add right arrow icon to year cards indicating they navigate to monthly details
- Add right arrow icon to month cards indicating they navigate to daily details
- Round mileage values in year and month cards to whole numbers
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
Remove unnecessary decimal precision from Total and Avg/Year mileage
values in the Mileage screen summary row.
Closes#4🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
The DashboardViewModel was using non-atomic state updates
(_uiState.value = _uiState.value.copy(...)) which caused a race
condition when two coroutines tried to update state concurrently.
When loading charges and drives counts in parallel:
1. Both coroutines read the state snapshot
2. Both do async work (API calls)
3. Each writes back with .copy() - second write overwrites first
With large datasets, API calls take longer, making this race window
much larger - explaining why users with many drives/charges saw
missing totals on the dashboard.
Fixed by using MutableStateFlow.update{} throughout the ViewModel,
which provides atomic state updates. Also updated tests to match
the current ViewModel API (CarStatusWithUnits, GeocodingRepository).
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The TeslaMateAPI updates endpoint supports pagination with `page` and
`show` query parameters, defaulting to show=100 results.
The app was not passing these parameters, causing users with more than
100 software updates to only see the most recent 100.
Fixed by adding pagination parameters to the API interface and passing
show=50000 in the repository (same pattern used for charges and drives).
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>