diff --git a/README.md b/README.md index 8bce614..aabc7e1 100644 --- a/README.md +++ b/README.md @@ -131,6 +131,7 @@ or [my BuyMeACoffee page](https://coff.ee/nsh07): - Shun Min Chang ([@jack24254029](https://github.com/jack24254029) on GitHub) - Chinedu Oji (on BuyMeACoffee) +- Zach Alden (on BuyMeACoffee) ## Special Thanks diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 2199875..f6a654f 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -43,8 +43,8 @@ android { applicationId = "org.nsh07.pomodoro" minSdk = 27 targetSdk = 36 - versionCode = 21 - versionName = "1.6.6" + versionCode = 22 + versionName = "1.7.0" testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" diff --git a/app/src/foss/java/org/nsh07/pomodoro/ui/settingsScreen/components/AboutButtons.kt b/app/src/foss/java/org/nsh07/pomodoro/ui/settingsScreen/components/AboutButtons.kt index 60f4dc2..e36d110 100644 --- a/app/src/foss/java/org/nsh07/pomodoro/ui/settingsScreen/components/AboutButtons.kt +++ b/app/src/foss/java/org/nsh07/pomodoro/ui/settingsScreen/components/AboutButtons.kt @@ -17,18 +17,12 @@ package org.nsh07.pomodoro.ui.settingsScreen.components -import androidx.compose.foundation.layout.Arrangement -import androidx.compose.foundation.layout.Row -import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.size -import androidx.compose.material3.Button -import androidx.compose.material3.ButtonColors -import androidx.compose.material3.ButtonDefaults import androidx.compose.material3.ExperimentalMaterial3ExpressiveApi import androidx.compose.material3.Icon +import androidx.compose.material3.MaterialTheme.colorScheme import androidx.compose.material3.Text import androidx.compose.runtime.Composable -import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.platform.LocalUriHandler import androidx.compose.ui.res.painterResource @@ -38,56 +32,44 @@ import org.nsh07.pomodoro.R @OptIn(ExperimentalMaterial3ExpressiveApi::class) @Composable -fun TopButton( - buttonColors: ButtonColors, - modifier: Modifier = Modifier -) { +fun TopButton(modifier: Modifier = Modifier) { val uriHandler = LocalUriHandler.current - Button( - colors = buttonColors, - onClick = { uriHandler.openUri("https://coff.ee/nsh07") }, - shapes = ButtonDefaults.shapes(), - modifier = modifier - ) { - Row( - horizontalArrangement = Arrangement.spacedBy(8.dp), - verticalAlignment = Alignment.CenterVertically - ) { + ClickableListItem( + leadingContent = { Icon( painterResource(R.drawable.bmc), + tint = colorScheme.primary, contentDescription = null, - modifier = Modifier.height(24.dp) + modifier = Modifier.size(24.dp) ) - - Text(text = stringResource(R.string.bmc)) - } - } + }, + headlineContent = { Text(stringResource(R.string.bmc)) }, + supportingContent = { Text(stringResource(R.string.bmc_desc)) }, + trailingContent = { Icon(painterResource(R.drawable.open_in_browser), null) }, + items = 2, + index = 0, + modifier = modifier + ) { uriHandler.openUri("https://coff.ee/nsh07") } } @OptIn(ExperimentalMaterial3ExpressiveApi::class) @Composable -fun BottomButton( - buttonColors: ButtonColors, - modifier: Modifier = Modifier -) { +fun BottomButton(modifier: Modifier = Modifier) { val uriHandler = LocalUriHandler.current - Button( - colors = buttonColors, - onClick = { uriHandler.openUri("https://hosted.weblate.org/engage/tomato/") }, - shapes = ButtonDefaults.shapes(), - modifier = modifier - ) { - Row( - horizontalArrangement = Arrangement.spacedBy(8.dp), - verticalAlignment = Alignment.CenterVertically - ) { + ClickableListItem( + leadingContent = { Icon( painterResource(R.drawable.weblate), + tint = colorScheme.secondary, contentDescription = null, - modifier = Modifier.size(20.dp) + modifier = Modifier.size(24.dp) ) - - Text(text = stringResource(R.string.help_with_translation)) - } - } + }, + headlineContent = { Text(stringResource(R.string.help_with_translation)) }, + supportingContent = { Text(stringResource(R.string.help_with_translation_desc)) }, + trailingContent = { Icon(painterResource(R.drawable.open_in_browser), null) }, + items = 2, + index = 1, + modifier = modifier + ) { uriHandler.openUri("https://hosted.weblate.org/engage/tomato/") } } \ No newline at end of file diff --git a/app/src/main/ic_launcher-playstore.png b/app/src/main/ic_launcher-playstore.png index 9d77681..ea0c79a 100644 Binary files a/app/src/main/ic_launcher-playstore.png and b/app/src/main/ic_launcher-playstore.png differ diff --git a/app/src/main/java/org/nsh07/pomodoro/MainActivity.kt b/app/src/main/java/org/nsh07/pomodoro/MainActivity.kt index 1b28db4..215fdc9 100644 --- a/app/src/main/java/org/nsh07/pomodoro/MainActivity.kt +++ b/app/src/main/java/org/nsh07/pomodoro/MainActivity.kt @@ -69,14 +69,14 @@ class MainActivity : ComponentActivity() { ) { val colorScheme = colorScheme LaunchedEffect(colorScheme) { - appContainer.appTimerRepository.colorScheme = colorScheme + appContainer.stateRepository.colorScheme = colorScheme } AppScreen( isPlus = isPlus, isAODEnabled = settingsState.aodEnabled, setTimerFrequency = { - appContainer.appTimerRepository.timerFrequency = it + appContainer.stateRepository.timerFrequency = it } ) } @@ -86,13 +86,13 @@ class MainActivity : ComponentActivity() { override fun onStop() { super.onStop() - // Reduce the timer loop frequency when not visible to save battery power - appContainer.appTimerRepository.timerFrequency = 1f + // Reduce the timer loop frequency when not visible to save battery + appContainer.stateRepository.timerFrequency = 1f } override fun onStart() { super.onStart() // Increase the timer loop frequency again when visible to make the progress smoother - appContainer.appTimerRepository.timerFrequency = 60f + appContainer.stateRepository.timerFrequency = 60f } } \ No newline at end of file diff --git a/app/src/main/java/org/nsh07/pomodoro/data/AppContainer.kt b/app/src/main/java/org/nsh07/pomodoro/data/AppContainer.kt index 12186a6..37c9f8a 100644 --- a/app/src/main/java/org/nsh07/pomodoro/data/AppContainer.kt +++ b/app/src/main/java/org/nsh07/pomodoro/data/AppContainer.kt @@ -31,19 +31,16 @@ import org.nsh07.pomodoro.billing.BillingManager import org.nsh07.pomodoro.billing.BillingManagerProvider import org.nsh07.pomodoro.service.ServiceHelper import org.nsh07.pomodoro.service.addTimerActions -import org.nsh07.pomodoro.ui.timerScreen.viewModel.TimerState -import org.nsh07.pomodoro.utils.millisecondsToStr interface AppContainer { val appPreferenceRepository: AppPreferenceRepository val appStatRepository: AppStatRepository - val appTimerRepository: AppTimerRepository + val stateRepository: StateRepository val billingManager: BillingManager val notificationManager: NotificationManagerCompat val notificationManagerService: NotificationManager val notificationBuilder: NotificationCompat.Builder val serviceHelper: ServiceHelper - val timerState: MutableStateFlow val time: MutableStateFlow var activityTurnScreenOn: (Boolean) -> Unit } @@ -58,7 +55,9 @@ class DefaultAppContainer(context: Context) : AppContainer { AppStatRepository(AppDatabase.getDatabase(context).statDao()) } - override val appTimerRepository: AppTimerRepository by lazy { AppTimerRepository() } + override val stateRepository: StateRepository by lazy { + StateRepository() + } override val billingManager: BillingManager by lazy { BillingManagerProvider.manager } @@ -93,20 +92,9 @@ class DefaultAppContainer(context: Context) : AppContainer { ServiceHelper(context) } - override val timerState: MutableStateFlow by lazy { - MutableStateFlow( - TimerState( - totalTime = appTimerRepository.focusTime, - timeStr = millisecondsToStr(appTimerRepository.focusTime), - nextTimeStr = millisecondsToStr(appTimerRepository.shortBreakTime) - ) - ) - } - override val time: MutableStateFlow by lazy { - MutableStateFlow(appTimerRepository.focusTime) + MutableStateFlow(stateRepository.settingsState.value.focusTime) } override var activityTurnScreenOn: (Boolean) -> Unit = {} - } \ No newline at end of file diff --git a/app/src/main/java/org/nsh07/pomodoro/data/StateRepository.kt b/app/src/main/java/org/nsh07/pomodoro/data/StateRepository.kt new file mode 100644 index 0000000..410e711 --- /dev/null +++ b/app/src/main/java/org/nsh07/pomodoro/data/StateRepository.kt @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Nishant Mishra + * + * This file is part of Tomato - a minimalist pomodoro timer for Android. + * + * Tomato is free software: you can redistribute it and/or modify it under the terms of the GNU + * General Public License as published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * Tomato is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even + * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General + * Public License for more details. + * + * You should have received a copy of the GNU General Public License along with Tomato. + * If not, see . + */ + +package org.nsh07.pomodoro.data + +import androidx.compose.material3.ColorScheme +import androidx.compose.material3.lightColorScheme +import kotlinx.coroutines.flow.MutableStateFlow +import org.nsh07.pomodoro.ui.settingsScreen.viewModel.SettingsState +import org.nsh07.pomodoro.ui.timerScreen.viewModel.TimerState + +class StateRepository { + val timerState = MutableStateFlow(TimerState()) + val settingsState = MutableStateFlow(SettingsState()) + var timerFrequency: Float = 60f + var colorScheme: ColorScheme = lightColorScheme() +} diff --git a/app/src/main/java/org/nsh07/pomodoro/data/TimerRepository.kt b/app/src/main/java/org/nsh07/pomodoro/data/TimerRepository.kt deleted file mode 100644 index 89f27af..0000000 --- a/app/src/main/java/org/nsh07/pomodoro/data/TimerRepository.kt +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (c) 2025 Nishant Mishra - * - * This file is part of Tomato - a minimalist pomodoro timer for Android. - * - * Tomato is free software: you can redistribute it and/or modify it under the terms of the GNU - * General Public License as published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * Tomato is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even - * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General - * Public License for more details. - * - * You should have received a copy of the GNU General Public License along with Tomato. - * If not, see . - */ - -package org.nsh07.pomodoro.data - -import android.net.Uri -import android.provider.Settings -import androidx.compose.material3.ColorScheme -import androidx.compose.material3.lightColorScheme -import kotlinx.coroutines.flow.MutableStateFlow - -/** - * Interface that holds the timer durations for each timer type. This repository maintains a single - * source of truth for the timer durations for the various ViewModels in the app. - */ -interface TimerRepository { - var focusTime: Long - var shortBreakTime: Long - var longBreakTime: Long - - var sessionLength: Int - - var timerFrequency: Float - - var alarmEnabled: Boolean - var vibrateEnabled: Boolean - var dndEnabled: Boolean - - var colorScheme: ColorScheme - - var alarmSoundUri: Uri? - - var serviceRunning: MutableStateFlow -} - -/** - * See [TimerRepository] for more details - */ -class AppTimerRepository : TimerRepository { - override var focusTime = 25 * 60 * 1000L - override var shortBreakTime = 5 * 60 * 1000L - override var longBreakTime = 15 * 60 * 1000L - override var sessionLength = 4 - override var timerFrequency: Float = 60f - override var alarmEnabled = true - override var vibrateEnabled = true - override var dndEnabled: Boolean = false - override var colorScheme = lightColorScheme() - override var alarmSoundUri: Uri? = - Settings.System.DEFAULT_ALARM_ALERT_URI ?: Settings.System.DEFAULT_RINGTONE_URI - override var serviceRunning = MutableStateFlow(false) -} \ No newline at end of file diff --git a/app/src/main/java/org/nsh07/pomodoro/service/TimerService.kt b/app/src/main/java/org/nsh07/pomodoro/service/TimerService.kt index e87e2a7..b369d57 100644 --- a/app/src/main/java/org/nsh07/pomodoro/service/TimerService.kt +++ b/app/src/main/java/org/nsh07/pomodoro/service/TimerService.kt @@ -36,10 +36,11 @@ import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Job import kotlinx.coroutines.SupervisorJob import kotlinx.coroutines.delay -import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.flow.update import kotlinx.coroutines.launch import kotlinx.coroutines.runBlocking +import kotlinx.coroutines.sync.Mutex +import kotlinx.coroutines.sync.withLock import org.nsh07.pomodoro.R import org.nsh07.pomodoro.TomatoApplication import org.nsh07.pomodoro.ui.timerScreen.viewModel.TimerMode @@ -51,27 +52,30 @@ class TimerService : Service() { (application as TomatoApplication).container } - private val timerRepository by lazy { appContainer.appTimerRepository } + private val stateRepository by lazy { appContainer.stateRepository } private val statRepository by lazy { appContainer.appStatRepository } private val notificationManager by lazy { appContainer.notificationManager } private val notificationManagerService by lazy { appContainer.notificationManagerService } private val notificationBuilder by lazy { appContainer.notificationBuilder } - private val _timerState by lazy { appContainer.timerState } + private val _timerState by lazy { stateRepository.timerState } + private val _settingsState by lazy { stateRepository.settingsState } private val _time by lazy { appContainer.time } - private val timeStateFlow by lazy { _time.asStateFlow() } - + /** + * Remaining time + */ private var time: Long - get() = timeStateFlow.value + get() = _time.value set(value) = _time.update { value } - private val timerState by lazy { _timerState.asStateFlow() } - private var cycles = 0 private var startTime = 0L private var pauseTime = 0L private var pauseDuration = 0L + private var lastSavedDuration = 0L + + private val saveLock = Mutex() private var job = SupervisorJob() private val timerScope = CoroutineScope(Dispatchers.IO + job) private val skipScope = CoroutineScope(Dispatchers.IO + job) @@ -88,7 +92,7 @@ class TimerService : Service() { } } - private val cs by lazy { timerRepository.colorScheme } + private val cs by lazy { stateRepository.colorScheme } private lateinit var notificationStyle: NotificationCompat.ProgressStyle @@ -98,15 +102,16 @@ class TimerService : Service() { override fun onCreate() { super.onCreate() - timerRepository.serviceRunning.update { true } + stateRepository.timerState.update { it.copy(serviceRunning = true) } alarm = initializeMediaPlayer() } override fun onDestroy() { - timerRepository.serviceRunning.update { false } + stateRepository.timerState.update { it.copy(serviceRunning = false) } runBlocking { job.cancel() saveTimeToDb() + lastSavedDuration = 0 setDoNotDisturb(false) notificationManager.cancel(1) alarm?.release() @@ -122,7 +127,7 @@ class TimerService : Service() { } Actions.RESET.toString() -> { - if (timerState.value.timerRunning) toggleTimer() + if (_timerState.value.timerRunning) toggleTimer() skipScope.launch { resetTimer() stopForegroundService() @@ -141,7 +146,7 @@ class TimerService : Service() { private fun toggleTimer() { updateProgressSegments() - if (timerState.value.timerRunning) { + if (_timerState.value.timerRunning) { setDoNotDisturb(false) notificationBuilder.clearActions().addTimerActions( this, R.drawable.play, getString(R.string.start) @@ -152,7 +157,7 @@ class TimerService : Service() { } pauseTime = SystemClock.elapsedRealtime() } else { - if (timerState.value.timerMode == TimerMode.FOCUS) setDoNotDisturb(true) + if (_timerState.value.timerMode == TimerMode.FOCUS) setDoNotDisturb(true) else setDoNotDisturb(false) notificationBuilder.clearActions().addTimerActions( this, R.drawable.pause, getString(R.string.stop) @@ -164,19 +169,20 @@ class TimerService : Service() { timerScope.launch { while (true) { - if (!timerState.value.timerRunning) break + if (!_timerState.value.timerRunning) break if (startTime == 0L) startTime = SystemClock.elapsedRealtime() - time = when (timerState.value.timerMode) { - TimerMode.FOCUS -> timerRepository.focusTime - (SystemClock.elapsedRealtime() - startTime - pauseDuration) + val settingsState = _settingsState.value + time = when (_timerState.value.timerMode) { + TimerMode.FOCUS -> settingsState.focusTime - (SystemClock.elapsedRealtime() - startTime - pauseDuration) - TimerMode.SHORT_BREAK -> timerRepository.shortBreakTime - (SystemClock.elapsedRealtime() - startTime - pauseDuration) + TimerMode.SHORT_BREAK -> settingsState.shortBreakTime - (SystemClock.elapsedRealtime() - startTime - pauseDuration) - else -> timerRepository.longBreakTime - (SystemClock.elapsedRealtime() - startTime - pauseDuration) + else -> settingsState.longBreakTime - (SystemClock.elapsedRealtime() - startTime - pauseDuration) } iterations = - (iterations + 1) % timerRepository.timerFrequency.toInt().coerceAtLeast(1) + (iterations + 1) % stateRepository.timerFrequency.toInt().coerceAtLeast(1) if (iterations == 0) showTimerNotification(time.toInt()) @@ -192,9 +198,16 @@ class TimerService : Service() { timeStr = millisecondsToStr(time) ) } + val totalTime = _timerState.value.totalTime + + if (totalTime - time < lastSavedDuration) + lastSavedDuration = + 0 // Sanity check, prevents bugs if service is force closed + if (totalTime - time - lastSavedDuration > 60000) + saveTimeToDb() } - delay((1000f / timerRepository.timerFrequency).toLong()) + delay((1000f / stateRepository.timerFrequency).toLong()) } } } @@ -207,21 +220,23 @@ class TimerService : Service() { fun showTimerNotification( remainingTime: Int, paused: Boolean = false, complete: Boolean = false ) { + val settingsState = _settingsState.value + if (complete) notificationBuilder.clearActions().addStopAlarmAction(this) - val totalTime = when (timerState.value.timerMode) { - TimerMode.FOCUS -> timerRepository.focusTime.toInt() - TimerMode.SHORT_BREAK -> timerRepository.shortBreakTime.toInt() - else -> timerRepository.longBreakTime.toInt() + val totalTime = when (_timerState.value.timerMode) { + TimerMode.FOCUS -> settingsState.focusTime.toInt() + TimerMode.SHORT_BREAK -> settingsState.shortBreakTime.toInt() + else -> settingsState.longBreakTime.toInt() } - val currentTimer = when (timerState.value.timerMode) { + val currentTimer = when (_timerState.value.timerMode) { TimerMode.FOCUS -> getString(R.string.focus) TimerMode.SHORT_BREAK -> getString(R.string.short_break) else -> getString(R.string.long_break) } - val nextTimer = when (timerState.value.nextTimerMode) { + val nextTimer = when (_timerState.value.nextTimerMode) { TimerMode.FOCUS -> getString(R.string.focus) TimerMode.SHORT_BREAK -> getString(R.string.short_break) else -> getString(R.string.long_break) @@ -244,14 +259,14 @@ class TimerService : Service() { getString( R.string.up_next_notification, nextTimer, - timerState.value.nextTimeStr + _timerState.value.nextTimeStr ) ) .setStyle( notificationStyle .setProgress( // Set the current progress by filling the previous intervals and part of the current interval - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.BAKLAVA) { - (totalTime - remainingTime) + ((cycles + 1) / 2) * timerRepository.focusTime.toInt() + (cycles / 2) * timerRepository.shortBreakTime.toInt() + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.BAKLAVA && !settingsState.singleProgressBar) { + (totalTime - remainingTime) + ((cycles + 1) / 2) * settingsState.focusTime.toInt() + (cycles / 2) * settingsState.shortBreakTime.toInt() } else (totalTime - remainingTime) ) ) @@ -269,37 +284,38 @@ class TimerService : Service() { } private fun updateProgressSegments() { + val settingsState = _settingsState.value notificationStyle = NotificationCompat.ProgressStyle() .also { // Add all the Focus, Short break and long break intervals in order - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.BAKLAVA) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.BAKLAVA && !settingsState.singleProgressBar) { // Android 16 and later supports live updates // Set progress bar sections if on Baklava or later - for (i in 0.. timerRepository.focusTime.toInt() - TimerMode.SHORT_BREAK -> timerRepository.shortBreakTime.toInt() - else -> timerRepository.longBreakTime.toInt() + when (_timerState.value.timerMode) { + TimerMode.FOCUS -> settingsState.focusTime.toInt() + TimerMode.SHORT_BREAK -> settingsState.shortBreakTime.toInt() + else -> settingsState.longBreakTime.toInt() } ) ) @@ -308,9 +324,11 @@ class TimerService : Service() { } private suspend fun resetTimer() { - updateProgressSegments() + val settingsState = _settingsState.value + saveTimeToDb() - time = timerRepository.focusTime + lastSavedDuration = 0 + time = settingsState.focusTime cycles = 0 startTime = 0L pauseTime = 0L @@ -321,47 +339,50 @@ class TimerService : Service() { timerMode = TimerMode.FOCUS, timeStr = millisecondsToStr(time), totalTime = time, - nextTimerMode = if (timerRepository.sessionLength > 1) TimerMode.SHORT_BREAK else TimerMode.LONG_BREAK, - nextTimeStr = millisecondsToStr(if (timerRepository.sessionLength > 1) timerRepository.shortBreakTime else timerRepository.longBreakTime), + nextTimerMode = if (settingsState.sessionLength > 1) TimerMode.SHORT_BREAK else TimerMode.LONG_BREAK, + nextTimeStr = millisecondsToStr(if (settingsState.sessionLength > 1) settingsState.shortBreakTime else settingsState.longBreakTime), currentFocusCount = 1, - totalFocusCount = timerRepository.sessionLength + totalFocusCount = settingsState.sessionLength ) } + + updateProgressSegments() } private suspend fun skipTimer(fromButton: Boolean = false) { - updateProgressSegments() + val settingsState = _settingsState.value saveTimeToDb() updateProgressSegments() showTimerNotification(0, paused = true, complete = !fromButton) + lastSavedDuration = 0 startTime = 0L pauseTime = 0L pauseDuration = 0L - cycles = (cycles + 1) % (timerRepository.sessionLength * 2) + cycles = (cycles + 1) % (settingsState.sessionLength * 2) if (cycles % 2 == 0) { - if (timerState.value.timerRunning) setDoNotDisturb(true) - time = timerRepository.focusTime + if (_timerState.value.timerRunning) setDoNotDisturb(true) + time = settingsState.focusTime _timerState.update { currentState -> currentState.copy( timerMode = TimerMode.FOCUS, timeStr = millisecondsToStr(time), totalTime = time, - nextTimerMode = if (cycles == (timerRepository.sessionLength - 1) * 2) TimerMode.LONG_BREAK else TimerMode.SHORT_BREAK, - nextTimeStr = if (cycles == (timerRepository.sessionLength - 1) * 2) millisecondsToStr( - timerRepository.longBreakTime + nextTimerMode = if (cycles == (settingsState.sessionLength - 1) * 2) TimerMode.LONG_BREAK else TimerMode.SHORT_BREAK, + nextTimeStr = if (cycles == (settingsState.sessionLength - 1) * 2) millisecondsToStr( + settingsState.longBreakTime ) else millisecondsToStr( - timerRepository.shortBreakTime + settingsState.shortBreakTime ), currentFocusCount = cycles / 2 + 1, - totalFocusCount = timerRepository.sessionLength + totalFocusCount = settingsState.sessionLength ) } } else { - if (timerState.value.timerRunning) setDoNotDisturb(false) - val long = cycles == (timerRepository.sessionLength * 2) - 1 - time = if (long) timerRepository.longBreakTime else timerRepository.shortBreakTime + if (_timerState.value.timerRunning) setDoNotDisturb(false) + val long = cycles == (settingsState.sessionLength * 2) - 1 + time = if (long) settingsState.longBreakTime else settingsState.shortBreakTime _timerState.update { currentState -> currentState.copy( @@ -369,14 +390,17 @@ class TimerService : Service() { timeStr = millisecondsToStr(time), totalTime = time, nextTimerMode = TimerMode.FOCUS, - nextTimeStr = millisecondsToStr(timerRepository.focusTime) + nextTimeStr = millisecondsToStr(settingsState.focusTime) ) } } + + updateProgressSegments() } fun startAlarm() { - if (timerRepository.alarmEnabled) alarm?.start() + val settingsState = _settingsState.value + if (settingsState.alarmEnabled) alarm?.start() appContainer.activityTurnScreenOn(true) @@ -385,7 +409,7 @@ class TimerService : Service() { stopAlarm() } - if (timerRepository.vibrateEnabled) { + if (settingsState.vibrateEnabled) { if (!vibrator.hasVibrator()) { return } @@ -397,14 +421,15 @@ class TimerService : Service() { } fun stopAlarm() { + val settingsState = _settingsState.value autoAlarmStopScope?.cancel() - if (timerRepository.alarmEnabled) { + if (settingsState.alarmEnabled) { alarm?.pause() alarm?.seekTo(0) } - if (timerRepository.vibrateEnabled) { + if (settingsState.vibrateEnabled) { vibrator.cancel() } @@ -418,24 +443,28 @@ class TimerService : Service() { getString(R.string.start_next) ) showTimerNotification( - when (timerState.value.timerMode) { - TimerMode.FOCUS -> timerRepository.focusTime.toInt() - TimerMode.SHORT_BREAK -> timerRepository.shortBreakTime.toInt() - else -> timerRepository.longBreakTime.toInt() + when (_timerState.value.timerMode) { + TimerMode.FOCUS -> settingsState.focusTime.toInt() + TimerMode.SHORT_BREAK -> settingsState.shortBreakTime.toInt() + else -> settingsState.longBreakTime.toInt() }, paused = true, complete = false ) } private fun initializeMediaPlayer(): MediaPlayer? { + val settingsState = _settingsState.value return try { MediaPlayer().apply { setAudioAttributes( AudioAttributes.Builder() .setContentType(AudioAttributes.CONTENT_TYPE_MUSIC) - .setUsage(AudioAttributes.USAGE_ALARM) + .setUsage( + if (settingsState.mediaVolumeForAlarm) AudioAttributes.USAGE_MEDIA + else AudioAttributes.USAGE_ALARM + ) .build() ) - timerRepository.alarmSoundUri?.let { + settingsState.alarmSoundUri?.let { setDataSource(applicationContext, it) prepare() } @@ -447,7 +476,7 @@ class TimerService : Service() { } private fun setDoNotDisturb(doNotDisturb: Boolean) { - if (timerRepository.dndEnabled && notificationManagerService.isNotificationPolicyAccessGranted()) { + if (_settingsState.value.dndEnabled && notificationManagerService.isNotificationPolicyAccessGranted()) { if (doNotDisturb) { notificationManagerService.setInterruptionFilter(NotificationManager.INTERRUPTION_FILTER_ALARMS) } else notificationManagerService.setInterruptionFilter(NotificationManager.INTERRUPTION_FILTER_ALL) @@ -460,14 +489,18 @@ class TimerService : Service() { } suspend fun saveTimeToDb() { - when (timerState.value.timerMode) { - TimerMode.FOCUS -> statRepository.addFocusTime( - (timerState.value.totalTime - time).coerceAtLeast( - 0L + saveLock.withLock { + val elapsedTime = _timerState.value.totalTime - time + when (_timerState.value.timerMode) { + TimerMode.FOCUS -> statRepository.addFocusTime( + (elapsedTime - lastSavedDuration).coerceAtLeast(0L) ) - ) - else -> statRepository.addBreakTime((timerState.value.totalTime - time).coerceAtLeast(0L)) + else -> statRepository.addBreakTime( + (elapsedTime - lastSavedDuration).coerceAtLeast(0L) + ) + } + lastSavedDuration = elapsedTime } } diff --git a/app/src/main/java/org/nsh07/pomodoro/ui/AlwaysOnDisplay.kt b/app/src/main/java/org/nsh07/pomodoro/ui/AlwaysOnDisplay.kt index ed82236..e3cc1ea 100644 --- a/app/src/main/java/org/nsh07/pomodoro/ui/AlwaysOnDisplay.kt +++ b/app/src/main/java/org/nsh07/pomodoro/ui/AlwaysOnDisplay.kt @@ -23,7 +23,6 @@ import androidx.activity.compose.LocalActivity import androidx.compose.animation.SharedTransitionLayout import androidx.compose.animation.SharedTransitionScope import androidx.compose.animation.animateColorAsState -import androidx.compose.animation.core.animateIntAsState import androidx.compose.foundation.background import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.fillMaxSize @@ -64,7 +63,7 @@ import androidx.core.view.WindowInsetsCompat import androidx.core.view.WindowInsetsControllerCompat import androidx.navigation3.ui.LocalNavAnimatedContentScope import kotlinx.coroutines.delay -import org.nsh07.pomodoro.ui.theme.AppFonts.interClock +import org.nsh07.pomodoro.ui.theme.AppFonts.googleFlex600 import org.nsh07.pomodoro.ui.theme.TomatoTheme import org.nsh07.pomodoro.ui.timerScreen.TimerScreen import org.nsh07.pomodoro.ui.timerScreen.viewModel.TimerMode @@ -159,7 +158,7 @@ fun SharedTransitionScope.AlwaysOnDisplay( animationSpec = motionScheme.slowEffectsSpec() ) - var randomX by remember { + var x by remember { mutableIntStateOf( Random.nextInt( 16.dp.toIntPx(density), @@ -167,7 +166,7 @@ fun SharedTransitionScope.AlwaysOnDisplay( ) ) } - var randomY by remember { + var y by remember { mutableIntStateOf( Random.nextInt( 16.dp.toIntPx(density), @@ -176,22 +175,21 @@ fun SharedTransitionScope.AlwaysOnDisplay( ) } - LaunchedEffect(timerState.timeStr[1]) { // Randomize position every minute + var xIncrement by remember { mutableIntStateOf(1) } + var yIncrement by remember { mutableIntStateOf(1) } + + LaunchedEffect(timerState.timeStr) { // Randomize position every minute if (sharedElementTransitionComplete) { - randomX = Random.nextInt( - 16.dp.toIntPx(density), - windowInfo.containerSize.width - 266.dp.toIntPx(density) - ) - randomY = Random.nextInt( - 16.dp.toIntPx(density), - windowInfo.containerSize.height - 266.dp.toIntPx(density) - ) + val elementSize = 266.dp.toIntPx(density) + if (windowInfo.containerSize.width - elementSize < x + xIncrement || x + xIncrement < 16) + xIncrement = -xIncrement + if (windowInfo.containerSize.height - elementSize < y + yIncrement || y + yIncrement < 16) + yIncrement = -yIncrement + x += xIncrement + y += yIncrement } } - val x by animateIntAsState(randomX, motionScheme.slowSpatialSpec()) - val y by animateIntAsState(randomY, motionScheme.slowSpatialSpec()) - Box( modifier = modifier .fillMaxSize() @@ -248,7 +246,7 @@ fun SharedTransitionScope.AlwaysOnDisplay( Text( text = timerState.timeStr, style = TextStyle( - fontFamily = interClock, + fontFamily = googleFlex600, fontSize = 56.sp, letterSpacing = (-2).sp, fontFeatureSettings = "tnum" diff --git a/app/src/main/java/org/nsh07/pomodoro/ui/AppScreen.kt b/app/src/main/java/org/nsh07/pomodoro/ui/AppScreen.kt index a998da7..7305806 100644 --- a/app/src/main/java/org/nsh07/pomodoro/ui/AppScreen.kt +++ b/app/src/main/java/org/nsh07/pomodoro/ui/AppScreen.kt @@ -21,36 +21,64 @@ import android.content.Intent import androidx.compose.animation.AnimatedVisibility import androidx.compose.animation.Crossfade import androidx.compose.animation.SharedTransitionLayout +import androidx.compose.animation.animateColorAsState +import androidx.compose.animation.expandHorizontally import androidx.compose.animation.fadeIn import androidx.compose.animation.fadeOut +import androidx.compose.animation.shrinkHorizontally import androidx.compose.animation.slideInVertically import androidx.compose.animation.slideOutVertically import androidx.compose.animation.togetherWith import androidx.compose.foundation.clickable +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.WindowInsets +import androidx.compose.foundation.layout.asPaddingValues import androidx.compose.foundation.layout.calculateEndPadding import androidx.compose.foundation.layout.calculateStartPadding +import androidx.compose.foundation.layout.displayCutout +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.systemBars +import androidx.compose.foundation.shape.CircleShape +import androidx.compose.material3.ButtonDefaults import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.ExperimentalMaterial3ExpressiveApi +import androidx.compose.material3.FloatingToolbarDefaults +import androidx.compose.material3.FloatingToolbarDefaults.ScreenOffset +import androidx.compose.material3.FloatingToolbarExitDirection +import androidx.compose.material3.HorizontalFloatingToolbar import androidx.compose.material3.Icon +import androidx.compose.material3.MaterialTheme.colorScheme import androidx.compose.material3.MaterialTheme.motionScheme -import androidx.compose.material3.NavigationItemIconPosition +import androidx.compose.material3.PlainTooltip import androidx.compose.material3.Scaffold -import androidx.compose.material3.ShortNavigationBar -import androidx.compose.material3.ShortNavigationBarArrangement -import androidx.compose.material3.ShortNavigationBarItem import androidx.compose.material3.Text +import androidx.compose.material3.ToggleButton +import androidx.compose.material3.ToggleButtonDefaults +import androidx.compose.material3.TooltipAnchorPosition +import androidx.compose.material3.TooltipBox +import androidx.compose.material3.TooltipDefaults import androidx.compose.material3.adaptive.currentWindowAdaptiveInfo +import androidx.compose.material3.rememberTooltipState import androidx.compose.runtime.Composable +import androidx.compose.runtime.derivedStateOf import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf 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.LocalLayoutDirection import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource +import androidx.compose.ui.text.style.TextOverflow +import androidx.compose.ui.unit.dp +import androidx.compose.ui.unit.sp +import androidx.compose.ui.util.fastForEach +import androidx.compose.ui.zIndex import androidx.lifecycle.compose.collectAsStateWithLifecycle import androidx.lifecycle.viewmodel.compose.viewModel import androidx.navigation3.runtime.entryProvider @@ -63,6 +91,7 @@ import org.nsh07.pomodoro.ui.settingsScreen.SettingsScreenRoot import org.nsh07.pomodoro.ui.statsScreen.StatsScreenRoot import org.nsh07.pomodoro.ui.timerScreen.AlarmDialog import org.nsh07.pomodoro.ui.timerScreen.TimerScreen +import org.nsh07.pomodoro.ui.timerScreen.viewModel.TimerMode import org.nsh07.pomodoro.ui.timerScreen.viewModel.TimerViewModel @OptIn(ExperimentalMaterial3Api::class, ExperimentalMaterial3ExpressiveApi::class) @@ -82,8 +111,13 @@ fun AppScreen( val layoutDirection = LocalLayoutDirection.current val motionScheme = motionScheme val windowSizeClass = currentWindowAdaptiveInfo().windowSizeClass + val systemBarsInsets = WindowInsets.systemBars.asPaddingValues() + val cutoutInsets = WindowInsets.displayCutout.asPaddingValues() val backStack = rememberNavBackStack(Screen.Timer) + val toolbarScrollBehavior = FloatingToolbarDefaults.exitAlwaysScrollBehavior( + FloatingToolbarExitDirection.Bottom + ) if (uiState.alarmRinging) AlarmDialog { @@ -99,46 +133,117 @@ fun AppScreen( bottomBar = { AnimatedVisibility( backStack.last() !is Screen.AOD, - enter = fadeIn(), - exit = fadeOut() + enter = slideInVertically(motionScheme.slowSpatialSpec()) { it }, + exit = slideOutVertically(motionScheme.slowSpatialSpec()) { it } ) { val wide = remember { windowSizeClass.isWidthAtLeastBreakpoint( WindowSizeClass.WIDTH_DP_MEDIUM_LOWER_BOUND ) } - ShortNavigationBar( - arrangement = - if (wide) ShortNavigationBarArrangement.Centered - else ShortNavigationBarArrangement.EqualWeight + + val primary by animateColorAsState( + if (uiState.timerMode == TimerMode.FOCUS) colorScheme.primary else colorScheme.tertiary + ) + val onPrimary by animateColorAsState( + if (uiState.timerMode == TimerMode.FOCUS) colorScheme.onPrimary else colorScheme.onTertiary + ) + val primaryContainer by animateColorAsState( + if (uiState.timerMode == TimerMode.FOCUS) colorScheme.primaryContainer else colorScheme.tertiaryContainer + ) + val onPrimaryContainer by animateColorAsState( + if (uiState.timerMode == TimerMode.FOCUS) colorScheme.onPrimaryContainer else colorScheme.onTertiaryContainer + ) + + Box( + Modifier + .fillMaxWidth() + .padding( + start = cutoutInsets.calculateStartPadding(layoutDirection), + end = cutoutInsets.calculateEndPadding(layoutDirection) + ), + Alignment.Center ) { - mainScreens.forEach { - val selected = backStack.last() == it.route - ShortNavigationBarItem( - selected = selected, - onClick = if (it.route != Screen.Timer) { // Ensure the backstack does not accumulate screens - { - if (backStack.size < 2) backStack.add(it.route) - else backStack[1] = it.route + HorizontalFloatingToolbar( + expanded = true, + scrollBehavior = toolbarScrollBehavior, + colors = FloatingToolbarDefaults.vibrantFloatingToolbarColors( + toolbarContainerColor = primaryContainer, + toolbarContentColor = onPrimaryContainer + ), + modifier = Modifier + .padding( + top = ScreenOffset, + bottom = systemBarsInsets.calculateBottomPadding() + + ScreenOffset + ) + .zIndex(1f) + ) { + mainScreens.fastForEach { item -> + val selected by remember { derivedStateOf { backStack.lastOrNull() == item.route } } + TooltipBox( + positionProvider = + TooltipDefaults.rememberTooltipPositionProvider( + TooltipAnchorPosition.Above + ), + tooltip = { PlainTooltip { Text(stringResource(item.label)) } }, + state = rememberTooltipState(), + ) { + ToggleButton( + checked = selected, + onCheckedChange = if (item.route != Screen.Timer) { // Ensure the backstack does not accumulate screens + { + if (backStack.size < 2) backStack.add(item.route) + else backStack[1] = item.route + } + } else { + { if (backStack.size > 1) backStack.removeAt(1) } + }, + colors = ToggleButtonDefaults.toggleButtonColors( + containerColor = primaryContainer, + contentColor = onPrimaryContainer, + checkedContainerColor = primary, + checkedContentColor = onPrimary + ), + shapes = ToggleButtonDefaults.shapes( + CircleShape, + CircleShape, + CircleShape + ), + modifier = Modifier.height(56.dp) + ) { + Row { + Crossfade(selected) { + if (it) Icon( + painterResource(item.selectedIcon), + null + ) + else Icon(painterResource(item.unselectedIcon), null) + } + AnimatedVisibility( + visible = selected || wide, + enter = expandHorizontally(motionScheme.defaultSpatialSpec()), + exit = shrinkHorizontally(motionScheme.defaultSpatialSpec()) + ) { + Text( + text = stringResource(item.label), + fontSize = 16.sp, + lineHeight = 24.sp, + maxLines = 1, + softWrap = false, + overflow = TextOverflow.Clip, + modifier = Modifier.padding(start = ButtonDefaults.IconSpacing) + ) + } + } } - } else { - { if (backStack.size > 1) backStack.removeAt(1) } - }, - icon = { - Crossfade(selected) { selected -> - if (selected) Icon(painterResource(it.selectedIcon), null) - else Icon(painterResource(it.unselectedIcon), null) - } - }, - iconPosition = - if (wide) NavigationItemIconPosition.Start - else NavigationItemIconPosition.Top, - label = { Text(stringResource(it.label)) } - ) + } + } } } } - } + }, + modifier = modifier ) { contentPadding -> SharedTransitionLayout { NavDisplay( @@ -161,20 +266,12 @@ fun AppScreen( TimerScreen( timerState = uiState, isPlus = isPlus, + contentPadding = contentPadding, progress = { progress }, onAction = timerViewModel::onAction, - modifier = modifier - .padding( - start = contentPadding.calculateStartPadding(layoutDirection), - end = contentPadding.calculateEndPadding(layoutDirection), - bottom = contentPadding.calculateBottomPadding() - ) - .then( - if (isAODEnabled) Modifier.clickable { - if (backStack.size < 2) backStack.add(Screen.AOD) - } - else Modifier - ), + modifier = if (isAODEnabled) Modifier.clickable { + if (backStack.size < 2) backStack.add(Screen.AOD) + } else Modifier ) } @@ -183,36 +280,21 @@ fun AppScreen( timerState = uiState, progress = { progress }, setTimerFrequency = setTimerFrequency, - modifier = Modifier - .then( - if (isAODEnabled) Modifier.clickable { - if (backStack.size > 1) backStack.removeLastOrNull() - } - else Modifier - ) + modifier = if (isAODEnabled) Modifier.clickable { + if (backStack.size > 1) backStack.removeLastOrNull() + } else Modifier ) } entry { SettingsScreenRoot( setShowPaywall = { showPaywall = it }, - modifier = modifier.padding( - start = contentPadding.calculateStartPadding(layoutDirection), - end = contentPadding.calculateEndPadding(layoutDirection), - bottom = contentPadding.calculateBottomPadding() - ) + contentPadding = contentPadding ) } entry { - StatsScreenRoot( - contentPadding = contentPadding, - modifier = modifier.padding( - start = contentPadding.calculateStartPadding(layoutDirection), - end = contentPadding.calculateEndPadding(layoutDirection), - bottom = contentPadding.calculateBottomPadding() - ) - ) + StatsScreenRoot(contentPadding = contentPadding) } } ) diff --git a/app/src/main/java/org/nsh07/pomodoro/ui/Navigation.kt b/app/src/main/java/org/nsh07/pomodoro/ui/Navigation.kt index 2641e7a..abf49bd 100644 --- a/app/src/main/java/org/nsh07/pomodoro/ui/Navigation.kt +++ b/app/src/main/java/org/nsh07/pomodoro/ui/Navigation.kt @@ -45,18 +45,23 @@ val settingsScreens = listOf( Screen.Settings.Timer, R.drawable.timer_filled, R.string.timer, - listOf(R.string.durations, R.string.session_length, R.string.always_on_display) + listOf(R.string.durations, R.string.dnd, R.string.always_on_display) ), SettingsNavItem( Screen.Settings.Alarm, R.drawable.alarm, R.string.alarm, - listOf(R.string.alarm_sound, R.string.alarm, R.string.vibrate) + listOf( + R.string.alarm_sound, + R.string.sound, + R.string.vibrate, + R.string.media_volume_for_alarm + ) ), SettingsNavItem( Screen.Settings.Appearance, R.drawable.palette, R.string.appearance, - listOf(R.string.color_scheme, R.string.theme, R.string.black_theme) + listOf(R.string.theme, R.string.color_scheme, R.string.black_theme) ) ) diff --git a/app/src/main/java/org/nsh07/pomodoro/ui/Screen.kt b/app/src/main/java/org/nsh07/pomodoro/ui/Screen.kt index a37fe21..b7ef562 100644 --- a/app/src/main/java/org/nsh07/pomodoro/ui/Screen.kt +++ b/app/src/main/java/org/nsh07/pomodoro/ui/Screen.kt @@ -34,6 +34,9 @@ sealed class Screen : NavKey { @Serializable object Main : Settings() + @Serializable + object About : Settings() + @Serializable object Alarm : Settings() diff --git a/app/src/main/java/org/nsh07/pomodoro/ui/mergePaddingValues.kt b/app/src/main/java/org/nsh07/pomodoro/ui/mergePaddingValues.kt new file mode 100644 index 0000000..dfbbf10 --- /dev/null +++ b/app/src/main/java/org/nsh07/pomodoro/ui/mergePaddingValues.kt @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2025 Nishant Mishra + * + * This file is part of Tomato - a minimalist pomodoro timer for Android. + * + * Tomato is free software: you can redistribute it and/or modify it under the terms of the GNU + * General Public License as published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * Tomato is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even + * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General + * Public License for more details. + * + * You should have received a copy of the GNU General Public License along with Tomato. + * If not, see . + */ + +package org.nsh07.pomodoro.ui + +import androidx.compose.foundation.layout.PaddingValues +import androidx.compose.foundation.layout.calculateEndPadding +import androidx.compose.foundation.layout.calculateStartPadding +import androidx.compose.runtime.Composable +import androidx.compose.ui.platform.LocalLayoutDirection + +@Composable +fun mergePaddingValues( + topSource: PaddingValues, + restSource: PaddingValues +): PaddingValues { + val layoutDirection = LocalLayoutDirection.current + + return PaddingValues( + top = topSource.calculateTopPadding(), + bottom = restSource.calculateBottomPadding(), + start = restSource.calculateStartPadding(layoutDirection), + end = restSource.calculateEndPadding(layoutDirection) + ) +} \ No newline at end of file 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 6c967ea..79dbda2 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 @@ -27,7 +27,7 @@ import androidx.compose.animation.slideOutHorizontally import androidx.compose.animation.togetherWith import androidx.compose.foundation.background import androidx.compose.foundation.layout.Arrangement -import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.height @@ -39,6 +39,7 @@ import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.ExperimentalMaterial3ExpressiveApi import androidx.compose.material3.Icon import androidx.compose.material3.LocalTextStyle +import androidx.compose.material3.Scaffold import androidx.compose.material3.SliderState import androidx.compose.material3.Text import androidx.compose.material3.TopAppBar @@ -64,12 +65,14 @@ import androidx.lifecycle.compose.collectAsStateWithLifecycle import androidx.lifecycle.viewmodel.compose.viewModel import androidx.navigation3.runtime.entryProvider import androidx.navigation3.ui.NavDisplay +import org.nsh07.pomodoro.BuildConfig import org.nsh07.pomodoro.R import org.nsh07.pomodoro.ui.Screen -import org.nsh07.pomodoro.ui.settingsScreen.components.AboutCard +import org.nsh07.pomodoro.ui.mergePaddingValues import org.nsh07.pomodoro.ui.settingsScreen.components.ClickableListItem import org.nsh07.pomodoro.ui.settingsScreen.components.LocaleBottomSheet import org.nsh07.pomodoro.ui.settingsScreen.components.PlusPromo +import org.nsh07.pomodoro.ui.settingsScreen.screens.AboutScreen import org.nsh07.pomodoro.ui.settingsScreen.screens.AlarmSettings import org.nsh07.pomodoro.ui.settingsScreen.screens.AppearanceSettings import org.nsh07.pomodoro.ui.settingsScreen.screens.TimerSettings @@ -86,6 +89,7 @@ import org.nsh07.pomodoro.ui.theme.CustomColors.topBarColors @Composable fun SettingsScreenRoot( setShowPaywall: (Boolean) -> Unit, + contentPadding: PaddingValues, modifier: Modifier = Modifier, viewModel: SettingsViewModel = viewModel(factory = SettingsViewModel.Factory) ) { @@ -119,6 +123,7 @@ fun SettingsScreenRoot( serviceRunning = serviceRunning, settingsState = settingsState, backStack = backStack, + contentPadding = contentPadding, focusTimeInputFieldState = focusTimeInputFieldState, shortBreakTimeInputFieldState = shortBreakTimeInputFieldState, longBreakTimeInputFieldState = longBreakTimeInputFieldState, @@ -137,6 +142,7 @@ private fun SettingsScreen( serviceRunning: Boolean, settingsState: SettingsState, backStack: SnapshotStateList, + contentPadding: PaddingValues, focusTimeInputFieldState: TextFieldState, shortBreakTimeInputFieldState: TextFieldState, longBreakTimeInputFieldState: TextFieldState, @@ -181,47 +187,63 @@ private fun SettingsScreen( }, entryProvider = entryProvider { entry { - Column(modifier.nestedScroll(scrollBehavior.nestedScrollConnection)) { - TopAppBar( - title = { - Text( - stringResource(R.string.settings), - style = LocalTextStyle.current.copy( - fontFamily = robotoFlexTopBar, - fontSize = 32.sp, - lineHeight = 32.sp + Scaffold( + topBar = { + TopAppBar( + title = { + Text( + stringResource(R.string.settings), + style = LocalTextStyle.current.copy( + fontFamily = robotoFlexTopBar, + fontSize = 32.sp, + lineHeight = 32.sp + ) ) - ) - }, - subtitle = {}, - colors = topBarColors, - titleHorizontalAlignment = Alignment.CenterHorizontally, - scrollBehavior = scrollBehavior - ) - + }, + subtitle = {}, + colors = topBarColors, + titleHorizontalAlignment = Alignment.CenterHorizontally, + scrollBehavior = scrollBehavior + ) + }, + modifier = modifier.nestedScroll(scrollBehavior.nestedScrollConnection) + ) { innerPadding -> + val insets = mergePaddingValues(innerPadding, contentPadding) LazyColumn( verticalArrangement = Arrangement.spacedBy(2.dp), + contentPadding = insets, modifier = Modifier .background(topBarColors.containerColor) .fillMaxSize() .padding(horizontal = 16.dp) ) { - item { Spacer(Modifier.height(12.dp)) } + item { Spacer(Modifier.height(14.dp)) } - if (!isPlus) item { + item { PlusPromo(isPlus, setShowPaywall) - Spacer(Modifier.height(14.dp)) } - item { AboutCard(isPlus) } + item { + ClickableListItem( + leadingContent = { + Icon(painterResource(R.drawable.info), null) + }, + headlineContent = { + Text(stringResource(R.string.about)) + }, + supportingContent = { + Text(stringResource(R.string.app_name) + " ${BuildConfig.VERSION_NAME}") + }, + trailingContent = { + Icon(painterResource(R.drawable.arrow_forward_big), null) + }, + items = 2, + index = 1 + ) { backStack.add(Screen.Settings.About) } + } item { Spacer(Modifier.height(12.dp)) } - if (isPlus) item { - PlusPromo(isPlus, setShowPaywall) - Spacer(Modifier.height(14.dp)) - } - itemsIndexed(settingsScreens) { index, item -> ClickableListItem( leadingContent = { @@ -276,9 +298,18 @@ private fun SettingsScreen( } } + entry { + AboutScreen( + contentPadding = contentPadding, + isPlus = isPlus, + onBack = backStack::removeLastOrNull + ) + } + entry { AlarmSettings( settingsState = settingsState, + contentPadding = contentPadding, onAction = onAction, onBack = backStack::removeLastOrNull, modifier = modifier, @@ -287,6 +318,7 @@ private fun SettingsScreen( entry { AppearanceSettings( settingsState = settingsState, + contentPadding = contentPadding, isPlus = isPlus, onAction = onAction, setShowPaywall = setShowPaywall, @@ -299,6 +331,7 @@ private fun SettingsScreen( isPlus = isPlus, serviceRunning = serviceRunning, settingsState = settingsState, + contentPadding = contentPadding, focusTimeInputFieldState = focusTimeInputFieldState, shortBreakTimeInputFieldState = shortBreakTimeInputFieldState, longBreakTimeInputFieldState = longBreakTimeInputFieldState, diff --git a/app/src/main/java/org/nsh07/pomodoro/ui/settingsScreen/SettingsSwitchItem.kt b/app/src/main/java/org/nsh07/pomodoro/ui/settingsScreen/SettingsSwitchItem.kt index f16c2f4..e202910 100644 --- a/app/src/main/java/org/nsh07/pomodoro/ui/settingsScreen/SettingsSwitchItem.kt +++ b/app/src/main/java/org/nsh07/pomodoro/ui/settingsScreen/SettingsSwitchItem.kt @@ -23,6 +23,7 @@ import androidx.annotation.StringRes data class SettingsSwitchItem( val checked: Boolean, val enabled: Boolean = true, + val collapsible: Boolean = false, @param:DrawableRes val icon: Int, @param:StringRes val label: Int, @param:StringRes val description: Int, diff --git a/app/src/main/java/org/nsh07/pomodoro/ui/settingsScreen/components/AboutCard.kt b/app/src/main/java/org/nsh07/pomodoro/ui/settingsScreen/components/AboutCard.kt deleted file mode 100644 index 580350a..0000000 --- a/app/src/main/java/org/nsh07/pomodoro/ui/settingsScreen/components/AboutCard.kt +++ /dev/null @@ -1,129 +0,0 @@ -/* - * Copyright (c) 2025 Nishant Mishra - * - * This file is part of Tomato - a minimalist pomodoro timer for Android. - * - * Tomato is free software: you can redistribute it and/or modify it under the terms of the GNU - * General Public License as published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * Tomato is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even - * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General - * Public License for more details. - * - * You should have received a copy of the GNU General Public License along with Tomato. - * If not, see . - */ - -package org.nsh07.pomodoro.ui.settingsScreen.components - -import android.widget.Toast -import androidx.compose.foundation.layout.Arrangement -import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.FlowRow -import androidx.compose.foundation.layout.Row -import androidx.compose.foundation.layout.Spacer -import androidx.compose.foundation.layout.fillMaxWidth -import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.layout.size -import androidx.compose.material3.ButtonDefaults -import androidx.compose.material3.Card -import androidx.compose.material3.CardDefaults -import androidx.compose.material3.ExperimentalMaterial3ExpressiveApi -import androidx.compose.material3.Icon -import androidx.compose.material3.IconButton -import androidx.compose.material3.IconButtonDefaults -import androidx.compose.material3.MaterialTheme -import androidx.compose.material3.MaterialTheme.colorScheme -import androidx.compose.material3.MaterialTheme.shapes -import androidx.compose.material3.Text -import androidx.compose.runtime.Composable -import androidx.compose.ui.Alignment -import androidx.compose.ui.Modifier -import androidx.compose.ui.platform.LocalContext -import androidx.compose.ui.platform.LocalUriHandler -import androidx.compose.ui.res.painterResource -import androidx.compose.ui.res.stringResource -import androidx.compose.ui.unit.dp -import org.nsh07.pomodoro.BuildConfig -import org.nsh07.pomodoro.R -import org.nsh07.pomodoro.ui.theme.AppFonts.robotoFlexTopBar - -// Taken from https://github.com/shub39/Grit/blob/master/app/src/main/java/com/shub39/grit/core/presentation/settings/ui/component/AboutApp.kt -@OptIn(ExperimentalMaterial3ExpressiveApi::class) -@Composable -fun AboutCard( - isPlus: Boolean, - modifier: Modifier = Modifier -) { - val uriHandler = LocalUriHandler.current - val context = LocalContext.current - - Card( - modifier = modifier.fillMaxWidth(), - colors = CardDefaults.cardColors( - containerColor = colorScheme.primaryContainer, - contentColor = colorScheme.onPrimaryContainer - ), - shape = shapes.extraLarge - ) { - val buttonColors = ButtonDefaults.buttonColors( - containerColor = colorScheme.onPrimaryContainer, - contentColor = colorScheme.primaryContainer - ) - - Row( - modifier = Modifier - .padding(16.dp) - .fillMaxWidth(), - verticalAlignment = Alignment.CenterVertically, - horizontalArrangement = Arrangement.spacedBy(8.dp) - ) { - Column { - Text( - if (!isPlus) stringResource(R.string.app_name) - else stringResource(R.string.app_name_plus), - style = MaterialTheme.typography.titleLarge, - fontFamily = robotoFlexTopBar - ) - Text(text = "${BuildConfig.VERSION_NAME} (${BuildConfig.VERSION_CODE})") - } - - Spacer(modifier = Modifier.weight(1f)) - - Row { - IconButton( - onClick = { - Toast.makeText(context, "Coming soon...", Toast.LENGTH_SHORT).show() - }, - shapes = IconButtonDefaults.shapes() - ) { - Icon( - painterResource(R.drawable.discord), - contentDescription = "Discord", - modifier = Modifier.size(24.dp) - ) - } - - IconButton( - onClick = { uriHandler.openUri("https://github.com/nsh07/Tomato") }, - shapes = IconButtonDefaults.shapes() - ) { - Icon( - painterResource(R.drawable.github), - contentDescription = "GitHub", - modifier = Modifier.size(24.dp) - ) - } - } - } - - FlowRow( - modifier = Modifier.padding(start = 16.dp, end = 16.dp, bottom = 16.dp), - horizontalArrangement = Arrangement.spacedBy(8.dp) - ) { - TopButton(buttonColors) - BottomButton(buttonColors) - } - } -} \ No newline at end of file diff --git a/app/src/main/java/org/nsh07/pomodoro/ui/settingsScreen/components/LicenseBottomSheet.kt b/app/src/main/java/org/nsh07/pomodoro/ui/settingsScreen/components/LicenseBottomSheet.kt new file mode 100644 index 0000000..48e4a03 --- /dev/null +++ b/app/src/main/java/org/nsh07/pomodoro/ui/settingsScreen/components/LicenseBottomSheet.kt @@ -0,0 +1,531 @@ +/* + * Copyright (c) 2025 Nishant Mishra + * + * This file is part of Tomato - a minimalist pomodoro timer for Android. + * + * Tomato is free software: you can redistribute it and/or modify it under the terms of the GNU + * General Public License as published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * Tomato is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even + * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General + * Public License for more details. + * + * You should have received a copy of the GNU General Public License along with Tomato. + * If not, see . + */ + +package org.nsh07.pomodoro.ui.settingsScreen.components + +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.lazy.LazyColumn +import androidx.compose.foundation.lazy.items +import androidx.compose.material3.ExperimentalMaterial3Api +import androidx.compose.material3.ExperimentalMaterial3ExpressiveApi +import androidx.compose.material3.MaterialTheme.colorScheme +import androidx.compose.material3.MaterialTheme.typography +import androidx.compose.material3.ModalBottomSheet +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.runtime.remember +import androidx.compose.ui.Modifier +import androidx.compose.ui.text.LinkAnnotation +import androidx.compose.ui.text.ParagraphStyle +import androidx.compose.ui.text.SpanStyle +import androidx.compose.ui.text.buildAnnotatedString +import androidx.compose.ui.text.font.FontFamily +import androidx.compose.ui.text.style.TextAlign +import androidx.compose.ui.text.withLink +import androidx.compose.ui.text.withStyle +import androidx.compose.ui.unit.dp +import org.nsh07.pomodoro.ui.theme.AppFonts.googleFlex400 +import org.nsh07.pomodoro.ui.theme.AppFonts.googleFlex600 + +@OptIn(ExperimentalMaterial3Api::class, ExperimentalMaterial3ExpressiveApi::class) +@Composable +fun LicenseBottomSheet( + setShowSheet: (Boolean) -> Unit, + modifier: Modifier = Modifier +) { + val colorScheme = colorScheme + val typography = typography + + val paragraphs = remember { + listOf( + buildAnnotatedString { + append("Copyright © 2007 Free Software Foundation, Inc. <") + withLink(LinkAnnotation.Url("https://fsf.org/")) { + append("https://fsf.org/") + } + append( + ">\n\n" + + "Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed." + ) + }, + buildAnnotatedString { + withStyle( + SpanStyle( + fontSize = typography.titleLarge.fontSize, + fontFamily = googleFlex600 + ) + ) { + append("Preamble") + } + }, + buildAnnotatedString { + append( + "The GNU General Public License is a free, copyleft license for software and other kinds of works.\n" + + "\n" + + "The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too.\n" + + "\n" + + "When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things.\n" + + "\n" + + "To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others.\n" + + "\n" + + "For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights.\n" + + "\n" + + "Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it.\n" + + "\n" + + "For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions.\n" + + "\n" + + "Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users.\n" + + "\n" + + "Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free.\n" + + "\n" + + "The precise terms and conditions for copying, distribution and modification follow." + ) + }, + buildAnnotatedString { + withStyle( + SpanStyle( + fontSize = typography.titleLarge.fontSize, + fontFamily = googleFlex600 + ) + ) { + append("TERMS AND CONDITIONS") + } + }, + buildAnnotatedString { + withStyle( + SpanStyle( + fontSize = typography.titleMedium.fontSize, + fontFamily = googleFlex600 + ) + ) { + append("0. Definitions.\n\n") + } + append( + "“This License” refers to version 3 of the GNU General Public License.\n" + + "\n" + + "“Copyright” also means copyright-like laws that apply to other kinds of works, such as semiconductor masks.\n" + + "\n" + + "“The Program” refers to any copyrightable work licensed under this License. Each licensee is addressed as “you”. “Licensees” and “recipients” may be individuals or organizations.\n" + + "\n" + + "To “modify” a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a “modified version” of the earlier work or a work “based on” the earlier work.\n" + + "\n" + + "A “covered work” means either the unmodified Program or a work based on the Program.\n" + + "\n" + + "To “propagate” a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well.\n" + + "\n" + + "To “convey” a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying.\n" + + "\n" + + "An interactive user interface displays “Appropriate Legal Notices” to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion.\n" + + "\n" + ) + withStyle( + SpanStyle( + fontSize = typography.titleMedium.fontSize, + fontFamily = googleFlex600 + ) + ) { + append("1. Source Code.\n\n") + } + append( + "The “source code” for a work means the preferred form of the work for making modifications to it. “Object code” means any non-source form of a work.\n" + + "\n" + + "A “Standard Interface” means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language.\n" + + "\n" + + "The “System Libraries” of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A “Major Component”, in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it.\n" + + "\n" + + "The “Corresponding Source” for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work.\n" + + "\n" + + "The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source.\n" + + "\n" + + "The Corresponding Source for a work in source code form is that same work.\n" + + "\n" + ) + withStyle( + SpanStyle( + fontSize = typography.titleMedium.fontSize, + fontFamily = googleFlex600 + ) + ) { + append("2. Basic Permissions.\n\n") + } + append( + "All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law.\n" + + "\n" + + "You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you.\n" + + "\n" + + "Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary.\n" + + "\n" + ) + withStyle( + SpanStyle( + fontSize = typography.titleMedium.fontSize, + fontFamily = googleFlex600 + ) + ) { + append("3. Protecting Users' Legal Rights From Anti-Circumvention Law.\n\n") + } + append( + "No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures.\n" + + "\n" + + "When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures.\n" + + "\n" + ) + withStyle( + SpanStyle( + fontSize = typography.titleMedium.fontSize, + fontFamily = googleFlex600 + ) + ) { + append("4. Conveying Verbatim Copies.\n\n") + } + append( + "You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program.\n" + + "\n" + + "You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee.\n" + + "\n" + ) + withStyle( + SpanStyle( + fontSize = typography.titleMedium.fontSize, + fontFamily = googleFlex600 + ) + ) { + append("5. Conveying Modified Source Versions.\n\n") + } + append( + "You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions:\n" + + "\n" + + "a) The work must carry prominent notices stating that you modified it, and giving a relevant date.\n" + + "b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to “keep intact all notices”.\n" + + "c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it.\n" + + "d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so.\n" + + "A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an “aggregate” if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate.\n" + + "\n" + ) + withStyle( + SpanStyle( + fontSize = typography.titleMedium.fontSize, + fontFamily = googleFlex600 + ) + ) { + append("6. Conveying Non-Source Forms.\n\n") + } + append( + "You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways:\n" + + "\n" + + "a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange.\n" + + "b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge.\n" + + "c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b.\n" + + "d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements.\n" + + "e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d.\n" + + "A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work.\n" + + "\n" + + "A “User Product” is either (1) a “consumer product”, which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, “normally used” refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product.\n" + + "\n" + + "“Installation Information” for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made.\n" + + "\n" + + "If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM).\n" + + "\n" + + "The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network.\n" + + "\n" + + "Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying.\n" + + "\n" + ) + withStyle( + SpanStyle( + fontSize = typography.titleMedium.fontSize, + fontFamily = googleFlex600 + ) + ) { + append("7. Additional Terms.\n\n") + } + append( + "“Additional permissions” are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions.\n" + + "\n" + + "When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission.\n" + + "\n" + + "Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms:\n" + + "\n" + + "a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or\n" + + "b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or\n" + + "c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or\n" + + "d) Limiting the use for publicity purposes of names of licensors or authors of the material; or\n" + + "e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or\n" + + "f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors.\n" + + "All other non-permissive additional terms are considered “further restrictions” within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying.\n" + + "\n" + + "If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms.\n" + + "\n" + + "Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way.\n" + + "\n" + ) + withStyle( + SpanStyle( + fontSize = typography.titleMedium.fontSize, + fontFamily = googleFlex600 + ) + ) { + append("8. Termination.\n\n") + } + append( + "You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11).\n" + + "\n" + + "However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation.\n" + + "\n" + + "Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice.\n" + + "\n" + + "Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10.\n" + + "\n" + ) + withStyle( + SpanStyle( + fontSize = typography.titleMedium.fontSize, + fontFamily = googleFlex600 + ) + ) { + append("9. Acceptance Not Required for Having Copies.\n\n") + } + append( + "You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so.\n" + + "\n" + ) + withStyle( + SpanStyle( + fontSize = typography.titleMedium.fontSize, + fontFamily = googleFlex600 + ) + ) { + append("10. Automatic Licensing of Downstream Recipients.\n\n") + } + append( + "Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License.\n" + + "\n" + + "An “entity transaction” is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts.\n" + + "\n" + + "You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it.\n" + + "\n" + ) + withStyle( + SpanStyle( + fontSize = typography.titleMedium.fontSize, + fontFamily = googleFlex600 + ) + ) { + append("11. Patents.\n\n") + } + append( + "A “contributor” is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's “contributor version”.\n" + + "\n" + + "A contributor's “essential patent claims” are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, “control” includes the right to grant patent sublicenses in a manner consistent with the requirements of this License.\n" + + "\n" + + "Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version.\n" + + "\n" + + "In the following three paragraphs, a “patent license” is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To “grant” such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party.\n" + + "\n" + + "If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. “Knowingly relying” means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid.\n" + + "\n" + + "If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it.\n" + + "\n" + + "A patent license is “discriminatory” if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007.\n" + + "\n" + + "Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law.\n" + + "\n" + ) + withStyle( + SpanStyle( + fontSize = typography.titleMedium.fontSize, + fontFamily = googleFlex600 + ) + ) { + append("12. No Surrender of Others' Freedom.\n\n") + } + append( + "If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program.\n" + + "\n" + ) + withStyle( + SpanStyle( + fontSize = typography.titleMedium.fontSize, + fontFamily = googleFlex600 + ) + ) { + append("13. Use with the GNU Affero General Public License.\n\n") + } + append( + "Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such.\n" + + "\n" + ) + withStyle( + SpanStyle( + fontSize = typography.titleMedium.fontSize, + fontFamily = googleFlex600 + ) + ) { + append("14. Revised Versions of this License.\n\n") + } + append( + "The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.\n" + + "\n" + + "Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License “or any later version” applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation.\n" + + "\n" + + "If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program.\n" + + "\n" + + "Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version.\n" + + "\n" + ) + withStyle( + SpanStyle( + fontSize = typography.titleMedium.fontSize, + fontFamily = googleFlex600 + ) + ) { + append("15. Disclaimer of Warranty.\n\n") + } + append( + "THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.\n" + + "\n" + ) + withStyle( + SpanStyle( + fontSize = typography.titleMedium.fontSize, + fontFamily = googleFlex600 + ) + ) { + append("16. Limitation of Liability.\n\n") + } + append( + "IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.\n" + + "\n" + ) + withStyle( + SpanStyle( + fontSize = typography.titleMedium.fontSize, + fontFamily = googleFlex600 + ) + ) { + append("17. Interpretation of Sections 15 and 16.\n\n") + } + append( + "If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee.\n" + + "\n" + ) + withStyle( + SpanStyle( + fontSize = typography.titleMedium.fontSize, + fontFamily = googleFlex600 + ) + ) { + append("END OF TERMS AND CONDITIONS") + } + }, + buildAnnotatedString { + withStyle(style = ParagraphStyle(lineHeight = typography.titleLarge.lineHeight)) { + withStyle( + SpanStyle( + fontSize = typography.titleLarge.fontSize, + fontFamily = googleFlex600 + ) + ) { + append("How to Apply These Terms to Your New Programs") + } + } + }, + buildAnnotatedString { + append( + "If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms.\n" + + "\n" + + "To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the “copyright” line and a pointer to where the full notice is found.\n" + + "\n" + ) + withStyle(SpanStyle(fontFamily = FontFamily.Monospace)) { + append( + "\nCopyright (C) \n" + + "\nThis program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.\n" + + "\nThis program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.\n" + + "\nYou should have received a copy of the GNU General Public License along with this program. If not, see .\n" + ) + } + append( + "\nAlso add information on how to contact you by electronic and paper mail.\n" + + "\n" + + "If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode:\n" + + "\n" + ) + withStyle(SpanStyle(fontFamily = FontFamily.Monospace)) { + append( + " Copyright (C) \n" + + "This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details.\n" + ) + } + append( + "\nThe hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an “about box”.\n" + + "\n" + + "You should also get your employer (if you work as a programmer) or school, if any, to sign a “copyright disclaimer” for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see <" + ) + withLink(LinkAnnotation.Url("https://www.gnu.org/licenses/")) { + append("https://www.gnu.org/licenses/") + } + append( + ">.\n" + + "\n" + + "The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read <" + ) + withLink(LinkAnnotation.Url("https://www.gnu.org/licenses/why-not-lgpl.html")) { + append("https://www.gnu.org/licenses/why-not-lgpl.html") + } + append( + ">." + ) + } + ) + } + ModalBottomSheet( + onDismissRequest = { setShowSheet(false) }, + modifier = modifier + ) { + LazyColumn(Modifier.padding(horizontal = 16.dp)) { + item { + Text( + "GNU GENERAL PUBLIC LICENSE", + style = typography.headlineSmall, + textAlign = TextAlign.Center, + modifier = Modifier + .padding(top = 16.dp, bottom = 4.dp) + .fillMaxWidth() + ) + Text( + "Version 3, 29 June 2007", + style = typography.titleSmall, + fontFamily = googleFlex400, + color = colorScheme.onSurfaceVariant, + textAlign = TextAlign.Center, + modifier = Modifier + .fillMaxWidth() + .padding(bottom = 16.dp) + ) + } + items(paragraphs) { + Text( + it, + style = typography.bodyMedium, + modifier = Modifier.padding(vertical = 12.dp) + ) + } + } + } +} \ No newline at end of file diff --git a/app/src/main/java/org/nsh07/pomodoro/ui/settingsScreen/components/LocaleBottomSheet.kt b/app/src/main/java/org/nsh07/pomodoro/ui/settingsScreen/components/LocaleBottomSheet.kt index 2872fcf..0bc1d25 100644 --- a/app/src/main/java/org/nsh07/pomodoro/ui/settingsScreen/components/LocaleBottomSheet.kt +++ b/app/src/main/java/org/nsh07/pomodoro/ui/settingsScreen/components/LocaleBottomSheet.kt @@ -125,9 +125,10 @@ fun LocaleBottomSheet( colors = if (currentLocales.isEmpty) ListItemDefaults.colors( - containerColor = colorScheme.primaryContainer.copy( - 0.3f - ) + containerColor = colorScheme.secondaryContainer, + headlineColor = colorScheme.onSecondaryContainer, + leadingIconColor = colorScheme.onSecondaryContainer, + trailingIconColor = colorScheme.onSecondaryContainer ) else listItemColors, modifier = Modifier @@ -169,7 +170,12 @@ fun LocaleBottomSheet( }, colors = if (!currentLocales.isEmpty && it.locale == currentLocales.get(0)) - ListItemDefaults.colors(containerColor = colorScheme.primaryContainer) + ListItemDefaults.colors( + containerColor = colorScheme.secondaryContainer, + headlineColor = colorScheme.onSecondaryContainer, + leadingIconColor = colorScheme.onSecondaryContainer, + trailingIconColor = colorScheme.onSecondaryContainer + ) else listItemColors, modifier = Modifier .clip( diff --git a/app/src/main/java/org/nsh07/pomodoro/ui/settingsScreen/components/MinuteInputField.kt b/app/src/main/java/org/nsh07/pomodoro/ui/settingsScreen/components/MinuteInputField.kt index f530eea..b6c0709 100644 --- a/app/src/main/java/org/nsh07/pomodoro/ui/settingsScreen/components/MinuteInputField.kt +++ b/app/src/main/java/org/nsh07/pomodoro/ui/settingsScreen/components/MinuteInputField.kt @@ -39,7 +39,7 @@ import androidx.compose.ui.text.input.KeyboardType import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp -import org.nsh07.pomodoro.ui.theme.AppFonts.interClock +import org.nsh07.pomodoro.ui.theme.AppFonts.googleFlex600 import org.nsh07.pomodoro.ui.theme.CustomColors.listItemColors @OptIn(ExperimentalMaterial3ExpressiveApi::class) @@ -62,7 +62,7 @@ fun MinuteInputField( imeAction = imeAction ), textStyle = TextStyle( - fontFamily = interClock, + fontFamily = googleFlex600, fontSize = 57.sp, letterSpacing = (-2).sp, color = if (enabled) colorScheme.onSurfaceVariant else colorScheme.outlineVariant, diff --git a/app/src/main/java/org/nsh07/pomodoro/ui/settingsScreen/components/PlusDivider.kt b/app/src/main/java/org/nsh07/pomodoro/ui/settingsScreen/components/PlusDivider.kt index 13cb270..6ba3c2c 100644 --- a/app/src/main/java/org/nsh07/pomodoro/ui/settingsScreen/components/PlusDivider.kt +++ b/app/src/main/java/org/nsh07/pomodoro/ui/settingsScreen/components/PlusDivider.kt @@ -32,7 +32,9 @@ import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip +import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.dp +import org.nsh07.pomodoro.R @OptIn(ExperimentalMaterial3ExpressiveApi::class) @Composable @@ -49,7 +51,7 @@ fun PlusDivider( .background(colorScheme.surfaceContainer) .padding(horizontal = 8.dp) ) { - Text("Customize further with Tomato+", style = typography.titleSmall) + Text(stringResource(R.string.tomato_plus_desc), style = typography.titleSmall) } } } \ No newline at end of file diff --git a/app/src/main/java/org/nsh07/pomodoro/ui/settingsScreen/components/PlusPromo.kt b/app/src/main/java/org/nsh07/pomodoro/ui/settingsScreen/components/PlusPromo.kt index 6566e8b..f6e0b3f 100644 --- a/app/src/main/java/org/nsh07/pomodoro/ui/settingsScreen/components/PlusPromo.kt +++ b/app/src/main/java/org/nsh07/pomodoro/ui/settingsScreen/components/PlusPromo.kt @@ -17,27 +17,18 @@ package org.nsh07.pomodoro.ui.settingsScreen.components -import androidx.compose.foundation.background -import androidx.compose.foundation.clickable -import androidx.compose.foundation.layout.Row -import androidx.compose.foundation.layout.Spacer -import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size -import androidx.compose.foundation.layout.width -import androidx.compose.foundation.shape.CircleShape import androidx.compose.material3.Icon +import androidx.compose.material3.ListItemDefaults import androidx.compose.material3.MaterialTheme.colorScheme -import androidx.compose.material3.MaterialTheme.typography import androidx.compose.material3.Text import androidx.compose.runtime.Composable -import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier -import androidx.compose.ui.draw.clip import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.dp import org.nsh07.pomodoro.R -import org.nsh07.pomodoro.ui.theme.AppFonts.robotoFlexTopBar +import org.nsh07.pomodoro.ui.theme.CustomColors.listItemColors @Composable fun PlusPromo( @@ -45,38 +36,38 @@ fun PlusPromo( setShowPaywall: (Boolean) -> Unit, modifier: Modifier = Modifier ) { - val container = if (isPlus) colorScheme.surfaceBright else colorScheme.primary - val onContainer = if (isPlus) colorScheme.onSurface else colorScheme.onPrimary - val onContainerVariant = if (isPlus) colorScheme.onSurfaceVariant else colorScheme.onPrimary - - Row( - verticalAlignment = Alignment.CenterVertically, + ClickableListItem( + leadingContent = { + Icon( + painterResource(R.drawable.tomato_logo_notification), + null, + modifier = Modifier.size(24.dp) + ) + }, + headlineContent = { + Text( + if (!isPlus) stringResource(R.string.get_plus) + else stringResource(R.string.app_name_plus) + ) + }, + supportingContent = { + if (!isPlus) Text(stringResource(R.string.tomato_plus_desc)) + }, + trailingContent = { + Icon( + painterResource(R.drawable.arrow_forward_big), + null + ) + }, + colors = if (isPlus) listItemColors else ListItemDefaults.colors( + containerColor = colorScheme.primary, + leadingIconColor = colorScheme.onPrimary, + trailingIconColor = colorScheme.onPrimary, + supportingColor = colorScheme.onPrimary, + headlineColor = colorScheme.onPrimary + ), + items = 2, + index = 0, modifier = modifier - .clip(CircleShape) - .clickable { setShowPaywall(true) } - .background(container) - .padding(16.dp) - ) { - Icon( - painterResource(R.drawable.tomato_logo_notification), - null, - tint = onContainerVariant, - modifier = Modifier - .size(24.dp) - ) - Spacer(Modifier.width(8.dp)) - Text( - if (!isPlus) stringResource(R.string.get_plus) - else stringResource(R.string.app_name_plus), - style = typography.titleLarge, - fontFamily = robotoFlexTopBar, - color = onContainer - ) - Spacer(Modifier.weight(1f)) - Icon( - painterResource(R.drawable.arrow_forward_big), - null, - tint = onContainerVariant - ) - } + ) { setShowPaywall(true) } } \ No newline at end of file diff --git a/app/src/main/java/org/nsh07/pomodoro/ui/settingsScreen/components/ThemePickerListItem.kt b/app/src/main/java/org/nsh07/pomodoro/ui/settingsScreen/components/ThemePickerListItem.kt index 411de79..df5ae3b 100644 --- a/app/src/main/java/org/nsh07/pomodoro/ui/settingsScreen/components/ThemePickerListItem.kt +++ b/app/src/main/java/org/nsh07/pomodoro/ui/settingsScreen/components/ThemePickerListItem.kt @@ -40,6 +40,7 @@ import androidx.compose.ui.semantics.role import androidx.compose.ui.semantics.semantics import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.unit.dp +import androidx.compose.ui.util.fastForEachIndexed import org.nsh07.pomodoro.R import org.nsh07.pomodoro.ui.theme.CustomColors.listItemColors import org.nsh07.pomodoro.ui.theme.TomatoShapeDefaults.bottomListItemShape @@ -101,7 +102,7 @@ fun ThemePickerListItem( .background(listItemColors.containerColor) .padding(start = 52.dp, end = 16.dp, bottom = 8.dp) ) { - options.forEachIndexed { index, theme -> + options.fastForEachIndexed { index, theme -> val isSelected = selectedIndex == index ToggleButton( checked = isSelected, diff --git a/app/src/main/java/org/nsh07/pomodoro/ui/settingsScreen/screens/AboutScreen.kt b/app/src/main/java/org/nsh07/pomodoro/ui/settingsScreen/screens/AboutScreen.kt new file mode 100644 index 0000000..ea9fdc3 --- /dev/null +++ b/app/src/main/java/org/nsh07/pomodoro/ui/settingsScreen/screens/AboutScreen.kt @@ -0,0 +1,291 @@ +/* + * Copyright (c) 2025 Nishant Mishra + * + * This file is part of Tomato - a minimalist pomodoro timer for Android. + * + * Tomato is free software: you can redistribute it and/or modify it under the terms of the GNU + * General Public License as published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * Tomato is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even + * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General + * Public License for more details. + * + * You should have received a copy of the GNU General Public License along with Tomato. + * If not, see . + */ + +package org.nsh07.pomodoro.ui.settingsScreen.screens + +import androidx.annotation.DrawableRes +import androidx.compose.foundation.background +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.FlowRow +import androidx.compose.foundation.layout.PaddingValues +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.size +import androidx.compose.foundation.layout.width +import androidx.compose.foundation.lazy.LazyColumn +import androidx.compose.material3.ButtonDefaults +import androidx.compose.material3.ExperimentalMaterial3Api +import androidx.compose.material3.ExperimentalMaterial3ExpressiveApi +import androidx.compose.material3.FilledTonalIconButton +import androidx.compose.material3.Icon +import androidx.compose.material3.IconButtonDefaults +import androidx.compose.material3.LargeFlexibleTopAppBar +import androidx.compose.material3.MaterialShapes +import androidx.compose.material3.MaterialTheme.colorScheme +import androidx.compose.material3.MaterialTheme.typography +import androidx.compose.material3.Scaffold +import androidx.compose.material3.Text +import androidx.compose.material3.TopAppBarDefaults +import androidx.compose.material3.toShape +import androidx.compose.runtime.Composable +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.saveable.rememberSaveable +import androidx.compose.runtime.setValue +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.input.nestedscroll.nestedScroll +import androidx.compose.ui.platform.LocalUriHandler +import androidx.compose.ui.res.painterResource +import androidx.compose.ui.res.stringResource +import androidx.compose.ui.tooling.preview.Preview +import androidx.compose.ui.unit.dp +import androidx.compose.ui.util.fastForEach +import org.nsh07.pomodoro.BuildConfig +import org.nsh07.pomodoro.R +import org.nsh07.pomodoro.ui.mergePaddingValues +import org.nsh07.pomodoro.ui.settingsScreen.components.BottomButton +import org.nsh07.pomodoro.ui.settingsScreen.components.ClickableListItem +import org.nsh07.pomodoro.ui.settingsScreen.components.LicenseBottomSheet +import org.nsh07.pomodoro.ui.settingsScreen.components.TopButton +import org.nsh07.pomodoro.ui.theme.AppFonts.googleFlex600 +import org.nsh07.pomodoro.ui.theme.AppFonts.robotoFlexTopBar +import org.nsh07.pomodoro.ui.theme.CustomColors.listItemColors +import org.nsh07.pomodoro.ui.theme.CustomColors.topBarColors +import org.nsh07.pomodoro.ui.theme.TomatoShapeDefaults.bottomListItemShape +import org.nsh07.pomodoro.ui.theme.TomatoShapeDefaults.topListItemShape +import org.nsh07.pomodoro.ui.theme.TomatoTheme + +@OptIn(ExperimentalMaterial3Api::class, ExperimentalMaterial3ExpressiveApi::class) +@Composable +fun AboutScreen( + contentPadding: PaddingValues, + isPlus: Boolean, + onBack: () -> Unit, + modifier: Modifier = Modifier +) { + val scrollBehavior = TopAppBarDefaults.enterAlwaysScrollBehavior() + val uriHandler = LocalUriHandler.current + + val socialLinks = remember { + listOf( + SocialLink(R.drawable.github, "https://github.com/nsh07"), + SocialLink(R.drawable.x, "https://x.com/nsh_zero7"), + SocialLink(R.drawable.globe, "https://nsh07.github.io"), + SocialLink(R.drawable.email, "mailto:nishant.28@outlook.com") + ) + } + + var showLicense by rememberSaveable { mutableStateOf(false) } + + Scaffold( + topBar = { + LargeFlexibleTopAppBar( + title = { + Text(stringResource(R.string.about), fontFamily = robotoFlexTopBar) + }, + subtitle = { + Text(stringResource(R.string.app_name)) + }, + navigationIcon = { + FilledTonalIconButton( + onClick = onBack, + shapes = IconButtonDefaults.shapes(), + colors = IconButtonDefaults.filledTonalIconButtonColors(containerColor = listItemColors.containerColor) + ) { + Icon( + painterResource(R.drawable.arrow_back), + null + ) + } + }, + colors = topBarColors, + scrollBehavior = scrollBehavior + ) + }, + modifier = modifier.nestedScroll(scrollBehavior.nestedScrollConnection) + ) { innerPadding -> + val insets = mergePaddingValues(innerPadding, contentPadding) + LazyColumn( + verticalArrangement = Arrangement.spacedBy(2.dp), + contentPadding = insets, + modifier = Modifier + .background(topBarColors.containerColor) + .fillMaxSize() + .padding(horizontal = 16.dp) + ) { + item { + Box(Modifier.background(listItemColors.containerColor, topListItemShape)) { + Row( + verticalAlignment = Alignment.CenterVertically, + modifier = Modifier.padding(16.dp) + ) { + Icon( + painterResource(R.drawable.ic_launcher_monochrome), + tint = colorScheme.onPrimaryContainer, + contentDescription = null, + modifier = Modifier + .size(64.dp) + .background( + colorScheme.primaryContainer, + MaterialShapes.Cookie12Sided.toShape() + ) + ) + Spacer(Modifier.width(16.dp)) + Column { + Text( + if (!isPlus) stringResource(R.string.app_name) + else stringResource(R.string.app_name_plus), + color = colorScheme.onSurface, + style = typography.titleLarge, + fontFamily = googleFlex600 + ) + Text( + text = "${BuildConfig.VERSION_NAME} (${BuildConfig.VERSION_CODE})", + style = typography.labelLarge, + color = colorScheme.primary + ) + } + Spacer(Modifier.weight(1f)) + Row(horizontalArrangement = Arrangement.spacedBy(2.dp)) { + FilledTonalIconButton( + onClick = { + uriHandler.openUri("http://discord.com/users/658886962048008192") + }, + shapes = IconButtonDefaults.shapes() + ) { + Icon( + painterResource(R.drawable.discord), + contentDescription = "Discord", + modifier = Modifier.size(24.dp) + ) + } + + FilledTonalIconButton( + onClick = { uriHandler.openUri("https://github.com/nsh07/Tomato") }, + shapes = IconButtonDefaults.shapes() + ) { + Icon( + painterResource(R.drawable.github), + contentDescription = "GitHub", + modifier = Modifier.size(24.dp) + ) + } + } + } + } + } + item { + Box(Modifier.background(listItemColors.containerColor, bottomListItemShape)) { + Column(modifier = Modifier.padding(16.dp)) { + Row(verticalAlignment = Alignment.CenterVertically) { + Icon( + painterResource(R.drawable.pfp), + tint = colorScheme.onSecondaryContainer, + contentDescription = null, + modifier = Modifier + .size(64.dp) + .background( + colorScheme.secondaryContainer, + MaterialShapes.Square.toShape() + ) + .padding(8.dp) + ) + Spacer(Modifier.width(16.dp)) + Column { + Text( + "Nishant Mishra", + style = typography.titleLarge, + color = colorScheme.onSurface, + fontFamily = googleFlex600 + ) + Text( + "Developer", + style = typography.labelLarge, + color = colorScheme.secondary + ) + } + Spacer(Modifier.weight(1f)) + } + Spacer(Modifier.height(8.dp)) + Row { + Spacer(Modifier.width((64 + 16).dp)) + FlowRow(horizontalArrangement = Arrangement.spacedBy(8.dp)) { + socialLinks.fastForEach { + FilledTonalIconButton( + onClick = { uriHandler.openUri(it.url) }, + shapes = IconButtonDefaults.shapes(), + modifier = Modifier.width(52.dp) + ) { + Icon( + painterResource(it.icon), + null, + modifier = Modifier.size(ButtonDefaults.SmallIconSize) + ) + } + } + } + } + } + } + } + item { Spacer(Modifier.height(12.dp)) } + + item { TopButton() } + item { BottomButton() } + + item { Spacer(Modifier.height(12.dp)) } + + item { + ClickableListItem( + leadingContent = { Icon(painterResource(R.drawable.gavel), null) }, + headlineContent = { Text(stringResource(R.string.license)) }, + supportingContent = { Text("GNU General Public License Version 3") }, + items = 1, + index = 0 + ) { showLicense = true } + } + } + } + + if (showLicense) { + LicenseBottomSheet({ showLicense = false }) + } +} + +@Preview +@Composable +private fun AboutScreenPreview() { + TomatoTheme(dynamicColor = false) { + AboutScreen( + contentPadding = PaddingValues(), + isPlus = true, + onBack = {} + ) + } +} + +data class SocialLink( + @param:DrawableRes val icon: Int, + val url: String +) diff --git a/app/src/main/java/org/nsh07/pomodoro/ui/settingsScreen/screens/AlarmSettings.kt b/app/src/main/java/org/nsh07/pomodoro/ui/settingsScreen/screens/AlarmSettings.kt index 377ac62..fdd7ea4 100644 --- a/app/src/main/java/org/nsh07/pomodoro/ui/settingsScreen/screens/AlarmSettings.kt +++ b/app/src/main/java/org/nsh07/pomodoro/ui/settingsScreen/screens/AlarmSettings.kt @@ -25,10 +25,11 @@ import android.net.Uri import android.os.Build import androidx.activity.compose.rememberLauncherForActivityResult import androidx.activity.result.contract.ActivityResultContracts +import androidx.compose.animation.animateContentSize import androidx.compose.foundation.background import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.Arrangement -import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.height @@ -43,6 +44,8 @@ import androidx.compose.material3.Icon import androidx.compose.material3.IconButtonDefaults import androidx.compose.material3.LargeFlexibleTopAppBar import androidx.compose.material3.ListItem +import androidx.compose.material3.MaterialTheme.motionScheme +import androidx.compose.material3.Scaffold import androidx.compose.material3.Switch import androidx.compose.material3.SwitchDefaults import androidx.compose.material3.Text @@ -59,12 +62,14 @@ import androidx.compose.ui.input.nestedscroll.nestedScroll import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource +import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp -import androidx.core.net.toUri +import androidx.compose.ui.util.fastForEach import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.withContext import org.nsh07.pomodoro.R +import org.nsh07.pomodoro.ui.mergePaddingValues import org.nsh07.pomodoro.ui.settingsScreen.SettingsSwitchItem import org.nsh07.pomodoro.ui.settingsScreen.viewModel.SettingsAction import org.nsh07.pomodoro.ui.settingsScreen.viewModel.SettingsState @@ -73,6 +78,7 @@ import org.nsh07.pomodoro.ui.theme.CustomColors.listItemColors import org.nsh07.pomodoro.ui.theme.CustomColors.switchColors import org.nsh07.pomodoro.ui.theme.CustomColors.topBarColors import org.nsh07.pomodoro.ui.theme.TomatoShapeDefaults.bottomListItemShape +import org.nsh07.pomodoro.ui.theme.TomatoShapeDefaults.cardShape import org.nsh07.pomodoro.ui.theme.TomatoShapeDefaults.middleListItemShape import org.nsh07.pomodoro.ui.theme.TomatoShapeDefaults.topListItemShape @@ -80,6 +86,7 @@ import org.nsh07.pomodoro.ui.theme.TomatoShapeDefaults.topListItemShape @Composable fun AlarmSettings( settingsState: SettingsState, + contentPadding: PaddingValues, onAction: (SettingsAction) -> Unit, onBack: () -> Unit, modifier: Modifier = Modifier @@ -89,10 +96,10 @@ fun AlarmSettings( var alarmName by remember { mutableStateOf("...") } - LaunchedEffect(settingsState.alarmSound) { + LaunchedEffect(settingsState.alarmSoundUri) { withContext(Dispatchers.IO) { alarmName = - RingtoneManager.getRingtone(context, settingsState.alarmSound.toUri()) + RingtoneManager.getRingtone(context, settingsState.alarmSoundUri) ?.getTitle(context) ?: "" } } @@ -116,64 +123,80 @@ fun AlarmSettings( } @SuppressLint("LocalContextGetResourceValueCall") - val ringtonePickerIntent = remember(settingsState.alarmSound) { + val ringtonePickerIntent = remember(settingsState.alarmSoundUri) { Intent(RingtoneManager.ACTION_RINGTONE_PICKER).apply { putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE, RingtoneManager.TYPE_ALARM) putExtra(RingtoneManager.EXTRA_RINGTONE_TITLE, context.getString(R.string.alarm_sound)) - putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, settingsState.alarmSound.toUri()) + putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, settingsState.alarmSoundUri) } } val switchItems = remember( - settingsState.blackTheme, - settingsState.aodEnabled, settingsState.alarmEnabled, - settingsState.vibrateEnabled + settingsState.vibrateEnabled, + settingsState.mediaVolumeForAlarm ) { listOf( - SettingsSwitchItem( - checked = settingsState.alarmEnabled, - icon = R.drawable.alarm_on, - label = R.string.sound, - description = R.string.alarm_desc, - onClick = { onAction(SettingsAction.SaveAlarmEnabled(it)) } + listOf( + SettingsSwitchItem( + checked = settingsState.alarmEnabled, + icon = R.drawable.alarm_on, + label = R.string.sound, + description = R.string.alarm_desc, + onClick = { onAction(SettingsAction.SaveAlarmEnabled(it)) } + ), + SettingsSwitchItem( + checked = settingsState.vibrateEnabled, + icon = R.drawable.mobile_vibrate, + label = R.string.vibrate, + description = R.string.vibrate_desc, + onClick = { onAction(SettingsAction.SaveVibrateEnabled(it)) } + ) ), - SettingsSwitchItem( - checked = settingsState.vibrateEnabled, - icon = R.drawable.mobile_vibrate, - label = R.string.vibrate, - description = R.string.vibrate_desc, - onClick = { onAction(SettingsAction.SaveVibrateEnabled(it)) } + listOf( + SettingsSwitchItem( + checked = settingsState.mediaVolumeForAlarm, + collapsible = true, + icon = R.drawable.music_note, + label = R.string.media_volume_for_alarm, + description = R.string.media_volume_for_alarm_desc, + onClick = { onAction(SettingsAction.SaveMediaVolumeForAlarm(it)) } + ) ) ) } - Column(modifier.nestedScroll(scrollBehavior.nestedScrollConnection)) { - LargeFlexibleTopAppBar( - title = { - Text(stringResource(R.string.alarm), fontFamily = robotoFlexTopBar) - }, - subtitle = { - Text(stringResource(R.string.settings)) - }, - navigationIcon = { - FilledTonalIconButton( - onClick = onBack, - shapes = IconButtonDefaults.shapes(), - colors = IconButtonDefaults.filledTonalIconButtonColors(containerColor = listItemColors.containerColor) - ) { - Icon( - painterResource(R.drawable.arrow_back), - null - ) - } - }, - colors = topBarColors, - scrollBehavior = scrollBehavior - ) - + Scaffold( + topBar = { + LargeFlexibleTopAppBar( + title = { + Text(stringResource(R.string.alarm), fontFamily = robotoFlexTopBar) + }, + subtitle = { + Text(stringResource(R.string.settings)) + }, + navigationIcon = { + FilledTonalIconButton( + onClick = onBack, + shapes = IconButtonDefaults.shapes(), + colors = IconButtonDefaults.filledTonalIconButtonColors(containerColor = listItemColors.containerColor) + ) { + Icon( + painterResource(R.drawable.arrow_back), + null + ) + } + }, + colors = topBarColors, + scrollBehavior = scrollBehavior + ) + }, + modifier = modifier.nestedScroll(scrollBehavior.nestedScrollConnection) + ) { innerPadding -> + val insets = mergePaddingValues(innerPadding, contentPadding) LazyColumn( verticalArrangement = Arrangement.spacedBy(2.dp), + contentPadding = insets, modifier = Modifier .background(topBarColors.containerColor) .fillMaxSize() @@ -196,44 +219,65 @@ fun AlarmSettings( .clickable(onClick = { ringtonePickerLauncher.launch(ringtonePickerIntent) }) ) } - itemsIndexed(switchItems) { index, item -> - ListItem( - leadingContent = { - Icon(painterResource(item.icon), contentDescription = null) - }, - headlineContent = { Text(stringResource(item.label)) }, - supportingContent = { Text(stringResource(item.description)) }, - trailingContent = { - Switch( - checked = item.checked, - onCheckedChange = { item.onClick(it) }, - thumbContent = { - if (item.checked) { - Icon( - painter = painterResource(R.drawable.check), - contentDescription = null, - modifier = Modifier.size(SwitchDefaults.IconSize), - ) - } else { - Icon( - painter = painterResource(R.drawable.clear), - contentDescription = null, - modifier = Modifier.size(SwitchDefaults.IconSize), - ) - } - }, - colors = switchColors - ) - }, - colors = listItemColors, - modifier = Modifier - .clip( - when (index) { - switchItems.lastIndex -> bottomListItemShape - else -> middleListItemShape + switchItems.fastForEach { items -> + itemsIndexed(items) { index, item -> + ListItem( + leadingContent = { + Icon(painterResource(item.icon), contentDescription = null) + }, + headlineContent = { Text(stringResource(item.label)) }, + supportingContent = { + if (item.collapsible) { + var expanded by remember { mutableStateOf(false) } + Text( + stringResource(item.description), + maxLines = if (expanded) Int.MAX_VALUE else 2, + overflow = TextOverflow.Ellipsis, + modifier = Modifier + .clickable { expanded = !expanded } + .animateContentSize(motionScheme.defaultSpatialSpec()) + ) + } else { + Text(stringResource(item.description)) } - ) - ) + }, + trailingContent = { + Switch( + checked = item.checked, + onCheckedChange = { item.onClick(it) }, + thumbContent = { + if (item.checked) { + Icon( + painter = painterResource(R.drawable.check), + contentDescription = null, + modifier = Modifier.size(SwitchDefaults.IconSize), + ) + } else { + Icon( + painter = painterResource(R.drawable.clear), + contentDescription = null, + modifier = Modifier.size(SwitchDefaults.IconSize), + ) + } + }, + colors = switchColors + ) + }, + colors = listItemColors, + modifier = Modifier + .clip( + when { + items.size == 1 -> cardShape + index == items.lastIndex -> bottomListItemShape + else -> middleListItemShape + } + ) + ) + } + + item { + Spacer(Modifier.height(12.dp)) + } } item { Spacer(Modifier.height(12.dp)) } @@ -248,6 +292,7 @@ fun AlarmSettingsPreview() { val settingsState = SettingsState() AlarmSettings( settingsState = settingsState, + contentPadding = PaddingValues(), onAction = {}, onBack = {} ) diff --git a/app/src/main/java/org/nsh07/pomodoro/ui/settingsScreen/screens/AppearanceSettings.kt b/app/src/main/java/org/nsh07/pomodoro/ui/settingsScreen/screens/AppearanceSettings.kt index f61fd18..32aaa87 100644 --- a/app/src/main/java/org/nsh07/pomodoro/ui/settingsScreen/screens/AppearanceSettings.kt +++ b/app/src/main/java/org/nsh07/pomodoro/ui/settingsScreen/screens/AppearanceSettings.kt @@ -19,7 +19,7 @@ package org.nsh07.pomodoro.ui.settingsScreen.screens import androidx.compose.foundation.background import androidx.compose.foundation.layout.Arrangement -import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.height @@ -33,6 +33,7 @@ import androidx.compose.material3.Icon import androidx.compose.material3.IconButtonDefaults import androidx.compose.material3.LargeFlexibleTopAppBar import androidx.compose.material3.ListItem +import androidx.compose.material3.Scaffold import androidx.compose.material3.Switch import androidx.compose.material3.SwitchDefaults import androidx.compose.material3.Text @@ -46,6 +47,7 @@ import androidx.compose.ui.res.stringResource import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import org.nsh07.pomodoro.R +import org.nsh07.pomodoro.ui.mergePaddingValues import org.nsh07.pomodoro.ui.settingsScreen.SettingsSwitchItem import org.nsh07.pomodoro.ui.settingsScreen.components.ColorSchemePickerListItem import org.nsh07.pomodoro.ui.settingsScreen.components.PlusDivider @@ -64,6 +66,7 @@ import org.nsh07.pomodoro.utils.toColor @Composable fun AppearanceSettings( settingsState: SettingsState, + contentPadding: PaddingValues, isPlus: Boolean, onAction: (SettingsAction) -> Unit, setShowPaywall: (Boolean) -> Unit, @@ -72,32 +75,37 @@ fun AppearanceSettings( ) { val scrollBehavior = TopAppBarDefaults.enterAlwaysScrollBehavior() - Column(modifier.nestedScroll(scrollBehavior.nestedScrollConnection)) { - LargeFlexibleTopAppBar( - title = { - Text(stringResource(R.string.appearance), fontFamily = robotoFlexTopBar) - }, - subtitle = { - Text(stringResource(R.string.settings)) - }, - navigationIcon = { - FilledTonalIconButton( - onClick = onBack, - shapes = IconButtonDefaults.shapes(), - colors = IconButtonDefaults.filledTonalIconButtonColors(containerColor = listItemColors.containerColor) - ) { - Icon( - painterResource(R.drawable.arrow_back), - null - ) - } - }, - colors = topBarColors, - scrollBehavior = scrollBehavior - ) - + Scaffold( + topBar = { + LargeFlexibleTopAppBar( + title = { + Text(stringResource(R.string.appearance), fontFamily = robotoFlexTopBar) + }, + subtitle = { + Text(stringResource(R.string.settings)) + }, + navigationIcon = { + FilledTonalIconButton( + onClick = onBack, + shapes = IconButtonDefaults.shapes(), + colors = IconButtonDefaults.filledTonalIconButtonColors(containerColor = listItemColors.containerColor) + ) { + Icon( + painterResource(R.drawable.arrow_back), + null + ) + } + }, + colors = topBarColors, + scrollBehavior = scrollBehavior + ) + }, + modifier = modifier.nestedScroll(scrollBehavior.nestedScrollConnection) + ) { innerPadding -> + val insets = mergePaddingValues(innerPadding, contentPadding) LazyColumn( verticalArrangement = Arrangement.spacedBy(2.dp), + contentPadding = insets, modifier = Modifier .background(topBarColors.containerColor) .fillMaxSize() @@ -182,6 +190,7 @@ fun AppearanceSettingsPreview() { TomatoTheme(dynamicColor = false) { AppearanceSettings( settingsState = settingsState, + contentPadding = PaddingValues(), isPlus = false, onAction = {}, setShowPaywall = {}, diff --git a/app/src/main/java/org/nsh07/pomodoro/ui/settingsScreen/screens/TimerSettings.kt b/app/src/main/java/org/nsh07/pomodoro/ui/settingsScreen/screens/TimerSettings.kt index d94b0f0..d68aba9 100644 --- a/app/src/main/java/org/nsh07/pomodoro/ui/settingsScreen/screens/TimerSettings.kt +++ b/app/src/main/java/org/nsh07/pomodoro/ui/settingsScreen/screens/TimerSettings.kt @@ -20,6 +20,7 @@ package org.nsh07.pomodoro.ui.settingsScreen.screens import android.app.NotificationManager import android.content.Context import android.content.Intent +import android.os.Build import android.provider.Settings import android.widget.Toast import androidx.compose.animation.AnimatedVisibility @@ -27,6 +28,7 @@ import androidx.compose.foundation.background import androidx.compose.foundation.horizontalScroll import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxSize @@ -53,6 +55,7 @@ import androidx.compose.material3.ListItem import androidx.compose.material3.LocalContentColor import androidx.compose.material3.MaterialTheme.colorScheme import androidx.compose.material3.MaterialTheme.typography +import androidx.compose.material3.Scaffold import androidx.compose.material3.Slider import androidx.compose.material3.SliderState import androidx.compose.material3.Switch @@ -77,6 +80,7 @@ import androidx.compose.ui.text.input.ImeAction import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import org.nsh07.pomodoro.R +import org.nsh07.pomodoro.ui.mergePaddingValues import org.nsh07.pomodoro.ui.settingsScreen.SettingsSwitchItem import org.nsh07.pomodoro.ui.settingsScreen.components.MinuteInputField import org.nsh07.pomodoro.ui.settingsScreen.components.PlusDivider @@ -98,6 +102,7 @@ fun TimerSettings( isPlus: Boolean, serviceRunning: Boolean, settingsState: SettingsState, + contentPadding: PaddingValues, focusTimeInputFieldState: TextFieldState, shortBreakTimeInputFieldState: TextFieldState, longBreakTimeInputFieldState: TextFieldState, @@ -113,60 +118,77 @@ fun TimerSettings( val notificationManagerService = remember { context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager } - val switchItems = listOf( - SettingsSwitchItem( - checked = settingsState.dndEnabled, - enabled = !serviceRunning, - icon = R.drawable.dnd, - label = R.string.dnd, - description = R.string.dnd_desc, - onClick = { - if (it && !notificationManagerService.isNotificationPolicyAccessGranted()) { - val intent = Intent(Settings.ACTION_NOTIFICATION_POLICY_ACCESS_SETTINGS) - Toast.makeText(context, "Enable permission for \"$appName\"", Toast.LENGTH_LONG) - .show() - context.startActivity(intent) - } else if (!it && notificationManagerService.isNotificationPolicyAccessGranted()) { - notificationManagerService.setInterruptionFilter(NotificationManager.INTERRUPTION_FILTER_ALL) + val switchItems = remember( + settingsState.dndEnabled, + settingsState.aodEnabled, + isPlus, + serviceRunning + ) { + listOf( + SettingsSwitchItem( + checked = settingsState.dndEnabled, + enabled = !serviceRunning, + icon = R.drawable.dnd, + label = R.string.dnd, + description = R.string.dnd_desc, + onClick = { + if (it && !notificationManagerService.isNotificationPolicyAccessGranted()) { + val intent = Intent(Settings.ACTION_NOTIFICATION_POLICY_ACCESS_SETTINGS) + Toast.makeText( + context, + "Enable permission for \"$appName\"", + Toast.LENGTH_LONG + ) + .show() + context.startActivity(intent) + } else if (!it && notificationManagerService.isNotificationPolicyAccessGranted()) { + notificationManagerService.setInterruptionFilter(NotificationManager.INTERRUPTION_FILTER_ALL) + } + onAction(SettingsAction.SaveDndEnabled(it)) } - onAction(SettingsAction.SaveDndEnabled(it)) - } - ), - SettingsSwitchItem( - checked = settingsState.aodEnabled, - icon = R.drawable.aod, - label = R.string.always_on_display, - description = R.string.always_on_display_desc, - onClick = { onAction(SettingsAction.SaveAodEnabled(it)) } - ) - ) - - Column(modifier.nestedScroll(scrollBehavior.nestedScrollConnection)) { - LargeFlexibleTopAppBar( - title = { - Text(stringResource(R.string.timer), fontFamily = robotoFlexTopBar) - }, - subtitle = { - Text(stringResource(R.string.settings)) - }, - navigationIcon = { - FilledTonalIconButton( - onClick = onBack, - shapes = IconButtonDefaults.shapes(), - colors = IconButtonDefaults.filledTonalIconButtonColors(containerColor = listItemColors.containerColor) - ) { - Icon( - painterResource(R.drawable.arrow_back), - null - ) - } - }, - colors = topBarColors, - scrollBehavior = scrollBehavior + ), + SettingsSwitchItem( + checked = settingsState.aodEnabled, + enabled = isPlus, + icon = R.drawable.aod, + label = R.string.always_on_display, + description = R.string.always_on_display_desc, + onClick = { onAction(SettingsAction.SaveAodEnabled(it)) } + ) ) + } + Scaffold( + topBar = { + LargeFlexibleTopAppBar( + title = { + Text(stringResource(R.string.timer), fontFamily = robotoFlexTopBar) + }, + subtitle = { + Text(stringResource(R.string.settings)) + }, + navigationIcon = { + FilledTonalIconButton( + onClick = onBack, + shapes = IconButtonDefaults.shapes(), + colors = IconButtonDefaults.filledTonalIconButtonColors(containerColor = listItemColors.containerColor) + ) { + Icon( + painterResource(R.drawable.arrow_back), + null + ) + } + }, + colors = topBarColors, + scrollBehavior = scrollBehavior + ) + }, + modifier = modifier.nestedScroll(scrollBehavior.nestedScrollConnection) + ) { innerPadding -> + val insets = mergePaddingValues(innerPadding, contentPadding) LazyColumn( verticalArrangement = Arrangement.spacedBy(2.dp), + contentPadding = insets, modifier = Modifier .background(topBarColors.containerColor) .fillMaxSize() @@ -259,31 +281,32 @@ fun TimerSettings( Spacer(Modifier.height(12.dp)) } item { - ListItem( - leadingContent = { - Icon(painterResource(R.drawable.clocks), null) - }, - headlineContent = { - Text(stringResource(R.string.session_length)) - }, - supportingContent = { - Column { + Column(Modifier.background(listItemColors.containerColor, cardShape)) { + ListItem( + leadingContent = { + Icon(painterResource(R.drawable.clocks), null) + }, + headlineContent = { + Text(stringResource(R.string.session_length)) + }, + supportingContent = { Text( stringResource( R.string.session_length_desc, sessionsSliderState.value.toInt() ) ) - Slider( - state = sessionsSliderState, - enabled = !serviceRunning, - modifier = Modifier.padding(vertical = 4.dp) - ) - } - }, - colors = listItemColors, - modifier = Modifier.clip(cardShape) - ) + }, + colors = listItemColors, + modifier = Modifier.clip(cardShape) + ) + Slider( + state = sessionsSliderState, + enabled = !serviceRunning, + modifier = Modifier + .padding(start = (16 * 2 + 24).dp, end = 16.dp, bottom = 12.dp) + ) + } } item { Spacer(Modifier.height(12.dp)) } @@ -333,6 +356,44 @@ fun TimerSettings( ) } + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.BAKLAVA) { + item { Spacer(Modifier.height(12.dp)) } + item { + ListItem( + leadingContent = { + Icon(painterResource(R.drawable.view_day), null) + }, + headlineContent = { Text(stringResource(R.string.session_only_progress)) }, + supportingContent = { Text(stringResource(R.string.session_only_progress_desc)) }, + trailingContent = { + Switch( + checked = settingsState.singleProgressBar, + enabled = !serviceRunning, + onCheckedChange = { onAction(SettingsAction.SaveSingleProgressBar(it)) }, + thumbContent = { + if (settingsState.singleProgressBar) { + Icon( + painter = painterResource(R.drawable.check), + contentDescription = null, + modifier = Modifier.size(SwitchDefaults.IconSize), + ) + } else { + Icon( + painter = painterResource(R.drawable.clear), + contentDescription = null, + modifier = Modifier.size(SwitchDefaults.IconSize), + ) + } + }, + colors = switchColors + ) + }, + colors = listItemColors, + modifier = Modifier.clip(cardShape) + ) + } + } + if (!isPlus) { item { PlusDivider(setShowPaywall) @@ -352,7 +413,7 @@ fun TimerSettings( Switch( checked = item.checked, onCheckedChange = { item.onClick(it) }, - enabled = isPlus, + enabled = item.enabled, thumbContent = { if (item.checked) { Icon( @@ -428,6 +489,7 @@ private fun TimerSettingsPreview() { isPlus = false, serviceRunning = true, settingsState = remember { SettingsState() }, + contentPadding = PaddingValues(), focusTimeInputFieldState = focusTimeInputFieldState, shortBreakTimeInputFieldState = shortBreakTimeInputFieldState, longBreakTimeInputFieldState = longBreakTimeInputFieldState, diff --git a/app/src/main/java/org/nsh07/pomodoro/ui/settingsScreen/viewModel/SettingsAction.kt b/app/src/main/java/org/nsh07/pomodoro/ui/settingsScreen/viewModel/SettingsAction.kt index ae5541a..9603809 100644 --- a/app/src/main/java/org/nsh07/pomodoro/ui/settingsScreen/viewModel/SettingsAction.kt +++ b/app/src/main/java/org/nsh07/pomodoro/ui/settingsScreen/viewModel/SettingsAction.kt @@ -26,6 +26,8 @@ sealed interface SettingsAction { data class SaveBlackTheme(val enabled: Boolean) : SettingsAction data class SaveAodEnabled(val enabled: Boolean) : SettingsAction data class SaveDndEnabled(val enabled: Boolean) : SettingsAction + data class SaveMediaVolumeForAlarm(val enabled: Boolean) : SettingsAction + data class SaveSingleProgressBar(val enabled: Boolean) : SettingsAction data class SaveAlarmSound(val uri: Uri?) : SettingsAction data class SaveTheme(val theme: String) : SettingsAction data class SaveColorScheme(val color: Color) : SettingsAction diff --git a/app/src/main/java/org/nsh07/pomodoro/ui/settingsScreen/viewModel/SettingsState.kt b/app/src/main/java/org/nsh07/pomodoro/ui/settingsScreen/viewModel/SettingsState.kt index b9d42b4..1ca0165 100644 --- a/app/src/main/java/org/nsh07/pomodoro/ui/settingsScreen/viewModel/SettingsState.kt +++ b/app/src/main/java/org/nsh07/pomodoro/ui/settingsScreen/viewModel/SettingsState.kt @@ -17,17 +17,29 @@ package org.nsh07.pomodoro.ui.settingsScreen.viewModel +import android.net.Uri +import android.provider.Settings import androidx.compose.runtime.Immutable import androidx.compose.ui.graphics.Color @Immutable data class SettingsState( val theme: String = "auto", - val alarmSound: String = "", val colorScheme: String = Color.White.toString(), val blackTheme: Boolean = false, val aodEnabled: Boolean = false, val alarmEnabled: Boolean = true, val vibrateEnabled: Boolean = true, - val dndEnabled: Boolean = false + val dndEnabled: Boolean = false, + val mediaVolumeForAlarm: Boolean = false, + val singleProgressBar: Boolean = false, + + val focusTime: Long = 25 * 60 * 1000L, + val shortBreakTime: Long = 5 * 60 * 1000L, + val longBreakTime: Long = 15 * 60 * 1000L, + + val sessionLength: Int = 4, + + val alarmSoundUri: Uri? = + Settings.System.DEFAULT_ALARM_ALERT_URI ?: Settings.System.DEFAULT_RINGTONE_URI ) 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 896eb28..5a524c2 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 @@ -25,6 +25,7 @@ import androidx.compose.material3.SliderState import androidx.compose.runtime.mutableStateListOf import androidx.compose.runtime.snapshotFlow import androidx.compose.ui.graphics.Color +import androidx.core.net.toUri import androidx.lifecycle.ViewModel import androidx.lifecycle.ViewModelProvider import androidx.lifecycle.ViewModelProvider.AndroidViewModelFactory.Companion.APPLICATION_KEY @@ -35,51 +36,57 @@ import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.FlowPreview import kotlinx.coroutines.Job import kotlinx.coroutines.flow.MutableStateFlow +import kotlinx.coroutines.flow.SharingStarted import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.flow.debounce +import kotlinx.coroutines.flow.map +import kotlinx.coroutines.flow.stateIn import kotlinx.coroutines.flow.update import kotlinx.coroutines.launch import org.nsh07.pomodoro.TomatoApplication import org.nsh07.pomodoro.billing.BillingManager -import org.nsh07.pomodoro.data.AppPreferenceRepository -import org.nsh07.pomodoro.data.TimerRepository +import org.nsh07.pomodoro.data.PreferenceRepository +import org.nsh07.pomodoro.data.StateRepository import org.nsh07.pomodoro.service.ServiceHelper import org.nsh07.pomodoro.ui.Screen import org.nsh07.pomodoro.ui.timerScreen.viewModel.TimerAction import org.nsh07.pomodoro.ui.timerScreen.viewModel.TimerMode -import org.nsh07.pomodoro.ui.timerScreen.viewModel.TimerState import org.nsh07.pomodoro.utils.millisecondsToStr @OptIn(FlowPreview::class, ExperimentalMaterial3Api::class) class SettingsViewModel( private val billingManager: BillingManager, - private val preferenceRepository: AppPreferenceRepository, + private val preferenceRepository: PreferenceRepository, + private val stateRepository: StateRepository, private val serviceHelper: ServiceHelper, - private val time: MutableStateFlow, - private val timerRepository: TimerRepository, - private val timerState: MutableStateFlow + private val time: MutableStateFlow ) : ViewModel() { val backStack = mutableStateListOf(Screen.Settings.Main) val isPlus = billingManager.isPlus - val serviceRunning = timerRepository.serviceRunning.asStateFlow() + val serviceRunning = stateRepository.timerState.map { it.serviceRunning } + .stateIn( + viewModelScope, + SharingStarted.WhileSubscribed(5000), + false + ) - private val _settingsState = MutableStateFlow(SettingsState()) + private val _settingsState = stateRepository.settingsState val settingsState = _settingsState.asStateFlow() val focusTimeTextFieldState by lazy { - TextFieldState((timerRepository.focusTime / 60000).toString()) + TextFieldState((_settingsState.value.focusTime / 60000).toString()) } val shortBreakTimeTextFieldState by lazy { - TextFieldState((timerRepository.shortBreakTime / 60000).toString()) + TextFieldState((_settingsState.value.shortBreakTime / 60000).toString()) } val longBreakTimeTextFieldState by lazy { - TextFieldState((timerRepository.longBreakTime / 60000).toString()) + TextFieldState((_settingsState.value.longBreakTime / 60000).toString()) } val sessionsSliderState by lazy { SliderState( - value = timerRepository.sessionLength.toFloat(), + value = _settingsState.value.sessionLength.toFloat(), steps = 4, valueRange = 1f..6f, onValueChangeFinished = ::updateSessionLength @@ -102,6 +109,8 @@ class SettingsViewModel( is SettingsAction.SaveAlarmEnabled -> saveAlarmEnabled(action.enabled) is SettingsAction.SaveVibrateEnabled -> saveVibrateEnabled(action.enabled) is SettingsAction.SaveDndEnabled -> saveDndEnabled(action.enabled) + is SettingsAction.SaveMediaVolumeForAlarm -> saveMediaVolumeForAlarm(action.enabled) + is SettingsAction.SaveSingleProgressBar -> saveSingleProgressBar(action.enabled) is SettingsAction.SaveColorScheme -> saveColorScheme(action.color) is SettingsAction.SaveTheme -> saveTheme(action.theme) is SettingsAction.SaveBlackTheme -> saveBlackTheme(action.enabled) @@ -110,11 +119,15 @@ class SettingsViewModel( } private fun updateSessionLength() { - viewModelScope.launch { - timerRepository.sessionLength = preferenceRepository.saveIntPreference( - "session_length", - sessionsSliderState.value.toInt() - ) + viewModelScope.launch(Dispatchers.IO) { + _settingsState.update { currentState -> + currentState.copy( + sessionLength = preferenceRepository.saveIntPreference( + "session_length", + sessionsSliderState.value.toInt() + ) + ) + } refreshTimer() } } @@ -125,11 +138,13 @@ class SettingsViewModel( .debounce(500) .collect { if (it.isNotEmpty()) { - timerRepository.focusTime = it.toString().toLong() * 60 * 1000 + _settingsState.update { currentState -> + currentState.copy(focusTime = it.toString().toLong() * 60 * 1000) + } refreshTimer() preferenceRepository.saveIntPreference( "focus_time", - timerRepository.focusTime.toInt() + _settingsState.value.focusTime.toInt() ) } } @@ -139,11 +154,13 @@ class SettingsViewModel( .debounce(500) .collect { if (it.isNotEmpty()) { - timerRepository.shortBreakTime = it.toString().toLong() * 60 * 1000 + _settingsState.update { currentState -> + currentState.copy(shortBreakTime = it.toString().toLong() * 60 * 1000) + } refreshTimer() preferenceRepository.saveIntPreference( "short_break_time", - timerRepository.shortBreakTime.toInt() + _settingsState.value.shortBreakTime.toInt() ) } } @@ -153,11 +170,13 @@ class SettingsViewModel( .debounce(500) .collect { if (it.isNotEmpty()) { - timerRepository.longBreakTime = it.toString().toLong() * 60 * 1000 + _settingsState.update { currentState -> + currentState.copy(longBreakTime = it.toString().toLong() * 60 * 1000) + } refreshTimer() preferenceRepository.saveIntPreference( "long_break_time", - timerRepository.longBreakTime.toInt() + _settingsState.value.longBreakTime.toInt() ) } } @@ -173,7 +192,6 @@ class SettingsViewModel( private fun saveAlarmEnabled(enabled: Boolean) { viewModelScope.launch { - timerRepository.alarmEnabled = enabled _settingsState.update { currentState -> currentState.copy(alarmEnabled = enabled) } @@ -183,7 +201,6 @@ class SettingsViewModel( private fun saveVibrateEnabled(enabled: Boolean) { viewModelScope.launch { - timerRepository.vibrateEnabled = enabled _settingsState.update { currentState -> currentState.copy(vibrateEnabled = enabled) } @@ -193,7 +210,6 @@ class SettingsViewModel( private fun saveDndEnabled(enabled: Boolean) { viewModelScope.launch { - timerRepository.dndEnabled = enabled _settingsState.update { currentState -> currentState.copy(dndEnabled = enabled) } @@ -203,9 +219,8 @@ class SettingsViewModel( private fun saveAlarmSound(uri: Uri?) { viewModelScope.launch { - timerRepository.alarmSoundUri = uri _settingsState.update { currentState -> - currentState.copy(alarmSound = uri.toString()) + currentState.copy(alarmSoundUri = uri) } preferenceRepository.saveStringPreference("alarm_sound", uri.toString()) } @@ -247,55 +262,150 @@ class SettingsViewModel( } } - suspend fun reloadSettings() { - val theme = preferenceRepository.getStringPreference("theme") - ?: preferenceRepository.saveStringPreference("theme", "auto") - val colorScheme = preferenceRepository.getStringPreference("color_scheme") - ?: preferenceRepository.saveStringPreference("color_scheme", Color.White.toString()) - val blackTheme = preferenceRepository.getBooleanPreference("black_theme") - ?: preferenceRepository.saveBooleanPreference("black_theme", false) - val aodEnabled = preferenceRepository.getBooleanPreference("aod_enabled") - ?: preferenceRepository.saveBooleanPreference("aod_enabled", false) - val alarmSound = preferenceRepository.getStringPreference("alarm_sound") - ?: preferenceRepository.saveStringPreference( - "alarm_sound", - (Settings.System.DEFAULT_ALARM_ALERT_URI - ?: Settings.System.DEFAULT_RINGTONE_URI).toString() + private fun saveMediaVolumeForAlarm(mediaVolumeForAlarm: Boolean) { + viewModelScope.launch { + _settingsState.update { currentState -> + currentState.copy(mediaVolumeForAlarm = mediaVolumeForAlarm) + } + preferenceRepository.saveBooleanPreference( + "media_volume_for_alarm", + mediaVolumeForAlarm ) + } + } + + private fun saveSingleProgressBar(singleProgressBar: Boolean) { + viewModelScope.launch { + _settingsState.update { currentState -> + currentState.copy(singleProgressBar = singleProgressBar) + } + preferenceRepository.saveBooleanPreference( + "single_progress_bar", + singleProgressBar + ) + } + } + + suspend fun reloadSettings() { + var settingsState = _settingsState.value + val focusTime = + preferenceRepository.getIntPreference("focus_time")?.toLong() + ?: preferenceRepository.saveIntPreference( + "focus_time", + settingsState.focusTime.toInt() + ).toLong() + val shortBreakTime = + preferenceRepository.getIntPreference("short_break_time")?.toLong() + ?: preferenceRepository.saveIntPreference( + "short_break_time", + settingsState.shortBreakTime.toInt() + ).toLong() + val longBreakTime = + preferenceRepository.getIntPreference("long_break_time")?.toLong() + ?: preferenceRepository.saveIntPreference( + "long_break_time", + settingsState.longBreakTime.toInt() + ).toLong() + val sessionLength = + preferenceRepository.getIntPreference("session_length") + ?: preferenceRepository.saveIntPreference( + "session_length", + settingsState.sessionLength + ) + + val alarmSoundUri = ( + preferenceRepository.getStringPreference("alarm_sound") + ?: preferenceRepository.saveStringPreference( + "alarm_sound", + (Settings.System.DEFAULT_ALARM_ALERT_URI + ?: Settings.System.DEFAULT_RINGTONE_URI).toString() + ) + ).toUri() + + val theme = preferenceRepository.getStringPreference("theme") + ?: preferenceRepository.saveStringPreference("theme", settingsState.theme) + val colorScheme = preferenceRepository.getStringPreference("color_scheme") + ?: preferenceRepository.saveStringPreference("color_scheme", settingsState.colorScheme) + val blackTheme = preferenceRepository.getBooleanPreference("black_theme") + ?: preferenceRepository.saveBooleanPreference("black_theme", settingsState.blackTheme) + val aodEnabled = preferenceRepository.getBooleanPreference("aod_enabled") + ?: preferenceRepository.saveBooleanPreference("aod_enabled", settingsState.aodEnabled) val alarmEnabled = preferenceRepository.getBooleanPreference("alarm_enabled") - ?: preferenceRepository.saveBooleanPreference("alarm_enabled", true) + ?: preferenceRepository.saveBooleanPreference( + "alarm_enabled", + settingsState.alarmEnabled + ) val vibrateEnabled = preferenceRepository.getBooleanPreference("vibrate_enabled") - ?: preferenceRepository.saveBooleanPreference("vibrate_enabled", true) + ?: preferenceRepository.saveBooleanPreference( + "vibrate_enabled", + settingsState.vibrateEnabled + ) val dndEnabled = preferenceRepository.getBooleanPreference("dnd_enabled") - ?: preferenceRepository.saveBooleanPreference("dnd_enabled", false) + ?: preferenceRepository.saveBooleanPreference("dnd_enabled", settingsState.dndEnabled) + val mediaVolumeForAlarm = + preferenceRepository.getBooleanPreference("media_volume_for_alarm") + ?: preferenceRepository.saveBooleanPreference( + "media_volume_for_alarm", + settingsState.mediaVolumeForAlarm + ) + val singleProgressBar = preferenceRepository.getBooleanPreference("single_progress_bar") + ?: preferenceRepository.saveBooleanPreference( + "single_progress_bar", + settingsState.singleProgressBar + ) _settingsState.update { currentState -> currentState.copy( + focusTime = focusTime, + shortBreakTime = shortBreakTime, + longBreakTime = longBreakTime, + sessionLength = sessionLength, theme = theme, colorScheme = colorScheme, - alarmSound = alarmSound, + alarmSoundUri = alarmSoundUri, blackTheme = blackTheme, aodEnabled = aodEnabled, alarmEnabled = alarmEnabled, vibrateEnabled = vibrateEnabled, - dndEnabled = dndEnabled + dndEnabled = dndEnabled, + mediaVolumeForAlarm = mediaVolumeForAlarm, + singleProgressBar = singleProgressBar ) } + + settingsState = _settingsState.value + + if (!stateRepository.timerState.value.serviceRunning) { + time.update { settingsState.focusTime } + stateRepository.timerState.update { currentState -> + currentState.copy( + timerMode = TimerMode.FOCUS, + timeStr = millisecondsToStr(time.value), + totalTime = time.value, + nextTimerMode = if (settingsState.sessionLength > 1) TimerMode.SHORT_BREAK else TimerMode.LONG_BREAK, + nextTimeStr = millisecondsToStr(if (settingsState.sessionLength > 1) settingsState.shortBreakTime else settingsState.longBreakTime), + currentFocusCount = 1, + totalFocusCount = settingsState.sessionLength + ) + } + } } private fun refreshTimer() { if (!serviceRunning.value) { - time.update { timerRepository.focusTime } + val settingsState = _settingsState.value - timerState.update { currentState -> + time.update { settingsState.focusTime } + + stateRepository.timerState.update { currentState -> currentState.copy( timerMode = TimerMode.FOCUS, timeStr = millisecondsToStr(time.value), totalTime = time.value, - nextTimerMode = if (timerRepository.sessionLength > 1) TimerMode.SHORT_BREAK else TimerMode.LONG_BREAK, - nextTimeStr = millisecondsToStr(if (timerRepository.sessionLength > 1) timerRepository.shortBreakTime else timerRepository.longBreakTime), + nextTimerMode = if (settingsState.sessionLength > 1) TimerMode.SHORT_BREAK else TimerMode.LONG_BREAK, + nextTimeStr = millisecondsToStr(if (settingsState.sessionLength > 1) settingsState.shortBreakTime else settingsState.longBreakTime), currentFocusCount = 1, - totalFocusCount = timerRepository.sessionLength + totalFocusCount = settingsState.sessionLength ) } } @@ -307,18 +417,16 @@ class SettingsViewModel( val application = (this[APPLICATION_KEY] as TomatoApplication) val appBillingManager = application.container.billingManager val appPreferenceRepository = application.container.appPreferenceRepository - val appTimerRepository = application.container.appTimerRepository val serviceHelper = application.container.serviceHelper + val stateRepository = application.container.stateRepository val time = application.container.time - val timerState = application.container.timerState SettingsViewModel( billingManager = appBillingManager, preferenceRepository = appPreferenceRepository, serviceHelper = serviceHelper, - time = time, - timerRepository = appTimerRepository, - timerState = timerState + stateRepository = stateRepository, + time = time ) } } diff --git a/app/src/main/java/org/nsh07/pomodoro/ui/statsScreen/ProductivityGraph.kt b/app/src/main/java/org/nsh07/pomodoro/ui/statsScreen/ProductivityGraph.kt index 70c928d..5b53ac1 100644 --- a/app/src/main/java/org/nsh07/pomodoro/ui/statsScreen/ProductivityGraph.kt +++ b/app/src/main/java/org/nsh07/pomodoro/ui/statsScreen/ProductivityGraph.kt @@ -32,7 +32,6 @@ import androidx.compose.ui.unit.dp import com.patrykandpatrick.vico.core.cartesian.data.CartesianChartModelProducer import com.patrykandpatrick.vico.core.cartesian.data.CartesianValueFormatter import org.nsh07.pomodoro.R -import org.nsh07.pomodoro.utils.millisecondsToHoursMinutes @Composable fun ColumnScope.ProductivityGraph( @@ -53,6 +52,9 @@ fun ColumnScope.ProductivityGraph( Spacer(Modifier.height(8.dp)) TimeColumnChart( modelProducer, + hoursFormat = stringResource(R.string.hours_format), + hoursMinutesFormat = stringResource(R.string.hours_and_minutes_format), + minutesFormat = stringResource(R.string.minutes_format), axisTypeface = axisTypeface, markerTypeface = markerTypeface, xValueFormatter = CartesianValueFormatter { _, value, _ -> @@ -63,9 +65,6 @@ fun ColumnScope.ProductivityGraph( 3.0 -> "18 - 24" else -> "" } - }, - yValueFormatter = CartesianValueFormatter { _, value, _ -> - millisecondsToHoursMinutes(value.toLong()) } ) } diff --git a/app/src/main/java/org/nsh07/pomodoro/ui/statsScreen/StatsScreen.kt b/app/src/main/java/org/nsh07/pomodoro/ui/statsScreen/StatsScreen.kt index 66c3957..18195b3 100644 --- a/app/src/main/java/org/nsh07/pomodoro/ui/statsScreen/StatsScreen.kt +++ b/app/src/main/java/org/nsh07/pomodoro/ui/statsScreen/StatsScreen.kt @@ -45,6 +45,7 @@ import androidx.compose.material3.MaterialTheme import androidx.compose.material3.MaterialTheme.colorScheme import androidx.compose.material3.MaterialTheme.motionScheme import androidx.compose.material3.MaterialTheme.typography +import androidx.compose.material3.Scaffold import androidx.compose.material3.Surface import androidx.compose.material3.Text import androidx.compose.material3.TopAppBar @@ -76,6 +77,7 @@ import com.patrykandpatrick.vico.core.common.data.ExtraStore import org.nsh07.pomodoro.BuildConfig import org.nsh07.pomodoro.R import org.nsh07.pomodoro.data.Stat +import org.nsh07.pomodoro.ui.mergePaddingValues import org.nsh07.pomodoro.ui.statsScreen.viewModel.StatsViewModel import org.nsh07.pomodoro.ui.theme.AppFonts.googleFlex400 import org.nsh07.pomodoro.ui.theme.AppFonts.googleFlex600 @@ -130,6 +132,10 @@ fun StatsScreen( ) { val scrollBehavior = TopAppBarDefaults.enterAlwaysScrollBehavior() + val hoursFormat = stringResource(R.string.hours_format) + val hoursMinutesFormat = stringResource(R.string.hours_and_minutes_format) + val minutesFormat = stringResource(R.string.minutes_format) + var lastWeekStatExpanded by rememberSaveable { mutableStateOf(false) } var lastMonthStatExpanded by rememberSaveable { mutableStateOf(false) } @@ -156,43 +162,45 @@ fun StatsScreen( val axisTypeface = remember { resolver.resolve(googleFlex400).value as Typeface } val markerTypeface = remember { resolver.resolve(googleFlex600).value as Typeface } - Column( - horizontalAlignment = Alignment.CenterHorizontally, - modifier = modifier.nestedScroll(scrollBehavior.nestedScrollConnection) - ) { - TopAppBar( - title = { - Text( - stringResource(R.string.stats), - style = LocalTextStyle.current.copy( - fontFamily = robotoFlexTopBar, - fontSize = 32.sp, - lineHeight = 32.sp - ), - modifier = Modifier - .padding(top = contentPadding.calculateTopPadding()) - .padding(vertical = 14.dp) - ) - }, - actions = if (BuildConfig.DEBUG) { - { - IconButton( - onClick = generateSampleData - ) { - Spacer(Modifier.size(24.dp)) + Scaffold( + topBar = { + TopAppBar( + title = { + Text( + stringResource(R.string.stats), + style = LocalTextStyle.current.copy( + fontFamily = robotoFlexTopBar, + fontSize = 32.sp, + lineHeight = 32.sp + ), + modifier = Modifier + .padding(top = contentPadding.calculateTopPadding()) + .padding(vertical = 14.dp) + ) + }, + actions = if (BuildConfig.DEBUG) { + { + IconButton( + onClick = generateSampleData + ) { + Spacer(Modifier.size(24.dp)) + } } - } - } else { - {} - }, - subtitle = {}, - titleHorizontalAlignment = Alignment.CenterHorizontally, - scrollBehavior = scrollBehavior, - windowInsets = WindowInsets() - ) - + } else { + {} + }, + subtitle = {}, + titleHorizontalAlignment = Alignment.CenterHorizontally, + scrollBehavior = scrollBehavior, + windowInsets = WindowInsets() + ) + }, + modifier = modifier.nestedScroll(scrollBehavior.nestedScrollConnection) + ) { innerPadding -> + val insets = mergePaddingValues(innerPadding, contentPadding) LazyColumn( horizontalAlignment = Alignment.CenterHorizontally, + contentPadding = insets, verticalArrangement = Arrangement.spacedBy(16.dp) ) { item { Spacer(Modifier) } @@ -223,7 +231,10 @@ fun StatsScreen( ) Text( remember(todayStat) { - millisecondsToHoursMinutes(todayStat?.totalFocusTime() ?: 0) + millisecondsToHoursMinutes( + todayStat?.totalFocusTime() ?: 0, + hoursMinutesFormat + ) }, style = typography.displaySmall, color = colorScheme.onPrimaryContainer, @@ -249,7 +260,10 @@ fun StatsScreen( ) Text( remember(todayStat) { - millisecondsToHoursMinutes(todayStat?.breakTime ?: 0) + millisecondsToHoursMinutes( + todayStat?.breakTime ?: 0, + hoursMinutesFormat + ) }, style = typography.displaySmall, color = colorScheme.onTertiaryContainer, @@ -282,7 +296,8 @@ fun StatsScreen( millisecondsToHoursMinutes( remember(lastWeekAverageFocusTimes) { lastWeekAverageFocusTimes.sum().toLong() - } + }, + hoursMinutesFormat ), style = typography.displaySmall ) @@ -295,7 +310,10 @@ fun StatsScreen( } item { TimeColumnChart( - lastWeekSummaryChartData.first, + modelProducer = lastWeekSummaryChartData.first, + hoursFormat = hoursFormat, + hoursMinutesFormat = hoursMinutesFormat, + minutesFormat = minutesFormat, modifier = Modifier.padding(start = 16.dp), axisTypeface = axisTypeface, markerTypeface = markerTypeface, @@ -361,7 +379,8 @@ fun StatsScreen( millisecondsToHoursMinutes( remember(lastMonthAverageFocusTimes) { lastMonthAverageFocusTimes.sum().toLong() - } + }, + hoursMinutesFormat ), style = typography.displaySmall ) @@ -374,7 +393,10 @@ fun StatsScreen( } item { TimeColumnChart( - lastMonthSummaryChartData.first, + modelProducer = lastMonthSummaryChartData.first, + hoursFormat = hoursFormat, + hoursMinutesFormat = hoursMinutesFormat, + minutesFormat = minutesFormat, modifier = Modifier.padding(start = 16.dp), axisTypeface = axisTypeface, markerTypeface = markerTypeface, @@ -441,7 +463,8 @@ fun StatsScreen( millisecondsToHoursMinutes( remember(lastYearAverageFocusTimes) { lastYearAverageFocusTimes.sum().toLong() - } + }, + hoursMinutesFormat ), style = typography.displaySmall ) @@ -454,7 +477,10 @@ fun StatsScreen( } item { TimeLineChart( - lastYearSummaryChartData.first, + modelProducer = lastYearSummaryChartData.first, + hoursFormat = hoursFormat, + hoursMinutesFormat = hoursMinutesFormat, + minutesFormat = minutesFormat, modifier = Modifier.padding(start = 16.dp), axisTypeface = axisTypeface, markerTypeface = markerTypeface, diff --git a/app/src/main/java/org/nsh07/pomodoro/ui/statsScreen/TimeColumnChart.kt b/app/src/main/java/org/nsh07/pomodoro/ui/statsScreen/TimeColumnChart.kt index 41585c0..f38b4b1 100644 --- a/app/src/main/java/org/nsh07/pomodoro/ui/statsScreen/TimeColumnChart.kt +++ b/app/src/main/java/org/nsh07/pomodoro/ui/statsScreen/TimeColumnChart.kt @@ -22,6 +22,7 @@ import androidx.compose.animation.core.AnimationSpec import androidx.compose.foundation.layout.height import androidx.compose.material3.ExperimentalMaterial3ExpressiveApi import androidx.compose.material3.MaterialTheme.colorScheme +import androidx.compose.material3.MaterialTheme.motionScheme import androidx.compose.material3.MaterialTheme.typography import androidx.compose.material3.Surface import androidx.compose.runtime.Composable @@ -68,6 +69,9 @@ import org.nsh07.pomodoro.utils.millisecondsToMinutes @Composable fun TimeColumnChart( modelProducer: CartesianChartModelProducer, + hoursFormat: String, + hoursMinutesFormat: String, + minutesFormat: String, modifier: Modifier = Modifier, axisTypeface: Typeface = Typeface.DEFAULT, markerTypeface: Typeface = Typeface.DEFAULT, @@ -76,9 +80,9 @@ fun TimeColumnChart( xValueFormatter: CartesianValueFormatter = CartesianValueFormatter.Default, yValueFormatter: CartesianValueFormatter = CartesianValueFormatter { _, value, _ -> if (value >= 60 * 60 * 1000) { - millisecondsToHours(value.toLong()) + millisecondsToHours(value.toLong(), hoursFormat) } else { - millisecondsToMinutes(value.toLong()) + millisecondsToMinutes(value.toLong(), minutesFormat) } }, markerValueFormatter: DefaultCartesianMarker.ValueFormatter = DefaultCartesianMarker.ValueFormatter { _, targets -> @@ -88,12 +92,12 @@ fun TimeColumnChart( } else 0L if (value >= 60 * 60 * 1000) { - millisecondsToHoursMinutes(value) + millisecondsToHoursMinutes(value, hoursMinutesFormat) } else { - millisecondsToMinutes(value) + millisecondsToMinutes(value, minutesFormat) } }, - animationSpec: AnimationSpec? = null + animationSpec: AnimationSpec? = motionScheme.defaultEffectsSpec() ) { ProvideVicoTheme(rememberM3VicoTheme()) { CartesianChartHost( @@ -157,6 +161,7 @@ fun TimeColumnChart( minZoom = Zoom.min(Zoom.Content, Zoom.fixed()) ), animationSpec = animationSpec, + animateIn = false, modifier = modifier.height(226.dp), ) } @@ -179,7 +184,13 @@ private fun TimeColumnChartPreview() { } TomatoTheme { Surface { - TimeColumnChart(thickness = 8.dp, modelProducer = modelProducer) + TimeColumnChart( + thickness = 8.dp, + modelProducer = modelProducer, + hoursFormat = "%dh", + hoursMinutesFormat = "%dh %dm", + minutesFormat = "%dm" + ) } } } diff --git a/app/src/main/java/org/nsh07/pomodoro/ui/statsScreen/TimeLineChart.kt b/app/src/main/java/org/nsh07/pomodoro/ui/statsScreen/TimeLineChart.kt index 29f6e69..2ee1bed 100644 --- a/app/src/main/java/org/nsh07/pomodoro/ui/statsScreen/TimeLineChart.kt +++ b/app/src/main/java/org/nsh07/pomodoro/ui/statsScreen/TimeLineChart.kt @@ -22,6 +22,7 @@ import androidx.compose.animation.core.AnimationSpec import androidx.compose.foundation.layout.height import androidx.compose.material3.ExperimentalMaterial3ExpressiveApi import androidx.compose.material3.MaterialTheme.colorScheme +import androidx.compose.material3.MaterialTheme.motionScheme import androidx.compose.material3.MaterialTheme.typography import androidx.compose.material3.Surface import androidx.compose.runtime.Composable @@ -74,6 +75,9 @@ import org.nsh07.pomodoro.utils.millisecondsToMinutes @Composable fun TimeLineChart( modelProducer: CartesianChartModelProducer, + hoursFormat: String, + hoursMinutesFormat: String, + minutesFormat: String, modifier: Modifier = Modifier, axisTypeface: Typeface = Typeface.DEFAULT, markerTypeface: Typeface = Typeface.DEFAULT, @@ -82,9 +86,9 @@ fun TimeLineChart( xValueFormatter: CartesianValueFormatter = CartesianValueFormatter.Default, yValueFormatter: CartesianValueFormatter = CartesianValueFormatter { _, value, _ -> if (value >= 60 * 60 * 1000) { - millisecondsToHours(value.toLong()) + millisecondsToHours(value.toLong(), hoursFormat) } else { - millisecondsToMinutes(value.toLong()) + millisecondsToMinutes(value.toLong(), minutesFormat) } }, markerValueFormatter: DefaultCartesianMarker.ValueFormatter = DefaultCartesianMarker.ValueFormatter { _, targets -> @@ -94,12 +98,12 @@ fun TimeLineChart( } else 0L if (value >= 60 * 60 * 1000) { - millisecondsToHoursMinutes(value) + millisecondsToHoursMinutes(value, hoursMinutesFormat) } else { - millisecondsToMinutes(value) + millisecondsToMinutes(value, minutesFormat) } }, - animationSpec: AnimationSpec? = null + animationSpec: AnimationSpec? = motionScheme.defaultEffectsSpec() ) { ProvideVicoTheme(rememberM3VicoTheme()) { CartesianChartHost( @@ -180,6 +184,7 @@ fun TimeLineChart( minZoom = Zoom.min(Zoom.Content, Zoom.fixed()) ), animationSpec = animationSpec, + animateIn = false, modifier = modifier.height(224.dp), ) } @@ -203,7 +208,12 @@ private fun TimeLineChartPreview() { } TomatoTheme { Surface { - TimeLineChart(modelProducer = modelProducer) + TimeLineChart( + modelProducer = modelProducer, + hoursFormat = "%dh", + hoursMinutesFormat = "%dh %dm", + minutesFormat = "%dm" + ) } } } diff --git a/app/src/main/java/org/nsh07/pomodoro/ui/theme/Type.kt b/app/src/main/java/org/nsh07/pomodoro/ui/theme/Type.kt index b526d70..86d5a0b 100644 --- a/app/src/main/java/org/nsh07/pomodoro/ui/theme/Type.kt +++ b/app/src/main/java/org/nsh07/pomodoro/ui/theme/Type.kt @@ -92,8 +92,6 @@ val Typography = Typography( @OptIn(ExperimentalTextApi::class) object AppFonts { - val interClock = FontFamily(Font(R.font.inter_bold)) - val googleFlex400 = FontFamily(Font(R.font.google_sans_flex_400)) val googleFlex600 = FontFamily(Font(R.font.google_sans_flex_600)) diff --git a/app/src/main/java/org/nsh07/pomodoro/ui/timerScreen/TimerScreen.kt b/app/src/main/java/org/nsh07/pomodoro/ui/timerScreen/TimerScreen.kt index 54e153c..359bce6 100644 --- a/app/src/main/java/org/nsh07/pomodoro/ui/timerScreen/TimerScreen.kt +++ b/app/src/main/java/org/nsh07/pomodoro/ui/timerScreen/TimerScreen.kt @@ -38,6 +38,7 @@ import androidx.compose.foundation.interaction.MutableInteractionSource import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.aspectRatio import androidx.compose.foundation.layout.fillMaxSize @@ -47,8 +48,7 @@ import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.width import androidx.compose.foundation.layout.widthIn -import androidx.compose.foundation.rememberScrollState -import androidx.compose.foundation.verticalScroll +import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.material3.ButtonGroup import androidx.compose.material3.ButtonGroupDefaults import androidx.compose.material3.CircularProgressIndicator @@ -64,6 +64,7 @@ import androidx.compose.material3.MaterialTheme.colorScheme import androidx.compose.material3.MaterialTheme.motionScheme import androidx.compose.material3.MaterialTheme.shapes import androidx.compose.material3.MaterialTheme.typography +import androidx.compose.material3.Scaffold import androidx.compose.material3.Surface import androidx.compose.material3.Text import androidx.compose.material3.TopAppBar @@ -94,7 +95,8 @@ import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp import androidx.navigation3.ui.LocalNavAnimatedContentScope import org.nsh07.pomodoro.R -import org.nsh07.pomodoro.ui.theme.AppFonts.interClock +import org.nsh07.pomodoro.ui.mergePaddingValues +import org.nsh07.pomodoro.ui.theme.AppFonts.googleFlex600 import org.nsh07.pomodoro.ui.theme.AppFonts.robotoFlexTopBar import org.nsh07.pomodoro.ui.theme.TomatoTheme import org.nsh07.pomodoro.ui.timerScreen.viewModel.TimerAction @@ -107,6 +109,7 @@ import org.nsh07.pomodoro.ui.timerScreen.viewModel.TimerState fun SharedTransitionScope.TimerScreen( timerState: TimerState, isPlus: Boolean, + contentPadding: PaddingValues, progress: () -> Float, onAction: (TimerAction) -> Unit, modifier: Modifier = Modifier @@ -137,407 +140,419 @@ fun SharedTransitionScope.TimerScreen( val scrollBehavior = TopAppBarDefaults.exitUntilCollapsedScrollBehavior() - Column(modifier = modifier.nestedScroll(scrollBehavior.nestedScrollConnection)) { - TopAppBar( - title = { - AnimatedContent( - if (!timerState.showBrandTitle) timerState.timerMode else TimerMode.BRAND, - transitionSpec = { - slideInVertically( - animationSpec = motionScheme.defaultSpatialSpec(), - initialOffsetY = { (-it * 1.25).toInt() } - ).togetherWith( - slideOutVertically( + Scaffold( + topBar = { + TopAppBar( + title = { + AnimatedContent( + if (!timerState.showBrandTitle) timerState.timerMode else TimerMode.BRAND, + transitionSpec = { + slideInVertically( animationSpec = motionScheme.defaultSpatialSpec(), - targetOffsetY = { (it * 1.25).toInt() } + initialOffsetY = { (-it * 1.25).toInt() } + ).togetherWith( + slideOutVertically( + animationSpec = motionScheme.defaultSpatialSpec(), + targetOffsetY = { (it * 1.25).toInt() } + ) ) - ) - }, - contentAlignment = Alignment.Center, - modifier = Modifier.fillMaxWidth(.9f) - ) { - when (it) { - TimerMode.BRAND -> - Text( - if (!isPlus) stringResource(R.string.app_name) - else stringResource(R.string.app_name_plus), + }, + contentAlignment = Alignment.Center, + modifier = Modifier.fillMaxWidth(.9f) + ) { + when (it) { + TimerMode.BRAND -> + Text( + if (!isPlus) stringResource(R.string.app_name) + else stringResource(R.string.app_name_plus), + style = TextStyle( + fontFamily = robotoFlexTopBar, + fontSize = 32.sp, + lineHeight = 32.sp, + color = colorScheme.error + ), + textAlign = TextAlign.Center + ) + + TimerMode.FOCUS -> + Text( + stringResource(R.string.focus), + style = TextStyle( + fontFamily = robotoFlexTopBar, + fontSize = 32.sp, + lineHeight = 32.sp, + color = colorScheme.primary + ), + textAlign = TextAlign.Center + ) + + TimerMode.SHORT_BREAK -> Text( + stringResource(R.string.short_break), style = TextStyle( fontFamily = robotoFlexTopBar, fontSize = 32.sp, lineHeight = 32.sp, - color = colorScheme.error + color = colorScheme.tertiary ), textAlign = TextAlign.Center ) - TimerMode.FOCUS -> - Text( - stringResource(R.string.focus), + TimerMode.LONG_BREAK -> Text( + stringResource(R.string.long_break), style = TextStyle( fontFamily = robotoFlexTopBar, fontSize = 32.sp, lineHeight = 32.sp, - color = colorScheme.primary + color = colorScheme.tertiary ), textAlign = TextAlign.Center ) - - TimerMode.SHORT_BREAK -> Text( - stringResource(R.string.short_break), - style = TextStyle( - fontFamily = robotoFlexTopBar, - fontSize = 32.sp, - lineHeight = 32.sp, - color = colorScheme.tertiary - ), - textAlign = TextAlign.Center - ) - - TimerMode.LONG_BREAK -> Text( - stringResource(R.string.long_break), - style = TextStyle( - fontFamily = robotoFlexTopBar, - fontSize = 32.sp, - lineHeight = 32.sp, - color = colorScheme.tertiary - ), - textAlign = TextAlign.Center - ) + } } - } - }, - subtitle = {}, - titleHorizontalAlignment = CenterHorizontally, - scrollBehavior = scrollBehavior - ) - - Column( + }, + subtitle = {}, + titleHorizontalAlignment = CenterHorizontally, + scrollBehavior = scrollBehavior + ) + }, + modifier = modifier + .nestedScroll(scrollBehavior.nestedScrollConnection) + ) { innerPadding -> + val insets = mergePaddingValues(innerPadding, contentPadding) + LazyColumn( verticalArrangement = Arrangement.Center, horizontalAlignment = CenterHorizontally, + contentPadding = insets, modifier = Modifier .fillMaxSize() - .verticalScroll(rememberScrollState()) ) { - Column(horizontalAlignment = CenterHorizontally) { - Box(contentAlignment = Alignment.Center) { - if (timerState.timerMode == TimerMode.FOCUS) { - CircularProgressIndicator( - progress = progress, - modifier = Modifier - .sharedBounds( - sharedContentState = this@TimerScreen.rememberSharedContentState( - "focus progress" - ), - animatedVisibilityScope = LocalNavAnimatedContentScope.current - ) - .widthIn(max = 350.dp) - .fillMaxWidth(0.9f) - .aspectRatio(1f), - color = color, - trackColor = colorContainer, - strokeWidth = 16.dp, - gapSize = 8.dp - ) - } else { - CircularWavyProgressIndicator( - progress = progress, - modifier = Modifier - .sharedBounds( - sharedContentState = this@TimerScreen.rememberSharedContentState( - "break progress" - ), - animatedVisibilityScope = LocalNavAnimatedContentScope.current - ) - .widthIn(max = 350.dp) - .fillMaxWidth(0.9f) - .aspectRatio(1f), - color = color, - trackColor = colorContainer, - stroke = Stroke( - width = with(LocalDensity.current) { - 16.dp.toPx() - }, - cap = StrokeCap.Round, - ), - trackStroke = Stroke( - width = with(LocalDensity.current) { - 16.dp.toPx() - }, - cap = StrokeCap.Round, - ), - wavelength = 60.dp, - gapSize = 8.dp - ) - } - var expanded by remember { mutableStateOf(timerState.showBrandTitle) } - Column( - horizontalAlignment = CenterHorizontally, - modifier = Modifier - .clip(shapes.largeIncreased) - .clickable(onClick = { expanded = !expanded }) - ) { - LaunchedEffect(timerState.showBrandTitle) { - expanded = timerState.showBrandTitle - } - Text( - text = timerState.timeStr, - style = TextStyle( - fontFamily = interClock, - fontSize = 72.sp, - letterSpacing = (-2).sp, - fontFeatureSettings = "tnum" - ), - textAlign = TextAlign.Center, - maxLines = 1, - modifier = Modifier.sharedBounds( - sharedContentState = this@TimerScreen.rememberSharedContentState("clock"), - animatedVisibilityScope = LocalNavAnimatedContentScope.current - ) - ) - AnimatedVisibility( - expanded, - enter = fadeIn(motionScheme.defaultEffectsSpec()) + - expandVertically(motionScheme.defaultSpatialSpec()), - exit = fadeOut(motionScheme.defaultEffectsSpec()) + - shrinkVertically(motionScheme.defaultSpatialSpec()) - ) { - Text( - stringResource( - R.string.timer_session_count, - timerState.currentFocusCount, - timerState.totalFocusCount - ), - fontFamily = interClock, - style = typography.titleLarge, - color = colorScheme.outline - ) - } - } - } - val interactionSources = remember { List(3) { MutableInteractionSource() } } - ButtonGroup( - overflowIndicator = { state -> - ButtonGroupDefaults.OverflowIndicator( - state, - colors = IconButtonDefaults.filledTonalIconButtonColors(), - modifier = Modifier.size(64.dp, 96.dp) - ) - }, - modifier = Modifier.padding(16.dp) - ) { - customItem( - { - FilledIconToggleButton( - onCheckedChange = { checked -> - onAction(TimerAction.ToggleTimer) - - if (checked) haptic.performHapticFeedback(HapticFeedbackType.ToggleOn) - else haptic.performHapticFeedback(HapticFeedbackType.ToggleOff) - - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU && checked) { - permissionLauncher.launch(Manifest.permission.POST_NOTIFICATIONS) - } - }, - checked = timerState.timerRunning, - colors = IconButtonDefaults.filledIconToggleButtonColors( - checkedContainerColor = color, - checkedContentColor = onColor - ), - shapes = IconButtonDefaults.toggleableShapes(), - interactionSource = interactionSources[0], + item { + Column(horizontalAlignment = CenterHorizontally) { + Box(contentAlignment = Alignment.Center) { + if (timerState.timerMode == TimerMode.FOCUS) { + CircularProgressIndicator( + progress = progress, modifier = Modifier - .size(width = 128.dp, height = 96.dp) - .animateWidth(interactionSources[0]) - ) { - if (timerState.timerRunning) { - Icon( - painterResource(R.drawable.pause_large), - contentDescription = stringResource(R.string.pause), - modifier = Modifier.size(32.dp) + .sharedBounds( + sharedContentState = this@TimerScreen.rememberSharedContentState( + "focus progress" + ), + animatedVisibilityScope = LocalNavAnimatedContentScope.current ) - } else { - Icon( - painterResource(R.drawable.play_large), - contentDescription = stringResource(R.string.play), - modifier = Modifier.size(32.dp) + .widthIn(max = 350.dp) + .fillMaxWidth(0.9f) + .aspectRatio(1f), + color = color, + trackColor = colorContainer, + strokeWidth = 16.dp, + gapSize = 8.dp + ) + } else { + CircularWavyProgressIndicator( + progress = progress, + modifier = Modifier + .sharedBounds( + sharedContentState = this@TimerScreen.rememberSharedContentState( + "break progress" + ), + animatedVisibilityScope = LocalNavAnimatedContentScope.current ) - } + .widthIn(max = 350.dp) + .fillMaxWidth(0.9f) + .aspectRatio(1f), + color = color, + trackColor = colorContainer, + stroke = Stroke( + width = with(LocalDensity.current) { + 16.dp.toPx() + }, + cap = StrokeCap.Round, + ), + trackStroke = Stroke( + width = with(LocalDensity.current) { + 16.dp.toPx() + }, + cap = StrokeCap.Round, + ), + wavelength = 60.dp, + gapSize = 8.dp + ) + } + var expanded by remember { mutableStateOf(timerState.showBrandTitle) } + Column( + horizontalAlignment = CenterHorizontally, + modifier = Modifier + .clip(shapes.largeIncreased) + .clickable(onClick = { expanded = !expanded }) + ) { + LaunchedEffect(timerState.showBrandTitle) { + expanded = timerState.showBrandTitle } + Text( + text = timerState.timeStr, + style = TextStyle( + fontFamily = googleFlex600, + fontSize = 72.sp, + letterSpacing = (-2.6).sp, + fontFeatureSettings = "tnum" + ), + textAlign = TextAlign.Center, + maxLines = 1, + modifier = Modifier.sharedBounds( + sharedContentState = this@TimerScreen.rememberSharedContentState( + "clock" + ), + animatedVisibilityScope = LocalNavAnimatedContentScope.current + ) + ) + AnimatedVisibility( + expanded, + enter = fadeIn(motionScheme.defaultEffectsSpec()) + + expandVertically(motionScheme.defaultSpatialSpec()), + exit = fadeOut(motionScheme.defaultEffectsSpec()) + + shrinkVertically(motionScheme.defaultSpatialSpec()) + ) { + Text( + stringResource( + R.string.timer_session_count, + timerState.currentFocusCount, + timerState.totalFocusCount + ), + fontFamily = googleFlex600, + style = typography.titleLarge, + color = colorScheme.outline + ) + } + } + } + val interactionSources = remember { List(3) { MutableInteractionSource() } } + ButtonGroup( + overflowIndicator = { state -> + ButtonGroupDefaults.OverflowIndicator( + state, + colors = IconButtonDefaults.filledTonalIconButtonColors(), + modifier = Modifier.size(64.dp, 96.dp) + ) }, - { state -> - DropdownMenuItem( - leadingIcon = { + modifier = Modifier.padding(16.dp) + ) { + customItem( + { + FilledIconToggleButton( + onCheckedChange = { checked -> + onAction(TimerAction.ToggleTimer) + + if (checked) haptic.performHapticFeedback(HapticFeedbackType.ToggleOn) + else haptic.performHapticFeedback(HapticFeedbackType.ToggleOff) + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU && checked) { + permissionLauncher.launch(Manifest.permission.POST_NOTIFICATIONS) + } + }, + checked = timerState.timerRunning, + colors = IconButtonDefaults.filledIconToggleButtonColors( + checkedContainerColor = color, + checkedContentColor = onColor + ), + shapes = IconButtonDefaults.toggleableShapes(), + interactionSource = interactionSources[0], + modifier = Modifier + .size(width = 128.dp, height = 96.dp) + .animateWidth(interactionSources[0]) + ) { if (timerState.timerRunning) { Icon( - painterResource(R.drawable.pause), - contentDescription = stringResource(R.string.pause) + painterResource(R.drawable.pause_large), + contentDescription = stringResource(R.string.pause), + modifier = Modifier.size(32.dp) ) } else { Icon( - painterResource(R.drawable.play), - contentDescription = stringResource(R.string.play) + painterResource(R.drawable.play_large), + contentDescription = stringResource(R.string.play), + modifier = Modifier.size(32.dp) ) } - }, - text = { - Text( - if (timerState.timerRunning) stringResource(R.string.pause) else stringResource( - R.string.play + } + }, + { state -> + DropdownMenuItem( + leadingIcon = { + if (timerState.timerRunning) { + Icon( + painterResource(R.drawable.pause), + contentDescription = stringResource(R.string.pause) + ) + } else { + Icon( + painterResource(R.drawable.play), + contentDescription = stringResource(R.string.play) + ) + } + }, + text = { + Text( + if (timerState.timerRunning) stringResource(R.string.pause) else stringResource( + R.string.play + ) ) - ) - }, - onClick = { - onAction(TimerAction.ToggleTimer) - state.dismiss() - } - ) - } - ) - - customItem( - { - FilledTonalIconButton( - onClick = { - onAction(TimerAction.ResetTimer) - haptic.performHapticFeedback(HapticFeedbackType.VirtualKey) - }, - colors = IconButtonDefaults.filledTonalIconButtonColors( - containerColor = colorContainer - ), - shapes = IconButtonDefaults.shapes(), - interactionSource = interactionSources[1], - modifier = Modifier - .size(96.dp) - .animateWidth(interactionSources[1]) - ) { - Icon( - painterResource(R.drawable.restart_large), - contentDescription = stringResource(R.string.restart), - modifier = Modifier.size(32.dp) + }, + onClick = { + onAction(TimerAction.ToggleTimer) + state.dismiss() + } ) } - }, - { state -> - DropdownMenuItem( - leadingIcon = { - Icon( - painterResource(R.drawable.restart), - stringResource(R.string.restart) - ) - }, - text = { Text(stringResource(R.string.restart)) }, - onClick = { - onAction(TimerAction.ResetTimer) - state.dismiss() - } - ) - } - ) + ) - customItem( - { - FilledTonalIconButton( - onClick = { - onAction(TimerAction.SkipTimer(fromButton = true)) - haptic.performHapticFeedback(HapticFeedbackType.VirtualKey) - }, - colors = IconButtonDefaults.filledTonalIconButtonColors( - containerColor = colorContainer - ), - shapes = IconButtonDefaults.shapes(), - interactionSource = interactionSources[2], - modifier = Modifier - .size(64.dp, 96.dp) - .animateWidth(interactionSources[2]) - ) { - Icon( - painterResource(R.drawable.skip_next_large), - contentDescription = stringResource(R.string.skip_to_next), - modifier = Modifier.size(32.dp) + customItem( + { + FilledTonalIconButton( + onClick = { + onAction(TimerAction.ResetTimer) + haptic.performHapticFeedback(HapticFeedbackType.VirtualKey) + }, + colors = IconButtonDefaults.filledTonalIconButtonColors( + containerColor = colorContainer + ), + shapes = IconButtonDefaults.shapes(), + interactionSource = interactionSources[1], + modifier = Modifier + .size(96.dp) + .animateWidth(interactionSources[1]) + ) { + Icon( + painterResource(R.drawable.restart_large), + contentDescription = stringResource(R.string.restart), + modifier = Modifier.size(32.dp) + ) + } + }, + { state -> + DropdownMenuItem( + leadingIcon = { + Icon( + painterResource(R.drawable.restart), + stringResource(R.string.restart) + ) + }, + text = { Text(stringResource(R.string.restart)) }, + onClick = { + onAction(TimerAction.ResetTimer) + state.dismiss() + } ) } - }, - { state -> - DropdownMenuItem( - leadingIcon = { + ) + + customItem( + { + FilledTonalIconButton( + onClick = { + onAction(TimerAction.SkipTimer(fromButton = true)) + haptic.performHapticFeedback(HapticFeedbackType.VirtualKey) + }, + colors = IconButtonDefaults.filledTonalIconButtonColors( + containerColor = colorContainer + ), + shapes = IconButtonDefaults.shapes(), + interactionSource = interactionSources[2], + modifier = Modifier + .size(64.dp, 96.dp) + .animateWidth(interactionSources[2]) + ) { Icon( - painterResource(R.drawable.skip_next), - stringResource(R.string.skip_to_next) + painterResource(R.drawable.skip_next_large), + contentDescription = stringResource(R.string.skip_to_next), + modifier = Modifier.size(32.dp) ) - }, - text = { Text(stringResource(R.string.skip_to_next)) }, - onClick = { - onAction(TimerAction.SkipTimer(fromButton = true)) - state.dismiss() } - ) - } - ) + }, + { state -> + DropdownMenuItem( + leadingIcon = { + Icon( + painterResource(R.drawable.skip_next), + stringResource(R.string.skip_to_next) + ) + }, + text = { Text(stringResource(R.string.skip_to_next)) }, + onClick = { + onAction(TimerAction.SkipTimer(fromButton = true)) + state.dismiss() + } + ) + } + ) + } } } - Spacer(Modifier.height(32.dp)) + item { Spacer(Modifier.height(32.dp)) } - Column(horizontalAlignment = CenterHorizontally) { - Text(stringResource(R.string.up_next), style = typography.titleSmall) - AnimatedContent( - timerState.nextTimeStr, - transitionSpec = { - slideInVertically( - animationSpec = motionScheme.defaultSpatialSpec(), - initialOffsetY = { (-it * 1.25).toInt() } - ).togetherWith( - slideOutVertically( + item { + Column(horizontalAlignment = CenterHorizontally) { + Text(stringResource(R.string.up_next), style = typography.titleSmall) + AnimatedContent( + timerState.nextTimeStr, + transitionSpec = { + slideInVertically( animationSpec = motionScheme.defaultSpatialSpec(), - targetOffsetY = { (it * 1.25).toInt() } + initialOffsetY = { (-it * 1.25).toInt() } + ).togetherWith( + slideOutVertically( + animationSpec = motionScheme.defaultSpatialSpec(), + targetOffsetY = { (it * 1.25).toInt() } + ) ) + } + ) { + Text( + it, + style = TextStyle( + fontFamily = googleFlex600, + fontSize = 22.sp, + lineHeight = 28.sp, + color = if (timerState.nextTimerMode == TimerMode.FOCUS) colorScheme.primary else colorScheme.tertiary, + textAlign = TextAlign.Center + ), + modifier = Modifier.width(200.dp) ) } - ) { - Text( - it, - style = TextStyle( - fontFamily = interClock, - fontSize = 22.sp, - lineHeight = 28.sp, - color = if (timerState.nextTimerMode == TimerMode.FOCUS) colorScheme.primary else colorScheme.tertiary, - textAlign = TextAlign.Center - ), - modifier = Modifier.width(200.dp) - ) - } - AnimatedContent( - timerState.nextTimerMode, - transitionSpec = { - slideInVertically( - animationSpec = motionScheme.defaultSpatialSpec(), - initialOffsetY = { (-it * 1.25).toInt() } - ).togetherWith( - slideOutVertically( + AnimatedContent( + timerState.nextTimerMode, + transitionSpec = { + slideInVertically( animationSpec = motionScheme.defaultSpatialSpec(), - targetOffsetY = { (it * 1.25).toInt() } + initialOffsetY = { (-it * 1.25).toInt() } + ).togetherWith( + slideOutVertically( + animationSpec = motionScheme.defaultSpatialSpec(), + targetOffsetY = { (it * 1.25).toInt() } + ) ) + } + ) { + Text( + when (it) { + TimerMode.FOCUS -> stringResource(R.string.focus) + TimerMode.SHORT_BREAK -> stringResource(R.string.short_break) + else -> stringResource(R.string.long_break) + }, + style = typography.titleMediumEmphasized, + textAlign = TextAlign.Center, + modifier = Modifier.width(200.dp) ) } - ) { - Text( - when (it) { - TimerMode.FOCUS -> stringResource(R.string.focus) - TimerMode.SHORT_BREAK -> stringResource(R.string.short_break) - else -> stringResource(R.string.long_break) - }, - style = typography.titleMediumEmphasized, - textAlign = TextAlign.Center, - modifier = Modifier.width(200.dp) - ) } } - Spacer(Modifier.height(16.dp)) + item { Spacer(Modifier.height(16.dp)) } } } } +@OptIn(ExperimentalMaterial3ExpressiveApi::class) @Preview( showSystemUi = true, device = Devices.PIXEL_9_PRO @@ -553,6 +568,7 @@ fun TimerScreenPreview() { TimerScreen( timerState, isPlus = true, + contentPadding = PaddingValues(), { 0.3f }, {} ) diff --git a/app/src/main/java/org/nsh07/pomodoro/ui/timerScreen/viewModel/TimerState.kt b/app/src/main/java/org/nsh07/pomodoro/ui/timerScreen/viewModel/TimerState.kt index 3a3cd3b..5c742d6 100644 --- a/app/src/main/java/org/nsh07/pomodoro/ui/timerScreen/viewModel/TimerState.kt +++ b/app/src/main/java/org/nsh07/pomodoro/ui/timerScreen/viewModel/TimerState.kt @@ -1,8 +1,18 @@ /* * Copyright (c) 2025 Nishant Mishra * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * This file is part of Tomato - a minimalist pomodoro timer for Android. + * + * Tomato is free software: you can redistribute it and/or modify it under the terms of the GNU + * General Public License as published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * Tomato is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even + * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General + * Public License for more details. + * + * You should have received a copy of the GNU General Public License along with Tomato. + * If not, see . */ package org.nsh07.pomodoro.ui.timerScreen.viewModel @@ -17,7 +27,8 @@ data class TimerState( val showBrandTitle: Boolean = true, val currentFocusCount: Int = 1, val totalFocusCount: Int = 4, - val alarmRinging: Boolean = false + val alarmRinging: Boolean = false, + val serviceRunning: Boolean = false ) enum class TimerMode { diff --git a/app/src/main/java/org/nsh07/pomodoro/ui/timerScreen/viewModel/TimerViewModel.kt b/app/src/main/java/org/nsh07/pomodoro/ui/timerScreen/viewModel/TimerViewModel.kt index 318a862..a670b70 100644 --- a/app/src/main/java/org/nsh07/pomodoro/ui/timerScreen/viewModel/TimerViewModel.kt +++ b/app/src/main/java/org/nsh07/pomodoro/ui/timerScreen/viewModel/TimerViewModel.kt @@ -17,8 +17,6 @@ package org.nsh07.pomodoro.ui.timerScreen.viewModel -import android.provider.Settings -import androidx.core.net.toUri import androidx.lifecycle.ViewModel import androidx.lifecycle.ViewModelProvider import androidx.lifecycle.ViewModelProvider.AndroidViewModelFactory.Companion.APPLICATION_KEY @@ -37,122 +35,49 @@ import kotlinx.coroutines.flow.stateIn import kotlinx.coroutines.flow.update import kotlinx.coroutines.launch import org.nsh07.pomodoro.TomatoApplication -import org.nsh07.pomodoro.data.PreferenceRepository import org.nsh07.pomodoro.data.Stat import org.nsh07.pomodoro.data.StatRepository -import org.nsh07.pomodoro.data.TimerRepository +import org.nsh07.pomodoro.data.StateRepository import org.nsh07.pomodoro.service.ServiceHelper -import org.nsh07.pomodoro.utils.millisecondsToStr import java.time.LocalDate import java.time.temporal.ChronoUnit @OptIn(FlowPreview::class) class TimerViewModel( - private val preferenceRepository: PreferenceRepository, private val serviceHelper: ServiceHelper, + private val stateRepository: StateRepository, private val statRepository: StatRepository, - private val timerRepository: TimerRepository, - private val _timerState: MutableStateFlow, private val _time: MutableStateFlow ) : ViewModel() { - val timerState: StateFlow = _timerState.asStateFlow() + val timerState: StateFlow = stateRepository.timerState.asStateFlow() val time: StateFlow = _time.asStateFlow() - val progress = _time.combine(_timerState) { remainingTime, uiState -> + val progress = _time.combine(stateRepository.timerState) { remainingTime, uiState -> (uiState.totalTime.toFloat() - remainingTime) / uiState.totalTime }.stateIn(viewModelScope, SharingStarted.WhileSubscribed(5000), 0f) - private var cycles = 0 - - private var startTime = 0L - private var pauseTime = 0L - private var pauseDuration = 0L - init { - if (!timerRepository.serviceRunning.value) - viewModelScope.launch(Dispatchers.IO) { - timerRepository.focusTime = - preferenceRepository.getIntPreference("focus_time")?.toLong() - ?: preferenceRepository.saveIntPreference( - "focus_time", - timerRepository.focusTime.toInt() - ).toLong() - timerRepository.shortBreakTime = - preferenceRepository.getIntPreference("short_break_time")?.toLong() - ?: preferenceRepository.saveIntPreference( - "short_break_time", - timerRepository.shortBreakTime.toInt() - ).toLong() - timerRepository.longBreakTime = - preferenceRepository.getIntPreference("long_break_time")?.toLong() - ?: preferenceRepository.saveIntPreference( - "long_break_time", - timerRepository.longBreakTime.toInt() - ).toLong() - timerRepository.sessionLength = - preferenceRepository.getIntPreference("session_length") - ?: preferenceRepository.saveIntPreference( - "session_length", - timerRepository.sessionLength - ) + viewModelScope.launch(Dispatchers.IO) { + var lastDate = statRepository.getLastDate() + val today = LocalDate.now() - timerRepository.alarmEnabled = - preferenceRepository.getBooleanPreference("alarm_enabled") - ?: preferenceRepository.saveBooleanPreference("alarm_enabled", true) - timerRepository.vibrateEnabled = - preferenceRepository.getBooleanPreference("vibrate_enabled") - ?: preferenceRepository.saveBooleanPreference("vibrate_enabled", true) - timerRepository.dndEnabled = - preferenceRepository.getBooleanPreference("dnd_enabled") - ?: preferenceRepository.saveBooleanPreference("dnd_enabled", false) - - timerRepository.alarmSoundUri = ( - preferenceRepository.getStringPreference("alarm_sound") - ?: preferenceRepository.saveStringPreference( - "alarm_sound", - (Settings.System.DEFAULT_ALARM_ALERT_URI - ?: Settings.System.DEFAULT_RINGTONE_URI).toString() - ) - ).toUri() - - _time.update { timerRepository.focusTime } - cycles = 0 - startTime = 0L - pauseTime = 0L - pauseDuration = 0L - - _timerState.update { currentState -> - currentState.copy( - timerMode = TimerMode.FOCUS, - timeStr = millisecondsToStr(time.value), - totalTime = time.value, - nextTimerMode = if (timerRepository.sessionLength > 1) TimerMode.SHORT_BREAK else TimerMode.LONG_BREAK, - nextTimeStr = millisecondsToStr(if (timerRepository.sessionLength > 1) timerRepository.shortBreakTime else timerRepository.longBreakTime), - currentFocusCount = 1, - totalFocusCount = timerRepository.sessionLength - ) - } - - var lastDate = statRepository.getLastDate() - val today = LocalDate.now() - - // Fills dates between today and lastDate with 0s to ensure continuous history - if (lastDate != null) { - while (ChronoUnit.DAYS.between(lastDate, today) > 0) { - lastDate = lastDate?.plusDays(1) - statRepository.insertStat(Stat(lastDate!!, 0, 0, 0, 0, 0)) - } - } else { - statRepository.insertStat(Stat(today, 0, 0, 0, 0, 0)) - } - - delay(1500) - - _timerState.update { currentState -> - currentState.copy(showBrandTitle = false) + // Fills dates between today and lastDate with 0s to ensure continuous history + if (lastDate != null) { + while (ChronoUnit.DAYS.between(lastDate, today) > 0) { + lastDate = lastDate?.plusDays(1) + statRepository.insertStat(Stat(lastDate!!, 0, 0, 0, 0, 0)) } + } else { + statRepository.insertStat(Stat(today, 0, 0, 0, 0, 0)) } + + delay(1500) + + stateRepository.timerState.update { currentState -> + currentState.copy(showBrandTitle = false) + } + } } fun onAction(action: TimerAction) { @@ -163,19 +88,15 @@ class TimerViewModel( val Factory: ViewModelProvider.Factory = viewModelFactory { initializer { val application = (this[APPLICATION_KEY] as TomatoApplication) - val appPreferenceRepository = application.container.appPreferenceRepository val appStatRepository = application.container.appStatRepository - val appTimerRepository = application.container.appTimerRepository + val stateRepository = application.container.stateRepository val serviceHelper = application.container.serviceHelper - val timerState = application.container.timerState val time = application.container.time TimerViewModel( - preferenceRepository = appPreferenceRepository, serviceHelper = serviceHelper, + stateRepository = stateRepository, statRepository = appStatRepository, - timerRepository = appTimerRepository, - _timerState = timerState, _time = time ) } diff --git a/app/src/main/java/org/nsh07/pomodoro/utils/Utils.kt b/app/src/main/java/org/nsh07/pomodoro/utils/Utils.kt index 4bbaabf..1497fb8 100644 --- a/app/src/main/java/org/nsh07/pomodoro/utils/Utils.kt +++ b/app/src/main/java/org/nsh07/pomodoro/utils/Utils.kt @@ -1,8 +1,18 @@ /* * Copyright (c) 2025 Nishant Mishra * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * This file is part of Tomato - a minimalist pomodoro timer for Android. + * + * Tomato is free software: you can redistribute it and/or modify it under the terms of the GNU + * General Public License as published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * Tomato is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even + * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General + * Public License for more details. + * + * You should have received a copy of the GNU General Public License along with Tomato. + * If not, see . */ package org.nsh07.pomodoro.utils @@ -21,29 +31,30 @@ fun millisecondsToStr(t: Long): String { ) } -fun millisecondsToHours(t: Long): String { +fun millisecondsToHours(t: Long, format: String = "%dh"): String { require(t >= 0L) return String.format( Locale.getDefault(), - "%dh", + format, TimeUnit.MILLISECONDS.toHours(t) ) } -fun millisecondsToMinutes(t: Long): String { +fun millisecondsToMinutes(t: Long, format: String = "%dm"): String { require(t >= 0L) return String.format( Locale.getDefault(), - "%dm", + format, TimeUnit.MILLISECONDS.toMinutes(t) ) } -fun millisecondsToHoursMinutes(t: Long): String { +fun millisecondsToHoursMinutes(t: Long, format: String = $$"%1$dh %2$dm"): String { require(t >= 0L) return String.format( Locale.getDefault(), - "%dh %dm", TimeUnit.MILLISECONDS.toHours(t), + format, + TimeUnit.MILLISECONDS.toHours(t), TimeUnit.MILLISECONDS.toMinutes(t) % TimeUnit.HOURS.toMinutes(1) ) } @@ -51,10 +62,12 @@ fun millisecondsToHoursMinutes(t: Long): String { /** * Extension function for [String] to convert it to a [androidx.compose.ui.graphics.Color] * - * The base string must be of the format produced by [androidx.compose.ui.graphics.Color.toString], + * The base string MUST be of the format produced by [androidx.compose.ui.graphics.Color.toString], * i.e, the color black with 100% opacity in sRGB would be represented by: * * Color(0.0, 0.0, 0.0, 1.0, sRGB IEC61966-2.1) + * + * The behaviour of this function is undefined if the format is not followed */ fun String.toColor(): Color { // Sample string: Color(0.0, 0.0, 0.0, 1.0, sRGB IEC61966-2.1) @@ -64,8 +77,8 @@ fun String.toColor(): Color { val comma4 = this.indexOf(',', comma3 + 1) val r = this.substringAfter('(').substringBefore(',').toFloat() - val g = this.slice(comma1 + 1..comma2 - 1).toFloat() - val b = this.slice(comma2 + 1..comma3 - 1).toFloat() - val a = this.slice(comma3 + 1..comma4 - 1).toFloat() + val g = this.slice(comma1 + 1.. + android:pathData="M579,480 L285,186q-15,-15 -14.5,-35.5T286,115q15,-15 35.5,-15t35.5,15l307,308q12,12 18,27t6,30q0,15 -6,30t-18,27L356,845q-15,15 -35,14.5T286,844q-15,-15 -15,-35.5t15,-35.5l293,-293Z" /> diff --git a/app/src/main/res/drawable/email.xml b/app/src/main/res/drawable/email.xml new file mode 100644 index 0000000..0301630 --- /dev/null +++ b/app/src/main/res/drawable/email.xml @@ -0,0 +1,26 @@ + + + + + diff --git a/app/src/main/res/drawable/gavel.xml b/app/src/main/res/drawable/gavel.xml new file mode 100644 index 0000000..c34f6cf --- /dev/null +++ b/app/src/main/res/drawable/gavel.xml @@ -0,0 +1,26 @@ + + + + + diff --git a/app/src/main/res/drawable/globe.xml b/app/src/main/res/drawable/globe.xml new file mode 100644 index 0000000..ed04c11 --- /dev/null +++ b/app/src/main/res/drawable/globe.xml @@ -0,0 +1,26 @@ + + + + + diff --git a/app/src/main/res/drawable/ic_launcher_foreground.xml b/app/src/main/res/drawable/ic_launcher_foreground.xml index 5b46f15..257d3b5 100644 --- a/app/src/main/res/drawable/ic_launcher_foreground.xml +++ b/app/src/main/res/drawable/ic_launcher_foreground.xml @@ -1,59 +1,65 @@ + + - - - - - - - - - - - - - - - + android:viewportWidth="25.4" + android:viewportHeight="25.4"> + + + + + + + + + + + + + diff --git a/app/src/main/res/drawable/ic_launcher_monochrome.xml b/app/src/main/res/drawable/ic_launcher_monochrome.xml index 86cd4d3..12c1cdc 100644 --- a/app/src/main/res/drawable/ic_launcher_monochrome.xml +++ b/app/src/main/res/drawable/ic_launcher_monochrome.xml @@ -1,36 +1,37 @@ + + + android:viewportWidth="25.4" + android:viewportHeight="25.4"> - + android:scaleX="0.65" + android:scaleY="0.65" + android:translateX="4.445" + android:translateY="4.445"> - + android:pathData="m8.886,10.709c1.099,-0.071 2.221,-0.352 3.111,-1.026 0.235,-0.192 0.456,-0.401 0.63,-0.651 0.419,0.625 1.098,1.024 1.79,1.283 0.749,0.262 1.543,0.409 2.337,0.402 0.291,-0.012 0.349,-0.376 0.236,-0.59C16.805,9.561 16.476,9.056 16.078,8.617 16.788,8.505 17.494,8.262 18.053,7.797 18.456,7.478 18.812,7.095 19.084,6.658 19.188,6.409 18.993,6.17 18.743,6.139 18.081,5.976 17.398,5.901 16.716,5.92 15.826,5.9 14.939,6.156 14.171,6.6 13.965,6.712 13.786,6.87 13.592,6.995c-0.037,-0.419 0.048,-0.86 0.247,-1.235 0.24,-0.393 0.686,-0.621 1.14,-0.631 0.237,0.002 0.577,-0.004 0.612,-0.31 0.105,-0.481 0.009,-1.022 -0.307,-1.407 -0.192,-0.194 -0.493,-0.074 -0.731,-0.063 -0.688,0.094 -1.381,0.348 -1.865,0.865 -0.396,0.403 -0.639,0.926 -0.773,1.47 -0.107,0.409 -0.157,0.829 -0.208,1.248C10.951,6.318 9.99,5.984 9.023,5.926 8.425,5.91 7.822,5.905 7.234,6.028c-0.273,0.062 -0.576,0.067 -0.818,0.218 -0.267,0.19 -0.063,0.517 0.095,0.704 0.561,0.763 1.384,1.335 2.306,1.562 0.138,0.065 0.557,0.04 0.28,0.228 -0.41,0.44 -0.7,0.984 -0.892,1.551 -0.021,0.434 0.344,0.45 0.68,0.417z" + android:strokeWidth="0.0124219" /> + android:pathData="m13.277,22.081c1.522,-0.097 3.008,-0.593 4.289,-1.416 1.718,-1.096 3.047,-2.838 3.5,-4.839 0.536,-2.224 -0.072,-4.68 -1.562,-6.413 -0.384,-0.451 -1.175,-1.183 -1.334,-1.227 -0.295,0.16 -0.495,0.381 -1.395,0.678 0.271,0.368 0.559,1.008 0.644,1.431 0.07,0.448 -0.354,0.874 -0.803,0.801C15.427,11.036 13.85,10.805 12.624,9.637 11.46,10.755 9.998,11.054 8.509,11.099 8.035,11.096 7.687,10.56 7.869,10.124 8.008,9.661 8.257,9.247 8.509,8.84 8.07,8.655 7.627,8.462 7.233,8.187 5.606,9.335 4.483,11.179 4.217,13.155c-0.215,1.411 0.03,2.882 0.64,4.168 0.585,1.265 1.545,2.338 2.679,3.141 1.327,0.939 2.911,1.498 4.532,1.607 0.402,0.037 0.807,0.019 1.209,0.01z" + android:strokeWidth="0.0124219" /> diff --git a/app/src/main/res/drawable/info.xml b/app/src/main/res/drawable/info.xml index bd589bd..8a56e42 100644 --- a/app/src/main/res/drawable/info.xml +++ b/app/src/main/res/drawable/info.xml @@ -1,10 +1,26 @@ + + diff --git a/app/src/main/res/drawable/music_note.xml b/app/src/main/res/drawable/music_note.xml new file mode 100644 index 0000000..84eb1e9 --- /dev/null +++ b/app/src/main/res/drawable/music_note.xml @@ -0,0 +1,26 @@ + + + + + diff --git a/app/src/main/res/drawable/open_in_browser.xml b/app/src/main/res/drawable/open_in_browser.xml new file mode 100644 index 0000000..0d36045 --- /dev/null +++ b/app/src/main/res/drawable/open_in_browser.xml @@ -0,0 +1,26 @@ + + + + + diff --git a/app/src/main/res/drawable/pfp.xml b/app/src/main/res/drawable/pfp.xml new file mode 100644 index 0000000..6475af5 --- /dev/null +++ b/app/src/main/res/drawable/pfp.xml @@ -0,0 +1,26 @@ + + + + + diff --git a/app/src/main/res/drawable/tomato_logo_notification.xml b/app/src/main/res/drawable/tomato_logo_notification.xml index 1410962..b0333b8 100644 --- a/app/src/main/res/drawable/tomato_logo_notification.xml +++ b/app/src/main/res/drawable/tomato_logo_notification.xml @@ -1,25 +1,31 @@ + android:viewportWidth="25.4" + android:viewportHeight="25.4"> + android:pathData="m8.002,10.249c1.354,-0.088 2.737,-0.434 3.833,-1.264 0.29,-0.236 0.562,-0.494 0.777,-0.802 0.516,0.77 1.353,1.261 2.205,1.58 0.923,0.323 1.901,0.504 2.879,0.495 0.359,-0.014 0.431,-0.463 0.291,-0.727C17.758,8.836 17.353,8.213 16.863,7.673 17.738,7.535 18.607,7.235 19.296,6.662 19.793,6.269 20.231,5.797 20.566,5.259 20.694,4.952 20.454,4.658 20.146,4.62 19.33,4.418 18.489,4.326 17.649,4.35 16.553,4.325 15.459,4.64 14.514,5.188 14.26,5.325 14.039,5.52 13.8,5.674 13.755,5.158 13.859,4.615 14.104,4.152 14.399,3.668 14.949,3.387 15.508,3.374 15.8,3.376 16.219,3.369 16.263,2.993 16.393,2.4 16.274,1.733 15.885,1.259 15.649,1.021 15.277,1.168 14.984,1.182 14.137,1.298 13.283,1.611 12.686,2.248 12.199,2.744 11.899,3.388 11.734,4.058 11.602,4.562 11.54,5.08 11.478,5.596 10.547,4.84 9.362,4.428 8.171,4.357 7.435,4.337 6.692,4.331 5.967,4.483 5.63,4.56 5.258,4.565 4.959,4.752 4.63,4.986 4.882,5.389 5.077,5.619 5.768,6.559 6.782,7.264 7.918,7.543 8.088,7.623 8.605,7.592 8.263,7.825 7.758,8.367 7.401,9.037 7.164,9.736 7.139,10.27 7.588,10.291 8.002,10.249Z" + android:strokeWidth="0.0153039" /> + android:pathData="m13.412,24.26c1.875,-0.119 3.705,-0.731 5.285,-1.745 2.117,-1.351 3.754,-3.496 4.312,-5.961 0.66,-2.74 -0.089,-5.766 -1.925,-7.9 -0.474,-0.556 -1.448,-1.458 -1.643,-1.511 -0.363,0.197 -0.61,0.469 -1.718,0.835 0.334,0.453 0.689,1.242 0.794,1.762 0.087,0.552 -0.437,1.076 -0.989,0.987 -1.466,-0.074 -3.409,-0.359 -4.92,-1.797C11.173,10.306 9.372,10.675 7.538,10.73 6.954,10.726 6.525,10.067 6.75,9.53 6.921,8.958 7.228,8.448 7.538,7.948 6.996,7.719 6.45,7.481 5.965,7.143 3.961,8.557 2.577,10.829 2.25,13.263c-0.265,1.738 0.037,3.551 0.789,5.135 0.721,1.559 1.903,2.88 3.3,3.869 1.634,1.157 3.586,1.845 5.583,1.98 0.495,0.046 0.995,0.024 1.49,0.013z" + android:strokeWidth="0.0153039" /> diff --git a/app/src/main/res/drawable/view_day.xml b/app/src/main/res/drawable/view_day.xml new file mode 100644 index 0000000..d9419ca --- /dev/null +++ b/app/src/main/res/drawable/view_day.xml @@ -0,0 +1,26 @@ + + + + + diff --git a/app/src/main/res/drawable/x.xml b/app/src/main/res/drawable/x.xml new file mode 100644 index 0000000..2f4a6a7 --- /dev/null +++ b/app/src/main/res/drawable/x.xml @@ -0,0 +1,26 @@ + + + + + diff --git a/app/src/main/res/font/inter_bold.ttf b/app/src/main/res/font/inter_bold.ttf deleted file mode 100644 index 9fb9b75..0000000 Binary files a/app/src/main/res/font/inter_bold.ttf and /dev/null differ diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index 34de209..147c97c 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -73,6 +73,6 @@ Sprache wählen Im Play Store bewerten Ausgewählt - Bei der Übersetzung helfen + Hilf beim Übersetzen Den Timer zurücksetzen um Einstellungen zu ändern diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index 9c43c91..ff21f28 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -3,13 +3,13 @@ Iniciar Detener Concentración - Pequeño descanso - Descanso extenso + Descanso corto + Descanso largo Salir Omitir Parar alarma En pausa - Predeterminado del sistema + Sistema Alarma Elige tema Análisis de productividad @@ -18,7 +18,7 @@ Tema negro Utilizar un tema oscuro negro puro Sonar alarma cuando el temporizador finalice - Vibrar + Vibración Vibrar cuando el temporizador finalice Tema Configuración @@ -29,12 +29,12 @@ Hoy Descanso Semana pasada - concentración por día (avg) + concentración por día (promedio) Más información Análisis de productividad semanal Mes pasado Análisis de productividad mensual - Parar alarma? + ¿Parar Alarma? La sesión actual del temporizador ha finalizado. Toque en cualquier lugar para detener la alarma. %1$d de %2$d Más @@ -54,7 +54,24 @@ Esquema de colores Dinámica Color - Luz + Claro Oscuro Año pasado + Apariencia + Duraciones + Sonido + No Molestar + Obtener Tomato+ + Color dinámico + Adapta los colores del tema a tu fondo de pantalla + Idioma + Seleccionar idioma + Seleccionado + Ayudar con la traducción + Always On Display + Toca en cualquier lugar mientras ves el temporizador para cambiar al modo AOD + Activar NM al ejecutar un temporizador de concentración + Todas las funciones están desbloqueadas en esta versión. Si mi aplicación ha marcado una diferencia en tu vida, por favor, considera apoyarme donando en %1$s. + Valorar en Google Play + Reinicia el temporizador para cambiar la configuración diff --git a/app/src/main/res/values-fa/strings.xml b/app/src/main/res/values-fa/strings.xml index 55344e5..998d998 100644 --- a/app/src/main/res/values-fa/strings.xml +++ b/app/src/main/res/values-fa/strings.xml @@ -1,3 +1,8 @@ - \ No newline at end of file + هشدار + زنگ هشدار هنگام پایان تایمر + صدای زنگ + نمایشگر همیشه روشن + روی هر نقطه هنگام مشاهده تایمر ضربه بزنید تا به حالت نمایشگر همیشه روشن (AOD) بروید + diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index e47305a..8e4529b 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -74,6 +74,11 @@ Choisissez la langue Noter sur Google Play Selectionné - Aider pour la traduction + Aider à traduire Tomato Réinitialiser le timer pour pouvoir changer les paramètres + Soutenez-moi avec un petit don + Personnalisez plus avec Tomato+ + A propos + Traduire Tomato dans votre langue + Vous aimez l\'appli? Écrivez un avis! diff --git a/app/src/main/res/values-ja/strings.xml b/app/src/main/res/values-ja/strings.xml index 41af685..73aa1bb 100644 --- a/app/src/main/res/values-ja/strings.xml +++ b/app/src/main/res/values-ja/strings.xml @@ -68,10 +68,19 @@ 言語 言語選択 Google Play で評価 - 翻訳を支援 + Tomato の翻訳を手伝う 設定を変更するにはタイマーをリセットしてください 選択中 タイマー表示中に常時表示ディスプレイに切り替えるには任意の場所をタップしてください タイマーの実行時にサイレントモードをオンにします 全機能がこのバージョンでは解放されています。私のアプリが生活に変化をもたらしたのであれば、%1$s で寄付することで私を支援することをご検討ください。 + %d時%d分 + %d時 + %d分 + について + Tomato をあなたの言語に翻訳してください + アプリが気に入りましたか?レビューを書いてください! + 小さな寄付でご支援してもよろしいでしょうか + Tomato+ を使用してさらにカスタマイズする + ライセンス diff --git a/app/src/main/res/values-mi/strings.xml b/app/src/main/res/values-mi/strings.xml new file mode 100644 index 0000000..3fd4c15 --- /dev/null +++ b/app/src/main/res/values-mi/strings.xml @@ -0,0 +1,85 @@ + + + Wawā + Whakatangihia te wawā inā mutu te kaitaki + Reo wawā + Mata Kikimo-Kore + I te kitenga mai o te kaitaki, pāngia te mata (ki whea nei) kia tīmata a MKK + Mata pango + Kia pango noa atu te āhua mata + Whakatā + Whiriwhiria ngā tae + Whiriwhiria te momo āhua + Tae + Ngā tae + Kua oti + Uriuri + Whitiwhiti + Puta atu + Arotahi + Wā arotahi ia rā (toharite) + I tērā marama + I tērā wiki + I tērā tau + Teatea + Whakatā nui + %1$s meneti e toe ana + Ripōata huanga ā-marama + Nui ake + Whakamārama tonu + KtP + Taihoa + Kua tū + Whakakā + Ko te \"huringa\" ko ētehi wā e takingia - he wāhanga arotahi, he wāhanga whakatā poto, ā, he wāhanga hoki o taua wā e whai whakatā nui ai te tangata. Ko te wā o te whakatā nui te wāhanga whakamutunga o te huringa. + Ripōata huanga + Ko te arotahitanga i tēnā, i tēnā wā o te rā + Tīmata anō + Ko te roa o te huringa + Wā arotahi i te huringa kotahi: %1$d + Tautuhinga + Whakatā poto + Hipa + Whanake atu + Tīmata + Wāhanga whai muri + Ngā tatauranga + Whakamutua + Whakamutua te wawā + Tautokona te whakawhiti reo ki Tomato + Whakahoua te kaitaki ki te tīni tautuhinga + Kua mutu te huringa. Pāngia te mata kia mutu te wawā. + Whakamutua te wāwā? + Pūnaha + Āhua ā-Kano + Kaitaki + Haerenga ā-kaitaki + %1$d o %2$d + Tēnei rā + E whai mai ana + Whai muri mai: %1$s (%2$s) + Ngatari + Ka ngatari inā mutu te kaitaki + Ripōata huanga ā-wiki + Āhua + Wāhanga + Oro + Kaua e Whakakotiti + Whakatūria a Kaua e Whakakotiti i te wā Arotahi + Tikiakegia Tomato+ + Tae whitiwhiti + Whāia ngā tae o tāu mata waea + Kua wātea ngā āheinga katoa ki tēnei putanga. Mēnā he mea whai āwhina i tō ao, tēnā, whakaarohia te tuku koha ki %1$s. + Reo + Whiriwhiri reo + Tohu kounga ki Google Play + Kua whiriwhiria + %dh %dm + %dh + %dm + Mō mātou + Whakawhitia a Tomato ki tō reo + Pai te taupāngā? Tuhia āu whakaaro! + Tautokona au ki te paku koha + He whakahāngaitanga anō ki Tomato+ + diff --git a/app/src/main/res/values-mn/strings.xml b/app/src/main/res/values-mn/strings.xml new file mode 100644 index 0000000..a85ab5b --- /dev/null +++ b/app/src/main/res/values-mn/strings.xml @@ -0,0 +1,23 @@ + + + хонх + Цаг хэмжигч дуусахад хонх дуугаргах + Хонхны дуу + Үргэлж дэлгэц дээр + гадаад төрх + Хар загвар + Завсарлага + Өнгөний схемийг сонгоно уу + Хэл сонгох + загвар сонгох + өнгө + Өнгөний схем + Дууссан + Харанхуй + Бүү саад бол горим + хугацаа + Динамик + Динамик өнгө + Гарах + анхаарлаа төвлөрүүлэх + diff --git a/app/src/main/res/values-pl/strings.xml b/app/src/main/res/values-pl/strings.xml index 52f22d0..9a3cfe2 100644 --- a/app/src/main/res/values-pl/strings.xml +++ b/app/src/main/res/values-pl/strings.xml @@ -15,7 +15,7 @@ Ukończono Ciemny Dynamiczna - Wyjść + Wyjdź Skupienie skupienia w ciągu dnia (średnio) Ostatni miesiąc @@ -23,12 +23,12 @@ Ostatni rok Jasny Długa przerwa - %1$s minut pozostało + pozostało %1$s min Więcej Więcej informacji Ok Wstrzymaj - Wstzymano + Wstrzymano Analiza miesięcznego czasu produktywności Wznów Analiza produktywności @@ -37,13 +37,13 @@ Ustawienia Krótka przerwa Pomiń - Zacznij + Wznów Statystyki - Zakończ + Zatrzymaj Wyłącz alarm - Sesja ukończona, kliknij gdziekolwiek, aby zatrzymać alarm. + Sesja ukończona. Kliknij gdziekolwiek, aby zatrzymać alarm. Zatrzymać alarm? - System + Systemowy Motyw Timer Dziś @@ -53,17 +53,34 @@ Wibruje gdy timer się zakończy Tygodniowa analiza czasu produktywności Wygląd - Długość - Dzwięk + Długość interwałów + Dźwięk Nie przeszkadzać - Włącz tryb nie przeszkadzać podczas sesji skupienia + Włącz tryb Nie przeszkadzać podczas sesji skupienia Język Zaznaczone Dynamiczny kolor Wybierz język Przejdź do następnego %1$d z %2$d - Pomóż w tłumaczeniu aplikacji + Pomóż przetłumaczyć Tomato Wystaw ocenę na Google Play Dostosuj kolory motywu do swojej tapety + Uzyskaj wersję Tomato+ + %dg %dm + %dg + %dm + „Sesja” to szereg interwałów pomodoro, który obejmuje interwały skupienia, krótkie przerwy i długą przerwę. Ostatnia przerwa w sesji to zawsze długa przerwa. + Liczba interwałów skupienia w sesji: %1$d + Czas spędzony w skupieniu o różnych porach dnia + Postęp timera + Zresetuj timer, aby zmienić ustawienia + W tej wersji wszystkie funkcje są odblokowane. Jeśli moja aplikacja zmieniła Twoje życie, rozważ wsparcie mnie poprzez darowiznę na %1$s. + O aplikacji + Przetłumacz Tomato na swój język + Podoba Ci się aplikacja? Napisz recenzję! + Wesprzyj mnie niewielką darowizną + Dodatkowe możliwości z Tomato+ + Licencja + Rozpocznij następny diff --git a/app/src/main/res/values-tr/strings.xml b/app/src/main/res/values-tr/strings.xml index 7df5f57..c297dbc 100644 --- a/app/src/main/res/values-tr/strings.xml +++ b/app/src/main/res/values-tr/strings.xml @@ -73,6 +73,15 @@ Dil seç Google Play\'de değerlendir Seçilen - Çeviriye yardım edin + Tomato\'nun çevirisine yardım edin Ayarları değiştirmek için zamanlayıcıyı sıfırlayın + %dsa %ddk + %dsa + %ddk + Hakkında + Tomato\'yu kendi dilinize çevirin + Uygulamayı beğendinizmi? Bir yorum bırakın! + Beni küçük bir bağışla destekleyin + Tomato+ ile daha fazla özelleştirin + Lisans diff --git a/app/src/main/res/values-uk/strings.xml b/app/src/main/res/values-uk/strings.xml index e344c42..5b34487 100644 --- a/app/src/main/res/values-uk/strings.xml +++ b/app/src/main/res/values-uk/strings.xml @@ -75,5 +75,13 @@ Оцінити на Google Play Обрано Перезапустіть таймер, щоб змінити налаштування - Допомога з перекладом + Допомогти з перекладом Tomato + %dгод %dхв + %dгод + %dхв + Відомості + Перекладіть Tomato на Вашу мову + Сподобався додаток? Напишіть відгук! + Підтримайте мене невеликим пожертвуванням + Налаштуйте ще більше з Tomato+ diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml index cad59f1..a5fcf61 100644 --- a/app/src/main/res/values-zh-rCN/strings.xml +++ b/app/src/main/res/values-zh-rCN/strings.xml @@ -75,4 +75,13 @@ 已选中 帮忙翻译 重置定时器来更改设置 + %1$d 小时 %2$d 分钟 + %1$d 小时 + %1$d 分钟 + 关于 + 将 Tomato 翻译成你的语言 + 喜欢本应用?写一条评价吧! + 小额捐赠支持 + 用 Tomato+ 进一步定制 + 许可证 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 433cd72..0cd5947 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -22,25 +22,40 @@ Always On Display Tap anywhere when viewing the timer to switch to AOD mode Tomato + Tomato+ + Appearance Black theme Use a pure black dark theme + BuyMeACoffee Break Choose color scheme + Choose language Choose theme Color Color scheme Completed Dark + Do Not Disturb + Turn on DND when running a Focus timer + Durations Dynamic + Dynamic color + Adapt theme colors from your wallpaper Exit Focus focus per day (avg) + Get Tomato+ + Help translate Tomato + %1$dh %2$dm + %1$dh + Language Last month Last week Last year Light Long break %1$s min remaining + %1$dm Monthly productivity analysis More More info @@ -51,13 +66,16 @@ A \"session\" is a sequence of pomodoro intervals that contain focus intervals, short break intervals, and a long break interval. The last break of a session is always a long break. Productivity analysis Focus durations at different times of the day + Rate on Google Play Restart + Selected Session length Focus intervals in one session: %1$d Settings Short break Skip Skip to next + Sound Start Start next Stats @@ -70,28 +88,23 @@ Timer Timer progress %1$d of %2$d + Reset the timer to change settings Today + Tomato FOSS + All features are unlocked in this version. If my app made a difference in your life, please consider supporting me by donating on %1$s. Up next Up next: %1$s (%2$s) Vibration Vibrate when a timer completes Weekly productivity analysis - Appearance - Durations - Sound - Do Not Disturb - Turn on DND when running a Focus timer - Tomato+ - Get Tomato+ - Dynamic color - Adapt theme colors from your wallpaper - Tomato FOSS - All features are unlocked in this version. If my app made a difference in your life, please consider supporting me by donating on %1$s. - Language - Choose language - Rate on Google Play - BuyMeACoffee - Selected - Help with translation - Reset the timer to change settings + About + Translate Tomato into your language + Liked the app? Write a review! + Support me with a small donation + Customize further with Tomato+ + License + Headphone mode + Plays on headphones only. If headphones are disconnected, alarm plays through speaker at media volume. + Session-only progress + Show progress for the current session only in notifications, rather than the full sequence. \ No newline at end of file diff --git a/app/src/play/java/org/nsh07/pomodoro/ui/settingsScreen/components/AboutButtons.kt b/app/src/play/java/org/nsh07/pomodoro/ui/settingsScreen/components/AboutButtons.kt index 4b4d724..20e170d 100644 --- a/app/src/play/java/org/nsh07/pomodoro/ui/settingsScreen/components/AboutButtons.kt +++ b/app/src/play/java/org/nsh07/pomodoro/ui/settingsScreen/components/AboutButtons.kt @@ -17,17 +17,12 @@ package org.nsh07.pomodoro.ui.settingsScreen.components -import androidx.compose.foundation.layout.Arrangement -import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.size -import androidx.compose.material3.Button -import androidx.compose.material3.ButtonColors -import androidx.compose.material3.ButtonDefaults import androidx.compose.material3.ExperimentalMaterial3ExpressiveApi import androidx.compose.material3.Icon +import androidx.compose.material3.MaterialTheme.colorScheme import androidx.compose.material3.Text import androidx.compose.runtime.Composable -import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.platform.LocalUriHandler import androidx.compose.ui.res.painterResource @@ -37,56 +32,43 @@ import org.nsh07.pomodoro.R @OptIn(ExperimentalMaterial3ExpressiveApi::class) @Composable -fun TopButton( - buttonColors: ButtonColors, - modifier: Modifier = Modifier -) { +fun TopButton(modifier: Modifier = Modifier) { val uriHandler = LocalUriHandler.current - Button( - colors = buttonColors, - onClick = { uriHandler.openUri("https://hosted.weblate.org/engage/tomato/") }, - shapes = ButtonDefaults.shapes(), - modifier = modifier - ) { - Row( - horizontalArrangement = Arrangement.spacedBy(8.dp), - verticalAlignment = Alignment.CenterVertically - ) { + ClickableListItem( + leadingContent = { Icon( painterResource(R.drawable.weblate), + tint = colorScheme.primary, contentDescription = null, modifier = Modifier.size(24.dp) ) - - Text(text = stringResource(R.string.help_with_translation)) - } - } + }, + headlineContent = { Text(stringResource(R.string.help_with_translation)) }, + supportingContent = { Text(stringResource(R.string.help_with_translation_desc)) }, + trailingContent = { Icon(painterResource(R.drawable.open_in_browser), null) }, + items = 2, + index = 0, + modifier = modifier + ) { uriHandler.openUri("https://hosted.weblate.org/engage/tomato/") } } @OptIn(ExperimentalMaterial3ExpressiveApi::class) @Composable -fun BottomButton( - buttonColors: ButtonColors, - modifier: Modifier = Modifier -) { +fun BottomButton(modifier: Modifier = Modifier) { val uriHandler = LocalUriHandler.current - Button( - colors = buttonColors, - onClick = { uriHandler.openUri("https://play.google.com/store/apps/details?id=org.nsh07.pomodoro") }, - shapes = ButtonDefaults.shapes(), - modifier = modifier - ) { - Row( - horizontalArrangement = Arrangement.spacedBy(8.dp), - verticalAlignment = Alignment.CenterVertically - ) { + ClickableListItem( + leadingContent = { Icon( painterResource(R.drawable.play_store), + tint = colorScheme.secondary, contentDescription = null, modifier = Modifier.size(24.dp) ) - - Text(text = stringResource(R.string.rate_on_google_play)) - } - } + }, + headlineContent = { Text(stringResource(R.string.rate_on_google_play)) }, + supportingContent = { Text(stringResource(R.string.rate_on_google_play_desc)) }, + items = 2, + index = 1, + modifier = modifier + ) { uriHandler.openUri("https://play.google.com/store/apps/details?id=org.nsh07.pomodoro") } } \ No newline at end of file diff --git a/app/src/test/java/org/nsh07/pomodoro/utils/UtilsKtTest.kt b/app/src/test/java/org/nsh07/pomodoro/utils/UtilsKtTest.kt index 21391b1..7447c94 100644 --- a/app/src/test/java/org/nsh07/pomodoro/utils/UtilsKtTest.kt +++ b/app/src/test/java/org/nsh07/pomodoro/utils/UtilsKtTest.kt @@ -1,12 +1,23 @@ /* * Copyright (c) 2025 Nishant Mishra * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * This file is part of Tomato - a minimalist pomodoro timer for Android. + * + * Tomato is free software: you can redistribute it and/or modify it under the terms of the GNU + * General Public License as published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * Tomato is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even + * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General + * Public License for more details. + * + * You should have received a copy of the GNU General Public License along with Tomato. + * If not, see . */ package org.nsh07.pomodoro.utils +import androidx.compose.ui.graphics.Color import junit.framework.TestCase.assertEquals import junit.framework.TestCase.assertTrue import org.junit.Assert.assertThrows @@ -162,4 +173,23 @@ class UtilsKtTest { assertEquals("2562047788015h 12m", millisecondsToHoursMinutes(Long.MAX_VALUE)) } + @Test + fun `toColor with a standard valid color string`() { + assertEquals(Color.Black.toString().toColor(), Color.Black) + } + + @Test + fun `toColor with color components at maximum valid values`() { + assertEquals(Color.White.toString().toColor(), Color.White) + } + + @Test + fun `toColor with floating point values having multiple decimal places`() { + assertEquals( + Color(0.12345f, 0.23456f, 0.34567f, 0.45678f) + .toString() + .toColor(), + Color(0.12345f, 0.23456f, 0.34567f, 0.45678f) + ) + } } \ No newline at end of file diff --git a/fastlane/metadata/android/en-US/changelogs/22.txt b/fastlane/metadata/android/en-US/changelogs/22.txt new file mode 100644 index 0000000..e877867 --- /dev/null +++ b/fastlane/metadata/android/en-US/changelogs/22.txt @@ -0,0 +1,12 @@ +New features: +- New app icon +- New redesigned navigation bar with new animations +- The clock now uses a new font +- New clutter-free settings screen +- New option to only play alarm on headphones if connected +- New option to only show current session's progress (Android 16+ only) + +Fixes: +- Significantly improved stats saving system +- AOD movement is now more subtle +- Navigation bar colors now reflect the current mode \ No newline at end of file diff --git a/fastlane/metadata/android/en-US/images/icon.png b/fastlane/metadata/android/en-US/images/icon.png index 9d77681..ea0c79a 100644 Binary files a/fastlane/metadata/android/en-US/images/icon.png and b/fastlane/metadata/android/en-US/images/icon.png differ diff --git a/fastlane/metadata/android/en-US/images/phoneScreenshots/1.png b/fastlane/metadata/android/en-US/images/phoneScreenshots/1.png index 2e90910..62df7b2 100644 Binary files a/fastlane/metadata/android/en-US/images/phoneScreenshots/1.png and b/fastlane/metadata/android/en-US/images/phoneScreenshots/1.png differ diff --git a/fastlane/metadata/android/en-US/images/phoneScreenshots/2.png b/fastlane/metadata/android/en-US/images/phoneScreenshots/2.png index 9c18d2a..4a5c1ee 100644 Binary files a/fastlane/metadata/android/en-US/images/phoneScreenshots/2.png and b/fastlane/metadata/android/en-US/images/phoneScreenshots/2.png differ diff --git a/fastlane/metadata/android/en-US/images/phoneScreenshots/3.png b/fastlane/metadata/android/en-US/images/phoneScreenshots/3.png index dd44119..8bca69c 100644 Binary files a/fastlane/metadata/android/en-US/images/phoneScreenshots/3.png and b/fastlane/metadata/android/en-US/images/phoneScreenshots/3.png differ diff --git a/fastlane/metadata/android/en-US/images/phoneScreenshots/4.png b/fastlane/metadata/android/en-US/images/phoneScreenshots/4.png index 9b7c222..3a8407d 100644 Binary files a/fastlane/metadata/android/en-US/images/phoneScreenshots/4.png and b/fastlane/metadata/android/en-US/images/phoneScreenshots/4.png differ diff --git a/fastlane/metadata/android/en-US/images/phoneScreenshots/5.png b/fastlane/metadata/android/en-US/images/phoneScreenshots/5.png index 9d09974..8ce962b 100644 Binary files a/fastlane/metadata/android/en-US/images/phoneScreenshots/5.png and b/fastlane/metadata/android/en-US/images/phoneScreenshots/5.png differ diff --git a/fastlane/metadata/android/en-US/images/phoneScreenshots/6.png b/fastlane/metadata/android/en-US/images/phoneScreenshots/6.png index ba10de9..9d09974 100644 Binary files a/fastlane/metadata/android/en-US/images/phoneScreenshots/6.png and b/fastlane/metadata/android/en-US/images/phoneScreenshots/6.png differ diff --git a/fastlane/metadata/android/en-US/images/phoneScreenshots/7.png b/fastlane/metadata/android/en-US/images/phoneScreenshots/7.png new file mode 100644 index 0000000..ba10de9 Binary files /dev/null and b/fastlane/metadata/android/en-US/images/phoneScreenshots/7.png differ diff --git a/fastlane/metadata/android/es-ES/full_description.txt b/fastlane/metadata/android/es-ES/full_description.txt index 4feacf8..3012fd7 100644 --- a/fastlane/metadata/android/es-ES/full_description.txt +++ b/fastlane/metadata/android/es-ES/full_description.txt @@ -1 +1,12 @@ -

Tomato es un temporizador Pomodoro minimalista para Android basado en "Material 3 Expressive".


Características:

  • Interfaz de usuario sencilla y minimalista basada en las últimas directrices de "Material 3 Expressive".
  • Estadísticas detalladas e intuitivas en los tiempos de trabajo/estudio.
    • Estadísticas simples y accesibles del día en curso.
    • Estadísticas de la última semana y del último mes mostradas en un gráfico sencillo.
    • Estadísticas adicionales de la última semana y del último mes que muestran a qué hora del día eres más productivo.
  • Parámetros de temporizador personalizables.
+Tomato es un temporizador Pomodoro minimalista para Android basado en Material 3 Expressive. + +Tomato es totalmente gratuito y de código abierto, para siempre. Puedes encontrar el código fuente e informar de errores o sugerir funciones en https://github.com/nsh07/Tomato. + +Características: +- Interfaz de usuario sencilla y minimalista basada en las últimas directrices de Material 3 Expressive. +- Estadísticas detalladas de los tiempos de trabajo/estudio de forma fácil de entender + - Estadísticas del día actual visibles de un vistazo + - Estadísticas de la última semana y del último mes mostradas en un gráfico claro y fácil de leer + - Estadísticas adicionales de la última semana y del último mes que muestran a qué hora del día eres más productivo +- Parámetros del temporizador personalizables +- Compatibilidad con las Actualizaciones en Directo de Android 16 diff --git a/fastlane/metadata/android/fa-IR/full_description.txt b/fastlane/metadata/android/fa-IR/full_description.txt new file mode 100644 index 0000000..a1ecf48 --- /dev/null +++ b/fastlane/metadata/android/fa-IR/full_description.txt @@ -0,0 +1,13 @@ +Tomato یک تایمر پومودورو مینیمالیستی برای اندروید است که بر پایه Material 3 Expressive ساخته شده است. + +Tomato کاملاً رایگان و متن‌باز است، برای همیشه. می‌توانید سورس‌کد را مشاهده کرده و باگ‌ها را گزارش دهید یا ویژگی‌های جدید پیشنهاد کنید: https://github.com/nsh07/Tomato + +ویژگی‌ها: + +* رابط کاربری ساده و مینیمالیستی بر اساس آخرین راهنماهای Material 3 Expressive +* آمار دقیق زمان‌های کار/مطالعه به شکلی قابل فهم +   - آمار مربوط به امروز در یک نگاه +   - آمار مربوط به هفته و ماه گذشته در قالب نمودار تمیز و خوانا +   - آمار تکمیلی برای هفته و ماه گذشته که نشان می‌دهد در چه زمانی از روز بیشترین بهره‌وری را دارید +* امکان شخصی‌سازی پارامترهای تایمر +* پشتیبانی از Android 16 Live Updates diff --git a/fastlane/metadata/android/fa-IR/short_description.txt b/fastlane/metadata/android/fa-IR/short_description.txt new file mode 100644 index 0000000..3074261 --- /dev/null +++ b/fastlane/metadata/android/fa-IR/short_description.txt @@ -0,0 +1 @@ +تایمر پومودرو مینیمال diff --git a/fastlane/metadata/android/mi/full_description.txt b/fastlane/metadata/android/mi/full_description.txt new file mode 100644 index 0000000..daa68d0 --- /dev/null +++ b/fastlane/metadata/android/mi/full_description.txt @@ -0,0 +1,12 @@ +Ko Tomato tētehi kaitaki ā-Pomodoro māmā mā Android e whai ana i te tikanga hoahoa o Material 3 Expressive. + +He mea “utu-kore, waehere-wātea” (FOSS) a Tomato, mō ake tonu. E taea ana te kite tōna waehere, te whakapānui ngāngara, me te inoi āheinga atu anō ki https://github.com/nsh07/Tomato + +Ōna āhuatanga: +- Hoahoanga māmā e whai ana i te tikanga Material 3 Expressive o te wā +- He tatauranga o ngā wā mahi/ako e āta mārama ana + - He tatauranga mō te rā, e ngāwari ana te kite tere + - He tatauranga mō te wiki me te marama o muri, e horahia ki te kauwhata + - He whakamōhiotanga ā-tatauranga hoki nō te wiki me te marama o muri e pānui ana i ngā wā o te rā e tino pukumahi ai koe +- He tautuhina ā-kaitaki e taea te whakahāngai ki āu hiahia +- He tautoko i te Android 16 Live Updates diff --git a/fastlane/metadata/android/mi/short_description.txt b/fastlane/metadata/android/mi/short_description.txt new file mode 100644 index 0000000..8293367 --- /dev/null +++ b/fastlane/metadata/android/mi/short_description.txt @@ -0,0 +1 @@ +Kaitaki Pomodoro māmā diff --git a/fastlane/metadata/android/mn-MN/short_description.txt b/fastlane/metadata/android/mn-MN/short_description.txt new file mode 100644 index 0000000..ddea2d4 --- /dev/null +++ b/fastlane/metadata/android/mn-MN/short_description.txt @@ -0,0 +1 @@ +Минималист Помодорогийн техник diff --git a/fastlane/metadata/android/pl-PL/full_description.txt b/fastlane/metadata/android/pl-PL/full_description.txt new file mode 100644 index 0000000..d37d0c2 --- /dev/null +++ b/fastlane/metadata/android/pl-PL/full_description.txt @@ -0,0 +1,12 @@ +Tomato to minimalistyczny timer Pomodoro dla systemu Android oparty na Material 3 Expressive. + +Tomato jest całkowicie wolny i otwartoźródłowy, na zawsze. Kod źródłowy oraz możliwość zgłaszania błędów lub sugerowania nowych funkcji można znaleźć na stronie https://github.com/nsh07/Tomato + +Funkcje: +- Prosty, minimalistyczny interfejs użytkownika oparty na najnowszych wytycznych Material 3 Expressive +- Szczegółowe statystyki czasu pracy/nauki przedstawione w przystępny sposób + - Statystyki za bieżący dzień widoczne na pierwszy rzut oka + - Statystyki za ostatni tydzień i ostatni miesiąc przedstawione w przejrzystym, czytelnym wykresie + - Dodatkowe statystyki za ostatni tydzień i miesiąc pokazujące, o której porze dnia jesteś najbardziej produktywny +- Konfigurowalne parametry timera +- Wsparcie dla Android 16 Live Updates diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 4361af8..4f393a3 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,8 +1,8 @@ [versions] -activityCompose = "1.12.0" +activityCompose = "1.12.1" adaptive = "1.2.0" agp = "8.13.1" -composeBom = "2025.11.01" +composeBom = "2025.12.00" coreKtx = "1.17.0" espressoCore = "3.7.0" junit = "4.13.2" @@ -12,7 +12,7 @@ ksp = "2.3.3" lifecycleRuntimeKtx = "2.10.0" materialKolor = "4.0.5" navigation3 = "1.0.0" -revenuecat = "9.14.1" +revenuecat = "9.15.1" room = "2.8.4" vico = "2.3.6"