- gradle fix, that might fix ClassNotFound Exception with Wear

- fix for duplicated entries
- trying to fix overwriting of data from NS (not done yet)
This commit is contained in:
Andy Rozman 2019-04-09 23:14:06 +01:00
parent 2397c8e0d2
commit 26a50bbbc4
7 changed files with 149 additions and 114 deletions

View file

@ -9,6 +9,7 @@ buildscript {
classpath 'com.dicedmelon.gradle:jacoco-android:0.1.3'
}
}
apply plugin: "com.android.application"
apply plugin: 'com.google.gms.google-services'
apply plugin: "io.fabric"
@ -21,6 +22,8 @@ ext {
powermockVersion = "1.7.3"
dexmakerVersion = "1.2"
butterknifeVersion = "8.8.1"
playServicesWearVersion = "10.2.1" // 10.2.1
}
@ -65,7 +68,7 @@ android {
multiDexEnabled true
versionCode 1500
// dev_version: 2.2.3-dev
version "medtronic-0.9.0-SNAPSHOT"
version "medtronic-0.9.1-SNAPSHOT"
buildConfigField "String", "VERSION", '"' + version + '"'
buildConfigField "String", "BUILDVERSION", '"' + generateGitBuild() + '-' + generateDate() + '"'
buildConfigField "String", "HEAD", '"' + generateGitBuild() + '"'
@ -158,6 +161,10 @@ android {
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
flatDir {
dirs 'libs'
}
@ -172,7 +179,10 @@ dependencies {
wearApp project(':wear')
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation "com.google.android.gms:play-services-wearable:16.0.1"
implementation 'com.google.firebase:firebase-core:16.0.8'
//implementation 'com.google.android.gms:play-services-auth:16.0.1'
//implementation 'com.google.firebase:firebase-auth:16.0.1'
implementation("com.crashlytics.sdk.android:crashlytics:2.9.9@aar") {
transitive = true;
}
@ -200,7 +210,7 @@ dependencies {
implementation "com.jjoe64:graphview:4.0.1"
implementation "com.joanzapata.iconify:android-iconify-fontawesome:2.1.1"
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.google.android.gms:play-services-wearable:10.2.1'
implementation(name: "android-edittext-validator-v1.3.4-mod", ext: "aar")
implementation 'com.madgag.spongycastle:core:1.58.0.0'

View file

@ -1,5 +1,6 @@
package info.nightscout.androidaps.plugins.pump.common.defs;
import java.util.HashMap;
import java.util.Map;
@ -7,9 +8,10 @@ import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.plugins.pump.common.data.DoseSettings;
/**
* Created by andy on 02/05/2018.
*
* <p>
* Most of this defintions is intended for VirtualPump only, but they can be used by other plugins.
*/
@ -24,30 +26,35 @@ public enum PumpType {
// Cellnovo
Cellnovo1("Cellnovo", 0.05d, null, //
new DoseSettings(0.05d, 30, 24 * 60, 1d, null), PumpTempBasalType.Percent, new DoseSettings(5, 30, 24 * 60, 0d,
200d), PumpCapability.BasalRate_Duration30minAllowed, //
new DoseSettings(0.05d, 30, 24 * 60, 1d, null),
PumpTempBasalType.Percent,
new DoseSettings(5, 30, 24 * 60, 0d, 200d), PumpCapability.BasalRate_Duration30minAllowed, //
0.05d, 0.05d, null, PumpCapability.VirtualPumpCapabilities), //
// Accu-Chek
AccuChekCombo("Accu-Chek Combo", 0.1d, null, //
new DoseSettings(0.1d, 15, 12 * 60, 0.1d), //
PumpTempBasalType.Percent, new DoseSettings(10, 15, 12 * 60, 0d, 500d), PumpCapability.BasalRate_Duration15and30minAllowed, //
PumpTempBasalType.Percent,
new DoseSettings(10, 15, 12 * 60, 0d, 500d), PumpCapability.BasalRate_Duration15and30minAllowed, //
0.01d, 0.01d, DoseStepSize.ComboBasal, PumpCapability.ComboCapabilities), //
AccuChekSpirit("Accu-Chek Spirit", 0.1d, null, //
new DoseSettings(0.1d, 15, 12 * 60, 0.1d), //
PumpTempBasalType.Percent, new DoseSettings(10, 15, 12 * 60, 0d, 500d), PumpCapability.BasalRate_Duration15and30minAllowed, //
PumpTempBasalType.Percent,
new DoseSettings(10, 15, 12 * 60, 0d, 500d), PumpCapability.BasalRate_Duration15and30minAllowed, //
0.01d, 0.1d, null, PumpCapability.VirtualPumpCapabilities), //
AccuChekInsight("Accu-Chek Insight", 0.05d, DoseStepSize.InsightBolus, //
new DoseSettings(0.05d, 15, 24 * 60, 0.05d), //
PumpTempBasalType.Percent, new DoseSettings(10, 15, 24 * 60, 0d, 250d), PumpCapability.BasalRate_Duration15and30minAllowed, //
PumpTempBasalType.Percent,
new DoseSettings(10, 15, 24 * 60, 0d, 250d), PumpCapability.BasalRate_Duration15and30minAllowed, //
0.02d, 0.01d, null, PumpCapability.InsightCapabilities), //
AccuChekInsightBluetooth("Accu-Chek Insight", 0.01d, null, //
new DoseSettings(0.01d, 15, 24 * 60, 0.05d), //
PumpTempBasalType.Percent, new DoseSettings(10, 15, 24 * 60, 0d, 250d), PumpCapability.BasalRate_Duration15and30minAllowed, //
PumpTempBasalType.Percent,
new DoseSettings(10, 15, 24 * 60, 0d, 250d), PumpCapability.BasalRate_Duration15and30minAllowed, //
0.02d, 0.01d, DoseStepSize.InsightBolus, PumpCapability.InsightCapabilities), //
// Animas
@ -80,12 +87,12 @@ public enum PumpType {
DanaRv2("DanaRv2", DanaRS),
// Insulet
Insulet_Omnipod("Insulet Omnipod", 0.05d, null, //
new DoseSettings(0.05d, 30, 8 * 60, 0.05d), //
PumpTempBasalType.Absolute, //
new DoseSettings(0.05d, 30, 12 * 60, 0d, 30.0d), PumpCapability.BasalRate_Duration30minAllowed, // cannot exceed max
// basal rate 30u/hr
new DoseSettings(0.05d, 30, 12 * 60, 0d, 30.0d), PumpCapability.BasalRate_Duration30minAllowed, // cannot exceed max basal rate 30u/hr
0.05d, 0.05d, null, PumpCapability.VirtualPumpCapabilities),
// Medtronic
@ -114,7 +121,9 @@ public enum PumpType {
// Tandem
TandemTSlim("Tandem t:slim", 0.01d, null, //
new DoseSettings(0.01d, 15, 8 * 60, 0.4d), PumpTempBasalType.Percent, new DoseSettings(1, 15, 8 * 60, 0d, 250d), PumpCapability.BasalRate_Duration15and30minAllowed, //
new DoseSettings(0.01d, 15, 8 * 60, 0.4d),
PumpTempBasalType.Percent,
new DoseSettings(1, 15, 8 * 60, 0d, 250d), PumpCapability.BasalRate_Duration15and30minAllowed, //
0.1d, 0.001d, null, PumpCapability.VirtualPumpCapabilities),
TandemTFlex("Tandem t:flex", TandemTSlim), //
@ -148,37 +157,30 @@ public enum PumpType {
PumpType(String description, PumpType parent) {
this.description = description;
this.parent = parent;
}
PumpType(String description, PumpType parent, PumpCapability pumpCapability) {
this.description = description;
this.parent = parent;
this.pumpCapability = pumpCapability;
}
PumpType(String description, double bolusSize,
DoseStepSize specialBolusSize, //
PumpType(String description, double bolusSize, DoseStepSize specialBolusSize, //
DoseSettings extendedBolusSettings, //
PumpTempBasalType pumpTempBasalType, DoseSettings tbrSettings,
PumpCapability specialBasalDurations, //
double baseBasalMinValue, double baseBasalStep, DoseStepSize baseBasalSpecialSteps,
PumpCapability pumpCapability) {
this(description, bolusSize, specialBolusSize, extendedBolusSettings, pumpTempBasalType, tbrSettings,
specialBasalDurations, baseBasalMinValue, null, baseBasalStep, baseBasalSpecialSteps, pumpCapability);
PumpTempBasalType pumpTempBasalType, DoseSettings tbrSettings, PumpCapability specialBasalDurations, //
double baseBasalMinValue, double baseBasalStep, DoseStepSize baseBasalSpecialSteps, PumpCapability pumpCapability) {
this(description, bolusSize, specialBolusSize, extendedBolusSettings, pumpTempBasalType, tbrSettings, specialBasalDurations, baseBasalMinValue, null, baseBasalStep, baseBasalSpecialSteps, pumpCapability);
}
PumpType(String description, double bolusSize,
DoseStepSize specialBolusSize, //
PumpType(String description, double bolusSize, DoseStepSize specialBolusSize, //
DoseSettings extendedBolusSettings, //
PumpTempBasalType pumpTempBasalType, DoseSettings tbrSettings,
PumpCapability specialBasalDurations, //
double baseBasalMinValue, Double baseBasalMaxValue, double baseBasalStep,
DoseStepSize baseBasalSpecialSteps, PumpCapability pumpCapability) {
PumpTempBasalType pumpTempBasalType, DoseSettings tbrSettings, PumpCapability specialBasalDurations, //
double baseBasalMinValue, Double baseBasalMaxValue, double baseBasalStep, DoseStepSize baseBasalSpecialSteps, PumpCapability pumpCapability) {
this.description = description;
this.bolusSize = bolusSize;
this.specialBolusSize = specialBolusSize;
@ -195,10 +197,10 @@ public enum PumpType {
public String getDescription() {
return description;
}
public PumpCapability getPumpCapability() {
if (isParentSet())
@ -207,63 +209,74 @@ public enum PumpType {
return this.pumpCapability;
}
public double getBolusSize() {
return isParentSet() ? parent.bolusSize : bolusSize;
}
public DoseStepSize getSpecialBolusSize() {
return isParentSet() ? parent.specialBolusSize : specialBolusSize;
}
public DoseSettings getExtendedBolusSettings() {
return isParentSet() ? parent.extendedBolusSettings : extendedBolusSettings;
}
public PumpTempBasalType getPumpTempBasalType() {
return isParentSet() ? parent.pumpTempBasalType : pumpTempBasalType;
}
public DoseSettings getTbrSettings() {
return isParentSet() ? parent.tbrSettings : tbrSettings;
}
public double getBaseBasalMinValue() {
return isParentSet() ? parent.baseBasalMinValue : baseBasalMinValue;
}
public Double getBaseBasalMaxValue() {
return isParentSet() ? parent.baseBasalMaxValue : baseBasalMaxValue;
}
public double getBaseBasalStep() {
return isParentSet() ? parent.baseBasalStep : baseBasalStep;
}
public DoseStepSize getBaseBasalSpecialSteps() {
return isParentSet() ? parent.baseBasalSpecialSteps : baseBasalSpecialSteps;
}
public PumpType getParent() {
return parent;
}
private boolean isParentSet() {
return this.parent != null;
}
public static PumpType getByDescription(String desc) {
if (mapByDescription.containsKey(desc)) {
return mapByDescription.get(desc);
} else {
@ -281,18 +294,17 @@ public enum PumpType {
String extendedNote = hasExtendedBasals ? MainApp.gs(R.string.virtualpump_pump_def_extended_note) : "";
return String.format(
i18nTemplate, //
return String.format(i18nTemplate, //
getStep("" + getBolusSize(), getSpecialBolusSize()), //
eb.getStep(), eb.getDurationStep(),
eb.getMaxDuration() / 60, //
eb.getStep(), eb.getDurationStep(), eb.getMaxDuration() / 60, //
getStep(getBaseBasalRange(), getBaseBasalSpecialSteps()), //
tbr.getMinDose() + unit + "-" + tbr.getMaxDose() + unit, tbr.getStep() + unit, tbr.getDurationStep(),
tbr.getMaxDuration() / 60, extendedNote);
tbr.getMinDose() + unit + "-" + tbr.getMaxDose() + unit, tbr.getStep() + unit,
tbr.getDurationStep(), tbr.getMaxDuration() / 60, extendedNote);
}
private String getBaseBasalRange() {
Double maxValue = getBaseBasalMaxValue();
return maxValue == null ? "" + getBaseBasalMinValue() : getBaseBasalMinValue() + "-" + maxValue;
@ -300,6 +312,7 @@ public enum PumpType {
private String getStep(String step, DoseStepSize stepSize) {
if (stepSize != null)
return step + " [" + stepSize.getDescription() + "] *";
else
@ -308,6 +321,7 @@ public enum PumpType {
public boolean hasExtendedBasals() {
return ((getBaseBasalSpecialSteps() != null) || (getSpecialBolusSize() != null));
}
@ -318,13 +332,12 @@ public enum PumpType {
return parent.getSpecialBasalDurations();
} else {
return specialBasalDurations == null ? //
PumpCapability.BasalRate_Duration15and30minNotAllowed
: specialBasalDurations;
PumpCapability.BasalRate_Duration15and30minNotAllowed : specialBasalDurations;
}
}
public double determineCorrectBolusSize(double bolusAmount) {
if (bolusAmount == 0.0d) {
return bolusAmount;
}
@ -336,7 +349,7 @@ public enum PumpType {
} else {
DoseStepSize specialBolusSize = getSpecialBolusSize();
bolusStepSize = specialBolusSize.getStepSizeForAmount((double)bolusAmount);
bolusStepSize = specialBolusSize.getStepSizeForAmount((double) bolusAmount);
}
return Math.round(bolusAmount / bolusStepSize) * bolusStepSize;
@ -344,6 +357,7 @@ public enum PumpType {
public double determineCorrectExtendedBolusSize(double bolusAmount) {
if (bolusAmount == 0.0d) {
return bolusAmount;
}
@ -367,6 +381,7 @@ public enum PumpType {
public double determineCorrectBasalSize(double basalAmount) {
if (basalAmount == 0.0d) {
return basalAmount;
}
@ -378,7 +393,7 @@ public enum PumpType {
} else {
DoseStepSize specialBolusSize = getBaseBasalSpecialSteps();
basalStepSize = specialBolusSize.getStepSizeForAmount((double)basalAmount);
basalStepSize = specialBolusSize.getStepSizeForAmount((double) basalAmount);
}
if (basalAmount > getTbrSettings().getMaxDose())

View file

@ -44,6 +44,7 @@ public class FabricUtil {
}
}
// FIXME andy!!!
// FabricPrivacy.getInstance().logCustom(customEvent);
}

View file

@ -631,9 +631,9 @@ public class MedtronicPumpHistoryDecoder extends MedtronicHistoryDecoder<PumpHis
if (MedtronicDeviceType.isSameDevice(MedtronicUtil.getMedtronicPumpModel(),
MedtronicDeviceType.Medtronic_523andHigher)) {
bolus.setRequestedAmount(bitUtils.toInt(data[0], data[1]) / 40.0f);
bolus.setDeliveredAmount(bitUtils.toInt(data[2], data[3]) / 40.0f);
bolus.setInsulinOnBoard(bitUtils.toInt(data[4], data[5]) / 40.0f);
bolus.setRequestedAmount(ByteUtil.toInt(data[0], data[1]) / 40.0f);
bolus.setDeliveredAmount(ByteUtil.toInt(data[2], data[3]) / 40.0f);
bolus.setInsulinOnBoard(ByteUtil.toInt(data[4], data[5]) / 40.0f);
bolus.setDuration(data[6] * 30);
} else {
bolus.setRequestedAmount(ByteUtil.asUINT8(data[0]) / 10.0f);

View file

@ -124,6 +124,11 @@ public class PumpHistoryEntry extends MedtronicHistoryEntry {
// }
public boolean isAfter(long atechDateTime) {
if (this.atechDateTime == null) {
LOG.error("Date is null. Show object: " + toString());
return false; // FIXME shouldn't happen
}
return atechDateTime < this.atechDateTime;
}

View file

@ -450,12 +450,13 @@ public class MedtronicHistoryData {
}
}
if (selectedBolus != null)
if (selectedBolus != null) {
boluses.remove(selectedBolus);
removeTreatmentsFromHistory.add(treatment);
}
}
}
treatmentsFromHistory.removeAll(removeTreatmentsFromHistory);
@ -607,11 +608,7 @@ public class MedtronicHistoryData {
case Normal: {
// DetailedBolusInfo normalBolus = new DetailedBolusInfo();
DetailedBolusInfo detailedBolusInfo = DetailedBolusInfoStorage
.findDetailedBolusInfo(tryToGetByLocalTime(bolus.atechDateTime));
if (detailedBolusInfo == null) {
detailedBolusInfo = new DetailedBolusInfo();
}
DetailedBolusInfo detailedBolusInfo = new DetailedBolusInfo();
detailedBolusInfo.date = tryToGetByLocalTime(bolus.atechDateTime);
detailedBolusInfo.source = Source.PUMP;
@ -775,20 +772,22 @@ public class MedtronicHistoryData {
LocalDateTime ldt = DateTimeUtil.toLocalDateTime(atechDateTime);
LOG.debug("TOE. Time of Entry: " + atechDateTime);
LOG.debug("TOE. Clock Pump: " + pumpTime.pumpTime.toString("HH:mm:ss"));
LOG.debug("TOE. LocalTime: " + pumpTime.localDeviceTime.toString("HH:mm:ss"));
LOG.debug("TOE. Difference(s): " + pumpTime.timeDifference);
// LOG.debug("TOE. Time of Entry: " + atechDateTime);
// LOG.debug("TOE. Clock Pump: " + pumpTime.pumpTime.toString("HH:mm:ss"));
// LOG.debug("TOE. LocalTime: " + pumpTime.localDeviceTime.toString("HH:mm:ss"));
// LOG.debug("TOE. Difference(s): " + pumpTime.timeDifference);
ldt = ldt.plusSeconds(pumpTime.timeDifference);
ldt = ldt.millisOfSecond().setCopy(000);
LOG.debug("TOE. New Time Of Entry: " + ldt.toString("HH:mm:ss"));
// LOG.debug("TOE. New Time Of Entry: " + ldt.toString("HH:mm:ss"));
ldt.millisOfSecond().setCopy(000);
LOG.debug("tryToGetByLocalTime: [TimeOfEntry={}, ClockPump={}, LocalTime={}, DifferenceSec={}, "
+ "NewTimeOfEntry={}, time={}", atechDateTime, pumpTime.pumpTime.toString("HH:mm:ss"),
pumpTime.localDeviceTime.toString("HH:mm:ss"), pumpTime.timeDifference, ldt.toString("HH:mm:ss"), ldt
.toDate().getTime());
return ldt.toDate().getTime();
// return 0;
}
@ -803,19 +802,25 @@ public class MedtronicHistoryData {
}
}
LocalDateTime d = DateTimeUtil.toLocalDateTime(dt);
d.minusMinutes(5);
// LOG.debug("Oldest entry: {}, pumpTimeDifference={}", dt, this.pumpTime.timeDifference);
LocalDateTime oldestEntryTime = DateTimeUtil.toLocalDateTime(dt);
oldestEntryTime = oldestEntryTime.minusMinutes(5);
if (this.pumpTime.timeDifference < 0) {
d.plusSeconds(this.pumpTime.timeDifference);
oldestEntryTime = oldestEntryTime.plusSeconds(this.pumpTime.timeDifference);
}
// } else {
// d.minusSeconds(this.pumpTime.timeDifference);
// }
Minutes minutes = Minutes.minutesBetween(d, new LocalDateTime());
LocalDateTime now = new LocalDateTime();
// returns oldest time in history, with calculated time difference between pump and phone, minus 2 minutes
Minutes minutes = Minutes.minutesBetween(oldestEntryTime, now);
// returns oldest time in history, with calculated time difference between pump and phone, minus 5 minutes
LOG.debug("Oldest entry: {}, pumpTimeDifference={}, newDt={}, currentTime={}, differenceMin={}", dt,
this.pumpTime.timeDifference, oldestEntryTime, now, minutes.getMinutes());
return minutes.getMinutes();

View file

@ -168,7 +168,6 @@ public class Treatment implements DataPointWithLabelInterface {
mealBolus = t.mealBolus;
pumpId = t.pumpId;
isSMB = t.isSMB;
source = t.source;
}