nsclient build variant

This commit is contained in:
Milos Kozak 2017-02-23 20:00:33 +01:00
parent 15d6de4701
commit b0c828c93e
30 changed files with 275 additions and 148 deletions

View file

@ -44,7 +44,8 @@ android {
minSdkVersion 21 minSdkVersion 21
targetSdkVersion 23 targetSdkVersion 23
versionCode 1100 versionCode 1100
versionName "1.1g" version "1.1g"
buildConfigField "String", "VERSION", '"' + version + '"'
buildConfigField "String", "BUILDVERSION", generateGitBuild() buildConfigField "String", "BUILDVERSION", generateGitBuild()
} }
lintOptions { lintOptions {
@ -60,26 +61,50 @@ android {
flavorDimensions "standard", "wear" flavorDimensions "standard", "wear"
full { full {
dimension "standard" dimension "standard"
resValue "string", "app_name", "AndroidAPS"
versionName version
manifestPlaceholders = [
appIcon: "@mipmap/blueowl"
]
buildConfigField "boolean", "APS", "true" buildConfigField "boolean", "APS", "true"
buildConfigField "boolean", "PUMPDRIVERS", "true" buildConfigField "boolean", "PUMPDRIVERS", "true"
buildConfigField "boolean", "NSCLIENTOLNY", "false"
buildConfigField "boolean", "CLOSEDLOOP", "true" buildConfigField "boolean", "CLOSEDLOOP", "true"
} }
pumpcontrol {
dimension "standard"
buildConfigField "boolean", "APS", "false"
buildConfigField "boolean", "PUMPDRIVERS", "true"
buildConfigField "boolean", "CLOSEDLOOP", "false"
}
careportal {
dimension "standard"
buildConfigField "boolean", "APS", "false"
buildConfigField "boolean", "PUMPDRIVERS", "false"
buildConfigField "boolean", "CLOSEDLOOP", "false"
}
openloop { openloop {
dimension "standard" dimension "standard"
resValue "string", "app_name", "AndroidAPS"
versionName version
manifestPlaceholders = [
appIcon: "@mipmap/blueowl"
]
buildConfigField "boolean", "APS", "true" buildConfigField "boolean", "APS", "true"
buildConfigField "boolean", "PUMPDRIVERS", "true" buildConfigField "boolean", "PUMPDRIVERS", "true"
buildConfigField "boolean", "NSCLIENTOLNY", "false"
buildConfigField "boolean", "CLOSEDLOOP", "false"
}
pumpcontrol {
dimension "standard"
resValue "string", "app_name", "AndroidAPS"
versionName version
manifestPlaceholders = [
appIcon: "@mipmap/blueowl"
]
buildConfigField "boolean", "APS", "false"
buildConfigField "boolean", "PUMPDRIVERS", "true"
buildConfigField "boolean", "NSCLIENTOLNY", "false"
buildConfigField "boolean", "CLOSEDLOOP", "false"
}
nsclient {
dimension "standard"
resValue "string", "app_name", "NSClient"
versionName version + "-nsclient"
manifestPlaceholders = [
appIcon: "@mipmap/yellowowl"
]
buildConfigField "boolean", "APS", "false"
buildConfigField "boolean", "PUMPDRIVERS", "false"
buildConfigField "boolean", "NSCLIENTOLNY", "true"
buildConfigField "boolean", "CLOSEDLOOP", "false" buildConfigField "boolean", "CLOSEDLOOP", "false"
} }
wear { wear {

View file

@ -24,7 +24,7 @@
<application <application
android:name=".MainApp" android:name=".MainApp"
android:allowBackup="true" android:allowBackup="true"
android:icon="@mipmap/ic_launcher" android:icon="${appIcon}"
android:label="@string/app_name" android:label="@string/app_name"
android:supportsRtl="true" android:supportsRtl="true"
android:theme="@style/AppTheme"> android:theme="@style/AppTheme">

View file

@ -11,12 +11,22 @@ public class Config {
public static final boolean LOOPENABLED = APS; public static final boolean LOOPENABLED = APS;
public static final boolean WEAR = BuildConfig.WEAR; public static final boolean WEAR = BuildConfig.WEAR;
public static final boolean CAREPORTALENABLED = true;
public static final boolean SMSCOMMUNICATORENABLED = true;
public static final boolean DANAR = true && BuildConfig.PUMPDRIVERS; public static final boolean DANAR = true && BuildConfig.PUMPDRIVERS;
public static final boolean DANARKOREAN = true && BuildConfig.PUMPDRIVERS; public static final boolean DANARKOREAN = true && BuildConfig.PUMPDRIVERS;
public static final boolean ACTION = !BuildConfig.NSCLIENTOLNY;
public static final boolean VIRTUALPUMP = !BuildConfig.NSCLIENTOLNY;
public static final boolean MDI = !BuildConfig.NSCLIENTOLNY;
public static final boolean OTHERPROFILES = !BuildConfig.NSCLIENTOLNY;
public static final boolean TEMPBASALS = !BuildConfig.NSCLIENTOLNY;
public static final boolean SAFETY = !BuildConfig.NSCLIENTOLNY;
public static final boolean SMSCOMMUNICATORENABLED = !BuildConfig.NSCLIENTOLNY;
public static final boolean ALLPREFERENCES = !BuildConfig.NSCLIENTOLNY;
public static final boolean detailedLog = true; public static final boolean detailedLog = true;
public static final boolean logFunctionCalls = true; public static final boolean logFunctionCalls = true;
public static final boolean logIncommingBG = true; public static final boolean logIncommingBG = true;

View file

@ -4,12 +4,10 @@ import android.Manifest;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.graphics.Rect; import android.graphics.Rect;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.v4.app.ActivityCompat; import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat; import android.support.v4.content.ContextCompat;
import android.support.v4.view.ViewPager; import android.support.v4.view.ViewPager;
@ -65,18 +63,17 @@ public class MainActivity extends AppCompatActivity {
log.debug("onCreate"); log.debug("onCreate");
// show version in toolbar // show version in toolbar
try { setTitle(getString(R.string.app_name) + " " + BuildConfig.VERSION);
setTitle(getString(R.string.app_name) + " " + getPackageManager().getPackageInfo(getPackageName(), 0).versionName);
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar); setSupportActionBar(toolbar);
registerBus(); registerBus();
try { try {
getSupportActionBar().setDisplayShowHomeEnabled(true); getSupportActionBar().setDisplayShowHomeEnabled(true);
getSupportActionBar().setIcon(R.mipmap.ic_launcher); if (BuildConfig.NSCLIENTOLNY)
getSupportActionBar().setIcon(R.mipmap.yellowowl);
else
getSupportActionBar().setIcon(R.mipmap.blueowl);
} catch (NullPointerException e) { } catch (NullPointerException e) {
// no action // no action
} }

View file

@ -78,29 +78,28 @@ public class MainApp extends Application {
pluginsList = new ArrayList<>(); pluginsList = new ArrayList<>();
// Register all tabs in app here // Register all tabs in app here
pluginsList.add(OverviewFragment.getPlugin()); pluginsList.add(OverviewFragment.getPlugin());
pluginsList.add(ActionsFragment.getPlugin()); if (Config.ACTION) pluginsList.add(ActionsFragment.getPlugin());
if (Config.DANAR) pluginsList.add(DanaRFragment.getPlugin()); if (Config.DANAR) pluginsList.add(DanaRFragment.getPlugin());
if (Config.DANARKOREAN) pluginsList.add(DanaRKoreanFragment.getPlugin()); if (Config.DANARKOREAN) pluginsList.add(DanaRKoreanFragment.getPlugin());
if (Config.CAREPORTALENABLED) pluginsList.add(CareportalFragment.getPlugin()); pluginsList.add(CareportalFragment.getPlugin());
pluginsList.add(MDIFragment.getPlugin()); if (Config.MDI) pluginsList.add(MDIFragment.getPlugin());
pluginsList.add(VirtualPumpFragment.getPlugin()); if (Config.VIRTUALPUMP) pluginsList.add(VirtualPumpFragment.getPlugin());
if (Config.LOOPENABLED) pluginsList.add(LoopFragment.getPlugin()); if (Config.LOOPENABLED) pluginsList.add(LoopFragment.getPlugin());
if (Config.OPENAPSENABLED) pluginsList.add(OpenAPSMAFragment.getPlugin()); if (Config.OPENAPSENABLED) pluginsList.add(OpenAPSMAFragment.getPlugin());
if (Config.OPENAPSENABLED) pluginsList.add(OpenAPSAMAFragment.getPlugin()); if (Config.OPENAPSENABLED) pluginsList.add(OpenAPSAMAFragment.getPlugin());
pluginsList.add(NSProfileFragment.getPlugin()); pluginsList.add(NSProfileFragment.getPlugin());
pluginsList.add(SimpleProfileFragment.getPlugin()); if (Config.OTHERPROFILES) pluginsList.add(SimpleProfileFragment.getPlugin());
pluginsList.add(LocalProfileFragment.getPlugin()); if (Config.OTHERPROFILES) pluginsList.add(LocalProfileFragment.getPlugin());
pluginsList.add(CircadianPercentageProfileFragment.getPlugin()); if (Config.OTHERPROFILES) pluginsList.add(CircadianPercentageProfileFragment.getPlugin());
if (Config.APS) pluginsList.add(TempTargetRangeFragment.getPlugin()); if (Config.APS) pluginsList.add(TempTargetRangeFragment.getPlugin());
pluginsList.add(TreatmentsFragment.getPlugin()); pluginsList.add(TreatmentsFragment.getPlugin());
pluginsList.add(TempBasalsFragment.getPlugin()); if (Config.TEMPBASALS) pluginsList.add(TempBasalsFragment.getPlugin());
pluginsList.add(SafetyFragment.getPlugin()); if (Config.SAFETY) pluginsList.add(SafetyFragment.getPlugin());
if (Config.APS) pluginsList.add(ObjectivesFragment.getPlugin()); if (Config.APS) pluginsList.add(ObjectivesFragment.getPlugin());
pluginsList.add(SourceXdripFragment.getPlugin()); pluginsList.add(SourceXdripFragment.getPlugin());
pluginsList.add(SourceNSClientFragment.getPlugin()); pluginsList.add(SourceNSClientFragment.getPlugin());
pluginsList.add(SourceMM640gFragment.getPlugin()); pluginsList.add(SourceMM640gFragment.getPlugin());
if (Config.SMSCOMMUNICATORENABLED) if (Config.SMSCOMMUNICATORENABLED) pluginsList.add(SmsCommunicatorFragment.getPlugin());
pluginsList.add(SmsCommunicatorFragment.getPlugin());
if (Config.WEAR) pluginsList.add(WearFragment.getPlugin(this)); if (Config.WEAR) pluginsList.add(WearFragment.getPlugin(this));
pluginsList.add(new PersistentNotificationPlugin(this)); pluginsList.add(new PersistentNotificationPlugin(this));

View file

@ -57,7 +57,7 @@ public class PreferencesActivity extends PreferenceActivity implements SharedPre
} }
if (pref instanceof EditTextPreference) { if (pref instanceof EditTextPreference) {
EditTextPreference editTextPref = (EditTextPreference) pref; EditTextPreference editTextPref = (EditTextPreference) pref;
if (pref.getKey().contains("password")) { if (pref.getKey().contains("password")|| pref.getKey().contains("secret")) {
pref.setSummary("******"); pref.setSummary("******");
} else if (editTextPref.getText() != null && !editTextPref.getText().equals("")) { } else if (editTextPref.getText() != null && !editTextPref.getText().equals("")) {
((EditTextPreference) pref).setDialogMessage(editTextPref.getDialogMessage()); ((EditTextPreference) pref).setDialogMessage(editTextPref.getDialogMessage());
@ -85,20 +85,28 @@ public class PreferencesActivity extends PreferenceActivity implements SharedPre
@Override @Override
public void onCreate(final Bundle savedInstanceState) { public void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.pref_password); if (Config.ALLPREFERENCES) {
addPreferencesFromResource(R.xml.pref_age); addPreferencesFromResource(R.xml.pref_password);
addPreferencesFromResource(R.xml.pref_age);
}
addPreferencesFromResource(R.xml.pref_language); addPreferencesFromResource(R.xml.pref_language);
addPreferencesFromResource(R.xml.pref_quickwizard); if (Config.ALLPREFERENCES) {
if (Config.CAREPORTALENABLED) addPreferencesFromResource(R.xml.pref_quickwizard);
addPreferencesFromResource(R.xml.pref_careportal); }
addPreferencesFromResource(R.xml.pref_treatments); addPreferencesFromResource(R.xml.pref_careportal);
if (Config.ALLPREFERENCES) {
addPreferencesFromResource(R.xml.pref_treatments);
}
if (Config.APS) if (Config.APS)
addPreferencesFromResource(R.xml.pref_closedmode); addPreferencesFromResource(R.xml.pref_closedmode);
if (Config.OPENAPSENABLED) if (Config.OPENAPSENABLED) {
addPreferencesFromResource(R.xml.pref_openapsma); addPreferencesFromResource(R.xml.pref_openapsma);
if (MainApp.getSpecificPlugin(OpenAPSAMAPlugin.class) != null && MainApp.getSpecificPlugin(OpenAPSAMAPlugin.class).isEnabled(PluginBase.APS)) if (MainApp.getSpecificPlugin(OpenAPSAMAPlugin.class) != null && MainApp.getSpecificPlugin(OpenAPSAMAPlugin.class).isEnabled(PluginBase.APS))
addPreferencesFromResource(R.xml.pref_openapsama); addPreferencesFromResource(R.xml.pref_openapsama);
addPreferencesFromResource(R.xml.pref_profile); }
if (Config.ALLPREFERENCES) {
addPreferencesFromResource(R.xml.pref_profile);
}
if (Config.DANAR) { if (Config.DANAR) {
DanaRPlugin danaRPlugin = (DanaRPlugin) MainApp.getSpecificPlugin(DanaRPlugin.class); DanaRPlugin danaRPlugin = (DanaRPlugin) MainApp.getSpecificPlugin(DanaRPlugin.class);
DanaRKoreanPlugin danaRKoreanPlugin = (DanaRKoreanPlugin) MainApp.getSpecificPlugin(DanaRKoreanPlugin.class); DanaRKoreanPlugin danaRKoreanPlugin = (DanaRKoreanPlugin) MainApp.getSpecificPlugin(DanaRKoreanPlugin.class);
@ -119,13 +127,17 @@ public class PreferencesActivity extends PreferenceActivity implements SharedPre
} }
if (Config.SMSCOMMUNICATORENABLED) if (Config.SMSCOMMUNICATORENABLED)
addPreferencesFromResource(R.xml.pref_smscommunicator); addPreferencesFromResource(R.xml.pref_smscommunicator);
addPreferencesFromResource(R.xml.pref_others); if (Config.ALLPREFERENCES) {
addPreferencesFromResource(R.xml.pref_advanced); addPreferencesFromResource(R.xml.pref_others);
addPreferencesFromResource(R.xml.pref_advanced);
}
initSummary(getPreferenceScreen()); initSummary(getPreferenceScreen());
WearPlugin wearPlugin = (WearPlugin) MainApp.getSpecificPlugin(WearPlugin.class); if (Config.WEAR) {
if (wearPlugin != null && wearPlugin.isEnabled(PluginBase.GENERAL)) { WearPlugin wearPlugin = (WearPlugin) MainApp.getSpecificPlugin(WearPlugin.class);
addPreferencesFromResource(R.xml.pref_wear); if (wearPlugin != null && wearPlugin.isEnabled(PluginBase.GENERAL)) {
addPreferencesFromResource(R.xml.pref_wear);
}
} }
} }

View file

@ -269,7 +269,7 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain
// PluginBase.PUMP // PluginBase.PUMP
pluginsInCategory = MainApp.getSpecificPluginsList(PluginBase.PUMP); pluginsInCategory = MainApp.getSpecificPluginsList(PluginBase.PUMP);
activePump = (PumpInterface) getTheOneEnabledInArray(pluginsInCategory, PluginBase.PUMP); activePump = (PumpInterface) getTheOneEnabledInArray(pluginsInCategory, PluginBase.PUMP);
if (Config.logConfigBuilder) if (Config.logConfigBuilder && activePump != null)
log.debug("Selected pump interface: " + ((PluginBase) activePump).getName()); log.debug("Selected pump interface: " + ((PluginBase) activePump).getName());
for (PluginBase p : pluginsInCategory) { for (PluginBase p : pluginsInCategory) {
if (!p.getName().equals(((PluginBase) activePump).getName())) { if (!p.getName().equals(((PluginBase) activePump).getName())) {
@ -293,7 +293,7 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain
// PluginBase.TEMPBASAL // PluginBase.TEMPBASAL
pluginsInCategory = MainApp.getSpecificPluginsList(PluginBase.TEMPBASAL); pluginsInCategory = MainApp.getSpecificPluginsList(PluginBase.TEMPBASAL);
activeTempBasals = (TempBasalsInterface) getTheOneEnabledInArray(pluginsInCategory, PluginBase.TEMPBASAL); activeTempBasals = (TempBasalsInterface) getTheOneEnabledInArray(pluginsInCategory, PluginBase.TEMPBASAL);
if (Config.logConfigBuilder) if (Config.logConfigBuilder && activeTempBasals != null)
log.debug("Selected tempbasal interface: " + ((PluginBase) activeTempBasals).getName()); log.debug("Selected tempbasal interface: " + ((PluginBase) activeTempBasals).getName());
for (PluginBase p : pluginsInCategory) { for (PluginBase p : pluginsInCategory) {
if (!p.getName().equals(((PluginBase) activeTempBasals).getName())) { if (!p.getName().equals(((PluginBase) activeTempBasals).getName())) {
@ -337,27 +337,37 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain
*/ */
@Override @Override
public boolean isInitialized() { public boolean isInitialized() {
return activePump.isInitialized(); if (activePump != null)
return activePump.isInitialized();
else return true;
} }
@Override @Override
public boolean isSuspended() { public boolean isSuspended() {
return activePump.isSuspended(); if (activePump != null)
return activePump.isSuspended();
else return false;
} }
@Override @Override
public boolean isBusy() { public boolean isBusy() {
return activePump.isBusy(); if (activePump != null)
return activePump.isBusy();
else return false;
} }
@Override @Override
public boolean isTempBasalInProgress() { public boolean isTempBasalInProgress() {
return activePump.isTempBasalInProgress(); if (activePump != null)
return activePump.isTempBasalInProgress();
else return false;
} }
@Override @Override
public boolean isExtendedBoluslInProgress() { public boolean isExtendedBoluslInProgress() {
return activePump.isExtendedBoluslInProgress(); if (activePump != null)
return activePump.isExtendedBoluslInProgress();
else return false;
} }
@Override @Override
@ -378,87 +388,129 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain
if (isThisProfileSet(profile)) { if (isThisProfileSet(profile)) {
log.debug("Correct profile already set"); log.debug("Correct profile already set");
return NOT_NEEDED; return NOT_NEEDED;
} else { } else if (activePump != null) {
return activePump.setNewBasalProfile(profile); return activePump.setNewBasalProfile(profile);
} } else
return SUCCESS;
} }
@Override @Override
public boolean isThisProfileSet(NSProfile profile) { public boolean isThisProfileSet(NSProfile profile) {
return activePump.isThisProfileSet(profile); if (activePump != null)
return activePump.isThisProfileSet(profile);
else return true;
} }
@Override @Override
public Date lastDataTime() { public Date lastDataTime() {
return activePump.lastDataTime(); if (activePump != null)
return activePump.lastDataTime();
else return new Date();
} }
@Override @Override
public void refreshDataFromPump(String reason) { public void refreshDataFromPump(String reason) {
activePump.refreshDataFromPump(reason); if (activePump != null)
activePump.refreshDataFromPump(reason);
} }
@Override @Override
public double getBaseBasalRate() { public double getBaseBasalRate() {
return activePump.getBaseBasalRate(); if (activePump != null)
return activePump.getBaseBasalRate();
else
return 0d;
} }
@Override @Override
public double getTempBasalAbsoluteRate() { public double getTempBasalAbsoluteRate() {
return activePump.getTempBasalAbsoluteRate(); if (activePump != null)
return activePump.getTempBasalAbsoluteRate();
else
return 0d;
} }
@Override @Override
public double getTempBasalRemainingMinutes() { public double getTempBasalRemainingMinutes() {
return activePump.getTempBasalRemainingMinutes(); if (activePump != null)
return activePump.getTempBasalRemainingMinutes();
else
return 0d;
} }
@Override @Override
public TempBasal getTempBasal(Date time) { public TempBasal getTempBasal(Date time) {
return activePump.getTempBasal(time); if (activePump != null)
return activePump.getTempBasal(time);
else
return null;
} }
@Override @Override
public TempBasal getTempBasal() { public TempBasal getTempBasal() {
return activePump.getTempBasal(); if (activePump != null)
return activePump.getTempBasal();
else
return null;
} }
@Override @Override
public TempBasal getExtendedBolus() { public TempBasal getExtendedBolus() {
return activePump.getExtendedBolus(); if (activePump != null)
return activePump.getExtendedBolus();
else
return null;
} }
public PumpEnactResult deliverTreatmentFromBolusWizard(Context context, Double insulin, Integer carbs, Double glucose, String glucoseType, int carbTime, JSONObject boluscalc) { public PumpEnactResult deliverTreatmentFromBolusWizard(Context context, Double insulin, Integer carbs, Double glucose, String glucoseType, int carbTime, JSONObject boluscalc) {
mWakeLock.acquire(); mWakeLock.acquire();
insulin = applyBolusConstraints(insulin); PumpEnactResult result;
carbs = applyCarbsConstraints(carbs); if (activePump != null) {
insulin = applyBolusConstraints(insulin);
carbs = applyCarbsConstraints(carbs);
BolusProgressDialog bolusProgressDialog = null; BolusProgressDialog bolusProgressDialog = null;
if (context != null) { if (context != null) {
bolusProgressDialog = new BolusProgressDialog(); bolusProgressDialog = new BolusProgressDialog();
bolusProgressDialog.setInsulin(insulin); bolusProgressDialog.setInsulin(insulin);
bolusProgressDialog.show(((AppCompatActivity) context).getSupportFragmentManager(), "BolusProgress"); bolusProgressDialog.show(((AppCompatActivity) context).getSupportFragmentManager(), "BolusProgress");
} }
MainApp.bus().post(new EventBolusRequested(insulin)); MainApp.bus().post(new EventBolusRequested(insulin));
PumpEnactResult result = activePump.deliverTreatment(insulin, carbs, context); result = activePump.deliverTreatment(insulin, carbs, context);
BolusProgressDialog.bolusEnded = true; BolusProgressDialog.bolusEnded = true;
MainApp.bus().post(new EventDismissBolusprogressIfRunning(result)); MainApp.bus().post(new EventDismissBolusprogressIfRunning(result));
if (result.success) { if (result.success) {
Treatment t = new Treatment();
t.insulin = result.bolusDelivered;
if (carbTime == 0)
t.carbs = (double) result.carbsDelivered; // with different carbTime record will come back from nightscout
t.created_at = new Date();
t.mealBolus = result.carbsDelivered > 0;
MainApp.getDbHelper().create(t);
t.setTimeIndex(t.getTimeIndex());
t.carbs = (double) result.carbsDelivered;
uploadBolusWizardRecord(t, glucose, glucoseType, carbTime, boluscalc);
}
} else {
if (Config.logCongigBuilderActions)
log.debug("Creating treatment: " + insulin + " carbs: " + carbs);
Treatment t = new Treatment(); Treatment t = new Treatment();
t.insulin = result.bolusDelivered; t.insulin = insulin;
if (carbTime == 0) t.carbs = (double) carbs;
t.carbs = (double) result.carbsDelivered; // with different carbTime record will come back from nightscout
t.created_at = new Date(); t.created_at = new Date();
t.mealBolus = result.carbsDelivered > 0; t.mealBolus = t.carbs > 0;
MainApp.getDbHelper().create(t); MainApp.getDbHelper().create(t);
t.setTimeIndex(t.getTimeIndex()); t.setTimeIndex(t.getTimeIndex());
t.carbs = (double) result.carbsDelivered; t.sendToNSClient();
uploadBolusWizardRecord(t, glucose, glucoseType, carbTime, boluscalc); result = new PumpEnactResult();
result.success = true;
result.bolusDelivered = insulin;
result.carbsDelivered = carbs;
} }
mWakeLock.release(); mWakeLock.release();
return result; return result;
@ -471,42 +523,60 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain
public PumpEnactResult deliverTreatment(Double insulin, Integer carbs, Context context, boolean createTreatment) { public PumpEnactResult deliverTreatment(Double insulin, Integer carbs, Context context, boolean createTreatment) {
mWakeLock.acquire(); mWakeLock.acquire();
insulin = applyBolusConstraints(insulin); PumpEnactResult result;
carbs = applyCarbsConstraints(carbs); if (activePump != null) {
insulin = applyBolusConstraints(insulin);
carbs = applyCarbsConstraints(carbs);
BolusProgressDialog bolusProgressDialog = null; BolusProgressDialog bolusProgressDialog = null;
if (context != null) { if (context != null) {
bolusProgressDialog = new BolusProgressDialog(); bolusProgressDialog = new BolusProgressDialog();
bolusProgressDialog.setInsulin(insulin); bolusProgressDialog.setInsulin(insulin);
bolusProgressDialog.show(((AppCompatActivity) context).getSupportFragmentManager(), "BolusProgress"); bolusProgressDialog.show(((AppCompatActivity) context).getSupportFragmentManager(), "BolusProgress");
} else {
Intent i = new Intent();
i.putExtra("insulin", insulin.doubleValue());
i.setClass(MainApp.instance(), BolusProgressHelperActivity.class);
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
MainApp.instance().startActivity(i);
}
MainApp.bus().post(new EventBolusRequested(insulin));
result = activePump.deliverTreatment(insulin, carbs, context);
BolusProgressDialog.bolusEnded = true;
MainApp.bus().post(new EventDismissBolusprogressIfRunning(result));
if (Config.logCongigBuilderActions)
log.debug("deliverTreatment insulin: " + insulin + " carbs: " + carbs + " success: " + result.success + " enacted: " + result.enacted + " bolusDelivered: " + result.bolusDelivered);
if (result.success && createTreatment) {
Treatment t = new Treatment();
t.insulin = result.bolusDelivered;
t.carbs = (double) result.carbsDelivered;
t.created_at = new Date();
t.mealBolus = t.carbs > 0;
MainApp.getDbHelper().create(t);
t.setTimeIndex(t.getTimeIndex());
t.sendToNSClient();
}
} else { } else {
Intent i = new Intent(); if (Config.logCongigBuilderActions)
i.putExtra("insulin", insulin.doubleValue()); log.debug("Creating treatment: " + insulin + " carbs: " + carbs);
i.setClass(MainApp.instance(), BolusProgressHelperActivity.class);
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
MainApp.instance().startActivity(i);
}
MainApp.bus().post(new EventBolusRequested(insulin));
PumpEnactResult result = activePump.deliverTreatment(insulin, carbs, context);
BolusProgressDialog.bolusEnded = true;
MainApp.bus().post(new EventDismissBolusprogressIfRunning(result));
if (Config.logCongigBuilderActions)
log.debug("deliverTreatment insulin: " + insulin + " carbs: " + carbs + " success: " + result.success + " enacted: " + result.enacted + " bolusDelivered: " + result.bolusDelivered);
if (result.success && createTreatment) {
Treatment t = new Treatment(); Treatment t = new Treatment();
t.insulin = result.bolusDelivered; t.insulin = insulin;
t.carbs = (double) result.carbsDelivered; t.carbs = (double) carbs;
t.created_at = new Date(); t.created_at = new Date();
t.mealBolus = t.carbs > 0; t.mealBolus = t.carbs > 0;
MainApp.getDbHelper().create(t); MainApp.getDbHelper().create(t);
t.setTimeIndex(t.getTimeIndex()); t.setTimeIndex(t.getTimeIndex());
t.sendToNSClient(); t.sendToNSClient();
result = new PumpEnactResult();
result.success = true;
result.bolusDelivered = insulin;
result.carbsDelivered = carbs;
} }
mWakeLock.release(); mWakeLock.release();
return result; return result;

View file

@ -196,7 +196,7 @@ public class LoopPlugin implements PluginBase {
if (result.changeRequested && allowNotification) { if (result.changeRequested && allowNotification) {
NotificationCompat.Builder builder = NotificationCompat.Builder builder =
new NotificationCompat.Builder(MainApp.instance().getApplicationContext()); new NotificationCompat.Builder(MainApp.instance().getApplicationContext());
builder.setSmallIcon(R.drawable.notification_icon) builder.setSmallIcon(R.drawable.notif_icon)
.setContentTitle(MainApp.sResources.getString(R.string.openloop_newsuggestion)) .setContentTitle(MainApp.sResources.getString(R.string.openloop_newsuggestion))
.setContentText(resultAfterConstraints.toString()) .setContentText(resultAfterConstraints.toString())
.setAutoCancel(true) .setAutoCancel(true)

View file

@ -309,12 +309,15 @@ public class WizardDialog extends DialogFragment implements OnClickListener {
} }
// IOB calculation // IOB calculation
TreatmentsInterface treatments = MainApp.getConfigBuilder().getActiveTreatments(); TreatmentsInterface treatments = ConfigBuilderPlugin.getActiveTreatments();
TempBasalsInterface tempBasals = MainApp.getConfigBuilder().getActiveTempBasals();
treatments.updateTotalIOB(); treatments.updateTotalIOB();
tempBasals.updateTotalIOB();
IobTotal bolusIob = treatments.getLastCalculation(); IobTotal bolusIob = treatments.getLastCalculation();
IobTotal basalIob = tempBasals.getLastCalculation(); TempBasalsInterface tempBasals = ConfigBuilderPlugin.getActiveTempBasals();
IobTotal basalIob = new IobTotal(new Date().getTime());
if (tempBasals != null) {
tempBasals.updateTotalIOB();
basalIob = tempBasals.getLastCalculation().round();
}
bolusIobInsulin.setText(DecimalFormatter.to2Decimal(-bolusIob.iob) + "U"); bolusIobInsulin.setText(DecimalFormatter.to2Decimal(-bolusIob.iob) + "U");
basalIobInsulin.setText(DecimalFormatter.to2Decimal(-basalIob.basaliob) + "U"); basalIobInsulin.setText(DecimalFormatter.to2Decimal(-basalIob.basaliob) + "U");

View file

@ -741,10 +741,13 @@ public class OverviewFragment extends Fragment {
timeAgoView.setText(String.format(MainApp.sResources.getString(R.string.minago), agoMin)); timeAgoView.setText(String.format(MainApp.sResources.getString(R.string.minago), agoMin));
// iob // iob
MainApp.getConfigBuilder().getActiveTreatments().updateTotalIOB(); ConfigBuilderPlugin.getActiveTreatments().updateTotalIOB();
IobTotal bolusIob = MainApp.getConfigBuilder().getActiveTreatments().getLastCalculation().round(); IobTotal bolusIob = ConfigBuilderPlugin.getActiveTreatments().getLastCalculation().round();
MainApp.getConfigBuilder().getActiveTempBasals().updateTotalIOB(); IobTotal basalIob = new IobTotal(new Date().getTime());
IobTotal basalIob = MainApp.getConfigBuilder().getActiveTempBasals().getLastCalculation().round(); if (ConfigBuilderPlugin.getActiveTempBasals() != null) {
ConfigBuilderPlugin.getActiveTempBasals().updateTotalIOB();
basalIob = ConfigBuilderPlugin.getActiveTempBasals().getLastCalculation().round();
}
String iobtext = getString(R.string.treatments_iob_label_string) + " " + DecimalFormatter.to2Decimal(bolusIob.iob + basalIob.basaliob) + "U (" String iobtext = getString(R.string.treatments_iob_label_string) + " " + DecimalFormatter.to2Decimal(bolusIob.iob + basalIob.basaliob) + "U ("
+ getString(R.string.bolus) + ": " + DecimalFormatter.to2Decimal(bolusIob.iob) + "U " + getString(R.string.bolus) + ": " + DecimalFormatter.to2Decimal(bolusIob.iob) + "U "

View file

@ -21,6 +21,7 @@ import info.nightscout.androidaps.db.TempBasal;
import info.nightscout.androidaps.interfaces.PluginBase; import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.interfaces.PumpDescription; import info.nightscout.androidaps.interfaces.PumpDescription;
import info.nightscout.androidaps.interfaces.PumpInterface; import info.nightscout.androidaps.interfaces.PumpInterface;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProgress; import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProgress;
import info.nightscout.androidaps.plugins.VirtualPump.events.EventVirtualPumpUpdateGui; import info.nightscout.androidaps.plugins.VirtualPump.events.EventVirtualPumpUpdateGui;
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSProfile; import info.nightscout.androidaps.plugins.NSClientInternal.data.NSProfile;
@ -169,7 +170,7 @@ public class VirtualPumpPlugin implements PluginBase, PumpInterface {
@Override @Override
public double getBaseBasalRate() { public double getBaseBasalRate() {
NSProfile profile = MainApp.getConfigBuilder().getActiveProfile().getProfile(); NSProfile profile = ConfigBuilderPlugin.getActiveProfile().getProfile();
if (profile == null) if (profile == null)
return defaultBasalValue; return defaultBasalValue;
return profile.getBasal(profile.secondsFromMidnight()); return profile.getBasal(profile.secondsFromMidnight());
@ -182,7 +183,7 @@ public class VirtualPumpPlugin implements PluginBase, PumpInterface {
if (getTempBasal().isAbsolute) { if (getTempBasal().isAbsolute) {
return getTempBasal().absolute; return getTempBasal().absolute;
} else { } else {
NSProfile profile = MainApp.getConfigBuilder().getActiveProfile().getProfile(); NSProfile profile = ConfigBuilderPlugin.getActiveProfile().getProfile();
if (profile == null) if (profile == null)
return defaultBasalValue; return defaultBasalValue;
Double baseRate = profile.getBasal(profile.secondsFromMidnight()); Double baseRate = profile.getBasal(profile.secondsFromMidnight());
@ -193,12 +194,12 @@ public class VirtualPumpPlugin implements PluginBase, PumpInterface {
@Override @Override
public TempBasal getTempBasal() { public TempBasal getTempBasal() {
return MainApp.getConfigBuilder().getActiveTempBasals().getTempBasal(new Date()); return ConfigBuilderPlugin.getActiveTempBasals().getTempBasal(new Date());
} }
@Override @Override
public TempBasal getExtendedBolus() { public TempBasal getExtendedBolus() {
return MainApp.getConfigBuilder().getActiveTempBasals().getExtendedBolus(new Date()); return ConfigBuilderPlugin.getActiveTempBasals().getExtendedBolus(new Date());
} }
@Override @Override
@ -210,7 +211,7 @@ public class VirtualPumpPlugin implements PluginBase, PumpInterface {
@Override @Override
public TempBasal getTempBasal(Date time) { public TempBasal getTempBasal(Date time) {
return MainApp.getConfigBuilder().getActiveTempBasals().getTempBasal(time); return ConfigBuilderPlugin.getActiveTempBasals().getTempBasal(time);
} }
@Override @Override

View file

@ -11,6 +11,8 @@ import android.support.v7.app.NotificationCompat;
import com.squareup.otto.Subscribe; import com.squareup.otto.Subscribe;
import java.util.Date;
import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainActivity; import info.nightscout.androidaps.MainActivity;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
@ -28,6 +30,7 @@ import info.nightscout.androidaps.events.EventTreatmentChange;
import info.nightscout.androidaps.interfaces.PluginBase; import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.interfaces.PumpInterface; import info.nightscout.androidaps.interfaces.PumpInterface;
import info.nightscout.androidaps.data.IobTotal; import info.nightscout.androidaps.data.IobTotal;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSProfile; import info.nightscout.androidaps.plugins.NSClientInternal.data.NSProfile;
import info.nightscout.utils.DecimalFormatter; import info.nightscout.utils.DecimalFormatter;
@ -38,7 +41,7 @@ import info.nightscout.utils.DecimalFormatter;
public class PersistentNotificationPlugin implements PluginBase{ public class PersistentNotificationPlugin implements PluginBase{
private static final int ONGOING_NOTIFICATION_ID = 4711; private static final int ONGOING_NOTIFICATION_ID = 4711;
static boolean fragmentEnabled = false; static boolean fragmentEnabled = true;
private final Context ctx; private final Context ctx;
public PersistentNotificationPlugin(Context ctx) { public PersistentNotificationPlugin(Context ctx) {
@ -131,10 +134,13 @@ public class PersistentNotificationPlugin implements PluginBase{
} }
//IOB //IOB
MainApp.getConfigBuilder().getActiveTreatments().updateTotalIOB(); ConfigBuilderPlugin.getActiveTreatments().updateTotalIOB();
IobTotal bolusIob = MainApp.getConfigBuilder().getActiveTreatments().getLastCalculation().round(); IobTotal bolusIob = ConfigBuilderPlugin.getActiveTreatments().getLastCalculation().round();
MainApp.getConfigBuilder().getActiveTempBasals().updateTotalIOB(); IobTotal basalIob = new IobTotal(new Date().getTime());
IobTotal basalIob = MainApp.getConfigBuilder().getActiveTempBasals().getLastCalculation().round(); if (ConfigBuilderPlugin.getActiveTempBasals() != null) {
ConfigBuilderPlugin.getActiveTempBasals().updateTotalIOB();
basalIob = ConfigBuilderPlugin.getActiveTempBasals().getLastCalculation().round();
}
String line2 = ctx.getString(R.string.treatments_iob_label_string) + " " + DecimalFormatter.to2Decimal(bolusIob.iob + basalIob.basaliob) + "U (" String line2 = ctx.getString(R.string.treatments_iob_label_string) + " " + DecimalFormatter.to2Decimal(bolusIob.iob + basalIob.basaliob) + "U ("
+ ctx.getString(R.string.bolus) + ": " + DecimalFormatter.to2Decimal(bolusIob.iob) + "U " + ctx.getString(R.string.bolus) + ": " + DecimalFormatter.to2Decimal(bolusIob.iob) + "U "
+ ctx.getString(R.string.basal) + ": " + DecimalFormatter.to2Decimal(basalIob.basaliob) + "U)"; + ctx.getString(R.string.basal) + ": " + DecimalFormatter.to2Decimal(basalIob.basaliob) + "U)";
@ -151,7 +157,7 @@ public class PersistentNotificationPlugin implements PluginBase{
builder.setOngoing(true); builder.setOngoing(true);
builder.setCategory(NotificationCompat.CATEGORY_STATUS); builder.setCategory(NotificationCompat.CATEGORY_STATUS);
builder.setSmallIcon(R.drawable.ic_notification); builder.setSmallIcon(R.drawable.ic_notification);
Bitmap largeIcon = BitmapFactory.decodeResource(ctx.getResources(), R.mipmap.ic_launcher); Bitmap largeIcon = BitmapFactory.decodeResource(ctx.getResources(), R.mipmap.blueowl);
builder.setLargeIcon(largeIcon); builder.setLargeIcon(largeIcon);
builder.setContentTitle(line1); builder.setContentTitle(line1);
builder.setContentText(line2); builder.setContentText(line2);

View file

@ -2,10 +2,13 @@ package info.nightscout.utils;
import org.json.JSONObject; import org.json.JSONObject;
import java.util.Date;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.interfaces.TempBasalsInterface; import info.nightscout.androidaps.interfaces.TempBasalsInterface;
import info.nightscout.androidaps.interfaces.TreatmentsInterface; import info.nightscout.androidaps.interfaces.TreatmentsInterface;
import info.nightscout.androidaps.data.IobTotal; import info.nightscout.androidaps.data.IobTotal;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSProfile; import info.nightscout.androidaps.plugins.NSClientInternal.data.NSProfile;
/** /**
@ -48,7 +51,7 @@ public class BolusWizard {
this.bg = bg; this.bg = bg;
this.correction = correction; this.correction = correction;
NSProfile profile = MainApp.getConfigBuilder().getActiveProfile().getProfile(); NSProfile profile = ConfigBuilderPlugin.getActiveProfile().getProfile();
// Insulin from BG // Insulin from BG
sens = profile.getIsf(specificProfile, NSProfile.secondsFromMidnight()); sens = profile.getIsf(specificProfile, NSProfile.secondsFromMidnight());
@ -66,12 +69,16 @@ public class BolusWizard {
insulinFromCarbs = carbs / ic; insulinFromCarbs = carbs / ic;
// Insulin from IOB // Insulin from IOB
TreatmentsInterface treatments = MainApp.getConfigBuilder().getActiveTreatments(); // IOB calculation
TempBasalsInterface tempBasals = MainApp.getConfigBuilder().getActiveTempBasals(); TreatmentsInterface treatments = ConfigBuilderPlugin.getActiveTreatments();
treatments.updateTotalIOB(); treatments.updateTotalIOB();
tempBasals.updateTotalIOB(); IobTotal bolusIob = treatments.getLastCalculation();
bolusIob = treatments.getLastCalculation(); TempBasalsInterface tempBasals = ConfigBuilderPlugin.getActiveTempBasals();
basalIob = tempBasals.getLastCalculation(); IobTotal basalIob = new IobTotal(new Date().getTime());
if (tempBasals != null) {
tempBasals.updateTotalIOB();
basalIob = tempBasals.getLastCalculation().round();
}
insulingFromBolusIOB = includeBolusIOB ? -bolusIob.iob : 0d; insulingFromBolusIOB = includeBolusIOB ? -bolusIob.iob : 0d;
insulingFromBasalsIOB = includeBasalIOB ? -basalIob.basaliob : 0d; insulingFromBasalsIOB = includeBasalIOB ? -basalIob.basaliob : 0d;

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.3 KiB

View file

Before

Width:  |  Height:  |  Size: 4.6 KiB

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

View file

Before

Width:  |  Height:  |  Size: 3 KiB

After

Width:  |  Height:  |  Size: 3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

View file

Before

Width:  |  Height:  |  Size: 6.9 KiB

After

Width:  |  Height:  |  Size: 6.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7 KiB

View file

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

View file

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

View file

@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<string name="app_name">AndroidAPS</string>
<string name="closedloop">Closed Loop</string> <string name="closedloop">Closed Loop</string>
<string name="openloop">Open Loop</string> <string name="openloop">Open Loop</string>
<string name="apsmode_title">APS режим</string> <string name="apsmode_title">APS режим</string>

View file

@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<string name="app_name">AndroidAPS</string>
<string name="closedloop">Uzavřená smyčka</string> <string name="closedloop">Uzavřená smyčka</string>
<string name="openloop">Otevřená smyčka</string> <string name="openloop">Otevřená smyčka</string>
<string name="apsmode_title">Typ smyčky</string> <string name="apsmode_title">Typ smyčky</string>

View file

@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<string name="app_name">AndroidAPS</string>
<string name="apsmode_title">APS Modus</string> <string name="apsmode_title">APS Modus</string>
<string name="objectives_bgavailableinns">BZ verfügbar in NS</string> <string name="objectives_bgavailableinns">BZ verfügbar in NS</string>
<string name="cancel">Abbrechen</string> <string name="cancel">Abbrechen</string>

View file

@ -1,5 +1,4 @@
<resources> <resources>
<string name="app_name">AndroidAPS</string>
<string name="treatmentssafety_title">Seguridad tratamientos</string> <string name="treatmentssafety_title">Seguridad tratamientos</string>
<string name="treatmentssafety_maxbolus_title">Máximo Bolo permitido [U]</string> <string name="treatmentssafety_maxbolus_title">Máximo Bolo permitido [U]</string>
<string name="treatmentssafety_maxcarbs_title">Máximos carbohidratos permitidos [g]</string> <string name="treatmentssafety_maxcarbs_title">Máximos carbohidratos permitidos [g]</string>

View file

@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<string name="app_name">AndroidAPS</string>
<string name="treatmentssafety_title">Treatments 안전설정</string> <string name="treatmentssafety_title">Treatments 안전설정</string>
<string name="treatmentssafety_maxbolus_title">최대 허용 식사주입인슐린 [U]</string> <string name="treatmentssafety_maxbolus_title">최대 허용 식사주입인슐린 [U]</string>
<string name="treatmentssafety_maxcarbs_title">최대 허용 탄수화물 [g]</string> <string name="treatmentssafety_maxcarbs_title">최대 허용 탄수화물 [g]</string>

View file

@ -1,5 +1,4 @@
<resources> <resources>
<string name="app_name">AndroidAPS</string>
<string name="treatmentssafety_title">Tratments safety</string> <string name="treatmentssafety_title">Tratments safety</string>
<string name="treatmentssafety_maxbolus_title">Max allowed bolus [U]</string> <string name="treatmentssafety_maxbolus_title">Max allowed bolus [U]</string>
<string name="treatmentssafety_maxcarbs_title">Max allowed carbs [g]</string> <string name="treatmentssafety_maxcarbs_title">Max allowed carbs [g]</string>