Wear: add pref sync maxCarbs maxBolus
This commit is contained in:
parent
2013332d70
commit
eda1c097a9
8 changed files with 50 additions and 13 deletions
|
@ -732,13 +732,16 @@ public class WatchUpdaterService extends WearableListenerService implements Goog
|
||||||
boolean wearcontrol = sp.getBoolean(R.string.key_wear_control, false);
|
boolean wearcontrol = sp.getBoolean(R.string.key_wear_control, false);
|
||||||
boolean mgdl = units.equals(GlucoseUnit.MGDL);
|
boolean mgdl = units.equals(GlucoseUnit.MGDL);
|
||||||
int percentage = sp.getInt(R.string.key_boluswizard_percentage, 100);
|
int percentage = sp.getInt(R.string.key_boluswizard_percentage, 100);
|
||||||
|
int maxCarbs = sp.getInt(R.string.key_treatmentssafety_maxcarbs, 48);
|
||||||
|
double maxBolus = sp.getDouble(R.string.key_treatmentssafety_maxbolus, 3.0);
|
||||||
PutDataMapRequest dataMapRequest = PutDataMapRequest.create(NEW_PREFERENCES_PATH);
|
PutDataMapRequest dataMapRequest = PutDataMapRequest.create(NEW_PREFERENCES_PATH);
|
||||||
//unique content
|
//unique content
|
||||||
dataMapRequest.getDataMap().putLong("timestamp", System.currentTimeMillis());
|
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_wear_control), wearcontrol);
|
||||||
dataMapRequest.getDataMap().putBoolean(rh.gs(R.string.key_units_mgdl), mgdl);
|
dataMapRequest.getDataMap().putBoolean(rh.gs(R.string.key_units_mgdl), mgdl);
|
||||||
dataMapRequest.getDataMap().putInt(rh.gs(R.string.key_boluswizard_percentage), percentage);
|
dataMapRequest.getDataMap().putInt(rh.gs(R.string.key_boluswizard_percentage), percentage);
|
||||||
|
dataMapRequest.getDataMap().putInt(rh.gs(R.string.key_treatmentssafety_maxcarbs), maxCarbs);
|
||||||
|
dataMapRequest.getDataMap().putDouble(rh.gs(R.string.key_treatmentssafety_maxbolus),maxBolus);
|
||||||
PutDataRequest putDataRequest = dataMapRequest.asPutDataRequest();
|
PutDataRequest putDataRequest = dataMapRequest.asPutDataRequest();
|
||||||
Wearable.DataApi.putDataItem(googleApiClient, putDataRequest);
|
Wearable.DataApi.putDataItem(googleApiClient, putDataRequest);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -362,6 +362,19 @@ public class ListenerService extends WearableListenerService implements GoogleAp
|
||||||
editor.putBoolean(keyUnits, mgdl);
|
editor.putBoolean(keyUnits, mgdl);
|
||||||
editor.apply();
|
editor.apply();
|
||||||
}
|
}
|
||||||
|
String keyMaxCarbs = getString(R.string.key_treatmentssafety_maxcarbs);
|
||||||
|
if (dataMap.containsKey(keyMaxCarbs)) {
|
||||||
|
int maxCarbs = dataMap.getInt(keyMaxCarbs, 48);
|
||||||
|
editor.putInt(keyMaxCarbs, maxCarbs);
|
||||||
|
editor.apply();
|
||||||
|
}
|
||||||
|
String keyMaxBolus = getString(R.string.key_treatmentssafety_maxbolus);
|
||||||
|
if (dataMap.containsKey(keyMaxBolus)) {
|
||||||
|
float maxBolus = (float)dataMap.getDouble(keyMaxBolus, 3.0f);
|
||||||
|
editor.putFloat(keyMaxBolus, maxBolus);
|
||||||
|
editor.apply();
|
||||||
|
}
|
||||||
|
|
||||||
} else if (path.equals(QUICK_WIZARD_PATH)) {
|
} else if (path.equals(QUICK_WIZARD_PATH)) {
|
||||||
dataMap = DataMapItem.fromDataItem(event.getDataItem()).getDataMap();
|
dataMap = DataMapItem.fromDataItem(event.getDataItem()).getDataMap();
|
||||||
Log.i(TAG, "onDataChanged: QUICK_WIZARD_PATH" + dataMap);
|
Log.i(TAG, "onDataChanged: QUICK_WIZARD_PATH" + dataMap);
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
package info.nightscout.androidaps.interaction.actions;
|
package info.nightscout.androidaps.interaction.actions;
|
||||||
|
|
||||||
|
import android.content.SharedPreferences;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.preference.PreferenceManager;
|
||||||
import android.support.wearable.view.GridPagerAdapter;
|
import android.support.wearable.view.GridPagerAdapter;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
@ -17,11 +19,14 @@ import info.nightscout.shared.SafeParse;
|
||||||
public class BolusActivity extends ViewSelectorActivity {
|
public class BolusActivity extends ViewSelectorActivity {
|
||||||
|
|
||||||
PlusMinusEditText editInsulin;
|
PlusMinusEditText editInsulin;
|
||||||
|
float maxBolus;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setAdapter(new MyGridViewPagerAdapter());
|
setAdapter(new MyGridViewPagerAdapter());
|
||||||
|
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
|
||||||
|
maxBolus = sp.getFloat(getString(R.string.key_treatmentssafety_maxbolus), 3f);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -50,7 +55,7 @@ public class BolusActivity extends ViewSelectorActivity {
|
||||||
if (editInsulin != null) {
|
if (editInsulin != null) {
|
||||||
def = SafeParse.stringToDouble(editInsulin.editText.getText().toString());
|
def = SafeParse.stringToDouble(editInsulin.editText.getText().toString());
|
||||||
}
|
}
|
||||||
editInsulin = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, def, 0d, 30d, 0.1d, new DecimalFormat("#0.0"), false);
|
editInsulin = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, def, 0d, (double)maxBolus, 0.1d, new DecimalFormat("#0.0"),false);
|
||||||
setLabelToPlusMinusView(view, getString(R.string.action_insulin));
|
setLabelToPlusMinusView(view, getString(R.string.action_insulin));
|
||||||
container.addView(view);
|
container.addView(view);
|
||||||
view.requestFocus();
|
view.requestFocus();
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
package info.nightscout.androidaps.interaction.actions;
|
package info.nightscout.androidaps.interaction.actions;
|
||||||
|
|
||||||
|
import android.content.SharedPreferences;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.preference.PreferenceManager;
|
||||||
import android.support.wearable.view.GridPagerAdapter;
|
import android.support.wearable.view.GridPagerAdapter;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
@ -23,11 +25,14 @@ public class ECarbActivity extends ViewSelectorActivity {
|
||||||
PlusMinusEditText editCarbs;
|
PlusMinusEditText editCarbs;
|
||||||
PlusMinusEditText editStartTime;
|
PlusMinusEditText editStartTime;
|
||||||
PlusMinusEditText editDuration;
|
PlusMinusEditText editDuration;
|
||||||
|
int maxCarbs;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setAdapter(new MyGridViewPagerAdapter());
|
setAdapter(new MyGridViewPagerAdapter());
|
||||||
|
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
|
||||||
|
maxCarbs = sp.getInt(getString(R.string.key_treatmentssafety_maxcarbs), 48);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -56,7 +61,7 @@ public class ECarbActivity extends ViewSelectorActivity {
|
||||||
if (editCarbs != null) {
|
if (editCarbs != null) {
|
||||||
def = SafeParse.stringToDouble(editCarbs.editText.getText().toString());
|
def = SafeParse.stringToDouble(editCarbs.editText.getText().toString());
|
||||||
}
|
}
|
||||||
editCarbs = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, def, 0d, 150d, 1d, new DecimalFormat("0"), true);
|
editCarbs = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, def, 0d, (double)maxCarbs, 1d, new DecimalFormat("0"), true);
|
||||||
setLabelToPlusMinusView(view, getString(R.string.action_carbs));
|
setLabelToPlusMinusView(view, getString(R.string.action_carbs));
|
||||||
container.addView(view);
|
container.addView(view);
|
||||||
view.requestFocus();
|
view.requestFocus();
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
package info.nightscout.androidaps.interaction.actions;
|
package info.nightscout.androidaps.interaction.actions;
|
||||||
|
|
||||||
|
import android.content.SharedPreferences;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.preference.PreferenceManager;
|
||||||
import android.support.wearable.view.GridPagerAdapter;
|
import android.support.wearable.view.GridPagerAdapter;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
@ -22,11 +24,16 @@ public class TreatmentActivity extends ViewSelectorActivity {
|
||||||
|
|
||||||
PlusMinusEditText editCarbs;
|
PlusMinusEditText editCarbs;
|
||||||
PlusMinusEditText editInsulin;
|
PlusMinusEditText editInsulin;
|
||||||
|
int maxCarbs;
|
||||||
|
float maxBolus;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setAdapter(new MyGridViewPagerAdapter());
|
setAdapter(new MyGridViewPagerAdapter());
|
||||||
|
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
|
||||||
|
maxCarbs = sp.getInt(getString(R.string.key_treatmentssafety_maxcarbs), 48);
|
||||||
|
maxBolus = sp.getFloat(getString(R.string.key_treatmentssafety_maxbolus), 3f);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -56,7 +63,7 @@ public class TreatmentActivity extends ViewSelectorActivity {
|
||||||
if (editInsulin != null) {
|
if (editInsulin != null) {
|
||||||
def = SafeParse.stringToDouble(editInsulin.editText.getText().toString());
|
def = SafeParse.stringToDouble(editInsulin.editText.getText().toString());
|
||||||
}
|
}
|
||||||
editInsulin = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, def, 0d, 30d, 0.1d, new DecimalFormat("#0.0"), false);
|
editInsulin = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, def, 0d, (double) maxBolus, 0.1d, new DecimalFormat("#0.0"),false);
|
||||||
setLabelToPlusMinusView(view, getString(R.string.action_insulin));
|
setLabelToPlusMinusView(view, getString(R.string.action_insulin));
|
||||||
container.addView(view);
|
container.addView(view);
|
||||||
view.requestFocus();
|
view.requestFocus();
|
||||||
|
@ -67,7 +74,7 @@ public class TreatmentActivity extends ViewSelectorActivity {
|
||||||
if (editCarbs != null) {
|
if (editCarbs != null) {
|
||||||
def = SafeParse.stringToDouble(editCarbs.editText.getText().toString());
|
def = SafeParse.stringToDouble(editCarbs.editText.getText().toString());
|
||||||
}
|
}
|
||||||
editCarbs = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, def, 0d, 150d, 1d, new DecimalFormat("0"), false);
|
editCarbs = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, def, 0d, (double)maxCarbs, 1d, new DecimalFormat("0"),false);
|
||||||
setLabelToPlusMinusView(view, getString(R.string.action_carbs));
|
setLabelToPlusMinusView(view, getString(R.string.action_carbs));
|
||||||
container.addView(view);
|
container.addView(view);
|
||||||
return view;
|
return view;
|
||||||
|
|
|
@ -27,6 +27,7 @@ public class WizardActivity extends ViewSelectorActivity {
|
||||||
|
|
||||||
boolean hasPercentage;
|
boolean hasPercentage;
|
||||||
int percentage;
|
int percentage;
|
||||||
|
int maxCarbs;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
@ -35,6 +36,7 @@ public class WizardActivity extends ViewSelectorActivity {
|
||||||
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
|
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
|
||||||
hasPercentage = sp.getBoolean("wizardpercentage", false);
|
hasPercentage = sp.getBoolean("wizardpercentage", false);
|
||||||
percentage = sp.getInt(getString(R.string.key_boluswizard_percentage), 100);
|
percentage = sp.getInt(getString(R.string.key_boluswizard_percentage), 100);
|
||||||
|
maxCarbs = sp.getInt(getString(R.string.key_treatmentssafety_maxcarbs), 48);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -60,10 +62,10 @@ public class WizardActivity extends ViewSelectorActivity {
|
||||||
if (col == 0) {
|
if (col == 0) {
|
||||||
final View view = getInflatedPlusMinusView(container);
|
final View view = getInflatedPlusMinusView(container);
|
||||||
if (editCarbs == null) {
|
if (editCarbs == null) {
|
||||||
editCarbs = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, 0d, 0d, 150d, 1d, new DecimalFormat("0"), false);
|
editCarbs = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, 0d, 0d, (double)maxCarbs, 1d, new DecimalFormat("0"), false);
|
||||||
} else {
|
} else {
|
||||||
double def = SafeParse.stringToDouble(editCarbs.editText.getText().toString());
|
double def = SafeParse.stringToDouble(editCarbs.editText.getText().toString());
|
||||||
editCarbs = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, def, 0d, 150d, 1d, new DecimalFormat("0"), false);
|
editCarbs = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, def, 0d, (double)maxCarbs, 1d, new DecimalFormat("0"),false);
|
||||||
}
|
}
|
||||||
setLabelToPlusMinusView(view, getString(R.string.action_carbs));
|
setLabelToPlusMinusView(view, getString(R.string.action_carbs));
|
||||||
container.addView(view);
|
container.addView(view);
|
||||||
|
|
|
@ -32,7 +32,7 @@ public class PlusMinusEditText implements View.OnKeyListener,
|
||||||
Double minValue = 0d;
|
Double minValue = 0d;
|
||||||
Double maxValue = 1d;
|
Double maxValue = 1d;
|
||||||
Double step = 1d;
|
Double step = 1d;
|
||||||
NumberFormat formater;
|
NumberFormat formatter;
|
||||||
boolean allowZero = false;
|
boolean allowZero = false;
|
||||||
boolean roundRobin;
|
boolean roundRobin;
|
||||||
|
|
||||||
|
@ -74,11 +74,11 @@ public class PlusMinusEditText implements View.OnKeyListener,
|
||||||
private static final int MSG_INC = 0;
|
private static final int MSG_INC = 0;
|
||||||
private static final int MSG_DEC = 1;
|
private static final int MSG_DEC = 1;
|
||||||
|
|
||||||
public PlusMinusEditText(View view, int editTextID, int plusID, int minusID, Double initValue, Double minValue, Double maxValue, Double step, NumberFormat formater, boolean allowZero) {
|
public PlusMinusEditText(View view, int editTextID, int plusID, int minusID, Double initValue, Double minValue, Double maxValue, Double step, NumberFormat formatter, boolean allowZero) {
|
||||||
this(view, editTextID, plusID, minusID, initValue, minValue, maxValue, step, formater, allowZero, false);
|
this(view, editTextID, plusID, minusID, initValue, minValue, maxValue, step, formatter, allowZero, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PlusMinusEditText(View view, int editTextID, int plusID, int minusID, Double initValue, Double minValue, Double maxValue, Double step, NumberFormat formater, boolean allowZero, boolean roundRobin) {
|
public PlusMinusEditText(View view, int editTextID, int plusID, int minusID, Double initValue, Double minValue, Double maxValue, Double step, NumberFormat formatter, boolean allowZero, boolean roundRobin) {
|
||||||
editText = view.findViewById(editTextID);
|
editText = view.findViewById(editTextID);
|
||||||
minusImage = view.findViewById(minusID);
|
minusImage = view.findViewById(minusID);
|
||||||
plusImage = view.findViewById(plusID);
|
plusImage = view.findViewById(plusID);
|
||||||
|
@ -87,7 +87,7 @@ public class PlusMinusEditText implements View.OnKeyListener,
|
||||||
this.minValue = minValue;
|
this.minValue = minValue;
|
||||||
this.maxValue = maxValue;
|
this.maxValue = maxValue;
|
||||||
this.step = step;
|
this.step = step;
|
||||||
this.formater = formater;
|
this.formatter = formatter;
|
||||||
this.allowZero = allowZero;
|
this.allowZero = allowZero;
|
||||||
this.roundRobin = roundRobin;
|
this.roundRobin = roundRobin;
|
||||||
|
|
||||||
|
@ -159,7 +159,7 @@ public class PlusMinusEditText implements View.OnKeyListener,
|
||||||
if (value == 0d && !allowZero)
|
if (value == 0d && !allowZero)
|
||||||
editText.setText("");
|
editText.setText("");
|
||||||
else
|
else
|
||||||
editText.setText(formater.format(value));
|
editText.setText(formatter.format(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void startUpdating(boolean inc) {
|
private void startUpdating(boolean inc) {
|
||||||
|
|
|
@ -172,6 +172,8 @@
|
||||||
<string name="key_wear_control" translatable="false">wearcontrol</string>
|
<string name="key_wear_control" translatable="false">wearcontrol</string>
|
||||||
<string name="key_units_mgdl" translatable="false">units_mgdl</string>
|
<string name="key_units_mgdl" translatable="false">units_mgdl</string>
|
||||||
<string name="key_boluswizard_percentage" translatable="false">boluswizard_percentage</string>
|
<string name="key_boluswizard_percentage" translatable="false">boluswizard_percentage</string>
|
||||||
|
<string name="key_treatmentssafety_maxcarbs" translatable="false">treatmentssafety_maxcarbs</string>
|
||||||
|
<string name="key_treatmentssafety_maxbolus" translatable="false">treatmentssafety_maxbolus</string>
|
||||||
<string name="simple_ui_off">Off</string>
|
<string name="simple_ui_off">Off</string>
|
||||||
<string name="simple_ui_charging">During Charging</string>
|
<string name="simple_ui_charging">During Charging</string>
|
||||||
<string name="simple_ui_always_on">Always On Mode</string>
|
<string name="simple_ui_always_on">Always On Mode</string>
|
||||||
|
|
Loading…
Reference in a new issue