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){
sendError("No recent BG to base calculation on!"); return;
}
DecimalFormat format = new DecimalFormat("0.00");
BolusWizard bolusWizard = new BolusWizard();
bolusWizard.doCalc(profile.getDefaultProfile(), carbsAfterConstraints, useBG?bgReading.valueToUnits(profile.getUnits()):0d, 0d, useBolusIOB, useBasalIOB);
Double insulinAfterConstraints = MainApp.getConfigBuilder().applyBolusConstraints(bolusWizard.calculatedTotalInsulin);
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 {
rAction = actionstring;
}
DecimalFormat format = new DecimalFormat("0.00");
rMessage += "Carbs: " + bolusWizard.carbs + "g";
rMessage += "\nBolus: " + format.format(bolusWizard.calculatedTotalInsulin) + "U";
rMessage += "\nCalculation: ";
rMessage += "\nWizard: " + format.format(insulin) + "U";
rMessage += "\nCarb: " + format.format(bolusWizard.insulinFromCarbs) + "U";
if(useBG)rMessage += "\nBG: " + format.format(bolusWizard.insulinFromBG) + "U";
rMessage += "\n_____________";
rMessage += "\nCalc (IC:" + DecimalFormatter.to1Decimal(bolusWizard.ic) + ", " + "ISF:" + DecimalFormatter.to1Decimal(bolusWizard.sens) + "): ";
rMessage += "\nFrom Carbs: " + format.format(bolusWizard.insulinFromCarbs) + "U";
if(useBG)rMessage += "\nFrom BG: " + format.format(bolusWizard.insulinFromBG) + "U";
if(useBolusIOB)rMessage += "\nBolus IOB: " + format.format(bolusWizard.insulingFromBolusIOB) + "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;
@ -315,7 +314,7 @@ public class ActionStringHandler {
}
private static void doFillBolus(final Double amount) {
if(1==1)return;
//if(1==1)return;
Handler handler = new Handler(handlerThread.getLooper());
handler.post(new Runnable() {
@Override
@ -331,7 +330,7 @@ public class ActionStringHandler {
}
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.post(new Runnable() {
@Override

View file

@ -80,8 +80,20 @@ public class ListenerService extends WearableListenerService implements GoogleAp
Wearable.MessageApi.sendMessage(googleApiClient, node.getId(), WEARABLE_RESEND_PATH, null);
}
}
} else
googleApiClient.connect();
} else {
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;
}
}

View file

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

View file

@ -18,7 +18,7 @@ import info.nightscout.androidaps.R;
public abstract class MenuListActivity extends Activity
implements WearableListView.ClickListener {
String[] elements = getElements();
String[] elements;
protected abstract String[] getElements();
@ -33,6 +33,7 @@ public abstract class MenuListActivity extends Activity
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
elements = getElements();
setContentView(R.layout.actions_list_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_iconOn="@drawable/settings_on"/>
<CheckBoxPreference
android:defaultValue="true"
android:key="animation"
@ -113,4 +112,12 @@
android:title="Animations"
app:wear_iconOff="@drawable/settings_off"
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>