From f457037f5ab48753f38faa79710380369297a717 Mon Sep 17 00:00:00 2001 From: Andries Smit Date: Wed, 16 Mar 2022 14:44:22 +0100 Subject: [PATCH] feat: wear split carbs and extended carbs --- wear/src/main/AndroidManifest.xml | 4 + .../interaction/actions/CarbActivity.java | 92 +++++++++++++++++++ .../androidaps/tile/ActionSource.kt | 14 +-- wear/src/main/res/values/arrays.xml | 2 + wear/src/main/res/values/strings.xml | 4 +- 5 files changed, 109 insertions(+), 7 deletions(-) create mode 100644 wear/src/main/java/info/nightscout/androidaps/interaction/actions/CarbActivity.java diff --git a/wear/src/main/AndroidManifest.xml b/wear/src/main/AndroidManifest.xml index 224b6e59f6..0bd323b107 100644 --- a/wear/src/main/AndroidManifest.xml +++ b/wear/src/main/AndroidManifest.xml @@ -607,6 +607,10 @@ + { + // With start time 0 and duration 0 + String actionstring = "ecarbs " + SafeParse.stringToInt(editCarbs.editText.getText().toString()) + " 0 0"; + ListenerService.initiateAction(CarbActivity.this, actionstring); + confirmAction(CarbActivity.this, R.string.action_ecarb_confirmation); + finishAffinity(); + + }); + container.addView(view); + return view; + } + } + + @Override + public void destroyItem(ViewGroup container, int row, int col, Object view) { + // Handle this to get the data before the view is destroyed? + // Object should still be kept by this, just setup for reinit? + container.removeView((View) view); + } + + @Override + public boolean isViewFromObject(View view, Object object) { + return view == object; + } + + } +} diff --git a/wear/src/main/java/info/nightscout/androidaps/tile/ActionSource.kt b/wear/src/main/java/info/nightscout/androidaps/tile/ActionSource.kt index d9f87ad77f..9223060e68 100644 --- a/wear/src/main/java/info/nightscout/androidaps/tile/ActionSource.kt +++ b/wear/src/main/java/info/nightscout/androidaps/tile/ActionSource.kt @@ -2,11 +2,7 @@ package info.nightscout.androidaps.tile import android.content.res.Resources import info.nightscout.androidaps.R -import info.nightscout.androidaps.interaction.actions.BolusActivity -import info.nightscout.androidaps.interaction.actions.TreatmentActivity -import info.nightscout.androidaps.interaction.actions.ECarbActivity -import info.nightscout.androidaps.interaction.actions.TempTargetActivity -import info.nightscout.androidaps.interaction.actions.WizardActivity +import info.nightscout.androidaps.interaction.actions.* object ActionSource : StaticTileSource() { @@ -36,6 +32,12 @@ object ActionSource : StaticTileSource() { settingName = "carbs", buttonText = resources.getString(R.string.action_carbs), iconRes = R.drawable.ic_carbs_orange, + activityClass = CarbActivity::class.java.name, + ), + StaticAction( + settingName = "ecarbs", + buttonText = resources.getString(R.string.action_ecarbs), + iconRes = R.drawable.ic_carbs_orange, activityClass = ECarbActivity::class.java.name, ), StaticAction( @@ -55,7 +57,7 @@ object ActionSource : StaticTileSource() { return mapOf( "tile_action_1" to "wizard", "tile_action_2" to "treatment", - "tile_action_3" to "carbs", + "tile_action_3" to "ecarbs", "tile_action_4" to "temp_target" ) } diff --git a/wear/src/main/res/values/arrays.xml b/wear/src/main/res/values/arrays.xml index a70ec6e5ec..1a9f62bb15 100644 --- a/wear/src/main/res/values/arrays.xml +++ b/wear/src/main/res/values/arrays.xml @@ -83,6 +83,7 @@ @string/menu_wizard @string/menu_treatment @string/menu_bolus + @string/menu_carb @string/menu_ecarb @string/menu_tempt @string/tile_none @@ -93,6 +94,7 @@ treatment bolus carbs + ecarbs temp_target none diff --git a/wear/src/main/res/values/strings.xml b/wear/src/main/res/values/strings.xml index efd047c1e5..56709347c7 100644 --- a/wear/src/main/res/values/strings.xml +++ b/wear/src/main/res/values/strings.xml @@ -79,7 +79,8 @@ Treatment Treat Bolus - Carbs + Carbs + eCarbs Settings Status Re-Sync @@ -102,6 +103,7 @@ Low High Carbs + eCarbs Percentage Start [min] Duration [h]