:database:entities cleanup
This commit is contained in:
parent
b982afbb49
commit
2200ce0afb
414 changed files with 2402 additions and 2222 deletions
|
@ -60,6 +60,8 @@ import app.aaps.core.ui.dialogs.OKDialog
|
|||
import app.aaps.core.ui.locale.LocaleHelper
|
||||
import app.aaps.core.ui.toast.ToastUtils
|
||||
import app.aaps.core.utils.isRunningRealPumpTest
|
||||
import app.aaps.database.entities.UserEntry.Action
|
||||
import app.aaps.database.entities.UserEntry.Sources
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
import com.google.android.material.tabs.TabLayoutMediator
|
||||
import com.google.firebase.crashlytics.FirebaseCrashlytics
|
||||
|
@ -68,8 +70,6 @@ import com.joanzapata.iconify.fonts.FontAwesomeModule
|
|||
import info.nightscout.androidaps.BuildConfig
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.databinding.ActivityMainBinding
|
||||
import info.nightscout.database.entities.UserEntry.Action
|
||||
import info.nightscout.database.entities.UserEntry.Sources
|
||||
import info.nightscout.plugins.constraints.signatureVerifier.SignatureVerifierPlugin
|
||||
import info.nightscout.ui.activities.ProfileHelperActivity
|
||||
import info.nightscout.ui.activities.StatsActivity
|
||||
|
|
|
@ -13,7 +13,6 @@ import androidx.work.Data
|
|||
import androidx.work.ExistingPeriodicWorkPolicy
|
||||
import androidx.work.PeriodicWorkRequest
|
||||
import androidx.work.WorkManager
|
||||
import app.aaps.di.DaggerAppComponent
|
||||
import app.aaps.core.interfaces.alerts.LocalAlertUtils
|
||||
import app.aaps.core.interfaces.configuration.Config
|
||||
import app.aaps.core.interfaces.configuration.ConfigBuilder
|
||||
|
@ -28,6 +27,10 @@ import app.aaps.core.interfaces.sharedPreferences.SP
|
|||
import app.aaps.core.interfaces.ui.UiInteraction
|
||||
import app.aaps.core.interfaces.utils.DateUtil
|
||||
import app.aaps.core.interfaces.versionChecker.VersionCheckerUtils
|
||||
import app.aaps.core.ui.locale.LocaleHelper
|
||||
import app.aaps.database.entities.TherapyEvent
|
||||
import app.aaps.database.entities.UserEntry
|
||||
import app.aaps.di.DaggerAppComponent
|
||||
import app.aaps.receivers.BTReceiver
|
||||
import app.aaps.receivers.ChargingStateReceiver
|
||||
import app.aaps.receivers.KeepAliveWorker
|
||||
|
@ -36,9 +39,6 @@ import dagger.android.AndroidInjector
|
|||
import dagger.android.DaggerApplication
|
||||
import info.nightscout.androidaps.BuildConfig
|
||||
import info.nightscout.androidaps.R
|
||||
import app.aaps.core.ui.locale.LocaleHelper
|
||||
import info.nightscout.database.entities.TherapyEvent
|
||||
import info.nightscout.database.entities.UserEntry
|
||||
import info.nightscout.database.impl.AppRepository
|
||||
import info.nightscout.database.impl.transactions.InsertIfNewByTimestampTherapyEventTransaction
|
||||
import info.nightscout.database.impl.transactions.VersionChangeTransaction
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
/**
|
||||
* GraphView
|
||||
* Copyright (C) 2014 Jonas Gehring
|
||||
*
|
||||
* <p>
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License,
|
||||
* with the "Linking Exception", which can be found at the license.txt
|
||||
* file in this program.
|
||||
*
|
||||
* <p>
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* <p>
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* with the "Linking Exception" along with this program; if not,
|
||||
* write to the author Jonas Gehring <g.jjoe64@gmail.com>.
|
||||
|
@ -39,122 +39,14 @@ import java.util.Map;
|
|||
*/
|
||||
public class GridLabelRenderer {
|
||||
/**
|
||||
* wrapper for the styles regarding
|
||||
* to the grid and the labels
|
||||
* reference to graphview
|
||||
*/
|
||||
public final class Styles {
|
||||
/**
|
||||
* the general text size of the axis titles.
|
||||
* can be overwritten with #verticalAxisTitleTextSize
|
||||
* and #horizontalAxisTitleTextSize
|
||||
*/
|
||||
public float textSize;
|
||||
|
||||
/**
|
||||
* the alignment of the vertical labels
|
||||
*/
|
||||
public Paint.Align verticalLabelsAlign;
|
||||
|
||||
/**
|
||||
* the alignment of the labels on the right side
|
||||
*/
|
||||
public Paint.Align verticalLabelsSecondScaleAlign;
|
||||
|
||||
/**
|
||||
* the color of the vertical labels
|
||||
*/
|
||||
public int verticalLabelsColor;
|
||||
|
||||
/**
|
||||
* the color of the labels on the right side
|
||||
*/
|
||||
public int verticalLabelsSecondScaleColor;
|
||||
|
||||
/**
|
||||
* the color of the horizontal labels
|
||||
*/
|
||||
public int horizontalLabelsColor;
|
||||
|
||||
/**
|
||||
* the color of the grid lines
|
||||
*/
|
||||
public int gridColor;
|
||||
|
||||
/**
|
||||
* flag whether the zero-lines (vertical+
|
||||
* horizontal) shall be highlighted
|
||||
*/
|
||||
public boolean highlightZeroLines;
|
||||
|
||||
/**
|
||||
* the padding around the graph and labels
|
||||
*/
|
||||
public int padding;
|
||||
|
||||
/**
|
||||
* font size of the vertical axis title
|
||||
*/
|
||||
public float verticalAxisTitleTextSize;
|
||||
|
||||
/**
|
||||
* font color of the vertical axis title
|
||||
*/
|
||||
public int verticalAxisTitleColor;
|
||||
|
||||
/**
|
||||
* font size of the horizontal axis title
|
||||
*/
|
||||
public float horizontalAxisTitleTextSize;
|
||||
|
||||
/**
|
||||
* font color of the horizontal axis title
|
||||
*/
|
||||
public int horizontalAxisTitleColor;
|
||||
|
||||
/**
|
||||
* flag whether the horizontal labels are
|
||||
* visible
|
||||
*/
|
||||
boolean horizontalLabelsVisible;
|
||||
|
||||
/**
|
||||
* flag whether the vertical labels are
|
||||
* visible
|
||||
*/
|
||||
boolean verticalLabelsVisible;
|
||||
|
||||
/**
|
||||
* defines which lines will be drawn in the background
|
||||
*/
|
||||
GridStyle gridStyle;
|
||||
|
||||
/**
|
||||
* the space between the labels text and the graph content
|
||||
*/
|
||||
int labelsSpace;
|
||||
}
|
||||
|
||||
/**
|
||||
* Definition which lines will be drawn in the background
|
||||
*/
|
||||
public enum GridStyle {
|
||||
BOTH, VERTICAL, HORIZONTAL, NONE;
|
||||
|
||||
public boolean drawVertical() { return this == BOTH || this == VERTICAL && this != NONE; }
|
||||
public boolean drawHorizontal() { return this == BOTH || this == HORIZONTAL && this != NONE; }
|
||||
}
|
||||
|
||||
private final GraphView mGraphView;
|
||||
/**
|
||||
* wraps the styles regarding the
|
||||
* grid and labels
|
||||
*/
|
||||
protected Styles mStyles;
|
||||
|
||||
/**
|
||||
* reference to graphview
|
||||
*/
|
||||
private final GraphView mGraphView;
|
||||
|
||||
/**
|
||||
* cache of the vertical steps
|
||||
* (horizontal lines and vertical labels)
|
||||
|
@ -162,7 +54,6 @@ public class GridLabelRenderer {
|
|||
* Value = y-value
|
||||
*/
|
||||
private Map<Integer, Double> mStepsVertical;
|
||||
|
||||
/**
|
||||
* cache of the vertical steps for the
|
||||
* second scale, which is on the right side
|
||||
|
@ -171,7 +62,6 @@ public class GridLabelRenderer {
|
|||
* Value = y-value
|
||||
*/
|
||||
private Map<Integer, Double> mStepsVerticalSecondScale;
|
||||
|
||||
/**
|
||||
* cache of the horizontal steps
|
||||
* (vertical lines and horizontal labels)
|
||||
|
@ -179,92 +69,75 @@ public class GridLabelRenderer {
|
|||
* Value = x-value
|
||||
*/
|
||||
private Map<Integer, Double> mStepsHorizontal;
|
||||
|
||||
/**
|
||||
* the paint to draw the grid lines
|
||||
*/
|
||||
private Paint mPaintLine;
|
||||
|
||||
/**
|
||||
* the paint to draw the labels
|
||||
*/
|
||||
private Paint mPaintLabel;
|
||||
|
||||
/**
|
||||
* the paint to draw axis titles
|
||||
*/
|
||||
private Paint mPaintAxisTitle;
|
||||
|
||||
/**
|
||||
* flag whether is bounds are automatically
|
||||
* adjusted for nice human-readable numbers
|
||||
*/
|
||||
private boolean mIsAdjusted;
|
||||
|
||||
/**
|
||||
* the width of the vertical labels
|
||||
*/
|
||||
private Integer mLabelVerticalWidth;
|
||||
|
||||
/**
|
||||
* indicates if the width was set manually
|
||||
*/
|
||||
private boolean mLabelVerticalWidthFixed;
|
||||
|
||||
/**
|
||||
* the height of the vertical labels
|
||||
*/
|
||||
private Integer mLabelVerticalHeight;
|
||||
|
||||
/**
|
||||
* indicates if the height was set manually
|
||||
*/
|
||||
private boolean mLabelHorizontalHeightFixed;
|
||||
|
||||
/**
|
||||
* the width of the vertical labels
|
||||
* of the second scale
|
||||
*/
|
||||
private Integer mLabelVerticalSecondScaleWidth;
|
||||
|
||||
/**
|
||||
* the height of the vertical labels
|
||||
* of the second scale
|
||||
*/
|
||||
private Integer mLabelVerticalSecondScaleHeight;
|
||||
|
||||
/**
|
||||
* the width of the horizontal labels
|
||||
*/
|
||||
private Integer mLabelHorizontalWidth;
|
||||
|
||||
/**
|
||||
* the height of the horizontal labels
|
||||
*/
|
||||
private Integer mLabelHorizontalHeight;
|
||||
|
||||
/**
|
||||
* the label formatter, that converts
|
||||
* the raw numbers to strings
|
||||
*/
|
||||
private LabelFormatter mLabelFormatter;
|
||||
|
||||
/**
|
||||
* the title of the horizontal axis
|
||||
*/
|
||||
private String mHorizontalAxisTitle;
|
||||
|
||||
/**
|
||||
* the title of the vertical axis
|
||||
*/
|
||||
private String mVerticalAxisTitle;
|
||||
|
||||
/**
|
||||
* count of the vertical labels, that
|
||||
* will be shown at one time.
|
||||
*/
|
||||
private int mNumVerticalLabels;
|
||||
|
||||
/**
|
||||
* count of the horizontal labels, that
|
||||
* will be shown at one time.
|
||||
|
@ -326,7 +199,7 @@ public class GridLabelRenderer {
|
|||
mStyles.gridColor = color2;
|
||||
mStyles.textSize = size;
|
||||
mStyles.padding = size2;
|
||||
mStyles.labelsSpace = (int) mStyles.textSize/5;
|
||||
mStyles.labelsSpace = (int) mStyles.textSize / 5;
|
||||
|
||||
mStyles.verticalLabelsAlign = Paint.Align.RIGHT;
|
||||
mStyles.verticalLabelsSecondScaleAlign = Paint.Align.LEFT;
|
||||
|
@ -369,6 +242,15 @@ public class GridLabelRenderer {
|
|||
return mStyles.textSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param textSize the general text size of the axis titles.
|
||||
* can be overwritten with {@link #setVerticalAxisTitleTextSize(float)}
|
||||
* and {@link #setHorizontalAxisTitleTextSize(float)}
|
||||
*/
|
||||
public void setTextSize(float textSize) {
|
||||
mStyles.textSize = textSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the font color of the vertical labels
|
||||
*/
|
||||
|
@ -376,6 +258,13 @@ public class GridLabelRenderer {
|
|||
return mStyles.verticalLabelsColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param verticalLabelsColor the color of the vertical labels
|
||||
*/
|
||||
public void setVerticalLabelsColor(int verticalLabelsColor) {
|
||||
mStyles.verticalLabelsColor = verticalLabelsColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the alignment of the text of the
|
||||
* vertical labels
|
||||
|
@ -384,6 +273,13 @@ public class GridLabelRenderer {
|
|||
return mStyles.verticalLabelsAlign;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param verticalLabelsAlign the alignment of the vertical labels
|
||||
*/
|
||||
public void setVerticalLabelsAlign(Paint.Align verticalLabelsAlign) {
|
||||
mStyles.verticalLabelsAlign = verticalLabelsAlign;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the font color of the horizontal labels
|
||||
*/
|
||||
|
@ -391,6 +287,13 @@ public class GridLabelRenderer {
|
|||
return mStyles.horizontalLabelsColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param horizontalLabelsColor the color of the horizontal labels
|
||||
*/
|
||||
public void setHorizontalLabelsColor(int horizontalLabelsColor) {
|
||||
mStyles.horizontalLabelsColor = horizontalLabelsColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* clears the internal cache and forces
|
||||
* to redraw the grid and labels.
|
||||
|
@ -677,7 +580,7 @@ public class GridLabelRenderer {
|
|||
if (mStepsHorizontal != null) {
|
||||
mStepsHorizontal.clear();
|
||||
} else {
|
||||
mStepsHorizontal = new LinkedHashMap<Integer, Double>((int) numHorizontalLabels);
|
||||
mStepsHorizontal = new LinkedHashMap<Integer, Double>(numHorizontalLabels);
|
||||
}
|
||||
int width = mGraphView.getGraphContentWidth();
|
||||
|
||||
|
@ -1167,50 +1070,6 @@ public class GridLabelRenderer {
|
|||
return mStyles.gridColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return whether the line at 0 are highlighted
|
||||
*/
|
||||
public boolean isHighlightZeroLines() {
|
||||
return mStyles.highlightZeroLines;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the padding around the grid and labels
|
||||
*/
|
||||
public int getPadding() {
|
||||
return mStyles.padding;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param textSize the general text size of the axis titles.
|
||||
* can be overwritten with {@link #setVerticalAxisTitleTextSize(float)}
|
||||
* and {@link #setHorizontalAxisTitleTextSize(float)}
|
||||
*/
|
||||
public void setTextSize(float textSize) {
|
||||
mStyles.textSize = textSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param verticalLabelsAlign the alignment of the vertical labels
|
||||
*/
|
||||
public void setVerticalLabelsAlign(Paint.Align verticalLabelsAlign) {
|
||||
mStyles.verticalLabelsAlign = verticalLabelsAlign;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param verticalLabelsColor the color of the vertical labels
|
||||
*/
|
||||
public void setVerticalLabelsColor(int verticalLabelsColor) {
|
||||
mStyles.verticalLabelsColor = verticalLabelsColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param horizontalLabelsColor the color of the horizontal labels
|
||||
*/
|
||||
public void setHorizontalLabelsColor(int horizontalLabelsColor) {
|
||||
mStyles.horizontalLabelsColor = horizontalLabelsColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param gridColor the color of the grid lines
|
||||
*/
|
||||
|
@ -1218,6 +1077,13 @@ public class GridLabelRenderer {
|
|||
mStyles.gridColor = gridColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return whether the line at 0 are highlighted
|
||||
*/
|
||||
public boolean isHighlightZeroLines() {
|
||||
return mStyles.highlightZeroLines;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param highlightZeroLines flag whether the zero-lines (vertical+
|
||||
* horizontal) shall be highlighted
|
||||
|
@ -1226,6 +1092,13 @@ public class GridLabelRenderer {
|
|||
mStyles.highlightZeroLines = highlightZeroLines;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the padding around the grid and labels
|
||||
*/
|
||||
public int getPadding() {
|
||||
return mStyles.padding;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param padding the padding around the graph and labels
|
||||
*/
|
||||
|
@ -1367,7 +1240,7 @@ public class GridLabelRenderer {
|
|||
* of the second scale
|
||||
*/
|
||||
public int getLabelVerticalSecondScaleWidth() {
|
||||
return mLabelVerticalSecondScaleWidth==null?0:mLabelVerticalSecondScaleWidth;
|
||||
return mLabelVerticalSecondScaleWidth == null ? 0 : mLabelVerticalSecondScaleWidth;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1465,4 +1338,115 @@ public class GridLabelRenderer {
|
|||
public void setLabelsSpace(int labelsSpace) {
|
||||
mStyles.labelsSpace = labelsSpace;
|
||||
}
|
||||
|
||||
/**
|
||||
* Definition which lines will be drawn in the background
|
||||
*/
|
||||
public enum GridStyle {
|
||||
BOTH, VERTICAL, HORIZONTAL, NONE;
|
||||
|
||||
public boolean drawVertical() {
|
||||
return this == BOTH || this == VERTICAL && this != NONE;
|
||||
}
|
||||
|
||||
public boolean drawHorizontal() {
|
||||
return this == BOTH || this == HORIZONTAL && this != NONE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* wrapper for the styles regarding
|
||||
* to the grid and the labels
|
||||
*/
|
||||
public final class Styles {
|
||||
/**
|
||||
* the general text size of the axis titles.
|
||||
* can be overwritten with #verticalAxisTitleTextSize
|
||||
* and #horizontalAxisTitleTextSize
|
||||
*/
|
||||
public float textSize;
|
||||
|
||||
/**
|
||||
* the alignment of the vertical labels
|
||||
*/
|
||||
public Paint.Align verticalLabelsAlign;
|
||||
|
||||
/**
|
||||
* the alignment of the labels on the right side
|
||||
*/
|
||||
public Paint.Align verticalLabelsSecondScaleAlign;
|
||||
|
||||
/**
|
||||
* the color of the vertical labels
|
||||
*/
|
||||
public int verticalLabelsColor;
|
||||
|
||||
/**
|
||||
* the color of the labels on the right side
|
||||
*/
|
||||
public int verticalLabelsSecondScaleColor;
|
||||
|
||||
/**
|
||||
* the color of the horizontal labels
|
||||
*/
|
||||
public int horizontalLabelsColor;
|
||||
|
||||
/**
|
||||
* the color of the grid lines
|
||||
*/
|
||||
public int gridColor;
|
||||
|
||||
/**
|
||||
* flag whether the zero-lines (vertical+
|
||||
* horizontal) shall be highlighted
|
||||
*/
|
||||
public boolean highlightZeroLines;
|
||||
|
||||
/**
|
||||
* the padding around the graph and labels
|
||||
*/
|
||||
public int padding;
|
||||
|
||||
/**
|
||||
* font size of the vertical axis title
|
||||
*/
|
||||
public float verticalAxisTitleTextSize;
|
||||
|
||||
/**
|
||||
* font color of the vertical axis title
|
||||
*/
|
||||
public int verticalAxisTitleColor;
|
||||
|
||||
/**
|
||||
* font size of the horizontal axis title
|
||||
*/
|
||||
public float horizontalAxisTitleTextSize;
|
||||
|
||||
/**
|
||||
* font color of the horizontal axis title
|
||||
*/
|
||||
public int horizontalAxisTitleColor;
|
||||
|
||||
/**
|
||||
* flag whether the horizontal labels are
|
||||
* visible
|
||||
*/
|
||||
boolean horizontalLabelsVisible;
|
||||
|
||||
/**
|
||||
* flag whether the vertical labels are
|
||||
* visible
|
||||
*/
|
||||
boolean verticalLabelsVisible;
|
||||
|
||||
/**
|
||||
* defines which lines will be drawn in the background
|
||||
*/
|
||||
GridStyle gridStyle;
|
||||
|
||||
/**
|
||||
* the space between the labels text and the graph content
|
||||
*/
|
||||
int labelsSpace;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
/**
|
||||
* GraphView
|
||||
* Copyright (C) 2014 Jonas Gehring
|
||||
*
|
||||
* <p>
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License,
|
||||
* with the "Linking Exception", which can be found at the license.txt
|
||||
* file in this program.
|
||||
*
|
||||
* <p>
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* <p>
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* with the "Linking Exception" along with this program; if not,
|
||||
* write to the author Jonas Gehring <g.jjoe64@gmail.com>.
|
||||
|
@ -45,33 +45,33 @@ public class BarGraphSeries<E extends DataPointInterface> extends BaseSeries<E>
|
|||
* paint to do drawing on canvas
|
||||
*/
|
||||
private final Paint mPaint;
|
||||
|
||||
/**
|
||||
* stores the coordinates of the bars to
|
||||
* trigger tap on series events.
|
||||
*/
|
||||
private final Map<RectF, E> mDataPoints = new HashMap<RectF, E>();
|
||||
/**
|
||||
* spacing between the bars in percentage.
|
||||
* 0 => no spacing
|
||||
* 100 => the space bewetten the bars is as big as the bars itself
|
||||
*/
|
||||
private int mSpacing;
|
||||
|
||||
/**
|
||||
* callback to generate value-dependent colors
|
||||
* of the bars
|
||||
*/
|
||||
private ValueDependentColor<E> mValueDependentColor;
|
||||
|
||||
/**
|
||||
* flag whether the values should drawn
|
||||
* above the bars as text
|
||||
*/
|
||||
private boolean mDrawValuesOnTop;
|
||||
|
||||
/**
|
||||
* color of the text above the bars.
|
||||
*
|
||||
* @see #mDrawValuesOnTop
|
||||
*/
|
||||
private int mValuesOnTopColor;
|
||||
|
||||
/**
|
||||
* font size of the text above the bars.
|
||||
*
|
||||
|
@ -79,12 +79,6 @@ public class BarGraphSeries<E extends DataPointInterface> extends BaseSeries<E>
|
|||
*/
|
||||
private float mValuesOnTopSize;
|
||||
|
||||
/**
|
||||
* stores the coordinates of the bars to
|
||||
* trigger tap on series events.
|
||||
*/
|
||||
private final Map<RectF, E> mDataPoints = new HashMap<RectF, E>();
|
||||
|
||||
/**
|
||||
* creates bar series without any data
|
||||
*/
|
||||
|
@ -139,10 +133,10 @@ public class BarGraphSeries<E extends DataPointInterface> extends BaseSeries<E>
|
|||
int numValues = 0;
|
||||
boolean isCurrentSeries;
|
||||
SortedSet<Double> xVals = new TreeSet<Double>();
|
||||
for(Series inspectedSeries: graphView.getSeries()) {
|
||||
if(inspectedSeries instanceof BarGraphSeries) {
|
||||
for (Series inspectedSeries : graphView.getSeries()) {
|
||||
if (inspectedSeries instanceof BarGraphSeries) {
|
||||
isCurrentSeries = (inspectedSeries == this);
|
||||
if(isCurrentSeries) {
|
||||
if (isCurrentSeries) {
|
||||
currentSeriesOrder = numBarSeries;
|
||||
}
|
||||
numBarSeries++;
|
||||
|
@ -155,10 +149,14 @@ public class BarGraphSeries<E extends DataPointInterface> extends BaseSeries<E>
|
|||
Iterator<E> curValues = inspectedSeries.getValues(minX, maxX);
|
||||
if (curValues.hasNext()) {
|
||||
xVals.add(curValues.next().getX());
|
||||
if(isCurrentSeries) { numValues++; }
|
||||
if (isCurrentSeries) {
|
||||
numValues++;
|
||||
}
|
||||
while (curValues.hasNext()) {
|
||||
xVals.add(curValues.next().getX());
|
||||
if(isCurrentSeries) { numValues++; }
|
||||
if (isCurrentSeries) {
|
||||
numValues++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -169,8 +167,8 @@ public class BarGraphSeries<E extends DataPointInterface> extends BaseSeries<E>
|
|||
|
||||
Double lastVal = null;
|
||||
double minGap = 0;
|
||||
for(Double curVal: xVals) {
|
||||
if(lastVal != null) {
|
||||
for (Double curVal : xVals) {
|
||||
if (lastVal != null) {
|
||||
double curGap = Math.abs(curVal - lastVal);
|
||||
if (minGap == 0 || (curGap > 0 && curGap < minGap)) {
|
||||
minGap = curGap;
|
||||
|
@ -179,7 +177,7 @@ public class BarGraphSeries<E extends DataPointInterface> extends BaseSeries<E>
|
|||
lastVal = curVal;
|
||||
}
|
||||
|
||||
int numBarSlots = (minGap == 0) ? 1 : (int)Math.round((maxX - minX)/minGap) + 1;
|
||||
int numBarSlots = (minGap == 0) ? 1 : (int) Math.round((maxX - minX) / minGap) + 1;
|
||||
|
||||
Iterator<E> values = getValues(minX, maxX);
|
||||
|
||||
|
@ -187,15 +185,15 @@ public class BarGraphSeries<E extends DataPointInterface> extends BaseSeries<E>
|
|||
// all series, and any spacing between sets of bars
|
||||
float barSlotWidth = numBarSlots == 1
|
||||
? graphView.getGraphContentWidth()
|
||||
: graphView.getGraphContentWidth() / (numBarSlots-1);
|
||||
: graphView.getGraphContentWidth() / (numBarSlots - 1);
|
||||
Log.d("BarGraphSeries", "numBars=" + numBarSlots);
|
||||
|
||||
// Total spacing (both sides) between sets of bars
|
||||
float spacing = Math.min((float) barSlotWidth*mSpacing/100, barSlotWidth*0.98f);
|
||||
float spacing = Math.min(barSlotWidth * mSpacing / 100, barSlotWidth * 0.98f);
|
||||
// Width of an individual bar
|
||||
float barWidth = (barSlotWidth - spacing) / numBarSeries;
|
||||
// Offset from the center of a given bar to start drawing
|
||||
float offset = barSlotWidth/2;
|
||||
float offset = barSlotWidth / 2;
|
||||
|
||||
double diffY = maxY - minY;
|
||||
double diffX = maxX - minX;
|
||||
|
@ -205,7 +203,7 @@ public class BarGraphSeries<E extends DataPointInterface> extends BaseSeries<E>
|
|||
float contentTop = graphView.getGraphContentTop();
|
||||
|
||||
// draw data
|
||||
int i=0;
|
||||
int i = 0;
|
||||
while (values.hasNext()) {
|
||||
E value = values.next();
|
||||
|
||||
|
@ -228,22 +226,22 @@ public class BarGraphSeries<E extends DataPointInterface> extends BaseSeries<E>
|
|||
mPaint.setColor(getColor());
|
||||
}
|
||||
|
||||
float left = (float)x + contentLeft - offset + spacing/2 + currentSeriesOrder*barWidth;
|
||||
float top = (contentTop - (float)y) + contentHeight;
|
||||
float left = (float) x + contentLeft - offset + spacing / 2 + currentSeriesOrder * barWidth;
|
||||
float top = (contentTop - (float) y) + contentHeight;
|
||||
float right = left + barWidth;
|
||||
float bottom = (contentTop - (float)y0) + contentHeight - (graphView.getGridLabelRenderer().isHighlightZeroLines()?4:1);
|
||||
float bottom = (contentTop - (float) y0) + contentHeight - (graphView.getGridLabelRenderer().isHighlightZeroLines() ? 4 : 1);
|
||||
|
||||
boolean reverse = top > bottom;
|
||||
if (reverse) {
|
||||
float tmp = top;
|
||||
top = bottom + (graphView.getGridLabelRenderer().isHighlightZeroLines()?4:1);
|
||||
top = bottom + (graphView.getGridLabelRenderer().isHighlightZeroLines() ? 4 : 1);
|
||||
bottom = tmp;
|
||||
}
|
||||
|
||||
// overdraw
|
||||
left = Math.max(left, contentLeft);
|
||||
right = Math.min(right, contentLeft+contentWidth);
|
||||
bottom = Math.min(bottom, contentTop+contentHeight);
|
||||
right = Math.min(right, contentLeft + contentWidth);
|
||||
bottom = Math.min(bottom, contentTop + contentHeight);
|
||||
top = Math.max(top, contentTop);
|
||||
|
||||
mDataPoints.put(new RectF(left, top, right, bottom), value);
|
||||
|
@ -254,16 +252,16 @@ public class BarGraphSeries<E extends DataPointInterface> extends BaseSeries<E>
|
|||
if (mDrawValuesOnTop) {
|
||||
if (reverse) {
|
||||
top = bottom + mValuesOnTopSize + 4;
|
||||
if (top > contentTop+contentHeight) top = contentTop + contentHeight;
|
||||
if (top > contentTop + contentHeight) top = contentTop + contentHeight;
|
||||
} else {
|
||||
top -= 4;
|
||||
if (top<=contentTop) top+=contentTop+4;
|
||||
if (top <= contentTop) top += contentTop + 4;
|
||||
}
|
||||
|
||||
mPaint.setColor(mValuesOnTopColor);
|
||||
canvas.drawText(
|
||||
graphView.getGridLabelRenderer().getLabelFormatter().formatLabel(value.getY(), false)
|
||||
, (left+right)/2, top, mPaint);
|
||||
, (left + right) / 2, top, mPaint);
|
||||
}
|
||||
|
||||
i++;
|
||||
|
|
|
@ -17,7 +17,7 @@ android {
|
|||
|
||||
namespace 'app.aaps.core.interfaces'
|
||||
defaultConfig {
|
||||
minSdkVersion 25 // for wear
|
||||
minSdkVersion 26 // for wear
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3,8 +3,8 @@ package app.aaps.core.interfaces.aps
|
|||
import android.text.Spanned
|
||||
import app.aaps.core.interfaces.constraints.Constraint
|
||||
import app.aaps.core.interfaces.iob.IobTotal
|
||||
import app.aaps.database.entities.GlucoseValue
|
||||
import dagger.android.HasAndroidInjector
|
||||
import info.nightscout.database.entities.GlucoseValue
|
||||
import org.json.JSONObject
|
||||
|
||||
interface APSResult {
|
||||
|
|
|
@ -4,7 +4,7 @@ import androidx.collection.LongSparseArray
|
|||
import app.aaps.core.interfaces.iob.InMemoryGlucoseValue
|
||||
import app.aaps.core.interfaces.logging.AAPSLogger
|
||||
import app.aaps.core.interfaces.utils.DateUtil
|
||||
import info.nightscout.database.entities.GlucoseValue
|
||||
import app.aaps.database.entities.GlucoseValue
|
||||
|
||||
interface AutosensDataStore {
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ package app.aaps.core.interfaces.aps
|
|||
import app.aaps.core.interfaces.constraints.Constraint
|
||||
import app.aaps.core.interfaces.profile.Profile
|
||||
import app.aaps.core.interfaces.pump.PumpEnactResult
|
||||
import info.nightscout.database.entities.OfflineEvent
|
||||
import app.aaps.database.entities.OfflineEvent
|
||||
|
||||
interface Loop {
|
||||
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
package app.aaps.core.interfaces.db
|
||||
|
||||
import app.aaps.core.interfaces.queue.Callback
|
||||
import app.aaps.database.ValueWrapper
|
||||
import app.aaps.database.entities.Bolus
|
||||
import app.aaps.database.entities.BolusCalculatorResult
|
||||
import app.aaps.database.entities.Carbs
|
||||
import app.aaps.database.entities.EffectiveProfileSwitch
|
||||
import app.aaps.database.entities.TemporaryTarget
|
||||
import app.aaps.database.entities.UserEntry
|
||||
import dagger.android.HasAndroidInjector
|
||||
import info.nightscout.database.ValueWrapper
|
||||
import info.nightscout.database.entities.Bolus
|
||||
import info.nightscout.database.entities.BolusCalculatorResult
|
||||
import info.nightscout.database.entities.Carbs
|
||||
import info.nightscout.database.entities.EffectiveProfileSwitch
|
||||
import info.nightscout.database.entities.TemporaryTarget
|
||||
import info.nightscout.database.entities.UserEntry
|
||||
import io.reactivex.rxjava3.core.Single
|
||||
|
||||
interface PersistenceLayer {
|
||||
|
|
|
@ -2,8 +2,8 @@ package app.aaps.core.interfaces.insulin
|
|||
|
||||
import app.aaps.core.interfaces.configuration.ConfigExportImport
|
||||
import app.aaps.core.interfaces.iob.Iob
|
||||
import info.nightscout.database.entities.Bolus
|
||||
import info.nightscout.database.entities.embedments.InsulinConfiguration
|
||||
import app.aaps.database.entities.Bolus
|
||||
import app.aaps.database.entities.embedments.InsulinConfiguration
|
||||
|
||||
interface Insulin : ConfigExportImport {
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package app.aaps.core.interfaces.iob
|
||||
|
||||
import info.nightscout.database.entities.GlucoseValue
|
||||
import app.aaps.database.entities.GlucoseValue
|
||||
|
||||
/**
|
||||
* Simplified [GlucoseValue] for storing in memory and calculations
|
||||
|
|
|
@ -5,8 +5,8 @@ import app.aaps.core.interfaces.aps.AutosensDataStore
|
|||
import app.aaps.core.interfaces.aps.AutosensResult
|
||||
import app.aaps.core.interfaces.aps.BasalData
|
||||
import app.aaps.core.interfaces.profile.Profile
|
||||
import info.nightscout.database.entities.ExtendedBolus
|
||||
import info.nightscout.database.entities.TemporaryBasal
|
||||
import app.aaps.database.entities.ExtendedBolus
|
||||
import app.aaps.database.entities.TemporaryBasal
|
||||
import org.json.JSONArray
|
||||
|
||||
interface IobCobCalculator {
|
||||
|
|
|
@ -2,10 +2,10 @@ package app.aaps.core.interfaces.logging
|
|||
|
||||
import app.aaps.core.interfaces.userEntry.UserEntryMapper
|
||||
import app.aaps.core.interfaces.userEntry.ValueWithUnitMapper
|
||||
import info.nightscout.database.entities.UserEntry
|
||||
import info.nightscout.database.entities.UserEntry.Action
|
||||
import info.nightscout.database.entities.UserEntry.Sources
|
||||
import info.nightscout.database.entities.ValueWithUnit
|
||||
import app.aaps.database.entities.UserEntry
|
||||
import app.aaps.database.entities.UserEntry.Action
|
||||
import app.aaps.database.entities.UserEntry.Sources
|
||||
import app.aaps.database.entities.ValueWithUnit
|
||||
|
||||
interface UserEntryLogger {
|
||||
|
||||
|
|
|
@ -1,19 +1,19 @@
|
|||
package app.aaps.core.interfaces.nsclient
|
||||
|
||||
import info.nightscout.database.entities.Bolus
|
||||
import info.nightscout.database.entities.BolusCalculatorResult
|
||||
import info.nightscout.database.entities.Carbs
|
||||
import info.nightscout.database.entities.DeviceStatus
|
||||
import info.nightscout.database.entities.EffectiveProfileSwitch
|
||||
import info.nightscout.database.entities.ExtendedBolus
|
||||
import info.nightscout.database.entities.Food
|
||||
import info.nightscout.database.entities.GlucoseValue
|
||||
import info.nightscout.database.entities.OfflineEvent
|
||||
import info.nightscout.database.entities.ProfileSwitch
|
||||
import info.nightscout.database.entities.TemporaryBasal
|
||||
import info.nightscout.database.entities.TemporaryTarget
|
||||
import info.nightscout.database.entities.TherapyEvent
|
||||
import info.nightscout.database.transactions.TransactionGlucoseValue
|
||||
import app.aaps.database.entities.Bolus
|
||||
import app.aaps.database.entities.BolusCalculatorResult
|
||||
import app.aaps.database.entities.Carbs
|
||||
import app.aaps.database.entities.DeviceStatus
|
||||
import app.aaps.database.entities.EffectiveProfileSwitch
|
||||
import app.aaps.database.entities.ExtendedBolus
|
||||
import app.aaps.database.entities.Food
|
||||
import app.aaps.database.entities.GlucoseValue
|
||||
import app.aaps.database.entities.OfflineEvent
|
||||
import app.aaps.database.entities.ProfileSwitch
|
||||
import app.aaps.database.entities.TemporaryBasal
|
||||
import app.aaps.database.entities.TemporaryTarget
|
||||
import app.aaps.database.entities.TherapyEvent
|
||||
import app.aaps.database.transactions.TransactionGlucoseValue
|
||||
|
||||
interface StoreDataForDb {
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package app.aaps.core.interfaces.profile
|
||||
|
||||
import app.aaps.core.interfaces.db.GlucoseUnit
|
||||
import info.nightscout.database.entities.ProfileSwitch
|
||||
import app.aaps.database.entities.ProfileSwitch
|
||||
|
||||
interface ProfileFunction {
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package app.aaps.core.interfaces.profile
|
||||
|
||||
import app.aaps.core.interfaces.db.GlucoseUnit
|
||||
import info.nightscout.database.entities.data.Block
|
||||
import info.nightscout.database.entities.data.TargetBlock
|
||||
import app.aaps.database.entities.data.Block
|
||||
import app.aaps.database.entities.data.TargetBlock
|
||||
import org.json.JSONObject
|
||||
import java.util.TimeZone
|
||||
|
||||
|
|
|
@ -2,11 +2,11 @@ package app.aaps.core.interfaces.pump
|
|||
|
||||
import android.content.Context
|
||||
import app.aaps.core.interfaces.pump.defs.PumpType
|
||||
import info.nightscout.database.entities.Bolus
|
||||
import info.nightscout.database.entities.BolusCalculatorResult
|
||||
import info.nightscout.database.entities.Carbs
|
||||
import info.nightscout.database.entities.TherapyEvent
|
||||
import info.nightscout.database.entities.embedments.InterfaceIDs
|
||||
import app.aaps.database.entities.Bolus
|
||||
import app.aaps.database.entities.BolusCalculatorResult
|
||||
import app.aaps.database.entities.Carbs
|
||||
import app.aaps.database.entities.TherapyEvent
|
||||
import app.aaps.database.entities.embedments.InterfaceIDs
|
||||
|
||||
class DetailedBolusInfo {
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ import app.aaps.core.interfaces.pump.defs.PumpType
|
|||
import app.aaps.core.interfaces.utils.DateUtil
|
||||
import app.aaps.core.interfaces.utils.DecimalFormatter
|
||||
import app.aaps.core.interfaces.utils.T
|
||||
import info.nightscout.database.entities.TemporaryBasal
|
||||
import app.aaps.database.entities.TemporaryBasal
|
||||
import kotlin.math.max
|
||||
import kotlin.math.min
|
||||
import kotlin.math.roundToInt
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package app.aaps.core.interfaces.pump
|
||||
|
||||
import android.widget.TextView
|
||||
import info.nightscout.database.entities.TherapyEvent
|
||||
import app.aaps.database.entities.TherapyEvent
|
||||
|
||||
interface WarnColors {
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package app.aaps.core.interfaces.source
|
||||
|
||||
import info.nightscout.database.entities.GlucoseValue
|
||||
import app.aaps.database.entities.GlucoseValue
|
||||
|
||||
interface NSClientSource {
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ package app.aaps.core.interfaces.stats
|
|||
import android.content.Context
|
||||
import android.util.LongSparseArray
|
||||
import android.widget.TableLayout
|
||||
import info.nightscout.database.entities.TotalDailyDose
|
||||
import app.aaps.database.entities.TotalDailyDose
|
||||
|
||||
interface TddCalculator {
|
||||
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
package app.aaps.core.interfaces.sync
|
||||
|
||||
import info.nightscout.database.entities.Bolus
|
||||
import info.nightscout.database.entities.BolusCalculatorResult
|
||||
import info.nightscout.database.entities.Carbs
|
||||
import info.nightscout.database.entities.DeviceStatus
|
||||
import info.nightscout.database.entities.EffectiveProfileSwitch
|
||||
import info.nightscout.database.entities.ExtendedBolus
|
||||
import info.nightscout.database.entities.Food
|
||||
import info.nightscout.database.entities.GlucoseValue
|
||||
import info.nightscout.database.entities.OfflineEvent
|
||||
import info.nightscout.database.entities.ProfileSwitch
|
||||
import info.nightscout.database.entities.TemporaryBasal
|
||||
import info.nightscout.database.entities.TemporaryTarget
|
||||
import info.nightscout.database.entities.TherapyEvent
|
||||
import app.aaps.database.entities.Bolus
|
||||
import app.aaps.database.entities.BolusCalculatorResult
|
||||
import app.aaps.database.entities.Carbs
|
||||
import app.aaps.database.entities.DeviceStatus
|
||||
import app.aaps.database.entities.EffectiveProfileSwitch
|
||||
import app.aaps.database.entities.ExtendedBolus
|
||||
import app.aaps.database.entities.Food
|
||||
import app.aaps.database.entities.GlucoseValue
|
||||
import app.aaps.database.entities.OfflineEvent
|
||||
import app.aaps.database.entities.ProfileSwitch
|
||||
import app.aaps.database.entities.TemporaryBasal
|
||||
import app.aaps.database.entities.TemporaryTarget
|
||||
import app.aaps.database.entities.TherapyEvent
|
||||
import org.json.JSONObject
|
||||
|
||||
interface DataSyncSelector {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package app.aaps.core.interfaces.userEntry
|
||||
|
||||
import info.nightscout.database.entities.UserEntry
|
||||
import app.aaps.database.entities.UserEntry
|
||||
|
||||
class UserEntryMapper {
|
||||
enum class Action(val db: UserEntry.Action) {
|
||||
|
|
|
@ -3,11 +3,11 @@ package app.aaps.core.interfaces.userEntry
|
|||
import android.text.Spanned
|
||||
import androidx.annotation.ColorRes
|
||||
import androidx.annotation.DrawableRes
|
||||
import info.nightscout.database.entities.UserEntry
|
||||
import info.nightscout.database.entities.UserEntry.Action
|
||||
import info.nightscout.database.entities.UserEntry.ColorGroup
|
||||
import info.nightscout.database.entities.UserEntry.Sources
|
||||
import info.nightscout.database.entities.ValueWithUnit
|
||||
import app.aaps.database.entities.UserEntry
|
||||
import app.aaps.database.entities.UserEntry.Action
|
||||
import app.aaps.database.entities.UserEntry.ColorGroup
|
||||
import app.aaps.database.entities.UserEntry.Sources
|
||||
import app.aaps.database.entities.ValueWithUnit
|
||||
|
||||
interface UserEntryPresentationHelper {
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
package app.aaps.core.interfaces.userEntry
|
||||
|
||||
import app.aaps.core.interfaces.db.GlucoseUnit
|
||||
import info.nightscout.database.entities.TemporaryTarget
|
||||
import info.nightscout.database.entities.TherapyEvent
|
||||
import info.nightscout.database.entities.ValueWithUnit
|
||||
import app.aaps.database.entities.TemporaryTarget
|
||||
import app.aaps.database.entities.TherapyEvent
|
||||
import app.aaps.database.entities.ValueWithUnit
|
||||
|
||||
sealed class ValueWithUnitMapper { //I use a sealed class because of StringResource that contains a listOf as second parameter
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
package app.aaps.core.interfaces.utils
|
||||
|
||||
import info.nightscout.database.entities.OfflineEvent
|
||||
import info.nightscout.database.entities.TemporaryTarget
|
||||
import info.nightscout.database.entities.TherapyEvent
|
||||
import info.nightscout.database.entities.UserEntry
|
||||
import info.nightscout.database.entities.ValueWithUnit
|
||||
import app.aaps.database.entities.OfflineEvent
|
||||
import app.aaps.database.entities.TemporaryTarget
|
||||
import app.aaps.database.entities.TherapyEvent
|
||||
import app.aaps.database.entities.UserEntry
|
||||
import app.aaps.database.entities.ValueWithUnit
|
||||
|
||||
interface Translator {
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ package app.aaps.core.interfaces.utils
|
|||
|
||||
import app.aaps.core.interfaces.aps.AutosensDataStore
|
||||
import app.aaps.core.interfaces.iob.InMemoryGlucoseValue
|
||||
import info.nightscout.database.entities.GlucoseValue
|
||||
import app.aaps.database.entities.GlucoseValue
|
||||
|
||||
/**
|
||||
* Convert BG direction value to trend arrow or calculate it if not provided
|
||||
|
|
|
@ -2,8 +2,8 @@ package app.aaps.core.main.extensions
|
|||
|
||||
import app.aaps.core.interfaces.utils.DateUtil
|
||||
import app.aaps.core.interfaces.utils.T
|
||||
import info.nightscout.database.entities.data.Block
|
||||
import info.nightscout.database.entities.data.TargetBlock
|
||||
import app.aaps.database.entities.data.Block
|
||||
import app.aaps.database.entities.data.TargetBlock
|
||||
import org.json.JSONArray
|
||||
import org.json.JSONObject
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ package app.aaps.core.main.extensions
|
|||
import app.aaps.core.interfaces.insulin.Insulin
|
||||
import app.aaps.core.interfaces.iob.Iob
|
||||
import app.aaps.core.interfaces.plugin.ActivePlugin
|
||||
import info.nightscout.database.entities.Bolus
|
||||
import app.aaps.database.entities.Bolus
|
||||
|
||||
fun Bolus.iobCalc(activePlugin: ActivePlugin, time: Long, dia: Double): Iob {
|
||||
if (!isValid || type == Bolus.Type.PRIMING) return Iob()
|
||||
|
|
|
@ -7,10 +7,10 @@ import app.aaps.core.interfaces.profile.Profile
|
|||
import app.aaps.core.interfaces.utils.DateUtil
|
||||
import app.aaps.core.interfaces.utils.DecimalFormatter
|
||||
import app.aaps.core.interfaces.utils.T
|
||||
import info.nightscout.database.entities.Bolus
|
||||
import info.nightscout.database.entities.ExtendedBolus
|
||||
import info.nightscout.database.entities.TemporaryBasal
|
||||
import info.nightscout.database.entities.interfaces.end
|
||||
import app.aaps.database.entities.Bolus
|
||||
import app.aaps.database.entities.ExtendedBolus
|
||||
import app.aaps.database.entities.TemporaryBasal
|
||||
import app.aaps.database.entities.interfaces.end
|
||||
import kotlin.math.ceil
|
||||
import kotlin.math.max
|
||||
import kotlin.math.min
|
||||
|
@ -41,7 +41,7 @@ fun ExtendedBolus.toTemporaryBasal(profile: Profile): TemporaryBasal =
|
|||
isAbsolute = true,
|
||||
isValid = isValid,
|
||||
interfaceIDs_backing = interfaceIDs_backing,
|
||||
type = info.nightscout.database.entities.TemporaryBasal.Type.FAKE_EXTENDED
|
||||
type = TemporaryBasal.Type.FAKE_EXTENDED
|
||||
)
|
||||
|
||||
fun ExtendedBolus.iobCalc(time: Long, profile: Profile, insulinInterface: Insulin): IobTotal {
|
||||
|
@ -61,7 +61,7 @@ fun ExtendedBolus.iobCalc(time: Long, profile: Profile, insulinInterface: Insuli
|
|||
val tempBolusPart = Bolus(
|
||||
timestamp = calcDate,
|
||||
amount = tempBolusSize,
|
||||
type = info.nightscout.database.entities.Bolus.Type.NORMAL
|
||||
type = Bolus.Type.NORMAL
|
||||
)
|
||||
val aIOB = insulinInterface.iobCalcForTreatment(tempBolusPart, time, dia)
|
||||
result.iob += aIOB.iobContrib
|
||||
|
@ -110,7 +110,7 @@ fun ExtendedBolus.iobCalc(
|
|||
val tempBolusPart = Bolus(
|
||||
timestamp = calcDate,
|
||||
amount = tempBolusSize,
|
||||
type = info.nightscout.database.entities.Bolus.Type.NORMAL
|
||||
type = Bolus.Type.NORMAL
|
||||
)
|
||||
val aIOB = insulinInterface.iobCalcForTreatment(tempBolusPart, time, dia)
|
||||
result.iob += aIOB.iobContrib
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
package app.aaps.core.main.extensions
|
||||
|
||||
import app.aaps.core.main.R
|
||||
import app.aaps.core.interfaces.configuration.Constants
|
||||
import app.aaps.core.interfaces.db.GlucoseUnit
|
||||
import app.aaps.core.interfaces.iob.InMemoryGlucoseValue
|
||||
import app.aaps.core.interfaces.utils.DateUtil
|
||||
import info.nightscout.database.entities.GlucoseValue
|
||||
import app.aaps.core.main.R
|
||||
import app.aaps.database.entities.GlucoseValue
|
||||
import org.json.JSONObject
|
||||
|
||||
fun GlucoseValue.toJson(isAdd: Boolean, dateUtil: DateUtil): JSONObject =
|
||||
|
|
|
@ -8,7 +8,7 @@ import app.aaps.core.interfaces.utils.DecimalFormatter
|
|||
import app.aaps.core.interfaces.utils.T
|
||||
import app.aaps.core.main.profile.ProfileSealed
|
||||
import app.aaps.core.utils.JsonHelper
|
||||
import info.nightscout.database.entities.ProfileSwitch
|
||||
import app.aaps.database.entities.ProfileSwitch
|
||||
import org.json.JSONObject
|
||||
import java.util.TimeZone
|
||||
|
||||
|
|
|
@ -7,9 +7,9 @@ import app.aaps.core.interfaces.profile.Profile
|
|||
import app.aaps.core.interfaces.utils.DateUtil
|
||||
import app.aaps.core.interfaces.utils.DecimalFormatter
|
||||
import app.aaps.core.interfaces.utils.T
|
||||
import info.nightscout.database.entities.Bolus
|
||||
import info.nightscout.database.entities.TemporaryBasal
|
||||
import info.nightscout.database.entities.interfaces.end
|
||||
import app.aaps.database.entities.Bolus
|
||||
import app.aaps.database.entities.TemporaryBasal
|
||||
import app.aaps.database.entities.interfaces.end
|
||||
import kotlin.math.ceil
|
||||
import kotlin.math.max
|
||||
import kotlin.math.min
|
||||
|
|
|
@ -5,7 +5,7 @@ import app.aaps.core.interfaces.db.GlucoseUnit
|
|||
import app.aaps.core.interfaces.profile.ProfileUtil
|
||||
import app.aaps.core.interfaces.resources.ResourceHelper
|
||||
import app.aaps.core.interfaces.utils.DecimalFormatter
|
||||
import info.nightscout.database.entities.TemporaryTarget
|
||||
import app.aaps.database.entities.TemporaryTarget
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
fun TemporaryTarget.lowValueToUnitsToString(units: GlucoseUnit, decimalFormatter: DecimalFormatter): String =
|
||||
|
|
|
@ -2,7 +2,7 @@ package app.aaps.core.main.extensions
|
|||
|
||||
import app.aaps.core.interfaces.db.GlucoseUnit
|
||||
import app.aaps.core.interfaces.utils.DateUtil
|
||||
import info.nightscout.database.entities.TherapyEvent
|
||||
import app.aaps.database.entities.TherapyEvent
|
||||
|
||||
fun TherapyEvent.isOlderThan(hours: Double, dateUtil: DateUtil): Boolean {
|
||||
return getHoursFromStart(dateUtil) > hours
|
||||
|
|
|
@ -5,10 +5,10 @@ import android.graphics.Color
|
|||
import android.util.AttributeSet
|
||||
import app.aaps.core.interfaces.insulin.Insulin
|
||||
import app.aaps.core.interfaces.utils.T
|
||||
import app.aaps.database.entities.Bolus
|
||||
import com.jjoe64.graphview.GraphView
|
||||
import com.jjoe64.graphview.series.DataPoint
|
||||
import com.jjoe64.graphview.series.LineGraphSeries
|
||||
import info.nightscout.database.entities.Bolus
|
||||
import kotlin.math.floor
|
||||
|
||||
class ActivityGraph : GraphView {
|
||||
|
|
|
@ -4,23 +4,23 @@ import android.content.Context
|
|||
import androidx.annotation.AttrRes
|
||||
import androidx.annotation.ColorInt
|
||||
import androidx.annotation.DrawableRes
|
||||
import app.aaps.core.main.graph.data.DataPointWithLabelInterface
|
||||
import app.aaps.core.main.graph.data.DeviationDataPoint
|
||||
import app.aaps.core.main.graph.data.FixedLineGraphSeries
|
||||
import app.aaps.core.main.graph.data.PointsWithLabelGraphSeries
|
||||
import app.aaps.core.main.graph.data.Scale
|
||||
import app.aaps.core.main.graph.data.ScaledDataPoint
|
||||
import app.aaps.core.interfaces.aps.AutosensData
|
||||
import app.aaps.core.interfaces.aps.AutosensDataStore
|
||||
import app.aaps.core.interfaces.iob.CobInfo
|
||||
import app.aaps.core.interfaces.iob.InMemoryGlucoseValue
|
||||
import app.aaps.core.interfaces.iob.IobCobCalculator
|
||||
import app.aaps.core.interfaces.iob.IobTotal
|
||||
import app.aaps.core.main.graph.data.DataPointWithLabelInterface
|
||||
import app.aaps.core.main.graph.data.DeviationDataPoint
|
||||
import app.aaps.core.main.graph.data.FixedLineGraphSeries
|
||||
import app.aaps.core.main.graph.data.PointsWithLabelGraphSeries
|
||||
import app.aaps.core.main.graph.data.Scale
|
||||
import app.aaps.core.main.graph.data.ScaledDataPoint
|
||||
import app.aaps.database.entities.GlucoseValue
|
||||
import app.aaps.database.entities.TemporaryTarget
|
||||
import com.jjoe64.graphview.series.BarGraphSeries
|
||||
import com.jjoe64.graphview.series.DataPoint
|
||||
import com.jjoe64.graphview.series.LineGraphSeries
|
||||
import info.nightscout.database.entities.GlucoseValue
|
||||
import info.nightscout.database.entities.TemporaryTarget
|
||||
|
||||
interface OverviewData {
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ import app.aaps.core.interfaces.plugin.ActivePlugin
|
|||
import app.aaps.core.interfaces.profile.DefaultValueHelper
|
||||
import app.aaps.core.interfaces.resources.ResourceHelper
|
||||
import app.aaps.core.interfaces.utils.DecimalFormatter
|
||||
import info.nightscout.database.entities.Bolus
|
||||
import app.aaps.database.entities.Bolus
|
||||
|
||||
class BolusDataPoint(
|
||||
val data: Bolus,
|
||||
|
|
|
@ -2,9 +2,9 @@ package app.aaps.core.main.graph.data
|
|||
|
||||
import android.content.Context
|
||||
import android.graphics.Paint
|
||||
import app.aaps.core.main.R
|
||||
import app.aaps.core.interfaces.resources.ResourceHelper
|
||||
import info.nightscout.database.entities.Carbs
|
||||
import app.aaps.core.main.R
|
||||
import app.aaps.database.entities.Carbs
|
||||
|
||||
class CarbsDataPoint(
|
||||
val data: Carbs,
|
||||
|
|
|
@ -4,7 +4,7 @@ import android.content.Context
|
|||
import android.graphics.Paint
|
||||
import app.aaps.core.interfaces.resources.ResourceHelper
|
||||
import app.aaps.core.interfaces.utils.T
|
||||
import info.nightscout.database.entities.EffectiveProfileSwitch
|
||||
import app.aaps.database.entities.EffectiveProfileSwitch
|
||||
|
||||
class EffectiveProfileSwitchDataPoint(
|
||||
val data: EffectiveProfileSwitch,
|
||||
|
|
|
@ -4,7 +4,7 @@ import android.content.Context
|
|||
import android.graphics.Paint
|
||||
import app.aaps.core.interfaces.resources.ResourceHelper
|
||||
import app.aaps.core.interfaces.utils.DecimalFormatter
|
||||
import info.nightscout.database.entities.ExtendedBolus
|
||||
import app.aaps.database.entities.ExtendedBolus
|
||||
|
||||
class ExtendedBolusDataPoint(
|
||||
val data: ExtendedBolus,
|
||||
|
|
|
@ -6,7 +6,7 @@ import app.aaps.core.interfaces.configuration.Constants
|
|||
import app.aaps.core.interfaces.db.GlucoseUnit
|
||||
import app.aaps.core.interfaces.profile.ProfileUtil
|
||||
import app.aaps.core.interfaces.resources.ResourceHelper
|
||||
import info.nightscout.database.entities.GlucoseValue
|
||||
import app.aaps.database.entities.GlucoseValue
|
||||
|
||||
class GlucoseValueDataPoint(
|
||||
val data: GlucoseValue,
|
||||
|
|
|
@ -3,7 +3,7 @@ package app.aaps.core.main.graph.data
|
|||
import android.content.Context
|
||||
import android.graphics.Paint
|
||||
import app.aaps.core.interfaces.resources.ResourceHelper
|
||||
import info.nightscout.database.entities.HeartRate
|
||||
import app.aaps.database.entities.HeartRate
|
||||
|
||||
class HeartRateDataPoint(
|
||||
private val data: HeartRate,
|
||||
|
|
|
@ -6,7 +6,7 @@ import app.aaps.core.interfaces.configuration.Constants
|
|||
import app.aaps.core.interfaces.profile.ProfileUtil
|
||||
import app.aaps.core.interfaces.resources.ResourceHelper
|
||||
import app.aaps.core.interfaces.utils.Translator
|
||||
import info.nightscout.database.entities.TherapyEvent
|
||||
import app.aaps.database.entities.TherapyEvent
|
||||
|
||||
class TherapyEventDataPoint(
|
||||
val data: TherapyEvent,
|
||||
|
|
|
@ -20,12 +20,12 @@ import app.aaps.core.main.extensions.shiftBlock
|
|||
import app.aaps.core.main.extensions.shiftTargetBlock
|
||||
import app.aaps.core.main.extensions.targetBlockValueBySeconds
|
||||
import app.aaps.core.utils.MidnightUtils
|
||||
import info.nightscout.database.entities.EffectiveProfileSwitch
|
||||
import info.nightscout.database.entities.ProfileSwitch
|
||||
import info.nightscout.database.entities.data.Block
|
||||
import info.nightscout.database.entities.data.TargetBlock
|
||||
import info.nightscout.database.entities.embedments.InsulinConfiguration
|
||||
import info.nightscout.database.entities.embedments.InterfaceIDs
|
||||
import app.aaps.database.entities.EffectiveProfileSwitch
|
||||
import app.aaps.database.entities.ProfileSwitch
|
||||
import app.aaps.database.entities.data.Block
|
||||
import app.aaps.database.entities.data.TargetBlock
|
||||
import app.aaps.database.entities.embedments.InsulinConfiguration
|
||||
import app.aaps.database.entities.embedments.InterfaceIDs
|
||||
import org.json.JSONArray
|
||||
import org.json.JSONObject
|
||||
import java.text.DecimalFormat
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package app.aaps.core.main.pump
|
||||
|
||||
import app.aaps.core.interfaces.pump.defs.PumpType
|
||||
import info.nightscout.database.entities.UserEntry
|
||||
import info.nightscout.database.entities.embedments.InterfaceIDs
|
||||
import app.aaps.database.entities.UserEntry
|
||||
import app.aaps.database.entities.embedments.InterfaceIDs
|
||||
|
||||
fun PumpType.Companion.fromDbSource(s: UserEntry.Sources): PumpType.Source =
|
||||
when (s) {
|
||||
|
|
|
@ -38,14 +38,14 @@ import app.aaps.core.main.iob.round
|
|||
import app.aaps.core.main.utils.extensions.formatColor
|
||||
import app.aaps.core.ui.dialogs.OKDialog
|
||||
import app.aaps.core.utils.HtmlHelper
|
||||
import app.aaps.database.entities.BolusCalculatorResult
|
||||
import app.aaps.database.entities.OfflineEvent
|
||||
import app.aaps.database.entities.TemporaryTarget
|
||||
import app.aaps.database.entities.UserEntry.Action
|
||||
import app.aaps.database.entities.UserEntry.Sources
|
||||
import app.aaps.database.entities.ValueWithUnit
|
||||
import com.google.common.base.Joiner
|
||||
import dagger.android.HasAndroidInjector
|
||||
import info.nightscout.database.entities.BolusCalculatorResult
|
||||
import info.nightscout.database.entities.OfflineEvent
|
||||
import info.nightscout.database.entities.TemporaryTarget
|
||||
import info.nightscout.database.entities.UserEntry.Action
|
||||
import info.nightscout.database.entities.UserEntry.Sources
|
||||
import info.nightscout.database.entities.ValueWithUnit
|
||||
import java.util.LinkedList
|
||||
import javax.inject.Inject
|
||||
import kotlin.math.abs
|
||||
|
|
|
@ -16,8 +16,8 @@ import app.aaps.core.main.iob.round
|
|||
import app.aaps.core.utils.JsonHelper.safeGetInt
|
||||
import app.aaps.core.utils.JsonHelper.safeGetString
|
||||
import app.aaps.core.utils.MidnightUtils
|
||||
import app.aaps.database.ValueWrapper
|
||||
import dagger.android.HasAndroidInjector
|
||||
import info.nightscout.database.ValueWrapper
|
||||
import org.json.JSONException
|
||||
import org.json.JSONObject
|
||||
import java.util.UUID
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
package app.aaps.core.main.extensions
|
||||
|
||||
import app.aaps.core.interfaces.utils.T
|
||||
import app.aaps.database.entities.data.Block
|
||||
import app.aaps.database.entities.data.TargetBlock
|
||||
import app.aaps.database.entities.data.checkSanity
|
||||
import com.google.common.truth.Truth.assertThat
|
||||
import info.nightscout.database.entities.data.Block
|
||||
import info.nightscout.database.entities.data.TargetBlock
|
||||
import info.nightscout.database.entities.data.checkSanity
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
class BlockExtensionKtTest {
|
||||
|
|
|
@ -2,13 +2,13 @@ package app.aaps.core.interfaces.iob
|
|||
|
||||
import android.content.Context
|
||||
import android.graphics.Color
|
||||
import app.aaps.core.main.graph.data.InMemoryGlucoseValueDataPoint
|
||||
import app.aaps.core.interfaces.db.GlucoseUnit
|
||||
import app.aaps.core.interfaces.profile.DefaultValueHelper
|
||||
import app.aaps.core.interfaces.profile.ProfileFunction
|
||||
import app.aaps.core.interfaces.resources.ResourceHelper
|
||||
import app.aaps.core.main.graph.data.InMemoryGlucoseValueDataPoint
|
||||
import app.aaps.database.entities.GlucoseValue
|
||||
import com.google.common.truth.Truth.assertThat
|
||||
import info.nightscout.database.entities.GlucoseValue
|
||||
import org.junit.jupiter.api.BeforeEach
|
||||
import org.junit.jupiter.api.Test
|
||||
import org.junit.jupiter.api.extension.ExtendWith
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
package app.aaps.core.interfaces.pump
|
||||
|
||||
import android.content.Context
|
||||
import app.aaps.database.entities.BolusCalculatorResult
|
||||
import app.aaps.database.entities.TherapyEvent
|
||||
import app.aaps.shared.tests.TestBase
|
||||
import com.google.common.truth.Truth.assertThat
|
||||
import com.google.gson.Gson
|
||||
import info.nightscout.database.entities.Bolus
|
||||
import info.nightscout.database.entities.BolusCalculatorResult
|
||||
import info.nightscout.database.entities.TherapyEvent
|
||||
import org.apache.commons.lang3.builder.EqualsBuilder
|
||||
import org.junit.jupiter.api.Test
|
||||
import org.mockito.Mock
|
||||
|
|
|
@ -82,7 +82,7 @@ object DateTimeUtil {
|
|||
|
||||
@JvmStatic fun toATechDate(timeInMillis: Long): Long {
|
||||
val gc = GregorianCalendar()
|
||||
gc.setTimeInMillis(timeInMillis)
|
||||
gc.timeInMillis = timeInMillis
|
||||
return toATechDate(gc)
|
||||
}
|
||||
|
||||
|
@ -139,7 +139,7 @@ object DateTimeUtil {
|
|||
|
||||
@JvmStatic fun toStringFromTimeInMillis(timeInMillis: Long): String {
|
||||
val gc = GregorianCalendar()
|
||||
gc.setTimeInMillis(timeInMillis)
|
||||
gc.timeInMillis = timeInMillis
|
||||
return toString(gc)
|
||||
}
|
||||
|
||||
|
@ -155,7 +155,7 @@ object DateTimeUtil {
|
|||
|
||||
fun toMillisFromATD(aTechDateTime: Long): Long {
|
||||
val gc = toGregorianCalendar(aTechDateTime)
|
||||
return gc.getTimeInMillis()
|
||||
return gc.timeInMillis
|
||||
}
|
||||
|
||||
fun getATechDateDifferenceAsMinutes(date1: Long, date2: Long): Int {
|
||||
|
@ -171,13 +171,13 @@ object DateTimeUtil {
|
|||
fun getMillisFromATDWithAddedMinutes(atd: Long, minutesDiff: Int): Long {
|
||||
val oldestEntryTime = toGregorianCalendar(atd)
|
||||
oldestEntryTime.add(Calendar.MINUTE, minutesDiff)
|
||||
return oldestEntryTime.getTimeInMillis()
|
||||
return oldestEntryTime.timeInMillis
|
||||
}
|
||||
|
||||
fun getATDWithAddedSeconds(atd: Long, addedSeconds: Int): Long {
|
||||
val oldestEntryTime = toGregorianCalendar(atd)
|
||||
oldestEntryTime.add(Calendar.SECOND, addedSeconds)
|
||||
return toATechDate(oldestEntryTime.getTimeInMillis())
|
||||
return toATechDate(oldestEntryTime.timeInMillis)
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -11,9 +11,9 @@ apply from: "${project.rootDir}/core/main/test_dependencies.gradle"
|
|||
|
||||
android {
|
||||
|
||||
namespace 'info.nightscout.database.entities'
|
||||
namespace 'app.aaps.database.entities'
|
||||
defaultConfig {
|
||||
minSdkVersion 25 // for wear
|
||||
minSdkVersion 26 // for wear
|
||||
}
|
||||
|
||||
buildFeatures {
|
||||
|
|
|
@ -1,45 +0,0 @@
|
|||
package info.nightscout.database.entities
|
||||
|
||||
import androidx.room.Embedded
|
||||
import androidx.room.Entity
|
||||
import androidx.room.ForeignKey
|
||||
import androidx.room.Index
|
||||
import androidx.room.PrimaryKey
|
||||
import info.nightscout.database.entities.embedments.InterfaceIDs
|
||||
import info.nightscout.database.entities.interfaces.TraceableDBEntry
|
||||
|
||||
@Entity(tableName = TABLE_APS_RESULT_LINKS,
|
||||
foreignKeys = [ForeignKey(
|
||||
entity = APSResult::class,
|
||||
parentColumns = arrayOf("id"),
|
||||
childColumns = arrayOf("apsResultId")), ForeignKey(
|
||||
|
||||
entity = Bolus::class,
|
||||
parentColumns = arrayOf("id"),
|
||||
childColumns = arrayOf("smbId")), ForeignKey(
|
||||
|
||||
entity = TemporaryBasal::class,
|
||||
parentColumns = arrayOf("id"),
|
||||
childColumns = arrayOf("tbrId")), ForeignKey(
|
||||
|
||||
entity = APSResultLink::class,
|
||||
parentColumns = arrayOf("id"),
|
||||
childColumns = arrayOf("referenceId"))],
|
||||
indices = [Index("referenceId"), Index("apsResultId"),
|
||||
Index("smbId"), Index("tbrId")])
|
||||
data class APSResultLink(
|
||||
@PrimaryKey(autoGenerate = true)
|
||||
override var id: Long = 0,
|
||||
override var version: Int = 0,
|
||||
override var dateCreated: Long = -1,
|
||||
override var isValid: Boolean = true,
|
||||
override var referenceId: Long? = null,
|
||||
@Embedded
|
||||
override var interfaceIDs_backing: InterfaceIDs? = null,
|
||||
var apsResultId: Long,
|
||||
var smbId: Long? = null,
|
||||
var tbrId: Long? = null
|
||||
) : TraceableDBEntry {
|
||||
override val foreignKeysValid: Boolean
|
||||
get() = super.foreignKeysValid && apsResultId != 0L && smbId != 0L && tbrId != 0L
|
||||
}
|
|
@ -1,40 +0,0 @@
|
|||
package info.nightscout.database.entities
|
||||
|
||||
import androidx.room.Embedded
|
||||
import androidx.room.Entity
|
||||
import androidx.room.ForeignKey
|
||||
import androidx.room.Index
|
||||
import androidx.room.PrimaryKey
|
||||
import info.nightscout.database.entities.embedments.InterfaceIDs
|
||||
import info.nightscout.database.entities.interfaces.TraceableDBEntry
|
||||
|
||||
@Entity(tableName = TABLE_MULTIWAVE_BOLUS_LINKS,
|
||||
foreignKeys = [ForeignKey(
|
||||
entity = Bolus::class,
|
||||
parentColumns = arrayOf("id"),
|
||||
childColumns = arrayOf("bolusId")), ForeignKey(
|
||||
|
||||
entity = ExtendedBolus::class,
|
||||
parentColumns = arrayOf("id"),
|
||||
childColumns = arrayOf("extendedBolusId")), ForeignKey(
|
||||
|
||||
entity = MultiwaveBolusLink::class,
|
||||
parentColumns = ["id"],
|
||||
childColumns = ["referenceId"])],
|
||||
indices = [Index("referenceId"), Index("bolusId"),
|
||||
Index("extendedBolusId")])
|
||||
data class MultiwaveBolusLink(
|
||||
@PrimaryKey(autoGenerate = true)
|
||||
override var id: Long = 0,
|
||||
override var version: Int = 0,
|
||||
override var dateCreated: Long = -1,
|
||||
override var isValid: Boolean = true,
|
||||
override var referenceId: Long? = null,
|
||||
@Embedded
|
||||
override var interfaceIDs_backing: InterfaceIDs? = null,
|
||||
var bolusId: Long,
|
||||
var extendedBolusId: Long
|
||||
) : TraceableDBEntry {
|
||||
override val foreignKeysValid: Boolean
|
||||
get() = super.foreignKeysValid && bolusId != 0L && bolusId != 0L && extendedBolusId != 0L
|
||||
}
|
|
@ -1,205 +0,0 @@
|
|||
package info.nightscout.database.entities
|
||||
|
||||
import androidx.room.Entity
|
||||
import androidx.room.Index
|
||||
import androidx.room.PrimaryKey
|
||||
import info.nightscout.database.entities.interfaces.DBEntry
|
||||
import info.nightscout.database.entities.interfaces.DBEntryWithTime
|
||||
import java.util.TimeZone
|
||||
|
||||
@Entity(tableName = TABLE_USER_ENTRY,
|
||||
indices = [
|
||||
Index("source"),
|
||||
Index("timestamp")
|
||||
])
|
||||
data class UserEntry(
|
||||
@PrimaryKey(autoGenerate = true)
|
||||
override var id: Long = 0L,
|
||||
override var timestamp: Long,
|
||||
override var utcOffset: Long = TimeZone.getDefault().getOffset(timestamp).toLong(),
|
||||
var action: Action,
|
||||
var source: Sources,
|
||||
var note: String,
|
||||
var values: List<@JvmSuppressWildcards ValueWithUnit?>
|
||||
) : DBEntry, DBEntryWithTime {
|
||||
enum class Action (val colorGroup: ColorGroup) {
|
||||
BOLUS (ColorGroup.InsulinTreatment),
|
||||
BOLUS_CALCULATOR_RESULT (ColorGroup.InsulinTreatment),
|
||||
BOLUS_CALCULATOR_RESULT_REMOVED (ColorGroup.Aaps),
|
||||
SMB (ColorGroup.InsulinTreatment),
|
||||
BOLUS_ADVISOR (ColorGroup.InsulinTreatment),
|
||||
EXTENDED_BOLUS (ColorGroup.InsulinTreatment),
|
||||
SUPERBOLUS_TBR (ColorGroup.InsulinTreatment),
|
||||
CARBS (ColorGroup.CarbTreatment),
|
||||
EXTENDED_CARBS (ColorGroup.CarbTreatment),
|
||||
TEMP_BASAL (ColorGroup.BasalTreatment),
|
||||
TT (ColorGroup.TT),
|
||||
NEW_PROFILE (ColorGroup.Profile),
|
||||
CLONE_PROFILE (ColorGroup.Profile),
|
||||
STORE_PROFILE (ColorGroup.Profile),
|
||||
PROFILE_SWITCH (ColorGroup.Profile),
|
||||
PROFILE_SWITCH_CLONED (ColorGroup.Profile),
|
||||
CLOSED_LOOP_MODE (ColorGroup.Loop),
|
||||
LGS_LOOP_MODE (ColorGroup.Loop),
|
||||
OPEN_LOOP_MODE (ColorGroup.Loop),
|
||||
LOOP_DISABLED (ColorGroup.Loop),
|
||||
LOOP_ENABLED (ColorGroup.Loop),
|
||||
LOOP_CHANGE (ColorGroup.Loop),
|
||||
LOOP_REMOVED (ColorGroup.Loop),
|
||||
RECONNECT (ColorGroup.Pump),
|
||||
DISCONNECT (ColorGroup.Pump),
|
||||
RESUME (ColorGroup.Loop),
|
||||
SUSPEND (ColorGroup.Loop),
|
||||
HW_PUMP_ALLOWED (ColorGroup.Pump),
|
||||
CLEAR_PAIRING_KEYS (ColorGroup.Pump),
|
||||
ACCEPTS_TEMP_BASAL (ColorGroup.BasalTreatment),
|
||||
CANCEL_TEMP_BASAL (ColorGroup.BasalTreatment),
|
||||
CANCEL_BOLUS (ColorGroup.InsulinTreatment),
|
||||
CANCEL_EXTENDED_BOLUS (ColorGroup.InsulinTreatment),
|
||||
CANCEL_TT (ColorGroup.TT),
|
||||
CAREPORTAL (ColorGroup.Careportal),
|
||||
SITE_CHANGE (ColorGroup.Pump),
|
||||
RESERVOIR_CHANGE (ColorGroup.Pump),
|
||||
CALIBRATION (ColorGroup.Careportal),
|
||||
PRIME_BOLUS (ColorGroup.Pump),
|
||||
TREATMENT (ColorGroup.InsulinTreatment),
|
||||
CAREPORTAL_NS_REFRESH (ColorGroup.Careportal),
|
||||
PROFILE_SWITCH_NS_REFRESH (ColorGroup.Profile),
|
||||
TREATMENTS_NS_REFRESH (ColorGroup.InsulinTreatment),
|
||||
TT_NS_REFRESH (ColorGroup.TT),
|
||||
AUTOMATION_REMOVED (ColorGroup.Aaps),
|
||||
BG_REMOVED (ColorGroup.Aaps),
|
||||
CAREPORTAL_REMOVED (ColorGroup.Careportal),
|
||||
EXTENDED_BOLUS_REMOVED (ColorGroup.InsulinTreatment),
|
||||
FOOD_REMOVED (ColorGroup.CarbTreatment),
|
||||
PROFILE_REMOVED (ColorGroup.Profile),
|
||||
PROFILE_SWITCH_REMOVED (ColorGroup.Profile),
|
||||
RESTART_EVENTS_REMOVED (ColorGroup.Aaps),
|
||||
TREATMENT_REMOVED (ColorGroup.InsulinTreatment),
|
||||
BOLUS_REMOVED (ColorGroup.InsulinTreatment),
|
||||
CARBS_REMOVED (ColorGroup.CarbTreatment),
|
||||
TEMP_BASAL_REMOVED (ColorGroup.BasalTreatment),
|
||||
TT_REMOVED (ColorGroup.TT),
|
||||
NS_PAUSED (ColorGroup.Aaps),
|
||||
NS_RESUME (ColorGroup.Aaps),
|
||||
NS_QUEUE_CLEARED (ColorGroup.Aaps),
|
||||
NS_SETTINGS_COPIED (ColorGroup.Aaps),
|
||||
ERROR_DIALOG_OK (ColorGroup.Aaps),
|
||||
ERROR_DIALOG_MUTE (ColorGroup.Aaps),
|
||||
ERROR_DIALOG_MUTE_5MIN (ColorGroup.Aaps),
|
||||
OBJECTIVE_STARTED (ColorGroup.Aaps),
|
||||
OBJECTIVE_UNSTARTED (ColorGroup.Aaps),
|
||||
OBJECTIVES_SKIPPED (ColorGroup.Aaps),
|
||||
STAT_RESET (ColorGroup.Aaps),
|
||||
DELETE_LOGS (ColorGroup.Aaps),
|
||||
DELETE_FUTURE_TREATMENTS (ColorGroup.Aaps),
|
||||
EXPORT_SETTINGS (ColorGroup.Aaps),
|
||||
IMPORT_SETTINGS (ColorGroup.Aaps),
|
||||
RESET_DATABASES (ColorGroup.Aaps),
|
||||
CLEANUP_DATABASES (ColorGroup.Aaps),
|
||||
EXPORT_DATABASES (ColorGroup.Aaps),
|
||||
IMPORT_DATABASES (ColorGroup.Aaps),
|
||||
OTP_EXPORT (ColorGroup.Aaps),
|
||||
OTP_RESET (ColorGroup.Aaps),
|
||||
STOP_SMS (ColorGroup.Aaps),
|
||||
FOOD (ColorGroup.CarbTreatment),
|
||||
EXPORT_CSV (ColorGroup.Aaps),
|
||||
START_AAPS (ColorGroup.Aaps),
|
||||
EXIT_AAPS (ColorGroup.Aaps),
|
||||
PLUGIN_ENABLED (ColorGroup.Aaps),
|
||||
PLUGIN_DISABLED (ColorGroup.Aaps),
|
||||
UNKNOWN (ColorGroup.Aaps)
|
||||
;
|
||||
|
||||
companion object {
|
||||
fun fromString(source: String?) = values().firstOrNull { it.name == source } ?: UNKNOWN
|
||||
}
|
||||
}
|
||||
|
||||
enum class Sources {
|
||||
TreatmentDialog,
|
||||
InsulinDialog,
|
||||
CarbDialog,
|
||||
WizardDialog,
|
||||
QuickWizard,
|
||||
ExtendedBolusDialog,
|
||||
TTDialog,
|
||||
ProfileSwitchDialog,
|
||||
LoopDialog,
|
||||
TempBasalDialog,
|
||||
CalibrationDialog,
|
||||
FillDialog,
|
||||
BgCheck,
|
||||
SensorInsert,
|
||||
BatteryChange,
|
||||
Note,
|
||||
Exercise,
|
||||
Question,
|
||||
Announcement,
|
||||
Actions, //From Actions plugin
|
||||
Automation, //From Automation plugin
|
||||
Autotune, //From Autotune plugin
|
||||
BG, //From BG plugin => Add One Source per BG Source for Calibration or Sensor Change
|
||||
Aidex,
|
||||
Dexcom,
|
||||
Eversense,
|
||||
Glimp,
|
||||
MM640g,
|
||||
NSClientSource,
|
||||
PocTech,
|
||||
Tomato,
|
||||
Glunovo,
|
||||
Intelligo,
|
||||
Xdrip,
|
||||
LocalProfile, //From LocalProfile plugin
|
||||
Loop, //From Loop plugin
|
||||
Maintenance, //From Maintenance plugin
|
||||
NSClient, //From NSClient plugin
|
||||
NSProfile, //From NSProfile plugin
|
||||
Objectives, //From Objectives plugin
|
||||
Pump, //To update with one Source per pump
|
||||
Dana, //Only one UserEntry in Common module Dana
|
||||
DanaR,
|
||||
DanaRC,
|
||||
DanaRv2,
|
||||
DanaRS,
|
||||
DanaI,
|
||||
DiaconnG8,
|
||||
Insight,
|
||||
Combo,
|
||||
Medtronic,
|
||||
Omnipod, //No entry currently
|
||||
OmnipodEros,
|
||||
OmnipodDash, //No entry currently
|
||||
EOPatch2,
|
||||
Medtrum,
|
||||
MDI,
|
||||
VirtualPump,
|
||||
SMS, //From SMS plugin
|
||||
Treatments, //From Treatments plugin
|
||||
Wear, //From Wear plugin
|
||||
Food, //From Food plugin
|
||||
ConfigBuilder, //From ConfigBuilder Plugin
|
||||
Overview, //From OverViewPlugin
|
||||
Stats, //From Stat Activity
|
||||
Aaps, // MainApp
|
||||
Unknown //if necessary
|
||||
;
|
||||
|
||||
companion object {
|
||||
fun fromString(source: String?) = values().firstOrNull { it.name == source } ?: Unknown
|
||||
}
|
||||
}
|
||||
|
||||
enum class ColorGroup {
|
||||
InsulinTreatment,
|
||||
BasalTreatment,
|
||||
CarbTreatment,
|
||||
TT,
|
||||
Profile,
|
||||
Loop,
|
||||
Careportal,
|
||||
Pump,
|
||||
Aaps
|
||||
}
|
||||
}
|
|
@ -1,41 +0,0 @@
|
|||
package info.nightscout.database.entities.data
|
||||
|
||||
import info.nightscout.database.entities.APSResult
|
||||
import info.nightscout.database.entities.APSResultLink
|
||||
import info.nightscout.database.entities.Bolus
|
||||
import info.nightscout.database.entities.BolusCalculatorResult
|
||||
import info.nightscout.database.entities.Carbs
|
||||
import info.nightscout.database.entities.EffectiveProfileSwitch
|
||||
import info.nightscout.database.entities.ExtendedBolus
|
||||
import info.nightscout.database.entities.GlucoseValue
|
||||
import info.nightscout.database.entities.HeartRate
|
||||
import info.nightscout.database.entities.MultiwaveBolusLink
|
||||
import info.nightscout.database.entities.OfflineEvent
|
||||
import info.nightscout.database.entities.PreferenceChange
|
||||
import info.nightscout.database.entities.ProfileSwitch
|
||||
import info.nightscout.database.entities.TemporaryBasal
|
||||
import info.nightscout.database.entities.TemporaryTarget
|
||||
import info.nightscout.database.entities.TherapyEvent
|
||||
import info.nightscout.database.entities.TotalDailyDose
|
||||
import info.nightscout.database.entities.VersionChange
|
||||
|
||||
data class NewEntries(
|
||||
val apsResults: List<APSResult>,
|
||||
val apsResultLinks: List<APSResultLink>,
|
||||
val bolusCalculatorResults: List<BolusCalculatorResult>,
|
||||
val boluses: List<Bolus>,
|
||||
val carbs: List<Carbs>,
|
||||
val effectiveProfileSwitches: List<EffectiveProfileSwitch>,
|
||||
val extendedBoluses: List<ExtendedBolus>,
|
||||
val glucoseValues: List<GlucoseValue>,
|
||||
val multiwaveBolusLinks: List<MultiwaveBolusLink>,
|
||||
val offlineEvents: List<OfflineEvent>,
|
||||
val preferencesChanges: List<PreferenceChange>,
|
||||
val profileSwitches: List<ProfileSwitch>,
|
||||
val temporaryBasals: List<TemporaryBasal>,
|
||||
val temporaryTarget: List<TemporaryTarget>,
|
||||
val therapyEvents: List<TherapyEvent>,
|
||||
val totalDailyDoses: List<TotalDailyDose>,
|
||||
val versionChanges: List<VersionChange>,
|
||||
val heartRates: List<HeartRate>,
|
||||
)
|
|
@ -1,7 +0,0 @@
|
|||
package info.nightscout.database.entities.embedments
|
||||
|
||||
data class InsulinConfiguration(
|
||||
var insulinLabel: String,
|
||||
var insulinEndTime: Long, // DIA before [milliseconds]
|
||||
var peak: Long // [milliseconds]
|
||||
)
|
|
@ -1,5 +0,0 @@
|
|||
package info.nightscout.database.entities.interfaces
|
||||
|
||||
interface DBEntry {
|
||||
var id: Long
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package info.nightscout.database
|
||||
package app.aaps.database
|
||||
|
||||
sealed class ValueWrapper<T> {
|
||||
data class Existing<T>(val value: T) : ValueWrapper<T>()
|
|
@ -1,21 +1,24 @@
|
|||
package info.nightscout.database.entities
|
||||
package app.aaps.database.entities
|
||||
|
||||
import androidx.room.Embedded
|
||||
import androidx.room.Entity
|
||||
import androidx.room.ForeignKey
|
||||
import androidx.room.Index
|
||||
import androidx.room.PrimaryKey
|
||||
import info.nightscout.database.entities.embedments.InterfaceIDs
|
||||
import info.nightscout.database.entities.interfaces.DBEntryWithTime
|
||||
import info.nightscout.database.entities.interfaces.TraceableDBEntry
|
||||
import app.aaps.database.entities.embedments.InterfaceIDs
|
||||
import app.aaps.database.entities.interfaces.DBEntryWithTime
|
||||
import app.aaps.database.entities.interfaces.TraceableDBEntry
|
||||
import java.util.TimeZone
|
||||
|
||||
@Entity(tableName = TABLE_APS_RESULTS,
|
||||
@Entity(
|
||||
tableName = TABLE_APS_RESULTS,
|
||||
foreignKeys = [ForeignKey(
|
||||
entity = APSResult::class,
|
||||
parentColumns = ["id"],
|
||||
childColumns = ["referenceId"])],
|
||||
indices = [Index("referenceId"), Index("timestamp")])
|
||||
childColumns = ["referenceId"]
|
||||
)],
|
||||
indices = [Index("referenceId"), Index("timestamp")]
|
||||
)
|
||||
data class APSResult(
|
||||
@PrimaryKey(autoGenerate = true)
|
||||
override var id: Long = 0,
|
||||
|
@ -37,6 +40,7 @@ data class APSResult(
|
|||
var isMicroBolusAllowed: Boolean?,
|
||||
var resultJson: String
|
||||
) : TraceableDBEntry, DBEntryWithTime {
|
||||
|
||||
enum class Algorithm {
|
||||
MA,
|
||||
AMA,
|
|
@ -0,0 +1,52 @@
|
|||
package app.aaps.database.entities
|
||||
|
||||
import androidx.room.Embedded
|
||||
import androidx.room.Entity
|
||||
import androidx.room.ForeignKey
|
||||
import androidx.room.Index
|
||||
import androidx.room.PrimaryKey
|
||||
import app.aaps.database.entities.embedments.InterfaceIDs
|
||||
import app.aaps.database.entities.interfaces.TraceableDBEntry
|
||||
|
||||
@Entity(
|
||||
tableName = TABLE_APS_RESULT_LINKS,
|
||||
foreignKeys = [ForeignKey(
|
||||
entity = APSResult::class,
|
||||
parentColumns = arrayOf("id"),
|
||||
childColumns = arrayOf("apsResultId")
|
||||
), ForeignKey(
|
||||
|
||||
entity = Bolus::class,
|
||||
parentColumns = arrayOf("id"),
|
||||
childColumns = arrayOf("smbId")
|
||||
), ForeignKey(
|
||||
|
||||
entity = TemporaryBasal::class,
|
||||
parentColumns = arrayOf("id"),
|
||||
childColumns = arrayOf("tbrId")
|
||||
), ForeignKey(
|
||||
|
||||
entity = APSResultLink::class,
|
||||
parentColumns = arrayOf("id"),
|
||||
childColumns = arrayOf("referenceId")
|
||||
)],
|
||||
indices = [Index("referenceId"), Index("apsResultId"),
|
||||
Index("smbId"), Index("tbrId")]
|
||||
)
|
||||
data class APSResultLink(
|
||||
@PrimaryKey(autoGenerate = true)
|
||||
override var id: Long = 0,
|
||||
override var version: Int = 0,
|
||||
override var dateCreated: Long = -1,
|
||||
override var isValid: Boolean = true,
|
||||
override var referenceId: Long? = null,
|
||||
@Embedded
|
||||
override var interfaceIDs_backing: InterfaceIDs? = null,
|
||||
var apsResultId: Long,
|
||||
var smbId: Long? = null,
|
||||
var tbrId: Long? = null
|
||||
) : TraceableDBEntry {
|
||||
|
||||
override val foreignKeysValid: Boolean
|
||||
get() = super.foreignKeysValid && apsResultId != 0L && smbId != 0L && tbrId != 0L
|
||||
}
|
|
@ -1,14 +1,14 @@
|
|||
package info.nightscout.database.entities
|
||||
package app.aaps.database.entities
|
||||
|
||||
import androidx.room.Embedded
|
||||
import androidx.room.Entity
|
||||
import androidx.room.ForeignKey
|
||||
import androidx.room.Index
|
||||
import androidx.room.PrimaryKey
|
||||
import info.nightscout.database.entities.embedments.InsulinConfiguration
|
||||
import info.nightscout.database.entities.embedments.InterfaceIDs
|
||||
import info.nightscout.database.entities.interfaces.DBEntryWithTime
|
||||
import info.nightscout.database.entities.interfaces.TraceableDBEntry
|
||||
import app.aaps.database.entities.embedments.InsulinConfiguration
|
||||
import app.aaps.database.entities.embedments.InterfaceIDs
|
||||
import app.aaps.database.entities.interfaces.DBEntryWithTime
|
||||
import app.aaps.database.entities.interfaces.TraceableDBEntry
|
||||
import java.util.TimeZone
|
||||
|
||||
@Entity(
|
|
@ -1,13 +1,13 @@
|
|||
package info.nightscout.database.entities
|
||||
package app.aaps.database.entities
|
||||
|
||||
import androidx.room.Embedded
|
||||
import androidx.room.Entity
|
||||
import androidx.room.ForeignKey
|
||||
import androidx.room.Index
|
||||
import androidx.room.PrimaryKey
|
||||
import info.nightscout.database.entities.embedments.InterfaceIDs
|
||||
import info.nightscout.database.entities.interfaces.DBEntryWithTime
|
||||
import info.nightscout.database.entities.interfaces.TraceableDBEntry
|
||||
import app.aaps.database.entities.embedments.InterfaceIDs
|
||||
import app.aaps.database.entities.interfaces.DBEntryWithTime
|
||||
import app.aaps.database.entities.interfaces.TraceableDBEntry
|
||||
import java.util.TimeZone
|
||||
|
||||
@Entity(
|
|
@ -1,13 +1,13 @@
|
|||
package info.nightscout.database.entities
|
||||
package app.aaps.database.entities
|
||||
|
||||
import androidx.room.Embedded
|
||||
import androidx.room.Entity
|
||||
import androidx.room.ForeignKey
|
||||
import androidx.room.Index
|
||||
import androidx.room.PrimaryKey
|
||||
import info.nightscout.database.entities.embedments.InterfaceIDs
|
||||
import info.nightscout.database.entities.interfaces.DBEntryWithTimeAndDuration
|
||||
import info.nightscout.database.entities.interfaces.TraceableDBEntry
|
||||
import app.aaps.database.entities.embedments.InterfaceIDs
|
||||
import app.aaps.database.entities.interfaces.DBEntryWithTimeAndDuration
|
||||
import app.aaps.database.entities.interfaces.TraceableDBEntry
|
||||
import java.util.TimeZone
|
||||
|
||||
@Entity(
|
|
@ -1,21 +1,23 @@
|
|||
package info.nightscout.database.entities
|
||||
package app.aaps.database.entities
|
||||
|
||||
import androidx.room.Embedded
|
||||
import androidx.room.Entity
|
||||
import androidx.room.Index
|
||||
import androidx.room.PrimaryKey
|
||||
import info.nightscout.database.entities.embedments.InterfaceIDs
|
||||
import info.nightscout.database.entities.interfaces.DBEntry
|
||||
import info.nightscout.database.entities.interfaces.DBEntryWithTime
|
||||
import app.aaps.database.entities.embedments.InterfaceIDs
|
||||
import app.aaps.database.entities.interfaces.DBEntry
|
||||
import app.aaps.database.entities.interfaces.DBEntryWithTime
|
||||
import java.util.TimeZone
|
||||
|
||||
@Entity(tableName = TABLE_DEVICE_STATUS,
|
||||
@Entity(
|
||||
tableName = TABLE_DEVICE_STATUS,
|
||||
foreignKeys = [],
|
||||
indices = [
|
||||
Index("id"),
|
||||
Index("nightscoutId"),
|
||||
Index("timestamp")
|
||||
])
|
||||
]
|
||||
)
|
||||
data class DeviceStatus(
|
||||
@PrimaryKey(autoGenerate = true)
|
||||
override var id: Long = 0,
|
|
@ -1,16 +1,16 @@
|
|||
package info.nightscout.database.entities
|
||||
package app.aaps.database.entities
|
||||
|
||||
import androidx.room.Embedded
|
||||
import androidx.room.Entity
|
||||
import androidx.room.ForeignKey
|
||||
import androidx.room.Index
|
||||
import androidx.room.PrimaryKey
|
||||
import info.nightscout.database.entities.data.Block
|
||||
import info.nightscout.database.entities.data.TargetBlock
|
||||
import info.nightscout.database.entities.embedments.InsulinConfiguration
|
||||
import info.nightscout.database.entities.embedments.InterfaceIDs
|
||||
import info.nightscout.database.entities.interfaces.DBEntryWithTime
|
||||
import info.nightscout.database.entities.interfaces.TraceableDBEntry
|
||||
import app.aaps.database.entities.data.Block
|
||||
import app.aaps.database.entities.data.TargetBlock
|
||||
import app.aaps.database.entities.embedments.InsulinConfiguration
|
||||
import app.aaps.database.entities.embedments.InterfaceIDs
|
||||
import app.aaps.database.entities.interfaces.DBEntryWithTime
|
||||
import app.aaps.database.entities.interfaces.TraceableDBEntry
|
||||
import java.util.TimeZone
|
||||
|
||||
@Entity(
|
|
@ -1,13 +1,13 @@
|
|||
package info.nightscout.database.entities
|
||||
package app.aaps.database.entities
|
||||
|
||||
import androidx.room.Embedded
|
||||
import androidx.room.Entity
|
||||
import androidx.room.ForeignKey
|
||||
import androidx.room.Index
|
||||
import androidx.room.PrimaryKey
|
||||
import info.nightscout.database.entities.embedments.InterfaceIDs
|
||||
import info.nightscout.database.entities.interfaces.DBEntryWithTimeAndDuration
|
||||
import info.nightscout.database.entities.interfaces.TraceableDBEntry
|
||||
import app.aaps.database.entities.embedments.InterfaceIDs
|
||||
import app.aaps.database.entities.interfaces.DBEntryWithTimeAndDuration
|
||||
import app.aaps.database.entities.interfaces.TraceableDBEntry
|
||||
import java.util.TimeZone
|
||||
|
||||
@Entity(
|
|
@ -1,12 +1,12 @@
|
|||
package info.nightscout.database.entities
|
||||
package app.aaps.database.entities
|
||||
|
||||
import androidx.room.Embedded
|
||||
import androidx.room.Entity
|
||||
import androidx.room.ForeignKey
|
||||
import androidx.room.Index
|
||||
import androidx.room.PrimaryKey
|
||||
import info.nightscout.database.entities.embedments.InterfaceIDs
|
||||
import info.nightscout.database.entities.interfaces.TraceableDBEntry
|
||||
import app.aaps.database.entities.embedments.InterfaceIDs
|
||||
import app.aaps.database.entities.interfaces.TraceableDBEntry
|
||||
|
||||
@Entity(
|
||||
tableName = TABLE_FOODS,
|
|
@ -1,10 +1,14 @@
|
|||
package info.nightscout.database.entities
|
||||
package app.aaps.database.entities
|
||||
|
||||
import androidx.room.*
|
||||
import info.nightscout.database.entities.embedments.InterfaceIDs
|
||||
import info.nightscout.database.entities.interfaces.DBEntryWithTime
|
||||
import info.nightscout.database.entities.interfaces.TraceableDBEntry
|
||||
import java.util.*
|
||||
import androidx.room.Embedded
|
||||
import androidx.room.Entity
|
||||
import androidx.room.ForeignKey
|
||||
import androidx.room.Index
|
||||
import androidx.room.PrimaryKey
|
||||
import app.aaps.database.entities.embedments.InterfaceIDs
|
||||
import app.aaps.database.entities.interfaces.DBEntryWithTime
|
||||
import app.aaps.database.entities.interfaces.TraceableDBEntry
|
||||
import java.util.TimeZone
|
||||
|
||||
@Entity(
|
||||
tableName = TABLE_GLUCOSE_VALUES,
|
|
@ -1,13 +1,13 @@
|
|||
package info.nightscout.database.entities
|
||||
package app.aaps.database.entities
|
||||
|
||||
import androidx.room.Embedded
|
||||
import androidx.room.Entity
|
||||
import androidx.room.Index
|
||||
import androidx.room.PrimaryKey
|
||||
import info.nightscout.database.entities.embedments.InterfaceIDs
|
||||
import info.nightscout.database.entities.interfaces.DBEntryWithTimeAndDuration
|
||||
import info.nightscout.database.entities.interfaces.TraceableDBEntry
|
||||
import java.util.*
|
||||
import app.aaps.database.entities.embedments.InterfaceIDs
|
||||
import app.aaps.database.entities.interfaces.DBEntryWithTimeAndDuration
|
||||
import app.aaps.database.entities.interfaces.TraceableDBEntry
|
||||
import java.util.TimeZone
|
||||
|
||||
/** Heart rate values measured by a user smart watch or the like. */
|
||||
@Entity(
|
|
@ -0,0 +1,46 @@
|
|||
package app.aaps.database.entities
|
||||
|
||||
import androidx.room.Embedded
|
||||
import androidx.room.Entity
|
||||
import androidx.room.ForeignKey
|
||||
import androidx.room.Index
|
||||
import androidx.room.PrimaryKey
|
||||
import app.aaps.database.entities.embedments.InterfaceIDs
|
||||
import app.aaps.database.entities.interfaces.TraceableDBEntry
|
||||
|
||||
@Entity(
|
||||
tableName = TABLE_MULTIWAVE_BOLUS_LINKS,
|
||||
foreignKeys = [ForeignKey(
|
||||
entity = Bolus::class,
|
||||
parentColumns = arrayOf("id"),
|
||||
childColumns = arrayOf("bolusId")
|
||||
), ForeignKey(
|
||||
|
||||
entity = ExtendedBolus::class,
|
||||
parentColumns = arrayOf("id"),
|
||||
childColumns = arrayOf("extendedBolusId")
|
||||
), ForeignKey(
|
||||
|
||||
entity = MultiwaveBolusLink::class,
|
||||
parentColumns = ["id"],
|
||||
childColumns = ["referenceId"]
|
||||
)],
|
||||
indices = [Index("referenceId"), Index("bolusId"),
|
||||
Index("extendedBolusId")]
|
||||
)
|
||||
data class MultiwaveBolusLink(
|
||||
@PrimaryKey(autoGenerate = true)
|
||||
override var id: Long = 0,
|
||||
override var version: Int = 0,
|
||||
override var dateCreated: Long = -1,
|
||||
override var isValid: Boolean = true,
|
||||
override var referenceId: Long? = null,
|
||||
@Embedded
|
||||
override var interfaceIDs_backing: InterfaceIDs? = null,
|
||||
var bolusId: Long,
|
||||
var extendedBolusId: Long
|
||||
) : TraceableDBEntry {
|
||||
|
||||
override val foreignKeysValid: Boolean
|
||||
get() = super.foreignKeysValid && bolusId != 0L && bolusId != 0L && extendedBolusId != 0L
|
||||
}
|
|
@ -1,13 +1,13 @@
|
|||
package info.nightscout.database.entities
|
||||
package app.aaps.database.entities
|
||||
|
||||
import androidx.room.Embedded
|
||||
import androidx.room.Entity
|
||||
import androidx.room.ForeignKey
|
||||
import androidx.room.Index
|
||||
import androidx.room.PrimaryKey
|
||||
import info.nightscout.database.entities.embedments.InterfaceIDs
|
||||
import info.nightscout.database.entities.interfaces.DBEntryWithTimeAndDuration
|
||||
import info.nightscout.database.entities.interfaces.TraceableDBEntry
|
||||
import app.aaps.database.entities.embedments.InterfaceIDs
|
||||
import app.aaps.database.entities.interfaces.DBEntryWithTimeAndDuration
|
||||
import app.aaps.database.entities.interfaces.TraceableDBEntry
|
||||
import java.util.TimeZone
|
||||
|
||||
@Entity(
|
|
@ -1,9 +1,9 @@
|
|||
package info.nightscout.database.entities
|
||||
package app.aaps.database.entities
|
||||
|
||||
import androidx.room.Entity
|
||||
import androidx.room.PrimaryKey
|
||||
import info.nightscout.database.entities.interfaces.DBEntry
|
||||
import info.nightscout.database.entities.interfaces.DBEntryWithTime
|
||||
import app.aaps.database.entities.interfaces.DBEntry
|
||||
import app.aaps.database.entities.interfaces.DBEntryWithTime
|
||||
import java.util.TimeZone
|
||||
|
||||
@Entity(tableName = TABLE_PREFERENCE_CHANGES)
|
|
@ -1,16 +1,16 @@
|
|||
package info.nightscout.database.entities
|
||||
package app.aaps.database.entities
|
||||
|
||||
import androidx.room.Embedded
|
||||
import androidx.room.Entity
|
||||
import androidx.room.ForeignKey
|
||||
import androidx.room.Index
|
||||
import androidx.room.PrimaryKey
|
||||
import info.nightscout.database.entities.data.Block
|
||||
import info.nightscout.database.entities.data.TargetBlock
|
||||
import info.nightscout.database.entities.embedments.InsulinConfiguration
|
||||
import info.nightscout.database.entities.embedments.InterfaceIDs
|
||||
import info.nightscout.database.entities.interfaces.DBEntryWithTimeAndDuration
|
||||
import info.nightscout.database.entities.interfaces.TraceableDBEntry
|
||||
import app.aaps.database.entities.data.Block
|
||||
import app.aaps.database.entities.data.TargetBlock
|
||||
import app.aaps.database.entities.embedments.InsulinConfiguration
|
||||
import app.aaps.database.entities.embedments.InterfaceIDs
|
||||
import app.aaps.database.entities.interfaces.DBEntryWithTimeAndDuration
|
||||
import app.aaps.database.entities.interfaces.TraceableDBEntry
|
||||
import java.util.TimeZone
|
||||
|
||||
@Entity(
|
|
@ -1,4 +1,4 @@
|
|||
package info.nightscout.database.entities
|
||||
package app.aaps.database.entities
|
||||
|
||||
const val TABLE_APS_RESULTS = "apsResults"
|
||||
const val TABLE_APS_RESULT_LINKS = "apsResultLinks"
|
|
@ -1,13 +1,13 @@
|
|||
package info.nightscout.database.entities
|
||||
package app.aaps.database.entities
|
||||
|
||||
import androidx.room.Embedded
|
||||
import androidx.room.Entity
|
||||
import androidx.room.ForeignKey
|
||||
import androidx.room.Index
|
||||
import androidx.room.PrimaryKey
|
||||
import info.nightscout.database.entities.embedments.InterfaceIDs
|
||||
import info.nightscout.database.entities.interfaces.DBEntryWithTimeAndDuration
|
||||
import info.nightscout.database.entities.interfaces.TraceableDBEntry
|
||||
import app.aaps.database.entities.embedments.InterfaceIDs
|
||||
import app.aaps.database.entities.interfaces.DBEntryWithTimeAndDuration
|
||||
import app.aaps.database.entities.interfaces.TraceableDBEntry
|
||||
import java.util.TimeZone
|
||||
|
||||
@Entity(
|
|
@ -1,13 +1,13 @@
|
|||
package info.nightscout.database.entities
|
||||
package app.aaps.database.entities
|
||||
|
||||
import androidx.room.Embedded
|
||||
import androidx.room.Entity
|
||||
import androidx.room.ForeignKey
|
||||
import androidx.room.Index
|
||||
import androidx.room.PrimaryKey
|
||||
import info.nightscout.database.entities.embedments.InterfaceIDs
|
||||
import info.nightscout.database.entities.interfaces.DBEntryWithTimeAndDuration
|
||||
import info.nightscout.database.entities.interfaces.TraceableDBEntry
|
||||
import app.aaps.database.entities.embedments.InterfaceIDs
|
||||
import app.aaps.database.entities.interfaces.DBEntryWithTimeAndDuration
|
||||
import app.aaps.database.entities.interfaces.TraceableDBEntry
|
||||
import java.util.TimeZone
|
||||
|
||||
@Entity(
|
|
@ -1,13 +1,13 @@
|
|||
package info.nightscout.database.entities
|
||||
package app.aaps.database.entities
|
||||
|
||||
import androidx.room.Embedded
|
||||
import androidx.room.Entity
|
||||
import androidx.room.ForeignKey
|
||||
import androidx.room.Index
|
||||
import androidx.room.PrimaryKey
|
||||
import info.nightscout.database.entities.embedments.InterfaceIDs
|
||||
import info.nightscout.database.entities.interfaces.DBEntryWithTimeAndDuration
|
||||
import info.nightscout.database.entities.interfaces.TraceableDBEntry
|
||||
import app.aaps.database.entities.embedments.InterfaceIDs
|
||||
import app.aaps.database.entities.interfaces.DBEntryWithTimeAndDuration
|
||||
import app.aaps.database.entities.interfaces.TraceableDBEntry
|
||||
import java.util.TimeZone
|
||||
|
||||
@Entity(
|
|
@ -1,20 +1,22 @@
|
|||
package info.nightscout.database.entities
|
||||
package app.aaps.database.entities
|
||||
|
||||
import androidx.room.Embedded
|
||||
import androidx.room.Entity
|
||||
import androidx.room.ForeignKey
|
||||
import androidx.room.Index
|
||||
import androidx.room.PrimaryKey
|
||||
import info.nightscout.database.entities.embedments.InterfaceIDs
|
||||
import info.nightscout.database.entities.interfaces.DBEntryWithTime
|
||||
import info.nightscout.database.entities.interfaces.TraceableDBEntry
|
||||
import app.aaps.database.entities.embedments.InterfaceIDs
|
||||
import app.aaps.database.entities.interfaces.DBEntryWithTime
|
||||
import app.aaps.database.entities.interfaces.TraceableDBEntry
|
||||
import java.util.TimeZone
|
||||
|
||||
@Entity(tableName = TABLE_TOTAL_DAILY_DOSES,
|
||||
@Entity(
|
||||
tableName = TABLE_TOTAL_DAILY_DOSES,
|
||||
foreignKeys = [ForeignKey(
|
||||
entity = TotalDailyDose::class,
|
||||
parentColumns = ["id"],
|
||||
childColumns = ["referenceId"])],
|
||||
childColumns = ["referenceId"]
|
||||
)],
|
||||
indices = [
|
||||
Index("id"),
|
||||
Index("pumpId"),
|
||||
|
@ -23,7 +25,8 @@ import java.util.TimeZone
|
|||
Index("isValid"),
|
||||
Index("referenceId"),
|
||||
Index("timestamp")
|
||||
])
|
||||
]
|
||||
)
|
||||
data class TotalDailyDose(
|
||||
@PrimaryKey(autoGenerate = true)
|
||||
override var id: Long = 0,
|
||||
|
@ -40,5 +43,6 @@ data class TotalDailyDose(
|
|||
var totalAmount: Double = 0.0, // if zero it's calculated as basalAmount + bolusAmount
|
||||
var carbs: Double = 0.0
|
||||
) : TraceableDBEntry, DBEntryWithTime {
|
||||
|
||||
companion object
|
||||
}
|
|
@ -0,0 +1,210 @@
|
|||
package app.aaps.database.entities
|
||||
|
||||
import androidx.room.Entity
|
||||
import androidx.room.Index
|
||||
import androidx.room.PrimaryKey
|
||||
import app.aaps.database.entities.interfaces.DBEntry
|
||||
import app.aaps.database.entities.interfaces.DBEntryWithTime
|
||||
import java.util.TimeZone
|
||||
|
||||
@Entity(
|
||||
tableName = TABLE_USER_ENTRY,
|
||||
indices = [
|
||||
Index("source"),
|
||||
Index("timestamp")
|
||||
]
|
||||
)
|
||||
data class UserEntry(
|
||||
@PrimaryKey(autoGenerate = true)
|
||||
override var id: Long = 0L,
|
||||
override var timestamp: Long,
|
||||
override var utcOffset: Long = TimeZone.getDefault().getOffset(timestamp).toLong(),
|
||||
var action: Action,
|
||||
var source: Sources,
|
||||
var note: String,
|
||||
var values: List<@JvmSuppressWildcards ValueWithUnit?>
|
||||
) : DBEntry, DBEntryWithTime {
|
||||
|
||||
enum class Action(val colorGroup: ColorGroup) {
|
||||
BOLUS(ColorGroup.InsulinTreatment),
|
||||
BOLUS_CALCULATOR_RESULT(ColorGroup.InsulinTreatment),
|
||||
BOLUS_CALCULATOR_RESULT_REMOVED(ColorGroup.Aaps),
|
||||
SMB(ColorGroup.InsulinTreatment),
|
||||
BOLUS_ADVISOR(ColorGroup.InsulinTreatment),
|
||||
EXTENDED_BOLUS(ColorGroup.InsulinTreatment),
|
||||
SUPERBOLUS_TBR(ColorGroup.InsulinTreatment),
|
||||
CARBS(ColorGroup.CarbTreatment),
|
||||
EXTENDED_CARBS(ColorGroup.CarbTreatment),
|
||||
TEMP_BASAL(ColorGroup.BasalTreatment),
|
||||
TT(ColorGroup.TT),
|
||||
NEW_PROFILE(ColorGroup.Profile),
|
||||
CLONE_PROFILE(ColorGroup.Profile),
|
||||
STORE_PROFILE(ColorGroup.Profile),
|
||||
PROFILE_SWITCH(ColorGroup.Profile),
|
||||
PROFILE_SWITCH_CLONED(ColorGroup.Profile),
|
||||
CLOSED_LOOP_MODE(ColorGroup.Loop),
|
||||
LGS_LOOP_MODE(ColorGroup.Loop),
|
||||
OPEN_LOOP_MODE(ColorGroup.Loop),
|
||||
LOOP_DISABLED(ColorGroup.Loop),
|
||||
LOOP_ENABLED(ColorGroup.Loop),
|
||||
LOOP_CHANGE(ColorGroup.Loop),
|
||||
LOOP_REMOVED(ColorGroup.Loop),
|
||||
RECONNECT(ColorGroup.Pump),
|
||||
DISCONNECT(ColorGroup.Pump),
|
||||
RESUME(ColorGroup.Loop),
|
||||
SUSPEND(ColorGroup.Loop),
|
||||
HW_PUMP_ALLOWED(ColorGroup.Pump),
|
||||
CLEAR_PAIRING_KEYS(ColorGroup.Pump),
|
||||
ACCEPTS_TEMP_BASAL(ColorGroup.BasalTreatment),
|
||||
CANCEL_TEMP_BASAL(ColorGroup.BasalTreatment),
|
||||
CANCEL_BOLUS(ColorGroup.InsulinTreatment),
|
||||
CANCEL_EXTENDED_BOLUS(ColorGroup.InsulinTreatment),
|
||||
CANCEL_TT(ColorGroup.TT),
|
||||
CAREPORTAL(ColorGroup.Careportal),
|
||||
SITE_CHANGE(ColorGroup.Pump),
|
||||
RESERVOIR_CHANGE(ColorGroup.Pump),
|
||||
CALIBRATION(ColorGroup.Careportal),
|
||||
PRIME_BOLUS(ColorGroup.Pump),
|
||||
TREATMENT(ColorGroup.InsulinTreatment),
|
||||
CAREPORTAL_NS_REFRESH(ColorGroup.Careportal),
|
||||
PROFILE_SWITCH_NS_REFRESH(ColorGroup.Profile),
|
||||
TREATMENTS_NS_REFRESH(ColorGroup.InsulinTreatment),
|
||||
TT_NS_REFRESH(ColorGroup.TT),
|
||||
AUTOMATION_REMOVED(ColorGroup.Aaps),
|
||||
BG_REMOVED(ColorGroup.Aaps),
|
||||
CAREPORTAL_REMOVED(ColorGroup.Careportal),
|
||||
EXTENDED_BOLUS_REMOVED(ColorGroup.InsulinTreatment),
|
||||
FOOD_REMOVED(ColorGroup.CarbTreatment),
|
||||
PROFILE_REMOVED(ColorGroup.Profile),
|
||||
PROFILE_SWITCH_REMOVED(ColorGroup.Profile),
|
||||
RESTART_EVENTS_REMOVED(ColorGroup.Aaps),
|
||||
TREATMENT_REMOVED(ColorGroup.InsulinTreatment),
|
||||
BOLUS_REMOVED(ColorGroup.InsulinTreatment),
|
||||
CARBS_REMOVED(ColorGroup.CarbTreatment),
|
||||
TEMP_BASAL_REMOVED(ColorGroup.BasalTreatment),
|
||||
TT_REMOVED(ColorGroup.TT),
|
||||
NS_PAUSED(ColorGroup.Aaps),
|
||||
NS_RESUME(ColorGroup.Aaps),
|
||||
NS_QUEUE_CLEARED(ColorGroup.Aaps),
|
||||
NS_SETTINGS_COPIED(ColorGroup.Aaps),
|
||||
ERROR_DIALOG_OK(ColorGroup.Aaps),
|
||||
ERROR_DIALOG_MUTE(ColorGroup.Aaps),
|
||||
ERROR_DIALOG_MUTE_5MIN(ColorGroup.Aaps),
|
||||
OBJECTIVE_STARTED(ColorGroup.Aaps),
|
||||
OBJECTIVE_UNSTARTED(ColorGroup.Aaps),
|
||||
OBJECTIVES_SKIPPED(ColorGroup.Aaps),
|
||||
STAT_RESET(ColorGroup.Aaps),
|
||||
DELETE_LOGS(ColorGroup.Aaps),
|
||||
DELETE_FUTURE_TREATMENTS(ColorGroup.Aaps),
|
||||
EXPORT_SETTINGS(ColorGroup.Aaps),
|
||||
IMPORT_SETTINGS(ColorGroup.Aaps),
|
||||
RESET_DATABASES(ColorGroup.Aaps),
|
||||
CLEANUP_DATABASES(ColorGroup.Aaps),
|
||||
EXPORT_DATABASES(ColorGroup.Aaps),
|
||||
IMPORT_DATABASES(ColorGroup.Aaps),
|
||||
OTP_EXPORT(ColorGroup.Aaps),
|
||||
OTP_RESET(ColorGroup.Aaps),
|
||||
STOP_SMS(ColorGroup.Aaps),
|
||||
FOOD(ColorGroup.CarbTreatment),
|
||||
EXPORT_CSV(ColorGroup.Aaps),
|
||||
START_AAPS(ColorGroup.Aaps),
|
||||
EXIT_AAPS(ColorGroup.Aaps),
|
||||
PLUGIN_ENABLED(ColorGroup.Aaps),
|
||||
PLUGIN_DISABLED(ColorGroup.Aaps),
|
||||
UNKNOWN(ColorGroup.Aaps)
|
||||
;
|
||||
|
||||
companion object {
|
||||
|
||||
fun fromString(source: String?) = values().firstOrNull { it.name == source } ?: UNKNOWN
|
||||
}
|
||||
}
|
||||
|
||||
enum class Sources {
|
||||
TreatmentDialog,
|
||||
InsulinDialog,
|
||||
CarbDialog,
|
||||
WizardDialog,
|
||||
QuickWizard,
|
||||
ExtendedBolusDialog,
|
||||
TTDialog,
|
||||
ProfileSwitchDialog,
|
||||
LoopDialog,
|
||||
TempBasalDialog,
|
||||
CalibrationDialog,
|
||||
FillDialog,
|
||||
BgCheck,
|
||||
SensorInsert,
|
||||
BatteryChange,
|
||||
Note,
|
||||
Exercise,
|
||||
Question,
|
||||
Announcement,
|
||||
Actions, //From Actions plugin
|
||||
Automation, //From Automation plugin
|
||||
Autotune, //From Autotune plugin
|
||||
BG, //From BG plugin => Add One Source per BG Source for Calibration or Sensor Change
|
||||
Aidex,
|
||||
Dexcom,
|
||||
Eversense,
|
||||
Glimp,
|
||||
MM640g,
|
||||
NSClientSource,
|
||||
PocTech,
|
||||
Tomato,
|
||||
Glunovo,
|
||||
Intelligo,
|
||||
Xdrip,
|
||||
LocalProfile, //From LocalProfile plugin
|
||||
Loop, //From Loop plugin
|
||||
Maintenance, //From Maintenance plugin
|
||||
NSClient, //From NSClient plugin
|
||||
NSProfile, //From NSProfile plugin
|
||||
Objectives, //From Objectives plugin
|
||||
Pump, //To update with one Source per pump
|
||||
Dana, //Only one UserEntry in Common module Dana
|
||||
DanaR,
|
||||
DanaRC,
|
||||
DanaRv2,
|
||||
DanaRS,
|
||||
DanaI,
|
||||
DiaconnG8,
|
||||
Insight,
|
||||
Combo,
|
||||
Medtronic,
|
||||
Omnipod, //No entry currently
|
||||
OmnipodEros,
|
||||
OmnipodDash, //No entry currently
|
||||
EOPatch2,
|
||||
Medtrum,
|
||||
MDI,
|
||||
VirtualPump,
|
||||
SMS, //From SMS plugin
|
||||
Treatments, //From Treatments plugin
|
||||
Wear, //From Wear plugin
|
||||
Food, //From Food plugin
|
||||
ConfigBuilder, //From ConfigBuilder Plugin
|
||||
Overview, //From OverViewPlugin
|
||||
Stats, //From Stat Activity
|
||||
Aaps, // MainApp
|
||||
Unknown //if necessary
|
||||
;
|
||||
|
||||
companion object {
|
||||
|
||||
fun fromString(source: String?) = values().firstOrNull { it.name == source } ?: Unknown
|
||||
}
|
||||
}
|
||||
|
||||
enum class ColorGroup {
|
||||
InsulinTreatment,
|
||||
BasalTreatment,
|
||||
CarbTreatment,
|
||||
TT,
|
||||
Profile,
|
||||
Loop,
|
||||
Careportal,
|
||||
Pump,
|
||||
Aaps
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package info.nightscout.database.entities
|
||||
package app.aaps.database.entities
|
||||
|
||||
sealed class ValueWithUnit {
|
||||
|
||||
|
@ -35,7 +35,7 @@ sealed class ValueWithUnit {
|
|||
data class OfflineEventReason(val value: OfflineEvent.Reason) : ValueWithUnit()
|
||||
|
||||
fun value(): Any? {
|
||||
return when(this) {
|
||||
return when (this) {
|
||||
is Gram -> this.value
|
||||
is Hour -> this.value
|
||||
is Insulin -> this.value
|
||||
|
@ -54,6 +54,7 @@ sealed class ValueWithUnit {
|
|||
UNKNOWN -> null
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
const val MGDL = "mg/dl" // This is Nightscout's representation
|
|
@ -1,9 +1,9 @@
|
|||
package info.nightscout.database.entities
|
||||
package app.aaps.database.entities
|
||||
|
||||
import androidx.room.Entity
|
||||
import androidx.room.PrimaryKey
|
||||
import info.nightscout.database.entities.interfaces.DBEntry
|
||||
import info.nightscout.database.entities.interfaces.DBEntryWithTime
|
||||
import app.aaps.database.entities.interfaces.DBEntry
|
||||
import app.aaps.database.entities.interfaces.DBEntryWithTime
|
||||
import java.util.TimeZone
|
||||
|
||||
@Entity(tableName = TABLE_VERSION_CHANGES)
|
|
@ -1,4 +1,4 @@
|
|||
package info.nightscout.database.entities.data
|
||||
package app.aaps.database.entities.data
|
||||
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
package app.aaps.database.entities.data
|
||||
|
||||
import app.aaps.database.entities.BolusCalculatorResult
|
||||
import app.aaps.database.entities.Carbs
|
||||
import app.aaps.database.entities.EffectiveProfileSwitch
|
||||
import app.aaps.database.entities.ExtendedBolus
|
||||
import app.aaps.database.entities.GlucoseValue
|
||||
import app.aaps.database.entities.HeartRate
|
||||
import app.aaps.database.entities.MultiwaveBolusLink
|
||||
import app.aaps.database.entities.OfflineEvent
|
||||
import app.aaps.database.entities.PreferenceChange
|
||||
import app.aaps.database.entities.ProfileSwitch
|
||||
import app.aaps.database.entities.TemporaryBasal
|
||||
import app.aaps.database.entities.TemporaryTarget
|
||||
import app.aaps.database.entities.TherapyEvent
|
||||
import app.aaps.database.entities.TotalDailyDose
|
||||
import app.aaps.database.entities.VersionChange
|
||||
|
||||
data class NewEntries(
|
||||
val apsResults: List<app.aaps.database.entities.APSResult>,
|
||||
val apsResultLinks: List<app.aaps.database.entities.APSResultLink>,
|
||||
val bolusCalculatorResults: List<BolusCalculatorResult>,
|
||||
val boluses: List<app.aaps.database.entities.Bolus>,
|
||||
val carbs: List<Carbs>,
|
||||
val effectiveProfileSwitches: List<EffectiveProfileSwitch>,
|
||||
val extendedBoluses: List<ExtendedBolus>,
|
||||
val glucoseValues: List<GlucoseValue>,
|
||||
val multiwaveBolusLinks: List<MultiwaveBolusLink>,
|
||||
val offlineEvents: List<OfflineEvent>,
|
||||
val preferencesChanges: List<PreferenceChange>,
|
||||
val profileSwitches: List<ProfileSwitch>,
|
||||
val temporaryBasals: List<TemporaryBasal>,
|
||||
val temporaryTarget: List<TemporaryTarget>,
|
||||
val therapyEvents: List<TherapyEvent>,
|
||||
val totalDailyDoses: List<TotalDailyDose>,
|
||||
val versionChanges: List<VersionChange>,
|
||||
val heartRates: List<HeartRate>,
|
||||
)
|
|
@ -1,4 +1,4 @@
|
|||
package info.nightscout.database.entities.data
|
||||
package app.aaps.database.entities.data
|
||||
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
package app.aaps.database.entities.embedments
|
||||
|
||||
data class InsulinConfiguration(
|
||||
var insulinLabel: String,
|
||||
var insulinEndTime: Long, // DIA before [milliseconds]
|
||||
var peak: Long // [milliseconds]
|
||||
)
|
|
@ -1,4 +1,4 @@
|
|||
package info.nightscout.database.entities.embedments
|
||||
package app.aaps.database.entities.embedments
|
||||
|
||||
import androidx.room.Ignore
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
package app.aaps.database.entities.interfaces
|
||||
|
||||
interface DBEntry {
|
||||
|
||||
var id: Long
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
package info.nightscout.database.entities.interfaces
|
||||
package app.aaps.database.entities.interfaces
|
||||
|
||||
interface DBEntryWithDuration {
|
||||
|
||||
var duration: Long
|
||||
|
||||
val durationUnknown get() = duration == Long.MAX_VALUE
|
|
@ -1,6 +1,7 @@
|
|||
package info.nightscout.database.entities.interfaces
|
||||
package app.aaps.database.entities.interfaces
|
||||
|
||||
interface DBEntryWithTime {
|
||||
|
||||
var timestamp: Long
|
||||
var utcOffset: Long
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package info.nightscout.database.entities.interfaces
|
||||
package app.aaps.database.entities.interfaces
|
||||
|
||||
import kotlin.math.min
|
||||
|
|
@ -1,8 +1,9 @@
|
|||
package info.nightscout.database.entities.interfaces
|
||||
package app.aaps.database.entities.interfaces
|
||||
|
||||
import info.nightscout.database.entities.embedments.InterfaceIDs
|
||||
import app.aaps.database.entities.embedments.InterfaceIDs
|
||||
|
||||
interface TraceableDBEntry : DBEntry {
|
||||
|
||||
interface TraceableDBEntry: DBEntry {
|
||||
var version: Int
|
||||
var dateCreated: Long
|
||||
var isValid: Boolean
|
|
@ -1,6 +1,6 @@
|
|||
package info.nightscout.database.transactions
|
||||
package app.aaps.database.transactions
|
||||
|
||||
import info.nightscout.database.entities.GlucoseValue
|
||||
import app.aaps.database.entities.GlucoseValue
|
||||
import java.util.TimeZone
|
||||
|
||||
data class TransactionGlucoseValue(
|
|
@ -1,16 +1,17 @@
|
|||
package info.nightscout.database.entities
|
||||
package app.aaps.database.entities
|
||||
|
||||
import org.junit.Assert.assertFalse
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
class HeartRateTest {
|
||||
|
||||
@Test
|
||||
fun contentEqualsTo_equals() {
|
||||
val hr1 = createHeartRate()
|
||||
assertTrue(hr1.contentEqualsTo(hr1))
|
||||
assertTrue(hr1.contentEqualsTo(hr1.copy()))
|
||||
assertTrue(hr1.contentEqualsTo(hr1.copy (id = 2, version = 2, dateCreated = 1L, referenceId = 4L)))
|
||||
assertTrue(hr1.contentEqualsTo(hr1.copy(id = 2, version = 2, dateCreated = 1L, referenceId = 4L)))
|
||||
}
|
||||
|
||||
@Test
|
|
@ -7,8 +7,8 @@ import androidx.sqlite.db.SupportSQLiteDatabase
|
|||
import androidx.test.core.app.ApplicationProvider
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import androidx.test.platform.app.InstrumentationRegistry
|
||||
import info.nightscout.database.entities.HeartRate
|
||||
import info.nightscout.database.entities.TABLE_HEART_RATE
|
||||
import app.aaps.database.entities.HeartRate
|
||||
import app.aaps.database.entities.TABLE_HEART_RATE
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertFalse
|
||||
import org.junit.Assert.assertTrue
|
||||
|
@ -112,6 +112,7 @@ internal class HeartRateDaoTest {
|
|||
}
|
||||
|
||||
companion object {
|
||||
|
||||
private const val TEST_DB_NAME = "testDatabase"
|
||||
|
||||
fun createHeartRate(timestamp: Long? = null, beatsPerMinute: Double = 80.0) =
|
||||
|
|
|
@ -3,6 +3,25 @@ package info.nightscout.database.impl
|
|||
import androidx.room.Database
|
||||
import androidx.room.RoomDatabase
|
||||
import androidx.room.TypeConverters
|
||||
import app.aaps.database.entities.Bolus
|
||||
import app.aaps.database.entities.BolusCalculatorResult
|
||||
import app.aaps.database.entities.Carbs
|
||||
import app.aaps.database.entities.DeviceStatus
|
||||
import app.aaps.database.entities.EffectiveProfileSwitch
|
||||
import app.aaps.database.entities.ExtendedBolus
|
||||
import app.aaps.database.entities.Food
|
||||
import app.aaps.database.entities.GlucoseValue
|
||||
import app.aaps.database.entities.HeartRate
|
||||
import app.aaps.database.entities.MultiwaveBolusLink
|
||||
import app.aaps.database.entities.OfflineEvent
|
||||
import app.aaps.database.entities.PreferenceChange
|
||||
import app.aaps.database.entities.ProfileSwitch
|
||||
import app.aaps.database.entities.TemporaryBasal
|
||||
import app.aaps.database.entities.TemporaryTarget
|
||||
import app.aaps.database.entities.TherapyEvent
|
||||
import app.aaps.database.entities.TotalDailyDose
|
||||
import app.aaps.database.entities.UserEntry
|
||||
import app.aaps.database.entities.VersionChange
|
||||
import info.nightscout.database.impl.daos.APSResultDao
|
||||
import info.nightscout.database.impl.daos.APSResultLinkDao
|
||||
import info.nightscout.database.impl.daos.BolusCalculatorResultDao
|
||||
|
@ -13,6 +32,7 @@ import info.nightscout.database.impl.daos.EffectiveProfileSwitchDao
|
|||
import info.nightscout.database.impl.daos.ExtendedBolusDao
|
||||
import info.nightscout.database.impl.daos.FoodDao
|
||||
import info.nightscout.database.impl.daos.GlucoseValueDao
|
||||
import info.nightscout.database.impl.daos.HeartRateDao
|
||||
import info.nightscout.database.impl.daos.MultiwaveBolusLinkDao
|
||||
import info.nightscout.database.impl.daos.OfflineEventDao
|
||||
import info.nightscout.database.impl.daos.PreferenceChangeDao
|
||||
|
@ -23,39 +43,19 @@ import info.nightscout.database.impl.daos.TherapyEventDao
|
|||
import info.nightscout.database.impl.daos.TotalDailyDoseDao
|
||||
import info.nightscout.database.impl.daos.UserEntryDao
|
||||
import info.nightscout.database.impl.daos.VersionChangeDao
|
||||
import info.nightscout.database.entities.APSResult
|
||||
import info.nightscout.database.entities.APSResultLink
|
||||
import info.nightscout.database.entities.Bolus
|
||||
import info.nightscout.database.entities.BolusCalculatorResult
|
||||
import info.nightscout.database.entities.Carbs
|
||||
import info.nightscout.database.entities.DeviceStatus
|
||||
import info.nightscout.database.entities.EffectiveProfileSwitch
|
||||
import info.nightscout.database.entities.ExtendedBolus
|
||||
import info.nightscout.database.entities.Food
|
||||
import info.nightscout.database.entities.GlucoseValue
|
||||
import info.nightscout.database.entities.HeartRate
|
||||
import info.nightscout.database.entities.MultiwaveBolusLink
|
||||
import info.nightscout.database.entities.OfflineEvent
|
||||
import info.nightscout.database.entities.PreferenceChange
|
||||
import info.nightscout.database.entities.ProfileSwitch
|
||||
import info.nightscout.database.entities.TemporaryBasal
|
||||
import info.nightscout.database.entities.TemporaryTarget
|
||||
import info.nightscout.database.entities.TherapyEvent
|
||||
import info.nightscout.database.entities.TotalDailyDose
|
||||
import info.nightscout.database.entities.UserEntry
|
||||
import info.nightscout.database.entities.VersionChange
|
||||
import info.nightscout.database.impl.daos.HeartRateDao
|
||||
import java.io.Closeable
|
||||
|
||||
const val DATABASE_VERSION = 24
|
||||
|
||||
@Database(version = DATABASE_VERSION,
|
||||
entities = [APSResult::class, Bolus::class, BolusCalculatorResult::class, Carbs::class,
|
||||
@Database(
|
||||
version = DATABASE_VERSION,
|
||||
entities = [app.aaps.database.entities.APSResult::class, Bolus::class, BolusCalculatorResult::class, Carbs::class,
|
||||
EffectiveProfileSwitch::class, ExtendedBolus::class, GlucoseValue::class, ProfileSwitch::class,
|
||||
TemporaryBasal::class, TemporaryTarget::class, TherapyEvent::class, TotalDailyDose::class, APSResultLink::class,
|
||||
TemporaryBasal::class, TemporaryTarget::class, TherapyEvent::class, TotalDailyDose::class, app.aaps.database.entities.APSResultLink::class,
|
||||
MultiwaveBolusLink::class, PreferenceChange::class, VersionChange::class, UserEntry::class,
|
||||
Food::class, DeviceStatus::class, OfflineEvent::class, HeartRate::class],
|
||||
exportSchema = true)
|
||||
exportSchema = true
|
||||
)
|
||||
@TypeConverters(Converters::class)
|
||||
internal abstract class AppDatabase : Closeable, RoomDatabase() {
|
||||
|
||||
|
|
|
@ -1,26 +1,26 @@
|
|||
package info.nightscout.database.impl
|
||||
|
||||
import info.nightscout.database.ValueWrapper
|
||||
import app.aaps.database.ValueWrapper
|
||||
import app.aaps.database.entities.Bolus
|
||||
import app.aaps.database.entities.BolusCalculatorResult
|
||||
import app.aaps.database.entities.Carbs
|
||||
import app.aaps.database.entities.DeviceStatus
|
||||
import app.aaps.database.entities.EffectiveProfileSwitch
|
||||
import app.aaps.database.entities.ExtendedBolus
|
||||
import app.aaps.database.entities.Food
|
||||
import app.aaps.database.entities.GlucoseValue
|
||||
import app.aaps.database.entities.HeartRate
|
||||
import app.aaps.database.entities.OfflineEvent
|
||||
import app.aaps.database.entities.ProfileSwitch
|
||||
import app.aaps.database.entities.TemporaryBasal
|
||||
import app.aaps.database.entities.TemporaryTarget
|
||||
import app.aaps.database.entities.TherapyEvent
|
||||
import app.aaps.database.entities.TotalDailyDose
|
||||
import app.aaps.database.entities.UserEntry
|
||||
import app.aaps.database.entities.data.NewEntries
|
||||
import app.aaps.database.entities.embedments.InterfaceIDs
|
||||
import app.aaps.database.entities.interfaces.DBEntry
|
||||
import info.nightscout.database.annotations.DbOpenForTesting
|
||||
import info.nightscout.database.entities.Bolus
|
||||
import info.nightscout.database.entities.BolusCalculatorResult
|
||||
import info.nightscout.database.entities.Carbs
|
||||
import info.nightscout.database.entities.DeviceStatus
|
||||
import info.nightscout.database.entities.EffectiveProfileSwitch
|
||||
import info.nightscout.database.entities.ExtendedBolus
|
||||
import info.nightscout.database.entities.Food
|
||||
import info.nightscout.database.entities.GlucoseValue
|
||||
import info.nightscout.database.entities.HeartRate
|
||||
import info.nightscout.database.entities.OfflineEvent
|
||||
import info.nightscout.database.entities.ProfileSwitch
|
||||
import info.nightscout.database.entities.TemporaryBasal
|
||||
import info.nightscout.database.entities.TemporaryTarget
|
||||
import info.nightscout.database.entities.TherapyEvent
|
||||
import info.nightscout.database.entities.TotalDailyDose
|
||||
import info.nightscout.database.entities.UserEntry
|
||||
import info.nightscout.database.entities.data.NewEntries
|
||||
import info.nightscout.database.entities.embedments.InterfaceIDs
|
||||
import info.nightscout.database.entities.interfaces.DBEntry
|
||||
import info.nightscout.database.impl.transactions.Transaction
|
||||
import io.reactivex.rxjava3.core.Completable
|
||||
import io.reactivex.rxjava3.core.Maybe
|
||||
|
|
|
@ -1,21 +1,21 @@
|
|||
package info.nightscout.database.impl
|
||||
|
||||
import androidx.room.TypeConverter
|
||||
import info.nightscout.database.entities.APSResult
|
||||
import info.nightscout.database.entities.Bolus
|
||||
import info.nightscout.database.entities.EffectiveProfileSwitch
|
||||
import info.nightscout.database.entities.GlucoseValue
|
||||
import info.nightscout.database.entities.OfflineEvent
|
||||
import info.nightscout.database.entities.ProfileSwitch
|
||||
import info.nightscout.database.entities.TemporaryBasal
|
||||
import info.nightscout.database.entities.TemporaryTarget
|
||||
import info.nightscout.database.entities.TherapyEvent
|
||||
import info.nightscout.database.entities.UserEntry.Action
|
||||
import info.nightscout.database.entities.UserEntry.Sources
|
||||
import info.nightscout.database.entities.ValueWithUnit
|
||||
import info.nightscout.database.entities.data.Block
|
||||
import info.nightscout.database.entities.data.TargetBlock
|
||||
import info.nightscout.database.entities.embedments.InterfaceIDs
|
||||
import app.aaps.database.entities.APSResult
|
||||
import app.aaps.database.entities.Bolus
|
||||
import app.aaps.database.entities.EffectiveProfileSwitch
|
||||
import app.aaps.database.entities.GlucoseValue
|
||||
import app.aaps.database.entities.OfflineEvent
|
||||
import app.aaps.database.entities.ProfileSwitch
|
||||
import app.aaps.database.entities.TemporaryBasal
|
||||
import app.aaps.database.entities.TemporaryTarget
|
||||
import app.aaps.database.entities.TherapyEvent
|
||||
import app.aaps.database.entities.UserEntry.Action
|
||||
import app.aaps.database.entities.UserEntry.Sources
|
||||
import app.aaps.database.entities.ValueWithUnit
|
||||
import app.aaps.database.entities.data.Block
|
||||
import app.aaps.database.entities.data.TargetBlock
|
||||
import app.aaps.database.entities.embedments.InterfaceIDs
|
||||
import info.nightscout.database.impl.serialisation.SealedClassHelper
|
||||
import info.nightscout.database.impl.serialisation.fromJson
|
||||
import org.json.JSONArray
|
||||
|
@ -186,9 +186,11 @@ class Converters {
|
|||
for (i in 0 until jsonArray.length()) {
|
||||
val jsonObject = jsonArray.getJSONObject(i)
|
||||
list.add(
|
||||
TargetBlock(jsonObject.getLong("duration"),
|
||||
TargetBlock(
|
||||
jsonObject.getLong("duration"),
|
||||
jsonObject.getDouble("lowTarget"),
|
||||
jsonObject.getDouble("highTarget"))
|
||||
jsonObject.getDouble("highTarget")
|
||||
)
|
||||
)
|
||||
}
|
||||
return list
|
||||
|
|
|
@ -6,9 +6,9 @@ import androidx.room.Room
|
|||
import androidx.room.RoomDatabase.Callback
|
||||
import androidx.room.migration.Migration
|
||||
import androidx.sqlite.db.SupportSQLiteDatabase
|
||||
import app.aaps.database.entities.TABLE_HEART_RATE
|
||||
import dagger.Module
|
||||
import dagger.Provides
|
||||
import info.nightscout.database.entities.TABLE_HEART_RATE
|
||||
import javax.inject.Qualifier
|
||||
import javax.inject.Singleton
|
||||
|
||||
|
@ -54,7 +54,7 @@ open class DatabaseModule {
|
|||
database.execSQL("DROP INDEX IF EXISTS `index_offlineEvents_end`")
|
||||
}
|
||||
|
||||
private val migration20to21 = object : Migration(20,21) {
|
||||
private val migration20to21 = object : Migration(20, 21) {
|
||||
override fun migrate(database: SupportSQLiteDatabase) {
|
||||
database.execSQL("DROP TABLE IF EXISTS offlineEvents")
|
||||
database.execSQL("CREATE TABLE IF NOT EXISTS `offlineEvents` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `version` INTEGER NOT NULL, `dateCreated` INTEGER NOT NULL, `isValid` INTEGER NOT NULL, `referenceId` INTEGER, `timestamp` INTEGER NOT NULL, `utcOffset` INTEGER NOT NULL, `reason` TEXT NOT NULL, `duration` INTEGER NOT NULL, `nightscoutSystemId` TEXT, `nightscoutId` TEXT, `pumpType` TEXT, `pumpSerial` TEXT, `temporaryId` INTEGER, `pumpId` INTEGER, `startId` INTEGER, `endId` INTEGER, FOREIGN KEY(`referenceId`) REFERENCES `offlineEvents`(`id`) ON UPDATE NO ACTION ON DELETE NO ACTION )")
|
||||
|
@ -68,7 +68,7 @@ open class DatabaseModule {
|
|||
}
|
||||
}
|
||||
|
||||
private val migration21to22 = object : Migration(21,22) {
|
||||
private val migration21to22 = object : Migration(21, 22) {
|
||||
override fun migrate(database: SupportSQLiteDatabase) {
|
||||
database.execSQL("ALTER TABLE `carbs` ADD COLUMN `notes` TEXT")
|
||||
database.execSQL("ALTER TABLE `boluses` ADD COLUMN `notes` TEXT")
|
||||
|
@ -77,7 +77,7 @@ open class DatabaseModule {
|
|||
}
|
||||
}
|
||||
|
||||
private val migration22to23 = object : Migration(22,23) {
|
||||
private val migration22to23 = object : Migration(22, 23) {
|
||||
override fun migrate(database: SupportSQLiteDatabase) {
|
||||
database.execSQL("ALTER TABLE `deviceStatus` ADD COLUMN `isCharging` INTEGER")
|
||||
// Custom indexes must be dropped on migration to pass room schema checking after upgrade
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue