diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/wear/ActionStringHandler.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/wear/ActionStringHandler.kt
index f463a10339..8837105f47 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/general/wear/ActionStringHandler.kt
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/wear/ActionStringHandler.kt
@@ -79,7 +79,8 @@ class ActionStringHandler @Inject constructor(
private val dateUtil: DateUtil,
private val config: Config,
private val repository: AppRepository,
- private val uel: UserEntryLogger
+ private val uel: UserEntryLogger,
+ private val defaultValueHelper: DefaultValueHelper
) {
private val timeout = 65 * 1000
@@ -143,32 +144,65 @@ class ActionStringHandler @Inject constructor(
}
rAction += "bolus $insulinAfterConstraints $carbsAfterConstraints"
} else if ("temptarget" == act[0]) { ///////////////////////////////////////////////////////// TEMPTARGET
- val isMGDL = java.lang.Boolean.parseBoolean(act[1])
- if (profileFunction.getUnits() == GlucoseUnit.MGDL != isMGDL) {
- sendError("Different units used on watch and phone!")
- return
- }
- val duration = SafeParse.stringToInt(act[2])
- if (duration == 0) {
- rMessage += "Zero-Temp-Target - cancelling running Temp-Targets?"
+ if ("cancel" == act[1]) {
+ rMessage += rh.gs(R.string.wear_action_tempt_cancel_message)
rAction = "temptarget true 0 0 0"
+ } else if ("preset" == act[1]) {
+ val presetIsMGDL = profileFunction.getUnits() == GlucoseUnit.MGDL
+ val preset = act[2]
+ if ("activity" == preset) {
+ val activityTTDuration = defaultValueHelper.determineActivityTTDuration()
+ val activityTT = defaultValueHelper.determineActivityTT()
+ val reason = rh.gs(R.string.activity)
+ rMessage += rh.gs(R.string.wear_action_tempt_preset_message, reason, activityTT, activityTTDuration)
+ rAction = "temptarget $presetIsMGDL $activityTTDuration $activityTT $activityTT"
+ }
+ if ("hypo" == preset) {
+ val hypoTTDuration = defaultValueHelper.determineHypoTTDuration()
+ val hypoTT = defaultValueHelper.determineHypoTT()
+ val reason = rh.gs(R.string.hypo)
+ rMessage += rh.gs(R.string.wear_action_tempt_preset_message, reason, hypoTT, hypoTTDuration)
+ rAction = "temptarget $presetIsMGDL $hypoTTDuration $hypoTT $hypoTT"
+ }
+ if ("eating" == preset) {
+ val eatingSoonTTDuration = defaultValueHelper.determineEatingSoonTTDuration()
+ val eatingSoonTT = defaultValueHelper.determineEatingSoonTT()
+ val reason = rh.gs(R.string.eatingsoon)
+ rMessage += rh.gs(R.string.wear_action_tempt_preset_message, reason, eatingSoonTT, eatingSoonTTDuration)
+ rAction = "temptarget $presetIsMGDL $eatingSoonTTDuration $eatingSoonTT $eatingSoonTT"
+ } else {
+ sendError(rh.gs(R.string.wear_action_tempt_preset_error, preset))
+ return
+ }
} else {
- var low = SafeParse.stringToDouble(act[3])
- var high = SafeParse.stringToDouble(act[4])
- if (!isMGDL) {
- low *= Constants.MMOLL_TO_MGDL
- high *= Constants.MMOLL_TO_MGDL
- }
- if (low < HardLimits.VERY_HARD_LIMIT_TEMP_MIN_BG[0] || low > HardLimits.VERY_HARD_LIMIT_TEMP_MIN_BG[1]) {
- sendError("Min-BG out of range!")
+ val isMGDL = java.lang.Boolean.parseBoolean(act[1])
+ if (profileFunction.getUnits() == GlucoseUnit.MGDL != isMGDL) {
+ sendError(rh.gs(R.string.wear_action_tempt_unit_error))
return
}
- if (high < HardLimits.VERY_HARD_LIMIT_TEMP_MAX_BG[0] || high > HardLimits.VERY_HARD_LIMIT_TEMP_MAX_BG[1]) {
- sendError("Max-BG out of range!")
- return
+ val duration = SafeParse.stringToInt(act[2])
+ if (duration == 0) {
+ rMessage += rh.gs(R.string.wear_action_tempt_zero_message)
+ rAction = "temptarget true 0 0 0"
+ } else {
+ var low = SafeParse.stringToDouble(act[3])
+ var high = SafeParse.stringToDouble(act[4])
+ if (!isMGDL) {
+ low *= Constants.MMOLL_TO_MGDL
+ high *= Constants.MMOLL_TO_MGDL
+ }
+ if (low < HardLimits.VERY_HARD_LIMIT_TEMP_MIN_BG[0] || low > HardLimits.VERY_HARD_LIMIT_TEMP_MIN_BG[1]) {
+ sendError(rh.gs(R.string.wear_action_tempt_min_bg_error))
+ return
+ }
+ if (high < HardLimits.VERY_HARD_LIMIT_TEMP_MAX_BG[0] || high > HardLimits.VERY_HARD_LIMIT_TEMP_MAX_BG[1]) {
+ sendError(rh.gs(R.string.wear_action_tempt_max_bg_error))
+ return
+ }
+ rMessage += if(act[3] === act[4]) rh.gs(R.string.wear_action_tempt_manual_message, act[3], act[2])
+ else rh.gs(R.string.wear_action_tempt_manual_range_message, act[3], act[4], act[2])
+ rAction = actionString
}
- rMessage += "Temptarget:\nMin: " + act[3] + "\nMax: " + act[4] + "\nDuration: " + act[2]
- rAction = actionString
}
} else if ("status" == act[0]) { ////////////////////////////////////////////// STATUS
rTitle = "STATUS"
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 25989f4c62..38ad892882 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -1165,4 +1165,15 @@
blood glucose
outdated
+
+ Temptarget unknown preset: %1$s
+ Cancelling running Temp-Targets?
+ Different units used on watch and phone!
+ Zero-Temp-Target - cancelling running Temp-Targets?
+ Min-BG out of range!
+ Max-BG out of range!
+ Temptarget:\nMin: %1$s\nMax: %2$s\nDuration: %3$s
+ Temptarget:\nTarget: %1$s\nDuration: %2$s
+ Temptarget:\Reason: %1$s\nTarget: %2$s\nDuration: %3$s
+
diff --git a/core/src/main/res/values/strings.xml b/core/src/main/res/values/strings.xml
index e0c2c022a0..4713c3d553 100644
--- a/core/src/main/res/values/strings.xml
+++ b/core/src/main/res/values/strings.xml
@@ -558,4 +558,15 @@
- %1$d minutes
+
+ Temptarget unknown preset: %1$s
+ Cancelling running Temp-Targets?
+ Different units used on watch and phone!
+ Zero-Temp-Target - cancelling running Temp-Targets?
+ Min-BG out of range!
+ Max-BG out of range!
+ Temptarget:\nMin: %1$s\nMax: %2$s\nDuration: %3$s
+ Temptarget:\nTarget: %1$s\nDuration: %2$s
+ Temptarget:\Reason: %1$s\nTarget: %2$s\nDuration: %3$s
+
\ No newline at end of file
diff --git a/wear/src/main/AndroidManifest.xml b/wear/src/main/AndroidManifest.xml
index 7d14940599..86dc19a239 100644
--- a/wear/src/main/AndroidManifest.xml
+++ b/wear/src/main/AndroidManifest.xml
@@ -512,17 +512,36 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/wear/src/main/java/info/nightscout/androidaps/interaction/AAPSPreferences.java b/wear/src/main/java/info/nightscout/androidaps/interaction/AAPSPreferences.java
index ccdaeff7dc..72f9f0a968 100644
--- a/wear/src/main/java/info/nightscout/androidaps/interaction/AAPSPreferences.java
+++ b/wear/src/main/java/info/nightscout/androidaps/interaction/AAPSPreferences.java
@@ -5,6 +5,8 @@ import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
+import androidx.core.content.ContextCompat;
+
import info.nightscout.androidaps.R;
import preference.WearPreferenceActivity;
@@ -14,21 +16,15 @@ public class AAPSPreferences extends WearPreferenceActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.preferences);
- ViewGroup view = (ViewGroup)getWindow().getDecorView();
+ ViewGroup view = (ViewGroup) getWindow().getDecorView();
removeBackgroundRecursively(view);
- view.setBackground(getResources().getDrawable(R.drawable.settings_background));
+ view.setBackground(ContextCompat.getDrawable(this, R.drawable.settings_background));
view.requestFocus();
}
- @Override
- protected void onPause(){
- super.onPause();
- finish();
- }
-
void removeBackgroundRecursively(View parent) {
if (parent instanceof ViewGroup) {
- ViewGroup group = (ViewGroup)parent;
+ ViewGroup group = (ViewGroup) parent;
for (int i = 0; i < group.getChildCount(); i++) {
removeBackgroundRecursively(group.getChildAt(i));
}
@@ -36,5 +32,4 @@ public class AAPSPreferences extends WearPreferenceActivity {
parent.setBackground(null);
}
-
-}
\ No newline at end of file
+}
diff --git a/wear/src/main/java/info/nightscout/androidaps/interaction/ConfigurationActivity.java b/wear/src/main/java/info/nightscout/androidaps/interaction/ConfigurationActivity.java
index 8348dfcb22..e01a31216c 100644
--- a/wear/src/main/java/info/nightscout/androidaps/interaction/ConfigurationActivity.java
+++ b/wear/src/main/java/info/nightscout/androidaps/interaction/ConfigurationActivity.java
@@ -5,6 +5,9 @@ import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
+
+import androidx.core.content.ContextCompat;
+
import info.nightscout.androidaps.R;
import preference.WearPreferenceActivity;
@@ -14,14 +17,14 @@ public class ConfigurationActivity extends WearPreferenceActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setTitle("Watchface");
- String configFileName=getIntent().getAction();
+ String configFileName = getIntent().getAction();
int resXmlId = getResources().getIdentifier(configFileName, "xml", getApplicationContext().getPackageName());
- Log.d("ConfigurationActivity::onCreate --->> getIntent().getAction()",configFileName);
- Log.d("ConfigurationActivity::onCreate --->> resXmlId",String.valueOf(resXmlId));
+ Log.d("ConfigurationActivity::onCreate --->> getIntent().getAction()", configFileName);
+ Log.d("ConfigurationActivity::onCreate --->> resXmlId", String.valueOf(resXmlId));
addPreferencesFromResource(resXmlId);
ViewGroup view = (ViewGroup) getWindow().getDecorView();
removeBackgroundRecursively(view);
- view.setBackground(getResources().getDrawable(R.drawable.settings_background));
+ view.setBackground(ContextCompat.getDrawable(this, R.drawable.settings_background));
view.requestFocus();
}
@@ -41,5 +44,4 @@ public class ConfigurationActivity extends WearPreferenceActivity {
parent.setBackground(null);
}
-
}
diff --git a/wear/src/main/java/info/nightscout/androidaps/interaction/TileConfigurationActivity.java b/wear/src/main/java/info/nightscout/androidaps/interaction/TileConfigurationActivity.java
new file mode 100644
index 0000000000..ef1fee57f6
--- /dev/null
+++ b/wear/src/main/java/info/nightscout/androidaps/interaction/TileConfigurationActivity.java
@@ -0,0 +1,40 @@
+package info.nightscout.androidaps.interaction;
+
+import android.os.Bundle;
+import android.util.Log;
+import android.view.View;
+import android.view.ViewGroup;
+
+import androidx.core.content.ContextCompat;
+
+import info.nightscout.androidaps.R;
+import preference.WearPreferenceActivity;
+
+public class TileConfigurationActivity extends WearPreferenceActivity {
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setTitle("Tile");
+ String configFileName = getIntent().getAction();
+ int resXmlId = getResources().getIdentifier(configFileName, "xml", getApplicationContext().getPackageName());
+ Log.d("ConfigurationActivity::onCreate --->> getIntent().getAction()", configFileName);
+ Log.d("ConfigurationActivity::onCreate --->> resXmlId", String.valueOf(resXmlId));
+ addPreferencesFromResource(resXmlId);
+ ViewGroup view = (ViewGroup) getWindow().getDecorView();
+ removeBackgroundRecursively(view);
+ view.setBackground(ContextCompat.getDrawable(this, R.drawable.settings_background));
+ view.requestFocus();
+ }
+
+ void removeBackgroundRecursively(View parent) {
+ if (parent instanceof ViewGroup) {
+ ViewGroup group = (ViewGroup) parent;
+ for (int i = 0; i < group.getChildCount(); i++) {
+ removeBackgroundRecursively(group.getChildAt(i));
+ }
+ }
+ parent.setBackground(null);
+ }
+
+}
diff --git a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/AcceptActivity.java b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/AcceptActivity.java
index 46ecf6be7a..1b3c1ba0f2 100644
--- a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/AcceptActivity.java
+++ b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/AcceptActivity.java
@@ -103,12 +103,9 @@ public class AcceptActivity extends ViewSelectorActivity {
} else {
final View view = LayoutInflater.from(getApplicationContext()).inflate(R.layout.action_send_item, container, false);
final ImageView confirmbutton = view.findViewById(R.id.confirmbutton);
- confirmbutton.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- ListenerService.confirmAction(AcceptActivity.this, actionstring);
- finishAffinity();
- }
+ confirmbutton.setOnClickListener((View v) -> {
+ ListenerService.confirmAction(AcceptActivity.this, actionstring);
+ finishAffinity();
});
container.addView(view);
return view;
diff --git a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/BolusActivity.java b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/BolusActivity.java
index 97fe81fa6a..9b570d23ca 100644
--- a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/BolusActivity.java
+++ b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/BolusActivity.java
@@ -75,16 +75,14 @@ public class BolusActivity extends ViewSelectorActivity {
final View view = LayoutInflater.from(getApplicationContext()).inflate(R.layout.action_send_item, container, false);
final ImageView confirmbutton = view.findViewById(R.id.confirmbutton);
- confirmbutton.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
+ confirmbutton.setOnClickListener((View v) -> {
//check if it can happen that the fagment is never created that hold data?
// (you have to swipe past them anyways - but still)
String actionstring = "bolus " + SafeParse.stringToDouble(editInsulin.editText.getText().toString())
+ " " + SafeParse.stringToInt(editCarbs.editText.getText().toString());
ListenerService.initiateAction(BolusActivity.this, actionstring);
+ confirmAction(BolusActivity.this, R.string.action_bolus_confirmation);
finishAffinity();
- }
});
container.addView(view);
return view;
diff --git a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/CPPActivity.java b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/CPPActivity.java
index 479e3945ed..d5c488f185 100644
--- a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/CPPActivity.java
+++ b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/CPPActivity.java
@@ -89,18 +89,15 @@ public class CPPActivity extends ViewSelectorActivity {
final View view = LayoutInflater.from(getApplicationContext()).inflate(R.layout.action_send_item, container, false);
final ImageView confirmbutton = view.findViewById(R.id.confirmbutton);
- confirmbutton.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
+ confirmbutton.setOnClickListener((View v) -> {
+ //check if it can happen that the fagment is never created that hold data?
+ // (you have to swipe past them anyways - but still)
- //check if it can happen that the fagment is never created that hold data?
- // (you have to swipe past them anyways - but still)
-
- String actionstring = "cppset " + SafeParse.stringToInt(editTimeshift.editText.getText().toString())
- + " " + SafeParse.stringToInt(editPercentage.editText.getText().toString());
- ListenerService.initiateAction(CPPActivity.this, actionstring);
- finishAffinity();
- }
+ String actionstring = "cppset " + SafeParse.stringToInt(editTimeshift.editText.getText().toString())
+ + " " + SafeParse.stringToInt(editPercentage.editText.getText().toString());
+ ListenerService.initiateAction(CPPActivity.this, actionstring);
+ confirmAction(CPPActivity.this, R.string.action_cpp_confirmation);
+ finishAffinity();
});
container.addView(view);
return view;
diff --git a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/ECarbActivity.java b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/ECarbActivity.java
index 379c9b33fe..4dc112f664 100644
--- a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/ECarbActivity.java
+++ b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/ECarbActivity.java
@@ -85,19 +85,18 @@ public class ECarbActivity extends ViewSelectorActivity {
final View view = LayoutInflater.from(getApplicationContext()).inflate(R.layout.action_send_item, container, false);
final ImageView confirmbutton = view.findViewById(R.id.confirmbutton);
- confirmbutton.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
+ confirmbutton.setOnClickListener((View v) -> {
- //check if it can happen that the fagment is never created that hold data?
- // (you have to swipe past them anyways - but still)
+ //check if it can happen that the fagment is never created that hold data?
+ // (you have to swipe past them anyways - but still)
+
+ String actionstring = "ecarbs " + SafeParse.stringToInt(editCarbs.editText.getText().toString())
+ + " " + SafeParse.stringToInt(editStartTime.editText.getText().toString())
+ + " " + SafeParse.stringToInt(editDuration.editText.getText().toString());
+ ListenerService.initiateAction(ECarbActivity.this, actionstring);
+ confirmAction(ECarbActivity.this, R.string.action_ecarb_confirmation);
+ finishAffinity();
- String actionstring = "ecarbs " + SafeParse.stringToInt(editCarbs.editText.getText().toString())
- + " " + SafeParse.stringToInt(editStartTime.editText.getText().toString())
- + " " + SafeParse.stringToInt(editDuration.editText.getText().toString());
- ListenerService.initiateAction(ECarbActivity.this, actionstring);
- finishAffinity();
- }
});
container.addView(view);
return view;
diff --git a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/FillActivity.java b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/FillActivity.java
index a53fdb2ba5..b76829182e 100644
--- a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/FillActivity.java
+++ b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/FillActivity.java
@@ -63,17 +63,14 @@ public class FillActivity extends ViewSelectorActivity {
final View view = LayoutInflater.from(getApplicationContext()).inflate(R.layout.action_send_item, container, false);
final ImageView confirmbutton = view.findViewById(R.id.confirmbutton);
- confirmbutton.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
-
+ confirmbutton.setOnClickListener((View v) -> {
//check if it can happen that the fagment is never created that hold data?
// (you have to swipe past them anyways - but still)
String actionstring = "fill " + SafeParse.stringToDouble(editInsulin.editText.getText().toString());
ListenerService.initiateAction(FillActivity.this, actionstring);
+ confirmAction(FillActivity.this, R.string.action_fill_confirmation);
finishAffinity();
- }
});
container.addView(view);
return view;
diff --git a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/TempTargetActivity.java b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/TempTargetActivity.java
index 6d42a63964..e255b65579 100644
--- a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/TempTargetActivity.java
+++ b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/TempTargetActivity.java
@@ -4,11 +4,11 @@ import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.wearable.view.GridPagerAdapter;
+import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
-import android.widget.TextView;
import java.text.DecimalFormat;
@@ -32,6 +32,9 @@ public class TempTargetActivity extends ViewSelectorActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
+ if (executeInBackground()){
+ return;
+ }
setAdapter(new MyGridViewPagerAdapter());
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
@@ -39,6 +42,22 @@ public class TempTargetActivity extends ViewSelectorActivity {
isSingleTarget = sp.getBoolean("singletarget", true);
}
+ private boolean executeInBackground() {
+ Bundle extras = getIntent().getExtras();
+ if (extras != null) {
+ String actionString = extras.getString("actionString", "");
+ boolean inBackground = extras.getBoolean("inBackground", false);
+ if (inBackground) {
+ Log.i("ASTAG", "TempTargetActivity.onCreate: " + actionString);
+ ListenerService.initiateAction(this, actionString);
+ confirmAction(this, R.string.action_tempt_confirmation);
+ finishAffinity();
+ return true;
+ }
+ }
+ return false;
+ }
+
@Override
protected void onPause() {
super.onPause();
@@ -61,8 +80,6 @@ public class TempTargetActivity extends ViewSelectorActivity {
if (col == 0) {
final View view = getInflatedPlusMinusView(container);
- final TextView textView = view.findViewById(R.id.label);
- textView.setText("duration");
if (time == null) {
time = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, 60d, 0d, 24 * 60d, 5d, new DecimalFormat("0"), false);
} else {
@@ -118,22 +135,19 @@ public class TempTargetActivity extends ViewSelectorActivity {
final View view = LayoutInflater.from(getApplicationContext()).inflate(R.layout.action_send_item, container, false);
final ImageView confirmbutton = view.findViewById(R.id.confirmbutton);
- confirmbutton.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
+ confirmbutton.setOnClickListener((View v) -> {
+ //check if it can happen that the fagment is never created that hold data?
+ // (you have to swipe past them anyways - but still)
- //check if it can happen that the fagment is never created that hold data?
- // (you have to swipe past them anyways - but still)
+ String actionstring = "temptarget"
+ + " " + isMGDL
+ + " " + SafeParse.stringToInt(time.editText.getText().toString())
+ + " " + SafeParse.stringToDouble(lowRange.editText.getText().toString())
+ + " " + (isSingleTarget ? SafeParse.stringToDouble(lowRange.editText.getText().toString()) : SafeParse.stringToDouble(highRange.editText.getText().toString()));
- String actionstring = "temptarget "
- + " " + isMGDL
- + " " + SafeParse.stringToInt(time.editText.getText().toString())
- + " " + SafeParse.stringToDouble(lowRange.editText.getText().toString())
- + " " + (isSingleTarget ? SafeParse.stringToDouble(lowRange.editText.getText().toString()) : SafeParse.stringToDouble(highRange.editText.getText().toString()));
-
- ListenerService.initiateAction(TempTargetActivity.this, actionstring);
- finishAffinity();
- }
+ ListenerService.initiateAction(TempTargetActivity.this, actionstring);
+ confirmAction(TempTargetActivity.this, R.string.action_tempt_confirmation);
+ finishAffinity();
});
container.addView(view);
return view;
diff --git a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/ViewSelectorActivity.java b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/ViewSelectorActivity.java
index afb3dda6cc..068cca59f7 100644
--- a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/ViewSelectorActivity.java
+++ b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/ViewSelectorActivity.java
@@ -1,6 +1,7 @@
package info.nightscout.androidaps.interaction.actions;
import android.app.Activity;
+import android.content.Context;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
@@ -11,6 +12,7 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
+import android.widget.Toast;
import androidx.wear.widget.CurvedTextView;
@@ -62,9 +64,9 @@ public class ViewSelectorActivity extends Activity {
private void setTitleBasedOnScreenShape() {
// intents can inject dynamic titles, otherwise we'll use the default
String title = String.valueOf(getTitle());
- if (getIntent().getExtras() != null)
+ if (getIntent().getExtras() != null) {
title = getIntent().getExtras().getString("title", title);
-
+ }
CurvedTextView titleViewCurved = findViewById(R.id.title_curved);
TextView titleView = findViewById(R.id.title);
if (this.getResources().getConfiguration().isScreenRound()) {
@@ -96,8 +98,12 @@ public class ViewSelectorActivity extends Activity {
}
void setLabelToPlusMinusView(View view, String labelText) {
- final TextView textView = view.findViewById(R.id.label);
- textView.setText(labelText);
+ final TextView textView = view.findViewById(R.id.label);
+ textView.setText(labelText);
+ }
+
+ void confirmAction(Context context, int text) {
+ Toast.makeText(context, getString(text), Toast.LENGTH_LONG).show();
}
}
diff --git a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/WizardActivity.java b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/WizardActivity.java
index e8ea60b0a4..9d31fc5154 100644
--- a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/WizardActivity.java
+++ b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/WizardActivity.java
@@ -82,23 +82,20 @@ public class WizardActivity extends ViewSelectorActivity {
final View view = LayoutInflater.from(getApplicationContext()).inflate(R.layout.action_send_item, container, false);
final ImageView confirmbutton = view.findViewById(R.id.confirmbutton);
- confirmbutton.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
+ confirmbutton.setOnClickListener((View v) -> {
+ // check if it can happen that the fragment is never created that hold data?
+ // (you have to swipe past them anyways - but still)
- // check if it can happen that the fragment is never created that hold data?
- // (you have to swipe past them anyways - but still)
+ int percentage = 100;
- int percentage = 100;
+ if (editPercentage != null)
+ percentage = SafeParse.stringToInt(editPercentage.editText.getText().toString());
- if (editPercentage != null)
- percentage = SafeParse.stringToInt(editPercentage.editText.getText().toString());
-
- String actionstring = "wizard2 " + SafeParse.stringToInt(editCarbs.editText.getText().toString())
- + " " + percentage;
- ListenerService.initiateAction(WizardActivity.this, actionstring);
- finishAffinity();
- }
+ String actionstring = "wizard2 " + SafeParse.stringToInt(editCarbs.editText.getText().toString())
+ + " " + percentage;
+ ListenerService.initiateAction(WizardActivity.this, actionstring);
+ confirmAction(WizardActivity.this, R.string.action_wizard_confirmation);
+ finishAffinity();
});
container.addView(view);
return view;
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 25bd71255e..196f9e0b96 100644
--- a/wear/src/main/java/info/nightscout/androidaps/tile/ActionSource.kt
+++ b/wear/src/main/java/info/nightscout/androidaps/tile/ActionSource.kt
@@ -1,48 +1,50 @@
package info.nightscout.androidaps.tile
-import androidx.annotation.DrawableRes
-import androidx.annotation.StringRes
-
import info.nightscout.androidaps.R
+import info.nightscout.androidaps.interaction.TileConfigurationActivity
import info.nightscout.androidaps.interaction.actions.BolusActivity
import info.nightscout.androidaps.interaction.actions.ECarbActivity
import info.nightscout.androidaps.interaction.actions.TempTargetActivity
-import info.nightscout.androidaps.interaction.actions.WizardActivity
-data class Action(
- val id: Long,
- @StringRes val nameRes: Int,
- val activityClass: String,
- @DrawableRes val iconRes: Int,
-)
+object ActionSource: TileSource {
-object ActionSource {
-
- fun getActions(): List {
+ override fun getActions(): List {
return listOf(
Action(
id = 0,
+ settingName = "wizzard",
nameRes = R.string.menu_wizard,
iconRes = R.drawable.ic_calculator_green,
- activityClass = WizardActivity::class.java.getName(),
+ activityClass = TileConfigurationActivity::class.java.getName(),
+ background = false,
+ actionString = "",
),
Action(
id = 1,
+ settingName = "bolus",
nameRes = R.string.action_bolus,
iconRes = R.drawable.ic_bolus_carbs,
activityClass = BolusActivity::class.java.getName(),
+ background = false,
+ actionString = "",
),
Action(
id = 2,
+ settingName = "carbs",
nameRes = R.string.action_carbs,
iconRes = R.drawable.ic_carbs_orange,
activityClass = ECarbActivity::class.java.getName(),
+ background = false,
+ actionString = "",
),
Action(
id = 3,
+ settingName = "temp_target",
nameRes = R.string.menu_tempt,
iconRes = R.drawable.ic_temptarget_flat,
activityClass = TempTargetActivity::class.java.getName(),
+ background = false,
+ actionString = "",
)
)
}
diff --git a/wear/src/main/java/info/nightscout/androidaps/tile/ActionsTileService.kt b/wear/src/main/java/info/nightscout/androidaps/tile/ActionsTileService.kt
index 89771d2754..75867735b7 100644
--- a/wear/src/main/java/info/nightscout/androidaps/tile/ActionsTileService.kt
+++ b/wear/src/main/java/info/nightscout/androidaps/tile/ActionsTileService.kt
@@ -1,172 +1,8 @@
package info.nightscout.androidaps.tile
-import androidx.core.content.ContextCompat
-
-import androidx.wear.tiles.ActionBuilders
-import androidx.wear.tiles.ColorBuilders.argb
-import androidx.wear.tiles.DeviceParametersBuilders.DeviceParameters
-import androidx.wear.tiles.DimensionBuilders.dp
-import androidx.wear.tiles.LayoutElementBuilders.Box
-import androidx.wear.tiles.LayoutElementBuilders.Column
-import androidx.wear.tiles.LayoutElementBuilders.FontStyles
-import androidx.wear.tiles.LayoutElementBuilders.Image
-import androidx.wear.tiles.LayoutElementBuilders.Layout
-import androidx.wear.tiles.LayoutElementBuilders.LayoutElement
-import androidx.wear.tiles.LayoutElementBuilders.Row
-import androidx.wear.tiles.LayoutElementBuilders.Spacer
-import androidx.wear.tiles.LayoutElementBuilders.Text
-import androidx.wear.tiles.ModifiersBuilders.Background
-import androidx.wear.tiles.ModifiersBuilders.Clickable
-import androidx.wear.tiles.ModifiersBuilders.Corner
-import androidx.wear.tiles.ModifiersBuilders.Modifiers
-import androidx.wear.tiles.ModifiersBuilders.Semantics
-import androidx.wear.tiles.RequestBuilders
-import androidx.wear.tiles.RequestBuilders.ResourcesRequest
-import androidx.wear.tiles.ResourceBuilders.AndroidImageResourceByResId
-import androidx.wear.tiles.ResourceBuilders.ImageResource
-import androidx.wear.tiles.ResourceBuilders.Resources
-import androidx.wear.tiles.TileBuilders.Tile
-import androidx.wear.tiles.TileService
-import androidx.wear.tiles.TimelineBuilders.Timeline
-import androidx.wear.tiles.TimelineBuilders.TimelineEntry
-
-import com.google.common.util.concurrent.ListenableFuture
-
-import info.nightscout.androidaps.R
-
-import kotlinx.coroutines.CoroutineScope
-import kotlinx.coroutines.Dispatchers
-import kotlinx.coroutines.Job
-import kotlinx.coroutines.guava.future
-
-private const val RESOURCES_VERSION = "1"
-private const val ID_IC_ACTION_PREFIX = "ic_action_"
-private const val CIRCLE_SIZE = 75f
-private val ICON_SIZE = dp(25f)
-private val SPACING_ACTIONS = dp(3f)
-private const val BUTTON_COLOR = R.color.gray_850
-
-class ActionsTileService : TileService() {
-
- private val serviceJob = Job()
- private val serviceScope = CoroutineScope(Dispatchers.IO + serviceJob)
-
- override fun onTileRequest(
- requestParams: RequestBuilders.TileRequest
- ): ListenableFuture = serviceScope.future {
- val actions = ActionSource.getActions().take(4)
- Tile.Builder()
- .setResourcesVersion(RESOURCES_VERSION)
- .setTimeline(
- Timeline.Builder().addTimelineEntry(
- TimelineEntry.Builder().setLayout(
- Layout.Builder().setRoot(layout(actions, requestParams.deviceParameters!!)).build()
- ).build()
- ).build()
- )
- .build()
- }
-
- override fun onResourcesRequest(
- requestParams: ResourcesRequest
- ): ListenableFuture = serviceScope.future {
- val actions = ActionSource.getActions().take(4)
- Resources.Builder()
- .setVersion(RESOURCES_VERSION)
- .apply {
- actions.mapNotNull { action ->
- addIdToImageMapping(
- ID_IC_ACTION_PREFIX + action.id,
- ImageResource.Builder()
- .setAndroidResourceByResId(
- AndroidImageResourceByResId.Builder()
- .setResourceId(action.iconRes)
- .build()
- )
- .build()
- )
- }
- }
- .build()
- }
-
- private fun layout(actions: List, deviceParameters: DeviceParameters): LayoutElement =
- Column.Builder()
- .addContent(
- Row.Builder()
- .addContent(action(actions[0], deviceParameters))
- .addContent(Spacer.Builder().setWidth(SPACING_ACTIONS).build())
- .addContent(action(actions[1], deviceParameters))
- .build()
- )
- .addContent(Spacer.Builder().setHeight(SPACING_ACTIONS).build())
- .addContent(
- Row.Builder()
- .addContent(action(actions[2], deviceParameters))
- .addContent(Spacer.Builder().setWidth(SPACING_ACTIONS).build())
- .addContent(action(actions[3], deviceParameters))
- .build()
- )
- .build()
-
- private fun action(action: Action, deviceParameters: DeviceParameters) = Box.Builder()
- .setWidth(dp(CIRCLE_SIZE))
- .setHeight(dp(CIRCLE_SIZE))
- .setModifiers(
- Modifiers.Builder()
- .setBackground(
- Background.Builder()
- .setColor(
- argb(ContextCompat.getColor(baseContext, BUTTON_COLOR))
- )
- .setCorner(
- Corner.Builder().setRadius(dp(CIRCLE_SIZE / 2)).build()
- )
- .build()
- )
- .setSemantics(
- Semantics.Builder()
- .setContentDescription(resources.getString(action.nameRes))
- .build()
- )
- .setClickable(
- Clickable.Builder()
- .setOnClick(
- ActionBuilders.LaunchAction.Builder()
- .setAndroidActivity(
- ActionBuilders.AndroidActivity.Builder()
- .setClassName(action.activityClass)
- .setPackageName(this.packageName)
- .build()
- )
- .build()
- )
- .build()
- )
- .build()
- )
- .addContent(
- Column.Builder()
- .addContent(
- Image.Builder()
- .setWidth(ICON_SIZE)
- .setHeight(ICON_SIZE)
- .setResourceId(ID_IC_ACTION_PREFIX + action.id)
- .build()
- ).addContent(
- Text.Builder()
- .setText(resources.getString(action.nameRes))
- .setFontStyle(
- FontStyles
- .button(deviceParameters)
- .setColor(
- argb(ContextCompat.getColor(baseContext, R.color.white))
- )
- .build()
- )
- .build()
- ).build()
- )
- .build()
-
+class ActionsTileService : TileBase(){
+ override val preferencePrefix = "tile_action_"
+ override val resourceVersion = "1"
+ override val idIconActionPrefix = "ic_action_"
+ override val source = ActionSource
}
diff --git a/wear/src/main/java/info/nightscout/androidaps/tile/TempTargetSource.kt b/wear/src/main/java/info/nightscout/androidaps/tile/TempTargetSource.kt
new file mode 100644
index 0000000000..210d4215ff
--- /dev/null
+++ b/wear/src/main/java/info/nightscout/androidaps/tile/TempTargetSource.kt
@@ -0,0 +1,60 @@
+package info.nightscout.androidaps.tile
+
+import info.nightscout.androidaps.R
+import info.nightscout.androidaps.interaction.actions.TempTargetActivity
+
+object TempTargetSource: TileSource {
+
+ override fun getActions(): List {
+ return listOf(
+ Action(
+ id = 0,
+ settingName = "activity",
+ nameRes = R.string.temp_target_activity,
+ iconRes = R.drawable.ic_target_activity,
+ activityClass = TempTargetActivity::class.java.getName(),
+ background = true,
+ actionString = "temptarget false 90 8.0 8.0",
+ // actionString = "temptarget preset activity",
+ ),
+ Action(
+ id = 1,
+ settingName = "eating_soon",
+ nameRes = R.string.temp_target_eating_soon,
+ iconRes = R.drawable.ic_target_eatingsoon,
+ activityClass = TempTargetActivity::class.java.getName(),
+ background = true,
+ actionString = "temptarget false 45 4.5 4.5",
+ //actionString = "temptarget preset eating",
+ ),
+ Action(
+ id = 2,
+ settingName = "hypo",
+ nameRes = R.string.temp_target_hypo,
+ iconRes = R.drawable.ic_target_hypo,
+ activityClass = TempTargetActivity::class.java.getName(),
+ background = true,
+ actionString = "temptarget false 45 7.0 7.0",
+ // actionString = "temptarget preset hypo",
+ ),
+ Action(
+ id = 3,
+ settingName = "manual",
+ nameRes = R.string.temp_target_manual,
+ iconRes = R.drawable.ic_target_manual,
+ activityClass = TempTargetActivity::class.java.getName(),
+ actionString = "",
+ background = false,
+ ),
+ Action(
+ id = 4,
+ settingName = "cancel",
+ nameRes = R.string.generic_cancel,
+ iconRes = R.drawable.ic_target_cancel,
+ activityClass = TempTargetActivity::class.java.getName(),
+ actionString = "temptarget cancel",
+ background = false,
+ )
+ )
+ }
+}
diff --git a/wear/src/main/java/info/nightscout/androidaps/tile/TempTargetTileService.kt b/wear/src/main/java/info/nightscout/androidaps/tile/TempTargetTileService.kt
new file mode 100644
index 0000000000..fa93d1b238
--- /dev/null
+++ b/wear/src/main/java/info/nightscout/androidaps/tile/TempTargetTileService.kt
@@ -0,0 +1,10 @@
+package info.nightscout.androidaps.tile
+
+class TempTargetTileService : TileBase(){
+
+ override val preferencePrefix = "tile_tempt_"
+ override val resourceVersion = "1"
+ override val idIconActionPrefix = "ic_tempt_"
+ override val source = TempTargetSource;
+
+}
diff --git a/wear/src/main/java/info/nightscout/androidaps/tile/TileBase.kt b/wear/src/main/java/info/nightscout/androidaps/tile/TileBase.kt
new file mode 100644
index 0000000000..80d77fa28d
--- /dev/null
+++ b/wear/src/main/java/info/nightscout/androidaps/tile/TileBase.kt
@@ -0,0 +1,253 @@
+package info.nightscout.androidaps.tile
+
+import android.util.Log
+import androidx.annotation.DrawableRes
+import androidx.annotation.StringRes
+
+import android.content.SharedPreferences
+import androidx.preference.PreferenceManager
+import androidx.core.content.ContextCompat
+
+import androidx.wear.tiles.ActionBuilders
+import androidx.wear.tiles.ColorBuilders.argb
+import androidx.wear.tiles.DeviceParametersBuilders.DeviceParameters
+import androidx.wear.tiles.DimensionBuilders.dp
+import androidx.wear.tiles.LayoutElementBuilders.Box
+import androidx.wear.tiles.LayoutElementBuilders.Column
+import androidx.wear.tiles.LayoutElementBuilders.FontStyles
+import androidx.wear.tiles.LayoutElementBuilders.Image
+import androidx.wear.tiles.LayoutElementBuilders.Layout
+import androidx.wear.tiles.LayoutElementBuilders.LayoutElement
+import androidx.wear.tiles.LayoutElementBuilders.Row
+import androidx.wear.tiles.LayoutElementBuilders.Spacer
+import androidx.wear.tiles.LayoutElementBuilders.Text
+import androidx.wear.tiles.ModifiersBuilders.Background
+import androidx.wear.tiles.ModifiersBuilders.Clickable
+import androidx.wear.tiles.ModifiersBuilders.Corner
+import androidx.wear.tiles.ModifiersBuilders.Modifiers
+import androidx.wear.tiles.ModifiersBuilders.Semantics
+import androidx.wear.tiles.RequestBuilders
+import androidx.wear.tiles.RequestBuilders.ResourcesRequest
+import androidx.wear.tiles.ResourceBuilders.AndroidImageResourceByResId
+import androidx.wear.tiles.ResourceBuilders.ImageResource
+import androidx.wear.tiles.ResourceBuilders.Resources
+import androidx.wear.tiles.TileBuilders.Tile
+import androidx.wear.tiles.TileService
+import androidx.wear.tiles.TimelineBuilders.Timeline
+import androidx.wear.tiles.TimelineBuilders.TimelineEntry
+
+import com.google.common.util.concurrent.ListenableFuture
+
+import info.nightscout.androidaps.R
+
+import kotlinx.coroutines.CoroutineScope
+import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.Job
+import kotlinx.coroutines.guava.future
+
+private const val CIRCLE_SIZE = 75f
+private val ICON_SIZE = dp(25f)
+private val SPACING_ACTIONS = dp(3f)
+private const val BUTTON_COLOR = R.color.gray_850
+private var sharedPrefs: SharedPreferences? = null
+
+interface TileSource {
+ fun getActions(): List
+}
+
+data class Action(
+ val id: Int,
+ val settingName: String,
+ @StringRes val nameRes: Int,
+ val activityClass: String,
+ @DrawableRes val iconRes: Int,
+ val background: Boolean?,
+ val actionString: String?,
+)
+
+const val TAG = "ASTAG-tile"
+
+open class TileBase : TileService(), SharedPreferences.OnSharedPreferenceChangeListener {
+
+ open val preferencePrefix = "tile_action_"
+ open val resourceVersion = "1"
+ open val idIconActionPrefix = "ic_action_"
+ open val source: TileSource = ActionSource
+
+ private val serviceJob = Job()
+ private val serviceScope = CoroutineScope(Dispatchers.IO + serviceJob)
+ private val actionsSelected: MutableList = mutableListOf()
+ private val actionsAll: MutableList = mutableListOf()
+
+ override fun onCreate() {
+ Log.i(TAG, "onCreate: ")
+ super.onCreate()
+ sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this)
+ sharedPrefs?.registerOnSharedPreferenceChangeListener(this)
+ actionsAll.addAll(source.getActions())
+ actionsSelected.addAll(getSelectedActions())
+ }
+
+ override fun onTileRequest(
+ requestParams: RequestBuilders.TileRequest
+ ): ListenableFuture = serviceScope.future {
+ Log.i(TAG, "onTileRequest: ")
+ Tile.Builder()
+ .setResourcesVersion(resourceVersion)
+ .setTimeline(
+ Timeline.Builder().addTimelineEntry(
+ TimelineEntry.Builder().setLayout(
+ Layout.Builder().setRoot(layout(actionsSelected, requestParams.deviceParameters!!)).build()
+ ).build()
+ ).build()
+ )
+ .build()
+ }
+
+ override fun onResourcesRequest(
+ requestParams: ResourcesRequest
+ ): ListenableFuture = serviceScope.future {
+ Log.i(TAG, "onResourcesRequest: ")
+ Resources.Builder()
+ .setVersion(resourceVersion)
+ .apply {
+ actionsAll.mapNotNull { action ->
+ addIdToImageMapping(
+ idIconActionPrefix + action.id,
+ ImageResource.Builder()
+ .setAndroidResourceByResId(
+ AndroidImageResourceByResId.Builder()
+ .setResourceId(action.iconRes)
+ .build()
+ )
+ .build()
+ )
+ }
+ }
+ .build()
+ }
+
+ private fun addRowSingle(action1: Action, deviceParameters: DeviceParameters): LayoutElement =
+ Row.Builder()
+ .addContent(action(action1, deviceParameters))
+ .build()
+
+ private fun addRowDouble(action1: Action, action2: Action, deviceParameters: DeviceParameters): LayoutElement =
+ Row.Builder()
+ .addContent(action(action1, deviceParameters))
+ .addContent(Spacer.Builder().setWidth(SPACING_ACTIONS).build())
+ .addContent(action(action2, deviceParameters))
+ .build()
+
+ private fun layout(actions: List, deviceParameters: DeviceParameters): LayoutElement {
+ if (actions.isNotEmpty()) {
+ val b = Column.Builder()
+ if (actions.size == 1 || actions.size == 3) {
+ b.addContent(addRowSingle(actions[0], deviceParameters))
+ }
+ if (actions.size == 4 || actions.size == 2) {
+ b.addContent(addRowDouble(actions[0], actions[1], deviceParameters))
+ }
+ if (actions.size == 3) {
+ b.addContent(addRowDouble(actions[1], actions[2], deviceParameters))
+ }
+ if (actions.size == 4) {
+ b.addContent(Spacer.Builder().setHeight(SPACING_ACTIONS).build())
+ .addContent(addRowDouble(actions[2], actions[3], deviceParameters))
+ }
+ return b.build()
+ }
+ return Text.Builder()
+ .setText(resources.getString(R.string.tile_no_config))
+ .build()
+ }
+
+ private fun doAction(action: Action): ActionBuilders.Action {
+ val ab = ActionBuilders.AndroidActivity.Builder()
+ .setClassName(action.activityClass)
+ .setPackageName(this.packageName)
+ if (action.actionString != null) {
+ ab.addKeyToExtraMapping("actionString", ActionBuilders.AndroidStringExtra.Builder().setValue(action.actionString).build())
+ }
+ if (action.background != null) {
+ ab.addKeyToExtraMapping("inBackground", ActionBuilders.AndroidBooleanExtra.Builder().setValue(action.background).build())
+ }
+ return ActionBuilders.LaunchAction.Builder()
+ .setAndroidActivity(ab.build())
+ .build()
+ }
+
+ private fun action(action: Action, deviceParameters: DeviceParameters) = Box.Builder()
+ .setWidth(dp(CIRCLE_SIZE))
+ .setHeight(dp(CIRCLE_SIZE))
+ .setModifiers(
+ Modifiers.Builder()
+ .setBackground(
+ Background.Builder()
+ .setColor(
+ argb(ContextCompat.getColor(baseContext, BUTTON_COLOR))
+ )
+ .setCorner(
+ Corner.Builder().setRadius(dp(CIRCLE_SIZE / 2)).build()
+ )
+ .build()
+ )
+ .setSemantics(
+ Semantics.Builder()
+ .setContentDescription(resources.getString(action.nameRes))
+ .build()
+ )
+ .setClickable(
+ Clickable.Builder()
+ .setOnClick(doAction(action))
+ .build()
+ )
+ .build()
+ )
+ .addContent(
+ Column.Builder()
+ .addContent(
+ Image.Builder()
+ .setWidth(ICON_SIZE)
+ .setHeight(ICON_SIZE)
+ .setResourceId(idIconActionPrefix + action.id)
+ .build()
+ ).addContent(
+ Text.Builder()
+ .setText(resources.getString(action.nameRes))
+ .setFontStyle(
+ FontStyles
+ .button(deviceParameters)
+ .setColor(
+ argb(ContextCompat.getColor(baseContext, R.color.white))
+ )
+ .build()
+ )
+ .build()
+ ).build()
+ )
+ .build()
+
+ override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences?, key: String?) {
+ Log.i(TAG, "onSharedPreferenceChanged: ")
+ getUpdater(this).requestUpdate(this::class.java)
+ }
+
+ private fun getSelectedActions(): List {
+ val actionList: MutableList = mutableListOf()
+ for (i in 0..4) {
+ val action = getActionFromPreference(i)
+ if (action != null) {
+ actionList.add(action)
+ }
+ }
+ Log.i(TAG, "getSelectedActions: " + actionList.toString())
+ return actionList
+ }
+
+ private fun getActionFromPreference(index: Int): Action? {
+ val sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this)
+ val actionPref = sharedPrefs.getString(preferencePrefix + index, "none")
+ return actionsAll.find { a -> a.settingName == actionPref }
+ }
+}
diff --git a/wear/src/main/res/drawable-notround-nodpi/action_tile_preview.png b/wear/src/main/res/drawable-notround-nodpi/action_tile_preview.png
index 5cd8cc62f1..a5970b7ce7 100644
Binary files a/wear/src/main/res/drawable-notround-nodpi/action_tile_preview.png and b/wear/src/main/res/drawable-notround-nodpi/action_tile_preview.png differ
diff --git a/wear/src/main/res/drawable-notround-nodpi/temp_target_tile.png b/wear/src/main/res/drawable-notround-nodpi/temp_target_tile.png
new file mode 100644
index 0000000000..b8eac46e2c
Binary files /dev/null and b/wear/src/main/res/drawable-notround-nodpi/temp_target_tile.png differ
diff --git a/wear/src/main/res/drawable-round-nodpi/action_tile_preview.png b/wear/src/main/res/drawable-round-nodpi/action_tile_preview.png
index 5cd8cc62f1..1e12b32e23 100644
Binary files a/wear/src/main/res/drawable-round-nodpi/action_tile_preview.png and b/wear/src/main/res/drawable-round-nodpi/action_tile_preview.png differ
diff --git a/wear/src/main/res/drawable-round-nodpi/temp_target_tile_preview.png b/wear/src/main/res/drawable-round-nodpi/temp_target_tile_preview.png
new file mode 100644
index 0000000000..17d23a596b
Binary files /dev/null and b/wear/src/main/res/drawable-round-nodpi/temp_target_tile_preview.png differ
diff --git a/wear/src/main/res/drawable/ic_target_activity.xml b/wear/src/main/res/drawable/ic_target_activity.xml
new file mode 100644
index 0000000000..4439597b75
--- /dev/null
+++ b/wear/src/main/res/drawable/ic_target_activity.xml
@@ -0,0 +1,18 @@
+
+
+
+
+
+
diff --git a/wear/src/main/res/drawable/ic_target_cancel.xml b/wear/src/main/res/drawable/ic_target_cancel.xml
new file mode 100644
index 0000000000..50d7304662
--- /dev/null
+++ b/wear/src/main/res/drawable/ic_target_cancel.xml
@@ -0,0 +1,15 @@
+
+
+
+
+
diff --git a/wear/src/main/res/drawable/ic_target_eatingsoon.xml b/wear/src/main/res/drawable/ic_target_eatingsoon.xml
new file mode 100644
index 0000000000..54b6162546
--- /dev/null
+++ b/wear/src/main/res/drawable/ic_target_eatingsoon.xml
@@ -0,0 +1,21 @@
+
+
+
+
+
+
+
diff --git a/wear/src/main/res/drawable/ic_target_hypo.xml b/wear/src/main/res/drawable/ic_target_hypo.xml
new file mode 100644
index 0000000000..30721cbf14
--- /dev/null
+++ b/wear/src/main/res/drawable/ic_target_hypo.xml
@@ -0,0 +1,21 @@
+
+
+
+
+
+
+
diff --git a/wear/src/main/res/drawable/ic_target_manual.xml b/wear/src/main/res/drawable/ic_target_manual.xml
new file mode 100644
index 0000000000..fc41c52757
--- /dev/null
+++ b/wear/src/main/res/drawable/ic_target_manual.xml
@@ -0,0 +1,15 @@
+
+
+
+
+
diff --git a/wear/src/main/res/layout/action_confirm_text.xml b/wear/src/main/res/layout/action_confirm_text.xml
index 3674cf7e24..031d98d1e2 100644
--- a/wear/src/main/res/layout/action_confirm_text.xml
+++ b/wear/src/main/res/layout/action_confirm_text.xml
@@ -1,8 +1,7 @@
+ android:layout_height="match_parent">
ambient_charging
+
+ - @string/menu_wizard
+ - @string/menu_bolus
+ - @string/menu_ecarb
+ - @string/menu_tempt
+ - @string/tile_none
+
+
+
+ - wizzard
+ - bolus
+ - carbs
+ - temp_target
+ - none
+
+
+
+ - @string/temp_target_activity
+ - @string/temp_target_eating_soon
+ - @string/temp_target_hypo
+ - @string/temp_target_manual
+ - @string/temp_target_cancel
+ - @string/tile_none
+
+
+
+ - activity
+ - eating_soon
+ - hypo
+ - manual
+ - cancel
+ - none
+
+
diff --git a/wear/src/main/res/values/colors.xml b/wear/src/main/res/values/colors.xml
index 7269a61922..708cec0302 100644
--- a/wear/src/main/res/values/colors.xml
+++ b/wear/src/main/res/values/colors.xml
@@ -48,6 +48,9 @@
#00FF00
+ #67DFE8
+ #FFFB8C00
+ #FF0000
#77dd77
diff --git a/wear/src/main/res/values/strings.xml b/wear/src/main/res/values/strings.xml
index f30fed3c74..cd2dd60ef3 100644
--- a/wear/src/main/res/values/strings.xml
+++ b/wear/src/main/res/values/strings.xml
@@ -14,6 +14,8 @@
AAPS(Steampunk)
AAPS(DigitalStyle)
+ AAPS(Actions)
+ AAPS(Temp Target)
No data!
Old data!
@@ -70,7 +72,6 @@
more Watchface settings
Look into Watchface configuration, please.
-
TempT
Wizard
Bolus
@@ -84,10 +85,16 @@
Menu
duration
+ Temp Target Requested
+ Bolus Requested
+ Updated Requested
+ Fill Requested
+ Carbs Requested
+ CPP Requested
target
low
high
- carbs
+ Carbs
percentage
start [min]
duration [h]
@@ -98,7 +105,7 @@
Free amount
CONFIRM
timeshift
- bolus
+ Bolus
Bolus Progress
press to cancel
@@ -113,7 +120,6 @@
IOB
no status
-
red
pink
purple
@@ -139,7 +145,6 @@
Simplify UI
Only show time and BG
-
Vibrate hourly
Show Week number
@@ -161,5 +166,12 @@
During Charging
Always On Mode
Always On and Charging
+ Eating
+ Hypo
+ Activity
+ Manual
+ Cancel
+ None
+ No tile config available
diff --git a/wear/src/main/res/xml/tile_configuration_activity.xml b/wear/src/main/res/xml/tile_configuration_activity.xml
new file mode 100644
index 0000000000..30fc68cd06
--- /dev/null
+++ b/wear/src/main/res/xml/tile_configuration_activity.xml
@@ -0,0 +1,33 @@
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/wear/src/main/res/xml/tile_configuration_tempt.xml b/wear/src/main/res/xml/tile_configuration_tempt.xml
new file mode 100644
index 0000000000..44ba856ef0
--- /dev/null
+++ b/wear/src/main/res/xml/tile_configuration_tempt.xml
@@ -0,0 +1,33 @@
+
+
+
+
+
+
+
+
+
+
+
+