diff --git a/app/build.gradle b/app/build.gradle
index 2d26bc2..46c5e2f 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -41,7 +41,7 @@ android {
}
dependencies {
- implementation 'com.simplemobiletools:commons:3.15.4'
+ implementation 'com.simplemobiletools:commons:3.15.6'
implementation 'com.facebook.stetho:stetho:1.5.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
}
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 e4a4971..3036d1b 100644
--- a/app/src/main/kotlin/com/simplemobiletools/clock/activities/SettingsActivity.kt
+++ b/app/src/main/kotlin/com/simplemobiletools/clock/activities/SettingsActivity.kt
@@ -3,10 +3,7 @@ package com.simplemobiletools.clock.activities
import android.os.Bundle
import com.simplemobiletools.clock.R
import com.simplemobiletools.clock.extensions.config
-import com.simplemobiletools.commons.extensions.beVisibleIf
-import com.simplemobiletools.commons.extensions.getAdjustedPrimaryColor
-import com.simplemobiletools.commons.extensions.updateTextColors
-import com.simplemobiletools.commons.extensions.useEnglishToggled
+import com.simplemobiletools.commons.extensions.*
import kotlinx.android.synthetic.main.activity_settings.*
import java.util.*
@@ -25,13 +22,15 @@ class SettingsActivity : SimpleActivity() {
setupPreventPhoneFromSleeping()
setupShowSeconds()
setupDisplayOtherTimeZones()
+ setupUseSameSnooze()
+ setupSnoozeTime()
updateTextColors(settings_holder)
setupSectionColors()
}
private fun setupSectionColors() {
val adjustedPrimaryColor = getAdjustedPrimaryColor()
- arrayListOf(clock_tab_label).forEach {
+ arrayListOf(clock_tab_label, alarm_tab_label).forEach {
it.setTextColor(adjustedPrimaryColor)
}
}
@@ -83,4 +82,28 @@ class SettingsActivity : SimpleActivity() {
config.displayOtherTimeZones = settings_display_other_timezones.isChecked
}
}
+
+ private fun setupUseSameSnooze() {
+ settings_snooze_time_holder.beVisibleIf(config.useSameSnooze)
+ settings_use_same_snooze.isChecked = config.useSameSnooze
+ settings_use_same_snooze_holder.setOnClickListener {
+ settings_use_same_snooze.toggle()
+ config.useSameSnooze = settings_use_same_snooze.isChecked
+ settings_snooze_time_holder.beVisibleIf(config.useSameSnooze)
+ }
+ }
+
+ private fun setupSnoozeTime() {
+ updateSnoozeText()
+ settings_snooze_time_holder.setOnClickListener {
+ showPickIntervalDialog(config.snoozeTime, true) {
+ config.snoozeTime = it
+ updateSnoozeText()
+ }
+ }
+ }
+
+ private fun updateSnoozeText() {
+ settings_snooze_time.text = formatMinutesToTimeString(config.snoozeTime)
+ }
}
diff --git a/app/src/main/kotlin/com/simplemobiletools/clock/extensions/Context.kt b/app/src/main/kotlin/com/simplemobiletools/clock/extensions/Context.kt
index 5b01549..9d09f1d 100644
--- a/app/src/main/kotlin/com/simplemobiletools/clock/extensions/Context.kt
+++ b/app/src/main/kotlin/com/simplemobiletools/clock/extensions/Context.kt
@@ -14,6 +14,7 @@ import com.simplemobiletools.clock.models.Alarm
import com.simplemobiletools.clock.models.AlarmSound
import com.simplemobiletools.clock.models.MyTimeZone
import com.simplemobiletools.clock.receivers.AlarmReceiver
+import com.simplemobiletools.commons.extensions.formatMinutesToTimeString
import com.simplemobiletools.commons.extensions.toast
import com.simplemobiletools.commons.helpers.isLollipopPlus
import java.util.*
@@ -105,27 +106,8 @@ fun Context.scheduleNextAlarm(alarm: Alarm, showToast: Boolean) {
}
}
-fun Context.showRemainingTimeMessage(triggerInMinutes: Int) {
- val days = triggerInMinutes / DAY_MINUTES
- val hours = (triggerInMinutes % DAY_MINUTES) / 60
- val minutes = triggerInMinutes % 60
- val timesString = StringBuilder()
- if (days > 0) {
- val daysString = String.format(resources.getQuantityString(R.plurals.days, days, days))
- timesString.append("$daysString, ")
- }
-
- if (hours > 0) {
- val hoursString = String.format(resources.getQuantityString(R.plurals.hours, hours, hours))
- timesString.append("$hoursString, ")
- }
-
- if (minutes > 0) {
- val minutesString = String.format(resources.getQuantityString(R.plurals.minutes, minutes, minutes))
- timesString.append(minutesString)
- }
-
- val fullString = String.format(getString(R.string.alarm_goes_off_in), timesString.toString().trim().trimEnd(','))
+fun Context.showRemainingTimeMessage(totalMinutes: Int) {
+ val fullString = String.format(getString(R.string.alarm_goes_off_in), formatMinutesToTimeString(totalMinutes))
toast(fullString, Toast.LENGTH_LONG)
}
diff --git a/app/src/main/kotlin/com/simplemobiletools/clock/services/SnoozeService.kt b/app/src/main/kotlin/com/simplemobiletools/clock/services/SnoozeService.kt
index 5eb4209..325b8f1 100644
--- a/app/src/main/kotlin/com/simplemobiletools/clock/services/SnoozeService.kt
+++ b/app/src/main/kotlin/com/simplemobiletools/clock/services/SnoozeService.kt
@@ -1,10 +1,21 @@
package com.simplemobiletools.clock.services
import android.app.IntentService
+import android.app.NotificationManager
+import android.content.Context
import android.content.Intent
+import com.simplemobiletools.clock.extensions.config
+import com.simplemobiletools.clock.extensions.dbHelper
+import com.simplemobiletools.clock.extensions.setupAlarmClock
+import com.simplemobiletools.clock.helpers.ALARM_ID
class SnoozeService : IntentService("Snooze") {
override fun onHandleIntent(intent: Intent) {
+ val id = intent.getIntExtra(ALARM_ID, -1)
+ val alarm = dbHelper.getAlarmWithId(id) ?: return
+ setupAlarmClock(alarm, config.snoozeTime * 60)
+ val manager = applicationContext.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
+ manager.cancel(alarm.id)
}
}
diff --git a/app/src/main/res/layout/activity_settings.xml b/app/src/main/res/layout/activity_settings.xml
index fc0de15..8969d9c 100644
--- a/app/src/main/res/layout/activity_settings.xml
+++ b/app/src/main/res/layout/activity_settings.xml
@@ -165,5 +165,81 @@
android:text="@string/display_other_time_zones"/>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+