add the alarm timepicker
This commit is contained in:
parent
e6e8039284
commit
470bcdb68a
|
@ -1,5 +1,6 @@
|
|||
package com.simplemobiletools.clock.dialogs
|
||||
|
||||
import android.app.TimePickerDialog
|
||||
import android.support.v7.app.AlertDialog
|
||||
import android.widget.TextView
|
||||
import com.simplemobiletools.clock.R
|
||||
|
@ -8,6 +9,7 @@ import com.simplemobiletools.clock.extensions.config
|
|||
import com.simplemobiletools.clock.extensions.formatAlarmTime
|
||||
import com.simplemobiletools.clock.models.Alarm
|
||||
import com.simplemobiletools.commons.extensions.applyColorFilter
|
||||
import com.simplemobiletools.commons.extensions.getDialogTheme
|
||||
import com.simplemobiletools.commons.extensions.moveLastItemToFront
|
||||
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
||||
import kotlinx.android.synthetic.main.dialog_edit_alarm.view.*
|
||||
|
@ -17,10 +19,11 @@ class EditAlarmDialog(val activity: SimpleActivity, val alarm: Alarm, val callba
|
|||
|
||||
init {
|
||||
val textColor = activity.config.textColor
|
||||
view.apply {
|
||||
edit_alarm_time.text = alarm.timeInMinutes.formatAlarmTime()
|
||||
edit_alarm_time.setOnClickListener {
|
||||
updateAlarmTime()
|
||||
|
||||
view.apply {
|
||||
edit_alarm_time.setOnClickListener {
|
||||
TimePickerDialog(context, context.getDialogTheme(), timeSetListener, alarm.timeInMinutes / 60, alarm.timeInMinutes % 60, context.config.use24hourFormat).show()
|
||||
}
|
||||
|
||||
colorLeftDrawable(edit_alarm_sound, textColor)
|
||||
|
@ -68,6 +71,15 @@ class EditAlarmDialog(val activity: SimpleActivity, val alarm: Alarm, val callba
|
|||
}
|
||||
}
|
||||
|
||||
private val timeSetListener = TimePickerDialog.OnTimeSetListener { view, hourOfDay, minute ->
|
||||
alarm.timeInMinutes = hourOfDay * 60 + minute
|
||||
updateAlarmTime()
|
||||
}
|
||||
|
||||
private fun updateAlarmTime() {
|
||||
view.edit_alarm_time.text = alarm.timeInMinutes.formatAlarmTime()
|
||||
}
|
||||
|
||||
private fun dialogConfirmed() {
|
||||
callback()
|
||||
}
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
package com.simplemobiletools.clock.models
|
||||
|
||||
data class Alarm(val id: Int, val timeInMinutes: Int, var days: Int, val isEnabled: Boolean, val vibrate: Boolean, val soundUri: String, val label: String)
|
||||
data class Alarm(val id: Int, var timeInMinutes: Int, var days: Int, var isEnabled: Boolean, var vibrate: Boolean, var soundUri: String, var label: String)
|
||||
|
|
Loading…
Reference in New Issue