From 7df773c4d9006358918600d9996b6e4b5ac41928 Mon Sep 17 00:00:00 2001 From: darthpaul Date: Fri, 24 Sep 2021 00:05:00 +0100 Subject: [PATCH] fix timer max reminder duration, format App file --- .../main/kotlin/com/simplemobiletools/clock/App.kt | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/clock/App.kt b/app/src/main/kotlin/com/simplemobiletools/clock/App.kt index e97244a9..4a937da8 100644 --- a/app/src/main/kotlin/com/simplemobiletools/clock/App.kt +++ b/app/src/main/kotlin/com/simplemobiletools/clock/App.kt @@ -5,15 +5,15 @@ import android.app.NotificationManager import android.content.Context import android.os.Build import android.os.CountDownTimer +import android.os.Handler +import android.os.Looper import androidx.annotation.RequiresApi import androidx.lifecycle.Lifecycle import androidx.lifecycle.LifecycleObserver import androidx.lifecycle.OnLifecycleEvent import androidx.lifecycle.ProcessLifecycleOwner import com.facebook.stetho.Stetho -import com.simplemobiletools.clock.extensions.getOpenTimerTabIntent -import com.simplemobiletools.clock.extensions.getTimerNotification -import com.simplemobiletools.clock.extensions.timerHelper +import com.simplemobiletools.clock.extensions.* import com.simplemobiletools.clock.models.TimerEvent import com.simplemobiletools.clock.models.TimerState import com.simplemobiletools.clock.services.TimerStopService @@ -76,7 +76,7 @@ class App : Application(), LifecycleObserver { @Subscribe(threadMode = ThreadMode.MAIN) fun onMessageEvent(event: TimerEvent.Delete) { countDownTimers[event.timerId]?.cancel() - timerHelper.deleteTimer(event.timerId){ + timerHelper.deleteTimer(event.timerId) { EventBus.getDefault().post(TimerEvent.Refresh) } } @@ -104,6 +104,9 @@ class App : Application(), LifecycleObserver { val notificationManager = getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager notificationManager.notify(event.timerId, notification) updateTimerState(event.timerId, TimerState.Finished) + Handler(Looper.getMainLooper()).postDelayed({ + hideNotification(event.timerId) + }, config.timerMaxReminderSecs * 1000L) } }