show the alarm reliability disclaimer at creating a new alarm

This commit is contained in:
tibbi 2021-04-19 12:27:50 +02:00
parent f507f18c50
commit 5167a36cb5
1 changed files with 16 additions and 6 deletions

View File

@ -14,6 +14,7 @@ import com.simplemobiletools.clock.helpers.TODAY_BIT
import com.simplemobiletools.clock.helpers.TOMORROW_BIT
import com.simplemobiletools.clock.helpers.getCurrentDayMinutes
import com.simplemobiletools.clock.models.Alarm
import com.simplemobiletools.commons.dialogs.ConfirmationDialog
import com.simplemobiletools.commons.dialogs.SelectAlarmSoundDialog
import com.simplemobiletools.commons.extensions.*
import com.simplemobiletools.commons.models.AlarmSound
@ -42,12 +43,12 @@ class EditAlarmDialog(val activity: SimpleActivity, val alarm: Alarm, val callba
updateSelectedAlarmSound(it)
}
}, onAlarmSoundDeleted = {
if (alarm.soundUri == it.uri) {
val defaultAlarm = context.getDefaultAlarmSound(RingtoneManager.TYPE_ALARM)
updateSelectedAlarmSound(defaultAlarm)
}
activity.checkAlarmsWithDeletedSoundUri(it.uri)
})
if (alarm.soundUri == it.uri) {
val defaultAlarm = context.getDefaultAlarmSound(RingtoneManager.TYPE_ALARM)
updateSelectedAlarmSound(defaultAlarm)
}
activity.checkAlarmsWithDeletedSoundUri(it.uri)
})
}
edit_alarm_vibrate.colorLeftDrawable(textColor)
@ -101,6 +102,15 @@ class EditAlarmDialog(val activity: SimpleActivity, val alarm: Alarm, val callba
.create().apply {
activity.setupDialogStuff(view, this) {
getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
if (!activity.config.wasAlarmWarningShown) {
ConfirmationDialog(activity, messageId = R.string.alarm_warning, positive = R.string.ok, negative = 0) {
activity.config.wasAlarmWarningShown = true
it.performClick()
}
return@setOnClickListener
}
if (alarm.days <= 0) {
alarm.days = if (alarm.timeInMinutes > getCurrentDayMinutes()) {
TODAY_BIT