11/*
22 * Copyright (c) 2025 Nishant Mishra
33 *
4- * You should have received a copy of the GNU General Public License
5- * along with this program. If not, see <https://www.gnu.org/licenses/>.
4+ * This file is part of Tomato - a minimalist pomodoro timer for Android.
5+ *
6+ * Tomato is free software: you can redistribute it and/or modify it under the terms of the GNU
7+ * General Public License as published by the Free Software Foundation, either version 3 of the
8+ * License, or (at your option) any later version.
9+ *
10+ * Tomato is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
11+ * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
12+ * Public License for more details.
13+ *
14+ * You should have received a copy of the GNU General Public License along with Tomato.
15+ * If not, see <https://www.gnu.org/licenses/>.
616 */
717
818package org.nsh07.pomodoro.ui
@@ -76,6 +86,7 @@ import kotlin.random.Random
7686fun SharedTransitionScope.AlwaysOnDisplay (
7787 timerState : TimerState ,
7888 progress : () -> Float ,
89+ setTimerFrequency : (Float ) -> Unit ,
7990 modifier : Modifier = Modifier
8091) {
8192 var sharedElementTransitionComplete by remember { mutableStateOf(false ) }
@@ -89,6 +100,7 @@ fun SharedTransitionScope.AlwaysOnDisplay(
89100 val insetsController = remember { WindowCompat .getInsetsController(window, view) }
90101
91102 DisposableEffect (Unit ) {
103+ setTimerFrequency(1f )
92104 window.addFlags(
93105 WindowManager .LayoutParams .FLAG_KEEP_SCREEN_ON or
94106 WindowManager .LayoutParams .FLAG_ALLOW_LOCK_WHILE_SCREEN_ON
@@ -102,6 +114,7 @@ fun SharedTransitionScope.AlwaysOnDisplay(
102114 }
103115
104116 onDispose {
117+ setTimerFrequency(10f )
105118 window.clearFlags(
106119 WindowManager .LayoutParams .FLAG_KEEP_SCREEN_ON or
107120 WindowManager .LayoutParams .FLAG_ALLOW_LOCK_WHILE_SCREEN_ON
@@ -263,7 +276,8 @@ private fun AlwaysOnDisplayPreview() {
263276 SharedTransitionLayout {
264277 AlwaysOnDisplay (
265278 timerState = timerState,
266- progress = progress
279+ progress = progress,
280+ setTimerFrequency = {}
267281 )
268282 }
269283 }
0 commit comments