diff --git a/app/build.gradle b/app/build.gradle
index 81933cbd..5dbb43bd 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -41,7 +41,7 @@ android {
}
dependencies {
- implementation 'com.simplemobiletools:commons:3.15.11'
+ implementation 'com.simplemobiletools:commons:3.15.12'
implementation 'com.facebook.stetho:stetho:1.5.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.shawnlin:number-picker:2.4.6'
diff --git a/app/src/main/kotlin/com/simplemobiletools/clock/activities/SettingsActivity.kt b/app/src/main/kotlin/com/simplemobiletools/clock/activities/SettingsActivity.kt
index 7fa2eedb..975c7262 100644
--- a/app/src/main/kotlin/com/simplemobiletools/clock/activities/SettingsActivity.kt
+++ b/app/src/main/kotlin/com/simplemobiletools/clock/activities/SettingsActivity.kt
@@ -3,7 +3,9 @@ package com.simplemobiletools.clock.activities
import android.os.Bundle
import com.simplemobiletools.clock.R
import com.simplemobiletools.clock.extensions.config
+import com.simplemobiletools.clock.helpers.DEFAULT_MAX_ALARM_REMINDER_SECS
import com.simplemobiletools.commons.extensions.*
+import com.simplemobiletools.commons.helpers.MINUTE_SECONDS
import kotlinx.android.synthetic.main.activity_settings.*
import java.util.*
@@ -22,6 +24,7 @@ class SettingsActivity : SimpleActivity() {
setupPreventPhoneFromSleeping()
setupShowSeconds()
setupDisplayOtherTimeZones()
+ setupAlarmMaxReminder()
setupUseSameSnooze()
setupSnoozeTime()
setupVibrate()
@@ -84,6 +87,16 @@ class SettingsActivity : SimpleActivity() {
}
}
+ private fun setupAlarmMaxReminder() {
+ updateAlarmMaxReminderText()
+ settings_alarm_max_reminder_holder.setOnClickListener {
+ showPickSecondsDialog(config.alarmMaxReminderSecs, true, true) {
+ config.alarmMaxReminderSecs = if (it != 0) it else DEFAULT_MAX_ALARM_REMINDER_SECS
+ updateAlarmMaxReminderText()
+ }
+ }
+ }
+
private fun setupUseSameSnooze() {
settings_snooze_time_holder.beVisibleIf(config.useSameSnooze)
settings_use_same_snooze.isChecked = config.useSameSnooze
@@ -97,8 +110,8 @@ class SettingsActivity : SimpleActivity() {
private fun setupSnoozeTime() {
updateSnoozeText()
settings_snooze_time_holder.setOnClickListener {
- showPickIntervalDialog(config.snoozeTime, true) {
- config.snoozeTime = it
+ showPickSecondsDialog(config.snoozeTime * MINUTE_SECONDS, true) {
+ config.snoozeTime = it / MINUTE_SECONDS
updateSnoozeText()
}
}
@@ -112,6 +125,10 @@ class SettingsActivity : SimpleActivity() {
}
}
+ private fun updateAlarmMaxReminderText() {
+ settings_alarm_max_reminder.text = formatSecondsToTimeString(config.alarmMaxReminderSecs)
+ }
+
private fun updateSnoozeText() {
settings_snooze_time.text = formatMinutesToTimeString(config.snoozeTime)
}
diff --git a/app/src/main/kotlin/com/simplemobiletools/clock/activities/SnoozeReminderActivity.kt b/app/src/main/kotlin/com/simplemobiletools/clock/activities/SnoozeReminderActivity.kt
index f0854742..f92adf98 100644
--- a/app/src/main/kotlin/com/simplemobiletools/clock/activities/SnoozeReminderActivity.kt
+++ b/app/src/main/kotlin/com/simplemobiletools/clock/activities/SnoozeReminderActivity.kt
@@ -7,7 +7,8 @@ import com.simplemobiletools.clock.extensions.dbHelper
import com.simplemobiletools.clock.extensions.hideNotification
import com.simplemobiletools.clock.extensions.setupAlarmClock
import com.simplemobiletools.clock.helpers.ALARM_ID
-import com.simplemobiletools.commons.extensions.showPickIntervalDialog
+import com.simplemobiletools.commons.extensions.showPickSecondsDialog
+import com.simplemobiletools.commons.helpers.MINUTE_SECONDS
class SnoozeReminderActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
@@ -15,9 +16,9 @@ class SnoozeReminderActivity : AppCompatActivity() {
val id = intent.getIntExtra(ALARM_ID, -1)
val alarm = dbHelper.getAlarmWithId(id) ?: return
hideNotification(id)
- showPickIntervalDialog(config.snoozeTime, true, cancelCallback = { dialogCancelled() }) {
- config.snoozeTime = it
- setupAlarmClock(alarm, it * 60)
+ showPickSecondsDialog(config.snoozeTime * MINUTE_SECONDS, true, cancelCallback = { dialogCancelled() }) {
+ config.snoozeTime = it * 60
+ setupAlarmClock(alarm, it)
finishActivity()
}
}
diff --git a/app/src/main/kotlin/com/simplemobiletools/clock/helpers/Config.kt b/app/src/main/kotlin/com/simplemobiletools/clock/helpers/Config.kt
index f71612f1..708d8720 100644
--- a/app/src/main/kotlin/com/simplemobiletools/clock/helpers/Config.kt
+++ b/app/src/main/kotlin/com/simplemobiletools/clock/helpers/Config.kt
@@ -41,4 +41,8 @@ class Config(context: Context) : BaseConfig(context) {
var timerSoundTitle: String
get() = prefs.getString(TIMER_SOUND_TITLE, context.getDefaultAlarmTitle())
set(timerSoundTitle) = prefs.edit().putString(TIMER_SOUND_TITLE, timerSoundTitle).apply()
+
+ var alarmMaxReminderSecs: Int
+ get() = prefs.getInt(ALARM_MAX_REMINDER_SECS, DEFAULT_MAX_ALARM_REMINDER_SECS)
+ set(alarmMaxReminderSecs) = prefs.edit().putInt(ALARM_MAX_REMINDER_SECS, alarmMaxReminderSecs).apply()
}
diff --git a/app/src/main/kotlin/com/simplemobiletools/clock/helpers/Constants.kt b/app/src/main/kotlin/com/simplemobiletools/clock/helpers/Constants.kt
index e772f848..3d653915 100644
--- a/app/src/main/kotlin/com/simplemobiletools/clock/helpers/Constants.kt
+++ b/app/src/main/kotlin/com/simplemobiletools/clock/helpers/Constants.kt
@@ -11,6 +11,7 @@ const val TIMER_SECONDS = "timer_seconds"
const val TIMER_VIBRATE = "timer_vibrate"
const val TIMER_SOUND_URI = "timer_sound_uri"
const val TIMER_SOUND_TITLE = "timer_sound_title"
+const val ALARM_MAX_REMINDER_SECS = "alarm_max_reminder_secs"
const val TABS_COUNT = 4
const val EDITED_TIME_ZONE_SEPARATOR = ":"
@@ -18,6 +19,7 @@ const val ALARM_ID = "alarm_id"
const val DEFAULT_ALARM_MINUTES = 480
const val DAY_MINUTES = 1440
const val TIMER_NOTIF_ID = 9999
+const val DEFAULT_MAX_ALARM_REMINDER_SECS = 300
const val SORT_BY_LAP = 1
const val SORT_BY_LAP_TIME = 2
diff --git a/app/src/main/kotlin/com/simplemobiletools/clock/receivers/AlarmReceiver.kt b/app/src/main/kotlin/com/simplemobiletools/clock/receivers/AlarmReceiver.kt
index 47f608ac..d5bf62b8 100644
--- a/app/src/main/kotlin/com/simplemobiletools/clock/receivers/AlarmReceiver.kt
+++ b/app/src/main/kotlin/com/simplemobiletools/clock/receivers/AlarmReceiver.kt
@@ -24,8 +24,6 @@ import com.simplemobiletools.commons.helpers.isLollipopPlus
import com.simplemobiletools.commons.helpers.isOreoPlus
class AlarmReceiver : BroadcastReceiver() {
- private val NOTIFICATION_DISAPPEAR_MS = 600000L
-
override fun onReceive(context: Context, intent: Intent) {
val id = intent.getIntExtra(ALARM_ID, -1)
val alarm = context.dbHelper.getAlarmWithId(id) ?: return
@@ -38,7 +36,7 @@ class AlarmReceiver : BroadcastReceiver() {
Handler().postDelayed({
context.hideNotification(id)
- }, NOTIFICATION_DISAPPEAR_MS)
+ }, context.config.alarmMaxReminderSecs * 1000L)
}
@SuppressLint("NewApi")
@@ -73,7 +71,7 @@ class AlarmReceiver : BroadcastReceiver() {
}
if (alarm.vibrate) {
- val vibrateArray = LongArray((NOTIFICATION_DISAPPEAR_MS / 500).toInt()) { 500 }
+ val vibrateArray = LongArray(context.config.alarmMaxReminderSecs * 2) { 500 }
builder.setVibrate(vibrateArray)
}
diff --git a/app/src/main/res/layout/activity_settings.xml b/app/src/main/res/layout/activity_settings.xml
index 495b1b15..912d0bcb 100644
--- a/app/src/main/res/layout/activity_settings.xml
+++ b/app/src/main/res/layout/activity_settings.xml
@@ -184,6 +184,41 @@
android:textAllCaps="true"
android:textSize="@dimen/smaller_text_size"/>
+
+
+
+
+
+
+
+