From 174a1627c38027d7069c777e93902644b8f49a31 Mon Sep 17 00:00:00 2001 From: Nishant Mishra Date: Mon, 20 Oct 2025 11:24:53 +0530 Subject: [PATCH 1/4] docs(readme): update README with Star History section --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index ce25364..1562443 100644 --- a/README.md +++ b/README.md @@ -137,6 +137,7 @@ This app was made possible by the following libraries: Navigation - [Room](https://developer.android.com/jetpack/androidx/releases/room) - SQLite Database - [Vico](https://github.com/patrykandpatrick/vico) - Graphs and charts +- [MaterialKolor](https://github.com/jordond/materialkolor)- Material 3 color schemes ### Fonts: @@ -145,3 +146,9 @@ This app was made possible by the following libraries: - [Open Runde](https://github.com/lauridskern/open-runde) by Laurids Kern
+ +## Star History + +Please give this repo a star if you liked my work + +[![Star History Chart](https://app.repohistory.com/api/svg?repo=nsh07/Tomato&type=Date&background=F9FAEF&color=4C662B)](https://app.repohistory.com/star-history) From 75d3029250f2c76d918e22962d21a9e8fabe1fcf Mon Sep 17 00:00:00 2001 From: Fandroid745 Date: Tue, 21 Oct 2025 18:47:53 +0530 Subject: [PATCH 2/4] feat:fix screen wake up when timer ends --- app/src/main/AndroidManifest.xml | 1 + .../java/org/nsh07/pomodoro/MainActivity.kt | 3 +- .../nsh07/pomodoro/service/TimerService.kt | 27 +++++++++- .../pomodoro/ui/timerScreen/AlarmDialog.kt | 49 +++++++++++++++++++ 4 files changed, 78 insertions(+), 2 deletions(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 19ff772..84c8ae7 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -7,6 +7,7 @@ + = Build.VERSION_CODES.S) { val vibratorManager = getSystemService(VIBRATOR_MANAGER_SERVICE) as VibratorManager @@ -89,6 +95,7 @@ class TimerService : Service() { saveTimeToDb() notificationManager.cancel(1) alarm?.release() + wakeLock?.release() } super.onDestroy() } @@ -117,6 +124,7 @@ class TimerService : Service() { return super.onStartCommand(intent, flags, startId) } + @Suppress("DEPRECATION") private fun toggleTimer() { updateProgressSegments() @@ -157,6 +165,20 @@ class TimerService : Service() { if (iterations == 0) showTimerNotification(time.toInt()) if (time < 0) { + val powerManager = this@TimerService.getSystemService(POWER_SERVICE) as PowerManager + wakeLock = powerManager.newWakeLock( + PowerManager.FULL_WAKE_LOCK or + PowerManager.ACQUIRE_CAUSES_WAKEUP or + PowerManager.ON_AFTER_RELEASE, + "PomodoroApp:AlarmWakeLock" + ) + wakeLock?.acquire(2 * 60 * 1000L) + val intent = Intent(this@TimerService, MainActivity::class.java).apply { + addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_SINGLE_TOP) + } + startActivity(intent) + + skipTimer() _timerState.update { currentState -> currentState.copy(timerRunning = false) @@ -176,7 +198,7 @@ class TimerService : Service() { } } - @SuppressLint("MissingPermission") // We check for the permission when pressing the Play button in the UI + @SuppressLint("MissingPermission", "StringFormatInvalid") // We check for the permission when pressing the Play button in the UI fun showTimerNotification( remainingTime: Int, paused: Boolean = false, complete: Boolean = false ) { @@ -372,6 +394,9 @@ class TimerService : Service() { vibrator.cancel() } + wakeLock?.release() + wakeLock = null + _timerState.update { currentState -> currentState.copy(alarmRinging = false) } diff --git a/app/src/main/java/org/nsh07/pomodoro/ui/timerScreen/AlarmDialog.kt b/app/src/main/java/org/nsh07/pomodoro/ui/timerScreen/AlarmDialog.kt index 9b27779..d41c27e 100644 --- a/app/src/main/java/org/nsh07/pomodoro/ui/timerScreen/AlarmDialog.kt +++ b/app/src/main/java/org/nsh07/pomodoro/ui/timerScreen/AlarmDialog.kt @@ -7,6 +7,11 @@ package org.nsh07.pomodoro.ui.timerScreen +import android.app.Activity +import android.content.Context +import android.content.ContextWrapper +import android.os.Build +import android.view.WindowManager import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Spacer @@ -24,8 +29,10 @@ import androidx.compose.material3.Surface import androidx.compose.material3.Text import androidx.compose.material3.TextButton import androidx.compose.runtime.Composable +import androidx.compose.runtime.DisposableEffect import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier +import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.dp @@ -37,6 +44,38 @@ fun AlarmDialog( modifier: Modifier = Modifier, stopAlarm: () -> Unit ) { + val context = LocalContext.current + val activity = context.findActivity() + + // Set lockscreen flags when dialog appears, remove when it disappears + DisposableEffect(Unit) { + // Show over lockscreen + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) { + activity?.setShowWhenLocked(true) + activity?.setTurnScreenOn(true) + } else { + @Suppress("DEPRECATION") + activity?.window?.addFlags( + WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED or + WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON + ) + } + + onDispose { + // Remove lockscreen flags when dialog is dismissed + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) { + activity?.setShowWhenLocked(false) + activity?.setTurnScreenOn(false) + } else { + @Suppress("DEPRECATION") + activity?.window?.clearFlags( + WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED or + WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON + ) + } + } + } + BasicAlertDialog( onDismissRequest = stopAlarm, modifier = modifier @@ -75,4 +114,14 @@ fun AlarmDialog( } } } +} + +// Add this helper function at the file level (outside the composable) +fun Context.findActivity(): Activity? { + var context = this + while (context is ContextWrapper) { + if (context is Activity) return context + context = context.baseContext + } + return null } \ No newline at end of file From 8e47b11ad2569c66673ba0c110a17f9832d3b890 Mon Sep 17 00:00:00 2001 From: Fandroid745 Date: Tue, 21 Oct 2025 21:48:30 +0530 Subject: [PATCH 3/4] fix:added the requried changes --- .../nsh07/pomodoro/service/TimerService.kt | 7 ++- .../pomodoro/ui/timerScreen/AlarmDialog.kt | 43 +++---------------- 2 files changed, 9 insertions(+), 41 deletions(-) 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 8408b6d..fc104ab 100644 --- a/app/src/main/java/org/nsh07/pomodoro/service/TimerService.kt +++ b/app/src/main/java/org/nsh07/pomodoro/service/TimerService.kt @@ -2,7 +2,6 @@ package org.nsh07.pomodoro.service import android.annotation.SuppressLint import android.app.Service -import android.content.Context import android.content.Intent import android.media.AudioAttributes import android.media.MediaPlayer @@ -124,7 +123,7 @@ class TimerService : Service() { return super.onStartCommand(intent, flags, startId) } - @Suppress("DEPRECATION") + private fun toggleTimer() { updateProgressSegments() @@ -167,8 +166,8 @@ class TimerService : Service() { if (time < 0) { val powerManager = this@TimerService.getSystemService(POWER_SERVICE) as PowerManager wakeLock = powerManager.newWakeLock( - PowerManager.FULL_WAKE_LOCK or - PowerManager.ACQUIRE_CAUSES_WAKEUP or + PowerManager.SCREEN_BRIGHT_WAKE_LOCK or + PowerManager.ACQUIRE_CAUSES_WAKEUP or PowerManager.ON_AFTER_RELEASE, "PomodoroApp:AlarmWakeLock" ) diff --git a/app/src/main/java/org/nsh07/pomodoro/ui/timerScreen/AlarmDialog.kt b/app/src/main/java/org/nsh07/pomodoro/ui/timerScreen/AlarmDialog.kt index d41c27e..ed39a73 100644 --- a/app/src/main/java/org/nsh07/pomodoro/ui/timerScreen/AlarmDialog.kt +++ b/app/src/main/java/org/nsh07/pomodoro/ui/timerScreen/AlarmDialog.kt @@ -7,11 +7,7 @@ package org.nsh07.pomodoro.ui.timerScreen -import android.app.Activity -import android.content.Context -import android.content.ContextWrapper -import android.os.Build -import android.view.WindowManager +import androidx.activity.compose.LocalActivity import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Spacer @@ -32,7 +28,6 @@ import androidx.compose.runtime.Composable import androidx.compose.runtime.DisposableEffect import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier -import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.dp @@ -44,35 +39,18 @@ fun AlarmDialog( modifier: Modifier = Modifier, stopAlarm: () -> Unit ) { - val context = LocalContext.current - val activity = context.findActivity() + val activity = LocalActivity.current // Set lockscreen flags when dialog appears, remove when it disappears DisposableEffect(Unit) { // Show over lockscreen - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) { - activity?.setShowWhenLocked(true) - activity?.setTurnScreenOn(true) - } else { - @Suppress("DEPRECATION") - activity?.window?.addFlags( - WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED or - WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON - ) - } + activity?.setShowWhenLocked(true) + activity?.setTurnScreenOn(true) onDispose { // Remove lockscreen flags when dialog is dismissed - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) { - activity?.setShowWhenLocked(false) - activity?.setTurnScreenOn(false) - } else { - @Suppress("DEPRECATION") - activity?.window?.clearFlags( - WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED or - WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON - ) - } + activity?.setShowWhenLocked(false) + activity?.setTurnScreenOn(false) } } @@ -116,12 +94,3 @@ fun AlarmDialog( } } -// Add this helper function at the file level (outside the composable) -fun Context.findActivity(): Activity? { - var context = this - while (context is ContextWrapper) { - if (context is Activity) return context - context = context.baseContext - } - return null -} \ No newline at end of file From 920d9112af9c40753ae6d6a9fa6f1f8f16b8fd34 Mon Sep 17 00:00:00 2001 From: Nishant Mishra Date: Wed, 22 Oct 2025 11:48:32 +0530 Subject: [PATCH 4/4] Revert "docs(readme): update README with Star History section" This reverts commit 174a1627c38027d7069c777e93902644b8f49a31. --- README.md | 7 ------- 1 file changed, 7 deletions(-) diff --git a/README.md b/README.md index 1562443..ce25364 100644 --- a/README.md +++ b/README.md @@ -137,7 +137,6 @@ This app was made possible by the following libraries: Navigation - [Room](https://developer.android.com/jetpack/androidx/releases/room) - SQLite Database - [Vico](https://github.com/patrykandpatrick/vico) - Graphs and charts -- [MaterialKolor](https://github.com/jordond/materialkolor)- Material 3 color schemes ### Fonts: @@ -146,9 +145,3 @@ This app was made possible by the following libraries: - [Open Runde](https://github.com/lauridskern/open-runde) by Laurids Kern
- -## Star History - -Please give this repo a star if you liked my work - -[![Star History Chart](https://app.repohistory.com/api/svg?repo=nsh07/Tomato&type=Date&background=F9FAEF&color=4C662B)](https://app.repohistory.com/star-history)