scheduleReminder in seconds
This commit is contained in:
parent
e14cdd7c2a
commit
aee036e200
|
@ -348,7 +348,7 @@ class CarbsDialog : DialogFragmentWithDate() {
|
|||
})
|
||||
}
|
||||
if (useAlarm && carbs > 0 && timeOffset > 0) {
|
||||
carbTimer.scheduleReminder(dateUtil.now() + T.mins(timeOffset.toLong()).msecs())
|
||||
carbTimer.scheduleReminder(T.mins(timeOffset.toLong()).secs())
|
||||
}
|
||||
}, null)
|
||||
}
|
||||
|
|
|
@ -24,8 +24,8 @@ class CarbTimer @Inject constructor(
|
|||
private val timerUtil: TimerUtil
|
||||
) {
|
||||
|
||||
fun scheduleReminder(time: Long, text: String? = null) =
|
||||
timerUtil.scheduleReminder(time, text ?: rh.gs(R.string.timetoeat))
|
||||
fun scheduleReminder(seconds: Long, text: String? = null) =
|
||||
timerUtil.scheduleReminder(seconds, text ?: rh.gs(R.string.timetoeat))
|
||||
|
||||
fun scheduleEatReminder() {
|
||||
val event = AutomationEvent(injector).apply {
|
||||
|
|
|
@ -456,7 +456,7 @@ class BolusWizard @Inject constructor(
|
|||
|
||||
}
|
||||
if (useAlarm && carbs > 0 && carbTime > 0) {
|
||||
carbTimer.scheduleReminder(dateUtil.now() + T.mins(carbTime.toLong()).msecs())
|
||||
carbTimer.scheduleReminder(T.mins(carbTime.toLong()).secs())
|
||||
}
|
||||
}
|
||||
})
|
||||
|
|
|
@ -38,7 +38,7 @@ class ActionAlarm(injector: HasAndroidInjector) : Action(injector) {
|
|||
override fun isValid(): Boolean = true // empty alarm will show app name
|
||||
|
||||
override fun doAction(callback: Callback) {
|
||||
timerUtil.scheduleReminder(dateUtil.now() + T.secs(10L).msecs(), text.value.takeIf { it.isNotBlank() }
|
||||
timerUtil.scheduleReminder(10, text.value.takeIf { it.isNotBlank() }
|
||||
?: rh.gs(R.string.app_name))
|
||||
callback.result(PumpEnactResult(injector).success(true).comment(R.string.ok))?.run()
|
||||
}
|
||||
|
|
|
@ -15,13 +15,15 @@ class TimerUtil @Inject constructor(
|
|||
private val dateUtil: DateUtil
|
||||
) {
|
||||
|
||||
fun scheduleReminder(time: Long, text: String? = null) {
|
||||
/**
|
||||
* Schedule alarm in @seconds
|
||||
*/
|
||||
fun scheduleReminder(seconds: Long, text: String) {
|
||||
Intent(AlarmClock.ACTION_SET_TIMER).apply {
|
||||
val length: Int = ((time - dateUtil.now()) / 1000).toInt()
|
||||
flags = flags or Intent.FLAG_ACTIVITY_NEW_TASK
|
||||
putExtra(AlarmClock.EXTRA_LENGTH, length)
|
||||
putExtra(AlarmClock.EXTRA_LENGTH, seconds)
|
||||
putExtra(AlarmClock.EXTRA_SKIP_UI, true)
|
||||
putExtra(AlarmClock.EXTRA_MESSAGE, text ?: rh.gs(R.string.app_name))
|
||||
putExtra(AlarmClock.EXTRA_MESSAGE, text)
|
||||
context.startActivity(this)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue