From 748829f7949e2e7cfc4e0a3e885b14cbc14e314d Mon Sep 17 00:00:00 2001 From: Nishant Mishra Date: Sat, 27 Sep 2025 22:30:40 +0530 Subject: [PATCH 1/3] fix: Fix a bug that caused timer settings to not save #48 --- .../viewModel/SettingsViewModel.kt | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/org/nsh07/pomodoro/ui/settingsScreen/viewModel/SettingsViewModel.kt b/app/src/main/java/org/nsh07/pomodoro/ui/settingsScreen/viewModel/SettingsViewModel.kt index fee0550..276f3de 100644 --- a/app/src/main/java/org/nsh07/pomodoro/ui/settingsScreen/viewModel/SettingsViewModel.kt +++ b/app/src/main/java/org/nsh07/pomodoro/ui/settingsScreen/viewModel/SettingsViewModel.kt @@ -22,7 +22,6 @@ import androidx.lifecycle.viewmodel.viewModelFactory import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.FlowPreview import kotlinx.coroutines.Job -import kotlinx.coroutines.SupervisorJob import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.flow.debounce @@ -60,10 +59,9 @@ class SettingsViewModel( val currentAlarmSound = timerRepository.alarmSoundUri.toString() - private val flowCollectionJob = SupervisorJob() - private val focusFlowCollectionJob = Job(flowCollectionJob) - private val shortBreakFlowCollectionJob = Job(flowCollectionJob) - private val longBreakFlowCollectionJob = Job(flowCollectionJob) + private var focusFlowCollectionJob: Job? = null + private var shortBreakFlowCollectionJob: Job? = null + private var longBreakFlowCollectionJob: Job? = null val alarmSound = preferenceRepository.getStringPreferenceFlow("alarm_sound").distinctUntilChanged() @@ -101,7 +99,7 @@ class SettingsViewModel( } fun runTextFieldFlowCollection() { - viewModelScope.launch(focusFlowCollectionJob + Dispatchers.IO) { + focusFlowCollectionJob = viewModelScope.launch(Dispatchers.IO) { snapshotFlow { focusTimeTextFieldState.text } .debounce(500) .collect { @@ -114,7 +112,7 @@ class SettingsViewModel( } } } - viewModelScope.launch(shortBreakFlowCollectionJob + Dispatchers.IO) { + shortBreakFlowCollectionJob = viewModelScope.launch(Dispatchers.IO) { snapshotFlow { shortBreakTimeTextFieldState.text } .debounce(500) .collect { @@ -127,7 +125,7 @@ class SettingsViewModel( } } } - viewModelScope.launch(longBreakFlowCollectionJob + Dispatchers.IO) { + longBreakFlowCollectionJob = viewModelScope.launch(Dispatchers.IO) { snapshotFlow { longBreakTimeTextFieldState.text } .debounce(500) .collect { @@ -142,7 +140,11 @@ class SettingsViewModel( } } - fun cancelTextFieldFlowCollection() = flowCollectionJob.cancel() + fun cancelTextFieldFlowCollection() { + focusFlowCollectionJob?.cancel() + shortBreakFlowCollectionJob?.cancel() + longBreakFlowCollectionJob?.cancel() + } fun saveAlarmEnabled(enabled: Boolean) { viewModelScope.launch { From 816b4f36a971f324b3185cf16031940806129bb9 Mon Sep 17 00:00:00 2001 From: Nishant Mishra Date: Sat, 27 Sep 2025 22:48:27 +0530 Subject: [PATCH 2/3] fix: Fix a bug that caused alarm name to not update #48 --- .../ui/settingsScreen/SettingsScreen.kt | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/org/nsh07/pomodoro/ui/settingsScreen/SettingsScreen.kt b/app/src/main/java/org/nsh07/pomodoro/ui/settingsScreen/SettingsScreen.kt index b558816..3e9b0cc 100644 --- a/app/src/main/java/org/nsh07/pomodoro/ui/settingsScreen/SettingsScreen.kt +++ b/app/src/main/java/org/nsh07/pomodoro/ui/settingsScreen/SettingsScreen.kt @@ -12,6 +12,7 @@ import android.content.Intent import android.media.RingtoneManager import android.net.Uri import android.os.Build +import android.provider.MediaStore import androidx.activity.compose.rememberLauncherForActivityResult import androidx.activity.result.contract.ActivityResultContracts import androidx.annotation.DrawableRes @@ -72,6 +73,7 @@ import androidx.compose.ui.tooling.preview.Devices import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp +import androidx.compose.ui.util.fastCoerceAtLeast import androidx.core.net.toUri import androidx.lifecycle.compose.collectAsStateWithLifecycle import androidx.lifecycle.viewmodel.compose.viewModel @@ -89,6 +91,7 @@ import org.nsh07.pomodoro.ui.theme.TomatoShapeDefaults.topListItemShape import org.nsh07.pomodoro.ui.theme.TomatoTheme import org.nsh07.pomodoro.utils.toColor + @OptIn(ExperimentalMaterial3Api::class) @Composable fun SettingsScreenRoot( @@ -197,9 +200,17 @@ private fun SettingsScreen( val context = LocalContext.current var alarmName by remember { mutableStateOf("") } - LaunchedEffect(Unit) { - alarmName = RingtoneManager.getRingtone(context, alarmSound.toUri()) - ?.getTitle(context) ?: "" + LaunchedEffect(alarmSound) { + val returnCursor = context.contentResolver.query(alarmSound.toUri(), null, null, null, null) + returnCursor?.moveToFirst() + alarmName = + returnCursor + ?.getString( + returnCursor + .getColumnIndex(MediaStore.MediaColumns.TITLE) + .fastCoerceAtLeast(0) + ) ?: "" + returnCursor?.close() } val ringtonePickerLauncher = rememberLauncherForActivityResult( From dbae3a4ae85c9475e3a89f6a25d5c997e2740935 Mon Sep 17 00:00:00 2001 From: Nishant Mishra Date: Sat, 27 Sep 2025 22:56:35 +0530 Subject: [PATCH 3/3] chore: Bump version string, update changelog --- app/build.gradle.kts | 4 ++-- fastlane/metadata/android/en-US/changelogs/9.txt | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 fastlane/metadata/android/en-US/changelogs/9.txt diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 1b4f644..06934fb 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -33,8 +33,8 @@ android { applicationId = "org.nsh07.pomodoro" minSdk = 26 targetSdk = 36 - versionCode = 8 - versionName = "1.4.0" + versionCode = 9 + versionName = "1.4.1" testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" } diff --git a/fastlane/metadata/android/en-US/changelogs/9.txt b/fastlane/metadata/android/en-US/changelogs/9.txt new file mode 100644 index 0000000..850bf66 --- /dev/null +++ b/fastlane/metadata/android/en-US/changelogs/9.txt @@ -0,0 +1,10 @@ +This release contains bug fixes on top of the existing new features of 1.4.0: + +New features: +- You can now choose a custom theme and color scheme for the app's UI +- New pure black dark theme mode + +Fixes: +- Average focus durations now do not include days with no activity +- Fix a critical bug that caused the app's timer state to reset to Focus whenever the app was closed from recents and then opened +- Replace the word "Reset" with "Exit" in the notification to make its purpose less ambiguous \ No newline at end of file