use system countdown for simple reminder all the time
This commit is contained in:
parent
8b24becac7
commit
b9bf699942
2 changed files with 8 additions and 27 deletions
|
@ -14,45 +14,26 @@ import info.nightscout.androidaps.plugins.general.automation.elements.InputDelta
|
||||||
import info.nightscout.androidaps.plugins.general.automation.triggers.TriggerBg
|
import info.nightscout.androidaps.plugins.general.automation.triggers.TriggerBg
|
||||||
import info.nightscout.androidaps.plugins.general.automation.triggers.TriggerConnector
|
import info.nightscout.androidaps.plugins.general.automation.triggers.TriggerConnector
|
||||||
import info.nightscout.androidaps.plugins.general.automation.triggers.TriggerDelta
|
import info.nightscout.androidaps.plugins.general.automation.triggers.TriggerDelta
|
||||||
import info.nightscout.androidaps.plugins.general.automation.triggers.TriggerTime
|
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
|
||||||
import java.text.DecimalFormat
|
import java.text.DecimalFormat
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
import javax.inject.Singleton
|
import javax.inject.Singleton
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
class CarbTimer @Inject constructor(
|
class CarbTimer @Inject constructor(
|
||||||
private val sp: SP,
|
|
||||||
private val context: Context,
|
private val context: Context,
|
||||||
private val injector: HasAndroidInjector,
|
private val injector: HasAndroidInjector,
|
||||||
private val resourceHelper: ResourceHelper,
|
private val resourceHelper: ResourceHelper,
|
||||||
private val automationPlugin: AutomationPlugin
|
private val automationPlugin: AutomationPlugin
|
||||||
) {
|
) {
|
||||||
|
|
||||||
fun scheduleReminder(time: Long) {
|
fun scheduleReminder(time: Long) = Intent(AlarmClock.ACTION_SET_TIMER).apply {
|
||||||
if (sp.getBoolean(R.string.key_raise_notifications_as_android_notifications, true)) {
|
val length: Int = ((time - DateUtil.now()) / 1000).toInt()
|
||||||
Intent(AlarmClock.ACTION_SET_TIMER).apply {
|
flags = flags or Intent.FLAG_ACTIVITY_NEW_TASK
|
||||||
val length: Int = ((time - DateUtil.now()) / 1000).toInt()
|
putExtra(AlarmClock.EXTRA_LENGTH, length)
|
||||||
flags = flags or Intent.FLAG_ACTIVITY_NEW_TASK
|
putExtra(AlarmClock.EXTRA_SKIP_UI, true)
|
||||||
putExtra(AlarmClock.EXTRA_LENGTH, length)
|
putExtra(AlarmClock.EXTRA_MESSAGE, resourceHelper.gs(R.string.timetoeat))
|
||||||
putExtra(AlarmClock.EXTRA_SKIP_UI, true)
|
context.startActivity(this)
|
||||||
putExtra(AlarmClock.EXTRA_MESSAGE, resourceHelper.gs(R.string.timetoeat))
|
|
||||||
context.startActivity(this)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
AutomationEvent(injector).apply {
|
|
||||||
title = resourceHelper.gs(R.string.timetoeat)
|
|
||||||
readOnly = true
|
|
||||||
systemAction = true
|
|
||||||
autoRemove = true
|
|
||||||
trigger = TriggerConnector(injector, TriggerConnector.Type.AND).apply {
|
|
||||||
list.add(TriggerTime(injector, time))
|
|
||||||
}
|
|
||||||
actions.add(ActionAlarm(injector, resourceHelper.gs(R.string.timetoeat)))
|
|
||||||
automationPlugin.addIfNotExists(this)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun scheduleEatReminder() {
|
fun scheduleEatReminder() {
|
||||||
|
|
|
@ -120,7 +120,7 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center"
|
android:layout_gravity="center"
|
||||||
android:src="@drawable/ic_access_alarm_24dp" />
|
android:src="@drawable/ic_access_alarm_24dp" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
|
Loading…
Reference in a new issue