Wear: support tt presets
This commit is contained in:
parent
c5c4064c8b
commit
6321758634
|
@ -144,6 +144,7 @@ class ActionStringHandler @Inject constructor(
|
||||||
}
|
}
|
||||||
rAction += "bolus $insulinAfterConstraints $carbsAfterConstraints"
|
rAction += "bolus $insulinAfterConstraints $carbsAfterConstraints"
|
||||||
} else if ("temptarget" == act[0]) { ///////////////////////////////////////////////////////// TEMPTARGET
|
} else if ("temptarget" == act[0]) { ///////////////////////////////////////////////////////// TEMPTARGET
|
||||||
|
aapsLogger.info(LTag.WEAR, "temptarget received:" + act)
|
||||||
if ("cancel" == act[1]) {
|
if ("cancel" == act[1]) {
|
||||||
rMessage += rh.gs(R.string.wear_action_tempt_cancel_message)
|
rMessage += rh.gs(R.string.wear_action_tempt_cancel_message)
|
||||||
rAction = "temptarget true 0 0 0"
|
rAction = "temptarget true 0 0 0"
|
||||||
|
@ -156,15 +157,13 @@ class ActionStringHandler @Inject constructor(
|
||||||
val reason = rh.gs(R.string.activity)
|
val reason = rh.gs(R.string.activity)
|
||||||
rMessage += rh.gs(R.string.wear_action_tempt_preset_message, reason, activityTT, activityTTDuration)
|
rMessage += rh.gs(R.string.wear_action_tempt_preset_message, reason, activityTT, activityTTDuration)
|
||||||
rAction = "temptarget $presetIsMGDL $activityTTDuration $activityTT $activityTT"
|
rAction = "temptarget $presetIsMGDL $activityTTDuration $activityTT $activityTT"
|
||||||
}
|
} else if ("hypo" == preset) {
|
||||||
if ("hypo" == preset) {
|
|
||||||
val hypoTTDuration = defaultValueHelper.determineHypoTTDuration()
|
val hypoTTDuration = defaultValueHelper.determineHypoTTDuration()
|
||||||
val hypoTT = defaultValueHelper.determineHypoTT()
|
val hypoTT = defaultValueHelper.determineHypoTT()
|
||||||
val reason = rh.gs(R.string.hypo)
|
val reason = rh.gs(R.string.hypo)
|
||||||
rMessage += rh.gs(R.string.wear_action_tempt_preset_message, reason, hypoTT, hypoTTDuration)
|
rMessage += rh.gs(R.string.wear_action_tempt_preset_message, reason, hypoTT, hypoTTDuration)
|
||||||
rAction = "temptarget $presetIsMGDL $hypoTTDuration $hypoTT $hypoTT"
|
rAction = "temptarget $presetIsMGDL $hypoTTDuration $hypoTT $hypoTT"
|
||||||
}
|
} else if ("eating" == preset) {
|
||||||
if ("eating" == preset) {
|
|
||||||
val eatingSoonTTDuration = defaultValueHelper.determineEatingSoonTTDuration()
|
val eatingSoonTTDuration = defaultValueHelper.determineEatingSoonTTDuration()
|
||||||
val eatingSoonTT = defaultValueHelper.determineEatingSoonTT()
|
val eatingSoonTT = defaultValueHelper.determineEatingSoonTT()
|
||||||
val reason = rh.gs(R.string.eatingsoon)
|
val reason = rh.gs(R.string.eatingsoon)
|
||||||
|
|
|
@ -14,8 +14,8 @@ object TempTargetSource : TileSource {
|
||||||
iconRes = R.drawable.ic_target_activity,
|
iconRes = R.drawable.ic_target_activity,
|
||||||
activityClass = TempTargetActivity::class.java.getName(),
|
activityClass = TempTargetActivity::class.java.getName(),
|
||||||
background = true,
|
background = true,
|
||||||
actionString = "temptarget false 90 8.0 8.0",
|
// actionString = "temptarget false 90 8.0 8.0",
|
||||||
// actionString = "temptarget preset activity",
|
actionString = "temptarget preset activity",
|
||||||
),
|
),
|
||||||
Action(
|
Action(
|
||||||
id = 1,
|
id = 1,
|
||||||
|
@ -24,8 +24,8 @@ object TempTargetSource : TileSource {
|
||||||
iconRes = R.drawable.ic_target_eatingsoon,
|
iconRes = R.drawable.ic_target_eatingsoon,
|
||||||
activityClass = TempTargetActivity::class.java.getName(),
|
activityClass = TempTargetActivity::class.java.getName(),
|
||||||
background = true,
|
background = true,
|
||||||
actionString = "temptarget false 45 4.5 4.5",
|
// actionString = "temptarget false 45 4.5 4.5",
|
||||||
//actionString = "temptarget preset eating",
|
actionString = "temptarget preset eating",
|
||||||
),
|
),
|
||||||
Action(
|
Action(
|
||||||
id = 2,
|
id = 2,
|
||||||
|
@ -34,8 +34,8 @@ object TempTargetSource : TileSource {
|
||||||
iconRes = R.drawable.ic_target_hypo,
|
iconRes = R.drawable.ic_target_hypo,
|
||||||
activityClass = TempTargetActivity::class.java.getName(),
|
activityClass = TempTargetActivity::class.java.getName(),
|
||||||
background = true,
|
background = true,
|
||||||
actionString = "temptarget false 45 7.0 7.0",
|
// actionString = "temptarget false 45 7.0 7.0",
|
||||||
// actionString = "temptarget preset hypo",
|
actionString = "temptarget preset hypo",
|
||||||
),
|
),
|
||||||
Action(
|
Action(
|
||||||
id = 3,
|
id = 3,
|
||||||
|
|
|
@ -234,12 +234,12 @@ abstract open class TileBase : TileService() {
|
||||||
|
|
||||||
private fun getActionFromPreference(sharedPrefs: SharedPreferences, index: Int): Action? {
|
private fun getActionFromPreference(sharedPrefs: SharedPreferences, index: Int): Action? {
|
||||||
val actionPref = sharedPrefs?.getString(preferencePrefix + index, "none")
|
val actionPref = sharedPrefs?.getString(preferencePrefix + index, "none")
|
||||||
return source.getActions().find { a -> a.settingName == actionPref }
|
return source.getActions().find { action -> action.settingName == actionPref }
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setDefaultSettings(sharedPrefs: SharedPreferences) {
|
fun setDefaultSettings(sharedPrefs: SharedPreferences) {
|
||||||
val defaults = source.getDefaultConfig()
|
val defaults = source.getDefaultConfig()
|
||||||
val firstKey = defaults.firstNotNullOf { d -> d.key }
|
val firstKey = defaults.firstNotNullOf { settings -> settings.key }
|
||||||
if (!sharedPrefs.contains(firstKey)) {
|
if (!sharedPrefs.contains(firstKey)) {
|
||||||
Log.i(TAG, "setDefaultSettings: set defaults")
|
Log.i(TAG, "setDefaultSettings: set defaults")
|
||||||
val editor = sharedPrefs.edit()
|
val editor = sharedPrefs.edit()
|
||||||
|
|
Loading…
Reference in a new issue