handle Snooze at Reminder activity
This commit is contained in:
parent
3c5fe3b935
commit
f827645522
|
@ -8,6 +8,7 @@ import com.simplemobiletools.clock.extensions.*
|
|||
import com.simplemobiletools.clock.helpers.ALARM_ID
|
||||
import com.simplemobiletools.clock.models.Alarm
|
||||
import com.simplemobiletools.commons.extensions.*
|
||||
import com.simplemobiletools.commons.helpers.MINUTE_SECONDS
|
||||
import kotlinx.android.synthetic.main.activity_reminder.*
|
||||
|
||||
class ReminderActivity : SimpleActivity() {
|
||||
|
@ -70,6 +71,20 @@ class ReminderActivity : SimpleActivity() {
|
|||
}
|
||||
|
||||
private fun snoozeClicked() {
|
||||
if (config.useSameSnooze) {
|
||||
setupAlarmClock(alarm!!, config.snoozeTime * MINUTE_SECONDS)
|
||||
finishActivity()
|
||||
} else {
|
||||
showPickSecondsDialog(config.snoozeTime * MINUTE_SECONDS, true, cancelCallback = { finishActivity() }) {
|
||||
config.snoozeTime = it / MINUTE_SECONDS
|
||||
setupAlarmClock(alarm!!, it)
|
||||
finishActivity()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun finishActivity() {
|
||||
finish()
|
||||
overridePendingTransition(0, 0)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ class SnoozeReminderActivity : AppCompatActivity() {
|
|||
val alarm = dbHelper.getAlarmWithId(id) ?: return
|
||||
hideNotification(id)
|
||||
showPickSecondsDialog(config.snoozeTime * MINUTE_SECONDS, true, cancelCallback = { dialogCancelled() }) {
|
||||
config.snoozeTime = it * 60
|
||||
config.snoozeTime = it / MINUTE_SECONDS
|
||||
setupAlarmClock(alarm, it)
|
||||
finishActivity()
|
||||
}
|
||||
|
|
|
@ -305,6 +305,7 @@ fun Context.getHideTimerPendingIntent(): PendingIntent {
|
|||
|
||||
fun Context.getHideAlarmPendingIntent(alarm: Alarm): PendingIntent {
|
||||
val intent = Intent(this, HideAlarmReceiver::class.java)
|
||||
intent.putExtra(ALARM_ID, alarm.id)
|
||||
return PendingIntent.getBroadcast(this, alarm.id, intent, PendingIntent.FLAG_UPDATE_CURRENT)
|
||||
}
|
||||
|
||||
|
|
|
@ -9,13 +9,14 @@ import com.simplemobiletools.clock.extensions.hideNotification
|
|||
import com.simplemobiletools.clock.extensions.setupAlarmClock
|
||||
import com.simplemobiletools.clock.helpers.ALARM_ID
|
||||
import com.simplemobiletools.clock.helpers.HIDE_REMINDER_ACTIVITY
|
||||
import com.simplemobiletools.commons.helpers.MINUTE_SECONDS
|
||||
|
||||
class SnoozeService : IntentService("Snooze") {
|
||||
override fun onHandleIntent(intent: Intent) {
|
||||
val id = intent.getIntExtra(ALARM_ID, -1)
|
||||
val alarm = dbHelper.getAlarmWithId(id) ?: return
|
||||
hideNotification(id)
|
||||
setupAlarmClock(alarm, config.snoozeTime * 60)
|
||||
setupAlarmClock(alarm, config.snoozeTime * MINUTE_SECONDS)
|
||||
|
||||
if (intent.getBooleanExtra(HIDE_REMINDER_ACTIVITY, false)) {
|
||||
Intent(this, ReminderActivity::class.java).apply {
|
||||
|
|
Loading…
Reference in New Issue