mirror of
https://github.com/SimpleMobileTools/Simple-Clock.git
synced 2025-04-05 06:11:01 +02:00
add the alarm timepicker
This commit is contained in:
parent
e6e8039284
commit
470bcdb68a
@ -1,5 +1,6 @@
|
|||||||
package com.simplemobiletools.clock.dialogs
|
package com.simplemobiletools.clock.dialogs
|
||||||
|
|
||||||
|
import android.app.TimePickerDialog
|
||||||
import android.support.v7.app.AlertDialog
|
import android.support.v7.app.AlertDialog
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import com.simplemobiletools.clock.R
|
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.extensions.formatAlarmTime
|
||||||
import com.simplemobiletools.clock.models.Alarm
|
import com.simplemobiletools.clock.models.Alarm
|
||||||
import com.simplemobiletools.commons.extensions.applyColorFilter
|
import com.simplemobiletools.commons.extensions.applyColorFilter
|
||||||
|
import com.simplemobiletools.commons.extensions.getDialogTheme
|
||||||
import com.simplemobiletools.commons.extensions.moveLastItemToFront
|
import com.simplemobiletools.commons.extensions.moveLastItemToFront
|
||||||
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
||||||
import kotlinx.android.synthetic.main.dialog_edit_alarm.view.*
|
import kotlinx.android.synthetic.main.dialog_edit_alarm.view.*
|
||||||
@ -17,10 +19,11 @@ class EditAlarmDialog(val activity: SimpleActivity, val alarm: Alarm, val callba
|
|||||||
|
|
||||||
init {
|
init {
|
||||||
val textColor = activity.config.textColor
|
val textColor = activity.config.textColor
|
||||||
view.apply {
|
updateAlarmTime()
|
||||||
edit_alarm_time.text = alarm.timeInMinutes.formatAlarmTime()
|
|
||||||
edit_alarm_time.setOnClickListener {
|
|
||||||
|
|
||||||
|
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)
|
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() {
|
private fun dialogConfirmed() {
|
||||||
callback()
|
callback()
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
package com.simplemobiletools.clock.models
|
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…
x
Reference in New Issue
Block a user