wear keep data when looking/swiping back

This commit is contained in:
AdrianLxM 2017-02-10 12:00:38 +01:00
parent 4220d7712a
commit bdcff12b01
5 changed files with 78 additions and 24 deletions

View file

@ -68,14 +68,22 @@ public class BolusActivity extends Activity {
final View view = LayoutInflater.from(getApplicationContext()).inflate(R.layout.action_editplusminus_item, container, false); final View view = LayoutInflater.from(getApplicationContext()).inflate(R.layout.action_editplusminus_item, container, false);
final TextView textView = (TextView) view.findViewById(R.id.label); final TextView textView = (TextView) view.findViewById(R.id.label);
textView.setText("insulin"); textView.setText("insulin");
editInsulin = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, 0d, 0d, 30d, 0.1d, new DecimalFormat("#0.0"), false); double def = 0;
if (editInsulin != null){
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);
container.addView(view); container.addView(view);
return view; return view;
} else if(col == 1){ } else if(col == 1){
final View view = LayoutInflater.from(getApplicationContext()).inflate(R.layout.action_editplusminus_item, container, false); final View view = LayoutInflater.from(getApplicationContext()).inflate(R.layout.action_editplusminus_item, container, false);
final TextView textView = (TextView) view.findViewById(R.id.label); final TextView textView = (TextView) view.findViewById(R.id.label);
textView.setText("carbs"); textView.setText("carbs");
editCarbs = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, 0d, 0d, 100d, 1d, new DecimalFormat("0"), false); double def = 0;
if (editCarbs != null){
def = SafeParse.stringToDouble(editCarbs.editText.getText().toString());
}
editCarbs = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, def, 0d, 100d, 1d, new DecimalFormat("0"), false);
container.addView(view); container.addView(view);
return view; return view;
} else { } else {

View file

@ -67,7 +67,11 @@ public class FillActivity extends Activity {
final View view = LayoutInflater.from(getApplicationContext()).inflate(R.layout.action_editplusminus_item, container, false); final View view = LayoutInflater.from(getApplicationContext()).inflate(R.layout.action_editplusminus_item, container, false);
final TextView textView = (TextView) view.findViewById(R.id.label); final TextView textView = (TextView) view.findViewById(R.id.label);
textView.setText("insulin"); textView.setText("insulin");
editInsulin = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, 0d, 0d, 30d, 0.1d, new DecimalFormat("#0.0"), false); double def = 0d;
if (editInsulin != null){
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);
container.addView(view); container.addView(view);
return view; return view;
} else { } else {

View file

@ -77,7 +77,12 @@ public class TempTargetActivity extends Activity {
final View view = LayoutInflater.from(getApplicationContext()).inflate(R.layout.action_editplusminus_item, container, false); final View view = LayoutInflater.from(getApplicationContext()).inflate(R.layout.action_editplusminus_item, container, false);
final TextView textView = (TextView) view.findViewById(R.id.label); final TextView textView = (TextView) view.findViewById(R.id.label);
textView.setText("duration"); textView.setText("duration");
time = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, 60d, 0d, 24*60d, 1d, new DecimalFormat("0"), false); if (time == null) {
time = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, 60d, 0d, 24 * 60d, 1d, new DecimalFormat("0"), false);
} else {
double def = SafeParse.stringToDouble(time.editText.getText().toString());
time = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, def, 0d, 24 * 60d, 1d, new DecimalFormat("0"), false);
}
container.addView(view); container.addView(view);
return view; return view;
@ -86,9 +91,17 @@ public class TempTargetActivity extends Activity {
final TextView textView = (TextView) view.findViewById(R.id.label); final TextView textView = (TextView) view.findViewById(R.id.label);
textView.setText("low"); textView.setText("low");
if (isMGDL){ if (isMGDL){
lowRange = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, 100d, 72d, 180d, 1d, new DecimalFormat("0"), false); double def = 100;
if (lowRange != null){
def = SafeParse.stringToDouble(lowRange.editText.getText().toString());
}
lowRange = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, def, 72d, 180d, 1d, new DecimalFormat("0"), false);
} else { } else {
lowRange = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, 5.5, 4d, 10d, 0.1d, new DecimalFormat("#0.0"), false); double def = 5.5;
if (lowRange != null){
def = SafeParse.stringToDouble(lowRange.editText.getText().toString());
}
lowRange = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, def, 4d, 10d, 0.1d, new DecimalFormat("#0.0"), false);
} }
container.addView(view); container.addView(view);
@ -98,9 +111,17 @@ public class TempTargetActivity extends Activity {
final TextView textView = (TextView) view.findViewById(R.id.label); final TextView textView = (TextView) view.findViewById(R.id.label);
textView.setText("high"); textView.setText("high");
if (isMGDL){ if (isMGDL){
highRange = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, 100d, 72d, 180d, 1d, new DecimalFormat("0"), false); double def = 100;
if (highRange != null){
def = SafeParse.stringToDouble(highRange.editText.getText().toString());
}
highRange = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, def, 72d, 180d, 1d, new DecimalFormat("0"), false);
} else { } else {
highRange = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, 5.5, 4d, 10d, 0.1d, new DecimalFormat("#0.0"), false); double def = 5.5;
if (highRange != null){
def = SafeParse.stringToDouble(highRange.editText.getText().toString());
}
highRange = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, def, 4d, 10d, 0.1d, new DecimalFormat("#0.0"), false);
} }
container.addView(view); container.addView(view);

View file

@ -71,7 +71,13 @@ public class WizardActivity extends Activity {
final View view = LayoutInflater.from(getApplicationContext()).inflate(R.layout.action_editplusminus_item, container, false); final View view = LayoutInflater.from(getApplicationContext()).inflate(R.layout.action_editplusminus_item, container, false);
final TextView textView = (TextView) view.findViewById(R.id.label); final TextView textView = (TextView) view.findViewById(R.id.label);
textView.setText("carbs"); textView.setText("carbs");
editCarbs = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, 0d, 0d, 100d, 1d, new DecimalFormat("0"), false); if (editCarbs == null) {
editCarbs = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, 0d, 0d, 100d, 1d, new DecimalFormat("0"), false);
} else {
double def = SafeParse.stringToDouble(editCarbs.editText.getText().toString());
editCarbs = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, def, 0d, 100d, 1d, new DecimalFormat("0"), false);
}
container.addView(view); container.addView(view);
return view; return view;
} else if(col == 1){ } else if(col == 1){
@ -80,6 +86,11 @@ public class WizardActivity extends Activity {
textView.setText("include BG?"); textView.setText("include BG?");
final ImageView togglebutton = (ImageView) view.findViewById(R.id.togglebutton); final ImageView togglebutton = (ImageView) view.findViewById(R.id.togglebutton);
if(useBG){
togglebutton.setImageResource(R.drawable.ic_toggle_on);
} else {
togglebutton.setImageResource(R.drawable.ic_toggle_off);
}
togglebutton.setOnClickListener(new View.OnClickListener() { togglebutton.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
@ -99,6 +110,11 @@ public class WizardActivity extends Activity {
textView.setText("Bolus IOB?"); textView.setText("Bolus IOB?");
final ImageView togglebutton = (ImageView) view.findViewById(R.id.togglebutton); final ImageView togglebutton = (ImageView) view.findViewById(R.id.togglebutton);
if(includeBolusIOB){
togglebutton.setImageResource(R.drawable.ic_toggle_on);
} else {
togglebutton.setImageResource(R.drawable.ic_toggle_off);
}
togglebutton.setOnClickListener(new View.OnClickListener() { togglebutton.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
@ -118,6 +134,11 @@ public class WizardActivity extends Activity {
textView.setText("Basal IOB?"); textView.setText("Basal IOB?");
final ImageView togglebutton = (ImageView) view.findViewById(R.id.togglebutton); final ImageView togglebutton = (ImageView) view.findViewById(R.id.togglebutton);
if(includeBasalIOB){
togglebutton.setImageResource(R.drawable.ic_toggle_on);
} else {
togglebutton.setImageResource(R.drawable.ic_toggle_off);
}
togglebutton.setOnClickListener(new View.OnClickListener() { togglebutton.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {

View file

@ -43,6 +43,13 @@
<sourceFolder url="file://$MODULE_DIR$/src/fullDebug/jni" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/src/fullDebug/jni" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/fullDebug/rs" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/src/fullDebug/rs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/fullDebug/shaders" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/src/fullDebug/shaders" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/androidTest/full/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/androidTest/full/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/androidTest/full/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/androidTest/full/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/apt/androidTest/full/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/androidTest/full/debug" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/resValues/androidTest/full/debug" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testFullDebug/res" type="java-test-resource" /> <sourceFolder url="file://$MODULE_DIR$/src/testFullDebug/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testFullDebug/resources" type="java-test-resource" /> <sourceFolder url="file://$MODULE_DIR$/src/testFullDebug/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testFullDebug/assets" type="java-test-resource" /> <sourceFolder url="file://$MODULE_DIR$/src/testFullDebug/assets" type="java-test-resource" />
@ -51,13 +58,6 @@
<sourceFolder url="file://$MODULE_DIR$/src/testFullDebug/jni" isTestSource="true" /> <sourceFolder url="file://$MODULE_DIR$/src/testFullDebug/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testFullDebug/rs" isTestSource="true" /> <sourceFolder url="file://$MODULE_DIR$/src/testFullDebug/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testFullDebug/shaders" isTestSource="true" /> <sourceFolder url="file://$MODULE_DIR$/src/testFullDebug/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/androidTest/full/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/androidTest/full/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/androidTest/full/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/androidTest/full/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/apt/androidTest/full/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/androidTest/full/debug" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/resValues/androidTest/full/debug" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/full/res" type="java-resource" /> <sourceFolder url="file://$MODULE_DIR$/src/full/res" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/full/resources" type="java-resource" /> <sourceFolder url="file://$MODULE_DIR$/src/full/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/full/assets" type="java-resource" /> <sourceFolder url="file://$MODULE_DIR$/src/full/assets" type="java-resource" />
@ -66,14 +66,6 @@
<sourceFolder url="file://$MODULE_DIR$/src/full/jni" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/src/full/jni" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/full/rs" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/src/full/rs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/full/shaders" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/src/full/shaders" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestFull/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestFull/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestFull/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestFull/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestFull/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestFull/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestFull/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestFull/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testFull/res" type="java-test-resource" /> <sourceFolder url="file://$MODULE_DIR$/src/testFull/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testFull/resources" type="java-test-resource" /> <sourceFolder url="file://$MODULE_DIR$/src/testFull/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testFull/assets" type="java-test-resource" /> <sourceFolder url="file://$MODULE_DIR$/src/testFull/assets" type="java-test-resource" />
@ -82,6 +74,14 @@
<sourceFolder url="file://$MODULE_DIR$/src/testFull/jni" isTestSource="true" /> <sourceFolder url="file://$MODULE_DIR$/src/testFull/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testFull/rs" isTestSource="true" /> <sourceFolder url="file://$MODULE_DIR$/src/testFull/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testFull/shaders" isTestSource="true" /> <sourceFolder url="file://$MODULE_DIR$/src/testFull/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestFull/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestFull/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestFull/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestFull/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestFull/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestFull/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestFull/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestFull/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/res" type="java-resource" /> <sourceFolder url="file://$MODULE_DIR$/src/debug/res" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/resources" type="java-resource" /> <sourceFolder url="file://$MODULE_DIR$/src/debug/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/assets" type="java-resource" /> <sourceFolder url="file://$MODULE_DIR$/src/debug/assets" type="java-resource" />