From 8ce20514b1eae9d4713ec94ceb5b028ef2f92697 Mon Sep 17 00:00:00 2001 From: pudup Date: Sun, 27 Aug 2023 15:14:35 +0530 Subject: [PATCH 1/2] Fix #490 --- .../clock/activities/ReminderActivity.kt | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/clock/activities/ReminderActivity.kt b/app/src/main/kotlin/com/simplemobiletools/clock/activities/ReminderActivity.kt index 8e09c79e..537e82c2 100644 --- a/app/src/main/kotlin/com/simplemobiletools/clock/activities/ReminderActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/clock/activities/ReminderActivity.kt @@ -14,6 +14,7 @@ import com.simplemobiletools.clock.R import com.simplemobiletools.clock.databinding.ActivityReminderBinding import com.simplemobiletools.clock.extensions.* import com.simplemobiletools.clock.helpers.ALARM_ID +import com.simplemobiletools.clock.helpers.ALARM_NOTIF_ID import com.simplemobiletools.clock.helpers.getPassedSeconds import com.simplemobiletools.clock.models.Alarm import com.simplemobiletools.commons.extensions.* @@ -39,6 +40,7 @@ class ReminderActivity : SimpleActivity() { private var initialAlarmVolume: Int? = null private var dragDownX = 0f private val binding: ActivityReminderBinding by viewBinding(ActivityReminderBinding::inflate) + private var finished = false override fun onCreate(savedInstanceState: Bundle?) { isMaterialActivity = true @@ -229,7 +231,13 @@ class ReminderActivity : SimpleActivity() { maxReminderDurationHandler.removeCallbacksAndMessages(null) swipeGuideFadeHandler.removeCallbacksAndMessages(null) vibrationHandler.removeCallbacksAndMessages(null) - destroyEffects() + if (!finished) { + finishActivity() + notificationManager.cancel(ALARM_NOTIF_ID) + } else { + destroyEffects() + } + } private fun destroyEffects() { @@ -265,6 +273,7 @@ class ReminderActivity : SimpleActivity() { scheduleNextAlarm(alarm!!, false) } + finished = true destroyEffects() finish() overridePendingTransition(0, 0) From da8002a6eb28746ac02696df85b971e0fc4f76ca Mon Sep 17 00:00:00 2001 From: pudup Date: Sun, 27 Aug 2023 15:14:35 +0530 Subject: [PATCH 2/2] Fix #502 --- .../clock/activities/ReminderActivity.kt | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/clock/activities/ReminderActivity.kt b/app/src/main/kotlin/com/simplemobiletools/clock/activities/ReminderActivity.kt index 8e09c79e..537e82c2 100644 --- a/app/src/main/kotlin/com/simplemobiletools/clock/activities/ReminderActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/clock/activities/ReminderActivity.kt @@ -14,6 +14,7 @@ import com.simplemobiletools.clock.R import com.simplemobiletools.clock.databinding.ActivityReminderBinding import com.simplemobiletools.clock.extensions.* import com.simplemobiletools.clock.helpers.ALARM_ID +import com.simplemobiletools.clock.helpers.ALARM_NOTIF_ID import com.simplemobiletools.clock.helpers.getPassedSeconds import com.simplemobiletools.clock.models.Alarm import com.simplemobiletools.commons.extensions.* @@ -39,6 +40,7 @@ class ReminderActivity : SimpleActivity() { private var initialAlarmVolume: Int? = null private var dragDownX = 0f private val binding: ActivityReminderBinding by viewBinding(ActivityReminderBinding::inflate) + private var finished = false override fun onCreate(savedInstanceState: Bundle?) { isMaterialActivity = true @@ -229,7 +231,13 @@ class ReminderActivity : SimpleActivity() { maxReminderDurationHandler.removeCallbacksAndMessages(null) swipeGuideFadeHandler.removeCallbacksAndMessages(null) vibrationHandler.removeCallbacksAndMessages(null) - destroyEffects() + if (!finished) { + finishActivity() + notificationManager.cancel(ALARM_NOTIF_ID) + } else { + destroyEffects() + } + } private fun destroyEffects() { @@ -265,6 +273,7 @@ class ReminderActivity : SimpleActivity() { scheduleNextAlarm(alarm!!, false) } + finished = true destroyEffects() finish() overridePendingTransition(0, 0)