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
targetSdkVersion 23
versionCode 1100
versionName "1.1g"
version "1.1g"
buildConfigField "String", "VERSION", '"' + version + '"'
buildConfigField "String", "BUILDVERSION", generateGitBuild()
}
lintOptions {
@ -60,26 +61,50 @@ android {
flavorDimensions "standard", "wear"
full {
dimension "standard"
resValue "string", "app_name", "AndroidAPS"
versionName version
manifestPlaceholders = [
appIcon: "@mipmap/blueowl"
]
buildConfigField "boolean", "APS", "true"
buildConfigField "boolean", "PUMPDRIVERS", "true"
buildConfigField "boolean", "NSCLIENTOLNY", "false"
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 {
dimension "standard"
resValue "string", "app_name", "AndroidAPS"
versionName version
manifestPlaceholders = [
appIcon: "@mipmap/blueowl"
]
buildConfigField "boolean", "APS", "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"
}
wear {

View file

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

View file

@ -11,12 +11,22 @@ public class Config {
public static final boolean LOOPENABLED = APS;
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 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 logFunctionCalls = true;
public static final boolean logIncommingBG = true;

View file

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

View file

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

View file

@ -57,7 +57,7 @@ public class PreferencesActivity extends PreferenceActivity implements SharedPre
}
if (pref instanceof EditTextPreference) {
EditTextPreference editTextPref = (EditTextPreference) pref;
if (pref.getKey().contains("password")) {
if (pref.getKey().contains("password")|| pref.getKey().contains("secret")) {
pref.setSummary("******");
} else if (editTextPref.getText() != null && !editTextPref.getText().equals("")) {
((EditTextPreference) pref).setDialogMessage(editTextPref.getDialogMessage());
@ -85,20 +85,28 @@ public class PreferencesActivity extends PreferenceActivity implements SharedPre
@Override
public void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.pref_password);
addPreferencesFromResource(R.xml.pref_age);
if (Config.ALLPREFERENCES) {
addPreferencesFromResource(R.xml.pref_password);
addPreferencesFromResource(R.xml.pref_age);
}
addPreferencesFromResource(R.xml.pref_language);
addPreferencesFromResource(R.xml.pref_quickwizard);
if (Config.CAREPORTALENABLED)
addPreferencesFromResource(R.xml.pref_careportal);
addPreferencesFromResource(R.xml.pref_treatments);
if (Config.ALLPREFERENCES) {
addPreferencesFromResource(R.xml.pref_quickwizard);
}
addPreferencesFromResource(R.xml.pref_careportal);
if (Config.ALLPREFERENCES) {
addPreferencesFromResource(R.xml.pref_treatments);
}
if (Config.APS)
addPreferencesFromResource(R.xml.pref_closedmode);
if (Config.OPENAPSENABLED)
if (Config.OPENAPSENABLED) {
addPreferencesFromResource(R.xml.pref_openapsma);
if (MainApp.getSpecificPlugin(OpenAPSAMAPlugin.class) != null && MainApp.getSpecificPlugin(OpenAPSAMAPlugin.class).isEnabled(PluginBase.APS))
addPreferencesFromResource(R.xml.pref_openapsama);
addPreferencesFromResource(R.xml.pref_profile);
if (MainApp.getSpecificPlugin(OpenAPSAMAPlugin.class) != null && MainApp.getSpecificPlugin(OpenAPSAMAPlugin.class).isEnabled(PluginBase.APS))
addPreferencesFromResource(R.xml.pref_openapsama);
}
if (Config.ALLPREFERENCES) {
addPreferencesFromResource(R.xml.pref_profile);
}
if (Config.DANAR) {
DanaRPlugin danaRPlugin = (DanaRPlugin) MainApp.getSpecificPlugin(DanaRPlugin.class);
DanaRKoreanPlugin danaRKoreanPlugin = (DanaRKoreanPlugin) MainApp.getSpecificPlugin(DanaRKoreanPlugin.class);
@ -119,13 +127,17 @@ public class PreferencesActivity extends PreferenceActivity implements SharedPre
}
if (Config.SMSCOMMUNICATORENABLED)
addPreferencesFromResource(R.xml.pref_smscommunicator);
addPreferencesFromResource(R.xml.pref_others);
addPreferencesFromResource(R.xml.pref_advanced);
if (Config.ALLPREFERENCES) {
addPreferencesFromResource(R.xml.pref_others);
addPreferencesFromResource(R.xml.pref_advanced);
}
initSummary(getPreferenceScreen());
WearPlugin wearPlugin = (WearPlugin) MainApp.getSpecificPlugin(WearPlugin.class);
if (wearPlugin != null && wearPlugin.isEnabled(PluginBase.GENERAL)) {
addPreferencesFromResource(R.xml.pref_wear);
if (Config.WEAR) {
WearPlugin wearPlugin = (WearPlugin) MainApp.getSpecificPlugin(WearPlugin.class);
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
pluginsInCategory = MainApp.getSpecificPluginsList(PluginBase.PUMP);
activePump = (PumpInterface) getTheOneEnabledInArray(pluginsInCategory, PluginBase.PUMP);
if (Config.logConfigBuilder)
if (Config.logConfigBuilder && activePump != null)
log.debug("Selected pump interface: " + ((PluginBase) activePump).getName());
for (PluginBase p : pluginsInCategory) {
if (!p.getName().equals(((PluginBase) activePump).getName())) {
@ -293,7 +293,7 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain
// PluginBase.TEMPBASAL
pluginsInCategory = MainApp.getSpecificPluginsList(PluginBase.TEMPBASAL);
activeTempBasals = (TempBasalsInterface) getTheOneEnabledInArray(pluginsInCategory, PluginBase.TEMPBASAL);
if (Config.logConfigBuilder)
if (Config.logConfigBuilder && activeTempBasals != null)
log.debug("Selected tempbasal interface: " + ((PluginBase) activeTempBasals).getName());
for (PluginBase p : pluginsInCategory) {
if (!p.getName().equals(((PluginBase) activeTempBasals).getName())) {
@ -337,27 +337,37 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain
*/
@Override
public boolean isInitialized() {
return activePump.isInitialized();
if (activePump != null)
return activePump.isInitialized();
else return true;
}
@Override
public boolean isSuspended() {
return activePump.isSuspended();
if (activePump != null)
return activePump.isSuspended();
else return false;
}
@Override
public boolean isBusy() {
return activePump.isBusy();
if (activePump != null)
return activePump.isBusy();
else return false;
}
@Override
public boolean isTempBasalInProgress() {
return activePump.isTempBasalInProgress();
if (activePump != null)
return activePump.isTempBasalInProgress();
else return false;
}
@Override
public boolean isExtendedBoluslInProgress() {
return activePump.isExtendedBoluslInProgress();
if (activePump != null)
return activePump.isExtendedBoluslInProgress();
else return false;
}
@Override
@ -378,87 +388,129 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain
if (isThisProfileSet(profile)) {
log.debug("Correct profile already set");
return NOT_NEEDED;
} else {
} else if (activePump != null) {
return activePump.setNewBasalProfile(profile);
}
} else
return SUCCESS;
}
@Override
public boolean isThisProfileSet(NSProfile profile) {
return activePump.isThisProfileSet(profile);
if (activePump != null)
return activePump.isThisProfileSet(profile);
else return true;
}
@Override
public Date lastDataTime() {
return activePump.lastDataTime();
if (activePump != null)
return activePump.lastDataTime();
else return new Date();
}
@Override
public void refreshDataFromPump(String reason) {
activePump.refreshDataFromPump(reason);
if (activePump != null)
activePump.refreshDataFromPump(reason);
}
@Override
public double getBaseBasalRate() {
return activePump.getBaseBasalRate();
if (activePump != null)
return activePump.getBaseBasalRate();
else
return 0d;
}
@Override
public double getTempBasalAbsoluteRate() {
return activePump.getTempBasalAbsoluteRate();
if (activePump != null)
return activePump.getTempBasalAbsoluteRate();
else
return 0d;
}
@Override
public double getTempBasalRemainingMinutes() {
return activePump.getTempBasalRemainingMinutes();
if (activePump != null)
return activePump.getTempBasalRemainingMinutes();
else
return 0d;
}
@Override
public TempBasal getTempBasal(Date time) {
return activePump.getTempBasal(time);
if (activePump != null)
return activePump.getTempBasal(time);
else
return null;
}
@Override
public TempBasal getTempBasal() {
return activePump.getTempBasal();
if (activePump != null)
return activePump.getTempBasal();
else
return null;
}
@Override
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) {
mWakeLock.acquire();
insulin = applyBolusConstraints(insulin);
carbs = applyCarbsConstraints(carbs);
PumpEnactResult result;
if (activePump != null) {
insulin = applyBolusConstraints(insulin);
carbs = applyCarbsConstraints(carbs);
BolusProgressDialog bolusProgressDialog = null;
if (context != null) {
bolusProgressDialog = new BolusProgressDialog();
bolusProgressDialog.setInsulin(insulin);
bolusProgressDialog.show(((AppCompatActivity) context).getSupportFragmentManager(), "BolusProgress");
}
BolusProgressDialog bolusProgressDialog = null;
if (context != null) {
bolusProgressDialog = new BolusProgressDialog();
bolusProgressDialog.setInsulin(insulin);
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();
t.insulin = result.bolusDelivered;
if (carbTime == 0)
t.carbs = (double) result.carbsDelivered; // with different carbTime record will come back from nightscout
t.insulin = insulin;
t.carbs = (double) carbs;
t.created_at = new Date();
t.mealBolus = result.carbsDelivered > 0;
t.mealBolus = t.carbs > 0;
MainApp.getDbHelper().create(t);
t.setTimeIndex(t.getTimeIndex());
t.carbs = (double) result.carbsDelivered;
uploadBolusWizardRecord(t, glucose, glucoseType, carbTime, boluscalc);
t.sendToNSClient();
result = new PumpEnactResult();
result.success = true;
result.bolusDelivered = insulin;
result.carbsDelivered = carbs;
}
mWakeLock.release();
return result;
@ -471,42 +523,60 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain
public PumpEnactResult deliverTreatment(Double insulin, Integer carbs, Context context, boolean createTreatment) {
mWakeLock.acquire();
insulin = applyBolusConstraints(insulin);
carbs = applyCarbsConstraints(carbs);
PumpEnactResult result;
if (activePump != null) {
insulin = applyBolusConstraints(insulin);
carbs = applyCarbsConstraints(carbs);
BolusProgressDialog bolusProgressDialog = null;
if (context != null) {
bolusProgressDialog = new BolusProgressDialog();
bolusProgressDialog.setInsulin(insulin);
bolusProgressDialog.show(((AppCompatActivity) context).getSupportFragmentManager(), "BolusProgress");
BolusProgressDialog bolusProgressDialog = null;
if (context != null) {
bolusProgressDialog = new BolusProgressDialog();
bolusProgressDialog.setInsulin(insulin);
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 {
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));
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) {
if (Config.logCongigBuilderActions)
log.debug("Creating treatment: " + insulin + " carbs: " + carbs);
Treatment t = new Treatment();
t.insulin = result.bolusDelivered;
t.carbs = (double) result.carbsDelivered;
t.insulin = insulin;
t.carbs = (double) carbs;
t.created_at = new Date();
t.mealBolus = t.carbs > 0;
MainApp.getDbHelper().create(t);
t.setTimeIndex(t.getTimeIndex());
t.sendToNSClient();
result = new PumpEnactResult();
result.success = true;
result.bolusDelivered = insulin;
result.carbsDelivered = carbs;
}
mWakeLock.release();
return result;

View file

@ -196,7 +196,7 @@ public class LoopPlugin implements PluginBase {
if (result.changeRequested && allowNotification) {
NotificationCompat.Builder builder =
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))
.setContentText(resultAfterConstraints.toString())
.setAutoCancel(true)

View file

@ -309,12 +309,15 @@ public class WizardDialog extends DialogFragment implements OnClickListener {
}
// IOB calculation
TreatmentsInterface treatments = MainApp.getConfigBuilder().getActiveTreatments();
TempBasalsInterface tempBasals = MainApp.getConfigBuilder().getActiveTempBasals();
TreatmentsInterface treatments = ConfigBuilderPlugin.getActiveTreatments();
treatments.updateTotalIOB();
tempBasals.updateTotalIOB();
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");
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));
// iob
MainApp.getConfigBuilder().getActiveTreatments().updateTotalIOB();
IobTotal bolusIob = MainApp.getConfigBuilder().getActiveTreatments().getLastCalculation().round();
MainApp.getConfigBuilder().getActiveTempBasals().updateTotalIOB();
IobTotal basalIob = MainApp.getConfigBuilder().getActiveTempBasals().getLastCalculation().round();
ConfigBuilderPlugin.getActiveTreatments().updateTotalIOB();
IobTotal bolusIob = ConfigBuilderPlugin.getActiveTreatments().getLastCalculation().round();
IobTotal basalIob = new IobTotal(new Date().getTime());
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 ("
+ 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.PumpDescription;
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.VirtualPump.events.EventVirtualPumpUpdateGui;
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSProfile;
@ -169,7 +170,7 @@ public class VirtualPumpPlugin implements PluginBase, PumpInterface {
@Override
public double getBaseBasalRate() {
NSProfile profile = MainApp.getConfigBuilder().getActiveProfile().getProfile();
NSProfile profile = ConfigBuilderPlugin.getActiveProfile().getProfile();
if (profile == null)
return defaultBasalValue;
return profile.getBasal(profile.secondsFromMidnight());
@ -182,7 +183,7 @@ public class VirtualPumpPlugin implements PluginBase, PumpInterface {
if (getTempBasal().isAbsolute) {
return getTempBasal().absolute;
} else {
NSProfile profile = MainApp.getConfigBuilder().getActiveProfile().getProfile();
NSProfile profile = ConfigBuilderPlugin.getActiveProfile().getProfile();
if (profile == null)
return defaultBasalValue;
Double baseRate = profile.getBasal(profile.secondsFromMidnight());
@ -193,12 +194,12 @@ public class VirtualPumpPlugin implements PluginBase, PumpInterface {
@Override
public TempBasal getTempBasal() {
return MainApp.getConfigBuilder().getActiveTempBasals().getTempBasal(new Date());
return ConfigBuilderPlugin.getActiveTempBasals().getTempBasal(new Date());
}
@Override
public TempBasal getExtendedBolus() {
return MainApp.getConfigBuilder().getActiveTempBasals().getExtendedBolus(new Date());
return ConfigBuilderPlugin.getActiveTempBasals().getExtendedBolus(new Date());
}
@Override
@ -210,7 +211,7 @@ public class VirtualPumpPlugin implements PluginBase, PumpInterface {
@Override
public TempBasal getTempBasal(Date time) {
return MainApp.getConfigBuilder().getActiveTempBasals().getTempBasal(time);
return ConfigBuilderPlugin.getActiveTempBasals().getTempBasal(time);
}
@Override

View file

@ -11,6 +11,8 @@ import android.support.v7.app.NotificationCompat;
import com.squareup.otto.Subscribe;
import java.util.Date;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainActivity;
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.PumpInterface;
import info.nightscout.androidaps.data.IobTotal;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSProfile;
import info.nightscout.utils.DecimalFormatter;
@ -38,7 +41,7 @@ import info.nightscout.utils.DecimalFormatter;
public class PersistentNotificationPlugin implements PluginBase{
private static final int ONGOING_NOTIFICATION_ID = 4711;
static boolean fragmentEnabled = false;
static boolean fragmentEnabled = true;
private final Context ctx;
public PersistentNotificationPlugin(Context ctx) {
@ -131,10 +134,13 @@ public class PersistentNotificationPlugin implements PluginBase{
}
//IOB
MainApp.getConfigBuilder().getActiveTreatments().updateTotalIOB();
IobTotal bolusIob = MainApp.getConfigBuilder().getActiveTreatments().getLastCalculation().round();
MainApp.getConfigBuilder().getActiveTempBasals().updateTotalIOB();
IobTotal basalIob = MainApp.getConfigBuilder().getActiveTempBasals().getLastCalculation().round();
ConfigBuilderPlugin.getActiveTreatments().updateTotalIOB();
IobTotal bolusIob = ConfigBuilderPlugin.getActiveTreatments().getLastCalculation().round();
IobTotal basalIob = new IobTotal(new Date().getTime());
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 ("
+ ctx.getString(R.string.bolus) + ": " + DecimalFormatter.to2Decimal(bolusIob.iob) + "U "
+ ctx.getString(R.string.basal) + ": " + DecimalFormatter.to2Decimal(basalIob.basaliob) + "U)";
@ -151,7 +157,7 @@ public class PersistentNotificationPlugin implements PluginBase{
builder.setOngoing(true);
builder.setCategory(NotificationCompat.CATEGORY_STATUS);
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.setContentTitle(line1);
builder.setContentText(line2);

View file

@ -2,10 +2,13 @@ package info.nightscout.utils;
import org.json.JSONObject;
import java.util.Date;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.interfaces.TempBasalsInterface;
import info.nightscout.androidaps.interfaces.TreatmentsInterface;
import info.nightscout.androidaps.data.IobTotal;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSProfile;
/**
@ -48,7 +51,7 @@ public class BolusWizard {
this.bg = bg;
this.correction = correction;
NSProfile profile = MainApp.getConfigBuilder().getActiveProfile().getProfile();
NSProfile profile = ConfigBuilderPlugin.getActiveProfile().getProfile();
// Insulin from BG
sens = profile.getIsf(specificProfile, NSProfile.secondsFromMidnight());
@ -66,12 +69,16 @@ public class BolusWizard {
insulinFromCarbs = carbs / ic;
// Insulin from IOB
TreatmentsInterface treatments = MainApp.getConfigBuilder().getActiveTreatments();
TempBasalsInterface tempBasals = MainApp.getConfigBuilder().getActiveTempBasals();
// IOB calculation
TreatmentsInterface treatments = ConfigBuilderPlugin.getActiveTreatments();
treatments.updateTotalIOB();
tempBasals.updateTotalIOB();
bolusIob = treatments.getLastCalculation();
basalIob = tempBasals.getLastCalculation();
IobTotal bolusIob = treatments.getLastCalculation();
TempBasalsInterface tempBasals = ConfigBuilderPlugin.getActiveTempBasals();
IobTotal basalIob = new IobTotal(new Date().getTime());
if (tempBasals != null) {
tempBasals.updateTotalIOB();
basalIob = tempBasals.getLastCalculation().round();
}
insulingFromBolusIOB = includeBolusIOB ? -bolusIob.iob : 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"?>
<resources>
<string name="app_name">AndroidAPS</string>
<string name="closedloop">Closed Loop</string>
<string name="openloop">Open Loop</string>
<string name="apsmode_title">APS режим</string>

View file

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

View file

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

View file

@ -1,5 +1,4 @@
<resources>
<string name="app_name">AndroidAPS</string>
<string name="treatmentssafety_title">Seguridad tratamientos</string>
<string name="treatmentssafety_maxbolus_title">Máximo Bolo permitido [U]</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"?>
<resources>
<string name="app_name">AndroidAPS</string>
<string name="treatmentssafety_title">Treatments 안전설정</string>
<string name="treatmentssafety_maxbolus_title">최대 허용 식사주입인슐린 [U]</string>
<string name="treatmentssafety_maxcarbs_title">최대 허용 탄수화물 [g]</string>

View file

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