wear wizard confirm reformat, connection stability, prime not in menu per default

This commit is contained in:
AdrianLxM 2017-02-11 19:51:33 +01:00
parent 6cb192b876
commit d9103b6823
5 changed files with 56 additions and 19 deletions

View file

@ -201,13 +201,15 @@ public class ActionStringHandler {
if(bgReading==null && useBG){ if(bgReading==null && useBG){
sendError("No recent BG to base calculation on!"); return; sendError("No recent BG to base calculation on!"); return;
} }
DecimalFormat format = new DecimalFormat("0.00");
BolusWizard bolusWizard = new BolusWizard(); BolusWizard bolusWizard = new BolusWizard();
bolusWizard.doCalc(profile.getDefaultProfile(), carbsAfterConstraints, useBG?bgReading.valueToUnits(profile.getUnits()):0d, 0d, useBolusIOB, useBasalIOB); bolusWizard.doCalc(profile.getDefaultProfile(), carbsAfterConstraints, useBG?bgReading.valueToUnits(profile.getUnits()):0d, 0d, useBolusIOB, useBasalIOB);
Double insulinAfterConstraints = MainApp.getConfigBuilder().applyBolusConstraints(bolusWizard.calculatedTotalInsulin); Double insulinAfterConstraints = MainApp.getConfigBuilder().applyBolusConstraints(bolusWizard.calculatedTotalInsulin);
if(insulinAfterConstraints - bolusWizard.calculatedTotalInsulin !=0){ if(insulinAfterConstraints - bolusWizard.calculatedTotalInsulin !=0){
sendError("Insulin contraint violation!"); return; sendError("Insulin contraint violation!" +
"\nCannot deliver " + format.format(bolusWizard.calculatedTotalInsulin) +"!");
return;
} }
@ -222,17 +224,14 @@ public class ActionStringHandler {
} else { } else {
rAction = actionstring; rAction = actionstring;
} }
DecimalFormat format = new DecimalFormat("0.00");
rMessage += "Carbs: " + bolusWizard.carbs + "g"; rMessage += "Carbs: " + bolusWizard.carbs + "g";
rMessage += "\nBolus: " + format.format(bolusWizard.calculatedTotalInsulin) + "U"; rMessage += "\nBolus: " + format.format(bolusWizard.calculatedTotalInsulin) + "U";
rMessage += "\nCalculation: "; rMessage += "\n_____________";
rMessage += "\nWizard: " + format.format(insulin) + "U"; rMessage += "\nCalc (IC:" + DecimalFormatter.to1Decimal(bolusWizard.ic) + ", " + "ISF:" + DecimalFormatter.to1Decimal(bolusWizard.sens) + "): ";
rMessage += "\nCarb: " + format.format(bolusWizard.insulinFromCarbs) + "U"; rMessage += "\nFrom Carbs: " + format.format(bolusWizard.insulinFromCarbs) + "U";
if(useBG)rMessage += "\nBG: " + format.format(bolusWizard.insulinFromBG) + "U"; if(useBG)rMessage += "\nFrom BG: " + format.format(bolusWizard.insulinFromBG) + "U";
if(useBolusIOB)rMessage += "\nBolus IOB: " + format.format(bolusWizard.insulingFromBolusIOB) + "U"; if(useBolusIOB)rMessage += "\nBolus IOB: " + format.format(bolusWizard.insulingFromBolusIOB) + "U";
if(useBasalIOB)rMessage += "\nBasal IOB: " + format.format(bolusWizard.insulingFromBasalsIOB) + "U"; if(useBasalIOB)rMessage += "\nBasal IOB: " + format.format(bolusWizard.insulingFromBasalsIOB) + "U";
rMessage += "\nIC:" + DecimalFormatter.to1Decimal(bolusWizard.ic);
if(useBG)rMessage += " ISF:" + DecimalFormatter.to1Decimal(bolusWizard.sens);
lastBolusWizard = bolusWizard; lastBolusWizard = bolusWizard;
@ -315,7 +314,7 @@ public class ActionStringHandler {
} }
private static void doFillBolus(final Double amount) { private static void doFillBolus(final Double amount) {
if(1==1)return; //if(1==1)return;
Handler handler = new Handler(handlerThread.getLooper()); Handler handler = new Handler(handlerThread.getLooper());
handler.post(new Runnable() { handler.post(new Runnable() {
@Override @Override
@ -331,7 +330,7 @@ public class ActionStringHandler {
} }
private static void doBolus(final Double amount, final Integer carbs) { private static void doBolus(final Double amount, final Integer carbs) {
if(1==1)return; //if(1==1)return;
Handler handler = new Handler(handlerThread.getLooper()); Handler handler = new Handler(handlerThread.getLooper());
handler.post(new Runnable() { handler.post(new Runnable() {
@Override @Override

View file

@ -80,8 +80,20 @@ public class ListenerService extends WearableListenerService implements GoogleAp
Wearable.MessageApi.sendMessage(googleApiClient, node.getId(), WEARABLE_RESEND_PATH, null); Wearable.MessageApi.sendMessage(googleApiClient, node.getId(), WEARABLE_RESEND_PATH, null);
} }
} }
} else } else {
googleApiClient.connect(); googleApiClient.blockingConnect(15, TimeUnit.SECONDS);
if (googleApiClient.isConnected()) {
if (System.currentTimeMillis() - lastRequest > 20 * 1000) { // enforce 20-second debounce period
lastRequest = System.currentTimeMillis();
NodeApi.GetConnectedNodesResult nodes =
Wearable.NodeApi.getConnectedNodes(googleApiClient).await();
for (Node node : nodes.getNodes()) {
Wearable.MessageApi.sendMessage(googleApiClient, node.getId(), WEARABLE_RESEND_PATH, null);
}
}
}
}
return null; return null;
} }
} }

View file

@ -1,6 +1,9 @@
package info.nightscout.androidaps.interaction.menus; package info.nightscout.androidaps.interaction.menus;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import info.nightscout.androidaps.data.ListenerService; import info.nightscout.androidaps.data.ListenerService;
import info.nightscout.androidaps.interaction.AAPSPreferences; import info.nightscout.androidaps.interaction.AAPSPreferences;
@ -15,8 +18,20 @@ import info.nightscout.androidaps.interaction.actions.WizardActivity;
public class MainMenuActivity extends MenuListActivity { public class MainMenuActivity extends MenuListActivity {
SharedPreferences sp;
@Override
protected void onCreate(Bundle savedInstanceState) {
sp = PreferenceManager.getDefaultSharedPreferences(this);
super.onCreate(savedInstanceState);
ListenerService.requestData(this);
}
@Override @Override
protected String[] getElements() { protected String[] getElements() {
boolean showPrimeFill = sp.getBoolean("primefill", false);
return new String[] { return new String[] {
"TempT", "TempT",
"Bolus", "Bolus",
@ -24,7 +39,7 @@ public class MainMenuActivity extends MenuListActivity {
"Settings", "Settings",
"Re-Sync", "Re-Sync",
"Status", "Status",
"Prime/Fill"}; showPrimeFill?"Prime/Fill":""};
} }
@Override @Override
@ -61,9 +76,12 @@ public class MainMenuActivity extends MenuListActivity {
this.startActivity(intent); this.startActivity(intent);
break; break;
case 6: case 6:
boolean showPrimeFill = sp.getBoolean("primefill", false);
if(showPrimeFill) {
intent = new Intent(this, FillMenuActivity.class); intent = new Intent(this, FillMenuActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
this.startActivity(intent); this.startActivity(intent);
}
break; break;
} }

View file

@ -18,7 +18,7 @@ import info.nightscout.androidaps.R;
public abstract class MenuListActivity extends Activity public abstract class MenuListActivity extends Activity
implements WearableListView.ClickListener { implements WearableListView.ClickListener {
String[] elements = getElements(); String[] elements;
protected abstract String[] getElements(); protected abstract String[] getElements();
@ -33,6 +33,7 @@ public abstract class MenuListActivity extends Activity
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
elements = getElements();
setContentView(R.layout.actions_list_activity); setContentView(R.layout.actions_list_activity);
// Get the list component from the layout of the activity // Get the list component from the layout of the activity

View file

@ -105,7 +105,6 @@
app:wear_iconOff="@drawable/settings_off" app:wear_iconOff="@drawable/settings_off"
app:wear_iconOn="@drawable/settings_on"/> app:wear_iconOn="@drawable/settings_on"/>
<CheckBoxPreference <CheckBoxPreference
android:defaultValue="true" android:defaultValue="true"
android:key="animation" android:key="animation"
@ -113,4 +112,12 @@
android:title="Animations" android:title="Animations"
app:wear_iconOff="@drawable/settings_off" app:wear_iconOff="@drawable/settings_off"
app:wear_iconOn="@drawable/settings_on"/> app:wear_iconOn="@drawable/settings_on"/>
<CheckBoxPreference
android:defaultValue="false"
android:key="primefill"
android:summary="Prime/Fill from watch possible"
android:title="Prime in Menu"
app:wear_iconOff="@drawable/settings_off"
app:wear_iconOn="@drawable/settings_on"/>
</PreferenceScreen> </PreferenceScreen>