diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/wear/wearintegration/WatchUpdaterService.java b/app/src/main/java/info/nightscout/androidaps/plugins/general/wear/wearintegration/WatchUpdaterService.java
index 1ce5c509bb..d6c840625f 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/general/wear/wearintegration/WatchUpdaterService.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/wear/wearintegration/WatchUpdaterService.java
@@ -720,16 +720,21 @@ public class WatchUpdaterService extends WearableListenerService implements Goog
private void sendPreferences() {
if (googleApiClient != null && googleApiClient.isConnected()) {
+ GlucoseUnit units = profileFunction.getUnits();
boolean wearcontrol = sp.getBoolean(R.string.key_wear_control, false);
+ boolean mgdl = units.equals(GlucoseUnit.MGDL);
+ int percentage = sp.getInt(R.string.key_boluswizard_percentage, 100);
PutDataMapRequest dataMapRequest = PutDataMapRequest.create(NEW_PREFERENCES_PATH);
//unique content
dataMapRequest.getDataMap().putLong("timestamp", System.currentTimeMillis());
dataMapRequest.getDataMap().putBoolean(rh.gs(R.string.key_wear_control), wearcontrol);
+ dataMapRequest.getDataMap().putBoolean(rh.gs(R.string.key_units_mgdl), mgdl);
+ dataMapRequest.getDataMap().putInt(rh.gs(R.string.key_boluswizard_percentage), percentage);
PutDataRequest putDataRequest = dataMapRequest.asPutDataRequest();
Wearable.DataApi.putDataItem(googleApiClient, putDataRequest);
} else {
- Log.e("SendStatus", "No connection to wearable available!");
+ Log.e("SendPreferences", "No connection to wearable available!");
}
}
diff --git a/core/src/main/res/values/strings.xml b/core/src/main/res/values/strings.xml
index e0c2c022a0..76428aa88f 100644
--- a/core/src/main/res/values/strings.xml
+++ b/core/src/main/res/values/strings.xml
@@ -27,6 +27,7 @@
virtualpump_type
QuickWizard
wearcontrol
+ units_mgdl
show_notes_entry_dialogs
autosens_max
autosens_min
diff --git a/wear/src/main/java/info/nightscout/androidaps/data/ListenerService.java b/wear/src/main/java/info/nightscout/androidaps/data/ListenerService.java
index ea49e6c7d7..bd64caacc4 100644
--- a/wear/src/main/java/info/nightscout/androidaps/data/ListenerService.java
+++ b/wear/src/main/java/info/nightscout/androidaps/data/ListenerService.java
@@ -544,14 +544,27 @@ public class ListenerService extends WearableListenerService implements GoogleAp
LocalBroadcastManager.getInstance(this).sendBroadcast(messageIntent);
} else if (path.equals(NEW_PREFERENCES_PATH)) {
dataMap = DataMapItem.fromDataItem(event.getDataItem()).getDataMap();
- if (dataMap.containsKey("wearcontrol")) {
- boolean wearcontrol = dataMap.getBoolean("wearcontrol", false);
- SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
- SharedPreferences.Editor editor = sharedPreferences.edit();
- editor.putBoolean("wearcontrol", wearcontrol);
+ SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
+ SharedPreferences.Editor editor = sharedPreferences.edit();
+ String keyControl = getString(R.string.key_wear_control);
+ if (dataMap.containsKey(keyControl)) {
+ boolean wearControl = dataMap.getBoolean(keyControl, false);
+ editor.putBoolean(keyControl, wearControl);
editor.apply();
updateTiles();
}
+ String keyPercentage = getString(R.string.key_boluswizard_percentage);
+ if (dataMap.containsKey(keyPercentage)) {
+ int wpercentage = dataMap.getInt(keyPercentage, 100);
+ editor.putInt(keyPercentage, wpercentage);
+ editor.apply();
+ }
+ String keyUnits = getString(R.string.key_units_mgdl);
+ if (dataMap.containsKey(keyUnits)) {
+ boolean mgdl = dataMap.getBoolean(keyUnits, true);
+ editor.putBoolean(keyUnits, mgdl);
+ editor.apply();
+ }
} else if (path.equals(NEW_CHANGECONFIRMATIONREQUEST_PATH)) {
String title = DataMapItem.fromDataItem(event.getDataItem()).getDataMap().getString("title");
String message = DataMapItem.fromDataItem(event.getDataItem()).getDataMap().getString("message");
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 9d31fc5154..8fbdcde783 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
@@ -26,6 +26,7 @@ public class WizardActivity extends ViewSelectorActivity {
PlusMinusEditText editPercentage;
boolean hasPercentage;
+ double percentage;
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -33,6 +34,7 @@ public class WizardActivity extends ViewSelectorActivity {
setAdapter(new MyGridViewPagerAdapter());
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
hasPercentage = sp.getBoolean("wizardpercentage", false);
+ percentage = sp.getInt(getString(R.string.key_boluswizard_percentage), 100);
}
@Override
@@ -70,7 +72,7 @@ public class WizardActivity extends ViewSelectorActivity {
} else if (col == 1 && hasPercentage) {
final View view = getInflatedPlusMinusView(container);
if (editPercentage == null) {
- editPercentage = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, 100d, 50d, 150d, 1d, new DecimalFormat("0"), false);
+ editPercentage = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, percentage, 50d, 150d, 1d, new DecimalFormat("0"), false);
} else {
double def = SafeParse.stringToDouble(editPercentage.editText.getText().toString());
editPercentage = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, def, 50d, 150d, 1d, new DecimalFormat("0"), false);
@@ -83,13 +85,9 @@ 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((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)
-
- int percentage = 100;
-
- if (editPercentage != null)
+ if (editPercentage != null) {
percentage = SafeParse.stringToInt(editPercentage.editText.getText().toString());
+ }
String actionstring = "wizard2 " + SafeParse.stringToInt(editCarbs.editText.getText().toString())
+ " " + percentage;
diff --git a/wear/src/main/res/values/strings.xml b/wear/src/main/res/values/strings.xml
index c07f881e8f..77481f8360 100644
--- a/wear/src/main/res/values/strings.xml
+++ b/wear/src/main/res/values/strings.xml
@@ -166,6 +166,9 @@
Bolus progress and cancel
Bolus progress and cancel with less vibrations
+ wearcontrol
+ units_mgdl
+ boluswizard_percentage
Off
During Charging
Always On Mode
diff --git a/wear/src/main/res/xml/preferences.xml b/wear/src/main/res/xml/preferences.xml
index a6ecb5ce95..efadbc39d9 100644
--- a/wear/src/main/res/xml/preferences.xml
+++ b/wear/src/main/res/xml/preferences.xml
@@ -101,15 +101,6 @@
android:summary="Chart Timeframe"
android:title="@string/pref_chart_timeframe" />
-
-