diff --git a/app/build.gradle.kts b/app/build.gradle.kts
index a356204..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"
}
@@ -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" }