Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.ccextractor.uac_companion

import com.ccextractor.uac_companion.Utils.Preferences

import android.app.*
import android.content.*
import android.os.Build
Expand Down Expand Up @@ -33,7 +35,11 @@ class AlarmSnoozeReceiver : BroadcastReceiver() {
// Reschedule the alarm 5 minute ahead
val alarmManager = context.getSystemService(Context.ALARM_SERVICE) as AlarmManager
// val triggerAtMillis = System.currentTimeMillis() + 300_000
val triggerAtMillis = System.currentTimeMillis() + 300_000

//Preferences.kt added and AlarmSnoozeReceiver updated.
val snoozeMinutes = Preferences.getSnoozeDurationMinutes(context)
val triggerAtMillis = System.currentTimeMillis() + snoozeMinutes * 60 * 1000


val snoozeIntent = Intent(context, AlarmBroadcastReceiver::class.java).apply {
// putExtra("alarmId", alarmId)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.ccextractor.uac_companion.Utils

import android.content.Context

object Preferences {

private const val PREF_NAME = "uac_companion_prefs"
private const val KEY_SNOOZE_DURATION_MINUTES = "snooze_duration_minutes"
private const val DEFAULT_SNOOZE_MINUTES = 5

fun getSnoozeDurationMinutes(context: Context): Int {
val prefs = context.getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE)
return prefs.getInt(KEY_SNOOZE_DURATION_MINUTES, DEFAULT_SNOOZE_MINUTES)
}

fun setSnoozeDurationMinutes(context: Context, minutes: Int) {
val prefs = context.getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE)
prefs.edit().putInt(KEY_SNOOZE_DURATION_MINUTES, minutes).apply()
}
}