Merge branch 'dev' into omnipod_eros_dev_dagger
This commit is contained in:
commit
387a134795
|
@ -129,7 +129,7 @@ android {
|
||||||
targetSdkVersion 28
|
targetSdkVersion 28
|
||||||
multiDexEnabled true
|
multiDexEnabled true
|
||||||
versionCode 1500
|
versionCode 1500
|
||||||
version "2.7-omnipod-0.4-SNAPSHOT"
|
version "2.7-omnipod-0.4-dagger-SNAPSHOT"
|
||||||
buildConfigField "String", "VERSION", '"' + version + '"'
|
buildConfigField "String", "VERSION", '"' + version + '"'
|
||||||
buildConfigField "String", "BUILDVERSION", '"' + generateGitBuild() + '-' + generateDate() + '"'
|
buildConfigField "String", "BUILDVERSION", '"' + generateGitBuild() + '-' + generateDate() + '"'
|
||||||
buildConfigField "String", "REMOTE", '"' + generateGitRemote() + '"'
|
buildConfigField "String", "REMOTE", '"' + generateGitRemote() + '"'
|
||||||
|
@ -139,8 +139,8 @@ android {
|
||||||
|
|
||||||
// OMNIPOD: Keep track of what commit from the main repository we're on, these fields aren't actually used anywhere
|
// OMNIPOD: Keep track of what commit from the main repository we're on, these fields aren't actually used anywhere
|
||||||
buildConfigField "String", "DEV_VERSION", '"2.6.5-dev"'
|
buildConfigField "String", "DEV_VERSION", '"2.6.5-dev"'
|
||||||
buildConfigField "String", "DEV_VERSION_COMMIT", '"1481755bc8e63a741f05507579846340dbd49cd6"'
|
buildConfigField "String", "DEV_VERSION_COMMIT", '"b87155ead499167b3d42a73e3daf808494f10a2d"'
|
||||||
buildConfigField "String", "DEV_VERSION_COMMIT_DATE", '"21.4.2020"' // 21st April
|
buildConfigField "String", "DEV_VERSION_COMMIT_DATE", '"24.4.2020"' // 24th April
|
||||||
|
|
||||||
ndk {
|
ndk {
|
||||||
moduleName "BleCommandUtil"
|
moduleName "BleCommandUtil"
|
||||||
|
@ -320,11 +320,6 @@ dependencies {
|
||||||
}
|
}
|
||||||
testImplementation "org.skyscreamer:jsonassert:1.5.0"
|
testImplementation "org.skyscreamer:jsonassert:1.5.0"
|
||||||
testImplementation "org.hamcrest:hamcrest-all:1.3"
|
testImplementation "org.hamcrest:hamcrest-all:1.3"
|
||||||
/*
|
|
||||||
testImplementation("uk.org.lidalia:slf4j-test:1.2.0") {
|
|
||||||
exclude group: "com.google.guava", module: "guava"
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
|
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
|
||||||
implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
|
implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
|
||||||
|
|
|
@ -28,6 +28,7 @@ import info.nightscout.androidaps.plugins.general.automation.AutomationPlugin
|
||||||
import info.nightscout.androidaps.plugins.general.careportal.CareportalPlugin
|
import info.nightscout.androidaps.plugins.general.careportal.CareportalPlugin
|
||||||
import info.nightscout.androidaps.plugins.general.maintenance.MaintenancePlugin
|
import info.nightscout.androidaps.plugins.general.maintenance.MaintenancePlugin
|
||||||
import info.nightscout.androidaps.plugins.general.nsclient.NSClientPlugin
|
import info.nightscout.androidaps.plugins.general.nsclient.NSClientPlugin
|
||||||
|
import info.nightscout.androidaps.plugins.general.nsclient.data.NSSettingsStatus
|
||||||
import info.nightscout.androidaps.plugins.general.smsCommunicator.SmsCommunicatorPlugin
|
import info.nightscout.androidaps.plugins.general.smsCommunicator.SmsCommunicatorPlugin
|
||||||
import info.nightscout.androidaps.plugins.general.tidepool.TidepoolPlugin
|
import info.nightscout.androidaps.plugins.general.tidepool.TidepoolPlugin
|
||||||
import info.nightscout.androidaps.plugins.general.wear.WearPlugin
|
import info.nightscout.androidaps.plugins.general.wear.WearPlugin
|
||||||
|
@ -50,8 +51,8 @@ import info.nightscout.androidaps.plugins.source.EversensePlugin
|
||||||
import info.nightscout.androidaps.plugins.source.GlimpPlugin
|
import info.nightscout.androidaps.plugins.source.GlimpPlugin
|
||||||
import info.nightscout.androidaps.plugins.source.PoctechPlugin
|
import info.nightscout.androidaps.plugins.source.PoctechPlugin
|
||||||
import info.nightscout.androidaps.plugins.source.TomatoPlugin
|
import info.nightscout.androidaps.plugins.source.TomatoPlugin
|
||||||
import info.nightscout.androidaps.utils.alertDialogs.OKDialog.show
|
|
||||||
import info.nightscout.androidaps.utils.SafeParse
|
import info.nightscout.androidaps.utils.SafeParse
|
||||||
|
import info.nightscout.androidaps.utils.alertDialogs.OKDialog.show
|
||||||
import info.nightscout.androidaps.utils.protection.PasswordCheck
|
import info.nightscout.androidaps.utils.protection.PasswordCheck
|
||||||
import info.nightscout.androidaps.utils.protection.ProtectionCheck
|
import info.nightscout.androidaps.utils.protection.ProtectionCheck
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
|
@ -99,6 +100,7 @@ class MyPreferenceFragment : PreferenceFragmentCompat(), OnSharedPreferenceChang
|
||||||
@Inject lateinit var maintenancePlugin: MaintenancePlugin
|
@Inject lateinit var maintenancePlugin: MaintenancePlugin
|
||||||
|
|
||||||
@Inject lateinit var passwordCheck: PasswordCheck
|
@Inject lateinit var passwordCheck: PasswordCheck
|
||||||
|
@Inject lateinit var nsSettingStatus: NSSettingsStatus
|
||||||
|
|
||||||
@Inject lateinit var androidInjector: DispatchingAndroidInjector<Any>
|
@Inject lateinit var androidInjector: DispatchingAndroidInjector<Any>
|
||||||
|
|
||||||
|
@ -342,6 +344,11 @@ class MyPreferenceFragment : PreferenceFragmentCompat(), OnSharedPreferenceChang
|
||||||
passwordCheck.setPassword(context, R.string.application_password, R.string.key_application_password)
|
passwordCheck.setPassword(context, R.string.application_password, R.string.key_application_password)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
// NSClient copy settings
|
||||||
|
if (preference.key == resourceHelper.gs(R.string.key_statuslights_copy_ns)) {
|
||||||
|
nsSettingStatus.copyStatusLightsNsSettings(context)
|
||||||
|
return true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return super.onPreferenceTreeClick(preference)
|
return super.onPreferenceTreeClick(preference)
|
||||||
|
|
|
@ -8,7 +8,6 @@ import com.j256.ormlite.table.DatabaseTable;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
import org.slf4j.Logger;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
@ -18,25 +17,31 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
|
||||||
|
import dagger.android.HasAndroidInjector;
|
||||||
import info.nightscout.androidaps.Constants;
|
import info.nightscout.androidaps.Constants;
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.data.Profile;
|
import info.nightscout.androidaps.data.Profile;
|
||||||
import info.nightscout.androidaps.interfaces.Interval;
|
import info.nightscout.androidaps.interfaces.Interval;
|
||||||
|
import info.nightscout.androidaps.logging.AAPSLogger;
|
||||||
import info.nightscout.androidaps.logging.L;
|
import info.nightscout.androidaps.logging.L;
|
||||||
import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
|
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction;
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
|
||||||
import info.nightscout.androidaps.plugins.general.nsclient.data.NSMbg;
|
import info.nightscout.androidaps.plugins.general.nsclient.data.NSMbg;
|
||||||
import info.nightscout.androidaps.plugins.general.overview.OverviewFragment;
|
|
||||||
import info.nightscout.androidaps.plugins.general.overview.graphExtensions.DataPointWithLabelInterface;
|
import info.nightscout.androidaps.plugins.general.overview.graphExtensions.DataPointWithLabelInterface;
|
||||||
import info.nightscout.androidaps.plugins.general.overview.graphExtensions.PointsWithLabelGraphSeries;
|
import info.nightscout.androidaps.plugins.general.overview.graphExtensions.PointsWithLabelGraphSeries;
|
||||||
import info.nightscout.androidaps.utils.DateUtil;
|
import info.nightscout.androidaps.utils.DateUtil;
|
||||||
import info.nightscout.androidaps.utils.T;
|
import info.nightscout.androidaps.utils.T;
|
||||||
import info.nightscout.androidaps.utils.Translator;
|
import info.nightscout.androidaps.utils.Translator;
|
||||||
|
import info.nightscout.androidaps.utils.resources.ResourceHelper;
|
||||||
|
|
||||||
@DatabaseTable(tableName = DatabaseHelper.DATABASE_CAREPORTALEVENTS)
|
@DatabaseTable(tableName = DatabaseHelper.DATABASE_CAREPORTALEVENTS)
|
||||||
public class CareportalEvent implements DataPointWithLabelInterface, Interval {
|
public class CareportalEvent implements DataPointWithLabelInterface, Interval {
|
||||||
private static Logger log = StacktraceLoggerWrapper.getLogger(L.DATABASE);
|
|
||||||
|
@Inject ProfileFunction profileFunction;
|
||||||
|
@Inject ResourceHelper resourceHelper;
|
||||||
|
@Inject AAPSLogger aapsLogger;
|
||||||
|
|
||||||
@DatabaseField(id = true)
|
@DatabaseField(id = true)
|
||||||
public long date;
|
public long date;
|
||||||
|
@ -76,7 +81,13 @@ public class CareportalEvent implements DataPointWithLabelInterface, Interval {
|
||||||
|
|
||||||
public static final String MBG = "Mbg"; // comming from entries
|
public static final String MBG = "Mbg"; // comming from entries
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public CareportalEvent() {
|
public CareportalEvent() {
|
||||||
|
MainApp.instance().androidInjector().inject(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public CareportalEvent(HasAndroidInjector injector) {
|
||||||
|
injector.androidInjector().inject(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public CareportalEvent(NSMbg mbg) {
|
public CareportalEvent(NSMbg mbg) {
|
||||||
|
@ -89,19 +100,19 @@ public class CareportalEvent implements DataPointWithLabelInterface, Interval {
|
||||||
return System.currentTimeMillis() - date;
|
return System.currentTimeMillis() - date;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getHoursFromStart() {
|
private double getHoursFromStart() {
|
||||||
return (System.currentTimeMillis() - date) / (60 * 60 * 1000.0);
|
return (System.currentTimeMillis() - date) / (60 * 60 * 1000.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String age(boolean useShortText) {
|
public String age(boolean useShortText, ResourceHelper resourceHelper) {
|
||||||
Map<TimeUnit, Long> diff = computeDiff(date, System.currentTimeMillis());
|
Map<TimeUnit, Long> diff = computeDiff(date, System.currentTimeMillis());
|
||||||
|
|
||||||
String days = " " + MainApp.gs(R.string.days) + " ";
|
String days = " " + resourceHelper.gs(R.string.days) + " ";
|
||||||
String hours = " " + MainApp.gs(R.string.hours) + " ";
|
String hours = " " + resourceHelper.gs(R.string.hours) + " ";
|
||||||
|
|
||||||
if (useShortText) {
|
if (useShortText) {
|
||||||
days = MainApp.gs(R.string.shortday);
|
days = resourceHelper.gs(R.string.shortday);
|
||||||
hours = MainApp.gs(R.string.shorthour);
|
hours = resourceHelper.gs(R.string.shorthour);
|
||||||
}
|
}
|
||||||
|
|
||||||
return diff.get(TimeUnit.DAYS) + days + diff.get(TimeUnit.HOURS) + hours;
|
return diff.get(TimeUnit.DAYS) + days + diff.get(TimeUnit.HOURS) + hours;
|
||||||
|
@ -124,11 +135,11 @@ public class CareportalEvent implements DataPointWithLabelInterface, Interval {
|
||||||
}
|
}
|
||||||
|
|
||||||
//Map:{DAYS=1, HOURS=3, MINUTES=46, SECONDS=40, MILLISECONDS=0, MICROSECONDS=0, NANOSECONDS=0}
|
//Map:{DAYS=1, HOURS=3, MINUTES=46, SECONDS=40, MILLISECONDS=0, MICROSECONDS=0, NANOSECONDS=0}
|
||||||
public static Map<TimeUnit, Long> computeDiff(long date1, long date2) {
|
private static Map<TimeUnit, Long> computeDiff(long date1, long date2) {
|
||||||
long diffInMillies = date2 - date1;
|
long diffInMillies = date2 - date1;
|
||||||
List<TimeUnit> units = new ArrayList<TimeUnit>(EnumSet.allOf(TimeUnit.class));
|
List<TimeUnit> units = new ArrayList<>(EnumSet.allOf(TimeUnit.class));
|
||||||
Collections.reverse(units);
|
Collections.reverse(units);
|
||||||
Map<TimeUnit, Long> result = new LinkedHashMap<TimeUnit, Long>();
|
Map<TimeUnit, Long> result = new LinkedHashMap<>();
|
||||||
long milliesRest = diffInMillies;
|
long milliesRest = diffInMillies;
|
||||||
for (TimeUnit unit : units) {
|
for (TimeUnit unit : units) {
|
||||||
long diff = unit.convert(milliesRest, TimeUnit.MILLISECONDS);
|
long diff = unit.convert(milliesRest, TimeUnit.MILLISECONDS);
|
||||||
|
@ -140,12 +151,12 @@ public class CareportalEvent implements DataPointWithLabelInterface, Interval {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static boolean isEvent5minBack(List<CareportalEvent> list, long time) {
|
public boolean isEvent5minBack(List<CareportalEvent> list, long time) {
|
||||||
for (int i = 0; i < list.size(); i++) {
|
for (int i = 0; i < list.size(); i++) {
|
||||||
CareportalEvent event = list.get(i);
|
CareportalEvent event = list.get(i);
|
||||||
if (event.date <= time && event.date > (time - T.mins(5).msecs())) {
|
if (event.date <= time && event.date > (time - T.mins(5).msecs())) {
|
||||||
if (L.isEnabled(L.DATABASE))
|
if (L.isEnabled(L.DATABASE))
|
||||||
log.debug("Found event for time: " + DateUtil.dateAndTimeString(time) + " " + event.toString());
|
aapsLogger.debug("Found event for time: " + DateUtil.dateAndTimeString(time) + " " + event.toString());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -159,18 +170,18 @@ public class CareportalEvent implements DataPointWithLabelInterface, Interval {
|
||||||
return date;
|
return date;
|
||||||
}
|
}
|
||||||
|
|
||||||
double yValue = 0;
|
private double yValue = 0;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getY() {
|
public double getY() {
|
||||||
String units = ConfigBuilderPlugin.getPlugin().getProfileFunction().getUnits();
|
String units = profileFunction.getUnits();
|
||||||
if (eventType.equals(MBG)) {
|
if (eventType.equals(MBG)) {
|
||||||
double mbg = 0d;
|
double mbg = 0d;
|
||||||
try {
|
try {
|
||||||
JSONObject object = new JSONObject(json);
|
JSONObject object = new JSONObject(json);
|
||||||
mbg = object.getDouble("mgdl");
|
mbg = object.getDouble("mgdl");
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
log.error("Unhandled exception", e);
|
aapsLogger.error("Unhandled exception", e);
|
||||||
}
|
}
|
||||||
return Profile.fromMgdlToUnits(mbg, units);
|
return Profile.fromMgdlToUnits(mbg, units);
|
||||||
}
|
}
|
||||||
|
@ -183,7 +194,7 @@ public class CareportalEvent implements DataPointWithLabelInterface, Interval {
|
||||||
units = object.getString("units");
|
units = object.getString("units");
|
||||||
}
|
}
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
log.error("Unhandled exception", e);
|
aapsLogger.error("Unhandled exception", e);
|
||||||
}
|
}
|
||||||
if (glucose != 0d) {
|
if (glucose != 0d) {
|
||||||
double mmol = 0d;
|
double mmol = 0d;
|
||||||
|
@ -214,7 +225,7 @@ public class CareportalEvent implements DataPointWithLabelInterface, Interval {
|
||||||
if (object.has("notes"))
|
if (object.has("notes"))
|
||||||
return StringUtils.abbreviate(object.getString("notes"), 40);
|
return StringUtils.abbreviate(object.getString("notes"), 40);
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
log.error("Unhandled exception", e);
|
aapsLogger.error("Unhandled exception", e);
|
||||||
}
|
}
|
||||||
return Translator.translate(eventType);
|
return Translator.translate(eventType);
|
||||||
}
|
}
|
||||||
|
@ -225,7 +236,7 @@ public class CareportalEvent implements DataPointWithLabelInterface, Interval {
|
||||||
if (object.has("notes"))
|
if (object.has("notes"))
|
||||||
return object.getString("notes");
|
return object.getString("notes");
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
log.error("Unhandled exception", e);
|
aapsLogger.error("Unhandled exception", e);
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
@ -256,14 +267,14 @@ public class CareportalEvent implements DataPointWithLabelInterface, Interval {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float getSize() {
|
public float getSize() {
|
||||||
boolean isTablet = MainApp.resources().getBoolean(R.bool.isTablet);
|
boolean isTablet = resourceHelper.gb(R.bool.isTablet);
|
||||||
return isTablet ? 12 : 10;
|
return isTablet ? 12 : 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getColor() {
|
public int getColor() {
|
||||||
if (eventType.equals(ANNOUNCEMENT))
|
if (eventType.equals(ANNOUNCEMENT))
|
||||||
return MainApp.gc(R.color.notificationAnnouncement);
|
return resourceHelper.gc(R.color.notificationAnnouncement);
|
||||||
if (eventType.equals(MBG))
|
if (eventType.equals(MBG))
|
||||||
return Color.RED;
|
return Color.RED;
|
||||||
if (eventType.equals(BGCHECK))
|
if (eventType.equals(BGCHECK))
|
||||||
|
@ -276,7 +287,7 @@ public class CareportalEvent implements DataPointWithLabelInterface, Interval {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Interval interface
|
// Interval interface
|
||||||
Long cuttedEnd = null;
|
private Long cuttedEnd = null;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long durationInMsec() {
|
public long durationInMsec() {
|
||||||
|
@ -285,7 +296,7 @@ public class CareportalEvent implements DataPointWithLabelInterface, Interval {
|
||||||
if (object.has("duration"))
|
if (object.has("duration"))
|
||||||
return object.getInt("duration") * 60 * 1000L;
|
return object.getInt("duration") * 60 * 1000L;
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
log.error("Unhandled exception", e);
|
aapsLogger.error("Unhandled exception", e);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,10 @@ import org.slf4j.Logger;
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
|
||||||
|
import dagger.android.HasAndroidInjector;
|
||||||
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.data.Iob;
|
import info.nightscout.androidaps.data.Iob;
|
||||||
import info.nightscout.androidaps.data.IobTotal;
|
import info.nightscout.androidaps.data.IobTotal;
|
||||||
|
@ -15,8 +19,8 @@ import info.nightscout.androidaps.interfaces.InsulinInterface;
|
||||||
import info.nightscout.androidaps.interfaces.Interval;
|
import info.nightscout.androidaps.interfaces.Interval;
|
||||||
import info.nightscout.androidaps.logging.L;
|
import info.nightscout.androidaps.logging.L;
|
||||||
import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
|
import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.PluginStore;
|
import info.nightscout.androidaps.plugins.configBuilder.PluginStore;
|
||||||
|
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction;
|
||||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensResult;
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensResult;
|
||||||
import info.nightscout.androidaps.plugins.treatments.Treatment;
|
import info.nightscout.androidaps.plugins.treatments.Treatment;
|
||||||
import info.nightscout.androidaps.utils.DateUtil;
|
import info.nightscout.androidaps.utils.DateUtil;
|
||||||
|
@ -31,6 +35,9 @@ import info.nightscout.androidaps.utils.SP;
|
||||||
public class TemporaryBasal implements Interval, DbObjectBase {
|
public class TemporaryBasal implements Interval, DbObjectBase {
|
||||||
private static Logger log = StacktraceLoggerWrapper.getLogger(L.DATABASE);
|
private static Logger log = StacktraceLoggerWrapper.getLogger(L.DATABASE);
|
||||||
|
|
||||||
|
@Inject public ProfileFunction profileFunction;
|
||||||
|
private HasAndroidInjector injector;
|
||||||
|
|
||||||
@DatabaseField(id = true)
|
@DatabaseField(id = true)
|
||||||
public long date;
|
public long date;
|
||||||
|
|
||||||
|
@ -59,7 +66,15 @@ public class TemporaryBasal implements Interval, DbObjectBase {
|
||||||
|
|
||||||
public double netExtendedRate = 0d;
|
public double netExtendedRate = 0d;
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public TemporaryBasal() {
|
public TemporaryBasal() {
|
||||||
|
injector = MainApp.instance();
|
||||||
|
injector.androidInjector().inject(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public TemporaryBasal(HasAndroidInjector injector) {
|
||||||
|
this.injector = injector;
|
||||||
|
injector.androidInjector().inject(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public TemporaryBasal date(long date) {
|
public TemporaryBasal date(long date) {
|
||||||
|
@ -95,7 +110,7 @@ public class TemporaryBasal implements Interval, DbObjectBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public TemporaryBasal(ExtendedBolus extendedBolus) {
|
public TemporaryBasal(ExtendedBolus extendedBolus) {
|
||||||
double basal = ConfigBuilderPlugin.getPlugin().getProfileFunction().getProfile(extendedBolus.date).getBasal(extendedBolus.date);
|
double basal = profileFunction.getProfile(extendedBolus.date).getBasal(extendedBolus.date);
|
||||||
this.date = extendedBolus.date;
|
this.date = extendedBolus.date;
|
||||||
this.isValid = extendedBolus.isValid;
|
this.isValid = extendedBolus.isValid;
|
||||||
this.source = extendedBolus.source;
|
this.source = extendedBolus.source;
|
||||||
|
@ -109,7 +124,7 @@ public class TemporaryBasal implements Interval, DbObjectBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public TemporaryBasal clone() {
|
public TemporaryBasal clone() {
|
||||||
TemporaryBasal t = new TemporaryBasal();
|
TemporaryBasal t = new TemporaryBasal(injector);
|
||||||
t.date = date;
|
t.date = date;
|
||||||
t.isValid = isValid;
|
t.isValid = isValid;
|
||||||
t.source = source;
|
t.source = source;
|
||||||
|
@ -404,7 +419,7 @@ public class TemporaryBasal implements Interval, DbObjectBase {
|
||||||
public String toStringFull() {
|
public String toStringFull() {
|
||||||
if (isFakeExtended) {
|
if (isFakeExtended) {
|
||||||
|
|
||||||
Profile profile = ConfigBuilderPlugin.getPlugin().getProfileFunction().getProfile();
|
Profile profile = profileFunction.getProfile();
|
||||||
if (profile == null)
|
if (profile == null)
|
||||||
return "null";
|
return "null";
|
||||||
Double currentBasalRate = profile.getBasal();
|
Double currentBasalRate = profile.getBasal();
|
||||||
|
@ -428,7 +443,7 @@ public class TemporaryBasal implements Interval, DbObjectBase {
|
||||||
|
|
||||||
double rate;
|
double rate;
|
||||||
if (isFakeExtended) {
|
if (isFakeExtended) {
|
||||||
Profile profile = ConfigBuilderPlugin.getPlugin().getProfileFunction().getProfile();
|
Profile profile = profileFunction.getProfile();
|
||||||
if (profile == null)
|
if (profile == null)
|
||||||
return "null";
|
return "null";
|
||||||
double currentBasalRate = profile.getBasal();
|
double currentBasalRate = profile.getBasal();
|
||||||
|
@ -438,7 +453,7 @@ public class TemporaryBasal implements Interval, DbObjectBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SP.getBoolean(R.string.key_danar_visualizeextendedaspercentage, false) && SP.getBoolean(R.string.key_danar_useextended, false)) {
|
if (SP.getBoolean(R.string.key_danar_visualizeextendedaspercentage, false) && SP.getBoolean(R.string.key_danar_useextended, false)) {
|
||||||
Profile profile = ConfigBuilderPlugin.getPlugin().getProfileFunction().getProfile();
|
Profile profile = profileFunction.getProfile();
|
||||||
if (profile != null) {
|
if (profile != null) {
|
||||||
double basal = profile.getBasal();
|
double basal = profile.getBasal();
|
||||||
if (basal != 0) {
|
if (basal != 0) {
|
||||||
|
@ -453,7 +468,7 @@ public class TemporaryBasal implements Interval, DbObjectBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getCalcuatedPercentageIfNeeded() {
|
private String getCalcuatedPercentageIfNeeded() {
|
||||||
Profile profile = ConfigBuilderPlugin.getPlugin().getProfileFunction().getProfile();
|
Profile profile = profileFunction.getProfile();
|
||||||
|
|
||||||
if (profile == null)
|
if (profile == null)
|
||||||
return "null";
|
return "null";
|
||||||
|
@ -479,7 +494,7 @@ public class TemporaryBasal implements Interval, DbObjectBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toStringVeryShort() {
|
public String toStringVeryShort() {
|
||||||
Profile profile = ConfigBuilderPlugin.getPlugin().getProfileFunction().getProfile();
|
Profile profile = profileFunction.getProfile();
|
||||||
|
|
||||||
if (profile == null)
|
if (profile == null)
|
||||||
return "null";
|
return "null";
|
||||||
|
|
|
@ -9,10 +9,12 @@ import info.nightscout.androidaps.data.Profile
|
||||||
import info.nightscout.androidaps.data.ProfileStore
|
import info.nightscout.androidaps.data.ProfileStore
|
||||||
import info.nightscout.androidaps.data.PumpEnactResult
|
import info.nightscout.androidaps.data.PumpEnactResult
|
||||||
import info.nightscout.androidaps.db.BgReading
|
import info.nightscout.androidaps.db.BgReading
|
||||||
|
import info.nightscout.androidaps.db.CareportalEvent
|
||||||
import info.nightscout.androidaps.db.ProfileSwitch
|
import info.nightscout.androidaps.db.ProfileSwitch
|
||||||
|
import info.nightscout.androidaps.db.TemporaryBasal
|
||||||
|
import info.nightscout.androidaps.plugins.aps.logger.LoggerCallback
|
||||||
import info.nightscout.androidaps.plugins.aps.loop.APSResult
|
import info.nightscout.androidaps.plugins.aps.loop.APSResult
|
||||||
import info.nightscout.androidaps.plugins.aps.openAPSAMA.DetermineBasalResultAMA
|
import info.nightscout.androidaps.plugins.aps.openAPSAMA.DetermineBasalResultAMA
|
||||||
import info.nightscout.androidaps.plugins.aps.logger.LoggerCallback
|
|
||||||
import info.nightscout.androidaps.plugins.aps.openAPSSMB.DetermineBasalAdapterSMBJS
|
import info.nightscout.androidaps.plugins.aps.openAPSSMB.DetermineBasalAdapterSMBJS
|
||||||
import info.nightscout.androidaps.plugins.aps.openAPSSMB.DetermineBasalResultSMB
|
import info.nightscout.androidaps.plugins.aps.openAPSSMB.DetermineBasalResultSMB
|
||||||
import info.nightscout.androidaps.plugins.constraints.objectives.objectives.*
|
import info.nightscout.androidaps.plugins.constraints.objectives.objectives.*
|
||||||
|
@ -152,6 +154,8 @@ interface AppComponent : AndroidInjector<MainApp> {
|
||||||
fun injectTreatment(treatment: Treatment)
|
fun injectTreatment(treatment: Treatment)
|
||||||
fun injectBgReading(bgReading: BgReading)
|
fun injectBgReading(bgReading: BgReading)
|
||||||
fun injectProfileSwitch(profileSwitch: ProfileSwitch)
|
fun injectProfileSwitch(profileSwitch: ProfileSwitch)
|
||||||
|
fun injectTemporaryBasal(temporaryBasal: TemporaryBasal)
|
||||||
|
fun injectCareportalEvent(careportalEvent: CareportalEvent)
|
||||||
|
|
||||||
fun injectNotification(notificationWithAction: NotificationWithAction)
|
fun injectNotification(notificationWithAction: NotificationWithAction)
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,9 @@ import info.nightscout.androidaps.data.Profile
|
||||||
import info.nightscout.androidaps.data.ProfileStore
|
import info.nightscout.androidaps.data.ProfileStore
|
||||||
import info.nightscout.androidaps.data.PumpEnactResult
|
import info.nightscout.androidaps.data.PumpEnactResult
|
||||||
import info.nightscout.androidaps.db.BgReading
|
import info.nightscout.androidaps.db.BgReading
|
||||||
|
import info.nightscout.androidaps.db.CareportalEvent
|
||||||
import info.nightscout.androidaps.db.ProfileSwitch
|
import info.nightscout.androidaps.db.ProfileSwitch
|
||||||
|
import info.nightscout.androidaps.db.TemporaryBasal
|
||||||
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
||||||
import info.nightscout.androidaps.interfaces.CommandQueueProvider
|
import info.nightscout.androidaps.interfaces.CommandQueueProvider
|
||||||
import info.nightscout.androidaps.interfaces.PluginBase
|
import info.nightscout.androidaps.interfaces.PluginBase
|
||||||
|
@ -37,6 +39,7 @@ import info.nightscout.androidaps.plugins.general.overview.graphData.GraphData
|
||||||
import info.nightscout.androidaps.plugins.general.maintenance.ImportExportPrefs
|
import info.nightscout.androidaps.plugins.general.maintenance.ImportExportPrefs
|
||||||
import info.nightscout.androidaps.plugins.general.maintenance.formats.ClassicPrefsFormat
|
import info.nightscout.androidaps.plugins.general.maintenance.formats.ClassicPrefsFormat
|
||||||
import info.nightscout.androidaps.plugins.general.maintenance.formats.EncryptedPrefsFormat
|
import info.nightscout.androidaps.plugins.general.maintenance.formats.EncryptedPrefsFormat
|
||||||
|
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload
|
||||||
import info.nightscout.androidaps.plugins.general.overview.notifications.NotificationWithAction
|
import info.nightscout.androidaps.plugins.general.overview.notifications.NotificationWithAction
|
||||||
import info.nightscout.androidaps.plugins.general.smsCommunicator.AuthRequest
|
import info.nightscout.androidaps.plugins.general.smsCommunicator.AuthRequest
|
||||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensData
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensData
|
||||||
|
@ -98,11 +101,14 @@ open class AppModule {
|
||||||
fun providesPlugins(@PluginsModule.AllConfigs allConfigs: Map<@JvmSuppressWildcards Int, @JvmSuppressWildcards PluginBase>,
|
fun providesPlugins(@PluginsModule.AllConfigs allConfigs: Map<@JvmSuppressWildcards Int, @JvmSuppressWildcards PluginBase>,
|
||||||
@PluginsModule.PumpDriver pumpDrivers: Lazy<Map<@JvmSuppressWildcards Int, @JvmSuppressWildcards PluginBase>>,
|
@PluginsModule.PumpDriver pumpDrivers: Lazy<Map<@JvmSuppressWildcards Int, @JvmSuppressWildcards PluginBase>>,
|
||||||
@PluginsModule.NotNSClient notNsClient: Lazy<Map<@JvmSuppressWildcards Int, @JvmSuppressWildcards PluginBase>>,
|
@PluginsModule.NotNSClient notNsClient: Lazy<Map<@JvmSuppressWildcards Int, @JvmSuppressWildcards PluginBase>>,
|
||||||
@PluginsModule.APS aps: Lazy<Map<@JvmSuppressWildcards Int, @JvmSuppressWildcards PluginBase>>): List<@JvmSuppressWildcards PluginBase> {
|
@PluginsModule.NSClient nsClient: Lazy<Map<@JvmSuppressWildcards Int, @JvmSuppressWildcards PluginBase>>,
|
||||||
|
@PluginsModule.APS aps: Lazy<Map<@JvmSuppressWildcards Int, @JvmSuppressWildcards PluginBase>>)
|
||||||
|
: List<@JvmSuppressWildcards PluginBase> {
|
||||||
val plugins = allConfigs.toMutableMap()
|
val plugins = allConfigs.toMutableMap()
|
||||||
if (Config.PUMPDRIVERS) plugins += pumpDrivers.get()
|
if (Config.PUMPDRIVERS) plugins += pumpDrivers.get()
|
||||||
if (Config.APS) plugins += aps.get()
|
if (Config.APS) plugins += aps.get()
|
||||||
if (!Config.NSCLIENT) plugins += notNsClient.get()
|
if (!Config.NSCLIENT) plugins += notNsClient.get()
|
||||||
|
if (Config.NSCLIENT) plugins += nsClient.get()
|
||||||
return plugins.toList().sortedBy { it.first }.map { it.second }
|
return plugins.toList().sortedBy { it.first }.map { it.second }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -233,6 +239,8 @@ open class AppModule {
|
||||||
@ContributesAndroidInjector fun bgReadingInjector(): BgReading
|
@ContributesAndroidInjector fun bgReadingInjector(): BgReading
|
||||||
@ContributesAndroidInjector fun treatmentInjector(): Treatment
|
@ContributesAndroidInjector fun treatmentInjector(): Treatment
|
||||||
@ContributesAndroidInjector fun profileSwitchInjector(): ProfileSwitch
|
@ContributesAndroidInjector fun profileSwitchInjector(): ProfileSwitch
|
||||||
|
@ContributesAndroidInjector fun temporaryBasalInjector(): TemporaryBasal
|
||||||
|
@ContributesAndroidInjector fun careportalEventInjector(): CareportalEvent
|
||||||
|
|
||||||
@ContributesAndroidInjector fun notificationWithActionInjector(): NotificationWithAction
|
@ContributesAndroidInjector fun notificationWithActionInjector(): NotificationWithAction
|
||||||
|
|
||||||
|
|
|
@ -165,7 +165,7 @@ abstract class PluginsModule {
|
||||||
abstract fun bindVirtualPumpPlugin(plugin: VirtualPumpPlugin): PluginBase
|
abstract fun bindVirtualPumpPlugin(plugin: VirtualPumpPlugin): PluginBase
|
||||||
|
|
||||||
@Binds
|
@Binds
|
||||||
@NotNSClient
|
@NSClient
|
||||||
@IntoMap
|
@IntoMap
|
||||||
@IntKey(180)
|
@IntKey(180)
|
||||||
abstract fun bindCareportalPlugin(plugin: CareportalPlugin): PluginBase
|
abstract fun bindCareportalPlugin(plugin: CareportalPlugin): PluginBase
|
||||||
|
@ -213,7 +213,7 @@ abstract class PluginsModule {
|
||||||
abstract fun bindTreatmentsPlugin(plugin: TreatmentsPlugin): PluginBase
|
abstract fun bindTreatmentsPlugin(plugin: TreatmentsPlugin): PluginBase
|
||||||
|
|
||||||
@Binds
|
@Binds
|
||||||
@NotNSClient
|
@AllConfigs
|
||||||
@IntoSet
|
@IntoSet
|
||||||
abstract fun bindSafetyPlugin(plugin: SafetyPlugin): PluginBase
|
abstract fun bindSafetyPlugin(plugin: SafetyPlugin): PluginBase
|
||||||
|
|
||||||
|
@ -359,6 +359,9 @@ abstract class PluginsModule {
|
||||||
@Qualifier
|
@Qualifier
|
||||||
annotation class NotNSClient
|
annotation class NotNSClient
|
||||||
|
|
||||||
|
@Qualifier
|
||||||
|
annotation class NSClient
|
||||||
|
|
||||||
@Qualifier
|
@Qualifier
|
||||||
annotation class APS
|
annotation class APS
|
||||||
|
|
||||||
|
|
|
@ -183,7 +183,7 @@ class CareDialog : DialogFragmentWithDate() {
|
||||||
|
|
||||||
activity?.let { activity ->
|
activity?.let { activity ->
|
||||||
OKDialog.showConfirmation(activity, resourceHelper.gs(event), HtmlHelper.fromHtml(Joiner.on("<br/>").join(actions)), Runnable {
|
OKDialog.showConfirmation(activity, resourceHelper.gs(event), HtmlHelper.fromHtml(Joiner.on("<br/>").join(actions)), Runnable {
|
||||||
val careportalEvent = CareportalEvent()
|
val careportalEvent = CareportalEvent(injector)
|
||||||
careportalEvent.date = eventTime
|
careportalEvent.date = eventTime
|
||||||
careportalEvent.source = Source.USER
|
careportalEvent.source = Source.USER
|
||||||
careportalEvent.eventType = when (options) {
|
careportalEvent.eventType = when (options) {
|
||||||
|
|
|
@ -7,6 +7,7 @@ import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import com.google.common.base.Joiner
|
import com.google.common.base.Joiner
|
||||||
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.androidaps.MainApp
|
import info.nightscout.androidaps.MainApp
|
||||||
import info.nightscout.androidaps.R
|
import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.activities.ErrorHelperActivity
|
import info.nightscout.androidaps.activities.ErrorHelperActivity
|
||||||
|
@ -40,6 +41,7 @@ class FillDialog : DialogFragmentWithDate() {
|
||||||
@Inject lateinit var ctx: Context
|
@Inject lateinit var ctx: Context
|
||||||
@Inject lateinit var commandQueue: CommandQueueProvider
|
@Inject lateinit var commandQueue: CommandQueueProvider
|
||||||
@Inject lateinit var activePlugin: ActivePluginProvider
|
@Inject lateinit var activePlugin: ActivePluginProvider
|
||||||
|
@Inject lateinit var injector: HasAndroidInjector
|
||||||
|
|
||||||
override fun onSaveInstanceState(savedInstanceState: Bundle) {
|
override fun onSaveInstanceState(savedInstanceState: Bundle) {
|
||||||
super.onSaveInstanceState(savedInstanceState)
|
super.onSaveInstanceState(savedInstanceState)
|
||||||
|
@ -161,7 +163,7 @@ class FillDialog : DialogFragmentWithDate() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun generateCareportalEvent(eventType: String, time: Long, notes: String) {
|
private fun generateCareportalEvent(eventType: String, time: Long, notes: String) {
|
||||||
val careportalEvent = CareportalEvent()
|
val careportalEvent = CareportalEvent(injector)
|
||||||
careportalEvent.source = Source.USER
|
careportalEvent.source = Source.USER
|
||||||
careportalEvent.date = time
|
careportalEvent.date = time
|
||||||
careportalEvent.json = generateJson(eventType, time, notes).toString()
|
careportalEvent.json = generateJson(eventType, time, notes).toString()
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package info.nightscout.androidaps.events
|
package info.nightscout.androidaps.events
|
||||||
|
|
||||||
class EventBTChange constructor(val state: Change, val deviceName: String) : Event() {
|
class EventBTChange(val state: Change, val deviceName: String?, val deviceAddress: String? = null) : Event() {
|
||||||
|
|
||||||
enum class Change {
|
enum class Change {
|
||||||
CONNECT,
|
CONNECT,
|
||||||
DISCONNECT
|
DISCONNECT
|
||||||
|
|
|
@ -1,378 +0,0 @@
|
||||||
package info.nightscout.androidaps.historyBrowser;
|
|
||||||
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.os.SystemClock;
|
|
||||||
import android.text.SpannableString;
|
|
||||||
import android.text.style.ForegroundColorSpan;
|
|
||||||
import android.view.Menu;
|
|
||||||
import android.view.MenuItem;
|
|
||||||
import android.view.View;
|
|
||||||
import android.widget.Button;
|
|
||||||
import android.widget.ImageButton;
|
|
||||||
import android.widget.SeekBar;
|
|
||||||
import android.widget.TextView;
|
|
||||||
|
|
||||||
import androidx.appcompat.widget.PopupMenu;
|
|
||||||
import androidx.core.content.res.ResourcesCompat;
|
|
||||||
|
|
||||||
import com.jjoe64.graphview.GraphView;
|
|
||||||
import com.wdullaer.materialdatetimepicker.date.DatePickerDialog;
|
|
||||||
|
|
||||||
import java.util.Calendar;
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
import javax.inject.Inject;
|
|
||||||
|
|
||||||
import dagger.android.HasAndroidInjector;
|
|
||||||
import info.nightscout.androidaps.R;
|
|
||||||
import info.nightscout.androidaps.activities.NoSplashAppCompatActivity;
|
|
||||||
import info.nightscout.androidaps.data.Profile;
|
|
||||||
import info.nightscout.androidaps.events.EventCustomCalculationFinished;
|
|
||||||
import info.nightscout.androidaps.events.EventRefreshOverview;
|
|
||||||
import info.nightscout.androidaps.interfaces.ActivePluginProvider;
|
|
||||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger;
|
|
||||||
import info.nightscout.androidaps.logging.LTag;
|
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper;
|
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction;
|
|
||||||
import info.nightscout.androidaps.plugins.general.overview.OverviewFragment;
|
|
||||||
import info.nightscout.androidaps.plugins.general.overview.OverviewMenus;
|
|
||||||
import info.nightscout.androidaps.plugins.general.overview.graphData.GraphData;
|
|
||||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventAutosensCalculationFinished;
|
|
||||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventIobCalculationProgress;
|
|
||||||
import info.nightscout.androidaps.utils.DateUtil;
|
|
||||||
import info.nightscout.androidaps.utils.DefaultValueHelper;
|
|
||||||
import info.nightscout.androidaps.utils.FabricPrivacy;
|
|
||||||
import info.nightscout.androidaps.utils.T;
|
|
||||||
import info.nightscout.androidaps.utils.buildHelper.BuildHelper;
|
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper;
|
|
||||||
import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
|
||||||
import io.reactivex.disposables.CompositeDisposable;
|
|
||||||
|
|
||||||
public class HistoryBrowseActivity extends NoSplashAppCompatActivity {
|
|
||||||
@Inject HasAndroidInjector injector;
|
|
||||||
@Inject AAPSLogger aapsLogger;
|
|
||||||
@Inject RxBusWrapper rxBus;
|
|
||||||
@Inject SP sp;
|
|
||||||
@Inject ResourceHelper resourceHelper;
|
|
||||||
@Inject ProfileFunction profileFunction;
|
|
||||||
@Inject DefaultValueHelper defaultValueHelper;
|
|
||||||
@Inject IobCobStaticCalculatorPlugin iobCobStaticCalculatorPlugin;
|
|
||||||
@Inject ActivePluginProvider activePlugin;
|
|
||||||
@Inject BuildHelper buildHelper;
|
|
||||||
@Inject FabricPrivacy fabricPrivacy;
|
|
||||||
@Inject OverviewMenus overviewMenus;
|
|
||||||
|
|
||||||
private CompositeDisposable disposable = new CompositeDisposable();
|
|
||||||
|
|
||||||
ImageButton chartButton;
|
|
||||||
|
|
||||||
boolean showBasal = true;
|
|
||||||
boolean showIob, showCob, showDev, showRat, showActPrim, showActSec, showDevslope;
|
|
||||||
|
|
||||||
|
|
||||||
Button buttonDate;
|
|
||||||
Button buttonZoom;
|
|
||||||
GraphView bgGraph;
|
|
||||||
GraphView iobGraph;
|
|
||||||
SeekBar seekBar;
|
|
||||||
TextView noProfile;
|
|
||||||
TextView iobCalculationProgressView;
|
|
||||||
|
|
||||||
private int rangeToDisplay = 24; // for graph
|
|
||||||
private long start = 0;
|
|
||||||
|
|
||||||
|
|
||||||
EventCustomCalculationFinished eventCustomCalculationFinished = new EventCustomCalculationFinished();
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
setContentView(R.layout.activity_historybrowse);
|
|
||||||
|
|
||||||
buttonDate = findViewById(R.id.historybrowse_date);
|
|
||||||
buttonZoom = findViewById(R.id.historybrowse_zoom);
|
|
||||||
bgGraph = findViewById(R.id.historyybrowse_bggraph);
|
|
||||||
iobGraph = findViewById(R.id.historybrowse_iobgraph);
|
|
||||||
seekBar = findViewById(R.id.historybrowse_seekBar);
|
|
||||||
noProfile = findViewById(R.id.historybrowse_noprofile);
|
|
||||||
iobCalculationProgressView = findViewById(R.id.overview_iobcalculationprogess);
|
|
||||||
|
|
||||||
findViewById(R.id.historybrowse_left).setOnClickListener(v -> {
|
|
||||||
start -= T.hours(rangeToDisplay).msecs();
|
|
||||||
updateGUI("onClickLeft");
|
|
||||||
runCalculation("onClickLeft");
|
|
||||||
});
|
|
||||||
|
|
||||||
findViewById(R.id.historybrowse_right).setOnClickListener(v -> {
|
|
||||||
start += T.hours(rangeToDisplay).msecs();
|
|
||||||
updateGUI("onClickRight");
|
|
||||||
runCalculation("onClickRight");
|
|
||||||
});
|
|
||||||
|
|
||||||
findViewById(R.id.historybrowse_end).setOnClickListener(v -> {
|
|
||||||
Calendar calendar = Calendar.getInstance();
|
|
||||||
calendar.setTimeInMillis(System.currentTimeMillis());
|
|
||||||
calendar.set(Calendar.MILLISECOND, 0);
|
|
||||||
calendar.set(Calendar.SECOND, 0);
|
|
||||||
calendar.set(Calendar.MINUTE, 0);
|
|
||||||
calendar.set(Calendar.HOUR_OF_DAY, 0);
|
|
||||||
start = calendar.getTimeInMillis();
|
|
||||||
updateGUI("onClickEnd");
|
|
||||||
runCalculation("onClickEnd");
|
|
||||||
});
|
|
||||||
|
|
||||||
findViewById(R.id.historybrowse_zoom).setOnClickListener(v -> {
|
|
||||||
rangeToDisplay += 6;
|
|
||||||
rangeToDisplay = rangeToDisplay > 24 ? 6 : rangeToDisplay;
|
|
||||||
updateGUI("rangeChange");
|
|
||||||
});
|
|
||||||
|
|
||||||
findViewById(R.id.historybrowse_zoom).setOnLongClickListener(v -> {
|
|
||||||
Calendar calendar = Calendar.getInstance();
|
|
||||||
calendar.setTimeInMillis(start);
|
|
||||||
calendar.set(Calendar.MILLISECOND, 0);
|
|
||||||
calendar.set(Calendar.SECOND, 0);
|
|
||||||
calendar.set(Calendar.MINUTE, 0);
|
|
||||||
calendar.set(Calendar.HOUR_OF_DAY, 0);
|
|
||||||
start = calendar.getTimeInMillis();
|
|
||||||
updateGUI("resetToMidnight");
|
|
||||||
runCalculation("onLongClickZoom");
|
|
||||||
return true;
|
|
||||||
});
|
|
||||||
|
|
||||||
findViewById(R.id.historybrowse_date).setOnClickListener(v -> {
|
|
||||||
Calendar calendar = Calendar.getInstance();
|
|
||||||
calendar.setTime(new Date(start));
|
|
||||||
DatePickerDialog dpd = DatePickerDialog.newInstance(
|
|
||||||
(view, year, monthOfYear, dayOfMonth) -> {
|
|
||||||
Date date = new Date(0);
|
|
||||||
date.setYear(year - 1900);
|
|
||||||
date.setMonth(monthOfYear);
|
|
||||||
date.setDate(dayOfMonth);
|
|
||||||
date.setHours(0);
|
|
||||||
start = date.getTime();
|
|
||||||
updateGUI("onClickDate");
|
|
||||||
runCalculation("onClickDate");
|
|
||||||
},
|
|
||||||
calendar.get(Calendar.YEAR),
|
|
||||||
calendar.get(Calendar.MONTH),
|
|
||||||
calendar.get(Calendar.DAY_OF_MONTH)
|
|
||||||
);
|
|
||||||
dpd.setThemeDark(true);
|
|
||||||
dpd.dismissOnPause(true);
|
|
||||||
dpd.show(getSupportFragmentManager(), "Datepickerdialog");
|
|
||||||
});
|
|
||||||
|
|
||||||
bgGraph.getGridLabelRenderer().setGridColor(resourceHelper.gc(R.color.graphgrid));
|
|
||||||
bgGraph.getGridLabelRenderer().reloadStyles();
|
|
||||||
iobGraph.getGridLabelRenderer().setGridColor(resourceHelper.gc(R.color.graphgrid));
|
|
||||||
iobGraph.getGridLabelRenderer().reloadStyles();
|
|
||||||
iobGraph.getGridLabelRenderer().setHorizontalLabelsVisible(false);
|
|
||||||
bgGraph.getGridLabelRenderer().setLabelVerticalWidth(50);
|
|
||||||
iobGraph.getGridLabelRenderer().setLabelVerticalWidth(50);
|
|
||||||
iobGraph.getGridLabelRenderer().setNumVerticalLabels(5);
|
|
||||||
|
|
||||||
overviewMenus.setupChartMenu(findViewById(R.id.overview_chartMenuButton));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onPause() {
|
|
||||||
super.onPause();
|
|
||||||
disposable.clear();
|
|
||||||
iobCobStaticCalculatorPlugin.stopCalculation("onPause");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onResume() {
|
|
||||||
super.onResume();
|
|
||||||
disposable.add(rxBus
|
|
||||||
.toObservable(EventAutosensCalculationFinished.class)
|
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
|
||||||
.subscribe(event -> {
|
|
||||||
if (event.getCause() == eventCustomCalculationFinished) {
|
|
||||||
aapsLogger.debug(LTag.AUTOSENS, "EventAutosensCalculationFinished");
|
|
||||||
synchronized (HistoryBrowseActivity.this) {
|
|
||||||
updateGUI("EventAutosensCalculationFinished");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, fabricPrivacy::logException)
|
|
||||||
);
|
|
||||||
disposable.add(rxBus
|
|
||||||
.toObservable(EventIobCalculationProgress.class)
|
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
|
||||||
.subscribe(event -> {
|
|
||||||
if (iobCalculationProgressView != null)
|
|
||||||
iobCalculationProgressView.setText(event.getProgress());
|
|
||||||
}, exception -> fabricPrivacy.logException(exception))
|
|
||||||
);
|
|
||||||
disposable.add(rxBus
|
|
||||||
.toObservable(EventRefreshOverview.class)
|
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
|
||||||
.subscribe(event -> updateGUI("EventRefreshOverview") , fabricPrivacy::logException)
|
|
||||||
);
|
|
||||||
// set start of current day
|
|
||||||
Calendar calendar = Calendar.getInstance();
|
|
||||||
calendar.setTimeInMillis(System.currentTimeMillis());
|
|
||||||
calendar.set(Calendar.MILLISECOND, 0);
|
|
||||||
calendar.set(Calendar.SECOND, 0);
|
|
||||||
calendar.set(Calendar.MINUTE, 0);
|
|
||||||
calendar.set(Calendar.HOUR_OF_DAY, 0);
|
|
||||||
start = calendar.getTimeInMillis();
|
|
||||||
runCalculation("onResume");
|
|
||||||
SystemClock.sleep(1000);
|
|
||||||
updateGUI("onResume");
|
|
||||||
}
|
|
||||||
|
|
||||||
private void runCalculation(String from) {
|
|
||||||
long end = start + T.hours(rangeToDisplay).msecs();
|
|
||||||
iobCobStaticCalculatorPlugin.stopCalculation(from);
|
|
||||||
iobCobStaticCalculatorPlugin.clearCache();
|
|
||||||
iobCobStaticCalculatorPlugin.runCalculation(from, end, true, false, eventCustomCalculationFinished);
|
|
||||||
}
|
|
||||||
|
|
||||||
void updateGUI(String from) {
|
|
||||||
aapsLogger.debug(LTag.UI, "updateGUI from: " + from);
|
|
||||||
|
|
||||||
if (noProfile == null || buttonDate == null || buttonZoom == null || bgGraph == null || iobGraph == null || seekBar == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
final PumpInterface pump = activePlugin.getActivePump();
|
|
||||||
final Profile profile = profileFunction.getProfile();
|
|
||||||
|
|
||||||
if (profile == null) {
|
|
||||||
noProfile.setVisibility(View.VISIBLE);
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
noProfile.setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
|
|
||||||
final double lowLine = defaultValueHelper.determineLowLine();
|
|
||||||
final double highLine = defaultValueHelper.determineHighLine();
|
|
||||||
|
|
||||||
buttonDate.setText(DateUtil.dateAndTimeString(start));
|
|
||||||
buttonZoom.setText(String.valueOf(rangeToDisplay));
|
|
||||||
|
|
||||||
final boolean showPrediction = false;
|
|
||||||
|
|
||||||
showBasal = sp.getBoolean("hist_showbasals", true);
|
|
||||||
showIob = sp.getBoolean("hist_showiob", true);
|
|
||||||
showCob = sp.getBoolean("hist_showcob", true);
|
|
||||||
showDev = sp.getBoolean("hist_showdeviations", false);
|
|
||||||
showRat = sp.getBoolean("hist_showratios", false);
|
|
||||||
showActPrim = sp.getBoolean("hist_showactivityprimary", false);
|
|
||||||
showActSec = sp.getBoolean("hist_showactivitysecondary", false);
|
|
||||||
showDevslope = sp.getBoolean("hist_showdevslope", false);
|
|
||||||
|
|
||||||
//int hoursToFetch;
|
|
||||||
final long toTime;
|
|
||||||
final long fromTime;
|
|
||||||
//if (showPrediction) {
|
|
||||||
//int predHours = (int) (Math.ceil(((DetermineBasalResultAMA) finalLastRun.constraintsProcessed).getLatestPredictionsTime() - System.currentTimeMillis()) / (60 * 60 * 1000));
|
|
||||||
//predHours = Math.min(2, predHours);
|
|
||||||
//predHours = Math.max(0, predHours);
|
|
||||||
//hoursToFetch = rangeToDisplay - predHours;
|
|
||||||
//toTime = calendar.getTimeInMillis() + 100000; // little bit more to avoid wrong rounding - Graphview specific
|
|
||||||
//fromTime = toTime - hoursToFetch * 60 * 60 * 1000L;
|
|
||||||
//endTime = toTime + predHours * 60 * 60 * 1000L;
|
|
||||||
//} else {
|
|
||||||
fromTime = start + T.secs(100).msecs();
|
|
||||||
toTime = start + T.hours(rangeToDisplay).msecs();
|
|
||||||
//}
|
|
||||||
|
|
||||||
aapsLogger.debug(LTag.UI, "Period: " + DateUtil.dateAndTimeString(fromTime) + " - " + DateUtil.dateAndTimeString(toTime));
|
|
||||||
|
|
||||||
final long pointer = System.currentTimeMillis();
|
|
||||||
|
|
||||||
// ------------------ 1st graph
|
|
||||||
|
|
||||||
final GraphData graphData = new GraphData(injector, bgGraph, iobCobStaticCalculatorPlugin);
|
|
||||||
|
|
||||||
// **** In range Area ****
|
|
||||||
graphData.addInRangeArea(fromTime, toTime, lowLine, highLine);
|
|
||||||
|
|
||||||
// **** BG ****
|
|
||||||
if (showPrediction)
|
|
||||||
//graphData.addBgReadings(fromTime, toTime, lowLine, highLine, (DetermineBasalResultAMA) finalLastRun.constraintsProcessed);
|
|
||||||
;
|
|
||||||
else
|
|
||||||
graphData.addBgReadings(fromTime, toTime, lowLine, highLine, null);
|
|
||||||
|
|
||||||
// set manual x bounds to have nice steps
|
|
||||||
graphData.formatAxis(fromTime, toTime);
|
|
||||||
|
|
||||||
if (showActPrim) {
|
|
||||||
graphData.addActivity(fromTime, toTime, false, 1d);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Treatments
|
|
||||||
graphData.addTreatments(fromTime, toTime);
|
|
||||||
|
|
||||||
// add basal data
|
|
||||||
if (pump.getPumpDescription().isTempBasalCapable && showBasal) {
|
|
||||||
graphData.addBasals(fromTime, toTime, lowLine / graphData.getMaxY() / 1.2d);
|
|
||||||
}
|
|
||||||
|
|
||||||
// **** NOW line ****
|
|
||||||
graphData.addNowLine(pointer);
|
|
||||||
|
|
||||||
// ------------------ 2nd graph
|
|
||||||
|
|
||||||
new Thread(() -> {
|
|
||||||
final GraphData secondGraphData = new GraphData(injector, iobGraph, iobCobStaticCalculatorPlugin);
|
|
||||||
|
|
||||||
boolean useIobForScale = false;
|
|
||||||
boolean useCobForScale = false;
|
|
||||||
boolean useDevForScale = false;
|
|
||||||
boolean useRatioForScale = false;
|
|
||||||
boolean useIAForScale = false;
|
|
||||||
boolean useDSForScale = false;
|
|
||||||
|
|
||||||
if (showIob) {
|
|
||||||
useIobForScale = true;
|
|
||||||
} else if (showCob) {
|
|
||||||
useCobForScale = true;
|
|
||||||
} else if (showDev) {
|
|
||||||
useDevForScale = true;
|
|
||||||
} else if (showRat) {
|
|
||||||
useRatioForScale = true;
|
|
||||||
} else if (showActSec) {
|
|
||||||
useIAForScale = true;
|
|
||||||
} else if (showDevslope) {
|
|
||||||
useDSForScale = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (showIob)
|
|
||||||
secondGraphData.addIob(fromTime, toTime, useIobForScale, 1d, showPrediction);
|
|
||||||
if (showCob)
|
|
||||||
secondGraphData.addCob(fromTime, toTime, useCobForScale, useCobForScale ? 1d : 0.5d);
|
|
||||||
if (showDev)
|
|
||||||
secondGraphData.addDeviations(fromTime, toTime, useDevForScale, 1d);
|
|
||||||
if (showRat)
|
|
||||||
secondGraphData.addRatio(fromTime, toTime, useRatioForScale, 1d);
|
|
||||||
if (showActSec)
|
|
||||||
secondGraphData.addActivity(fromTime, toTime, useIAForScale, useIAForScale ? 2d : 1d);
|
|
||||||
if (showDevslope)
|
|
||||||
secondGraphData.addDeviationSlope(fromTime, toTime, useDSForScale, 1d);
|
|
||||||
|
|
||||||
// **** NOW line ****
|
|
||||||
// set manual x bounds to have nice steps
|
|
||||||
secondGraphData.formatAxis(fromTime, toTime);
|
|
||||||
secondGraphData.addNowLine(pointer);
|
|
||||||
|
|
||||||
// do GUI update
|
|
||||||
runOnUiThread(() -> {
|
|
||||||
if (showIob || showCob || showDev || showRat || showActSec || showDevslope) {
|
|
||||||
iobGraph.setVisibility(View.VISIBLE);
|
|
||||||
} else {
|
|
||||||
iobGraph.setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
// finally enforce drawing of graphs
|
|
||||||
graphData.performUpdate();
|
|
||||||
if (showIob || showCob || showDev || showRat || showActSec || showDevslope)
|
|
||||||
secondGraphData.performUpdate();
|
|
||||||
});
|
|
||||||
}).start();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,330 @@
|
||||||
|
package info.nightscout.androidaps.historyBrowser
|
||||||
|
|
||||||
|
import android.app.DatePickerDialog
|
||||||
|
import android.graphics.Color
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.os.SystemClock
|
||||||
|
import android.util.DisplayMetrics
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import android.widget.LinearLayout
|
||||||
|
import android.widget.TextView
|
||||||
|
import com.jjoe64.graphview.GraphView
|
||||||
|
import dagger.android.HasAndroidInjector
|
||||||
|
import info.nightscout.androidaps.R
|
||||||
|
import info.nightscout.androidaps.activities.NoSplashAppCompatActivity
|
||||||
|
import info.nightscout.androidaps.events.EventCustomCalculationFinished
|
||||||
|
import info.nightscout.androidaps.events.EventRefreshOverview
|
||||||
|
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
||||||
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
|
import info.nightscout.androidaps.logging.LTag
|
||||||
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
|
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction
|
||||||
|
import info.nightscout.androidaps.plugins.general.overview.OverviewMenus
|
||||||
|
import info.nightscout.androidaps.plugins.general.overview.graphData.GraphData
|
||||||
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventAutosensCalculationFinished
|
||||||
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventIobCalculationProgress
|
||||||
|
import info.nightscout.androidaps.utils.DateUtil
|
||||||
|
import info.nightscout.androidaps.utils.DefaultValueHelper
|
||||||
|
import info.nightscout.androidaps.utils.FabricPrivacy
|
||||||
|
import info.nightscout.androidaps.utils.T
|
||||||
|
import info.nightscout.androidaps.utils.buildHelper.BuildHelper
|
||||||
|
import info.nightscout.androidaps.utils.extensions.toVisibility
|
||||||
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
|
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||||
|
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||||
|
import io.reactivex.disposables.CompositeDisposable
|
||||||
|
import kotlinx.android.synthetic.main.activity_historybrowse.*
|
||||||
|
import kotlinx.coroutines.Dispatchers
|
||||||
|
import kotlinx.coroutines.GlobalScope
|
||||||
|
import kotlinx.coroutines.launch
|
||||||
|
import kotlinx.coroutines.withContext
|
||||||
|
import java.util.*
|
||||||
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
class HistoryBrowseActivity : NoSplashAppCompatActivity() {
|
||||||
|
@Inject lateinit var injector: HasAndroidInjector
|
||||||
|
@Inject lateinit var aapsLogger: AAPSLogger
|
||||||
|
@Inject lateinit var rxBus: RxBusWrapper
|
||||||
|
@Inject lateinit var sp: SP
|
||||||
|
@Inject lateinit var resourceHelper: ResourceHelper
|
||||||
|
@Inject lateinit var profileFunction: ProfileFunction
|
||||||
|
@Inject lateinit var defaultValueHelper: DefaultValueHelper
|
||||||
|
@Inject lateinit var iobCobStaticCalculatorPlugin: IobCobStaticCalculatorPlugin
|
||||||
|
@Inject lateinit var activePlugin: ActivePluginProvider
|
||||||
|
@Inject lateinit var buildHelper: BuildHelper
|
||||||
|
@Inject lateinit var fabricPrivacy: FabricPrivacy
|
||||||
|
@Inject lateinit var overviewMenus: OverviewMenus
|
||||||
|
|
||||||
|
private val disposable = CompositeDisposable()
|
||||||
|
|
||||||
|
private val secondaryGraphs = ArrayList<GraphView>()
|
||||||
|
private val secondaryGraphsLabel = ArrayList<TextView>()
|
||||||
|
|
||||||
|
private var axisWidth: Int = 0
|
||||||
|
private var rangeToDisplay = 24 // for graph
|
||||||
|
private var start: Long = 0
|
||||||
|
|
||||||
|
private var eventCustomCalculationFinished = EventCustomCalculationFinished()
|
||||||
|
|
||||||
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
super.onCreate(savedInstanceState)
|
||||||
|
setContentView(R.layout.activity_historybrowse)
|
||||||
|
|
||||||
|
historybrowse_left.setOnClickListener {
|
||||||
|
start -= T.hours(rangeToDisplay.toLong()).msecs()
|
||||||
|
updateGUI("onClickLeft")
|
||||||
|
runCalculation("onClickLeft")
|
||||||
|
}
|
||||||
|
historybrowse_right.setOnClickListener {
|
||||||
|
start += T.hours(rangeToDisplay.toLong()).msecs()
|
||||||
|
updateGUI("onClickRight")
|
||||||
|
runCalculation("onClickRight")
|
||||||
|
}
|
||||||
|
historybrowse_end.setOnClickListener {
|
||||||
|
val calendar = Calendar.getInstance()
|
||||||
|
calendar.timeInMillis = System.currentTimeMillis()
|
||||||
|
calendar[Calendar.MILLISECOND] = 0
|
||||||
|
calendar[Calendar.SECOND] = 0
|
||||||
|
calendar[Calendar.MINUTE] = 0
|
||||||
|
calendar[Calendar.HOUR_OF_DAY] = 0
|
||||||
|
start = calendar.timeInMillis
|
||||||
|
updateGUI("onClickEnd")
|
||||||
|
runCalculation("onClickEnd")
|
||||||
|
}
|
||||||
|
historybrowse_zoom.setOnClickListener {
|
||||||
|
rangeToDisplay += 6
|
||||||
|
rangeToDisplay = if (rangeToDisplay > 24) 6 else rangeToDisplay
|
||||||
|
updateGUI("rangeChange")
|
||||||
|
}
|
||||||
|
historybrowse_zoom.setOnLongClickListener {
|
||||||
|
val calendar = Calendar.getInstance()
|
||||||
|
calendar.timeInMillis = start
|
||||||
|
calendar[Calendar.MILLISECOND] = 0
|
||||||
|
calendar[Calendar.SECOND] = 0
|
||||||
|
calendar[Calendar.MINUTE] = 0
|
||||||
|
calendar[Calendar.HOUR_OF_DAY] = 0
|
||||||
|
start = calendar.timeInMillis
|
||||||
|
updateGUI("resetToMidnight")
|
||||||
|
runCalculation("onLongClickZoom")
|
||||||
|
true
|
||||||
|
}
|
||||||
|
|
||||||
|
// create an OnDateSetListener
|
||||||
|
val dateSetListener = DatePickerDialog.OnDateSetListener { _, year, monthOfYear, dayOfMonth ->
|
||||||
|
val cal = Calendar.getInstance()
|
||||||
|
cal.timeInMillis = start
|
||||||
|
cal.set(Calendar.YEAR, year)
|
||||||
|
cal.set(Calendar.MONTH, monthOfYear)
|
||||||
|
cal.set(Calendar.DAY_OF_MONTH, dayOfMonth)
|
||||||
|
start = cal.timeInMillis
|
||||||
|
historybrowse_date?.text = DateUtil.dateAndTimeString(start)
|
||||||
|
updateGUI("onClickDate")
|
||||||
|
runCalculation("onClickDate")
|
||||||
|
}
|
||||||
|
|
||||||
|
historybrowse_date.setOnClickListener {
|
||||||
|
val cal = Calendar.getInstance()
|
||||||
|
cal.timeInMillis = start
|
||||||
|
DatePickerDialog(this, dateSetListener,
|
||||||
|
cal.get(Calendar.YEAR),
|
||||||
|
cal.get(Calendar.MONTH),
|
||||||
|
cal.get(Calendar.DAY_OF_MONTH)
|
||||||
|
).show()
|
||||||
|
}
|
||||||
|
|
||||||
|
val dm = DisplayMetrics()
|
||||||
|
windowManager?.defaultDisplay?.getMetrics(dm)
|
||||||
|
|
||||||
|
axisWidth = if (dm.densityDpi <= 120) 3 else if (dm.densityDpi <= 160) 10 else if (dm.densityDpi <= 320) 35 else if (dm.densityDpi <= 420) 50 else if (dm.densityDpi <= 560) 70 else 80
|
||||||
|
historybrowse_bggraph?.gridLabelRenderer?.gridColor = resourceHelper.gc(R.color.graphgrid)
|
||||||
|
historybrowse_bggraph?.gridLabelRenderer?.reloadStyles()
|
||||||
|
historybrowse_bggraph?.gridLabelRenderer?.labelVerticalWidth = axisWidth
|
||||||
|
|
||||||
|
overviewMenus.setupChartMenu(overview_chartMenuButton)
|
||||||
|
prepareGraphs()
|
||||||
|
}
|
||||||
|
|
||||||
|
public override fun onPause() {
|
||||||
|
super.onPause()
|
||||||
|
disposable.clear()
|
||||||
|
iobCobStaticCalculatorPlugin.stopCalculation("onPause")
|
||||||
|
}
|
||||||
|
|
||||||
|
public override fun onResume() {
|
||||||
|
super.onResume()
|
||||||
|
disposable.add(rxBus
|
||||||
|
.toObservable(EventAutosensCalculationFinished::class.java)
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe({ event: EventAutosensCalculationFinished ->
|
||||||
|
// catch only events from iobCobStaticCalculatorPlugin
|
||||||
|
if (event.cause === eventCustomCalculationFinished) {
|
||||||
|
aapsLogger.debug(LTag.AUTOSENS, "EventAutosensCalculationFinished")
|
||||||
|
updateGUI("EventAutosensCalculationFinished")
|
||||||
|
}
|
||||||
|
}) { fabricPrivacy::logException }
|
||||||
|
)
|
||||||
|
disposable.add(rxBus
|
||||||
|
.toObservable(EventIobCalculationProgress::class.java)
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe({ overview_iobcalculationprogess?.text = it.progress }) { fabricPrivacy::logException }
|
||||||
|
)
|
||||||
|
disposable.add(rxBus
|
||||||
|
.toObservable(EventRefreshOverview::class.java)
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe({
|
||||||
|
prepareGraphs()
|
||||||
|
updateGUI("EventRefreshOverview")
|
||||||
|
}) { fabricPrivacy::logException }
|
||||||
|
)
|
||||||
|
// set start of current day
|
||||||
|
val calendar = Calendar.getInstance()
|
||||||
|
calendar.timeInMillis = System.currentTimeMillis()
|
||||||
|
calendar[Calendar.MILLISECOND] = 0
|
||||||
|
calendar[Calendar.SECOND] = 0
|
||||||
|
calendar[Calendar.MINUTE] = 0
|
||||||
|
calendar[Calendar.HOUR_OF_DAY] = 0
|
||||||
|
start = calendar.timeInMillis
|
||||||
|
runCalculation("onResume")
|
||||||
|
SystemClock.sleep(1000)
|
||||||
|
updateGUI("onResume")
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun prepareGraphs() {
|
||||||
|
val numOfGraphs = overviewMenus.setting.size
|
||||||
|
|
||||||
|
if (numOfGraphs != secondaryGraphs.size - 1) {
|
||||||
|
//aapsLogger.debug("New secondary graph count ${numOfGraphs-1}")
|
||||||
|
// rebuild needed
|
||||||
|
secondaryGraphs.clear()
|
||||||
|
secondaryGraphsLabel.clear()
|
||||||
|
history_iobgraph.removeAllViews()
|
||||||
|
for (i in 1 until numOfGraphs) {
|
||||||
|
val label = TextView(this)
|
||||||
|
label.layoutParams = LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT).also { it.setMargins(100, 0, 0, -50) }
|
||||||
|
history_iobgraph.addView(label)
|
||||||
|
secondaryGraphsLabel.add(label)
|
||||||
|
val graph = GraphView(this)
|
||||||
|
graph.layoutParams = LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, resourceHelper.dpToPx(100)).also { it.setMargins(0, 0, 0, resourceHelper.dpToPx(10)) }
|
||||||
|
graph.gridLabelRenderer?.gridColor = resourceHelper.gc(R.color.graphgrid)
|
||||||
|
graph.gridLabelRenderer?.reloadStyles()
|
||||||
|
graph.gridLabelRenderer?.isHorizontalLabelsVisible = false
|
||||||
|
graph.gridLabelRenderer?.labelVerticalWidth = axisWidth
|
||||||
|
graph.gridLabelRenderer?.numVerticalLabels = 3
|
||||||
|
graph.viewport.backgroundColor = Color.argb(20, 255, 255, 255) // 8% of gray
|
||||||
|
history_iobgraph.addView(graph)
|
||||||
|
secondaryGraphs.add(graph)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun runCalculation(from: String) {
|
||||||
|
val end = start + T.hours(rangeToDisplay.toLong()).msecs()
|
||||||
|
iobCobStaticCalculatorPlugin.stopCalculation(from)
|
||||||
|
iobCobStaticCalculatorPlugin.clearCache()
|
||||||
|
iobCobStaticCalculatorPlugin.runCalculation(from, end, true, false, eventCustomCalculationFinished)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Synchronized
|
||||||
|
fun updateGUI(from: String) {
|
||||||
|
aapsLogger.debug(LTag.UI, "updateGUI from: $from")
|
||||||
|
val pump = activePlugin.activePump
|
||||||
|
val profile = profileFunction.getProfile()
|
||||||
|
|
||||||
|
historybrowse_noprofile?.visibility = (profile == null).toVisibility()
|
||||||
|
profile ?: return
|
||||||
|
|
||||||
|
val lowLine = defaultValueHelper.determineLowLine()
|
||||||
|
val highLine = defaultValueHelper.determineHighLine()
|
||||||
|
historybrowse_date?.text = DateUtil.dateAndTimeString(start)
|
||||||
|
historybrowse_zoom?.text = rangeToDisplay.toString()
|
||||||
|
|
||||||
|
GlobalScope.launch(Dispatchers.Main) {
|
||||||
|
historybrowse_bggraph ?: return@launch
|
||||||
|
val graphData = GraphData(injector, historybrowse_bggraph, iobCobStaticCalculatorPlugin)
|
||||||
|
val secondaryGraphsData: ArrayList<GraphData> = ArrayList()
|
||||||
|
|
||||||
|
// do preparation in different thread
|
||||||
|
withContext(Dispatchers.Default) {
|
||||||
|
val fromTime: Long = start + T.secs(100).msecs()
|
||||||
|
val toTime: Long = start + T.hours(rangeToDisplay.toLong()).msecs()
|
||||||
|
aapsLogger.debug(LTag.UI, "Period: " + DateUtil.dateAndTimeString(fromTime) + " - " + DateUtil.dateAndTimeString(toTime))
|
||||||
|
val pointer = System.currentTimeMillis()
|
||||||
|
|
||||||
|
// **** In range Area ****
|
||||||
|
graphData.addInRangeArea(fromTime, toTime, lowLine, highLine)
|
||||||
|
|
||||||
|
// **** BG ****
|
||||||
|
graphData.addBgReadings(fromTime, toTime, lowLine, highLine, null)
|
||||||
|
|
||||||
|
// set manual x bounds to have nice steps
|
||||||
|
graphData.formatAxis(fromTime, toTime)
|
||||||
|
|
||||||
|
// Treatments
|
||||||
|
graphData.addTreatments(fromTime, toTime)
|
||||||
|
if (overviewMenus.setting[0][OverviewMenus.CharType.ACT.ordinal])
|
||||||
|
graphData.addActivity(fromTime, toTime, false, 0.8)
|
||||||
|
|
||||||
|
// add basal data
|
||||||
|
if (pump.pumpDescription.isTempBasalCapable && overviewMenus.setting[0][OverviewMenus.CharType.BAS.ordinal]) {
|
||||||
|
graphData.addBasals(fromTime, toTime, lowLine / graphData.maxY / 1.2)
|
||||||
|
}
|
||||||
|
|
||||||
|
// add target line
|
||||||
|
graphData.addTargetLine(fromTime, toTime, profile, null)
|
||||||
|
|
||||||
|
// **** NOW line ****
|
||||||
|
graphData.addNowLine(pointer)
|
||||||
|
|
||||||
|
// ------------------ 2nd graph
|
||||||
|
for (g in 0 until secondaryGraphs.size) {
|
||||||
|
val secondGraphData = GraphData(injector, secondaryGraphs[g], iobCobStaticCalculatorPlugin)
|
||||||
|
var useIobForScale = false
|
||||||
|
var useCobForScale = false
|
||||||
|
var useDevForScale = false
|
||||||
|
var useRatioForScale = false
|
||||||
|
var useDSForScale = false
|
||||||
|
var useIAForScale = false
|
||||||
|
var useABSForScale = false
|
||||||
|
when {
|
||||||
|
overviewMenus.setting[g + 1][OverviewMenus.CharType.IOB.ordinal] -> useIobForScale = true
|
||||||
|
overviewMenus.setting[g + 1][OverviewMenus.CharType.COB.ordinal] -> useCobForScale = true
|
||||||
|
overviewMenus.setting[g + 1][OverviewMenus.CharType.DEV.ordinal] -> useDevForScale = true
|
||||||
|
overviewMenus.setting[g + 1][OverviewMenus.CharType.SEN.ordinal] -> useRatioForScale = true
|
||||||
|
overviewMenus.setting[g + 1][OverviewMenus.CharType.ACT.ordinal] -> useIAForScale = true
|
||||||
|
overviewMenus.setting[g + 1][OverviewMenus.CharType.ABS.ordinal] -> useABSForScale = true
|
||||||
|
overviewMenus.setting[g + 1][OverviewMenus.CharType.DEVSLOPE.ordinal] -> useDSForScale = true
|
||||||
|
}
|
||||||
|
|
||||||
|
if (overviewMenus.setting[g + 1][OverviewMenus.CharType.IOB.ordinal]) secondGraphData.addIob(fromTime, toTime, useIobForScale, 1.0, overviewMenus.setting[g + 1][OverviewMenus.CharType.PRE.ordinal])
|
||||||
|
if (overviewMenus.setting[g + 1][OverviewMenus.CharType.COB.ordinal]) secondGraphData.addCob(fromTime, toTime, useCobForScale, if (useCobForScale) 1.0 else 0.5)
|
||||||
|
if (overviewMenus.setting[g + 1][OverviewMenus.CharType.DEV.ordinal]) secondGraphData.addDeviations(fromTime, toTime, useDevForScale, 1.0)
|
||||||
|
if (overviewMenus.setting[g + 1][OverviewMenus.CharType.SEN.ordinal]) secondGraphData.addRatio(fromTime, toTime, useRatioForScale, 1.0)
|
||||||
|
if (overviewMenus.setting[g + 1][OverviewMenus.CharType.ACT.ordinal]) secondGraphData.addActivity(fromTime, toTime, useIAForScale, 0.8)
|
||||||
|
if (overviewMenus.setting[g + 1][OverviewMenus.CharType.ABS.ordinal]) secondGraphData.addAbsIob(fromTime, toTime, useABSForScale, 1.0)
|
||||||
|
if (overviewMenus.setting[g + 1][OverviewMenus.CharType.DEVSLOPE.ordinal] && buildHelper.isDev()) secondGraphData.addDeviationSlope(fromTime, toTime, useDSForScale, 1.0)
|
||||||
|
|
||||||
|
// set manual x bounds to have nice steps
|
||||||
|
secondGraphData.formatAxis(fromTime, toTime)
|
||||||
|
secondGraphData.addNowLine(pointer)
|
||||||
|
secondaryGraphsData.add(secondGraphData)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// finally enforce drawing of graphs in UI thread
|
||||||
|
graphData.performUpdate()
|
||||||
|
for (g in 0 until secondaryGraphs.size) {
|
||||||
|
secondaryGraphsLabel[g].text = overviewMenus.enabledTypes(g + 1)
|
||||||
|
secondaryGraphs[g].visibility = (
|
||||||
|
overviewMenus.setting[g + 1][OverviewMenus.CharType.IOB.ordinal] ||
|
||||||
|
overviewMenus.setting[g + 1][OverviewMenus.CharType.COB.ordinal] ||
|
||||||
|
overviewMenus.setting[g + 1][OverviewMenus.CharType.DEV.ordinal] ||
|
||||||
|
overviewMenus.setting[g + 1][OverviewMenus.CharType.SEN.ordinal] ||
|
||||||
|
overviewMenus.setting[g + 1][OverviewMenus.CharType.ACT.ordinal] ||
|
||||||
|
overviewMenus.setting[g + 1][OverviewMenus.CharType.ABS.ordinal] ||
|
||||||
|
overviewMenus.setting[g + 1][OverviewMenus.CharType.DEVSLOPE.ordinal]
|
||||||
|
).toVisibility()
|
||||||
|
secondaryGraphsData[g].performUpdate()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -744,7 +744,7 @@ public class LoopPlugin extends PluginBase {
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
getAapsLogger().error("Unhandled exception", e);
|
getAapsLogger().error("Unhandled exception", e);
|
||||||
}
|
}
|
||||||
CareportalEvent event = new CareportalEvent();
|
CareportalEvent event = new CareportalEvent(getInjector());
|
||||||
event.date = DateUtil.now();
|
event.date = DateUtil.now();
|
||||||
event.source = Source.USER;
|
event.source = Source.USER;
|
||||||
event.eventType = CareportalEvent.OPENAPSOFFLINE;
|
event.eventType = CareportalEvent.OPENAPSOFFLINE;
|
||||||
|
|
|
@ -1,344 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.configBuilder;
|
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
import androidx.annotation.Nullable;
|
|
||||||
import androidx.fragment.app.FragmentActivity;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
import javax.inject.Inject;
|
|
||||||
import javax.inject.Singleton;
|
|
||||||
|
|
||||||
import dagger.android.HasAndroidInjector;
|
|
||||||
import info.nightscout.androidaps.R;
|
|
||||||
import info.nightscout.androidaps.events.EventAppInitialized;
|
|
||||||
import info.nightscout.androidaps.events.EventConfigBuilderChange;
|
|
||||||
import info.nightscout.androidaps.events.EventRebuildTabs;
|
|
||||||
import info.nightscout.androidaps.interfaces.APSInterface;
|
|
||||||
import info.nightscout.androidaps.interfaces.ActivePluginProvider;
|
|
||||||
import info.nightscout.androidaps.interfaces.BgSourceInterface;
|
|
||||||
import info.nightscout.androidaps.interfaces.InsulinInterface;
|
|
||||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
|
||||||
import info.nightscout.androidaps.interfaces.PluginDescription;
|
|
||||||
import info.nightscout.androidaps.interfaces.PluginType;
|
|
||||||
import info.nightscout.androidaps.interfaces.ProfileInterface;
|
|
||||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
|
||||||
import info.nightscout.androidaps.interfaces.SensitivityInterface;
|
|
||||||
import info.nightscout.androidaps.interfaces.TreatmentsInterface;
|
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger;
|
|
||||||
import info.nightscout.androidaps.logging.LTag;
|
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper;
|
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.events.EventConfigBuilderUpdateGui;
|
|
||||||
import info.nightscout.androidaps.utils.alertDialogs.OKDialog;
|
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper;
|
|
||||||
import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by mike on 05.08.2016.
|
|
||||||
*/
|
|
||||||
@Singleton
|
|
||||||
public class ConfigBuilderPlugin extends PluginBase {
|
|
||||||
private static ConfigBuilderPlugin configBuilderPlugin;
|
|
||||||
|
|
||||||
private final ActivePluginProvider activePlugin;
|
|
||||||
private final SP sp;
|
|
||||||
private final AAPSLogger aapsLogger;
|
|
||||||
private final RxBusWrapper rxBus;
|
|
||||||
private final ResourceHelper resourceHelper;
|
|
||||||
private final ProfileFunction profileFunction;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Use dagger to get an instance
|
|
||||||
*/
|
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public ProfileFunction getProfileFunction() {
|
|
||||||
if (profileFunction == null)
|
|
||||||
throw new IllegalStateException("Accessing profileFunction before first instantiation");
|
|
||||||
return profileFunction;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
static public ConfigBuilderPlugin getPlugin() {
|
|
||||||
if (configBuilderPlugin == null)
|
|
||||||
throw new IllegalStateException("Accessing ConfigBuilder before first instantiation");
|
|
||||||
return configBuilderPlugin;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Written by Adrian:
|
|
||||||
* The ConfigBuilderPlugin.getPlugin() method is used at 333 places throughout the app.
|
|
||||||
* In order to make the transition to DI, while legacy code is still calling `getPlugin()`,
|
|
||||||
* I'd instantiate this plugin very very early on (first injected dependency in MainApp) and use
|
|
||||||
* Lazy dependencies in this constructor.
|
|
||||||
* */
|
|
||||||
@Inject
|
|
||||||
public ConfigBuilderPlugin(
|
|
||||||
ActivePluginProvider activePlugin,
|
|
||||||
HasAndroidInjector injector,
|
|
||||||
SP sp,
|
|
||||||
RxBusWrapper rxBus,
|
|
||||||
AAPSLogger aapsLogger,
|
|
||||||
ResourceHelper resourceHelper,
|
|
||||||
ProfileFunction profileFunction
|
|
||||||
) {
|
|
||||||
super(new PluginDescription()
|
|
||||||
.mainType(PluginType.GENERAL)
|
|
||||||
.fragmentClass(ConfigBuilderFragment.class.getName())
|
|
||||||
.showInList(true)
|
|
||||||
.alwaysEnabled(true)
|
|
||||||
.alwaysVisible(false)
|
|
||||||
.pluginName(R.string.configbuilder)
|
|
||||||
.shortName(R.string.configbuilder_shortname)
|
|
||||||
.description(R.string.description_config_builder),
|
|
||||||
aapsLogger, resourceHelper, injector
|
|
||||||
);
|
|
||||||
this.activePlugin = activePlugin;
|
|
||||||
this.sp = sp;
|
|
||||||
this.rxBus = rxBus;
|
|
||||||
this.aapsLogger = aapsLogger;
|
|
||||||
this.resourceHelper = resourceHelper;
|
|
||||||
this.profileFunction = profileFunction;
|
|
||||||
configBuilderPlugin = this; // TODO: only while transitioning to Dagger
|
|
||||||
}
|
|
||||||
|
|
||||||
public void initialize() {
|
|
||||||
upgradeSettings();
|
|
||||||
((PluginStore) activePlugin).loadDefaults();
|
|
||||||
loadSettings();
|
|
||||||
setAlwaysEnabledPluginsEnabled();
|
|
||||||
rxBus.send(new EventAppInitialized());
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setAlwaysEnabledPluginsEnabled() {
|
|
||||||
for (PluginBase plugin : activePlugin.getPluginsList()) {
|
|
||||||
if (plugin.getPluginDescription().alwaysEnabled)
|
|
||||||
plugin.setPluginEnabled(plugin.getType(), true);
|
|
||||||
}
|
|
||||||
storeSettings("setAlwaysEnabledPluginsEnabled");
|
|
||||||
}
|
|
||||||
|
|
||||||
public void storeSettings(String from) {
|
|
||||||
activePlugin.getPluginsList();
|
|
||||||
getAapsLogger().debug(LTag.CONFIGBUILDER, "Storing settings from: " + from);
|
|
||||||
|
|
||||||
activePlugin.verifySelectionInCategories();
|
|
||||||
|
|
||||||
for (PluginBase p : activePlugin.getPluginsList()) {
|
|
||||||
PluginType type = p.getType();
|
|
||||||
if (p.getPluginDescription().alwaysEnabled && p.getPluginDescription().alwaysVisible)
|
|
||||||
continue;
|
|
||||||
if (p.getPluginDescription().alwaysEnabled && p.getPluginDescription().neverVisible)
|
|
||||||
continue;
|
|
||||||
savePref(p, type, true);
|
|
||||||
if (type == PluginType.PUMP) {
|
|
||||||
if (p instanceof ProfileInterface) { // Store state of optional Profile interface
|
|
||||||
savePref(p, PluginType.PROFILE, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void savePref(PluginBase p, PluginType type, boolean storeVisible) {
|
|
||||||
String settingEnabled = "ConfigBuilder_" + type.name() + "_" + p.getClass().getSimpleName() + "_Enabled";
|
|
||||||
sp.putBoolean(settingEnabled, p.isEnabled(type));
|
|
||||||
getAapsLogger().debug(LTag.CONFIGBUILDER, "Storing: " + settingEnabled + ":" + p.isEnabled(type));
|
|
||||||
if (storeVisible) {
|
|
||||||
String settingVisible = "ConfigBuilder_" + type.name() + "_" + p.getClass().getSimpleName() + "_Visible";
|
|
||||||
sp.putBoolean(settingVisible, p.isFragmentVisible());
|
|
||||||
getAapsLogger().debug(LTag.CONFIGBUILDER, "Storing: " + settingVisible + ":" + p.isFragmentVisible());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void loadSettings() {
|
|
||||||
getAapsLogger().debug(LTag.CONFIGBUILDER, "Loading stored settings");
|
|
||||||
for (PluginBase p : activePlugin.getPluginsList()) {
|
|
||||||
PluginType type = p.getType();
|
|
||||||
loadPref(p, type, true);
|
|
||||||
if (p.getType() == PluginType.PUMP) {
|
|
||||||
if (p instanceof ProfileInterface) {
|
|
||||||
loadPref(p, PluginType.PROFILE, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
activePlugin.verifySelectionInCategories();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void loadPref(PluginBase p, PluginType type, boolean loadVisible) {
|
|
||||||
String settingEnabled = "ConfigBuilder_" + type.name() + "_" + p.getClass().getSimpleName() + "_Enabled";
|
|
||||||
if (sp.contains(settingEnabled))
|
|
||||||
p.setPluginEnabled(type, sp.getBoolean(settingEnabled, false));
|
|
||||||
else if (p.getType() == type && (p.getPluginDescription().enableByDefault || p.getPluginDescription().alwaysEnabled)) {
|
|
||||||
p.setPluginEnabled(type, true);
|
|
||||||
}
|
|
||||||
getAapsLogger().debug(LTag.CONFIGBUILDER, "Loaded: " + settingEnabled + ":" + p.isEnabled(type));
|
|
||||||
if (loadVisible) {
|
|
||||||
String settingVisible = "ConfigBuilder_" + type.name() + "_" + p.getClass().getSimpleName() + "_Visible";
|
|
||||||
if (sp.contains(settingVisible))
|
|
||||||
p.setFragmentVisible(type, sp.getBoolean(settingVisible, false) && sp.getBoolean(settingEnabled, false));
|
|
||||||
else if (p.getType() == type && p.getPluginDescription().visibleByDefault) {
|
|
||||||
p.setFragmentVisible(type, true);
|
|
||||||
}
|
|
||||||
getAapsLogger().debug(LTag.CONFIGBUILDER, "Loaded: " + settingVisible + ":" + p.isFragmentVisible());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Detect settings prior 1.60
|
|
||||||
private void upgradeSettings() {
|
|
||||||
if (!sp.contains("ConfigBuilder_1_NSProfilePlugin_Enabled"))
|
|
||||||
return;
|
|
||||||
getAapsLogger().debug(LTag.CONFIGBUILDER, "Upgrading stored settings");
|
|
||||||
for (PluginBase p : activePlugin.getPluginsList()) {
|
|
||||||
getAapsLogger().debug(LTag.CONFIGBUILDER, "Processing " + p.getName());
|
|
||||||
for (int type = 1; type < 11; type++) {
|
|
||||||
PluginType newType;
|
|
||||||
switch (type) {
|
|
||||||
case 1:
|
|
||||||
newType = PluginType.GENERAL;
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
newType = PluginType.TREATMENT;
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
newType = PluginType.SENSITIVITY;
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
newType = PluginType.PROFILE;
|
|
||||||
break;
|
|
||||||
case 5:
|
|
||||||
newType = PluginType.APS;
|
|
||||||
break;
|
|
||||||
case 6:
|
|
||||||
newType = PluginType.PUMP;
|
|
||||||
break;
|
|
||||||
case 7:
|
|
||||||
newType = PluginType.CONSTRAINTS;
|
|
||||||
break;
|
|
||||||
case 8:
|
|
||||||
newType = PluginType.LOOP;
|
|
||||||
break;
|
|
||||||
case 9:
|
|
||||||
newType = PluginType.BGSOURCE;
|
|
||||||
break;
|
|
||||||
case 10:
|
|
||||||
newType = PluginType.INSULIN;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
newType = PluginType.GENERAL;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
String settingEnabled = "ConfigBuilder_" + type + "_" + p.getClass().getSimpleName() + "_Enabled";
|
|
||||||
String settingVisible = "ConfigBuilder_" + type + "_" + p.getClass().getSimpleName() + "_Visible";
|
|
||||||
if (sp.contains(settingEnabled))
|
|
||||||
p.setPluginEnabled(newType, sp.getBoolean(settingEnabled, false));
|
|
||||||
if (sp.contains(settingVisible))
|
|
||||||
p.setFragmentVisible(newType, sp.getBoolean(settingVisible, false) && sp.getBoolean(settingEnabled, false));
|
|
||||||
sp.remove(settingEnabled);
|
|
||||||
sp.remove(settingVisible);
|
|
||||||
if (newType == p.getType()) {
|
|
||||||
savePref(p, newType, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void logPluginStatus() {
|
|
||||||
for (PluginBase p : activePlugin.getPluginsList()) {
|
|
||||||
getAapsLogger().debug(LTag.CONFIGBUILDER, p.getName() + ":" +
|
|
||||||
(p.isEnabled(PluginType.GENERAL) ? " GENERAL" : "") +
|
|
||||||
(p.isEnabled(PluginType.TREATMENT) ? " TREATMENT" : "") +
|
|
||||||
(p.isEnabled(PluginType.SENSITIVITY) ? " SENSITIVITY" : "") +
|
|
||||||
(p.isEnabled(PluginType.PROFILE) ? " PROFILE" : "") +
|
|
||||||
(p.isEnabled(PluginType.APS) ? " APS" : "") +
|
|
||||||
(p.isEnabled(PluginType.PUMP) ? " PUMP" : "") +
|
|
||||||
(p.isEnabled(PluginType.CONSTRAINTS) ? " CONSTRAINTS" : "") +
|
|
||||||
(p.isEnabled(PluginType.LOOP) ? " LOOP" : "") +
|
|
||||||
(p.isEnabled(PluginType.BGSOURCE) ? " BGSOURCE" : "") +
|
|
||||||
(p.isEnabled(PluginType.INSULIN) ? " INSULIN" : "")
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Ask when switching to physical pump plugin
|
|
||||||
public void switchAllowed(@NonNull PluginBase changedPlugin, boolean newState, @Nullable FragmentActivity activity, @NonNull PluginType type) {
|
|
||||||
if (changedPlugin.getType() == PluginType.PUMP && !changedPlugin.getName().equals(resourceHelper.gs(R.string.virtualpump)))
|
|
||||||
confirmPumpPluginActivation(changedPlugin, newState, activity, type);
|
|
||||||
else
|
|
||||||
performPluginSwitch(changedPlugin, newState, type);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void confirmPumpPluginActivation(@NonNull PluginBase changedPlugin, boolean newState, @Nullable FragmentActivity activity, @NonNull PluginType type) {
|
|
||||||
boolean allowHardwarePump = sp.getBoolean("allow_hardware_pump", false);
|
|
||||||
if (allowHardwarePump || activity == null) {
|
|
||||||
performPluginSwitch(changedPlugin, newState, type);
|
|
||||||
} else {
|
|
||||||
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.allow_hardware_pump_text), () -> {
|
|
||||||
performPluginSwitch(changedPlugin, newState, type);
|
|
||||||
sp.putBoolean("allow_hardware_pump", true);
|
|
||||||
aapsLogger.debug(LTag.PUMP, "First time HW pump allowed!");
|
|
||||||
}, () -> {
|
|
||||||
rxBus.send(new EventConfigBuilderUpdateGui());
|
|
||||||
aapsLogger.debug(LTag.PUMP, "User does not allow switching to HW pump!");
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void performPluginSwitch(PluginBase changedPlugin, boolean enabled, @NonNull PluginType type) {
|
|
||||||
changedPlugin.setPluginEnabled(type, enabled);
|
|
||||||
changedPlugin.setFragmentVisible(type, enabled);
|
|
||||||
processOnEnabledCategoryChanged(changedPlugin, type);
|
|
||||||
storeSettings("CheckedCheckboxEnabled");
|
|
||||||
rxBus.send(new EventRebuildTabs());
|
|
||||||
rxBus.send(new EventConfigBuilderChange());
|
|
||||||
rxBus.send(new EventConfigBuilderUpdateGui());
|
|
||||||
logPluginStatus();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void processOnEnabledCategoryChanged(PluginBase changedPlugin, PluginType type) {
|
|
||||||
ArrayList<PluginBase> pluginsInCategory = null;
|
|
||||||
switch (type) {
|
|
||||||
// Multiple selection allowed
|
|
||||||
case GENERAL:
|
|
||||||
case CONSTRAINTS:
|
|
||||||
case LOOP:
|
|
||||||
break;
|
|
||||||
// Single selection allowed
|
|
||||||
case INSULIN:
|
|
||||||
pluginsInCategory = activePlugin.getSpecificPluginsListByInterface(InsulinInterface.class);
|
|
||||||
break;
|
|
||||||
case SENSITIVITY:
|
|
||||||
pluginsInCategory = activePlugin.getSpecificPluginsListByInterface(SensitivityInterface.class);
|
|
||||||
break;
|
|
||||||
case APS:
|
|
||||||
pluginsInCategory = activePlugin.getSpecificPluginsListByInterface(APSInterface.class);
|
|
||||||
break;
|
|
||||||
case PROFILE:
|
|
||||||
pluginsInCategory = activePlugin.getSpecificPluginsListByInterface(ProfileInterface.class);
|
|
||||||
break;
|
|
||||||
case BGSOURCE:
|
|
||||||
pluginsInCategory = activePlugin.getSpecificPluginsListByInterface(BgSourceInterface.class);
|
|
||||||
break;
|
|
||||||
case TREATMENT:
|
|
||||||
pluginsInCategory = activePlugin.getSpecificPluginsListByInterface(TreatmentsInterface.class);
|
|
||||||
break;
|
|
||||||
case PUMP:
|
|
||||||
pluginsInCategory = activePlugin.getSpecificPluginsListByInterface(PumpInterface.class);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (pluginsInCategory != null) {
|
|
||||||
boolean newSelection = changedPlugin.isEnabled(type);
|
|
||||||
if (newSelection) { // new plugin selected -> disable others
|
|
||||||
for (PluginBase p : pluginsInCategory) {
|
|
||||||
if (p.getName().equals(changedPlugin.getName())) {
|
|
||||||
// this is new selected
|
|
||||||
} else {
|
|
||||||
p.setPluginEnabled(type, false);
|
|
||||||
p.setFragmentVisible(type, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else { // enable first plugin in list
|
|
||||||
pluginsInCategory.get(0).setPluginEnabled(type, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,191 @@
|
||||||
|
package info.nightscout.androidaps.plugins.configBuilder
|
||||||
|
|
||||||
|
import androidx.fragment.app.FragmentActivity
|
||||||
|
import dagger.android.HasAndroidInjector
|
||||||
|
import info.nightscout.androidaps.R
|
||||||
|
import info.nightscout.androidaps.events.EventAppInitialized
|
||||||
|
import info.nightscout.androidaps.events.EventConfigBuilderChange
|
||||||
|
import info.nightscout.androidaps.events.EventRebuildTabs
|
||||||
|
import info.nightscout.androidaps.interfaces.*
|
||||||
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
|
import info.nightscout.androidaps.logging.LTag
|
||||||
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
|
import info.nightscout.androidaps.plugins.configBuilder.events.EventConfigBuilderUpdateGui
|
||||||
|
import info.nightscout.androidaps.utils.alertDialogs.OKDialog.showConfirmation
|
||||||
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
|
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||||
|
import java.util.*
|
||||||
|
import javax.inject.Inject
|
||||||
|
import javax.inject.Singleton
|
||||||
|
|
||||||
|
@Singleton
|
||||||
|
class ConfigBuilderPlugin @Inject constructor(
|
||||||
|
injector: HasAndroidInjector,
|
||||||
|
aapsLogger: AAPSLogger,
|
||||||
|
resourceHelper: ResourceHelper,
|
||||||
|
private val sp: SP,
|
||||||
|
private val rxBus: RxBusWrapper,
|
||||||
|
private val activePlugin: ActivePluginProvider
|
||||||
|
) : PluginBase(PluginDescription()
|
||||||
|
.mainType(PluginType.GENERAL)
|
||||||
|
.fragmentClass(ConfigBuilderFragment::class.java.name)
|
||||||
|
.showInList(true)
|
||||||
|
.alwaysEnabled(true)
|
||||||
|
.alwaysVisible(false)
|
||||||
|
.pluginName(R.string.configbuilder)
|
||||||
|
.shortName(R.string.configbuilder_shortname)
|
||||||
|
.description(R.string.description_config_builder),
|
||||||
|
aapsLogger, resourceHelper, injector
|
||||||
|
) {
|
||||||
|
|
||||||
|
fun initialize() {
|
||||||
|
(activePlugin as PluginStore).loadDefaults()
|
||||||
|
loadSettings()
|
||||||
|
setAlwaysEnabledPluginsEnabled()
|
||||||
|
rxBus.send(EventAppInitialized())
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setAlwaysEnabledPluginsEnabled() {
|
||||||
|
for (plugin in activePlugin.pluginsList) {
|
||||||
|
if (plugin.pluginDescription.alwaysEnabled) plugin.setPluginEnabled(plugin.getType(), true)
|
||||||
|
}
|
||||||
|
storeSettings("setAlwaysEnabledPluginsEnabled")
|
||||||
|
}
|
||||||
|
|
||||||
|
fun storeSettings(from: String) {
|
||||||
|
activePlugin.pluginsList
|
||||||
|
aapsLogger.debug(LTag.CONFIGBUILDER, "Storing settings from: $from")
|
||||||
|
activePlugin.verifySelectionInCategories()
|
||||||
|
for (p in activePlugin.pluginsList) {
|
||||||
|
val type = p.getType()
|
||||||
|
if (p.pluginDescription.alwaysEnabled && p.pluginDescription.alwaysVisible) continue
|
||||||
|
if (p.pluginDescription.alwaysEnabled && p.pluginDescription.neverVisible) continue
|
||||||
|
savePref(p, type, true)
|
||||||
|
if (type == PluginType.PUMP) {
|
||||||
|
if (p is ProfileInterface) { // Store state of optional Profile interface
|
||||||
|
savePref(p, PluginType.PROFILE, false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun savePref(p: PluginBase, type: PluginType, storeVisible: Boolean) {
|
||||||
|
val settingEnabled = "ConfigBuilder_" + type.name + "_" + p.javaClass.simpleName + "_Enabled"
|
||||||
|
sp.putBoolean(settingEnabled, p.isEnabled(type))
|
||||||
|
aapsLogger.debug(LTag.CONFIGBUILDER, "Storing: " + settingEnabled + ":" + p.isEnabled(type))
|
||||||
|
if (storeVisible) {
|
||||||
|
val settingVisible = "ConfigBuilder_" + type.name + "_" + p.javaClass.simpleName + "_Visible"
|
||||||
|
sp.putBoolean(settingVisible, p.isFragmentVisible())
|
||||||
|
aapsLogger.debug(LTag.CONFIGBUILDER, "Storing: " + settingVisible + ":" + p.isFragmentVisible())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun loadSettings() {
|
||||||
|
aapsLogger.debug(LTag.CONFIGBUILDER, "Loading stored settings")
|
||||||
|
for (p in activePlugin.pluginsList) {
|
||||||
|
val type = p.getType()
|
||||||
|
loadPref(p, type, true)
|
||||||
|
if (p.getType() == PluginType.PUMP) {
|
||||||
|
if (p is ProfileInterface) {
|
||||||
|
loadPref(p, PluginType.PROFILE, false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
activePlugin.verifySelectionInCategories()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun loadPref(p: PluginBase, type: PluginType, loadVisible: Boolean) {
|
||||||
|
val settingEnabled = "ConfigBuilder_" + type.name + "_" + p.javaClass.simpleName + "_Enabled"
|
||||||
|
if (sp.contains(settingEnabled)) p.setPluginEnabled(type, sp.getBoolean(settingEnabled, false)) else if (p.getType() == type && (p.pluginDescription.enableByDefault || p.pluginDescription.alwaysEnabled)) {
|
||||||
|
p.setPluginEnabled(type, true)
|
||||||
|
}
|
||||||
|
aapsLogger.debug(LTag.CONFIGBUILDER, "Loaded: " + settingEnabled + ":" + p.isEnabled(type))
|
||||||
|
if (loadVisible) {
|
||||||
|
val settingVisible = "ConfigBuilder_" + type.name + "_" + p.javaClass.simpleName + "_Visible"
|
||||||
|
if (sp.contains(settingVisible)) p.setFragmentVisible(type, sp.getBoolean(settingVisible, false) && sp.getBoolean(settingEnabled, false)) else if (p.getType() == type && p.pluginDescription.visibleByDefault) {
|
||||||
|
p.setFragmentVisible(type, true)
|
||||||
|
}
|
||||||
|
aapsLogger.debug(LTag.CONFIGBUILDER, "Loaded: " + settingVisible + ":" + p.isFragmentVisible())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun logPluginStatus() {
|
||||||
|
for (p in activePlugin.pluginsList) {
|
||||||
|
aapsLogger.debug(LTag.CONFIGBUILDER, p.name + ":" +
|
||||||
|
(if (p.isEnabled(PluginType.GENERAL)) " GENERAL" else "") +
|
||||||
|
(if (p.isEnabled(PluginType.TREATMENT)) " TREATMENT" else "") +
|
||||||
|
(if (p.isEnabled(PluginType.SENSITIVITY)) " SENSITIVITY" else "") +
|
||||||
|
(if (p.isEnabled(PluginType.PROFILE)) " PROFILE" else "") +
|
||||||
|
(if (p.isEnabled(PluginType.APS)) " APS" else "") +
|
||||||
|
(if (p.isEnabled(PluginType.PUMP)) " PUMP" else "") +
|
||||||
|
(if (p.isEnabled(PluginType.CONSTRAINTS)) " CONSTRAINTS" else "") +
|
||||||
|
(if (p.isEnabled(PluginType.LOOP)) " LOOP" else "") +
|
||||||
|
(if (p.isEnabled(PluginType.BGSOURCE)) " BGSOURCE" else "") +
|
||||||
|
if (p.isEnabled(PluginType.INSULIN)) " INSULIN" else ""
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ask when switching to physical pump plugin
|
||||||
|
fun switchAllowed(changedPlugin: PluginBase, newState: Boolean, activity: FragmentActivity?, type: PluginType) {
|
||||||
|
if (changedPlugin.getType() == PluginType.PUMP && changedPlugin.name != resourceHelper.gs(R.string.virtualpump)) confirmPumpPluginActivation(changedPlugin, newState, activity, type) else performPluginSwitch(changedPlugin, newState, type)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun confirmPumpPluginActivation(changedPlugin: PluginBase, newState: Boolean, activity: FragmentActivity?, type: PluginType) {
|
||||||
|
val allowHardwarePump = sp.getBoolean("allow_hardware_pump", false)
|
||||||
|
if (allowHardwarePump || activity == null) {
|
||||||
|
performPluginSwitch(changedPlugin, newState, type)
|
||||||
|
} else {
|
||||||
|
showConfirmation(activity, resourceHelper.gs(R.string.allow_hardware_pump_text), Runnable {
|
||||||
|
performPluginSwitch(changedPlugin, newState, type)
|
||||||
|
sp.putBoolean("allow_hardware_pump", true)
|
||||||
|
aapsLogger.debug(LTag.PUMP, "First time HW pump allowed!")
|
||||||
|
}, Runnable {
|
||||||
|
rxBus.send(EventConfigBuilderUpdateGui())
|
||||||
|
aapsLogger.debug(LTag.PUMP, "User does not allow switching to HW pump!")
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun performPluginSwitch(changedPlugin: PluginBase, enabled: Boolean, type: PluginType) {
|
||||||
|
changedPlugin.setPluginEnabled(type, enabled)
|
||||||
|
changedPlugin.setFragmentVisible(type, enabled)
|
||||||
|
processOnEnabledCategoryChanged(changedPlugin, type)
|
||||||
|
storeSettings("CheckedCheckboxEnabled")
|
||||||
|
rxBus.send(EventRebuildTabs())
|
||||||
|
rxBus.send(EventConfigBuilderChange())
|
||||||
|
rxBus.send(EventConfigBuilderUpdateGui())
|
||||||
|
logPluginStatus()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun processOnEnabledCategoryChanged(changedPlugin: PluginBase, type: PluginType?) {
|
||||||
|
var pluginsInCategory: ArrayList<PluginBase>? = null
|
||||||
|
when (type) {
|
||||||
|
PluginType.INSULIN -> pluginsInCategory = activePlugin.getSpecificPluginsListByInterface(InsulinInterface::class.java)
|
||||||
|
PluginType.SENSITIVITY -> pluginsInCategory = activePlugin.getSpecificPluginsListByInterface(SensitivityInterface::class.java)
|
||||||
|
PluginType.APS -> pluginsInCategory = activePlugin.getSpecificPluginsListByInterface(APSInterface::class.java)
|
||||||
|
PluginType.PROFILE -> pluginsInCategory = activePlugin.getSpecificPluginsListByInterface(ProfileInterface::class.java)
|
||||||
|
PluginType.BGSOURCE -> pluginsInCategory = activePlugin.getSpecificPluginsListByInterface(BgSourceInterface::class.java)
|
||||||
|
PluginType.TREATMENT -> pluginsInCategory = activePlugin.getSpecificPluginsListByInterface(TreatmentsInterface::class.java)
|
||||||
|
PluginType.PUMP -> pluginsInCategory = activePlugin.getSpecificPluginsListByInterface(PumpInterface::class.java)
|
||||||
|
|
||||||
|
else -> {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (pluginsInCategory != null) {
|
||||||
|
val newSelection = changedPlugin.isEnabled(type!!)
|
||||||
|
if (newSelection) { // new plugin selected -> disable others
|
||||||
|
for (p in pluginsInCategory) {
|
||||||
|
if (p.name == changedPlugin.name) {
|
||||||
|
// this is new selected
|
||||||
|
} else {
|
||||||
|
p.setPluginEnabled(type, false)
|
||||||
|
p.setFragmentVisible(type, false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else { // enable first plugin in list
|
||||||
|
pluginsInCategory[0].setPluginEnabled(type, true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -86,10 +86,10 @@ class ProfileFunctionImplementation @Inject constructor(
|
||||||
}
|
}
|
||||||
if (activeTreatments.profileSwitchesFromHistory.size() > 0) {
|
if (activeTreatments.profileSwitchesFromHistory.size() > 0) {
|
||||||
val bundle = Bundle()
|
val bundle = Bundle()
|
||||||
bundle.putString(FirebaseAnalytics.Param.ITEM_ID, "CatchedError")
|
bundle.putString(FirebaseAnalytics.Param.ITEM_LIST_ID, "CatchedError")
|
||||||
bundle.putString(FirebaseAnalytics.Param.ITEM_CATEGORY, BuildConfig.BUILDVERSION)
|
bundle.putString(FirebaseAnalytics.Param.ITEM_CATEGORY, BuildConfig.BUILDVERSION)
|
||||||
bundle.putString(FirebaseAnalytics.Param.START_DATE, time.toString())
|
bundle.putString(FirebaseAnalytics.Param.START_DATE, time.toString())
|
||||||
bundle.putString(FirebaseAnalytics.Param.VALUE, activeTreatments.profileSwitchesFromHistory.toString())
|
bundle.putString(FirebaseAnalytics.Param.ITEM_LIST_NAME, activeTreatments.profileSwitchesFromHistory.toString())
|
||||||
fabricPrivacy.logCustom(bundle)
|
fabricPrivacy.logCustom(bundle)
|
||||||
}
|
}
|
||||||
aapsLogger.error("getProfile at the end: returning null")
|
aapsLogger.error("getProfile at the end: returning null")
|
||||||
|
|
|
@ -240,7 +240,7 @@ class ActionsFragment : DaggerFragment() {
|
||||||
|
|
||||||
actions_temptarget?.visibility = Config.APS.toVisibility()
|
actions_temptarget?.visibility = Config.APS.toVisibility()
|
||||||
actions_tddstats?.visibility = pump.pumpDescription.supportsTDDs.toVisibility()
|
actions_tddstats?.visibility = pump.pumpDescription.supportsTDDs.toVisibility()
|
||||||
statusLightHandler.updateAge(careportal_sensorage, careportal_insulinage, careportal_canulaage, careportal_pbage)
|
statusLightHandler.updateStatusLights(careportal_canulaage, careportal_insulinage, null, careportal_sensorage, careportal_pbage, null)
|
||||||
checkPumpCustomActions()
|
checkPumpCustomActions()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,6 @@ import info.nightscout.androidaps.events.EventCareportalEventChange
|
||||||
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
import info.nightscout.androidaps.plugins.general.careportal.Dialogs.NewNSTreatmentDialog
|
import info.nightscout.androidaps.plugins.general.careportal.Dialogs.NewNSTreatmentDialog
|
||||||
import info.nightscout.androidaps.plugins.general.nsclient.data.NSSettingsStatus
|
|
||||||
import info.nightscout.androidaps.plugins.general.overview.StatusLightHandler
|
import info.nightscout.androidaps.plugins.general.overview.StatusLightHandler
|
||||||
import info.nightscout.androidaps.utils.FabricPrivacy
|
import info.nightscout.androidaps.utils.FabricPrivacy
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
|
@ -23,7 +22,6 @@ import javax.inject.Inject
|
||||||
class CareportalFragment : DaggerFragment(), View.OnClickListener {
|
class CareportalFragment : DaggerFragment(), View.OnClickListener {
|
||||||
@Inject lateinit var resourceHelper: ResourceHelper
|
@Inject lateinit var resourceHelper: ResourceHelper
|
||||||
@Inject lateinit var rxBus: RxBusWrapper
|
@Inject lateinit var rxBus: RxBusWrapper
|
||||||
@Inject lateinit var nsSettingsStatus: NSSettingsStatus
|
|
||||||
@Inject lateinit var statusLightHandler: StatusLightHandler
|
@Inject lateinit var statusLightHandler: StatusLightHandler
|
||||||
@Inject lateinit var fabricPrivacy: FabricPrivacy
|
@Inject lateinit var fabricPrivacy: FabricPrivacy
|
||||||
@Inject lateinit var activePlugin: ActivePluginProvider
|
@Inject lateinit var activePlugin: ActivePluginProvider
|
||||||
|
@ -133,6 +131,6 @@ class CareportalFragment : DaggerFragment(), View.OnClickListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateGUI() {
|
private fun updateGUI() {
|
||||||
statusLightHandler.updateAge(careportal_sensorage, careportal_insulinage, careportal_canulaage, careportal_pbage)
|
statusLightHandler.updateStatusLights(careportal_canulaage, careportal_insulinage, null, careportal_sensorage, careportal_pbage, null)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -185,15 +185,7 @@ public class NSClientPlugin extends PluginBase {
|
||||||
super.preprocessPreferences(preferenceFragment);
|
super.preprocessPreferences(preferenceFragment);
|
||||||
|
|
||||||
if (Config.NSCLIENT) {
|
if (Config.NSCLIENT) {
|
||||||
PreferenceScreen scrnAdvancedSettings = preferenceFragment.findPreference(resourceHelper.gs(R.string.key_advancedsettings));
|
preferenceFragment.findPreference(resourceHelper.gs(R.string.key_statuslights_overview_advanced));
|
||||||
if (scrnAdvancedSettings != null) {
|
|
||||||
scrnAdvancedSettings.removePreference(preferenceFragment.findPreference(resourceHelper.gs(R.string.key_statuslights_res_warning)));
|
|
||||||
scrnAdvancedSettings.removePreference(preferenceFragment.findPreference(resourceHelper.gs(R.string.key_statuslights_res_critical)));
|
|
||||||
scrnAdvancedSettings.removePreference(preferenceFragment.findPreference(resourceHelper.gs(R.string.key_statuslights_bat_warning)));
|
|
||||||
scrnAdvancedSettings.removePreference(preferenceFragment.findPreference(resourceHelper.gs(R.string.key_statuslights_bat_critical)));
|
|
||||||
scrnAdvancedSettings.removePreference(preferenceFragment.findPreference(resourceHelper.gs(R.string.key_show_statuslights)));
|
|
||||||
scrnAdvancedSettings.removePreference(preferenceFragment.findPreference(resourceHelper.gs(R.string.key_show_statuslights_extended)));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -73,11 +73,10 @@ public class NSUpload {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void uploadTempBasalStartPercent(TemporaryBasal temporaryBasal) {
|
public static void uploadTempBasalStartPercent(TemporaryBasal temporaryBasal, Profile profile) {
|
||||||
try {
|
try {
|
||||||
SharedPreferences SP = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext());
|
SharedPreferences SP = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext());
|
||||||
boolean useAbsolute = SP.getBoolean("ns_sync_use_absolute", false);
|
boolean useAbsolute = SP.getBoolean("ns_sync_use_absolute", false);
|
||||||
Profile profile = ConfigBuilderPlugin.getPlugin().getProfileFunction().getProfile(temporaryBasal.date);
|
|
||||||
double absoluteRate = 0;
|
double absoluteRate = 0;
|
||||||
if (profile != null) {
|
if (profile != null) {
|
||||||
absoluteRate = profile.getBasal(temporaryBasal.date) * temporaryBasal.percentRate / 100d;
|
absoluteRate = profile.getBasal(temporaryBasal.date) * temporaryBasal.percentRate / 100d;
|
||||||
|
@ -264,16 +263,16 @@ public class NSUpload {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void uploadTempTarget(TempTarget tempTarget) {
|
public static void uploadTempTarget(TempTarget tempTarget, ProfileFunction profileFunction) {
|
||||||
try {
|
try {
|
||||||
JSONObject data = new JSONObject();
|
JSONObject data = new JSONObject();
|
||||||
data.put("eventType", CareportalEvent.TEMPORARYTARGET);
|
data.put("eventType", CareportalEvent.TEMPORARYTARGET);
|
||||||
data.put("duration", tempTarget.durationInMinutes);
|
data.put("duration", tempTarget.durationInMinutes);
|
||||||
if (tempTarget.low > 0) {
|
if (tempTarget.low > 0) {
|
||||||
data.put("reason", tempTarget.reason);
|
data.put("reason", tempTarget.reason);
|
||||||
data.put("targetBottom", Profile.fromMgdlToUnits(tempTarget.low, ConfigBuilderPlugin.getPlugin().getProfileFunction().getUnits()));
|
data.put("targetBottom", Profile.fromMgdlToUnits(tempTarget.low, profileFunction.getUnits()));
|
||||||
data.put("targetTop", Profile.fromMgdlToUnits(tempTarget.high, ConfigBuilderPlugin.getPlugin().getProfileFunction().getUnits()));
|
data.put("targetTop", Profile.fromMgdlToUnits(tempTarget.high, profileFunction.getUnits()));
|
||||||
data.put("units", ConfigBuilderPlugin.getPlugin().getProfileFunction().getUnits());
|
data.put("units", profileFunction.getUnits());
|
||||||
}
|
}
|
||||||
data.put("created_at", DateUtil.toISOString(tempTarget.date));
|
data.put("created_at", DateUtil.toISOString(tempTarget.date));
|
||||||
data.put("enteredBy", MainApp.gs(R.string.app_name));
|
data.put("enteredBy", MainApp.gs(R.string.app_name));
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package info.nightscout.androidaps.plugins.general.nsclient.data
|
package info.nightscout.androidaps.plugins.general.nsclient.data
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
import info.nightscout.androidaps.Config
|
import info.nightscout.androidaps.Config
|
||||||
import info.nightscout.androidaps.R
|
import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
|
@ -10,7 +11,9 @@ import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotifi
|
||||||
import info.nightscout.androidaps.plugins.general.overview.notifications.Notification
|
import info.nightscout.androidaps.plugins.general.overview.notifications.Notification
|
||||||
import info.nightscout.androidaps.utils.DefaultValueHelper
|
import info.nightscout.androidaps.utils.DefaultValueHelper
|
||||||
import info.nightscout.androidaps.utils.JsonHelper
|
import info.nightscout.androidaps.utils.JsonHelper
|
||||||
|
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
|
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||||
import org.json.JSONException
|
import org.json.JSONException
|
||||||
import org.json.JSONObject
|
import org.json.JSONObject
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
@ -111,10 +114,12 @@ class NSSettingsStatus @Inject constructor(
|
||||||
private val aapsLogger: AAPSLogger,
|
private val aapsLogger: AAPSLogger,
|
||||||
private val resourceHelper: ResourceHelper,
|
private val resourceHelper: ResourceHelper,
|
||||||
private val rxBus: RxBusWrapper,
|
private val rxBus: RxBusWrapper,
|
||||||
private val defaultValueHelper: DefaultValueHelper
|
private val defaultValueHelper: DefaultValueHelper,
|
||||||
|
private val sp: SP
|
||||||
) {
|
) {
|
||||||
|
|
||||||
var nightscoutVersionName = ""
|
var nightscoutVersionName = ""
|
||||||
|
|
||||||
// ***** PUMP STATUS ******
|
// ***** PUMP STATUS ******
|
||||||
var data: JSONObject? = null
|
var data: JSONObject? = null
|
||||||
|
|
||||||
|
@ -133,6 +138,7 @@ class NSSettingsStatus @Inject constructor(
|
||||||
val targetlow = getSettingsThreshold("bgTargetBottom")
|
val targetlow = getSettingsThreshold("bgTargetBottom")
|
||||||
if (targetHigh != null) defaultValueHelper.bgTargetHigh = targetHigh
|
if (targetHigh != null) defaultValueHelper.bgTargetHigh = targetHigh
|
||||||
if (targetlow != null) defaultValueHelper.bgTargetLow = targetlow
|
if (targetlow != null) defaultValueHelper.bgTargetLow = targetlow
|
||||||
|
copyStatusLightsNsSettings(null)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getName(): String? =
|
fun getName(): String? =
|
||||||
|
@ -152,10 +158,14 @@ class NSSettingsStatus @Inject constructor(
|
||||||
|
|
||||||
// valid property is "warn" or "urgent"
|
// valid property is "warn" or "urgent"
|
||||||
// plugings "iage" "sage" "cage" "pbage"
|
// plugings "iage" "sage" "cage" "pbage"
|
||||||
fun getExtendedWarnValue(plugin: String, property: String, defaultValue: Double): Double {
|
fun getExtendedWarnValue(plugin: String, property: String): Double? {
|
||||||
val extendedSettings = getExtendedSettings() ?: return defaultValue
|
val extendedSettings = getExtendedSettings() ?: return null
|
||||||
val pluginJson = extendedSettings.optJSONObject(plugin) ?: return defaultValue
|
val pluginJson = extendedSettings.optJSONObject(plugin) ?: return null
|
||||||
return pluginJson.optDouble(property, defaultValue)
|
try {
|
||||||
|
return pluginJson.getDouble(property)
|
||||||
|
} catch (e: Exception) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// "bgHigh": 252,
|
// "bgHigh": 252,
|
||||||
|
@ -211,4 +221,20 @@ class NSSettingsStatus @Inject constructor(
|
||||||
val openaps = JsonHelper.safeGetJSONObject(getExtendedSettings(), "openaps", null)
|
val openaps = JsonHelper.safeGetJSONObject(getExtendedSettings(), "openaps", null)
|
||||||
return JsonHelper.safeGetBoolean(openaps, "enableAlerts")
|
return JsonHelper.safeGetBoolean(openaps, "enableAlerts")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun copyStatusLightsNsSettings(context: Context?) {
|
||||||
|
val action = Runnable {
|
||||||
|
getExtendedWarnValue("cage", "warn")?.let { sp.putDouble(R.string.key_statuslights_cage_warning, it) }
|
||||||
|
getExtendedWarnValue("cage", "urgent")?.let { sp.putDouble(R.string.key_statuslights_cage_critical, it) }
|
||||||
|
getExtendedWarnValue("iage", "warn")?.let { sp.putDouble(R.string.key_statuslights_iage_warning, it) }
|
||||||
|
getExtendedWarnValue("iage", "urgent")?.let { sp.putDouble(R.string.key_statuslights_iage_critical, it) }
|
||||||
|
getExtendedWarnValue("sage", "warn")?.let { sp.putDouble(R.string.key_statuslights_sage_warning, it) }
|
||||||
|
getExtendedWarnValue("sage", "urgent")?.let { sp.putDouble(R.string.key_statuslights_sage_critical, it) }
|
||||||
|
getExtendedWarnValue("bage", "warn")?.let { sp.putDouble(R.string.key_statuslights_bage_warning, it) }
|
||||||
|
getExtendedWarnValue("bage", "urgent")?.let { sp.putDouble(R.string.key_statuslights_bage_critical, it) }
|
||||||
|
}
|
||||||
|
|
||||||
|
if (context != null) OKDialog.showConfirmation(context, resourceHelper.gs(R.string.statuslights), resourceHelper.gs(R.string.copyexistingvalues), action)
|
||||||
|
else action.run()
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -68,8 +68,13 @@ import info.nightscout.androidaps.utils.wizard.QuickWizard
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||||
import io.reactivex.disposables.CompositeDisposable
|
import io.reactivex.disposables.CompositeDisposable
|
||||||
import io.reactivex.schedulers.Schedulers
|
import io.reactivex.schedulers.Schedulers
|
||||||
import kotlinx.android.synthetic.main.careportal_stats_fragment.*
|
|
||||||
import kotlinx.android.synthetic.main.overview_fragment.*
|
import kotlinx.android.synthetic.main.overview_fragment.*
|
||||||
|
import kotlinx.android.synthetic.main.overview_fragment.careportal_canulaage
|
||||||
|
import kotlinx.android.synthetic.main.overview_fragment.careportal_insulinage
|
||||||
|
import kotlinx.android.synthetic.main.overview_fragment.careportal_reservoirlevel
|
||||||
|
import kotlinx.android.synthetic.main.overview_fragment.careportal_sensorage
|
||||||
|
import kotlinx.android.synthetic.main.overview_fragment.careportal_pbage
|
||||||
|
import kotlinx.android.synthetic.main.overview_fragment.careportal_batterylevel
|
||||||
import kotlinx.android.synthetic.main.overview_fragment.overview_activeprofile
|
import kotlinx.android.synthetic.main.overview_fragment.overview_activeprofile
|
||||||
import kotlinx.android.synthetic.main.overview_fragment.overview_apsmode
|
import kotlinx.android.synthetic.main.overview_fragment.overview_apsmode
|
||||||
import kotlinx.android.synthetic.main.overview_fragment.overview_arrow
|
import kotlinx.android.synthetic.main.overview_fragment.overview_arrow
|
||||||
|
@ -714,15 +719,9 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// NSClient mode
|
// Status lights
|
||||||
statusLightHandler.updateAge(careportal_sensorage, careportal_insulinage, careportal_canulaage, careportal_pbage)
|
overview_statuslights?.visibility = (sp.getBoolean(R.string.key_show_statuslights, true) || Config.NSCLIENT).toVisibility()
|
||||||
// Mode modes
|
statusLightHandler.updateStatusLights(careportal_canulaage, careportal_insulinage, careportal_reservoirlevel, careportal_sensorage, careportal_pbage, careportal_batterylevel)
|
||||||
if (sp.getBoolean(R.string.key_show_statuslights, false)) {
|
|
||||||
if (sp.getBoolean(R.string.key_show_statuslights_extended, false))
|
|
||||||
statusLightHandler.extendedStatusLight(overview_canulaage, overview_insulinage, overview_reservoirlevel, overview_sensorage, overview_batterylevel)
|
|
||||||
else
|
|
||||||
statusLightHandler.statusLight(overview_canulaage, overview_insulinage, overview_reservoirlevel, overview_sensorage, overview_batterylevel)
|
|
||||||
}
|
|
||||||
|
|
||||||
// cob
|
// cob
|
||||||
var cobText: String = resourceHelper.gs(R.string.value_unavailable_short)
|
var cobText: String = resourceHelper.gs(R.string.value_unavailable_short)
|
||||||
|
@ -755,7 +754,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
|
||||||
|
|
||||||
// ****** GRAPH *******
|
// ****** GRAPH *******
|
||||||
GlobalScope.launch(Dispatchers.Main) {
|
GlobalScope.launch(Dispatchers.Main) {
|
||||||
overview_bggraph?: return@launch
|
overview_bggraph ?: return@launch
|
||||||
val graphData = GraphData(injector, overview_bggraph, iobCobCalculatorPlugin)
|
val graphData = GraphData(injector, overview_bggraph, iobCobCalculatorPlugin)
|
||||||
val secondaryGraphsData: ArrayList<GraphData> = ArrayList()
|
val secondaryGraphsData: ArrayList<GraphData> = ArrayList()
|
||||||
|
|
||||||
|
|
|
@ -1,17 +1,15 @@
|
||||||
package info.nightscout.androidaps.plugins.general.overview
|
package info.nightscout.androidaps.plugins.general.overview
|
||||||
|
|
||||||
import android.graphics.Color
|
|
||||||
import android.view.View
|
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import androidx.arch.core.util.Function
|
import androidx.annotation.StringRes
|
||||||
|
import info.nightscout.androidaps.Config
|
||||||
import info.nightscout.androidaps.MainApp
|
import info.nightscout.androidaps.MainApp
|
||||||
import info.nightscout.androidaps.R
|
import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.db.CareportalEvent
|
import info.nightscout.androidaps.db.CareportalEvent
|
||||||
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
||||||
import info.nightscout.androidaps.plugins.general.nsclient.data.NSSettingsStatus
|
|
||||||
import info.nightscout.androidaps.plugins.pump.common.defs.PumpType
|
import info.nightscout.androidaps.plugins.pump.common.defs.PumpType
|
||||||
import info.nightscout.androidaps.utils.DecimalFormatter
|
import info.nightscout.androidaps.utils.DecimalFormatter
|
||||||
import info.nightscout.androidaps.utils.SetWarnColor
|
import info.nightscout.androidaps.utils.WarnColors
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
@ -19,154 +17,44 @@ import javax.inject.Singleton
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
class StatusLightHandler @Inject constructor(
|
class StatusLightHandler @Inject constructor(
|
||||||
private val nsSettingsStatus: NSSettingsStatus,
|
|
||||||
private val resourceHelper: ResourceHelper,
|
private val resourceHelper: ResourceHelper,
|
||||||
private val sp: SP,
|
private val sp: SP,
|
||||||
private val activePlugin: ActivePluginProvider
|
private val activePlugin: ActivePluginProvider,
|
||||||
|
private val warnColors: WarnColors
|
||||||
) {
|
) {
|
||||||
|
|
||||||
/**
|
|
||||||
* applies the statusLight subview on the overview fragment
|
|
||||||
*/
|
|
||||||
fun statusLight(cageView: TextView?, iAgeView: TextView?, reservoirView: TextView?,
|
|
||||||
sageView: TextView?, batteryView: TextView?) {
|
|
||||||
val pump = activePlugin.activePump
|
|
||||||
applyStatusLight("cage", CareportalEvent.SITECHANGE, cageView, "CAN", 48, 72)
|
|
||||||
applyStatusLight("iage", CareportalEvent.INSULINCHANGE, iAgeView, "INS", 72, 96)
|
|
||||||
val reservoirLevel = if (pump.isInitialized) pump.reservoirLevel else (-1).toDouble()
|
|
||||||
applyStatusLightLevel(R.string.key_statuslights_res_critical, 10.0,
|
|
||||||
R.string.key_statuslights_res_warning, 80.0, reservoirView, "RES", reservoirLevel)
|
|
||||||
applyStatusLight("sage", CareportalEvent.SENSORCHANGE, sageView, "SEN", 164, 166)
|
|
||||||
if (pump.model() != PumpType.AccuChekCombo) {
|
|
||||||
val batteryLevel = if (pump.isInitialized) pump.batteryLevel.toDouble() else -1.0
|
|
||||||
applyStatusLightLevel(R.string.key_statuslights_bat_critical, 5.0,
|
|
||||||
R.string.key_statuslights_bat_warning, 22.0,
|
|
||||||
batteryView, "BAT", batteryLevel)
|
|
||||||
} else {
|
|
||||||
applyStatusLight("bage", CareportalEvent.PUMPBATTERYCHANGE, batteryView, "BAT", 224, 336)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun applyStatusLight(nsSettingPlugin: String?, eventName: String?, view: TextView?, text: String?,
|
|
||||||
defaultWarnThreshold: Int, defaultUrgentThreshold: Int) {
|
|
||||||
if (view != null) {
|
|
||||||
val urgent = nsSettingsStatus.getExtendedWarnValue(nsSettingPlugin!!, "urgent", defaultUrgentThreshold.toDouble())
|
|
||||||
val warn = nsSettingsStatus.getExtendedWarnValue(nsSettingPlugin, "warn", defaultWarnThreshold.toDouble())
|
|
||||||
val event = MainApp.getDbHelper().getLastCareportalEvent(eventName)
|
|
||||||
val age = event?.hoursFromStart ?: Double.MAX_VALUE
|
|
||||||
applyStatusLight(view, text, age, warn, urgent, Double.MAX_VALUE, true)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun applyStatusLightLevel(criticalSetting: Int, criticalDefaultValue: Double,
|
|
||||||
warnSetting: Int, warnDefaultValue: Double,
|
|
||||||
view: TextView?, text: String?, level: Double) {
|
|
||||||
if (view != null) {
|
|
||||||
val resUrgent = sp.getDouble(criticalSetting, criticalDefaultValue)
|
|
||||||
val resWarn = sp.getDouble(warnSetting, warnDefaultValue)
|
|
||||||
applyStatusLight(view, text, level, resWarn, resUrgent, -1.0, false)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun applyStatusLight(view: TextView, text: String?, value: Double, warnThreshold: Double,
|
|
||||||
urgentThreshold: Double, invalid: Double, checkAscending: Boolean) {
|
|
||||||
val check =
|
|
||||||
if (checkAscending) Function { threshold: Double -> value >= threshold }
|
|
||||||
else Function { threshold: Double -> value <= threshold }
|
|
||||||
if (value != invalid) {
|
|
||||||
view.text = text
|
|
||||||
when {
|
|
||||||
check.apply(urgentThreshold) -> view.setTextColor(resourceHelper.gc(R.color.ribbonCritical))
|
|
||||||
check.apply(warnThreshold) -> view.setTextColor(resourceHelper.gc(R.color.ribbonWarning))
|
|
||||||
else -> view.setTextColor(resourceHelper.gc(R.color.ribbonDefault))
|
|
||||||
}
|
|
||||||
view.visibility = View.VISIBLE
|
|
||||||
} else {
|
|
||||||
view.visibility = View.GONE
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* applies the extended statusLight subview on the overview fragment
|
* applies the extended statusLight subview on the overview fragment
|
||||||
*/
|
*/
|
||||||
fun extendedStatusLight(cageView: TextView?, iAgeView: TextView?,
|
fun updateStatusLights(careportal_canulaage: TextView?, careportal_insulinage: TextView?, careportal_reservoirlevel: TextView?, careportal_sensorage: TextView?, careportal_pbage: TextView?, careportal_batterylevel: TextView?) {
|
||||||
reservoirView: TextView?, sageView: TextView?,
|
|
||||||
batteryView: TextView?) {
|
|
||||||
val pump = activePlugin.activePump
|
val pump = activePlugin.activePump
|
||||||
handleAge("cage", CareportalEvent.SITECHANGE, cageView, "CAN ",
|
handleAge(careportal_canulaage, "cage", CareportalEvent.SITECHANGE, R.string.key_statuslights_cage_warning, 48.0, R.string.key_statuslights_cage_critical, 72.0)
|
||||||
48, 72)
|
handleAge(careportal_insulinage, "iage", CareportalEvent.INSULINCHANGE, R.string.key_statuslights_iage_warning, 72.0, R.string.key_statuslights_iage_critical, 144.0)
|
||||||
handleAge("iage", CareportalEvent.INSULINCHANGE, iAgeView, "INS ",
|
handleAge(careportal_sensorage, "sage", CareportalEvent.SENSORCHANGE, R.string.key_statuslights_sage_warning, 216.0, R.string.key_statuslights_sage_critical, 240.0)
|
||||||
72, 96)
|
handleAge(careportal_pbage, "bage", CareportalEvent.PUMPBATTERYCHANGE, R.string.key_statuslights_bage_warning, 216.0, R.string.key_statuslights_bage_critical, 240.0)
|
||||||
handleLevel(R.string.key_statuslights_res_critical, 10.0,
|
if (!Config.NSCLIENT)
|
||||||
R.string.key_statuslights_res_warning, 80.0,
|
handleLevel(careportal_reservoirlevel, R.string.key_statuslights_res_critical, 10.0, R.string.key_statuslights_res_warning, 80.0, pump.reservoirLevel)
|
||||||
reservoirView, "RES ", pump.reservoirLevel)
|
if (!Config.NSCLIENT && pump.model() != PumpType.AccuChekCombo)
|
||||||
handleAge("sage", CareportalEvent.SENSORCHANGE, sageView, "SEN ",
|
handleLevel(careportal_batterylevel, R.string.key_statuslights_bat_critical, 26.0, R.string.key_statuslights_bat_warning, 51.0, pump.batteryLevel.toDouble())
|
||||||
164, 166)
|
}
|
||||||
if (pump.model() != PumpType.AccuChekCombo) {
|
|
||||||
handleLevel(R.string.key_statuslights_bat_critical, 26.0,
|
private fun handleAge(view: TextView?, nsSettingPlugin: String, eventName: String, @StringRes warnSettings: Int, defaultWarnThreshold: Double, @StringRes urgentSettings: Int, defaultUrgentThreshold: Double) {
|
||||||
R.string.key_statuslights_bat_warning, 51.0,
|
val warn = sp.getDouble(warnSettings, defaultWarnThreshold)
|
||||||
batteryView, "BAT ", pump.batteryLevel.toDouble())
|
val urgent = sp.getDouble(urgentSettings, defaultUrgentThreshold)
|
||||||
|
val careportalEvent = MainApp.getDbHelper().getLastCareportalEvent(eventName)
|
||||||
|
if (careportalEvent != null) {
|
||||||
|
warnColors.setColorByAge(view, careportalEvent, warn, urgent)
|
||||||
|
view?.text = careportalEvent.age(resourceHelper.shortTextMode(), resourceHelper)
|
||||||
} else {
|
} else {
|
||||||
handleAge("bage", CareportalEvent.PUMPBATTERYCHANGE, batteryView, "BAT ",
|
view?.text = if (resourceHelper.shortTextMode()) "-" else resourceHelper.gs(R.string.notavailable)
|
||||||
224, 336)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun handleAge(nsSettingPlugin: String, eventName: String, view: TextView?, text: String,
|
private fun handleLevel(view: TextView?, criticalSetting: Int, criticalDefaultValue: Double, warnSetting: Int, warnDefaultValue: Double, level: Double) {
|
||||||
defaultWarnThreshold: Int, defaultUrgentThreshold: Int) {
|
|
||||||
val urgent = nsSettingsStatus.getExtendedWarnValue(nsSettingPlugin, "urgent", defaultUrgentThreshold.toDouble())
|
|
||||||
val warn = nsSettingsStatus.getExtendedWarnValue(nsSettingPlugin, "warn", defaultWarnThreshold.toDouble())
|
|
||||||
handleAge(view, text, eventName, warn, urgent)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun handleLevel(criticalSetting: Int, criticalDefaultValue: Double,
|
|
||||||
warnSetting: Int, warnDefaultValue: Double,
|
|
||||||
view: TextView?, text: String, level: Double) {
|
|
||||||
if (view != null) {
|
|
||||||
val resUrgent = sp.getDouble(criticalSetting, criticalDefaultValue)
|
val resUrgent = sp.getDouble(criticalSetting, criticalDefaultValue)
|
||||||
val resWarn = sp.getDouble(warnSetting, warnDefaultValue)
|
val resWarn = sp.getDouble(warnSetting, warnDefaultValue)
|
||||||
@Suppress("SetTextI18n")
|
@Suppress("SetTextI18n")
|
||||||
view.text = text + DecimalFormatter.to0Decimal(level)
|
view?.text = " " + DecimalFormatter.to0Decimal(level)
|
||||||
SetWarnColor.setColorInverse(view, level, resWarn, resUrgent)
|
warnColors.setColorInverse(view, level, resWarn, resUrgent)
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun handleAge(age: TextView?, eventType: String, warnThreshold: Double, urgentThreshold: Double) =
|
|
||||||
handleAge(age, "", eventType, warnThreshold, urgentThreshold)
|
|
||||||
|
|
||||||
fun handleAge(age: TextView?, prefix: String, eventType: String, warnThreshold: Double, urgentThreshold: Double) {
|
|
||||||
val notavailable = if (resourceHelper.shortTextMode()) "-" else resourceHelper.gs(R.string.notavailable)
|
|
||||||
val careportalEvent = MainApp.getDbHelper().getLastCareportalEvent(eventType)
|
|
||||||
if (careportalEvent != null) {
|
|
||||||
age?.setTextColor(determineTextColor(careportalEvent, warnThreshold, urgentThreshold))
|
|
||||||
age?.text = prefix + careportalEvent.age(resourceHelper.shortTextMode())
|
|
||||||
} else {
|
|
||||||
age?.text = notavailable
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun updateAge(sage: TextView?, iage: TextView?, cage: TextView?, pbage: TextView?) {
|
|
||||||
val iageUrgent = nsSettingsStatus.getExtendedWarnValue("iage", "urgent", 96.0)
|
|
||||||
val iageWarn = nsSettingsStatus.getExtendedWarnValue("iage", "warn", 72.0)
|
|
||||||
handleAge(iage, CareportalEvent.INSULINCHANGE, iageWarn, iageUrgent)
|
|
||||||
val cageUrgent = nsSettingsStatus.getExtendedWarnValue("cage", "urgent", 72.0)
|
|
||||||
val cageWarn = nsSettingsStatus.getExtendedWarnValue("cage", "warn", 48.0)
|
|
||||||
handleAge(cage, CareportalEvent.SITECHANGE, cageWarn, cageUrgent)
|
|
||||||
val sageUrgent = nsSettingsStatus.getExtendedWarnValue("sage", "urgent", 166.0)
|
|
||||||
val sageWarn = nsSettingsStatus.getExtendedWarnValue("sage", "warn", 164.0)
|
|
||||||
handleAge(sage, CareportalEvent.SENSORCHANGE, sageWarn, sageUrgent)
|
|
||||||
val pbageUrgent = nsSettingsStatus.getExtendedWarnValue("bage", "urgent", 360.0)
|
|
||||||
val pbageWarn = nsSettingsStatus.getExtendedWarnValue("bage", "warn", 240.0)
|
|
||||||
handleAge(pbage, CareportalEvent.PUMPBATTERYCHANGE, pbageWarn, pbageUrgent)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun determineTextColor(careportalEvent: CareportalEvent, warnThreshold: Double, urgentThreshold: Double): Int {
|
|
||||||
return if (careportalEvent.isOlderThan(urgentThreshold)) {
|
|
||||||
resourceHelper.gc(R.color.low)
|
|
||||||
} else if (careportalEvent.isOlderThan(warnThreshold)) {
|
|
||||||
resourceHelper.gc(R.color.high)
|
|
||||||
} else {
|
|
||||||
Color.WHITE
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -6,7 +6,6 @@ import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.logging.LTag
|
import info.nightscout.androidaps.logging.LTag
|
||||||
import info.nightscout.androidaps.plugins.general.nsclient.NSClientPlugin
|
import info.nightscout.androidaps.plugins.general.nsclient.NSClientPlugin
|
||||||
import info.nightscout.androidaps.plugins.general.nsclient.data.NSAlarm
|
import info.nightscout.androidaps.plugins.general.nsclient.data.NSAlarm
|
||||||
import info.nightscout.androidaps.plugins.general.nsclient.data.NSSettingsStatus
|
|
||||||
import info.nightscout.androidaps.utils.DefaultValueHelper
|
import info.nightscout.androidaps.utils.DefaultValueHelper
|
||||||
import info.nightscout.androidaps.utils.T
|
import info.nightscout.androidaps.utils.T
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
|
@ -21,7 +20,6 @@ class NotificationWithAction constructor(
|
||||||
@Inject lateinit var resourceHelper: ResourceHelper
|
@Inject lateinit var resourceHelper: ResourceHelper
|
||||||
@Inject lateinit var sp: SP
|
@Inject lateinit var sp: SP
|
||||||
@Inject lateinit var defaultValueHelper: DefaultValueHelper
|
@Inject lateinit var defaultValueHelper: DefaultValueHelper
|
||||||
@Inject lateinit var nsSettingsStatus: NSSettingsStatus
|
|
||||||
@Inject lateinit var nsClientPlugin: NSClientPlugin
|
@Inject lateinit var nsClientPlugin: NSClientPlugin
|
||||||
|
|
||||||
private var nsAlarm: NSAlarm? = null
|
private var nsAlarm: NSAlarm? = null
|
||||||
|
|
|
@ -470,7 +470,7 @@ public class IobCobCalculatorPlugin extends PluginBase {
|
||||||
// OpenAPSSMB only
|
// OpenAPSSMB only
|
||||||
// Add expected zero temp basal for next 240 mins
|
// Add expected zero temp basal for next 240 mins
|
||||||
IobTotal basalIobWithZeroTemp = basalIob.copy();
|
IobTotal basalIobWithZeroTemp = basalIob.copy();
|
||||||
TemporaryBasal t = new TemporaryBasal()
|
TemporaryBasal t = new TemporaryBasal(injector)
|
||||||
.date(now + 60 * 1000L)
|
.date(now + 60 * 1000L)
|
||||||
.duration(240)
|
.duration(240)
|
||||||
.absolute(0);
|
.absolute(0);
|
||||||
|
@ -517,7 +517,7 @@ public class IobCobCalculatorPlugin extends PluginBase {
|
||||||
// OpenAPSSMB only
|
// OpenAPSSMB only
|
||||||
// Add expected zero temp basal for next 240 mins
|
// Add expected zero temp basal for next 240 mins
|
||||||
IobTotal basalIobWithZeroTemp = basalIob.copy();
|
IobTotal basalIobWithZeroTemp = basalIob.copy();
|
||||||
TemporaryBasal t = new TemporaryBasal()
|
TemporaryBasal t = new TemporaryBasal(injector)
|
||||||
.date(now + 60 * 1000L)
|
.date(now + 60 * 1000L)
|
||||||
.duration(240)
|
.duration(240)
|
||||||
.absolute(0);
|
.absolute(0);
|
||||||
|
|
|
@ -777,7 +777,7 @@ public class ComboPlugin extends PumpPluginBase implements PumpInterface, Constr
|
||||||
PumpState state = commandResult.state;
|
PumpState state = commandResult.state;
|
||||||
if (state.tbrActive && state.tbrPercent == adjustedPercent
|
if (state.tbrActive && state.tbrPercent == adjustedPercent
|
||||||
&& (state.tbrRemainingDuration == durationInMinutes || state.tbrRemainingDuration == durationInMinutes - 1)) {
|
&& (state.tbrRemainingDuration == durationInMinutes || state.tbrRemainingDuration == durationInMinutes - 1)) {
|
||||||
TemporaryBasal tempStart = new TemporaryBasal()
|
TemporaryBasal tempStart = new TemporaryBasal(getInjector())
|
||||||
.date(state.timestamp)
|
.date(state.timestamp)
|
||||||
.duration(state.tbrRemainingDuration)
|
.duration(state.tbrRemainingDuration)
|
||||||
.percent(state.tbrPercent)
|
.percent(state.tbrPercent)
|
||||||
|
@ -823,7 +823,7 @@ public class ComboPlugin extends PumpPluginBase implements PumpInterface, Constr
|
||||||
return new PumpEnactResult(getInjector()).success(false).enacted(false);
|
return new PumpEnactResult(getInjector()).success(false).enacted(false);
|
||||||
}
|
}
|
||||||
if (!cancelResult.state.tbrActive) {
|
if (!cancelResult.state.tbrActive) {
|
||||||
TemporaryBasal tempBasal = new TemporaryBasal()
|
TemporaryBasal tempBasal = new TemporaryBasal(getInjector())
|
||||||
.date(cancelResult.state.timestamp)
|
.date(cancelResult.state.timestamp)
|
||||||
.duration(0)
|
.duration(0)
|
||||||
.source(Source.USER);
|
.source(Source.USER);
|
||||||
|
@ -974,7 +974,7 @@ public class ComboPlugin extends PumpPluginBase implements PumpInterface, Constr
|
||||||
TemporaryBasal aapsTbr = treatmentsPlugin.getTempBasalFromHistory(now);
|
TemporaryBasal aapsTbr = treatmentsPlugin.getTempBasalFromHistory(now);
|
||||||
if (aapsTbr == null || aapsTbr.percentRate != 0) {
|
if (aapsTbr == null || aapsTbr.percentRate != 0) {
|
||||||
getAapsLogger().debug(LTag.PUMP, "Creating 15m zero temp since pump is suspended");
|
getAapsLogger().debug(LTag.PUMP, "Creating 15m zero temp since pump is suspended");
|
||||||
TemporaryBasal newTempBasal = new TemporaryBasal()
|
TemporaryBasal newTempBasal = new TemporaryBasal(getInjector())
|
||||||
.date(now)
|
.date(now)
|
||||||
.percent(0)
|
.percent(0)
|
||||||
.duration(15)
|
.duration(15)
|
||||||
|
@ -1100,7 +1100,7 @@ public class ComboPlugin extends PumpPluginBase implements PumpInterface, Constr
|
||||||
TemporaryBasal aapsTbr = treatmentsPlugin.getTempBasalFromHistory(now);
|
TemporaryBasal aapsTbr = treatmentsPlugin.getTempBasalFromHistory(now);
|
||||||
if (aapsTbr == null && state.tbrActive && state.tbrRemainingDuration > 2) {
|
if (aapsTbr == null && state.tbrActive && state.tbrRemainingDuration > 2) {
|
||||||
getAapsLogger().debug(LTag.PUMP, "Creating temp basal from pump TBR");
|
getAapsLogger().debug(LTag.PUMP, "Creating temp basal from pump TBR");
|
||||||
TemporaryBasal newTempBasal = new TemporaryBasal()
|
TemporaryBasal newTempBasal = new TemporaryBasal(getInjector())
|
||||||
.date(now)
|
.date(now)
|
||||||
.percent(state.tbrPercent)
|
.percent(state.tbrPercent)
|
||||||
.duration(state.tbrRemainingDuration)
|
.duration(state.tbrRemainingDuration)
|
||||||
|
@ -1108,7 +1108,7 @@ public class ComboPlugin extends PumpPluginBase implements PumpInterface, Constr
|
||||||
treatmentsPlugin.addToHistoryTempBasal(newTempBasal);
|
treatmentsPlugin.addToHistoryTempBasal(newTempBasal);
|
||||||
} else if (aapsTbr != null && aapsTbr.getPlannedRemainingMinutes() > 2 && !state.tbrActive) {
|
} else if (aapsTbr != null && aapsTbr.getPlannedRemainingMinutes() > 2 && !state.tbrActive) {
|
||||||
getAapsLogger().debug(LTag.PUMP, "Ending AAPS-TBR since pump has no TBR active");
|
getAapsLogger().debug(LTag.PUMP, "Ending AAPS-TBR since pump has no TBR active");
|
||||||
TemporaryBasal tempStop = new TemporaryBasal()
|
TemporaryBasal tempStop = new TemporaryBasal(getInjector())
|
||||||
.date(now)
|
.date(now)
|
||||||
.duration(0)
|
.duration(0)
|
||||||
.source(Source.USER);
|
.source(Source.USER);
|
||||||
|
@ -1117,13 +1117,13 @@ public class ComboPlugin extends PumpPluginBase implements PumpInterface, Constr
|
||||||
&& (aapsTbr.percentRate != state.tbrPercent ||
|
&& (aapsTbr.percentRate != state.tbrPercent ||
|
||||||
Math.abs(aapsTbr.getPlannedRemainingMinutes() - state.tbrRemainingDuration) > 2)) {
|
Math.abs(aapsTbr.getPlannedRemainingMinutes() - state.tbrRemainingDuration) > 2)) {
|
||||||
getAapsLogger().debug(LTag.PUMP, "AAPSs and pump-TBR differ; ending AAPS-TBR and creating new TBR based on pump TBR");
|
getAapsLogger().debug(LTag.PUMP, "AAPSs and pump-TBR differ; ending AAPS-TBR and creating new TBR based on pump TBR");
|
||||||
TemporaryBasal tempStop = new TemporaryBasal()
|
TemporaryBasal tempStop = new TemporaryBasal(getInjector())
|
||||||
.date(now - 1000)
|
.date(now - 1000)
|
||||||
.duration(0)
|
.duration(0)
|
||||||
.source(Source.USER);
|
.source(Source.USER);
|
||||||
treatmentsPlugin.addToHistoryTempBasal(tempStop);
|
treatmentsPlugin.addToHistoryTempBasal(tempStop);
|
||||||
|
|
||||||
TemporaryBasal newTempBasal = new TemporaryBasal()
|
TemporaryBasal newTempBasal = new TemporaryBasal(getInjector())
|
||||||
.date(now)
|
.date(now)
|
||||||
.percent(state.tbrPercent)
|
.percent(state.tbrPercent)
|
||||||
.duration(state.tbrRemainingDuration)
|
.duration(state.tbrRemainingDuration)
|
||||||
|
|
|
@ -6,6 +6,7 @@ import android.content.ServiceConnection;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
@ -30,10 +31,8 @@ import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||||
import info.nightscout.androidaps.interfaces.PumpPluginBase;
|
import info.nightscout.androidaps.interfaces.PumpPluginBase;
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger;
|
import info.nightscout.androidaps.logging.AAPSLogger;
|
||||||
import info.nightscout.androidaps.logging.LTag;
|
import info.nightscout.androidaps.logging.LTag;
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBus;
|
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper;
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper;
|
||||||
import info.nightscout.androidaps.plugins.common.ManufacturerType;
|
import info.nightscout.androidaps.plugins.common.ManufacturerType;
|
||||||
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification;
|
|
||||||
import info.nightscout.androidaps.plugins.general.overview.events.EventOverviewBolusProgress;
|
import info.nightscout.androidaps.plugins.general.overview.events.EventOverviewBolusProgress;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.data.PumpStatus;
|
import info.nightscout.androidaps.plugins.pump.common.data.PumpStatus;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.defs.PumpDriverState;
|
import info.nightscout.androidaps.plugins.pump.common.defs.PumpDriverState;
|
||||||
|
@ -43,7 +42,6 @@ import info.nightscout.androidaps.plugins.treatments.Treatment;
|
||||||
import info.nightscout.androidaps.utils.DateUtil;
|
import info.nightscout.androidaps.utils.DateUtil;
|
||||||
import info.nightscout.androidaps.utils.DecimalFormatter;
|
import info.nightscout.androidaps.utils.DecimalFormatter;
|
||||||
import info.nightscout.androidaps.utils.FabricPrivacy;
|
import info.nightscout.androidaps.utils.FabricPrivacy;
|
||||||
import info.nightscout.androidaps.utils.TimeChangeType;
|
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper;
|
import info.nightscout.androidaps.utils.resources.ResourceHelper;
|
||||||
import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
||||||
import io.reactivex.disposables.CompositeDisposable;
|
import io.reactivex.disposables.CompositeDisposable;
|
||||||
|
@ -78,6 +76,7 @@ public abstract class PumpPluginAbstract extends PumpPluginBase implements PumpI
|
||||||
// protected boolean isInitialized = false;
|
// protected boolean isInitialized = false;
|
||||||
protected PumpDriverState pumpState = PumpDriverState.NotInitialized;
|
protected PumpDriverState pumpState = PumpDriverState.NotInitialized;
|
||||||
protected boolean displayConnectionMessages = false;
|
protected boolean displayConnectionMessages = false;
|
||||||
|
protected PumpType pumpType;
|
||||||
|
|
||||||
|
|
||||||
protected PumpPluginAbstract(
|
protected PumpPluginAbstract(
|
||||||
|
@ -103,8 +102,7 @@ public abstract class PumpPluginAbstract extends PumpPluginBase implements PumpI
|
||||||
this.sp = sp;
|
this.sp = sp;
|
||||||
|
|
||||||
pumpDescription.setPumpDescription(pumpType);
|
pumpDescription.setPumpDescription(pumpType);
|
||||||
|
this.pumpType = pumpType;
|
||||||
initPumpStatusData();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -447,10 +445,34 @@ public abstract class PumpPluginAbstract extends PumpPluginBase implements PumpI
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// removed from dev
|
protected void refreshCustomActionsList() {
|
||||||
// public boolean isLoggingEnabled() {
|
rxBus.send(new EventCustomActionsChanged());
|
||||||
// return L.isEnabled(L.PUMP);
|
}
|
||||||
// }
|
|
||||||
|
|
||||||
|
public ManufacturerType manufacturer() {
|
||||||
|
return pumpType.getManufacturer() ;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public PumpType model() {
|
||||||
|
return pumpType;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public PumpType getPumpType() {
|
||||||
|
return pumpType;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void setPumpType(PumpType pumpType) {
|
||||||
|
this.pumpType = pumpType;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public boolean canHandleDST() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
protected abstract PumpEnactResult deliverBolus(DetailedBolusInfo detailedBolusInfo);
|
protected abstract PumpEnactResult deliverBolus(DetailedBolusInfo detailedBolusInfo);
|
||||||
|
@ -461,37 +483,4 @@ public abstract class PumpPluginAbstract extends PumpPluginBase implements PumpI
|
||||||
return new PumpEnactResult(getInjector()).success(false).enacted(false).comment(getResourceHelper().gs(resourceId));
|
return new PumpEnactResult(getInjector()).success(false).enacted(false).comment(getResourceHelper().gs(resourceId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// removed from dev
|
|
||||||
@Override
|
|
||||||
public boolean canHandleDST() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// removed from dev
|
|
||||||
@Override
|
|
||||||
public ManufacturerType manufacturer() {
|
|
||||||
return pumpStatus.pumpType.getManufacturer();
|
|
||||||
}
|
|
||||||
|
|
||||||
// removed from dev
|
|
||||||
@Override
|
|
||||||
public PumpType model() {
|
|
||||||
return pumpStatus.pumpType;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// removed from dev
|
|
||||||
@Override
|
|
||||||
public void timezoneOrDSTChanged(TimeChangeType timeChangeType) {
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// removed from dev
|
|
||||||
public void refreshCustomActionsList() {
|
|
||||||
rxBus.send(new EventCustomActionsChanged());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,9 +33,9 @@ import static info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyL
|
||||||
*/
|
*/
|
||||||
public abstract class RileyLinkService extends DaggerService {
|
public abstract class RileyLinkService extends DaggerService {
|
||||||
|
|
||||||
@Inject AAPSLogger aapsLogger;
|
@Inject protected AAPSLogger aapsLogger;
|
||||||
@Inject SP sp;
|
@Inject protected SP sp;
|
||||||
@Inject Context context;
|
@Inject protected Context context;
|
||||||
|
|
||||||
|
|
||||||
public RileyLinkBLE rileyLinkBLE; // android-bluetooth management
|
public RileyLinkBLE rileyLinkBLE; // android-bluetooth management
|
||||||
|
@ -48,7 +48,6 @@ public abstract class RileyLinkService extends DaggerService {
|
||||||
@Override
|
@Override
|
||||||
public void onCreate() {
|
public void onCreate() {
|
||||||
super.onCreate();
|
super.onCreate();
|
||||||
//LOG.debug("onCreate");
|
|
||||||
|
|
||||||
RileyLinkUtil.setContext(this.context);
|
RileyLinkUtil.setContext(this.context);
|
||||||
RileyLinkUtil.setRileyLinkService(this);
|
RileyLinkUtil.setRileyLinkService(this);
|
||||||
|
@ -61,8 +60,6 @@ public abstract class RileyLinkService extends DaggerService {
|
||||||
|
|
||||||
bluetoothStateReceiver = new RileyLinkBluetoothStateReceiver();
|
bluetoothStateReceiver = new RileyLinkBluetoothStateReceiver();
|
||||||
bluetoothStateReceiver.registerBroadcasts(this);
|
bluetoothStateReceiver.registerBroadcasts(this);
|
||||||
|
|
||||||
//LOG.debug("onCreate(): It's ALIVE!");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -489,4 +489,5 @@ public abstract class AbstractDanaRPlugin extends PumpPluginBase implements Pump
|
||||||
public void timezoneOrDSTChanged(TimeChangeType timeChangeType) {
|
public void timezoneOrDSTChanged(TimeChangeType timeChangeType) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,8 +27,8 @@ import info.nightscout.androidaps.plugins.pump.danaRKorean.DanaRKoreanPlugin
|
||||||
import info.nightscout.androidaps.queue.events.EventQueueChanged
|
import info.nightscout.androidaps.queue.events.EventQueueChanged
|
||||||
import info.nightscout.androidaps.utils.DateUtil
|
import info.nightscout.androidaps.utils.DateUtil
|
||||||
import info.nightscout.androidaps.utils.FabricPrivacy
|
import info.nightscout.androidaps.utils.FabricPrivacy
|
||||||
import info.nightscout.androidaps.utils.SetWarnColor
|
|
||||||
import info.nightscout.androidaps.utils.T
|
import info.nightscout.androidaps.utils.T
|
||||||
|
import info.nightscout.androidaps.utils.WarnColors
|
||||||
import info.nightscout.androidaps.utils.extensions.plusAssign
|
import info.nightscout.androidaps.utils.extensions.plusAssign
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||||
|
@ -45,6 +45,7 @@ class DanaRFragment : DaggerFragment() {
|
||||||
@Inject lateinit var danaRKoreanPlugin: DanaRKoreanPlugin
|
@Inject lateinit var danaRKoreanPlugin: DanaRKoreanPlugin
|
||||||
@Inject lateinit var danaRPump: DanaRPump
|
@Inject lateinit var danaRPump: DanaRPump
|
||||||
@Inject lateinit var resourceHelper: ResourceHelper
|
@Inject lateinit var resourceHelper: ResourceHelper
|
||||||
|
@Inject lateinit var warnColors: WarnColors
|
||||||
|
|
||||||
private var disposable: CompositeDisposable = CompositeDisposable()
|
private var disposable: CompositeDisposable = CompositeDisposable()
|
||||||
|
|
||||||
|
@ -157,7 +158,7 @@ class DanaRFragment : DaggerFragment() {
|
||||||
val agoMsec = System.currentTimeMillis() - pump.lastConnection
|
val agoMsec = System.currentTimeMillis() - pump.lastConnection
|
||||||
val agoMin = (agoMsec.toDouble() / 60.0 / 1000.0).toInt()
|
val agoMin = (agoMsec.toDouble() / 60.0 / 1000.0).toInt()
|
||||||
danar_lastconnection.text = DateUtil.timeString(pump.lastConnection) + " (" + resourceHelper.gs(R.string.minago, agoMin) + ")"
|
danar_lastconnection.text = DateUtil.timeString(pump.lastConnection) + " (" + resourceHelper.gs(R.string.minago, agoMin) + ")"
|
||||||
SetWarnColor.setColor(danar_lastconnection, agoMin.toDouble(), 16.0, 31.0)
|
warnColors.setColor(danar_lastconnection, agoMin.toDouble(), 16.0, 31.0)
|
||||||
}
|
}
|
||||||
if (pump.lastBolusTime != 0L) {
|
if (pump.lastBolusTime != 0L) {
|
||||||
val agoMsec = System.currentTimeMillis() - pump.lastBolusTime
|
val agoMsec = System.currentTimeMillis() - pump.lastBolusTime
|
||||||
|
@ -170,7 +171,7 @@ class DanaRFragment : DaggerFragment() {
|
||||||
}
|
}
|
||||||
|
|
||||||
danar_dailyunits.text = resourceHelper.gs(R.string.reservoirvalue, pump.dailyTotalUnits, pump.maxDailyTotalUnits)
|
danar_dailyunits.text = resourceHelper.gs(R.string.reservoirvalue, pump.dailyTotalUnits, pump.maxDailyTotalUnits)
|
||||||
SetWarnColor.setColor(danar_dailyunits, pump.dailyTotalUnits, pump.maxDailyTotalUnits * 0.75, pump.maxDailyTotalUnits * 0.9)
|
warnColors.setColor(danar_dailyunits, pump.dailyTotalUnits, pump.maxDailyTotalUnits * 0.75, pump.maxDailyTotalUnits * 0.9)
|
||||||
danar_basabasalrate.text = "( " + (pump.activeProfile + 1) + " ) " + resourceHelper.gs(R.string.pump_basebasalrate, plugin.baseBasalRate)
|
danar_basabasalrate.text = "( " + (pump.activeProfile + 1) + " ) " + resourceHelper.gs(R.string.pump_basebasalrate, plugin.baseBasalRate)
|
||||||
// DanaRPlugin, DanaRKoreanPlugin
|
// DanaRPlugin, DanaRKoreanPlugin
|
||||||
if (activePlugin.activePump.isFakingTempsByExtendedBoluses == true) {
|
if (activePlugin.activePump.isFakingTempsByExtendedBoluses == true) {
|
||||||
|
@ -184,9 +185,9 @@ class DanaRFragment : DaggerFragment() {
|
||||||
danar_extendedbolus.text = activePlugin.activeTreatments.getExtendedBolusFromHistory(System.currentTimeMillis())?.toString()
|
danar_extendedbolus.text = activePlugin.activeTreatments.getExtendedBolusFromHistory(System.currentTimeMillis())?.toString()
|
||||||
?: ""
|
?: ""
|
||||||
danar_reservoir.text = resourceHelper.gs(R.string.reservoirvalue, pump.reservoirRemainingUnits, 300)
|
danar_reservoir.text = resourceHelper.gs(R.string.reservoirvalue, pump.reservoirRemainingUnits, 300)
|
||||||
SetWarnColor.setColorInverse(danar_reservoir, pump.reservoirRemainingUnits, 50.0, 20.0)
|
warnColors.setColorInverse(danar_reservoir, pump.reservoirRemainingUnits, 50.0, 20.0)
|
||||||
danar_battery.text = "{fa-battery-" + pump.batteryRemaining / 25 + "}"
|
danar_battery.text = "{fa-battery-" + pump.batteryRemaining / 25 + "}"
|
||||||
SetWarnColor.setColorInverse(danar_battery, pump.batteryRemaining.toDouble(), 51.0, 26.0)
|
warnColors.setColorInverse(danar_battery, pump.batteryRemaining.toDouble(), 51.0, 26.0)
|
||||||
danar_iob.text = resourceHelper.gs(R.string.formatinsulinunits, pump.iob)
|
danar_iob.text = resourceHelper.gs(R.string.formatinsulinunits, pump.iob)
|
||||||
if (pump.model != 0 || pump.protocol != 0 || pump.productCode != 0) {
|
if (pump.model != 0 || pump.protocol != 0 || pump.productCode != 0) {
|
||||||
danar_firmware.text = resourceHelper.gs(R.string.danar_model, pump.model, pump.protocol, pump.productCode)
|
danar_firmware.text = resourceHelper.gs(R.string.danar_model, pump.model, pump.protocol, pump.productCode)
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
||||||
|
|
||||||
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
||||||
import info.nightscout.androidaps.interfaces.CommandQueueProvider
|
import info.nightscout.androidaps.interfaces.CommandQueueProvider
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
|
@ -25,7 +26,8 @@ class MessageHashTableR @Inject constructor(
|
||||||
danaRKoreanPlugin: DanaRKoreanPlugin,
|
danaRKoreanPlugin: DanaRKoreanPlugin,
|
||||||
configBuilderPlugin: ConfigBuilderPlugin,
|
configBuilderPlugin: ConfigBuilderPlugin,
|
||||||
commandQueue: CommandQueueProvider,
|
commandQueue: CommandQueueProvider,
|
||||||
activePlugin: ActivePluginProvider
|
activePlugin: ActivePluginProvider,
|
||||||
|
injector: HasAndroidInjector
|
||||||
) : MessageHashTableBase {
|
) : MessageHashTableBase {
|
||||||
|
|
||||||
var messages: HashMap<Int, MessageBase> = HashMap()
|
var messages: HashMap<Int, MessageBase> = HashMap()
|
||||||
|
@ -36,7 +38,7 @@ class MessageHashTableR @Inject constructor(
|
||||||
put(MsgBolusStartWithSpeed(aapsLogger, constraintChecker, danaRPump, 0.0, 0)) // 0x0104 CMD_MEALINS_START_DATA_SPEED
|
put(MsgBolusStartWithSpeed(aapsLogger, constraintChecker, danaRPump, 0.0, 0)) // 0x0104 CMD_MEALINS_START_DATA_SPEED
|
||||||
put(MsgBolusProgress(aapsLogger, resourceHelper, rxBus, danaRPump)) // 0x0202 CMD_PUMP_THIS_REMAINDER_MEAL_INS
|
put(MsgBolusProgress(aapsLogger, resourceHelper, rxBus, danaRPump)) // 0x0202 CMD_PUMP_THIS_REMAINDER_MEAL_INS
|
||||||
put(MsgStatusProfile(aapsLogger, danaRPump)) // 0x0204 CMD_PUMP_CALCULATION_SETTING
|
put(MsgStatusProfile(aapsLogger, danaRPump)) // 0x0204 CMD_PUMP_CALCULATION_SETTING
|
||||||
put(MsgStatusTempBasal(aapsLogger, danaRPump, activePlugin)) // 0x0205 CMD_PUMP_EXERCISE_MODE
|
put(MsgStatusTempBasal(aapsLogger, danaRPump, activePlugin, injector)) // 0x0205 CMD_PUMP_EXERCISE_MODE
|
||||||
put(MsgStatusBolusExtended(aapsLogger, danaRPump, activePlugin)) // 0x0207 CMD_PUMP_EXPANS_INS_I
|
put(MsgStatusBolusExtended(aapsLogger, danaRPump, activePlugin)) // 0x0207 CMD_PUMP_EXPANS_INS_I
|
||||||
put(MsgStatusBasic(aapsLogger, danaRPump)) // 0x020A CMD_PUMP_INITVIEW_I
|
put(MsgStatusBasic(aapsLogger, danaRPump)) // 0x020A CMD_PUMP_INITVIEW_I
|
||||||
put(MsgStatus(aapsLogger, danaRPump)) // 0x020B CMD_PUMP_STATUS
|
put(MsgStatus(aapsLogger, danaRPump)) // 0x020B CMD_PUMP_STATUS
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
||||||
|
|
||||||
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.androidaps.db.Source
|
import info.nightscout.androidaps.db.Source
|
||||||
import info.nightscout.androidaps.db.TemporaryBasal
|
import info.nightscout.androidaps.db.TemporaryBasal
|
||||||
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
||||||
|
@ -11,7 +12,8 @@ import kotlin.math.ceil
|
||||||
class MsgStatusTempBasal(
|
class MsgStatusTempBasal(
|
||||||
private val aapsLogger: AAPSLogger,
|
private val aapsLogger: AAPSLogger,
|
||||||
private val danaRPump: DanaRPump,
|
private val danaRPump: DanaRPump,
|
||||||
private val activePlugin: ActivePluginProvider
|
private val activePlugin: ActivePluginProvider,
|
||||||
|
private val injector: HasAndroidInjector
|
||||||
) : MessageBase() {
|
) : MessageBase() {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
|
@ -52,10 +54,10 @@ class MsgStatusTempBasal(
|
||||||
val tempBasal = activePlugin.activeTreatments.getRealTempBasalFromHistory(System.currentTimeMillis())
|
val tempBasal = activePlugin.activeTreatments.getRealTempBasalFromHistory(System.currentTimeMillis())
|
||||||
if (danaRPump.isTempBasalInProgress) {
|
if (danaRPump.isTempBasalInProgress) {
|
||||||
if (tempBasal.percentRate != danaRPump.tempBasalPercent) { // Close current temp basal
|
if (tempBasal.percentRate != danaRPump.tempBasalPercent) { // Close current temp basal
|
||||||
val tempStop = TemporaryBasal().date(danaRPump.tempBasalStart - 1000).source(Source.USER)
|
val tempStop = TemporaryBasal(injector).date(danaRPump.tempBasalStart - 1000).source(Source.USER)
|
||||||
activePlugin.activeTreatments.addToHistoryTempBasal(tempStop)
|
activePlugin.activeTreatments.addToHistoryTempBasal(tempStop)
|
||||||
// Create new
|
// Create new
|
||||||
val newTempBasal = TemporaryBasal()
|
val newTempBasal = TemporaryBasal(injector)
|
||||||
.date(danaRPump.tempBasalStart)
|
.date(danaRPump.tempBasalStart)
|
||||||
.percent(danaRPump.tempBasalPercent)
|
.percent(danaRPump.tempBasalPercent)
|
||||||
.duration(danaRPump.tempBasalTotalSec / 60)
|
.duration(danaRPump.tempBasalTotalSec / 60)
|
||||||
|
@ -63,12 +65,12 @@ class MsgStatusTempBasal(
|
||||||
activePlugin.activeTreatments.addToHistoryTempBasal(newTempBasal)
|
activePlugin.activeTreatments.addToHistoryTempBasal(newTempBasal)
|
||||||
}
|
}
|
||||||
} else { // Close current temp basal
|
} else { // Close current temp basal
|
||||||
val tempStop = TemporaryBasal().date(now).source(Source.USER)
|
val tempStop = TemporaryBasal(injector).date(now).source(Source.USER)
|
||||||
activePlugin.activeTreatments.addToHistoryTempBasal(tempStop)
|
activePlugin.activeTreatments.addToHistoryTempBasal(tempStop)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (danaRPump.isTempBasalInProgress) { // Create new
|
if (danaRPump.isTempBasalInProgress) { // Create new
|
||||||
val newTempBasal = TemporaryBasal()
|
val newTempBasal = TemporaryBasal(injector)
|
||||||
.date(danaRPump.tempBasalStart)
|
.date(danaRPump.tempBasalStart)
|
||||||
.percent(danaRPump.tempBasalPercent)
|
.percent(danaRPump.tempBasalPercent)
|
||||||
.duration(danaRPump.tempBasalTotalSec / 60)
|
.duration(danaRPump.tempBasalTotalSec / 60)
|
||||||
|
|
|
@ -55,7 +55,7 @@ import io.reactivex.schedulers.Schedulers;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public abstract class AbstractDanaRExecutionService extends DaggerService {
|
public abstract class AbstractDanaRExecutionService extends DaggerService {
|
||||||
@Inject HasAndroidInjector injector;
|
@Inject protected HasAndroidInjector injector;
|
||||||
@Inject AAPSLogger aapsLogger;
|
@Inject AAPSLogger aapsLogger;
|
||||||
@Inject RxBusWrapper rxBus;
|
@Inject RxBusWrapper rxBus;
|
||||||
@Inject SP sp;
|
@Inject SP sp;
|
||||||
|
|
|
@ -11,6 +11,7 @@ import java.util.Date;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
|
import dagger.android.HasAndroidInjector;
|
||||||
import info.nightscout.androidaps.Constants;
|
import info.nightscout.androidaps.Constants;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.data.Profile;
|
import info.nightscout.androidaps.data.Profile;
|
||||||
|
@ -91,6 +92,7 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService {
|
||||||
@Inject ActivePluginProvider activePlugin;
|
@Inject ActivePluginProvider activePlugin;
|
||||||
@Inject ProfileFunction profileFunction;
|
@Inject ProfileFunction profileFunction;
|
||||||
@Inject SP sp;
|
@Inject SP sp;
|
||||||
|
@Inject HasAndroidInjector injector;
|
||||||
|
|
||||||
public DanaRExecutionService() {
|
public DanaRExecutionService() {
|
||||||
}
|
}
|
||||||
|
@ -147,7 +149,7 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService {
|
||||||
rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.gettingpumpstatus)));
|
rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.gettingpumpstatus)));
|
||||||
MsgStatus statusMsg = new MsgStatus(aapsLogger, danaRPump);
|
MsgStatus statusMsg = new MsgStatus(aapsLogger, danaRPump);
|
||||||
MsgStatusBasic statusBasicMsg = new MsgStatusBasic(aapsLogger, danaRPump);
|
MsgStatusBasic statusBasicMsg = new MsgStatusBasic(aapsLogger, danaRPump);
|
||||||
MsgStatusTempBasal tempStatusMsg = new MsgStatusTempBasal(aapsLogger, danaRPump, activePlugin);
|
MsgStatusTempBasal tempStatusMsg = new MsgStatusTempBasal(aapsLogger, danaRPump, activePlugin, injector);
|
||||||
MsgStatusBolusExtended exStatusMsg = new MsgStatusBolusExtended(aapsLogger, danaRPump, activePlugin);
|
MsgStatusBolusExtended exStatusMsg = new MsgStatusBolusExtended(aapsLogger, danaRPump, activePlugin);
|
||||||
MsgCheckValue checkValue = new MsgCheckValue(aapsLogger, danaRPump, danaRPlugin);
|
MsgCheckValue checkValue = new MsgCheckValue(aapsLogger, danaRPump, danaRPlugin);
|
||||||
|
|
||||||
|
@ -239,7 +241,7 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService {
|
||||||
}
|
}
|
||||||
rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.settingtempbasal)));
|
rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.settingtempbasal)));
|
||||||
mSerialIOThread.sendMessage(new MsgSetTempBasalStart(aapsLogger, percent, durationInHours));
|
mSerialIOThread.sendMessage(new MsgSetTempBasalStart(aapsLogger, percent, durationInHours));
|
||||||
mSerialIOThread.sendMessage(new MsgStatusTempBasal(aapsLogger, danaRPump, activePlugin));
|
mSerialIOThread.sendMessage(new MsgStatusTempBasal(aapsLogger, danaRPump, activePlugin, injector));
|
||||||
rxBus.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING));
|
rxBus.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -248,7 +250,7 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService {
|
||||||
if (!isConnected()) return false;
|
if (!isConnected()) return false;
|
||||||
rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.stoppingtempbasal)));
|
rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.stoppingtempbasal)));
|
||||||
mSerialIOThread.sendMessage(new MsgSetTempBasalStop(aapsLogger));
|
mSerialIOThread.sendMessage(new MsgSetTempBasalStop(aapsLogger));
|
||||||
mSerialIOThread.sendMessage(new MsgStatusTempBasal(aapsLogger, danaRPump, activePlugin));
|
mSerialIOThread.sendMessage(new MsgStatusTempBasal(aapsLogger, danaRPump, activePlugin, injector));
|
||||||
rxBus.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING));
|
rxBus.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaRKorean.comm
|
package info.nightscout.androidaps.plugins.pump.danaRKorean.comm
|
||||||
|
|
||||||
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
||||||
import info.nightscout.androidaps.interfaces.CommandQueueProvider
|
import info.nightscout.androidaps.interfaces.CommandQueueProvider
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
|
@ -26,7 +27,8 @@ class MessageHashTableRKorean @Inject constructor(
|
||||||
danaRKoreanPlugin: DanaRKoreanPlugin,
|
danaRKoreanPlugin: DanaRKoreanPlugin,
|
||||||
configBuilderPlugin: ConfigBuilderPlugin,
|
configBuilderPlugin: ConfigBuilderPlugin,
|
||||||
commandQueue: CommandQueueProvider,
|
commandQueue: CommandQueueProvider,
|
||||||
activePlugin: ActivePluginProvider
|
activePlugin: ActivePluginProvider,
|
||||||
|
injector: HasAndroidInjector
|
||||||
) : MessageHashTableBase {
|
) : MessageHashTableBase {
|
||||||
|
|
||||||
var messages: HashMap<Int, MessageBase> = HashMap()
|
var messages: HashMap<Int, MessageBase> = HashMap()
|
||||||
|
@ -36,7 +38,7 @@ class MessageHashTableRKorean @Inject constructor(
|
||||||
put(MsgBolusStart(aapsLogger, constraintChecker, danaRPump, 0.0)) // 0x0102 CMD_MEALINS_START_DATA
|
put(MsgBolusStart(aapsLogger, constraintChecker, danaRPump, 0.0)) // 0x0102 CMD_MEALINS_START_DATA
|
||||||
put(MsgBolusProgress(aapsLogger, resourceHelper, rxBus, danaRPump)) // 0x0202 CMD_PUMP_THIS_REMAINDER_MEAL_INS
|
put(MsgBolusProgress(aapsLogger, resourceHelper, rxBus, danaRPump)) // 0x0202 CMD_PUMP_THIS_REMAINDER_MEAL_INS
|
||||||
put(MsgStatusProfile(aapsLogger, danaRPump)) // 0x0204 CMD_PUMP_CALCULATION_SETTING
|
put(MsgStatusProfile(aapsLogger, danaRPump)) // 0x0204 CMD_PUMP_CALCULATION_SETTING
|
||||||
put(MsgStatusTempBasal(aapsLogger, danaRPump, activePlugin)) // 0x0205 CMD_PUMP_EXERCISE_MODE
|
put(MsgStatusTempBasal(aapsLogger, danaRPump, activePlugin, injector)) // 0x0205 CMD_PUMP_EXERCISE_MODE
|
||||||
put(MsgStatusBolusExtended(aapsLogger, danaRPump, activePlugin)) // 0x0207 CMD_PUMP_EXPANS_INS_I
|
put(MsgStatusBolusExtended(aapsLogger, danaRPump, activePlugin)) // 0x0207 CMD_PUMP_EXPANS_INS_I
|
||||||
put(MsgStatusBasic_k(aapsLogger, danaRPump)) // 0x020A CMD_PUMP_INITVIEW_I
|
put(MsgStatusBasic_k(aapsLogger, danaRPump)) // 0x020A CMD_PUMP_INITVIEW_I
|
||||||
put(MsgStatus_k(aapsLogger, danaRPump)) // 0x020B CMD_PUMP_STATUS
|
put(MsgStatus_k(aapsLogger, danaRPump)) // 0x020B CMD_PUMP_STATUS
|
||||||
|
|
|
@ -138,7 +138,7 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService {
|
||||||
rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.gettingpumpstatus)));
|
rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.gettingpumpstatus)));
|
||||||
//MsgStatus_k statusMsg = new MsgStatus_k();
|
//MsgStatus_k statusMsg = new MsgStatus_k();
|
||||||
MsgStatusBasic_k statusBasicMsg = new MsgStatusBasic_k(aapsLogger, danaRPump);
|
MsgStatusBasic_k statusBasicMsg = new MsgStatusBasic_k(aapsLogger, danaRPump);
|
||||||
MsgStatusTempBasal tempStatusMsg = new MsgStatusTempBasal(aapsLogger, danaRPump, activePlugin);
|
MsgStatusTempBasal tempStatusMsg = new MsgStatusTempBasal(aapsLogger, danaRPump, activePlugin, injector);
|
||||||
MsgStatusBolusExtended exStatusMsg = new MsgStatusBolusExtended(aapsLogger, danaRPump, activePlugin);
|
MsgStatusBolusExtended exStatusMsg = new MsgStatusBolusExtended(aapsLogger, danaRPump, activePlugin);
|
||||||
MsgCheckValue_k checkValue = new MsgCheckValue_k(aapsLogger, danaRPump, danaRKoreanPlugin);
|
MsgCheckValue_k checkValue = new MsgCheckValue_k(aapsLogger, danaRPump, danaRKoreanPlugin);
|
||||||
|
|
||||||
|
@ -228,7 +228,7 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService {
|
||||||
}
|
}
|
||||||
rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.settingtempbasal)));
|
rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.settingtempbasal)));
|
||||||
mSerialIOThread.sendMessage(new MsgSetTempBasalStart(aapsLogger, percent, durationInHours));
|
mSerialIOThread.sendMessage(new MsgSetTempBasalStart(aapsLogger, percent, durationInHours));
|
||||||
mSerialIOThread.sendMessage(new MsgStatusTempBasal(aapsLogger, danaRPump, activePlugin));
|
mSerialIOThread.sendMessage(new MsgStatusTempBasal(aapsLogger, danaRPump, activePlugin, injector));
|
||||||
rxBus.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING));
|
rxBus.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -237,7 +237,7 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService {
|
||||||
if (!isConnected()) return false;
|
if (!isConnected()) return false;
|
||||||
rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.stoppingtempbasal)));
|
rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.stoppingtempbasal)));
|
||||||
mSerialIOThread.sendMessage(new MsgSetTempBasalStop(aapsLogger));
|
mSerialIOThread.sendMessage(new MsgSetTempBasalStop(aapsLogger));
|
||||||
mSerialIOThread.sendMessage(new MsgStatusTempBasal(aapsLogger, danaRPump, activePlugin));
|
mSerialIOThread.sendMessage(new MsgStatusTempBasal(aapsLogger, danaRPump, activePlugin, injector));
|
||||||
rxBus.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING));
|
rxBus.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
||||||
|
|
||||||
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
|
@ -21,7 +22,8 @@ class DanaRSMessageHashTable @Inject constructor(
|
||||||
danaRSPlugin: DanaRSPlugin,
|
danaRSPlugin: DanaRSPlugin,
|
||||||
activePlugin: ActivePluginProvider,
|
activePlugin: ActivePluginProvider,
|
||||||
constraintChecker: ConstraintChecker,
|
constraintChecker: ConstraintChecker,
|
||||||
detailedBolusInfoStorage: DetailedBolusInfoStorage
|
detailedBolusInfoStorage: DetailedBolusInfoStorage,
|
||||||
|
injector: HasAndroidInjector
|
||||||
) {
|
) {
|
||||||
|
|
||||||
var messages: HashMap<Int, DanaRS_Packet> = HashMap()
|
var messages: HashMap<Int, DanaRS_Packet> = HashMap()
|
||||||
|
@ -99,7 +101,7 @@ class DanaRSMessageHashTable @Inject constructor(
|
||||||
put(DanaRS_Packet_History_Temporary(aapsLogger, rxBus))
|
put(DanaRS_Packet_History_Temporary(aapsLogger, rxBus))
|
||||||
// APS
|
// APS
|
||||||
put(DanaRS_Packet_APS_Basal_Set_Temporary_Basal(aapsLogger, 0))
|
put(DanaRS_Packet_APS_Basal_Set_Temporary_Basal(aapsLogger, 0))
|
||||||
put(DanaRS_Packet_APS_History_Events(aapsLogger, rxBus, resourceHelper, activePlugin, danaRSPlugin, detailedBolusInfoStorage, 0))
|
put(DanaRS_Packet_APS_History_Events(aapsLogger, rxBus, resourceHelper, activePlugin, danaRSPlugin, detailedBolusInfoStorage, injector,0))
|
||||||
put(DanaRS_Packet_APS_Set_Event_History(aapsLogger, 0, 0, 0, 0))
|
put(DanaRS_Packet_APS_Set_Event_History(aapsLogger, 0, 0, 0, 0))
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,6 +1,7 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
||||||
|
|
||||||
import com.cozmo.danar.util.BleCommandUtil
|
import com.cozmo.danar.util.BleCommandUtil
|
||||||
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.androidaps.R
|
import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.data.DetailedBolusInfo
|
import info.nightscout.androidaps.data.DetailedBolusInfo
|
||||||
import info.nightscout.androidaps.db.ExtendedBolus
|
import info.nightscout.androidaps.db.ExtendedBolus
|
||||||
|
@ -25,6 +26,7 @@ open class DanaRS_Packet_APS_History_Events(
|
||||||
private val activePlugin: ActivePluginProvider,
|
private val activePlugin: ActivePluginProvider,
|
||||||
private val danaRSPlugin: DanaRSPlugin,
|
private val danaRSPlugin: DanaRSPlugin,
|
||||||
private val detailedBolusInfoStorage: DetailedBolusInfoStorage,
|
private val detailedBolusInfoStorage: DetailedBolusInfoStorage,
|
||||||
|
private val injector: HasAndroidInjector,
|
||||||
private var from: Long
|
private var from: Long
|
||||||
) : DanaRS_Packet() {
|
) : DanaRS_Packet() {
|
||||||
|
|
||||||
|
@ -75,7 +77,7 @@ open class DanaRS_Packet_APS_History_Events(
|
||||||
val datetime = dateTimeSecFromBuff(data, 1) // 6 bytes
|
val datetime = dateTimeSecFromBuff(data, 1) // 6 bytes
|
||||||
val param1 = (intFromBuff(data, 7, 1) shl 8 and 0xFF00) + (intFromBuff(data, 8, 1) and 0xFF)
|
val param1 = (intFromBuff(data, 7, 1) shl 8 and 0xFF00) + (intFromBuff(data, 8, 1) and 0xFF)
|
||||||
val param2 = (intFromBuff(data, 9, 1) shl 8 and 0xFF00) + (intFromBuff(data, 10, 1) and 0xFF)
|
val param2 = (intFromBuff(data, 9, 1) shl 8 and 0xFF00) + (intFromBuff(data, 10, 1) and 0xFF)
|
||||||
val temporaryBasal = TemporaryBasal().date(datetime).source(Source.PUMP).pumpId(datetime)
|
val temporaryBasal = TemporaryBasal(injector).date(datetime).source(Source.PUMP).pumpId(datetime)
|
||||||
val extendedBolus = ExtendedBolus().date(datetime).source(Source.PUMP).pumpId(datetime)
|
val extendedBolus = ExtendedBolus().date(datetime).source(Source.PUMP).pumpId(datetime)
|
||||||
val status: String
|
val status: String
|
||||||
when (recordCode.toInt()) {
|
when (recordCode.toInt()) {
|
||||||
|
|
|
@ -271,10 +271,10 @@ public class DanaRSService extends DaggerService {
|
||||||
|
|
||||||
DanaRS_Packet_APS_History_Events msg;
|
DanaRS_Packet_APS_History_Events msg;
|
||||||
if (lastHistoryFetched == 0) {
|
if (lastHistoryFetched == 0) {
|
||||||
msg = new DanaRS_Packet_APS_History_Events(aapsLogger, rxBus, resourceHelper, activePlugin, danaRSPlugin, detailedBolusInfoStorage, 0);
|
msg = new DanaRS_Packet_APS_History_Events(aapsLogger, rxBus, resourceHelper, activePlugin, danaRSPlugin, detailedBolusInfoStorage, injector, 0);
|
||||||
aapsLogger.debug(LTag.PUMPCOMM, "Loading complete event history");
|
aapsLogger.debug(LTag.PUMPCOMM, "Loading complete event history");
|
||||||
} else {
|
} else {
|
||||||
msg = new DanaRS_Packet_APS_History_Events(aapsLogger, rxBus, resourceHelper, activePlugin, danaRSPlugin, detailedBolusInfoStorage, lastHistoryFetched);
|
msg = new DanaRS_Packet_APS_History_Events(aapsLogger, rxBus, resourceHelper, activePlugin, danaRSPlugin, detailedBolusInfoStorage, injector, lastHistoryFetched);
|
||||||
aapsLogger.debug(LTag.PUMPCOMM, "Loading event history from: " + DateUtil.dateAndTimeString(lastHistoryFetched));
|
aapsLogger.debug(LTag.PUMPCOMM, "Loading event history from: " + DateUtil.dateAndTimeString(lastHistoryFetched));
|
||||||
}
|
}
|
||||||
bleComm.sendMessage(msg);
|
bleComm.sendMessage(msg);
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaRv2.comm
|
package info.nightscout.androidaps.plugins.pump.danaRv2.comm
|
||||||
|
|
||||||
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
||||||
import info.nightscout.androidaps.interfaces.CommandQueueProvider
|
import info.nightscout.androidaps.interfaces.CommandQueueProvider
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
|
@ -32,7 +33,8 @@ class MessageHashTableRv2 @Inject constructor(
|
||||||
commandQueue: CommandQueueProvider,
|
commandQueue: CommandQueueProvider,
|
||||||
activePlugin: ActivePluginProvider,
|
activePlugin: ActivePluginProvider,
|
||||||
detailedBolusInfoStorage: DetailedBolusInfoStorage,
|
detailedBolusInfoStorage: DetailedBolusInfoStorage,
|
||||||
treatmentsPlugin: TreatmentsPlugin
|
treatmentsPlugin: TreatmentsPlugin,
|
||||||
|
injector: HasAndroidInjector
|
||||||
) : MessageHashTableBase {
|
) : MessageHashTableBase {
|
||||||
|
|
||||||
var messages: HashMap<Int, MessageBase> = HashMap()
|
var messages: HashMap<Int, MessageBase> = HashMap()
|
||||||
|
@ -91,7 +93,7 @@ class MessageHashTableRv2 @Inject constructor(
|
||||||
put(MsgCheckValue_v2(aapsLogger, rxBus, resourceHelper, danaRPump, danaRPlugin, danaRKoreanPlugin, danaRv2Plugin, configBuilderPlugin, commandQueue)) // 0xF0F1 CMD_PUMP_CHECK_VALUE
|
put(MsgCheckValue_v2(aapsLogger, rxBus, resourceHelper, danaRPump, danaRPlugin, danaRKoreanPlugin, danaRv2Plugin, configBuilderPlugin, commandQueue)) // 0xF0F1 CMD_PUMP_CHECK_VALUE
|
||||||
put(MsgStatusAPS_v2(aapsLogger, danaRPump)) // 0xE001 CMD_PUMPSTATUS_APS
|
put(MsgStatusAPS_v2(aapsLogger, danaRPump)) // 0xE001 CMD_PUMPSTATUS_APS
|
||||||
put(MsgSetAPSTempBasalStart_v2(aapsLogger, 0, false, false)) // 0xE002 CMD_PUMPSET_APSTEMP
|
put(MsgSetAPSTempBasalStart_v2(aapsLogger, 0, false, false)) // 0xE002 CMD_PUMPSET_APSTEMP
|
||||||
put(MsgHistoryEvents_v2(aapsLogger, resourceHelper, detailedBolusInfoStorage, danaRv2Plugin, rxBus, treatmentsPlugin)) // 0xE003 CMD_GET_HISTORY
|
put(MsgHistoryEvents_v2(aapsLogger, resourceHelper, detailedBolusInfoStorage, danaRv2Plugin, rxBus, treatmentsPlugin, injector)) // 0xE003 CMD_GET_HISTORY
|
||||||
put(MsgSetHistoryEntry_v2(aapsLogger, 0, 0, 0, 0)) // 0xE004 CMD_SET_HISTORY_ENTRY
|
put(MsgSetHistoryEntry_v2(aapsLogger, 0, 0, 0, 0)) // 0xE004 CMD_SET_HISTORY_ENTRY
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaRv2.comm
|
package info.nightscout.androidaps.plugins.pump.danaRv2.comm
|
||||||
|
|
||||||
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.androidaps.R
|
import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.data.DetailedBolusInfo
|
import info.nightscout.androidaps.data.DetailedBolusInfo
|
||||||
import info.nightscout.androidaps.db.ExtendedBolus
|
import info.nightscout.androidaps.db.ExtendedBolus
|
||||||
|
@ -25,6 +26,7 @@ class MsgHistoryEvents_v2 constructor(
|
||||||
val danaRv2Plugin: DanaRv2Plugin,
|
val danaRv2Plugin: DanaRv2Plugin,
|
||||||
val rxBus: RxBusWrapper,
|
val rxBus: RxBusWrapper,
|
||||||
val treatmentsPlugin: TreatmentsPlugin,
|
val treatmentsPlugin: TreatmentsPlugin,
|
||||||
|
private val injector: HasAndroidInjector,
|
||||||
var from: Long = 0
|
var from: Long = 0
|
||||||
) : MessageBase() {
|
) : MessageBase() {
|
||||||
|
|
||||||
|
@ -61,7 +63,7 @@ class MsgHistoryEvents_v2 constructor(
|
||||||
val datetime = dateTimeSecFromBuff(bytes, 1) // 6 bytes
|
val datetime = dateTimeSecFromBuff(bytes, 1) // 6 bytes
|
||||||
val param1 = intFromBuff(bytes, 7, 2)
|
val param1 = intFromBuff(bytes, 7, 2)
|
||||||
val param2 = intFromBuff(bytes, 9, 2)
|
val param2 = intFromBuff(bytes, 9, 2)
|
||||||
val temporaryBasal = TemporaryBasal()
|
val temporaryBasal = TemporaryBasal(injector)
|
||||||
.date(datetime)
|
.date(datetime)
|
||||||
.source(Source.PUMP)
|
.source(Source.PUMP)
|
||||||
.pumpId(datetime)
|
.pumpId(datetime)
|
||||||
|
|
|
@ -455,7 +455,7 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
|
||||||
if (!isConnected())
|
if (!isConnected())
|
||||||
return new PumpEnactResult(injector).success(false);
|
return new PumpEnactResult(injector).success(false);
|
||||||
SystemClock.sleep(300);
|
SystemClock.sleep(300);
|
||||||
MsgHistoryEvents_v2 msg = new MsgHistoryEvents_v2(aapsLogger, resourceHelper, detailedBolusInfoStorage, danaRv2Plugin, rxBus, treatmentsPlugin, lastHistoryFetched);
|
MsgHistoryEvents_v2 msg = new MsgHistoryEvents_v2(aapsLogger, resourceHelper, detailedBolusInfoStorage, danaRv2Plugin, rxBus, treatmentsPlugin, injector, lastHistoryFetched);
|
||||||
aapsLogger.debug(LTag.PUMP, "Loading event history from: " + DateUtil.dateAndTimeString(lastHistoryFetched));
|
aapsLogger.debug(LTag.PUMP, "Loading event history from: " + DateUtil.dateAndTimeString(lastHistoryFetched));
|
||||||
|
|
||||||
mSerialIOThread.sendMessage(msg);
|
mSerialIOThread.sendMessage(msg);
|
||||||
|
|
|
@ -1230,7 +1230,7 @@ public class LocalInsightPlugin extends PumpPluginBase implements PumpInterface,
|
||||||
InsightPumpID stoppedEvent = MainApp.getDbHelper().getPumpStoppedEvent(pumpID.pumpSerial, pumpID.timestamp);
|
InsightPumpID stoppedEvent = MainApp.getDbHelper().getPumpStoppedEvent(pumpID.pumpSerial, pumpID.timestamp);
|
||||||
if (stoppedEvent == null || stoppedEvent.eventType.equals("PumpPaused")) continue;
|
if (stoppedEvent == null || stoppedEvent.eventType.equals("PumpPaused")) continue;
|
||||||
long tbrStart = stoppedEvent.timestamp + 10000;
|
long tbrStart = stoppedEvent.timestamp + 10000;
|
||||||
TemporaryBasal temporaryBasal = new TemporaryBasal();
|
TemporaryBasal temporaryBasal = new TemporaryBasal(getInjector());
|
||||||
temporaryBasal.durationInMinutes = (int) ((pumpID.timestamp - tbrStart) / 60000);
|
temporaryBasal.durationInMinutes = (int) ((pumpID.timestamp - tbrStart) / 60000);
|
||||||
temporaryBasal.date = tbrStart;
|
temporaryBasal.date = tbrStart;
|
||||||
temporaryBasal.source = Source.PUMP;
|
temporaryBasal.source = Source.PUMP;
|
||||||
|
@ -1356,7 +1356,7 @@ public class LocalInsightPlugin extends PumpPluginBase implements PumpInterface,
|
||||||
pumpID.timestamp = timestamp;
|
pumpID.timestamp = timestamp;
|
||||||
pumpID.eventType = "StartOfTBR";
|
pumpID.eventType = "StartOfTBR";
|
||||||
MainApp.getDbHelper().createOrUpdate(pumpID);
|
MainApp.getDbHelper().createOrUpdate(pumpID);
|
||||||
TemporaryBasal temporaryBasal = new TemporaryBasal();
|
TemporaryBasal temporaryBasal = new TemporaryBasal(getInjector());
|
||||||
temporaryBasal.durationInMinutes = event.getDuration();
|
temporaryBasal.durationInMinutes = event.getDuration();
|
||||||
temporaryBasal.source = Source.PUMP;
|
temporaryBasal.source = Source.PUMP;
|
||||||
temporaryBasal.pumpId = pumpID.id;
|
temporaryBasal.pumpId = pumpID.id;
|
||||||
|
@ -1375,7 +1375,7 @@ public class LocalInsightPlugin extends PumpPluginBase implements PumpInterface,
|
||||||
pumpID.eventType = "EndOfTBR";
|
pumpID.eventType = "EndOfTBR";
|
||||||
pumpID.timestamp = timestamp;
|
pumpID.timestamp = timestamp;
|
||||||
MainApp.getDbHelper().createOrUpdate(pumpID);
|
MainApp.getDbHelper().createOrUpdate(pumpID);
|
||||||
TemporaryBasal temporaryBasal = new TemporaryBasal();
|
TemporaryBasal temporaryBasal = new TemporaryBasal(getInjector());
|
||||||
temporaryBasal.durationInMinutes = 0;
|
temporaryBasal.durationInMinutes = 0;
|
||||||
temporaryBasal.source = Source.PUMP;
|
temporaryBasal.source = Source.PUMP;
|
||||||
temporaryBasal.pumpId = pumpID.id;
|
temporaryBasal.pumpId = pumpID.id;
|
||||||
|
@ -1573,7 +1573,7 @@ public class LocalInsightPlugin extends PumpPluginBase implements PumpInterface,
|
||||||
data.put("created_at", DateUtil.toISOString(date));
|
data.put("created_at", DateUtil.toISOString(date));
|
||||||
data.put("eventType", CareportalEvent.NOTE);
|
data.put("eventType", CareportalEvent.NOTE);
|
||||||
data.put("notes", note);
|
data.put("notes", note);
|
||||||
CareportalEvent careportalEvent = new CareportalEvent();
|
CareportalEvent careportalEvent = new CareportalEvent(getInjector());
|
||||||
careportalEvent.date = date;
|
careportalEvent.date = date;
|
||||||
careportalEvent.source = Source.USER;
|
careportalEvent.source = Source.USER;
|
||||||
careportalEvent.eventType = CareportalEvent.NOTE;
|
careportalEvent.eventType = CareportalEvent.NOTE;
|
||||||
|
@ -1607,7 +1607,7 @@ public class LocalInsightPlugin extends PumpPluginBase implements PumpInterface,
|
||||||
if (!enteredBy.equals("")) data.put("enteredBy", enteredBy);
|
if (!enteredBy.equals("")) data.put("enteredBy", enteredBy);
|
||||||
data.put("created_at", DateUtil.toISOString(date));
|
data.put("created_at", DateUtil.toISOString(date));
|
||||||
data.put("eventType", event);
|
data.put("eventType", event);
|
||||||
CareportalEvent careportalEvent = new CareportalEvent();
|
CareportalEvent careportalEvent = new CareportalEvent(getInjector());
|
||||||
careportalEvent.date = date;
|
careportalEvent.date = date;
|
||||||
careportalEvent.source = Source.USER;
|
careportalEvent.source = Source.USER;
|
||||||
careportalEvent.eventType = event;
|
careportalEvent.eventType = event;
|
||||||
|
|
|
@ -38,8 +38,8 @@ import info.nightscout.androidaps.queue.events.EventQueueChanged
|
||||||
import info.nightscout.androidaps.utils.DateUtil
|
import info.nightscout.androidaps.utils.DateUtil
|
||||||
import info.nightscout.androidaps.utils.FabricPrivacy
|
import info.nightscout.androidaps.utils.FabricPrivacy
|
||||||
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
|
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
|
||||||
import info.nightscout.androidaps.utils.SetWarnColor
|
|
||||||
import info.nightscout.androidaps.utils.T
|
import info.nightscout.androidaps.utils.T
|
||||||
|
import info.nightscout.androidaps.utils.WarnColors
|
||||||
import info.nightscout.androidaps.utils.extensions.plusAssign
|
import info.nightscout.androidaps.utils.extensions.plusAssign
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||||
|
@ -56,6 +56,7 @@ class MedtronicFragment : DaggerFragment() {
|
||||||
@Inject lateinit var commandQueue: CommandQueueProvider
|
@Inject lateinit var commandQueue: CommandQueueProvider
|
||||||
@Inject lateinit var activePlugin: ActivePluginProvider
|
@Inject lateinit var activePlugin: ActivePluginProvider
|
||||||
@Inject lateinit var medtronicPumpPlugin: MedtronicPumpPlugin
|
@Inject lateinit var medtronicPumpPlugin: MedtronicPumpPlugin
|
||||||
|
@Inject lateinit var warnColors: WarnColors
|
||||||
|
|
||||||
private var disposable: CompositeDisposable = CompositeDisposable()
|
private var disposable: CompositeDisposable = CompositeDisposable()
|
||||||
|
|
||||||
|
@ -325,11 +326,11 @@ class MedtronicFragment : DaggerFragment() {
|
||||||
} else {
|
} else {
|
||||||
medtronic_pumpstate_battery.text = "{fa-battery-" + pumpStatus.batteryRemaining / 25 + "} " + pumpStatus.batteryRemaining + "%" + String.format(" (%.2f V)", pumpStatus.batteryVoltage)
|
medtronic_pumpstate_battery.text = "{fa-battery-" + pumpStatus.batteryRemaining / 25 + "} " + pumpStatus.batteryRemaining + "%" + String.format(" (%.2f V)", pumpStatus.batteryVoltage)
|
||||||
}
|
}
|
||||||
SetWarnColor.setColorInverse(medtronic_pumpstate_battery, pumpStatus.batteryRemaining.toDouble(), 25.0, 10.0)
|
warnColors.setColorInverse(medtronic_pumpstate_battery, pumpStatus.batteryRemaining.toDouble(), 25.0, 10.0)
|
||||||
|
|
||||||
// reservoir
|
// reservoir
|
||||||
medtronic_reservoir.text = resourceHelper.gs(R.string.reservoirvalue, pumpStatus.reservoirRemainingUnits, pumpStatus.reservoirFullUnits)
|
medtronic_reservoir.text = resourceHelper.gs(R.string.reservoirvalue, pumpStatus.reservoirRemainingUnits, pumpStatus.reservoirFullUnits)
|
||||||
SetWarnColor.setColorInverse(medtronic_reservoir, pumpStatus.reservoirRemainingUnits, 50.0, 20.0)
|
warnColors.setColorInverse(medtronic_reservoir, pumpStatus.reservoirRemainingUnits, 50.0, 20.0)
|
||||||
|
|
||||||
medtronic_errors.text = pumpStatus.errorInfo
|
medtronic_errors.text = pumpStatus.errorInfo
|
||||||
}
|
}
|
||||||
|
|
|
@ -95,8 +95,6 @@ import static info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUt
|
||||||
@Singleton
|
@Singleton
|
||||||
public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInterface {
|
public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInterface {
|
||||||
|
|
||||||
//private final SP sp;
|
|
||||||
|
|
||||||
protected static MedtronicPumpPlugin plugin = null;
|
protected static MedtronicPumpPlugin plugin = null;
|
||||||
private RileyLinkMedtronicService medtronicService;
|
private RileyLinkMedtronicService medtronicService;
|
||||||
private MedtronicPumpStatus pumpStatusLocal = null;
|
private MedtronicPumpStatus pumpStatusLocal = null;
|
||||||
|
@ -1031,7 +1029,7 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
|
||||||
pumpStatusLocal.tempBasalAmount = absoluteRate;
|
pumpStatusLocal.tempBasalAmount = absoluteRate;
|
||||||
pumpStatusLocal.tempBasalLength = durationInMinutes;
|
pumpStatusLocal.tempBasalLength = durationInMinutes;
|
||||||
|
|
||||||
TemporaryBasal tempStart = new TemporaryBasal() //
|
TemporaryBasal tempStart = new TemporaryBasal(getInjector()) //
|
||||||
.date(System.currentTimeMillis()) //
|
.date(System.currentTimeMillis()) //
|
||||||
.duration(durationInMinutes) //
|
.duration(durationInMinutes) //
|
||||||
.absolute(absoluteRate) //
|
.absolute(absoluteRate) //
|
||||||
|
@ -1372,7 +1370,7 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
|
||||||
if (response) {
|
if (response) {
|
||||||
aapsLogger.info(LTag.PUMP, getLogPrefix() + "cancelTempBasal - Cancel TBR successful.");
|
aapsLogger.info(LTag.PUMP, getLogPrefix() + "cancelTempBasal - Cancel TBR successful.");
|
||||||
|
|
||||||
TemporaryBasal tempBasal = new TemporaryBasal() //
|
TemporaryBasal tempBasal = new TemporaryBasal(getInjector()) //
|
||||||
.date(System.currentTimeMillis()) //
|
.date(System.currentTimeMillis()) //
|
||||||
.duration(0) //
|
.duration(0) //
|
||||||
.source(Source.USER);
|
.source(Source.USER);
|
||||||
|
@ -1577,10 +1575,6 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
|
||||||
this.hasTimeDateOrTimeZoneChanged = true;
|
this.hasTimeDateOrTimeZoneChanged = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// private void refreshCustomActionsList() {
|
|
||||||
// rxBus.send(new EventCustomActionsChanged());
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
public void setEnableCustomAction(MedtronicCustomActionType customAction, boolean isEnabled) {
|
public void setEnableCustomAction(MedtronicCustomActionType customAction, boolean isEnabled) {
|
||||||
|
|
||||||
|
|
|
@ -127,4 +127,10 @@ public class TempBasalPair extends info.nightscout.androidaps.plugins.pump.commo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "TempBasalPair [" + "Rate=" + insulinRate + ", DurationMinutes=" + durationMinutes + ", IsPercent="
|
||||||
|
+ isPercent + "]";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,10 +36,10 @@ import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
||||||
*/
|
*/
|
||||||
public class RileyLinkMedtronicService extends RileyLinkService {
|
public class RileyLinkMedtronicService extends RileyLinkService {
|
||||||
|
|
||||||
@Inject AAPSLogger aapsLogger;
|
//@Inject AAPSLogger aapsLogger;
|
||||||
@Inject Context context;
|
//@Inject Context context;
|
||||||
@Inject MedtronicPumpPlugin medtronicPumpPlugin;
|
@Inject MedtronicPumpPlugin medtronicPumpPlugin;
|
||||||
@Inject SP sp;
|
//@Inject SP sp;
|
||||||
|
|
||||||
private static RileyLinkMedtronicService instance;
|
private static RileyLinkMedtronicService instance;
|
||||||
private static ServiceTask currentTask = null;
|
private static ServiceTask currentTask = null;
|
||||||
|
@ -53,9 +53,6 @@ public class RileyLinkMedtronicService extends RileyLinkService {
|
||||||
public RileyLinkMedtronicService() {
|
public RileyLinkMedtronicService() {
|
||||||
super();
|
super();
|
||||||
instance = this;
|
instance = this;
|
||||||
aapsLogger.debug(LTag.PUMPCOMM, "RileyLinkMedtronicService newly constructed");
|
|
||||||
MedtronicUtil.setMedtronicService(this);
|
|
||||||
pumpStatus = (MedtronicPumpStatus) medtronicPumpPlugin.getPumpStatusData();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -106,6 +103,11 @@ public class RileyLinkMedtronicService extends RileyLinkService {
|
||||||
|
|
||||||
// init rileyLinkCommunicationManager
|
// init rileyLinkCommunicationManager
|
||||||
medtronicCommunicationManager = new MedtronicCommunicationManager(rfspy);
|
medtronicCommunicationManager = new MedtronicCommunicationManager(rfspy);
|
||||||
|
|
||||||
|
aapsLogger.debug(LTag.PUMPCOMM, "RileyLinkMedtronicService newly constructed");
|
||||||
|
MedtronicUtil.setMedtronicService(this);
|
||||||
|
pumpStatus = (MedtronicPumpStatus) medtronicPumpPlugin.getPumpStatusData();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -60,6 +60,7 @@ class OmnipodFragment : DaggerFragment() {
|
||||||
@Inject lateinit var commandQueue: CommandQueueProvider
|
@Inject lateinit var commandQueue: CommandQueueProvider
|
||||||
@Inject lateinit var activePlugin: ActivePluginProvider
|
@Inject lateinit var activePlugin: ActivePluginProvider
|
||||||
@Inject lateinit var medtronicPumpPlugin: MedtronicPumpPlugin
|
@Inject lateinit var medtronicPumpPlugin: MedtronicPumpPlugin
|
||||||
|
@Inject lateinit var warnColors: WarnColors
|
||||||
|
|
||||||
private var disposable: CompositeDisposable = CompositeDisposable()
|
private var disposable: CompositeDisposable = CompositeDisposable()
|
||||||
|
|
||||||
|
@ -443,7 +444,7 @@ class OmnipodFragment : DaggerFragment() {
|
||||||
} else {
|
} else {
|
||||||
omnipod_reservoir.text = resourceHelper.gs(R.string.omnipod_reservoir_left, pumpStatus.reservoirRemainingUnits)
|
omnipod_reservoir.text = resourceHelper.gs(R.string.omnipod_reservoir_left, pumpStatus.reservoirRemainingUnits)
|
||||||
}
|
}
|
||||||
SetWarnColor.setColorInverse(omnipod_reservoir, pumpStatus.reservoirRemainingUnits, 50.0, 20.0)
|
warnColors.setColorInverse(omnipod_reservoir, pumpStatus.reservoirRemainingUnits, 50.0, 20.0)
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
omnipod_basabasalrate.text = ""
|
omnipod_basabasalrate.text = ""
|
||||||
|
|
|
@ -240,7 +240,7 @@ class VirtualPumpPlugin @Inject constructor(
|
||||||
|
|
||||||
override fun stopBolusDelivering() {}
|
override fun stopBolusDelivering() {}
|
||||||
override fun setTempBasalAbsolute(absoluteRate: Double, durationInMinutes: Int, profile: Profile, enforceNew: Boolean): PumpEnactResult {
|
override fun setTempBasalAbsolute(absoluteRate: Double, durationInMinutes: Int, profile: Profile, enforceNew: Boolean): PumpEnactResult {
|
||||||
val tempBasal = TemporaryBasal()
|
val tempBasal = TemporaryBasal(injector)
|
||||||
.date(System.currentTimeMillis())
|
.date(System.currentTimeMillis())
|
||||||
.absolute(absoluteRate)
|
.absolute(absoluteRate)
|
||||||
.duration(durationInMinutes)
|
.duration(durationInMinutes)
|
||||||
|
@ -260,7 +260,7 @@ class VirtualPumpPlugin @Inject constructor(
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun setTempBasalPercent(percent: Int, durationInMinutes: Int, profile: Profile, enforceNew: Boolean): PumpEnactResult {
|
override fun setTempBasalPercent(percent: Int, durationInMinutes: Int, profile: Profile, enforceNew: Boolean): PumpEnactResult {
|
||||||
val tempBasal = TemporaryBasal()
|
val tempBasal = TemporaryBasal(injector)
|
||||||
.date(System.currentTimeMillis())
|
.date(System.currentTimeMillis())
|
||||||
.percent(percent)
|
.percent(percent)
|
||||||
.duration(durationInMinutes)
|
.duration(durationInMinutes)
|
||||||
|
@ -308,7 +308,7 @@ class VirtualPumpPlugin @Inject constructor(
|
||||||
result.comment = resourceHelper.gs(R.string.virtualpump_resultok)
|
result.comment = resourceHelper.gs(R.string.virtualpump_resultok)
|
||||||
if (treatmentsPlugin.isTempBasalInProgress) {
|
if (treatmentsPlugin.isTempBasalInProgress) {
|
||||||
result.enacted = true
|
result.enacted = true
|
||||||
val tempStop = TemporaryBasal().date(System.currentTimeMillis()).source(Source.USER)
|
val tempStop = TemporaryBasal(injector).date(System.currentTimeMillis()).source(Source.USER)
|
||||||
treatmentsPlugin.addToHistoryTempBasal(tempStop)
|
treatmentsPlugin.addToHistoryTempBasal(tempStop)
|
||||||
//tempBasal = null;
|
//tempBasal = null;
|
||||||
aapsLogger.debug(LTag.PUMP, "Canceling temp basal: $result")
|
aapsLogger.debug(LTag.PUMP, "Canceling temp basal: $result")
|
||||||
|
|
|
@ -109,7 +109,7 @@ public class SensitivityAAPSPlugin extends AbstractSensitivityPlugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
// reset deviations after site change
|
// reset deviations after site change
|
||||||
if (CareportalEvent.isEvent5minBack(siteChanges, autosensData.time)) {
|
if (new CareportalEvent(getInjector()).isEvent5minBack(siteChanges, autosensData.time)) {
|
||||||
deviationsArray.clear();
|
deviationsArray.clear();
|
||||||
pastSensitivity += "(SITECHANGE)";
|
pastSensitivity += "(SITECHANGE)";
|
||||||
}
|
}
|
||||||
|
|
|
@ -118,7 +118,7 @@ public class SensitivityOref1Plugin extends AbstractSensitivityPlugin {
|
||||||
String pastSensitivity = pastSensitivityArray.get(hoursegment);
|
String pastSensitivity = pastSensitivityArray.get(hoursegment);
|
||||||
|
|
||||||
// reset deviations after site change
|
// reset deviations after site change
|
||||||
if (CareportalEvent.isEvent5minBack(siteChanges, autosensData.time)) {
|
if (new CareportalEvent(getInjector()).isEvent5minBack(siteChanges, autosensData.time)) {
|
||||||
deviationsArray.clear();
|
deviationsArray.clear();
|
||||||
pastSensitivity += "(SITECHANGE)";
|
pastSensitivity += "(SITECHANGE)";
|
||||||
}
|
}
|
||||||
|
|
|
@ -111,7 +111,7 @@ public class SensitivityWeightedAveragePlugin extends AbstractSensitivityPlugin
|
||||||
}
|
}
|
||||||
|
|
||||||
// reset deviations after site change
|
// reset deviations after site change
|
||||||
if (CareportalEvent.isEvent5minBack(siteChanges, autosensData.time)) {
|
if (new CareportalEvent(getInjector()).isEvent5minBack(siteChanges, autosensData.time)) {
|
||||||
data.clear();
|
data.clear();
|
||||||
pastSensitivity += "(SITECHANGE)";
|
pastSensitivity += "(SITECHANGE)";
|
||||||
}
|
}
|
||||||
|
|
|
@ -102,7 +102,7 @@ class DexcomPlugin @Inject constructor(
|
||||||
jsonObject.put("glucose", meter.getInt("meterValue"))
|
jsonObject.put("glucose", meter.getInt("meterValue"))
|
||||||
jsonObject.put("units", Constants.MGDL)
|
jsonObject.put("units", Constants.MGDL)
|
||||||
|
|
||||||
val careportalEvent = CareportalEvent()
|
val careportalEvent = CareportalEvent(injector)
|
||||||
careportalEvent.date = timestamp
|
careportalEvent.date = timestamp
|
||||||
careportalEvent.source = Source.USER
|
careportalEvent.source = Source.USER
|
||||||
careportalEvent.eventType = CareportalEvent.BGCHECK
|
careportalEvent.eventType = CareportalEvent.BGCHECK
|
||||||
|
@ -122,7 +122,7 @@ class DexcomPlugin @Inject constructor(
|
||||||
jsonObject.put("enteredBy", "AndroidAPS-Dexcom$sensorType")
|
jsonObject.put("enteredBy", "AndroidAPS-Dexcom$sensorType")
|
||||||
jsonObject.put("created_at", DateUtil.toISOString(sensorInsertionTime))
|
jsonObject.put("created_at", DateUtil.toISOString(sensorInsertionTime))
|
||||||
jsonObject.put("eventType", CareportalEvent.SENSORCHANGE)
|
jsonObject.put("eventType", CareportalEvent.SENSORCHANGE)
|
||||||
val careportalEvent = CareportalEvent()
|
val careportalEvent = CareportalEvent(injector)
|
||||||
careportalEvent.date = sensorInsertionTime
|
careportalEvent.date = sensorInsertionTime
|
||||||
careportalEvent.source = Source.USER
|
careportalEvent.source = Source.USER
|
||||||
careportalEvent.eventType = CareportalEvent.SENSORCHANGE
|
careportalEvent.eventType = CareportalEvent.SENSORCHANGE
|
||||||
|
|
|
@ -402,7 +402,7 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface
|
||||||
Profile profile = profileFunction.getProfile(t.date);
|
Profile profile = profileFunction.getProfile(t.date);
|
||||||
if (profile == null) continue;
|
if (profile == null) continue;
|
||||||
if (truncate && t.end() > truncateTime) {
|
if (truncate && t.end() > truncateTime) {
|
||||||
TemporaryBasal dummyTemp = new TemporaryBasal();
|
TemporaryBasal dummyTemp = new TemporaryBasal(getInjector());
|
||||||
dummyTemp.copyFrom(t);
|
dummyTemp.copyFrom(t);
|
||||||
dummyTemp.cutEndTo(truncateTime);
|
dummyTemp.cutEndTo(truncateTime);
|
||||||
calc = dummyTemp.iobCalc(time, profile);
|
calc = dummyTemp.iobCalc(time, profile);
|
||||||
|
@ -477,7 +477,7 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface
|
||||||
Profile profile = profileFunction.getProfile(t.date);
|
Profile profile = profileFunction.getProfile(t.date);
|
||||||
if (profile == null) continue;
|
if (profile == null) continue;
|
||||||
if (t.end() > truncateTime) {
|
if (t.end() > truncateTime) {
|
||||||
TemporaryBasal dummyTemp = new TemporaryBasal();
|
TemporaryBasal dummyTemp = new TemporaryBasal(getInjector());
|
||||||
dummyTemp.copyFrom(t);
|
dummyTemp.copyFrom(t);
|
||||||
dummyTemp.cutEndTo(truncateTime);
|
dummyTemp.cutEndTo(truncateTime);
|
||||||
calc = dummyTemp.iobCalc(time, profile, lastAutosensResult, exercise_mode, half_basal_exercise_target, isTempTarget);
|
calc = dummyTemp.iobCalc(time, profile, lastAutosensResult, exercise_mode, half_basal_exercise_target, isTempTarget);
|
||||||
|
@ -586,7 +586,7 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface
|
||||||
else if (tempBasal.isAbsolute)
|
else if (tempBasal.isAbsolute)
|
||||||
NSUpload.uploadTempBasalStartAbsolute(tempBasal, null);
|
NSUpload.uploadTempBasalStartAbsolute(tempBasal, null);
|
||||||
else
|
else
|
||||||
NSUpload.uploadTempBasalStartPercent(tempBasal);
|
NSUpload.uploadTempBasalStartPercent(tempBasal, profileFunction.getProfile(tempBasal.date));
|
||||||
}
|
}
|
||||||
return newRecordCreated;
|
return newRecordCreated;
|
||||||
}
|
}
|
||||||
|
@ -652,8 +652,8 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface
|
||||||
context.startActivity(i);
|
context.startActivity(i);
|
||||||
|
|
||||||
Bundle bundle = new Bundle();
|
Bundle bundle = new Bundle();
|
||||||
bundle.putString(FirebaseAnalytics.Param.ITEM_ID, "TreatmentClash");
|
bundle.putString(FirebaseAnalytics.Param.ITEM_LIST_ID, "TreatmentClash");
|
||||||
bundle.putString(FirebaseAnalytics.Param.VALUE, status);
|
bundle.putString(FirebaseAnalytics.Param.ITEM_LIST_NAME, status);
|
||||||
fabricPrivacy.logCustom(bundle);
|
fabricPrivacy.logCustom(bundle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -706,7 +706,7 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface
|
||||||
public void addToHistoryTempTarget(TempTarget tempTarget) {
|
public void addToHistoryTempTarget(TempTarget tempTarget) {
|
||||||
//log.debug("Adding new TemporaryBasal record" + profileSwitch.log());
|
//log.debug("Adding new TemporaryBasal record" + profileSwitch.log());
|
||||||
MainApp.getDbHelper().createOrUpdate(tempTarget);
|
MainApp.getDbHelper().createOrUpdate(tempTarget);
|
||||||
NSUpload.uploadTempTarget(tempTarget);
|
NSUpload.uploadTempTarget(tempTarget, profileFunction);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -13,13 +13,13 @@ class BTReceiver : DaggerBroadcastReceiver() {
|
||||||
|
|
||||||
override fun onReceive(context: Context, intent: Intent) {
|
override fun onReceive(context: Context, intent: Intent) {
|
||||||
super.onReceive(context, intent)
|
super.onReceive(context, intent)
|
||||||
val device : BluetoothDevice = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE)
|
val device: BluetoothDevice = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE)
|
||||||
|
|
||||||
when (intent.action) {
|
when (intent.action) {
|
||||||
BluetoothDevice.ACTION_ACL_CONNECTED ->
|
BluetoothDevice.ACTION_ACL_CONNECTED ->
|
||||||
rxBus.send(EventBTChange(EventBTChange.Change.CONNECT, device.name))
|
rxBus.send(EventBTChange(EventBTChange.Change.CONNECT, deviceName = device.name, deviceAddress = device.address))
|
||||||
BluetoothDevice.ACTION_ACL_DISCONNECTED ->
|
BluetoothDevice.ACTION_ACL_DISCONNECTED ->
|
||||||
rxBus.send(EventBTChange(EventBTChange.Change.DISCONNECT, device.name))
|
rxBus.send(EventBTChange(EventBTChange.Change.DISCONNECT, deviceName = device.name, deviceAddress = device.address))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -2,19 +2,13 @@ package info.nightscout.androidaps.receivers
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.content.IntentFilter
|
|
||||||
import dagger.android.DaggerBroadcastReceiver
|
import dagger.android.DaggerBroadcastReceiver
|
||||||
import info.nightscout.androidaps.MainApp
|
|
||||||
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
||||||
import info.nightscout.androidaps.interfaces.PumpInterface
|
import info.nightscout.androidaps.interfaces.PumpInterface
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.logging.L
|
|
||||||
import info.nightscout.androidaps.logging.LTag
|
import info.nightscout.androidaps.logging.LTag
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin
|
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodUtil
|
import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodUtil
|
||||||
import info.nightscout.androidaps.utils.T
|
|
||||||
import info.nightscout.androidaps.utils.TimeChangeType
|
import info.nightscout.androidaps.utils.TimeChangeType
|
||||||
import org.slf4j.LoggerFactory
|
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,7 @@ class FabricPrivacy @Inject constructor(
|
||||||
fun logCustom(event: Bundle) {
|
fun logCustom(event: Bundle) {
|
||||||
try {
|
try {
|
||||||
if (fabricEnabled()) {
|
if (fabricEnabled()) {
|
||||||
mainApp.firebaseAnalytics.logEvent(FirebaseAnalytics.Event.SELECT_CONTENT, event)
|
mainApp.firebaseAnalytics.logEvent(FirebaseAnalytics.Event.SELECT_ITEM, event)
|
||||||
} else {
|
} else {
|
||||||
aapsLogger.debug(LTag.CORE, "Ignoring recently opted-out event: $event")
|
aapsLogger.debug(LTag.CORE, "Ignoring recently opted-out event: $event")
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,25 +0,0 @@
|
||||||
package info.nightscout.androidaps.utils;
|
|
||||||
|
|
||||||
import android.graphics.Color;
|
|
||||||
import android.widget.TextView;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by mike on 08.07.2016.
|
|
||||||
*/
|
|
||||||
public class SetWarnColor {
|
|
||||||
static final int normalColor = Color.WHITE;
|
|
||||||
static final int warnColor = Color.YELLOW;
|
|
||||||
static final int urgentColor = Color.RED;
|
|
||||||
|
|
||||||
public static void setColor(TextView view, double value, double warnLevel, double urgentLevel) {
|
|
||||||
if (value >= urgentLevel) view.setTextColor(urgentColor);
|
|
||||||
else if (value >= warnLevel) view.setTextColor(warnColor);
|
|
||||||
else view.setTextColor(normalColor);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void setColorInverse(TextView view, double value, double warnLevel, double urgentLevel) {
|
|
||||||
if (value <= urgentLevel) view.setTextColor(urgentColor);
|
|
||||||
else if (value <= warnLevel) view.setTextColor(warnColor);
|
|
||||||
else view.setTextColor(normalColor);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,38 @@
|
||||||
|
package info.nightscout.androidaps.utils
|
||||||
|
|
||||||
|
import android.graphics.Color
|
||||||
|
import android.widget.TextView
|
||||||
|
import info.nightscout.androidaps.R
|
||||||
|
import info.nightscout.androidaps.db.CareportalEvent
|
||||||
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
|
import javax.inject.Inject
|
||||||
|
import javax.inject.Singleton
|
||||||
|
|
||||||
|
@Singleton
|
||||||
|
class WarnColors @Inject constructor(val resourceHelper: ResourceHelper) {
|
||||||
|
|
||||||
|
private val normalColor = Color.WHITE
|
||||||
|
private val warnColor = Color.YELLOW
|
||||||
|
private val urgentColor = Color.RED
|
||||||
|
|
||||||
|
fun setColor(view: TextView?, value: Double, warnLevel: Double, urgentLevel: Double) =
|
||||||
|
view?.setTextColor(when {
|
||||||
|
value >= urgentLevel -> urgentColor
|
||||||
|
value >= warnLevel -> warnColor
|
||||||
|
else -> normalColor
|
||||||
|
})
|
||||||
|
|
||||||
|
fun setColorInverse(view: TextView?, value: Double, warnLevel: Double, urgentLevel: Double) =
|
||||||
|
view?.setTextColor(when {
|
||||||
|
value <= urgentLevel -> urgentColor
|
||||||
|
value <= warnLevel -> warnColor
|
||||||
|
else -> normalColor
|
||||||
|
})
|
||||||
|
|
||||||
|
fun setColorByAge(view: TextView?, careportalEvent: CareportalEvent, warnThreshold: Double, urgentThreshold: Double) =
|
||||||
|
view?.setTextColor(when {
|
||||||
|
careportalEvent.isOlderThan(urgentThreshold) -> resourceHelper.gc(R.color.low)
|
||||||
|
careportalEvent.isOlderThan(warnThreshold) -> resourceHelper.gc(R.color.high)
|
||||||
|
else -> Color.WHITE
|
||||||
|
})
|
||||||
|
}
|
|
@ -42,21 +42,19 @@ class ResourceHelperImplementation @Inject constructor(private val context: Cont
|
||||||
override fun openRawResourceFd(id: Int): AssetFileDescriptor =
|
override fun openRawResourceFd(id: Int): AssetFileDescriptor =
|
||||||
context.resources.openRawResourceFd(id)
|
context.resources.openRawResourceFd(id)
|
||||||
|
|
||||||
override fun getIcon(): Int {
|
override fun getIcon(): Int =
|
||||||
return when {
|
when {
|
||||||
Config.NSCLIENT -> R.mipmap.ic_yellowowl
|
Config.NSCLIENT -> R.mipmap.ic_yellowowl
|
||||||
Config.PUMPCONTROL -> R.mipmap.ic_pumpcontrol
|
Config.PUMPCONTROL -> R.mipmap.ic_pumpcontrol
|
||||||
else -> R.mipmap.ic_launcher
|
else -> R.mipmap.ic_launcher
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
override fun getNotificationIcon(): Int {
|
override fun getNotificationIcon(): Int =
|
||||||
return when {
|
when {
|
||||||
Config.NSCLIENT -> R.drawable.ic_notif_nsclient
|
Config.NSCLIENT -> R.drawable.ic_notif_nsclient
|
||||||
Config.PUMPCONTROL -> R.drawable.ic_notif_pumpcontrol
|
Config.PUMPCONTROL -> R.drawable.ic_notif_pumpcontrol
|
||||||
else -> R.drawable.ic_notif_aaps
|
else -> R.drawable.ic_notif_aaps
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
override fun decodeResource(id: Int): Bitmap =
|
override fun decodeResource(id: Int): Bitmap =
|
||||||
BitmapFactory.decodeResource(context.resources, id)
|
BitmapFactory.decodeResource(context.resources, id)
|
||||||
|
@ -69,5 +67,5 @@ class ResourceHelperImplementation @Inject constructor(private val context: Cont
|
||||||
return (dp * scale + 0.5f).toInt()
|
return (dp * scale + 0.5f).toInt()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun shortTextMode() : Boolean = !gb(R.bool.isTablet) && Config.NSCLIENT
|
override fun shortTextMode() : Boolean = !gb(R.bool.isTablet)
|
||||||
}
|
}
|
|
@ -29,6 +29,7 @@ interface SP {
|
||||||
fun putBoolean(key: String, value: Boolean)
|
fun putBoolean(key: String, value: Boolean)
|
||||||
fun putBoolean(@StringRes resourceID: Int, value: Boolean)
|
fun putBoolean(@StringRes resourceID: Int, value: Boolean)
|
||||||
fun putDouble(key: String, value: Double)
|
fun putDouble(key: String, value: Double)
|
||||||
|
fun putDouble(@StringRes resourceID: Int, value: Double)
|
||||||
fun putLong(key: String, value: Long)
|
fun putLong(key: String, value: Long)
|
||||||
fun putLong(@StringRes resourceID: Int, value: Long)
|
fun putLong(@StringRes resourceID: Int, value: Long)
|
||||||
fun putInt(key: String, value: Int)
|
fun putInt(key: String, value: Int)
|
||||||
|
|
|
@ -102,6 +102,10 @@ class SPImplementation @Inject constructor(
|
||||||
override fun putDouble(key: String, value: Double) =
|
override fun putDouble(key: String, value: Double) =
|
||||||
sharedPreferences.edit().putString(key, value.toString()).apply()
|
sharedPreferences.edit().putString(key, value.toString()).apply()
|
||||||
|
|
||||||
|
override fun putDouble(resourceID: Int, value: Double) {
|
||||||
|
sharedPreferences.edit().putString(resourceHelper.gs(resourceID), value.toString()).apply()
|
||||||
|
}
|
||||||
|
|
||||||
override fun putLong(key: String, value: Long) =
|
override fun putLong(key: String, value: Long) =
|
||||||
sharedPreferences.edit().putLong(key, value).apply()
|
sharedPreferences.edit().putLong(key, value).apply()
|
||||||
|
|
||||||
|
|
|
@ -61,11 +61,6 @@
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:orientation="horizontal">
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
@ -77,7 +72,7 @@
|
||||||
android:layout_weight="1">
|
android:layout_weight="1">
|
||||||
|
|
||||||
<com.jjoe64.graphview.GraphView
|
<com.jjoe64.graphview.GraphView
|
||||||
android:id="@+id/historyybrowse_bggraph"
|
android:id="@+id/historybrowse_bggraph"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="match_parent" />
|
android:layout_height="match_parent" />
|
||||||
|
|
||||||
|
@ -85,8 +80,8 @@
|
||||||
android:id="@+id/overview_chartMenuButton"
|
android:id="@+id/overview_chartMenuButton"
|
||||||
android:layout_width="30dp"
|
android:layout_width="30dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_alignParentEnd="true"
|
|
||||||
android:layout_alignParentTop="true"
|
android:layout_alignParentTop="true"
|
||||||
|
android:layout_alignParentEnd="true"
|
||||||
android:paddingTop="5dp"
|
android:paddingTop="5dp"
|
||||||
app:srcCompat="@drawable/ic_arrow_drop_down_white_24dp" />
|
app:srcCompat="@drawable/ic_arrow_drop_down_white_24dp" />
|
||||||
|
|
||||||
|
@ -99,32 +94,14 @@
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
<com.jjoe64.graphview.GraphView
|
<LinearLayout
|
||||||
android:id="@+id/historybrowse_iobgraph"
|
android:id="@+id/history_iobgraph"
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="100dp" />
|
|
||||||
|
|
||||||
<SeekBar
|
|
||||||
android:id="@+id/historybrowse_seekBar"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:visibility="gone"/>
|
android:orientation="vertical" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<ScrollView
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content">
|
|
||||||
|
|
||||||
<FrameLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content">
|
|
||||||
|
|
||||||
</FrameLayout>
|
|
||||||
|
|
||||||
</ScrollView>
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -363,58 +363,101 @@
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/overview_statuslights"
|
android:id="@+id/overview_statuslights"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:gravity="center_horizontal"
|
android:layout_marginTop="3dp"
|
||||||
|
android:layout_marginBottom="3dp"
|
||||||
|
android:background="?android:attr/colorControlHighlight"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
|
android:paddingTop="4dp"
|
||||||
|
android:paddingBottom="4dp"
|
||||||
app:layout_constraintBottom_toTopOf="@+id/overview_bggraph"
|
app:layout_constraintBottom_toTopOf="@+id/overview_bggraph"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@id/bg_tbr_layout">
|
app:layout_constraintTop_toBottomOf="@id/bg_tbr_layout">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:layout_width="40dp"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:scaleType="centerInside"
|
||||||
|
android:src="@drawable/icon_cp_age_canula" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/overview_canulaage"
|
android:id="@+id/careportal_canulaage"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:paddingStart="1dp"
|
||||||
|
android:paddingEnd="2dp"
|
||||||
|
android:textSize="14sp" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:layout_width="40dp"
|
||||||
|
android:layout_height="match_parent"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:gravity="center"
|
android:gravity="center_vertical"
|
||||||
android:text=""
|
android:scaleType="centerInside"
|
||||||
|
android:src="@drawable/icon_cp_age_insulin" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/careportal_insulinage"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:paddingStart="1dp"
|
||||||
|
android:paddingEnd="2dp"
|
||||||
android:textSize="14sp" />
|
android:textSize="14sp" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/overview_insulinage"
|
android:id="@+id/careportal_reservoirlevel"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:textSize="14sp" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:layout_width="40dp"
|
||||||
|
android:layout_height="match_parent"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:gravity="center"
|
android:gravity="center_vertical"
|
||||||
android:text=""
|
android:scaleType="centerInside"
|
||||||
|
android:src="@drawable/icon_cp_age_sensor" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/careportal_sensorage"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:paddingStart="1dp"
|
||||||
|
android:paddingEnd="2dp"
|
||||||
|
android:textSize="14sp" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:layout_width="40dp"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:scaleType="centerInside"
|
||||||
|
android:src="@drawable/icon_cp_age_battery" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/careportal_pbage"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:paddingStart="1dp"
|
||||||
|
android:paddingEnd="1dp"
|
||||||
android:textSize="14sp" />
|
android:textSize="14sp" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/overview_reservoirlevel"
|
android:id="@+id/careportal_batterylevel"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="1"
|
android:gravity="center_vertical"
|
||||||
android:gravity="center"
|
android:paddingStart="1dp"
|
||||||
android:text=""
|
android:paddingEnd="2dp"
|
||||||
android:textSize="14sp" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/overview_sensorage"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:gravity="center"
|
|
||||||
android:text=""
|
|
||||||
android:textSize="14sp" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/overview_batterylevel"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:gravity="center"
|
|
||||||
android:text=""
|
|
||||||
android:textSize="14sp" />
|
android:textSize="14sp" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
|
@ -363,58 +363,101 @@
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/overview_statuslights"
|
android:id="@+id/overview_statuslights"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:gravity="center_horizontal"
|
android:layout_marginTop="3dp"
|
||||||
|
android:layout_marginBottom="3dp"
|
||||||
|
android:background="?android:attr/colorControlHighlight"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
|
android:paddingTop="4dp"
|
||||||
|
android:paddingBottom="4dp"
|
||||||
app:layout_constraintBottom_toTopOf="@+id/overview_bggraph"
|
app:layout_constraintBottom_toTopOf="@+id/overview_bggraph"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@id/bg_tbr_layout">
|
app:layout_constraintTop_toBottomOf="@id/bg_tbr_layout">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:layout_width="40dp"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:scaleType="centerInside"
|
||||||
|
android:src="@drawable/icon_cp_age_canula" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/overview_canulaage"
|
android:id="@+id/careportal_canulaage"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:paddingStart="1dp"
|
||||||
|
android:paddingEnd="2dp"
|
||||||
|
android:textSize="14sp" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:layout_width="40dp"
|
||||||
|
android:layout_height="match_parent"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:gravity="center"
|
android:gravity="center_vertical"
|
||||||
android:text=""
|
android:scaleType="centerInside"
|
||||||
|
android:src="@drawable/icon_cp_age_insulin" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/careportal_insulinage"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:paddingStart="1dp"
|
||||||
|
android:paddingEnd="2dp"
|
||||||
android:textSize="14sp" />
|
android:textSize="14sp" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/overview_insulinage"
|
android:id="@+id/careportal_reservoirlevel"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:textSize="14sp" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:layout_width="40dp"
|
||||||
|
android:layout_height="match_parent"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:gravity="center"
|
android:gravity="center_vertical"
|
||||||
android:text=""
|
android:scaleType="centerInside"
|
||||||
|
android:src="@drawable/icon_cp_age_sensor" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/careportal_sensorage"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:paddingStart="1dp"
|
||||||
|
android:paddingEnd="2dp"
|
||||||
|
android:textSize="14sp" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:layout_width="40dp"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:scaleType="centerInside"
|
||||||
|
android:src="@drawable/icon_cp_age_battery" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/careportal_pbage"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:paddingStart="1dp"
|
||||||
|
android:paddingEnd="1dp"
|
||||||
android:textSize="14sp" />
|
android:textSize="14sp" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/overview_reservoirlevel"
|
android:id="@+id/careportal_batterylevel"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="1"
|
android:gravity="center_vertical"
|
||||||
android:gravity="center"
|
android:paddingStart="1dp"
|
||||||
android:text=""
|
android:paddingEnd="2dp"
|
||||||
android:textSize="14sp" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/overview_sensorage"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:gravity="center"
|
|
||||||
android:text=""
|
|
||||||
android:textSize="14sp" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/overview_batterylevel"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:gravity="center"
|
|
||||||
android:text=""
|
|
||||||
android:textSize="14sp" />
|
android:textSize="14sp" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
|
@ -117,7 +117,7 @@
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
app:layout_constraintBottom_toTopOf="@+id/overview_statuslights_nscl"
|
app:layout_constraintBottom_toTopOf="@+id/overview_statuslights"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/overview_pumpstatuslayout">
|
app:layout_constraintTop_toBottomOf="@+id/overview_pumpstatuslayout">
|
||||||
|
@ -362,98 +362,104 @@
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/overview_statuslights_nscl"
|
android:id="@+id/overview_statuslights"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="3dp"
|
||||||
|
android:layout_marginBottom="3dp"
|
||||||
android:background="?android:attr/colorControlHighlight"
|
android:background="?android:attr/colorControlHighlight"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
android:paddingTop="4dp"
|
android:paddingTop="4dp"
|
||||||
android:paddingBottom="4dp"
|
android:paddingBottom="4dp"
|
||||||
app:layout_constraintBottom_toTopOf="@+id/overview_pump"
|
app:layout_constraintBottom_toTopOf="@+id/overview_bggraph"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@id/bg_tbr_layout">
|
app:layout_constraintTop_toBottomOf="@id/bg_tbr_layout">
|
||||||
|
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:layout_width="30dp"
|
android:layout_width="40dp"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_weight="0"
|
android:layout_weight="1"
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
android:paddingStart="2dp"
|
|
||||||
android:paddingEnd="1dp"
|
|
||||||
android:scaleType="centerInside"
|
android:scaleType="centerInside"
|
||||||
android:src="@drawable/icon_cp_age_canula" />
|
android:src="@drawable/icon_cp_age_canula" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/careportal_canulaage"
|
android:id="@+id/careportal_canulaage"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="1"
|
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
android:paddingStart="1dp"
|
android:paddingStart="1dp"
|
||||||
android:paddingEnd="2dp"
|
android:paddingEnd="2dp"
|
||||||
android:textSize="14sp" />
|
android:textSize="14sp" />
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:layout_width="30dp"
|
android:layout_width="40dp"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_weight="0"
|
android:layout_weight="1"
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
android:paddingStart="2dp"
|
|
||||||
android:paddingEnd="1dp"
|
|
||||||
android:scaleType="centerInside"
|
android:scaleType="centerInside"
|
||||||
android:src="@drawable/icon_cp_age_insulin" />
|
android:src="@drawable/icon_cp_age_insulin" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/careportal_insulinage"
|
android:id="@+id/careportal_insulinage"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="1"
|
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
android:paddingStart="1dp"
|
android:paddingStart="1dp"
|
||||||
android:paddingEnd="2dp"
|
android:paddingEnd="2dp"
|
||||||
android:textSize="14sp" />
|
android:textSize="14sp" />
|
||||||
|
|
||||||
<ImageView
|
<TextView
|
||||||
android:layout_width="30dp"
|
android:id="@+id/careportal_reservoirlevel"
|
||||||
android:layout_height="match_parent"
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:textSize="14sp" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:layout_width="40dp"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_weight="1"
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
android:paddingStart="2dp"
|
|
||||||
android:paddingEnd="1dp"
|
|
||||||
android:scaleType="centerInside"
|
android:scaleType="centerInside"
|
||||||
android:src="@drawable/icon_cp_age_sensor" />
|
android:src="@drawable/icon_cp_age_sensor" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/careportal_sensorage"
|
android:id="@+id/careportal_sensorage"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="1"
|
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
android:paddingStart="1dp"
|
android:paddingStart="1dp"
|
||||||
android:paddingEnd="2dp"
|
android:paddingEnd="2dp"
|
||||||
android:textSize="14sp" />
|
android:textSize="14sp" />
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:layout_width="30dp"
|
android:layout_width="40dp"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_weight="0"
|
android:layout_weight="1"
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
android:paddingStart="2dp"
|
|
||||||
android:paddingEnd="1dp"
|
|
||||||
android:scaleType="centerInside"
|
android:scaleType="centerInside"
|
||||||
android:src="@drawable/icon_cp_age_battery" />
|
android:src="@drawable/icon_cp_age_battery" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/careportal_pbage"
|
android:id="@+id/careportal_pbage"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="1"
|
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
android:paddingStart="1dp"
|
android:paddingStart="1dp"
|
||||||
android:paddingEnd="1dp"
|
android:paddingEnd="1dp"
|
||||||
android:textSize="14sp" />
|
android:textSize="14sp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/careportal_batterylevel"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:paddingStart="1dp"
|
||||||
|
android:paddingEnd="2dp"
|
||||||
|
android:textSize="14sp" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
@ -468,7 +474,7 @@
|
||||||
app:layout_constraintBottom_toTopOf="@+id/overview_openaps"
|
app:layout_constraintBottom_toTopOf="@+id/overview_openaps"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/overview_statuslights_nscl" />
|
app:layout_constraintTop_toBottomOf="@+id/overview_statuslights" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/overview_openaps"
|
android:id="@+id/overview_openaps"
|
||||||
|
|
|
@ -131,7 +131,6 @@
|
||||||
|
|
||||||
<string name="configbuilder">Config Builder</string>
|
<string name="configbuilder">Config Builder</string>
|
||||||
<string name="objectives">Objectives</string>
|
<string name="objectives">Objectives</string>
|
||||||
<string name="openapsma">OpenAPS MA</string>
|
|
||||||
<string name="overview">Overview</string>
|
<string name="overview">Overview</string>
|
||||||
<string name="nsprofile">NS Profile</string>
|
<string name="nsprofile">NS Profile</string>
|
||||||
<string name="simpleprofile">Simple profile</string>
|
<string name="simpleprofile">Simple profile</string>
|
||||||
|
@ -652,18 +651,31 @@
|
||||||
<string name="key_usesuperbolus" translatable="false">key_usersuperbolus</string>
|
<string name="key_usesuperbolus" translatable="false">key_usersuperbolus</string>
|
||||||
<string name="enablesuperbolus">Enable superbolus in wizard</string>
|
<string name="enablesuperbolus">Enable superbolus in wizard</string>
|
||||||
<string name="enablesuperbolus_summary">Enable superbolus functionality in wizard. Do not enable until you learn what it really does. IT MAY CAUSE INSULIN OVERDOSE IF USED BLINDLY!</string>
|
<string name="enablesuperbolus_summary">Enable superbolus functionality in wizard. Do not enable until you learn what it really does. IT MAY CAUSE INSULIN OVERDOSE IF USED BLINDLY!</string>
|
||||||
<string name="key_show_statuslights" translatable="false">key_show_statuslights</string>
|
<string name="key_show_statuslights" translatable="false">show_statuslights</string>
|
||||||
<string name="key_show_statuslights_extended" translatable="false">key_show_statuslights_extended</string>
|
|
||||||
<string name="show_statuslights">Show status lights on home screen</string>
|
<string name="show_statuslights">Show status lights on home screen</string>
|
||||||
<string name="show_statuslights_extended">Show extended status lights on home screen</string>
|
<string name="key_statuslights_cage_warning" translatable="false">statuslights_cage_warning</string>
|
||||||
<string name="show_statuslights_extended_summary">Enable extended status lights for cage, iage, sage, reservoir and battery level on home screen.</string>
|
<string name="statuslights_cage_warning">Threshold warning canula age [h]</string>
|
||||||
<string name="key_statuslights_res_warning" translatable="false">key_statuslights_res_warning</string>
|
<string name="key_statuslights_cage_critical" translatable="false">statuslights_cage_critical</string>
|
||||||
|
<string name="statuslights_cage_critical">Threshold critical canula age [h]</string>
|
||||||
|
<string name="key_statuslights_iage_warning" translatable="false">statuslights_iage_warning</string>
|
||||||
|
<string name="statuslights_iage_warning">Threshold warning insulin age [h]</string>
|
||||||
|
<string name="key_statuslights_iage_critical" translatable="false">statuslights_iage_critical</string>
|
||||||
|
<string name="statuslights_iage_critical">Threshold critical insulin age [h]</string>
|
||||||
|
<string name="key_statuslights_sage_warning" translatable="false">statuslights_sage_warning</string>
|
||||||
|
<string name="statuslights_sage_warning">Threshold warning sensor age [h]</string>
|
||||||
|
<string name="key_statuslights_sage_critical" translatable="false">statuslights_sage_critical</string>
|
||||||
|
<string name="statuslights_sage_critical">Threshold critical sensor age [h]</string>
|
||||||
|
<string name="key_statuslights_bage_warning" translatable="false">statuslights_bage_warning</string>
|
||||||
|
<string name="statuslights_bage_warning">Threshold warning battery age [h]</string>
|
||||||
|
<string name="key_statuslights_bage_critical" translatable="false">statuslights_bage_critical</string>
|
||||||
|
<string name="statuslights_bage_critical">Threshold critical battery age [h]</string>
|
||||||
|
<string name="key_statuslights_res_warning" translatable="false">statuslights_res_warning</string>
|
||||||
<string name="statuslights_res_warning">Threshold warning reservoir level [U]</string>
|
<string name="statuslights_res_warning">Threshold warning reservoir level [U]</string>
|
||||||
<string name="key_statuslights_res_critical" translatable="false">key_statuslights_res_critical</string>
|
<string name="key_statuslights_res_critical" translatable="false">statuslights_res_critical</string>
|
||||||
<string name="statuslights_res_critical">Threshold critical reservoir level [U]</string>
|
<string name="statuslights_res_critical">Threshold critical reservoir level [U]</string>
|
||||||
<string name="key_statuslights_bat_warning" translatable="false">key_statuslights_bat_warning</string>
|
<string name="key_statuslights_bat_warning" translatable="false">statuslights_bat_warning</string>
|
||||||
<string name="statuslights_bat_warning">Threshold warning battery level [%]</string>
|
<string name="statuslights_bat_warning">Threshold warning battery level [%]</string>
|
||||||
<string name="key_statuslights_bat_critical" translatable="false">key_statuslights_bat_critical</string>
|
<string name="key_statuslights_bat_critical" translatable="false">statuslights_bat_critical</string>
|
||||||
<string name="statuslights_bat_critical">Threshold critical battery level [%]</string>
|
<string name="statuslights_bat_critical">Threshold critical battery level [%]</string>
|
||||||
<string name="iob">IOB</string>
|
<string name="iob">IOB</string>
|
||||||
<string name="cob">COB</string>
|
<string name="cob">COB</string>
|
||||||
|
@ -1547,7 +1559,6 @@
|
||||||
<string name="rileylink_scanner_scanning_error">Scanning error: %1$d</string>
|
<string name="rileylink_scanner_scanning_error">Scanning error: %1$d</string>
|
||||||
<string name="common_never">Never</string>
|
<string name="common_never">Never</string>
|
||||||
|
|
||||||
|
|
||||||
<!-- RL Status Page -->
|
<!-- RL Status Page -->
|
||||||
<string name="rileylink_settings_tab1">Settings</string>
|
<string name="rileylink_settings_tab1">Settings</string>
|
||||||
<string name="rileylink_settings_tab2">History</string>
|
<string name="rileylink_settings_tab2">History</string>
|
||||||
|
@ -1810,6 +1821,12 @@
|
||||||
<string name="master_password_summary">Master password is used for backup encryption and to override security in application. Remember it or store on a safe place.</string>
|
<string name="master_password_summary">Master password is used for backup encryption and to override security in application. Remember it or store on a safe place.</string>
|
||||||
<string name="passwords_dont_match">Passwords don\'t match</string>
|
<string name="passwords_dont_match">Passwords don\'t match</string>
|
||||||
<string name="current_master_password">Current master password</string>
|
<string name="current_master_password">Current master password</string>
|
||||||
|
<string name="statuslights">Status lights</string>
|
||||||
|
<string name="statuslights_copy_ns">Copy settings from NS</string>
|
||||||
|
<string name="key_statuslights_copy_ns" translatable="false">statuslights_copy_ns</string>
|
||||||
|
<string name="copyexistingvalues">Copy NS settings (if exists)?</string>
|
||||||
|
<string name="key_statuslights_overview_advanced" translatable="false">statuslights_overview_advanced</string>
|
||||||
|
|
||||||
|
|
||||||
<!-- Omnipod -->
|
<!-- Omnipod -->
|
||||||
|
|
||||||
|
|
|
@ -94,8 +94,6 @@
|
||||||
<item name="colorAccent">@color/errorAlertBackground</item>
|
<item name="colorAccent">@color/errorAlertBackground</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<style name="WizardPagePodContent">
|
<style name="WizardPagePodContent">
|
||||||
<item name="android:layout_width">match_parent</item>
|
<item name="android:layout_width">match_parent</item>
|
||||||
<item name="android:layout_height">wrap_content</item>
|
<item name="android:layout_height">wrap_content</item>
|
||||||
|
@ -128,7 +126,4 @@
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -1,63 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
||||||
xmlns:validate="http://schemas.android.com/apk/res-auto">
|
|
||||||
<PreferenceCategory
|
|
||||||
android:title="@string/openapsma"
|
|
||||||
app:initialExpandedChildrenCount="0">
|
|
||||||
|
|
||||||
<info.nightscout.androidaps.utils.textValidator.ValidatingEditTextPreference
|
|
||||||
android:defaultValue="1"
|
|
||||||
android:dialogMessage="@string/openapsma_maxbasal_summary"
|
|
||||||
android:inputType="numberDecimal"
|
|
||||||
android:key="@string/key_openapsma_max_basal"
|
|
||||||
android:title="@string/openapsma_maxbasal_title"
|
|
||||||
validate:floatmaxNumber="12.0"
|
|
||||||
validate:floatminNumber="0.1"
|
|
||||||
validate:testType="floatNumericRange" />
|
|
||||||
|
|
||||||
<info.nightscout.androidaps.utils.textValidator.ValidatingEditTextPreference
|
|
||||||
android:defaultValue="1.5"
|
|
||||||
android:dialogMessage="@string/openapsma_maxiob_summary"
|
|
||||||
android:inputType="numberDecimal"
|
|
||||||
android:key="@string/key_openapsma_max_iob"
|
|
||||||
android:title="@string/openapsma_maxiob_title"
|
|
||||||
validate:floatmaxNumber="12.0"
|
|
||||||
validate:floatminNumber="0"
|
|
||||||
validate:testType="floatNumericRange" />
|
|
||||||
|
|
||||||
<androidx.preference.PreferenceScreen
|
|
||||||
android:key="absorption_ma_advanced"
|
|
||||||
android:title="@string/advancedsettings_title">
|
|
||||||
|
|
||||||
<Preference android:summary="@string/openapsama_link_to_preferncejson_doc_txt">
|
|
||||||
<intent
|
|
||||||
android:action="android.intent.action.VIEW"
|
|
||||||
android:data="@string/openapsama_link_to_preferncejson_doc" />
|
|
||||||
</Preference>
|
|
||||||
|
|
||||||
<SwitchPreference
|
|
||||||
android:defaultValue="false"
|
|
||||||
android:key="@string/key_always_use_shortavg"
|
|
||||||
android:summary="@string/always_use_shortavg_summary"
|
|
||||||
android:title="@string/always_use_shortavg" />
|
|
||||||
|
|
||||||
<info.nightscout.androidaps.utils.textValidator.ValidatingEditTextPreference
|
|
||||||
android:defaultValue="2"
|
|
||||||
android:dialogMessage="@string/openapsama_bolussnooze_dia_divisor_summary"
|
|
||||||
android:digits="0123456789.,"
|
|
||||||
android:inputType="numberDecimal"
|
|
||||||
android:key="@string/key_openapsama_bolussnooze_dia_divisor"
|
|
||||||
android:maxLines="20"
|
|
||||||
android:selectAllOnFocus="true"
|
|
||||||
android:singleLine="true"
|
|
||||||
android:title="@string/openapsama_bolussnooze_dia_divisor"
|
|
||||||
validate:maxNumber="10"
|
|
||||||
validate:minNumber="1"
|
|
||||||
validate:testType="floatNumericRange" />
|
|
||||||
|
|
||||||
</androidx.preference.PreferenceScreen>
|
|
||||||
|
|
||||||
</PreferenceCategory>
|
|
||||||
|
|
||||||
</androidx.preference.PreferenceScreen>
|
|
|
@ -274,39 +274,117 @@
|
||||||
android:title="@string/overview_show_notes_field_in_dialogs_title" />
|
android:title="@string/overview_show_notes_field_in_dialogs_title" />
|
||||||
|
|
||||||
<androidx.preference.PreferenceScreen
|
<androidx.preference.PreferenceScreen
|
||||||
android:key="absorption_overview_advanced"
|
android:key="@string/key_statuslights_overview_advanced"
|
||||||
android:title="@string/advancedsettings_title">
|
android:title="@string/statuslights">
|
||||||
|
|
||||||
<info.nightscout.androidaps.utils.textValidator.ValidatingEditTextPreference
|
|
||||||
android:defaultValue="100"
|
|
||||||
android:dialogMessage="@string/deliverpartofboluswizard"
|
|
||||||
android:inputType="number"
|
|
||||||
android:key="@string/key_boluswizard_percentage"
|
|
||||||
android:maxLines="1"
|
|
||||||
android:selectAllOnFocus="true"
|
|
||||||
android:singleLine="true"
|
|
||||||
android:title="@string/partialboluswizard"
|
|
||||||
validate:maxNumber="100"
|
|
||||||
validate:minNumber="10"
|
|
||||||
validate:testType="numericRange" />
|
|
||||||
|
|
||||||
<SwitchPreference
|
<SwitchPreference
|
||||||
android:defaultValue="false"
|
android:defaultValue="true"
|
||||||
android:key="@string/key_usesuperbolus"
|
|
||||||
android:summary="@string/enablesuperbolus_summary"
|
|
||||||
android:title="@string/enablesuperbolus" />
|
|
||||||
|
|
||||||
<SwitchPreference
|
|
||||||
android:defaultValue="false"
|
|
||||||
android:key="@string/key_show_statuslights"
|
android:key="@string/key_show_statuslights"
|
||||||
android:title="@string/show_statuslights" />
|
android:title="@string/show_statuslights" />
|
||||||
|
|
||||||
<SwitchPreference
|
<info.nightscout.androidaps.utils.textValidator.ValidatingEditTextPreference
|
||||||
android:defaultValue="false"
|
android:defaultValue="48"
|
||||||
android:dependency="@string/key_show_statuslights"
|
android:dependency="@string/key_show_statuslights"
|
||||||
android:key="@string/key_show_statuslights_extended"
|
android:inputType="numberSigned"
|
||||||
android:summary="@string/show_statuslights_extended_summary"
|
android:key="@string/key_statuslights_cage_warning"
|
||||||
android:title="@string/show_statuslights_extended" />
|
android:maxLines="20"
|
||||||
|
android:selectAllOnFocus="true"
|
||||||
|
android:singleLine="true"
|
||||||
|
android:title="@string/statuslights_cage_warning"
|
||||||
|
validate:maxNumber="120"
|
||||||
|
validate:minNumber="24"
|
||||||
|
validate:testType="numericRange" />
|
||||||
|
|
||||||
|
<info.nightscout.androidaps.utils.textValidator.ValidatingEditTextPreference
|
||||||
|
android:defaultValue="72"
|
||||||
|
android:dependency="@string/key_show_statuslights"
|
||||||
|
android:inputType="numberSigned"
|
||||||
|
android:key="@string/key_statuslights_cage_critical"
|
||||||
|
android:maxLines="20"
|
||||||
|
android:selectAllOnFocus="true"
|
||||||
|
android:singleLine="true"
|
||||||
|
android:title="@string/statuslights_cage_critical"
|
||||||
|
validate:maxNumber="120"
|
||||||
|
validate:minNumber="24"
|
||||||
|
validate:testType="numericRange" />
|
||||||
|
|
||||||
|
<info.nightscout.androidaps.utils.textValidator.ValidatingEditTextPreference
|
||||||
|
android:defaultValue="72"
|
||||||
|
android:dependency="@string/key_show_statuslights"
|
||||||
|
android:inputType="numberSigned"
|
||||||
|
android:key="@string/key_statuslights_iage_warning"
|
||||||
|
android:maxLines="20"
|
||||||
|
android:selectAllOnFocus="true"
|
||||||
|
android:singleLine="true"
|
||||||
|
android:title="@string/statuslights_iage_warning"
|
||||||
|
validate:maxNumber="240"
|
||||||
|
validate:minNumber="24"
|
||||||
|
validate:testType="numericRange" />
|
||||||
|
|
||||||
|
<info.nightscout.androidaps.utils.textValidator.ValidatingEditTextPreference
|
||||||
|
android:defaultValue="144"
|
||||||
|
android:dependency="@string/key_show_statuslights"
|
||||||
|
android:inputType="numberSigned"
|
||||||
|
android:key="@string/key_statuslights_iage_critical"
|
||||||
|
android:maxLines="20"
|
||||||
|
android:selectAllOnFocus="true"
|
||||||
|
android:singleLine="true"
|
||||||
|
android:title="@string/statuslights_iage_critical"
|
||||||
|
validate:maxNumber="240"
|
||||||
|
validate:minNumber="24"
|
||||||
|
validate:testType="numericRange" />
|
||||||
|
|
||||||
|
<info.nightscout.androidaps.utils.textValidator.ValidatingEditTextPreference
|
||||||
|
android:defaultValue="216"
|
||||||
|
android:dependency="@string/key_show_statuslights"
|
||||||
|
android:inputType="numberSigned"
|
||||||
|
android:key="@string/key_statuslights_sage_warning"
|
||||||
|
android:maxLines="20"
|
||||||
|
android:selectAllOnFocus="true"
|
||||||
|
android:singleLine="true"
|
||||||
|
android:title="@string/statuslights_sage_warning"
|
||||||
|
validate:maxNumber="720"
|
||||||
|
validate:minNumber="24"
|
||||||
|
validate:testType="numericRange" />
|
||||||
|
|
||||||
|
<info.nightscout.androidaps.utils.textValidator.ValidatingEditTextPreference
|
||||||
|
android:defaultValue="240"
|
||||||
|
android:dependency="@string/key_show_statuslights"
|
||||||
|
android:inputType="numberSigned"
|
||||||
|
android:key="@string/key_statuslights_sage_critical"
|
||||||
|
android:maxLines="20"
|
||||||
|
android:selectAllOnFocus="true"
|
||||||
|
android:singleLine="true"
|
||||||
|
android:title="@string/statuslights_sage_critical"
|
||||||
|
validate:maxNumber="720"
|
||||||
|
validate:minNumber="24"
|
||||||
|
validate:testType="numericRange" />
|
||||||
|
|
||||||
|
<info.nightscout.androidaps.utils.textValidator.ValidatingEditTextPreference
|
||||||
|
android:defaultValue="216"
|
||||||
|
android:dependency="@string/key_show_statuslights"
|
||||||
|
android:inputType="numberSigned"
|
||||||
|
android:key="@string/key_statuslights_bage_warning"
|
||||||
|
android:maxLines="20"
|
||||||
|
android:selectAllOnFocus="true"
|
||||||
|
android:singleLine="true"
|
||||||
|
android:title="@string/statuslights_bage_warning"
|
||||||
|
validate:maxNumber="1000"
|
||||||
|
validate:minNumber="24"
|
||||||
|
validate:testType="numericRange" />
|
||||||
|
|
||||||
|
<info.nightscout.androidaps.utils.textValidator.ValidatingEditTextPreference
|
||||||
|
android:defaultValue="240"
|
||||||
|
android:dependency="@string/key_show_statuslights"
|
||||||
|
android:inputType="numberSigned"
|
||||||
|
android:key="@string/key_statuslights_bage_critical"
|
||||||
|
android:maxLines="20"
|
||||||
|
android:selectAllOnFocus="true"
|
||||||
|
android:singleLine="true"
|
||||||
|
android:title="@string/statuslights_bage_critical"
|
||||||
|
validate:maxNumber="1000"
|
||||||
|
validate:minNumber="24"
|
||||||
|
validate:testType="numericRange" />
|
||||||
|
|
||||||
<info.nightscout.androidaps.utils.textValidator.ValidatingEditTextPreference
|
<info.nightscout.androidaps.utils.textValidator.ValidatingEditTextPreference
|
||||||
android:defaultValue="80"
|
android:defaultValue="80"
|
||||||
|
@ -360,6 +438,37 @@
|
||||||
validate:minNumber="0"
|
validate:minNumber="0"
|
||||||
validate:testType="numericRange" />
|
validate:testType="numericRange" />
|
||||||
|
|
||||||
|
<Preference
|
||||||
|
android:key="@string/key_statuslights_copy_ns"
|
||||||
|
android:dependency="@string/key_show_statuslights"
|
||||||
|
android:title="@string/statuslights_copy_ns">
|
||||||
|
</Preference>
|
||||||
|
|
||||||
|
</androidx.preference.PreferenceScreen>
|
||||||
|
|
||||||
|
<androidx.preference.PreferenceScreen
|
||||||
|
android:key="overview_advanced"
|
||||||
|
android:title="@string/advancedsettings_title">
|
||||||
|
|
||||||
|
<info.nightscout.androidaps.utils.textValidator.ValidatingEditTextPreference
|
||||||
|
android:defaultValue="100"
|
||||||
|
android:dialogMessage="@string/deliverpartofboluswizard"
|
||||||
|
android:inputType="number"
|
||||||
|
android:key="@string/key_boluswizard_percentage"
|
||||||
|
android:maxLines="1"
|
||||||
|
android:selectAllOnFocus="true"
|
||||||
|
android:singleLine="true"
|
||||||
|
android:title="@string/partialboluswizard"
|
||||||
|
validate:maxNumber="100"
|
||||||
|
validate:minNumber="10"
|
||||||
|
validate:testType="numericRange" />
|
||||||
|
|
||||||
|
<SwitchPreference
|
||||||
|
android:defaultValue="false"
|
||||||
|
android:key="@string/key_usesuperbolus"
|
||||||
|
android:summary="@string/enablesuperbolus_summary"
|
||||||
|
android:title="@string/enablesuperbolus" />
|
||||||
|
|
||||||
</androidx.preference.PreferenceScreen>
|
</androidx.preference.PreferenceScreen>
|
||||||
|
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
package info.nightscout.androidaps.data
|
package info.nightscout.androidaps.data
|
||||||
|
|
||||||
|
import dagger.android.AndroidInjector
|
||||||
|
import dagger.android.HasAndroidInjector
|
||||||
|
import info.nightscout.androidaps.TestBase
|
||||||
import info.nightscout.androidaps.db.TemporaryBasal
|
import info.nightscout.androidaps.db.TemporaryBasal
|
||||||
import info.nightscout.androidaps.utils.DateUtil
|
import info.nightscout.androidaps.utils.DateUtil
|
||||||
import info.nightscout.androidaps.utils.T
|
import info.nightscout.androidaps.utils.T
|
||||||
|
@ -9,21 +12,23 @@ import org.junit.runner.RunWith
|
||||||
import org.powermock.modules.junit4.PowerMockRunner
|
import org.powermock.modules.junit4.PowerMockRunner
|
||||||
|
|
||||||
@RunWith(PowerMockRunner::class)
|
@RunWith(PowerMockRunner::class)
|
||||||
class NonOverlappingIntervalsTest {
|
class NonOverlappingIntervalsTest : TestBase() {
|
||||||
|
|
||||||
private val startDate = DateUtil.now()
|
private val startDate = DateUtil.now()
|
||||||
var list = NonOverlappingIntervals<TemporaryBasal>()
|
var list = NonOverlappingIntervals<TemporaryBasal>()
|
||||||
|
|
||||||
|
val injector = HasAndroidInjector { AndroidInjector {} }
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun doTests() {
|
fun doTests() {
|
||||||
// create one 10h interval and test value in and out
|
// create one 10h interval and test value in and out
|
||||||
list.add(TemporaryBasal().date(startDate).duration(T.hours(10).mins().toInt()).absolute(1.0))
|
list.add(TemporaryBasal(injector).date(startDate).duration(T.hours(10).mins().toInt()).absolute(1.0))
|
||||||
Assert.assertEquals(null, list.getValueByInterval(startDate - T.secs(1).msecs()))
|
Assert.assertEquals(null, list.getValueByInterval(startDate - T.secs(1).msecs()))
|
||||||
Assert.assertEquals(1.0, list.getValueByInterval(startDate)!!.absoluteRate, 0.01)
|
Assert.assertEquals(1.0, list.getValueByInterval(startDate)!!.absoluteRate, 0.01)
|
||||||
Assert.assertEquals(null, list.getValueByInterval(startDate + T.hours(10).msecs() + 1))
|
Assert.assertEquals(null, list.getValueByInterval(startDate + T.hours(10).msecs() + 1))
|
||||||
|
|
||||||
// stop temp after 5h
|
// stop temp after 5h
|
||||||
list.add(TemporaryBasal().date(startDate + T.hours(5).msecs()).duration(0))
|
list.add(TemporaryBasal(injector).date(startDate + T.hours(5).msecs()).duration(0))
|
||||||
Assert.assertEquals(null, list.getValueByInterval(startDate - T.secs(1).msecs()))
|
Assert.assertEquals(null, list.getValueByInterval(startDate - T.secs(1).msecs()))
|
||||||
Assert.assertEquals(1.0, list.getValueByInterval(startDate)!!.absoluteRate, 0.01)
|
Assert.assertEquals(1.0, list.getValueByInterval(startDate)!!.absoluteRate, 0.01)
|
||||||
Assert.assertEquals(1.0, list.getValueByInterval(startDate + T.hours(5).msecs() - 1)!!.absoluteRate, 0.01)
|
Assert.assertEquals(1.0, list.getValueByInterval(startDate + T.hours(5).msecs() - 1)!!.absoluteRate, 0.01)
|
||||||
|
@ -31,7 +36,7 @@ class NonOverlappingIntervalsTest {
|
||||||
Assert.assertEquals(null, list.getValueByInterval(startDate + T.hours(10).msecs() + 1))
|
Assert.assertEquals(null, list.getValueByInterval(startDate + T.hours(10).msecs() + 1))
|
||||||
|
|
||||||
// insert 1h interval inside
|
// insert 1h interval inside
|
||||||
list.add(TemporaryBasal().date(startDate + T.hours(3).msecs()).duration(T.hours(1).mins().toInt()).absolute(2.0))
|
list.add(TemporaryBasal(injector).date(startDate + T.hours(3).msecs()).duration(T.hours(1).mins().toInt()).absolute(2.0))
|
||||||
Assert.assertEquals(null, list.getValueByInterval(startDate - T.secs(1).msecs()))
|
Assert.assertEquals(null, list.getValueByInterval(startDate - T.secs(1).msecs()))
|
||||||
Assert.assertEquals(1.0, list.getValueByInterval(startDate)!!.absoluteRate, 0.01)
|
Assert.assertEquals(1.0, list.getValueByInterval(startDate)!!.absoluteRate, 0.01)
|
||||||
Assert.assertEquals(null, list.getValueByInterval(startDate + T.hours(5).msecs() - 1))
|
Assert.assertEquals(null, list.getValueByInterval(startDate + T.hours(5).msecs() - 1))
|
||||||
|
@ -44,7 +49,7 @@ class NonOverlappingIntervalsTest {
|
||||||
@Test
|
@Test
|
||||||
fun testCopyConstructor() {
|
fun testCopyConstructor() {
|
||||||
list.reset()
|
list.reset()
|
||||||
list.add(TemporaryBasal().date(startDate).duration(T.hours(10).mins().toInt()).absolute(1.0))
|
list.add(TemporaryBasal(injector).date(startDate).duration(T.hours(10).mins().toInt()).absolute(1.0))
|
||||||
val list2 = NonOverlappingIntervals(list)
|
val list2 = NonOverlappingIntervals(list)
|
||||||
Assert.assertEquals(1, list2.list.size.toLong())
|
Assert.assertEquals(1, list2.list.size.toLong())
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,20 +2,14 @@ package info.nightscout.androidaps.plugins.aps.loop
|
||||||
|
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.androidaps.TestBase
|
|
||||||
import info.nightscout.androidaps.TestBaseWithProfile
|
import info.nightscout.androidaps.TestBaseWithProfile
|
||||||
import info.nightscout.androidaps.db.TemporaryBasal
|
import info.nightscout.androidaps.db.TemporaryBasal
|
||||||
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
|
||||||
import info.nightscout.androidaps.interfaces.Constraint
|
import info.nightscout.androidaps.interfaces.Constraint
|
||||||
import info.nightscout.androidaps.interfaces.PumpDescription
|
import info.nightscout.androidaps.interfaces.PumpDescription
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker
|
import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction
|
|
||||||
import info.nightscout.androidaps.plugins.pump.common.defs.PumpType
|
import info.nightscout.androidaps.plugins.pump.common.defs.PumpType
|
||||||
import info.nightscout.androidaps.plugins.pump.virtual.VirtualPumpPlugin
|
import info.nightscout.androidaps.plugins.pump.virtual.VirtualPumpPlugin
|
||||||
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin
|
|
||||||
import info.nightscout.androidaps.utils.JsonHelper.safeGetDouble
|
import info.nightscout.androidaps.utils.JsonHelper.safeGetDouble
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
|
||||||
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||||
import org.junit.Assert
|
import org.junit.Assert
|
||||||
import org.junit.Before
|
import org.junit.Before
|
||||||
|
@ -35,6 +29,8 @@ class APSResultTest : TestBaseWithProfile() {
|
||||||
@Mock lateinit var sp: SP
|
@Mock lateinit var sp: SP
|
||||||
@Mock lateinit var virtualPumpPlugin: VirtualPumpPlugin
|
@Mock lateinit var virtualPumpPlugin: VirtualPumpPlugin
|
||||||
|
|
||||||
|
private val injector = HasAndroidInjector { AndroidInjector { } }
|
||||||
|
|
||||||
private var closedLoopEnabled = Constraint(false)
|
private var closedLoopEnabled = Constraint(false)
|
||||||
private val pumpDescription = PumpDescription()
|
private val pumpDescription = PumpDescription()
|
||||||
|
|
||||||
|
@ -79,36 +75,36 @@ class APSResultTest : TestBaseWithProfile() {
|
||||||
Assert.assertEquals(false, apsResult.isChangeRequested)
|
Assert.assertEquals(false, apsResult.isChangeRequested)
|
||||||
|
|
||||||
// request equal temp
|
// request equal temp
|
||||||
`when`(treatmentsPlugin.getTempBasalFromHistory(ArgumentMatchers.anyLong())).thenReturn(TemporaryBasal().percent(70).duration(30))
|
`when`(treatmentsPlugin.getTempBasalFromHistory(ArgumentMatchers.anyLong())).thenReturn(TemporaryBasal(injector).percent(70).duration(30))
|
||||||
apsResult.tempBasalRequested(true).percent(70).duration(30)
|
apsResult.tempBasalRequested(true).percent(70).duration(30)
|
||||||
Assert.assertEquals(false, apsResult.isChangeRequested)
|
Assert.assertEquals(false, apsResult.isChangeRequested)
|
||||||
|
|
||||||
// request zero temp
|
// request zero temp
|
||||||
`when`(treatmentsPlugin.getTempBasalFromHistory(ArgumentMatchers.anyLong())).thenReturn(TemporaryBasal().percent(10).duration(30))
|
`when`(treatmentsPlugin.getTempBasalFromHistory(ArgumentMatchers.anyLong())).thenReturn(TemporaryBasal(injector).percent(10).duration(30))
|
||||||
apsResult.tempBasalRequested(true).percent(0).duration(30)
|
apsResult.tempBasalRequested(true).percent(0).duration(30)
|
||||||
Assert.assertEquals(true, apsResult.isChangeRequested)
|
Assert.assertEquals(true, apsResult.isChangeRequested)
|
||||||
|
|
||||||
// request high temp
|
// request high temp
|
||||||
`when`(treatmentsPlugin.getTempBasalFromHistory(ArgumentMatchers.anyLong())).thenReturn(TemporaryBasal().percent(190).duration(30))
|
`when`(treatmentsPlugin.getTempBasalFromHistory(ArgumentMatchers.anyLong())).thenReturn(TemporaryBasal(injector).percent(190).duration(30))
|
||||||
apsResult.tempBasalRequested(true).percent(200).duration(30)
|
apsResult.tempBasalRequested(true).percent(200).duration(30)
|
||||||
Assert.assertEquals(true, apsResult.isChangeRequested)
|
Assert.assertEquals(true, apsResult.isChangeRequested)
|
||||||
|
|
||||||
// request slightly different temp
|
// request slightly different temp
|
||||||
`when`(treatmentsPlugin.getTempBasalFromHistory(ArgumentMatchers.anyLong())).thenReturn(TemporaryBasal().percent(70).duration(30))
|
`when`(treatmentsPlugin.getTempBasalFromHistory(ArgumentMatchers.anyLong())).thenReturn(TemporaryBasal(injector).percent(70).duration(30))
|
||||||
apsResult.tempBasalRequested(true).percent(80).duration(30)
|
apsResult.tempBasalRequested(true).percent(80).duration(30)
|
||||||
Assert.assertEquals(false, apsResult.isChangeRequested)
|
Assert.assertEquals(false, apsResult.isChangeRequested)
|
||||||
|
|
||||||
// request different temp
|
// request different temp
|
||||||
`when`(treatmentsPlugin.getTempBasalFromHistory(ArgumentMatchers.anyLong())).thenReturn(TemporaryBasal().percent(70).duration(30))
|
`when`(treatmentsPlugin.getTempBasalFromHistory(ArgumentMatchers.anyLong())).thenReturn(TemporaryBasal(injector).percent(70).duration(30))
|
||||||
apsResult.tempBasalRequested(true).percent(120).duration(30)
|
apsResult.tempBasalRequested(true).percent(120).duration(30)
|
||||||
Assert.assertEquals(true, apsResult.isChangeRequested)
|
Assert.assertEquals(true, apsResult.isChangeRequested)
|
||||||
|
|
||||||
// it should work with absolute temps too
|
// it should work with absolute temps too
|
||||||
// request different temp
|
// request different temp
|
||||||
`when`(treatmentsPlugin.getTempBasalFromHistory(ArgumentMatchers.anyLong())).thenReturn(TemporaryBasal().absolute(1.0).duration(30))
|
`when`(treatmentsPlugin.getTempBasalFromHistory(ArgumentMatchers.anyLong())).thenReturn(TemporaryBasal(injector).absolute(1.0).duration(30))
|
||||||
apsResult.tempBasalRequested(true).percent(100).duration(30)
|
apsResult.tempBasalRequested(true).percent(100).duration(30)
|
||||||
Assert.assertEquals(false, apsResult.isChangeRequested)
|
Assert.assertEquals(false, apsResult.isChangeRequested)
|
||||||
`when`(treatmentsPlugin.getTempBasalFromHistory(ArgumentMatchers.anyLong())).thenReturn(TemporaryBasal().absolute(2.0).duration(30))
|
`when`(treatmentsPlugin.getTempBasalFromHistory(ArgumentMatchers.anyLong())).thenReturn(TemporaryBasal(injector).absolute(2.0).duration(30))
|
||||||
apsResult.tempBasalRequested(true).percent(50).duration(30)
|
apsResult.tempBasalRequested(true).percent(50).duration(30)
|
||||||
Assert.assertEquals(true, apsResult.isChangeRequested)
|
Assert.assertEquals(true, apsResult.isChangeRequested)
|
||||||
|
|
||||||
|
@ -124,39 +120,39 @@ class APSResultTest : TestBaseWithProfile() {
|
||||||
Assert.assertEquals(false, apsResult.isChangeRequested)
|
Assert.assertEquals(false, apsResult.isChangeRequested)
|
||||||
|
|
||||||
// request equal temp
|
// request equal temp
|
||||||
`when`(treatmentsPlugin.getTempBasalFromHistory(ArgumentMatchers.anyLong())).thenReturn(TemporaryBasal().absolute(2.0).duration(30))
|
`when`(treatmentsPlugin.getTempBasalFromHistory(ArgumentMatchers.anyLong())).thenReturn(TemporaryBasal(injector).absolute(2.0).duration(30))
|
||||||
apsResult.tempBasalRequested(true).rate(2.0).duration(30)
|
apsResult.tempBasalRequested(true).rate(2.0).duration(30)
|
||||||
Assert.assertEquals(false, apsResult.isChangeRequested)
|
Assert.assertEquals(false, apsResult.isChangeRequested)
|
||||||
`when`(treatmentsPlugin.getTempBasalFromHistory(ArgumentMatchers.anyLong())).thenReturn(TemporaryBasal().percent(200).duration(30))
|
`when`(treatmentsPlugin.getTempBasalFromHistory(ArgumentMatchers.anyLong())).thenReturn(TemporaryBasal(injector).percent(200).duration(30))
|
||||||
apsResult.tempBasalRequested(true).rate(2.0).duration(30)
|
apsResult.tempBasalRequested(true).rate(2.0).duration(30)
|
||||||
Assert.assertEquals(false, apsResult.isChangeRequested)
|
Assert.assertEquals(false, apsResult.isChangeRequested)
|
||||||
|
|
||||||
// request zero temp
|
// request zero temp
|
||||||
`when`(treatmentsPlugin.getTempBasalFromHistory(ArgumentMatchers.anyLong())).thenReturn(TemporaryBasal().absolute(0.1).duration(30))
|
`when`(treatmentsPlugin.getTempBasalFromHistory(ArgumentMatchers.anyLong())).thenReturn(TemporaryBasal(injector).absolute(0.1).duration(30))
|
||||||
apsResult.tempBasalRequested(true).rate(0.0).duration(30)
|
apsResult.tempBasalRequested(true).rate(0.0).duration(30)
|
||||||
Assert.assertEquals(true, apsResult.isChangeRequested)
|
Assert.assertEquals(true, apsResult.isChangeRequested)
|
||||||
|
|
||||||
// request high temp
|
// request high temp
|
||||||
`when`(treatmentsPlugin.getTempBasalFromHistory(ArgumentMatchers.anyLong())).thenReturn(TemporaryBasal().absolute(34.9).duration(30))
|
`when`(treatmentsPlugin.getTempBasalFromHistory(ArgumentMatchers.anyLong())).thenReturn(TemporaryBasal(injector).absolute(34.9).duration(30))
|
||||||
apsResult.tempBasalRequested(true).rate(35.0).duration(30)
|
apsResult.tempBasalRequested(true).rate(35.0).duration(30)
|
||||||
Assert.assertEquals(true, apsResult.isChangeRequested)
|
Assert.assertEquals(true, apsResult.isChangeRequested)
|
||||||
|
|
||||||
// request slightly different temp
|
// request slightly different temp
|
||||||
`when`(treatmentsPlugin.getTempBasalFromHistory(ArgumentMatchers.anyLong())).thenReturn(TemporaryBasal().absolute(1.1).duration(30))
|
`when`(treatmentsPlugin.getTempBasalFromHistory(ArgumentMatchers.anyLong())).thenReturn(TemporaryBasal(injector).absolute(1.1).duration(30))
|
||||||
apsResult.tempBasalRequested(true).rate(1.2).duration(30)
|
apsResult.tempBasalRequested(true).rate(1.2).duration(30)
|
||||||
Assert.assertEquals(false, apsResult.isChangeRequested)
|
Assert.assertEquals(false, apsResult.isChangeRequested)
|
||||||
|
|
||||||
// request different temp
|
// request different temp
|
||||||
`when`(treatmentsPlugin.getTempBasalFromHistory(ArgumentMatchers.anyLong())).thenReturn(TemporaryBasal().absolute(1.1).duration(30))
|
`when`(treatmentsPlugin.getTempBasalFromHistory(ArgumentMatchers.anyLong())).thenReturn(TemporaryBasal(injector).absolute(1.1).duration(30))
|
||||||
apsResult.tempBasalRequested(true).rate(1.5).duration(30)
|
apsResult.tempBasalRequested(true).rate(1.5).duration(30)
|
||||||
Assert.assertEquals(true, apsResult.isChangeRequested)
|
Assert.assertEquals(true, apsResult.isChangeRequested)
|
||||||
|
|
||||||
// it should work with percent temps too
|
// it should work with percent temps too
|
||||||
// request different temp
|
// request different temp
|
||||||
`when`(treatmentsPlugin.getTempBasalFromHistory(ArgumentMatchers.anyLong())).thenReturn(TemporaryBasal().percent(110).duration(30))
|
`when`(treatmentsPlugin.getTempBasalFromHistory(ArgumentMatchers.anyLong())).thenReturn(TemporaryBasal(injector).percent(110).duration(30))
|
||||||
apsResult.tempBasalRequested(true).rate(1.1).duration(30)
|
apsResult.tempBasalRequested(true).rate(1.1).duration(30)
|
||||||
Assert.assertEquals(false, apsResult.isChangeRequested)
|
Assert.assertEquals(false, apsResult.isChangeRequested)
|
||||||
`when`(treatmentsPlugin.getTempBasalFromHistory(ArgumentMatchers.anyLong())).thenReturn(TemporaryBasal().percent(200).duration(30))
|
`when`(treatmentsPlugin.getTempBasalFromHistory(ArgumentMatchers.anyLong())).thenReturn(TemporaryBasal(injector).percent(200).duration(30))
|
||||||
apsResult.tempBasalRequested(true).rate(0.5).duration(30)
|
apsResult.tempBasalRequested(true).rate(0.5).duration(30)
|
||||||
Assert.assertEquals(true, apsResult.isChangeRequested)
|
Assert.assertEquals(true, apsResult.isChangeRequested)
|
||||||
}
|
}
|
||||||
|
@ -173,7 +169,7 @@ class APSResultTest : TestBaseWithProfile() {
|
||||||
it.resourceHelper = resourceHelper
|
it.resourceHelper = resourceHelper
|
||||||
}
|
}
|
||||||
apsResult.rate(10.0)
|
apsResult.rate(10.0)
|
||||||
val apsResult2 = apsResult.newAndClone(HasAndroidInjector { AndroidInjector { Unit } })
|
val apsResult2 = apsResult.newAndClone(injector)
|
||||||
Assert.assertEquals(apsResult.rate, apsResult2.rate, 0.0)
|
Assert.assertEquals(apsResult.rate, apsResult2.rate, 0.0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,6 @@ import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.androidaps.TestBase
|
import info.nightscout.androidaps.TestBase
|
||||||
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
||||||
import info.nightscout.androidaps.interfaces.CommandQueueProvider
|
import info.nightscout.androidaps.interfaces.CommandQueueProvider
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
import info.nightscout.androidaps.plugins.pump.virtual.VirtualPumpPlugin
|
import info.nightscout.androidaps.plugins.pump.virtual.VirtualPumpPlugin
|
||||||
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin
|
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin
|
||||||
|
@ -28,7 +27,6 @@ class ConfigBuilderPluginTest : TestBase() {
|
||||||
@Mock lateinit var resourceHelper: ResourceHelper
|
@Mock lateinit var resourceHelper: ResourceHelper
|
||||||
@Mock lateinit var commandQueue: CommandQueueProvider
|
@Mock lateinit var commandQueue: CommandQueueProvider
|
||||||
@Mock lateinit var activePlugin: ActivePluginProvider
|
@Mock lateinit var activePlugin: ActivePluginProvider
|
||||||
@Mock lateinit var profileFunction: ProfileFunction
|
|
||||||
|
|
||||||
lateinit var configBuilderPlugin: ConfigBuilderPlugin
|
lateinit var configBuilderPlugin: ConfigBuilderPlugin
|
||||||
|
|
||||||
|
@ -45,6 +43,6 @@ class ConfigBuilderPluginTest : TestBase() {
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
fun prepareMock() {
|
fun prepareMock() {
|
||||||
configBuilderPlugin = ConfigBuilderPlugin(activePlugin, injector, sp, RxBusWrapper(), aapsLogger, resourceHelper, profileFunction)
|
configBuilderPlugin = ConfigBuilderPlugin(injector, aapsLogger, resourceHelper, sp, RxBusWrapper(), activePlugin)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -16,9 +16,11 @@ import org.junit.Assert
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
import org.mockito.Mock
|
import org.mockito.Mock
|
||||||
|
import org.powermock.core.classloader.annotations.PrepareForTest
|
||||||
import org.powermock.modules.junit4.PowerMockRunner
|
import org.powermock.modules.junit4.PowerMockRunner
|
||||||
|
|
||||||
@RunWith(PowerMockRunner::class)
|
@RunWith(PowerMockRunner::class)
|
||||||
|
@PrepareForTest(ConfigBuilderPlugin::class)
|
||||||
class AutomationEventTest : TestBase() {
|
class AutomationEventTest : TestBase() {
|
||||||
|
|
||||||
@Mock lateinit var loopPlugin: LoopPlugin
|
@Mock lateinit var loopPlugin: LoopPlugin
|
||||||
|
|
|
@ -21,7 +21,7 @@ import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||||
import org.mockito.Mock
|
import org.mockito.Mock
|
||||||
import org.powermock.core.classloader.annotations.PrepareForTest
|
import org.powermock.core.classloader.annotations.PrepareForTest
|
||||||
|
|
||||||
@PrepareForTest(VirtualPumpPlugin::class, RxBusWrapper::class, LocalProfilePlugin::class, SmsCommunicatorPlugin::class)
|
@PrepareForTest(VirtualPumpPlugin::class, RxBusWrapper::class, LocalProfilePlugin::class, SmsCommunicatorPlugin::class, ConfigBuilderPlugin::class)
|
||||||
open class ActionsTestBase : TestBaseWithProfile() {
|
open class ActionsTestBase : TestBaseWithProfile() {
|
||||||
|
|
||||||
@Mock lateinit var sp: SP
|
@Mock lateinit var sp: SP
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
||||||
|
|
||||||
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.androidaps.TestBase
|
import info.nightscout.androidaps.TestBase
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
import info.nightscout.androidaps.db.TemporaryBasal
|
||||||
|
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction
|
||||||
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump
|
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump
|
||||||
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||||
import org.junit.Before
|
import org.junit.Before
|
||||||
|
@ -11,7 +13,15 @@ import org.mockito.Mock
|
||||||
open class DanaRTestBase : TestBase() {
|
open class DanaRTestBase : TestBase() {
|
||||||
|
|
||||||
@Mock lateinit var sp: SP
|
@Mock lateinit var sp: SP
|
||||||
@Mock lateinit var injector: HasAndroidInjector
|
@Mock lateinit var profileFunction: ProfileFunction
|
||||||
|
|
||||||
|
val injector = HasAndroidInjector {
|
||||||
|
AndroidInjector {
|
||||||
|
if (it is TemporaryBasal) {
|
||||||
|
it.profileFunction = profileFunction
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
lateinit var danaRPump: DanaRPump
|
lateinit var danaRPump: DanaRPump
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ import org.powermock.core.classloader.annotations.PrepareForTest
|
||||||
import org.powermock.modules.junit4.PowerMockRunner
|
import org.powermock.modules.junit4.PowerMockRunner
|
||||||
|
|
||||||
@RunWith(PowerMockRunner::class)
|
@RunWith(PowerMockRunner::class)
|
||||||
@PrepareForTest(ConstraintChecker::class, DetailedBolusInfoStorage::class)
|
@PrepareForTest(ConstraintChecker::class, DetailedBolusInfoStorage::class, ConfigBuilderPlugin::class)
|
||||||
class MessageHashTableRTest : DanaRTestBase() {
|
class MessageHashTableRTest : DanaRTestBase() {
|
||||||
|
|
||||||
@Mock lateinit var rxBus: RxBusWrapper
|
@Mock lateinit var rxBus: RxBusWrapper
|
||||||
|
@ -36,7 +36,7 @@ class MessageHashTableRTest : DanaRTestBase() {
|
||||||
|
|
||||||
@Test fun runTest() {
|
@Test fun runTest() {
|
||||||
Mockito.`when`(constraintChecker.applyBolusConstraints(anyObject())).thenReturn(Constraint(0.0))
|
Mockito.`when`(constraintChecker.applyBolusConstraints(anyObject())).thenReturn(Constraint(0.0))
|
||||||
val messageHashTable = MessageHashTableR(aapsLogger, rxBus, resourceHelper, constraintChecker, danaRPump, danaRPlugin, danaRKoreanPlugin, configBuilderPlugin, commandQueue, activePlugin)
|
val messageHashTable = MessageHashTableR(aapsLogger, rxBus, resourceHelper, constraintChecker, danaRPump, danaRPlugin, danaRKoreanPlugin, configBuilderPlugin, commandQueue, activePlugin, injector)
|
||||||
val testMessage = messageHashTable.findMessage(0x41f2)
|
val testMessage = messageHashTable.findMessage(0x41f2)
|
||||||
Assert.assertEquals("CMD_HISTORY_ALL", testMessage.messageName)
|
Assert.assertEquals("CMD_HISTORY_ALL", testMessage.messageName)
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@ import org.powermock.core.classloader.annotations.PrepareForTest
|
||||||
import org.powermock.modules.junit4.PowerMockRunner
|
import org.powermock.modules.junit4.PowerMockRunner
|
||||||
|
|
||||||
@RunWith(PowerMockRunner::class)
|
@RunWith(PowerMockRunner::class)
|
||||||
@PrepareForTest(DanaRKoreanPlugin::class, DanaRPlugin::class)
|
@PrepareForTest(DanaRKoreanPlugin::class, DanaRPlugin::class, ConfigBuilderPlugin::class)
|
||||||
class MsgInitConnStatusTimeTest : DanaRTestBase() {
|
class MsgInitConnStatusTimeTest : DanaRTestBase() {
|
||||||
|
|
||||||
@Mock lateinit var resourceHelper: ResourceHelper
|
@Mock lateinit var resourceHelper: ResourceHelper
|
||||||
|
|
|
@ -1,15 +1,18 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
||||||
|
|
||||||
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
||||||
|
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin
|
||||||
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin
|
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin
|
||||||
import org.junit.Assert
|
import org.junit.Assert
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
import org.mockito.Mock
|
import org.mockito.Mock
|
||||||
import org.mockito.Mockito.`when`
|
import org.mockito.Mockito.`when`
|
||||||
|
import org.powermock.core.classloader.annotations.PrepareForTest
|
||||||
import org.powermock.modules.junit4.PowerMockRunner
|
import org.powermock.modules.junit4.PowerMockRunner
|
||||||
|
|
||||||
@RunWith(PowerMockRunner::class)
|
@RunWith(PowerMockRunner::class)
|
||||||
|
@PrepareForTest(ConfigBuilderPlugin::class)
|
||||||
class MsgStatusTempBasalTest : DanaRTestBase() {
|
class MsgStatusTempBasalTest : DanaRTestBase() {
|
||||||
|
|
||||||
@Mock lateinit var activePlugin: ActivePluginProvider
|
@Mock lateinit var activePlugin: ActivePluginProvider
|
||||||
|
@ -17,7 +20,7 @@ class MsgStatusTempBasalTest : DanaRTestBase() {
|
||||||
|
|
||||||
@Test fun runTest() {
|
@Test fun runTest() {
|
||||||
`when`(activePlugin.activeTreatments).thenReturn(treatmentsPlugin)
|
`when`(activePlugin.activeTreatments).thenReturn(treatmentsPlugin)
|
||||||
val packet = MsgStatusTempBasal(aapsLogger, danaRPump, activePlugin)
|
val packet = MsgStatusTempBasal(aapsLogger, danaRPump, activePlugin, injector)
|
||||||
// test message decoding
|
// test message decoding
|
||||||
// test message decoding
|
// test message decoding
|
||||||
packet.handleMessage(createArray(34, 1.toByte()))
|
packet.handleMessage(createArray(34, 1.toByte()))
|
||||||
|
|
|
@ -19,7 +19,7 @@ import org.powermock.core.classloader.annotations.PrepareForTest
|
||||||
import org.powermock.modules.junit4.PowerMockRunner
|
import org.powermock.modules.junit4.PowerMockRunner
|
||||||
|
|
||||||
@RunWith(PowerMockRunner::class)
|
@RunWith(PowerMockRunner::class)
|
||||||
@PrepareForTest(ConstraintChecker::class, DetailedBolusInfoStorage::class)
|
@PrepareForTest(ConstraintChecker::class, DetailedBolusInfoStorage::class, ConfigBuilderPlugin::class)
|
||||||
class MessageHashTableRKoreanTest : DanaRSTestBase() {
|
class MessageHashTableRKoreanTest : DanaRSTestBase() {
|
||||||
|
|
||||||
@Mock lateinit var constraintChecker: ConstraintChecker
|
@Mock lateinit var constraintChecker: ConstraintChecker
|
||||||
|
@ -32,7 +32,7 @@ class MessageHashTableRKoreanTest : DanaRSTestBase() {
|
||||||
|
|
||||||
@Test fun runTest() {
|
@Test fun runTest() {
|
||||||
Mockito.`when`(constraintChecker.applyBolusConstraints(anyObject())).thenReturn(Constraint(0.0))
|
Mockito.`when`(constraintChecker.applyBolusConstraints(anyObject())).thenReturn(Constraint(0.0))
|
||||||
val messageHashTable = MessageHashTableRKorean(aapsLogger, rxBus, resourceHelper, constraintChecker, danaRPump, danaRPlugin, danaRKoreanPlugin, configBuilderPlugin, commandQueue, activePlugin)
|
val messageHashTable = MessageHashTableRKorean(aapsLogger, rxBus, resourceHelper, constraintChecker, danaRPump, danaRPlugin, danaRKoreanPlugin, configBuilderPlugin, commandQueue, activePlugin, injector)
|
||||||
val testMessage = messageHashTable.findMessage(0x41f2)
|
val testMessage = messageHashTable.findMessage(0x41f2)
|
||||||
Assert.assertEquals("CMD_HISTORY_ALL", testMessage.messageName)
|
Assert.assertEquals("CMD_HISTORY_ALL", testMessage.messageName)
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ class DanaRSMessageHashTableTest : DanaRSTestBase() {
|
||||||
fun runTest() {
|
fun runTest() {
|
||||||
`when`(constraintChecker.applyBolusConstraints(anyObject())).thenReturn(Constraint(0.0))
|
`when`(constraintChecker.applyBolusConstraints(anyObject())).thenReturn(Constraint(0.0))
|
||||||
|
|
||||||
val danaRSMessageHashTable = DanaRSMessageHashTable(aapsLogger, rxBus, resourceHelper, danaRPump, danaRSPlugin, activePlugin, constraintChecker, detailedBolusInfoStorage)
|
val danaRSMessageHashTable = DanaRSMessageHashTable(aapsLogger, rxBus, resourceHelper, danaRPump, danaRSPlugin, activePlugin, constraintChecker, detailedBolusInfoStorage, injector)
|
||||||
val forTesting: DanaRS_Packet = DanaRS_Packet_APS_Set_Event_History(aapsLogger, DanaRPump.CARBS, 0, 0, 0)
|
val forTesting: DanaRS_Packet = DanaRS_Packet_APS_Set_Event_History(aapsLogger, DanaRPump.CARBS, 0, 0, 0)
|
||||||
val testPacket: DanaRS_Packet = danaRSMessageHashTable.findMessage(forTesting.command)
|
val testPacket: DanaRS_Packet = danaRSMessageHashTable.findMessage(forTesting.command)
|
||||||
Assert.assertEquals(BleCommandUtil.DANAR_PACKET__OPCODE__APS_SET_EVENT_HISTORY.toLong(), testPacket.getOpCode().toLong())
|
Assert.assertEquals(BleCommandUtil.DANAR_PACKET__OPCODE__APS_SET_EVENT_HISTORY.toLong(), testPacket.getOpCode().toLong())
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
||||||
|
|
||||||
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.androidaps.TestBaseWithProfile
|
import info.nightscout.androidaps.TestBaseWithProfile
|
||||||
|
import info.nightscout.androidaps.db.TemporaryBasal
|
||||||
|
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction
|
||||||
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump
|
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump
|
||||||
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||||
import org.junit.Before
|
import org.junit.Before
|
||||||
|
@ -10,7 +13,14 @@ import org.mockito.Mock
|
||||||
open class DanaRSTestBase : TestBaseWithProfile() {
|
open class DanaRSTestBase : TestBaseWithProfile() {
|
||||||
|
|
||||||
@Mock lateinit var sp: SP
|
@Mock lateinit var sp: SP
|
||||||
@Mock lateinit var injector: HasAndroidInjector
|
|
||||||
|
val injector = HasAndroidInjector {
|
||||||
|
AndroidInjector {
|
||||||
|
if (it is TemporaryBasal) {
|
||||||
|
it.profileFunction = profileFunction
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
lateinit var danaRPump: DanaRPump
|
lateinit var danaRPump: DanaRPump
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ class DanaRS_Packet_APS_History_EventsTest : DanaRSTestBase() {
|
||||||
@Test fun runTest() {
|
@Test fun runTest() {
|
||||||
val now = DateUtil.now()
|
val now = DateUtil.now()
|
||||||
|
|
||||||
val testPacket = DanaRS_Packet_APS_History_Events(aapsLogger, rxBus, resourceHelper, activePlugin, danaRSPlugin, detailedBolusInfoStorage, now)
|
val testPacket = DanaRS_Packet_APS_History_Events(aapsLogger, rxBus, resourceHelper, activePlugin, danaRSPlugin, detailedBolusInfoStorage, injector, now)
|
||||||
// test getRequestedParams
|
// test getRequestedParams
|
||||||
val returnedValues = testPacket.requestParams
|
val returnedValues = testPacket.requestParams
|
||||||
val expectedValues = getCalender(now)
|
val expectedValues = getCalender(now)
|
||||||
|
|
|
@ -23,7 +23,7 @@ import org.powermock.core.classloader.annotations.PrepareForTest
|
||||||
import org.powermock.modules.junit4.PowerMockRunner
|
import org.powermock.modules.junit4.PowerMockRunner
|
||||||
|
|
||||||
@RunWith(PowerMockRunner::class)
|
@RunWith(PowerMockRunner::class)
|
||||||
@PrepareForTest(ConstraintChecker::class, DetailedBolusInfoStorage::class)
|
@PrepareForTest(ConstraintChecker::class, DetailedBolusInfoStorage::class, ConfigBuilderPlugin::class)
|
||||||
class MessageHashTable_rv2Test : DanaRTestBase() {
|
class MessageHashTable_rv2Test : DanaRTestBase() {
|
||||||
|
|
||||||
@Mock lateinit var rxBus: RxBusWrapper
|
@Mock lateinit var rxBus: RxBusWrapper
|
||||||
|
@ -41,7 +41,7 @@ class MessageHashTable_rv2Test : DanaRTestBase() {
|
||||||
@Test
|
@Test
|
||||||
fun runTest() {
|
fun runTest() {
|
||||||
`when`(constraintChecker.applyBolusConstraints(anyObject())).thenReturn(Constraint(0.0))
|
`when`(constraintChecker.applyBolusConstraints(anyObject())).thenReturn(Constraint(0.0))
|
||||||
val messageHashTableRv2 = MessageHashTableRv2(aapsLogger, rxBus, resourceHelper, constraintChecker, danaRPump, danaRPlugin, danaRKoreanPlugin, danaRv2Plugin, configBuilderPlugin, commandQueue, activePlugin, detailedBolusInfoStorage, treatmentsPlugin)
|
val messageHashTableRv2 = MessageHashTableRv2(aapsLogger, rxBus, resourceHelper, constraintChecker, danaRPump, danaRPlugin, danaRKoreanPlugin, danaRv2Plugin, configBuilderPlugin, commandQueue, activePlugin, detailedBolusInfoStorage, treatmentsPlugin, injector)
|
||||||
val forTesting: MessageBase = MsgStatusAPS_v2(aapsLogger, danaRPump)
|
val forTesting: MessageBase = MsgStatusAPS_v2(aapsLogger, danaRPump)
|
||||||
val testPacket: MessageBase = messageHashTableRv2.findMessage(forTesting.command)
|
val testPacket: MessageBase = messageHashTableRv2.findMessage(forTesting.command)
|
||||||
Assert.assertEquals(0xE001, testPacket.command.toLong())
|
Assert.assertEquals(0xE001, testPacket.command.toLong())
|
||||||
|
|
|
@ -17,7 +17,7 @@ import org.powermock.core.classloader.annotations.PrepareForTest
|
||||||
import org.powermock.modules.junit4.PowerMockRunner
|
import org.powermock.modules.junit4.PowerMockRunner
|
||||||
|
|
||||||
@RunWith(PowerMockRunner::class)
|
@RunWith(PowerMockRunner::class)
|
||||||
@PrepareForTest(DanaRKoreanPlugin::class, DanaRPlugin::class, DanaRv2Plugin::class)
|
@PrepareForTest(DanaRKoreanPlugin::class, DanaRPlugin::class, DanaRv2Plugin::class, ConfigBuilderPlugin::class)
|
||||||
class MsgCheckValue_v2Test : DanaRTestBase() {
|
class MsgCheckValue_v2Test : DanaRTestBase() {
|
||||||
|
|
||||||
val rxBus = RxBusWrapper()
|
val rxBus = RxBusWrapper()
|
||||||
|
|
|
@ -23,7 +23,7 @@ class MsgHistoryEvents_v2Test : DanaRTestBase() {
|
||||||
@Mock lateinit var treatmentsPlugin: TreatmentsPlugin
|
@Mock lateinit var treatmentsPlugin: TreatmentsPlugin
|
||||||
|
|
||||||
@Test @Throws(Exception::class) fun runTest() {
|
@Test @Throws(Exception::class) fun runTest() {
|
||||||
var packet = MsgHistoryEvents_v2(aapsLogger, resourceHelper, detailedBolusInfoStorage, danaRv2Plugin, RxBusWrapper(), treatmentsPlugin, 0)
|
var packet = MsgHistoryEvents_v2(aapsLogger, resourceHelper, detailedBolusInfoStorage, danaRv2Plugin, RxBusWrapper(), treatmentsPlugin, injector, 0)
|
||||||
|
|
||||||
// test message decoding
|
// test message decoding
|
||||||
val array = ByteArray(100)
|
val array = ByteArray(100)
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
package info.nightscout.androidaps.plugins.treatments
|
package info.nightscout.androidaps.plugins.treatments
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import dagger.android.AndroidInjector
|
||||||
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.androidaps.MainApp
|
import info.nightscout.androidaps.MainApp
|
||||||
import info.nightscout.androidaps.TestBaseWithProfile
|
import info.nightscout.androidaps.TestBaseWithProfile
|
||||||
import info.nightscout.androidaps.db.DatabaseHelper
|
import info.nightscout.androidaps.db.DatabaseHelper
|
||||||
|
@ -32,6 +34,14 @@ class TreatmentsPluginTest : TestBaseWithProfile() {
|
||||||
@Mock lateinit var databaseHelper: DatabaseHelper
|
@Mock lateinit var databaseHelper: DatabaseHelper
|
||||||
@Mock lateinit var treatmentService: TreatmentService
|
@Mock lateinit var treatmentService: TreatmentService
|
||||||
|
|
||||||
|
val injector = HasAndroidInjector {
|
||||||
|
AndroidInjector {
|
||||||
|
if (it is TemporaryBasal) {
|
||||||
|
it.profileFunction = profileFunction
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
lateinit var insulinOrefRapidActingPlugin: InsulinOrefRapidActingPlugin
|
lateinit var insulinOrefRapidActingPlugin: InsulinOrefRapidActingPlugin
|
||||||
lateinit var sot: TreatmentsPlugin
|
lateinit var sot: TreatmentsPlugin
|
||||||
|
|
||||||
|
@ -53,7 +63,7 @@ class TreatmentsPluginTest : TestBaseWithProfile() {
|
||||||
fun `zero TBR should produce zero absolute insulin`() {
|
fun `zero TBR should produce zero absolute insulin`() {
|
||||||
val now = DateUtil.now()
|
val now = DateUtil.now()
|
||||||
val tbrs : MutableList<TemporaryBasal> = ArrayList()
|
val tbrs : MutableList<TemporaryBasal> = ArrayList()
|
||||||
tbrs.add(TemporaryBasal().date(now - T.hours(30). msecs()).duration(10000).percent(0))
|
tbrs.add(TemporaryBasal(injector).date(now - T.hours(30). msecs()).duration(10000).percent(0))
|
||||||
|
|
||||||
`when`(databaseHelper.getTemporaryBasalsDataFromTime(ArgumentMatchers.anyLong(), ArgumentMatchers.anyBoolean())).thenReturn(tbrs)
|
`when`(databaseHelper.getTemporaryBasalsDataFromTime(ArgumentMatchers.anyLong(), ArgumentMatchers.anyBoolean())).thenReturn(tbrs)
|
||||||
sot.initializeData(T.hours(30). msecs())
|
sot.initializeData(T.hours(30). msecs())
|
||||||
|
@ -69,7 +79,7 @@ class TreatmentsPluginTest : TestBaseWithProfile() {
|
||||||
sot.initializeData(T.hours(30). msecs())
|
sot.initializeData(T.hours(30). msecs())
|
||||||
val iob100pct = sot.getAbsoluteIOBTempBasals(now)
|
val iob100pct = sot.getAbsoluteIOBTempBasals(now)
|
||||||
|
|
||||||
tbrs.add(TemporaryBasal().date(now - T.hours(30). msecs()).duration(10000).percent(90))
|
tbrs.add(TemporaryBasal(injector).date(now - T.hours(30). msecs()).duration(10000).percent(90))
|
||||||
sot.initializeData(T.hours(30). msecs())
|
sot.initializeData(T.hours(30). msecs())
|
||||||
val iob90pct = sot.getAbsoluteIOBTempBasals(now)
|
val iob90pct = sot.getAbsoluteIOBTempBasals(now)
|
||||||
Assert.assertTrue(iob100pct.iob > iob90pct.iob)
|
Assert.assertTrue(iob100pct.iob > iob90pct.iob)
|
||||||
|
@ -83,7 +93,7 @@ class TreatmentsPluginTest : TestBaseWithProfile() {
|
||||||
sot.initializeData(T.hours(30). msecs())
|
sot.initializeData(T.hours(30). msecs())
|
||||||
val iob100pct = sot.getAbsoluteIOBTempBasals(now)
|
val iob100pct = sot.getAbsoluteIOBTempBasals(now)
|
||||||
|
|
||||||
tbrs.add(TemporaryBasal().date(now - T.hours(30). msecs()).duration(10000).percent(110))
|
tbrs.add(TemporaryBasal(injector).date(now - T.hours(30). msecs()).duration(10000).percent(110))
|
||||||
sot.initializeData(T.hours(30). msecs())
|
sot.initializeData(T.hours(30). msecs())
|
||||||
val iob110pct = sot.getAbsoluteIOBTempBasals(now)
|
val iob110pct = sot.getAbsoluteIOBTempBasals(now)
|
||||||
Assert.assertEquals(1.1, iob110pct.iob / iob100pct.iob, 0.0001)
|
Assert.assertEquals(1.1, iob110pct.iob / iob100pct.iob, 0.0001)
|
||||||
|
|
|
@ -8,7 +8,7 @@ buildscript {
|
||||||
maven { url 'https://maven.fabric.io/public' }
|
maven { url 'https://maven.fabric.io/public' }
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:3.6.2'
|
classpath 'com.android.tools.build:gradle:3.6.3'
|
||||||
classpath 'com.google.gms:google-services:4.3.3'
|
classpath 'com.google.gms:google-services:4.3.3'
|
||||||
classpath 'io.fabric.tools:gradle:1.31.2'
|
classpath 'io.fabric.tools:gradle:1.31.2'
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue