Skip to content

v1.4.0

Choose a tag to compare

@spewedprojects spewedprojects released this 08 Jul 16:14

Full Changelog: v1.3.0...v1.4.0

feat(stats): implement local database history syncing and overlay retrograde support

Optimized historical usage logging and overlay accuracy by shifting to a database-first local cache fallback and implementing retrograde sync on startup.

  • UsageDao.kt:

    • Added @Query method updateSeconds(pkg, date, seconds) to overwrite total seconds for a package on a specific day without resetting session metadata.
  • ScreenUsageHelper.kt:

    • Added syncUsageHistory(context, usageStatsManager, dao) to run in the background and sync system stats from the last 8 days into the Room DB (UsageDb -> daily_totals). This operates for all apps to establish a permanent offline copy of usage data.
  • OverlayService.kt:

    • Replaced duplicate DB query blocks and synchronous runBlocking calls with a single asynchronous coroutine on Dispatchers.IO at startup.
    • Invokes ScreenUsageHelper.syncUsageHistory(...) on startup to fetch today's accumulated usage up to the second the service starts, resolving the issue where starting the service mid-day would display 00:00:00 instead of the true ticking total.
  • AppUsageViewModel.kt:

    • Added Room DB UsageDao initialization using UsageDb.get(context).dao().
    • Added syncUsageHistory(...) call on view initialization (loadInitialData()).
    • Added getUsageForDate and getUsageForRange helper methods to query the local Room database first (priority 1), falling back to UsageStatsManager (priority 2).
    • Modified generateWeeklyData() and filterAndSortDataSync() to query the DB first via getUsageForDate and getUsageForRange.
    • Added hasUsageForOffset(offset) helper method to query the DB or system for the presence of records on preceding days/weeks.
    • Dynamically updates _canGoPrevious.value at the end of loadChartDataSync(), effectively disabling the previous page (<) button when no records are available.
  • Maintenance:

    • Change app versionName and versionCode to 1.4.0 and 4.