add new alarms for the next day by default
This commit is contained in:
parent
232361d807
commit
6faf369636
|
@ -3,8 +3,8 @@ package com.simplemobiletools.clock.dialogs
|
|||
import android.app.TimePickerDialog
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.media.AudioManager
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import android.widget.TextView
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import com.simplemobiletools.clock.R
|
||||
import com.simplemobiletools.clock.activities.SimpleActivity
|
||||
import com.simplemobiletools.clock.extensions.*
|
||||
|
|
|
@ -19,6 +19,7 @@ import com.simplemobiletools.commons.extensions.updateTextColors
|
|||
import com.simplemobiletools.commons.models.AlarmSound
|
||||
import kotlinx.android.synthetic.main.fragment_alarm.view.*
|
||||
import java.util.*
|
||||
import kotlin.math.pow
|
||||
|
||||
class AlarmFragment : Fragment(), ToggleAlarmInterface {
|
||||
private var alarms = ArrayList<Alarm>()
|
||||
|
@ -59,6 +60,12 @@ class AlarmFragment : Fragment(), ToggleAlarmInterface {
|
|||
alarm_fab.setOnClickListener {
|
||||
val newAlarm = context.createNewAlarm(DEFAULT_ALARM_MINUTES, 0)
|
||||
newAlarm.isEnabled = true
|
||||
|
||||
val calendar = Calendar.getInstance()
|
||||
calendar.add(Calendar.DAY_OF_WEEK, 1) // set the next alarm to the next day by default
|
||||
val dayOfWeek = (calendar.get(Calendar.DAY_OF_WEEK) + 5) % 7
|
||||
newAlarm.days = 2.0.pow(dayOfWeek).toInt()
|
||||
|
||||
openEditAlarm(newAlarm)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue