From 01e7ab090f074bfcccbd99d5a214ea9a66dc5143 Mon Sep 17 00:00:00 2001
From: Shreyash Pattewar <34227385+shreyashp47@users.noreply.github.com>
Date: Sun, 13 Sep 2026 14:05:22 +0530
Subject: [PATCH 1/4] perf: optimize startup without functional change (#99
#100 #101 #102)
- #99: eliminate runBlocking DataStore in attachBaseContext
DoTrackApplication.getLanguageCodeSync now reads SharedPreferences
sync cache (dotrack_sync_prefs) instead of runBlocking dataStore.first();
UserPreferencesRepositoryImpl dual-writes language to sync prefs;
Application.onCreate migrates existing DataStore value async
- #100: fix StartupProvider removal - WorkManagerInitializer and
EmojiCompatInitializer now correctly removed via provider merge;
verified merged manifest only keeps ProcessLifecycle + ProfileInstaller
- #101: add SplashScreen API (androidx.core:core-splashscreen 1.0.1)
Theme.DoTrack.Splash + installSplashScreen() in MainActivity for
perceived startup 200-400ms, postSplashScreenTheme -> Theme.DoTrack
- #102: startup cleanup
* WallpaperGenerator wallpaperManager by lazy, dateFormatter companion,
7 prefs reads now concurrent via async/coroutineScope
* DatabaseModule uses addMigrations(MIGRATION_1_2,2_3,3_4) instead of
fallbackToDestructiveMigration()
* Theme: cache dynamic colorScheme + priorityCardColors with remember,
remove SideEffect global mutation; TaskComponents now uses
LocalPriorityCardColors
* DateTimeConverters formatter to companion object
* TasksViewModel single tasksResultFlow shared upstream, taskCounts
derived from same flow (single Room observer)
* Widget updatePeriodMillis 300000 -> 0 (rely on TaskWidgetUpdater)
No user-visible behavior change, assembleDebug + testDebugUnitTest green
Experimental branch for startup work
---
app/build.gradle.kts | 1 +
app/src/main/AndroidManifest.xml | 20 +++++++---
.../shreyash/dotrack/DoTrackApplication.kt | 38 ++++++++++++++++--
.../java/com/shreyash/dotrack/MainActivity.kt | 2 +
.../dotrack/core/util/WallpaperGenerator.kt | 38 +++++++++++++-----
.../dotrack/ui/tasks/TaskComponents.kt | 11 +++--
.../dotrack/ui/tasks/TasksViewModel.kt | 12 +++++-
app/src/main/res/values/colors.xml | 1 +
app/src/main/res/values/themes.xml | 7 ++++
app/src/main/res/xml/task_widget_info.xml | 2 +-
.../shreyash/dotrack/core/ui/theme/Theme.kt | 40 +++++++++----------
.../dotrack/data/di/DatabaseModule.kt | 8 +++-
.../UserPreferencesRepositoryImpl.kt | 12 +++++-
.../dotrack/data/util/DateTimeConverters.kt | 4 +-
gradle/libs.versions.toml | 2 +
15 files changed, 144 insertions(+), 54 deletions(-)
diff --git a/app/build.gradle.kts b/app/build.gradle.kts
index 7050f5d..aa1956c 100644
--- a/app/build.gradle.kts
+++ b/app/build.gradle.kts
@@ -87,6 +87,7 @@ dependencies {
// AndroidX Core
implementation(libs.androidx.core.ktx)
+ implementation(libs.androidx.core.splashscreen)
// Compose
implementation(platform(libs.compose.bom))
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 1207739..bb521a7 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -17,13 +17,21 @@
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_app_icon"
android:supportsRtl="true"
- android:theme="@style/Theme.DoTrack"
+ android:theme="@style/Theme.DoTrack.Splash"
tools:targetApi="31">
-
-
+
+
+
+
+
): Result {
return withContext(Dispatchers.IO) {
try {
- // Get the user's preferred colors
- val startColorHex = getWallpaperColorUseCase().first()
- val secondaryStartColorHex = getSecondaryWallpaperColorUseCase().first()
- val highPriorityColorHex = getHighPriorityColorUseCase().first()
- val mediumPriorityColorHex = getMediumPriorityColorUseCase().first()
- val lowPriorityColorHex = getLowPriorityColorUseCase().first()
- val sortOption = getSortOptionUseCase().first()
- val sortDirection = getSortDirectionUseCase().first()
+ // Get the user's preferred colors & sort prefs concurrently (#102)
+ val startColorHex: String
+ val secondaryStartColorHex: String
+ val highPriorityColorHex: String
+ val mediumPriorityColorHex: String
+ val lowPriorityColorHex: String
+ val sortOption: SortOption
+ val sortDirection: SortDirection
+ coroutineScope {
+ val deferredStart = async { getWallpaperColorUseCase().first() }
+ val deferredSecondary = async { getSecondaryWallpaperColorUseCase().first() }
+ val deferredHigh = async { getHighPriorityColorUseCase().first() }
+ val deferredMedium = async { getMediumPriorityColorUseCase().first() }
+ val deferredLow = async { getLowPriorityColorUseCase().first() }
+ val deferredSortOption = async { getSortOptionUseCase().first() }
+ val deferredSortDirection = async { getSortDirectionUseCase().first() }
+ startColorHex = deferredStart.await()
+ secondaryStartColorHex = deferredSecondary.await()
+ highPriorityColorHex = deferredHigh.await()
+ mediumPriorityColorHex = deferredMedium.await()
+ lowPriorityColorHex = deferredLow.await()
+ sortOption = deferredSortOption.await()
+ sortDirection = deferredSortDirection.await()
+ }
val bitmap = generateTaskListBitmap(
tasks,
diff --git a/app/src/main/java/com/shreyash/dotrack/ui/tasks/TaskComponents.kt b/app/src/main/java/com/shreyash/dotrack/ui/tasks/TaskComponents.kt
index 5f236f4..bc97276 100644
--- a/app/src/main/java/com/shreyash/dotrack/ui/tasks/TaskComponents.kt
+++ b/app/src/main/java/com/shreyash/dotrack/ui/tasks/TaskComponents.kt
@@ -38,10 +38,8 @@ import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.shreyash.dotrack.R
-import com.shreyash.dotrack.core.ui.theme.CardColorHighPriority
-import com.shreyash.dotrack.core.ui.theme.CardColorLowPriority
-import com.shreyash.dotrack.core.ui.theme.CardColorMediumPriority
import com.shreyash.dotrack.core.ui.theme.DoTrackTheme
+import com.shreyash.dotrack.core.ui.theme.LocalPriorityCardColors
import com.shreyash.dotrack.domain.model.Priority
import com.shreyash.dotrack.domain.model.Task
import java.time.LocalDateTime
@@ -77,10 +75,11 @@ fun TaskItem(
onDeleteTask: (String) -> Unit = {},
modifier: Modifier = Modifier
) {
+ val priorityCardColors = LocalPriorityCardColors.current
val color = when (task.priority) {
- Priority.HIGH -> CardColorHighPriority
- Priority.MEDIUM -> CardColorMediumPriority
- Priority.LOW -> CardColorLowPriority
+ Priority.HIGH -> priorityCardColors.high
+ Priority.MEDIUM -> priorityCardColors.medium
+ Priority.LOW -> priorityCardColors.low
}
Card(
modifier = modifier
diff --git a/app/src/main/java/com/shreyash/dotrack/ui/tasks/TasksViewModel.kt b/app/src/main/java/com/shreyash/dotrack/ui/tasks/TasksViewModel.kt
index ec825a6..351f344 100644
--- a/app/src/main/java/com/shreyash/dotrack/ui/tasks/TasksViewModel.kt
+++ b/app/src/main/java/com/shreyash/dotrack/ui/tasks/TasksViewModel.kt
@@ -95,8 +95,16 @@ class TasksViewModel @Inject constructor(
val filterPriority: Priority? get() = _filterPriority.value
val filterCompleted: Boolean? get() = _filterCompleted.value
+ // Shared upstream to avoid duplicate Room observers (#102)
+ private val tasksResultFlow: StateFlow>> = getTasksUseCase()
+ .stateIn(
+ scope = viewModelScope,
+ started = SharingStarted.WhileSubscribed(5000),
+ initialValue = Result.Loading
+ )
+
val sortedTasks: StateFlow>> = combine(
- getTasksUseCase(),
+ tasksResultFlow,
_sortOption,
_sortDirection,
_filterPriority,
@@ -122,7 +130,7 @@ class TasksViewModel @Inject constructor(
initialValue = Result.Loading
)
- val taskCounts: StateFlow = getTasksUseCase()
+ val taskCounts: StateFlow = tasksResultFlow
.map { result ->
val tasks = result.getOrNull().orEmpty()
TaskCounts(
diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml
index c8524cd..deefa9b 100644
--- a/app/src/main/res/values/colors.xml
+++ b/app/src/main/res/values/colors.xml
@@ -2,4 +2,5 @@
#FF000000
#FFFFFFFF
+ #7C3AED
\ No newline at end of file
diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml
index 69156c7..ad8996c 100644
--- a/app/src/main/res/values/themes.xml
+++ b/app/src/main/res/values/themes.xml
@@ -6,4 +6,11 @@
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/xml/task_widget_info.xml b/app/src/main/res/xml/task_widget_info.xml
index ca91918..204b3b8 100644
--- a/app/src/main/res/xml/task_widget_info.xml
+++ b/app/src/main/res/xml/task_widget_info.xml
@@ -5,5 +5,5 @@
android:minHeight="110dp"
android:previewImage="@drawable/widget_preview"
android:resizeMode="horizontal|vertical"
- android:updatePeriodMillis="300000"
+ android:updatePeriodMillis="0"
android:widgetCategory="home_screen" />
\ No newline at end of file
diff --git a/core/src/main/java/com/shreyash/dotrack/core/ui/theme/Theme.kt b/core/src/main/java/com/shreyash/dotrack/core/ui/theme/Theme.kt
index 53d56a4..0a6a579 100644
--- a/core/src/main/java/com/shreyash/dotrack/core/ui/theme/Theme.kt
+++ b/core/src/main/java/com/shreyash/dotrack/core/ui/theme/Theme.kt
@@ -13,8 +13,8 @@ import androidx.compose.material3.dynamicLightColorScheme
import androidx.compose.material3.lightColorScheme
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
-import androidx.compose.runtime.SideEffect
import androidx.compose.runtime.compositionLocalOf
+import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
@@ -76,30 +76,26 @@ fun DoTrackTheme(
dynamicColor: Boolean = true,
content: @Composable () -> Unit
) {
- val colorScheme = when {
- dynamicColor && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> {
- val context = LocalContext.current
- if (darkTheme) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context)
+ val context = LocalContext.current
+ val colorScheme = remember(context, darkTheme, dynamicColor) {
+ when {
+ dynamicColor && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> {
+ if (darkTheme) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context)
+ }
+ darkTheme -> DarkColorScheme
+ else -> LightColorScheme
}
-
- darkTheme -> DarkColorScheme
- else -> LightColorScheme
}
-
- // Set the priority card colors based on the current theme
- val priorityCardColors = PriorityCardColors(
- high = if (darkTheme) CardColorHighPriorityDark else CardColorHighPriorityLight,
- medium = if (darkTheme) CardColorMediumPriorityDark else CardColorMediumPriorityLight,
- low = if (darkTheme) CardColorLowPriorityDark else CardColorLowPriorityLight
- )
-
- // Update the global color variables for backward compatibility
- SideEffect {
- CardColorHighPriority = priorityCardColors.high
- CardColorMediumPriority = priorityCardColors.medium
- CardColorLowPriority = priorityCardColors.low
+
+ // Set the priority card colors based on the current theme - cached per theme
+ val priorityCardColors = remember(darkTheme) {
+ PriorityCardColors(
+ high = if (darkTheme) CardColorHighPriorityDark else CardColorHighPriorityLight,
+ medium = if (darkTheme) CardColorMediumPriorityDark else CardColorMediumPriorityLight,
+ low = if (darkTheme) CardColorLowPriorityDark else CardColorLowPriorityLight
+ )
}
-
+
CompositionLocalProvider(LocalPriorityCardColors provides priorityCardColors) {
MaterialTheme(
colorScheme = colorScheme,
diff --git a/data/src/main/java/com/shreyash/dotrack/data/di/DatabaseModule.kt b/data/src/main/java/com/shreyash/dotrack/data/di/DatabaseModule.kt
index 6f53f25..e7adf06 100644
--- a/data/src/main/java/com/shreyash/dotrack/data/di/DatabaseModule.kt
+++ b/data/src/main/java/com/shreyash/dotrack/data/di/DatabaseModule.kt
@@ -24,8 +24,12 @@ object DatabaseModule {
TaskDatabase::class.java,
"dotrack_database"
)
- .fallbackToDestructiveMigration() // This will recreate the database if a migration isn't found
- .build()
+ .addMigrations(
+ TaskDatabase.MIGRATION_1_2,
+ TaskDatabase.MIGRATION_2_3,
+ TaskDatabase.MIGRATION_3_4
+ )
+ .build()
}
@Provides
diff --git a/data/src/main/java/com/shreyash/dotrack/data/repository/UserPreferencesRepositoryImpl.kt b/data/src/main/java/com/shreyash/dotrack/data/repository/UserPreferencesRepositoryImpl.kt
index 8489be8..24ad3f5 100644
--- a/data/src/main/java/com/shreyash/dotrack/data/repository/UserPreferencesRepositoryImpl.kt
+++ b/data/src/main/java/com/shreyash/dotrack/data/repository/UserPreferencesRepositoryImpl.kt
@@ -1,5 +1,6 @@
package com.shreyash.dotrack.data.repository
+import android.content.Context
import android.util.Log
import androidx.datastore.core.DataStore
import androidx.datastore.preferences.core.Preferences
@@ -16,6 +17,7 @@ import com.shreyash.dotrack.core.util.Result
import com.shreyash.dotrack.domain.model.SortDirection
import com.shreyash.dotrack.domain.model.SortOption
import com.shreyash.dotrack.domain.repository.UserPreferencesRepository
+import dagger.hilt.android.qualifiers.ApplicationContext
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.catch
import kotlinx.coroutines.flow.map
@@ -26,7 +28,8 @@ import javax.inject.Singleton
// data/repository/UserPreferencesRepositoryImpl.kt
@Singleton
class UserPreferencesRepositoryImpl @Inject constructor(
- private val dataStore: DataStore
+ private val dataStore: DataStore,
+ @ApplicationContext private val context: Context
) : UserPreferencesRepository {
private object PreferencesKeys {
@@ -238,6 +241,13 @@ class UserPreferencesRepositoryImpl @Inject constructor(
dataStore.edit { preferences ->
preferences[PreferencesKeys.LANGUAGE] = language
}
+ // Keep sync SharedPreferences cache in sync for fast attachBaseContext read (#99)
+ try {
+ context.getSharedPreferences("dotrack_sync_prefs", Context.MODE_PRIVATE)
+ .edit().putString("language_sync", language).apply()
+ } catch (_: Exception) {
+ // non-critical
+ }
Result.Success(Unit)
} catch (e: Exception) {
Result.Error(e)
diff --git a/data/src/main/java/com/shreyash/dotrack/data/util/DateTimeConverters.kt b/data/src/main/java/com/shreyash/dotrack/data/util/DateTimeConverters.kt
index 738a753..0c53bd0 100644
--- a/data/src/main/java/com/shreyash/dotrack/data/util/DateTimeConverters.kt
+++ b/data/src/main/java/com/shreyash/dotrack/data/util/DateTimeConverters.kt
@@ -5,7 +5,9 @@ import java.time.LocalDateTime
import java.time.format.DateTimeFormatter
class DateTimeConverters {
- private val formatter = DateTimeFormatter.ISO_LOCAL_DATE_TIME
+ companion object {
+ private val formatter = DateTimeFormatter.ISO_LOCAL_DATE_TIME
+ }
@TypeConverter
fun fromLocalDateTime(value: LocalDateTime?): String? {
diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml
index b874182..16f7266 100644
--- a/gradle/libs.versions.toml
+++ b/gradle/libs.versions.toml
@@ -11,6 +11,7 @@ junitVersion = "1.3.0"
espressoCore = "3.7.0"
testRunner = "1.7.0"
leakcanaryAndroid = "2.14"
+splashscreen = "1.0.1"
# Compose
compose-bom = "2025.06.01"
@@ -41,6 +42,7 @@ turbine = "1.0.0"
[libraries]
# AndroidX Core
androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" }
+androidx-core-splashscreen = { group = "androidx.core", name = "core-splashscreen", version.ref = "splashscreen" }
androidx-datastore-preferences = { module = "androidx.datastore:datastore-preferences", version.ref = "datastorePreferences" }
colorpicker-compose = { module = "com.github.skydoves:colorpicker-compose", version.ref = "colorpickerCompose" }
leakcanary-android = { module = "com.squareup.leakcanary:leakcanary-android", version.ref = "leakcanaryAndroid" }
From 225c2d48a226a35d676c85c5f8e322a50b93dcde Mon Sep 17 00:00:00 2001
From: Shreyash Pattewar <34227385+shreyashp47@users.noreply.github.com>
Date: Sun, 13 Sep 2026 14:20:45 +0530
Subject: [PATCH 2/4] =?UTF-8?q?fix:=20lint=20ContextCastToActivity=20?=
=?UTF-8?q?=E2=80=94=20use=20LocalActivity=20instead=20of=20LocalContext?=
=?UTF-8?q?=20cast?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Fixes Build and Deploy failure on experimental@01e7ab0
/app/src/main/java/com/shreyash/dotrack/MainActivity.kt:117 lint error
Use androidx.activity.compose.LocalActivity.current
Verified locally, no functional change
---
app/src/main/java/com/shreyash/dotrack/MainActivity.kt | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/app/src/main/java/com/shreyash/dotrack/MainActivity.kt b/app/src/main/java/com/shreyash/dotrack/MainActivity.kt
index 2345465..15c2428 100644
--- a/app/src/main/java/com/shreyash/dotrack/MainActivity.kt
+++ b/app/src/main/java/com/shreyash/dotrack/MainActivity.kt
@@ -1,12 +1,12 @@
package com.shreyash.dotrack
-import android.app.Activity
import android.content.Context
import android.content.Intent
import android.content.res.Configuration
import android.os.Build
import android.os.Bundle
import androidx.activity.ComponentActivity
+import androidx.activity.compose.LocalActivity
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
@@ -30,7 +30,6 @@ import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
-import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalInspectionMode
import androidx.compose.ui.tooling.preview.Preview
import androidx.hilt.navigation.compose.hiltViewModel
@@ -114,7 +113,7 @@ fun DoTrackApp(
val languagePref by themeViewModel.language.collectAsState()
var isInitialLanguage by remember { mutableStateOf(true) }
- val activity = LocalContext.current as? Activity
+ val activity = LocalActivity.current
LaunchedEffect(languagePref) {
if (isInitialLanguage) {
isInitialLanguage = false
From 652a82d8cfd20bb724349f10d3eb1c70ad8ad237 Mon Sep 17 00:00:00 2001
From: Shreyash Pattewar <34227385+shreyashp47@users.noreply.github.com>
Date: Sun, 13 Sep 2026 15:37:07 +0530
Subject: [PATCH 3/4] chore: bump version to 1.53 (53) to resolve Play Store
conflict
Previous beta track already has 53 (run 30335669059), so increment to unblock experimental beta deploy
---
app/build.gradle.kts | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/app/build.gradle.kts b/app/build.gradle.kts
index aa1956c..5bf30b8 100644
--- a/app/build.gradle.kts
+++ b/app/build.gradle.kts
@@ -29,8 +29,8 @@ android {
applicationId = "com.shreyash.dotrack"
minSdk = 26
targetSdk = 36
- versionCode = 52
- versionName = "1.52"
+ versionCode = 53
+ versionName = "1.53"
testInstrumentationRunner = "com.shreyash.dotrack.HiltTestRunner"
}
From 1c59b57c02c43f73c9fd81519f7e688bc6ca5ee1 Mon Sep 17 00:00:00 2001
From: GitHub Action
Date: Sun, 13 Sep 2026 10:23:41 +0000
Subject: [PATCH 4/4] Bump version to 1.56 (56)
---
app/build.gradle.kts | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/app/build.gradle.kts b/app/build.gradle.kts
index aa4e7cf..50a148c 100644
--- a/app/build.gradle.kts
+++ b/app/build.gradle.kts
@@ -29,8 +29,8 @@ android {
applicationId = "com.shreyash.dotrack"
minSdk = 26
targetSdk = 36
- versionCode = 55
- versionName = "1.55"
+ versionCode = 56
+ versionName = "1.56"
testInstrumentationRunner = "com.shreyash.dotrack.HiltTestRunner"
}