mirror of
				https://github.com/SimpleMobileTools/Simple-Clock.git
				synced 2025-06-05 22:19:17 +02:00 
			
		
		
		
	disable today/tomorrow alarms on dismiss
This commit is contained in:
		| @@ -244,9 +244,6 @@ fun Context.showAlarmNotification(alarm: Alarm) { | |||||||
|  |  | ||||||
|     if (alarm.days > 0) { |     if (alarm.days > 0) { | ||||||
|         scheduleNextAlarm(alarm, false) |         scheduleNextAlarm(alarm, false) | ||||||
|     } else { |  | ||||||
|         dbHelper.updateAlarmEnabledState(alarm.id, false) |  | ||||||
|         updateWidgets() |  | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -3,12 +3,23 @@ package com.simplemobiletools.clock.receivers | |||||||
| import android.content.BroadcastReceiver | import android.content.BroadcastReceiver | ||||||
| import android.content.Context | import android.content.Context | ||||||
| import android.content.Intent | import android.content.Intent | ||||||
|  | import com.simplemobiletools.clock.extensions.dbHelper | ||||||
| import com.simplemobiletools.clock.extensions.hideNotification | import com.simplemobiletools.clock.extensions.hideNotification | ||||||
|  | import com.simplemobiletools.clock.extensions.updateWidgets | ||||||
| import com.simplemobiletools.clock.helpers.ALARM_ID | import com.simplemobiletools.clock.helpers.ALARM_ID | ||||||
|  | import com.simplemobiletools.commons.helpers.ensureBackgroundThread | ||||||
|  |  | ||||||
| class HideAlarmReceiver : BroadcastReceiver() { | class HideAlarmReceiver : BroadcastReceiver() { | ||||||
|     override fun onReceive(context: Context, intent: Intent) { |     override fun onReceive(context: Context, intent: Intent) { | ||||||
|         val id = intent.getIntExtra(ALARM_ID, -1) |         val id = intent.getIntExtra(ALARM_ID, -1) | ||||||
|         context.hideNotification(id) |         context.hideNotification(id) | ||||||
|  |  | ||||||
|  |         ensureBackgroundThread { | ||||||
|  |             val alarm = context.dbHelper.getAlarmWithId(id) | ||||||
|  |             if (alarm != null && alarm.days < 0) { | ||||||
|  |                 context.dbHelper.updateAlarmEnabledState(alarm.id, false) | ||||||
|  |                 context.updateWidgets() | ||||||
|  |             } | ||||||
|  |         } | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user