work from old autosens branch

This commit is contained in:
Milos Kozak 2017-06-16 14:37:43 +02:00
parent b67d8be1ef
commit e90812634b
10 changed files with 291 additions and 154 deletions

View file

@ -10,15 +10,18 @@ public class AutosensData {
long time = 0L;
public String pastSensitivity = "";
public double deviation = 0d;
boolean calculateWithDeviation = false;
boolean nonCarbsDeviation = false;
boolean nonEqualDeviation = false;
double absorbed = 0d;
public double carbsFromBolus = 0d;
public double cob = 0;
public double bgi = 0d;
public double delta = 0d;
public double autosensRatio = 1d;
public String log(long time) {
return "AutosensData: " + new Date(time).toLocaleString() + " " + pastSensitivity + " Delta=" + delta + " Bgi=" + bgi + " Deviation=" + deviation + " Absorbed=" + absorbed + " CarbsFromBolus=" + carbsFromBolus + " COB=" + cob;
return "AutosensData: " + new Date(time).toLocaleString() + " " + pastSensitivity + " Delta=" + delta + " Bgi=" + bgi + " Deviation=" + deviation + " Absorbed=" + absorbed + " CarbsFromBolus=" + carbsFromBolus + " COB=" + cob + " autosensRatio=" + autosensRatio;
}
public int minOld() {

View file

@ -19,6 +19,7 @@ import java.util.List;
import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.data.IobTotal;
import info.nightscout.androidaps.data.Profile;
import info.nightscout.androidaps.db.BgReading;
@ -26,6 +27,7 @@ import info.nightscout.androidaps.db.TemporaryBasal;
import info.nightscout.androidaps.db.Treatment;
import info.nightscout.androidaps.events.EventNewBG;
import info.nightscout.androidaps.events.EventNewBasalProfile;
import info.nightscout.androidaps.events.EventPreferenceChange;
import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.plugins.IobCobCalculator.events.BasalData;
import info.nightscout.androidaps.plugins.IobCobCalculator.events.EventAutosensCalculationFinished;
@ -304,6 +306,8 @@ public class IobCobCalculatorPlugin implements PluginBase {
if (MainApp.getConfigBuilder() == null)
return; // app still initializing
//log.debug("Locking calculateSensitivityData");
long oldestTimeWithData = oldestDataAvailable();
synchronized (dataLock) {
if (bucketed_data == null || bucketed_data.size() < 3) {
@ -371,12 +375,14 @@ public class IobCobCalculatorPlugin implements PluginBase {
if (autosensData.cob <= 0) {
if (Math.abs(deviation) < Constants.DEVIATION_TO_BE_EQUAL) {
autosensData.pastSensitivity += "=";
autosensData.nonEqualDeviation = true;
} else if (deviation > 0) {
autosensData.pastSensitivity += "+";
autosensData.nonEqualDeviation = true;
} else {
autosensData.pastSensitivity += "-";
}
autosensData.calculateWithDeviation = true;
autosensData.nonCarbsDeviation = true;
} else {
autosensData.pastSensitivity += "C";
}
@ -384,6 +390,7 @@ public class IobCobCalculatorPlugin implements PluginBase {
previous = autosensData;
autosensDataTable.put(bgTime, autosensData);
autosensData.autosensRatio = detectSensitivity(oldestTimeWithData, bgTime).ratio;
if (Config.logAutosensData)
log.debug(autosensData.log(bgTime));
}
@ -392,6 +399,15 @@ public class IobCobCalculatorPlugin implements PluginBase {
//log.debug("Releasing calculateSensitivityData");
}
public static long oldestDataAvailable() {
long now = System.currentTimeMillis();
long oldestDataAvailable = MainApp.getConfigBuilder().oldestDataAvailable();
long getBGDataFrom = Math.max(oldestDataAvailable, (long) (now - 60 * 60 * 1000L * (24 + MainApp.getConfigBuilder().getProfile().getDia())));
log.debug("Limiting data to oldest available temps: " + new Date(oldestDataAvailable).toString());
return getBGDataFrom;
}
public static IobTotal calulateFromTreatmentsAndTemps(long time) {
long now = System.currentTimeMillis();
time = roundUpTime(time);
@ -493,102 +509,109 @@ public class IobCobCalculatorPlugin implements PluginBase {
return array;
}
public static AutosensResult detectSensitivity(long fromTime) {
//log.debug("Locking detectSensitivity");
public static AutosensResult detectSensitivityWithLock(long fromTime, long toTime) {
synchronized (dataLock) {
if (autosensDataTable == null || autosensDataTable.size() < 4) {
log.debug("No autosens data available");
return new AutosensResult();
}
AutosensData current = getLastAutosensData();
if (current == null) {
log.debug("No current autosens data available");
return new AutosensResult();
}
List<Double> deviationsArray = new ArrayList<>();
String pastSensitivity = "";
int index = 0;
while (index < autosensDataTable.size()) {
AutosensData autosensData = autosensDataTable.valueAt(index);
if (autosensData.time < fromTime) {
index++;
continue;
}
if (autosensData.calculateWithDeviation)
deviationsArray.add(autosensData.deviation);
pastSensitivity += autosensData.pastSensitivity;
int secondsFromMidnight = Profile.secondsFromMidnight(autosensData.time);
if (secondsFromMidnight % 3600 < 2.5 * 60 || secondsFromMidnight % 3600 > 57.5 * 60) {
pastSensitivity += "(" + Math.round(secondsFromMidnight / 3600d) + ")";
}
index++;
}
Double[] deviations = new Double[deviationsArray.size()];
deviations = deviationsArray.toArray(deviations);
Profile profile = MainApp.getConfigBuilder().getProfile();
double sens = profile.getIsf();
double ratio = 1;
String ratioLimit = "";
String sensResult = "";
log.debug("Records: " + index + " " + pastSensitivity);
Arrays.sort(deviations);
for (double i = 0.9; i > 0.1; i = i - 0.02) {
if (percentile(deviations, (i + 0.02)) >= 0 && percentile(deviations, i) < 0) {
log.debug(Math.round(100 * i) + "% of non-meal deviations negative (target 45%-50%)");
}
}
double pSensitive = percentile(deviations, 0.50);
double pResistant = percentile(deviations, 0.45);
double basalOff = 0;
if (pSensitive < 0) { // sensitive
basalOff = pSensitive * (60 / 5) / Profile.toMgdl(sens, profile.getUnits());
sensResult = "Excess insulin sensitivity detected";
} else if (pResistant > 0) { // resistant
basalOff = pResistant * (60 / 5) / Profile.toMgdl(sens, profile.getUnits());
sensResult = "Excess insulin resistance detected";
} else {
sensResult = "Sensitivity normal";
}
log.debug(sensResult);
ratio = 1 + (basalOff / profile.getMaxDailyBasal());
double rawRatio = ratio;
ratio = Math.max(ratio, SafeParse.stringToDouble(SP.getString("openapsama_autosens_min", "0.7")));
ratio = Math.min(ratio, SafeParse.stringToDouble(SP.getString("openapsama_autosens_max", "1.2")));
if (ratio != rawRatio) {
ratioLimit = "Ratio limited from " + rawRatio + " to " + ratio;
log.debug(ratioLimit);
}
double newisf = Math.round(Profile.toMgdl(sens, profile.getUnits()) / ratio);
if (ratio != 1) {
log.debug("ISF adjusted from " + Profile.toMgdl(sens, profile.getUnits()) + " to " + newisf);
}
AutosensResult output = new AutosensResult();
output.ratio = Round.roundTo(ratio, 0.01);
output.carbsAbsorbed = Round.roundTo(current.cob, 0.01);
output.pastSensitivity = pastSensitivity;
output.ratioLimit = ratioLimit;
output.sensResult = sensResult;
return output;
return detectSensitivity(fromTime, toTime);
}
//log.debug("Releasing detectSensitivity");
}
public static AutosensResult detectSensitivity(long fromTime, long toTime) {
String age = SP.getString(R.string.key_age, "");
int defaultHours = 24;
if (age.equals(MainApp.sResources.getString(R.string.key_adult))) defaultHours = 24;
if (age.equals(MainApp.sResources.getString(R.string.key_teenage))) defaultHours = 4;
if (age.equals(MainApp.sResources.getString(R.string.key_child))) defaultHours = 4;
int hoursForDetection = SP.getInt(R.string.key_openapsama_autosens_period, defaultHours);
long now = System.currentTimeMillis();
if (autosensDataTable == null || autosensDataTable.size() < 4) {
log.debug("No autosens data available");
return new AutosensResult();
}
AutosensData current = getAutosensData(toTime);
if (current == null) {
log.debug("No autosens data available");
return new AutosensResult();
}
List<Double> deviationsArray = new ArrayList<>();
String pastSensitivity = "";
int index = 0;
while (index < autosensDataTable.size()) {
AutosensData autosensData = autosensDataTable.valueAt(index);
if (autosensData.time < fromTime) {
index++;
continue;
}
if (autosensData.time > toTime) {
index++;
continue;
}
if (autosensData.time > now - hoursForDetection * 60 * 60 * 1000L)
deviationsArray.add(autosensData.nonEqualDeviation ? autosensData.deviation : 0d);
if (deviationsArray.size() > hoursForDetection * 60 / 5)
deviationsArray.remove(0);
pastSensitivity += autosensData.pastSensitivity;
int secondsFromMidnight = Profile.secondsFromMidnight(autosensData.time);
if (secondsFromMidnight % 3600 < 2.5 * 60 || secondsFromMidnight % 3600 > 57.5 * 60) {
pastSensitivity += "(" + Math.round(secondsFromMidnight / 3600d) + ")";
}
index++;
}
Double[] deviations = new Double[deviationsArray.size()];
deviations = deviationsArray.toArray(deviations);
Profile profile = MainApp.getConfigBuilder().getProfile();
double sens = profile.getIsf();
String ratioLimit = "";
String sensResult = "";
log.debug("Records: " + index + " " + pastSensitivity);
Arrays.sort(deviations);
double percentile = percentile(deviations, 0.50);
double basalOff = percentile * (60 / 5) / Profile.toMgdl(sens, profile.getUnits());
double ratio = 1 + (basalOff / profile.getMaxDailyBasal());
if (percentile < 0) { // sensitive
sensResult = "Excess insulin sensitivity detected";
} else if (percentile > 0) { // resistant
sensResult = "Excess insulin resistance detected";
} else {
sensResult = "Sensitivity normal";
}
log.debug(sensResult);
double rawRatio = ratio;
ratio = Math.max(ratio, SafeParse.stringToDouble(SP.getString("openapsama_autosens_min", "0.7")));
ratio = Math.min(ratio, SafeParse.stringToDouble(SP.getString("openapsama_autosens_max", "1.2")));
if (ratio != rawRatio) {
ratioLimit = "Ratio limited from " + rawRatio + " to " + ratio;
log.debug(ratioLimit);
}
log.error("Sensitivity to: " + new Date(toTime).toLocaleString() + " percentile: " + percentile);
AutosensResult output = new AutosensResult();
output.ratio = Round.roundTo(ratio, 0.01);
output.carbsAbsorbed = Round.roundTo(current.cob, 0.01);
output.pastSensitivity = pastSensitivity;
output.ratioLimit = ratioLimit;
output.sensResult = sensResult;
return output;
}
@ -634,6 +657,25 @@ public class IobCobCalculatorPlugin implements PluginBase {
});
}
@Subscribe
public void onStatusEvent(EventPreferenceChange ev) {
if (ev.isChanged(R.string.key_openapsama_autosens_period) ||
ev.isChanged(R.string.key_age)
) {
synchronized (dataLock) {
log.debug("Invalidating cached data because of preference change. IOB: " + iobTable.size() + " Autosens: " + autosensDataTable.size() + " records");
iobTable = new LongSparseArray<>();
autosensDataTable = new LongSparseArray<>();
}
sHandler.post(new Runnable() {
@Override
public void run() {
calculateSensitivityData();
}
});
}
}
// When historical data is changed (comming from NS etc) finished calculations after this date must be invalidated
@Subscribe
public void onNewHistoryData(EventNewHistoryData ev) {

View file

@ -207,14 +207,9 @@ public class OpenAPSAMAPlugin implements PluginBase, APSInterface {
if (!checkOnlyHardLimits(profile.getMaxDailyBasal(), "max_daily_basal", 0.1, 10)) return;
if (!checkOnlyHardLimits(pump.getBaseBasalRate(), "current_basal", 0.01, 5)) return;
long oldestDataAvailable = MainApp.getConfigBuilder().oldestDataAvailable();
long getBGDataFrom = Math.max(oldestDataAvailable, (long) (System.currentTimeMillis() - 60 * 60 * 1000L * (24 + profile.getDia())));
log.debug("Limiting data to oldest available temps: " + new Date(oldestDataAvailable).toString());
startPart = new Date();
if (MainApp.getConfigBuilder().isAMAModeEnabled()) {
//lastAutosensResult = Autosens.detectSensitivityandCarbAbsorption(getBGDataFrom, null);
lastAutosensResult = IobCobCalculatorPlugin.detectSensitivity(getBGDataFrom);
lastAutosensResult = IobCobCalculatorPlugin.detectSensitivityWithLock(IobCobCalculatorPlugin.oldestDataAvailable(), System.currentTimeMillis());
} else {
lastAutosensResult = new AutosensResult();
}

View file

@ -164,6 +164,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
CheckBox showIobView;
CheckBox showCobView;
CheckBox showDeviationsView;
CheckBox showRatiosView;
RecyclerView notificationsView;
LinearLayoutManager llm;
@ -275,36 +276,25 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
showIobView = (CheckBox) view.findViewById(R.id.overview_showiob);
showCobView = (CheckBox) view.findViewById(R.id.overview_showcob);
showDeviationsView = (CheckBox) view.findViewById(R.id.overview_showdeviations);
showRatiosView = (CheckBox) view.findViewById(R.id.overview_showratios);
showPredictionView.setChecked(SP.getBoolean("showprediction", false));
showBasalsView.setChecked(SP.getBoolean("showbasals", true));
showIobView.setChecked(SP.getBoolean("showiob", false));
showCobView.setChecked(SP.getBoolean("showcob", false));
showDeviationsView.setChecked(SP.getBoolean("showdeviations", false));
showRatiosView.setChecked(SP.getBoolean("showratios", false));
showPredictionView.setOnCheckedChangeListener(this);
showBasalsView.setOnCheckedChangeListener(this);
showIobView.setOnCheckedChangeListener(this);
showCobView.setOnCheckedChangeListener(this);
showDeviationsView.setOnCheckedChangeListener(this);
showRatiosView.setOnCheckedChangeListener(this);
notificationsView = (RecyclerView) view.findViewById(R.id.overview_notifications);
notificationsView.setHasFixedSize(true);
llm = new LinearLayoutManager(view.getContext());
notificationsView.setLayoutManager(llm);
/*
final LinearLayout graphs = (LinearLayout)view.findViewById(R.id.overview_graphs_layout);
ViewTreeObserver observer = graphs.getViewTreeObserver();
observer.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
log.debug("Height: " + graphs.getHeight());
graphs.getViewTreeObserver().removeGlobalOnLayoutListener(
this);
int heightNeeded = Math.max(320, graphs.getHeight() - 200);
if (heightNeeded != bgGraph.getHeight())
bgGraph.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, heightNeeded));
}
});
*/
bgGraph.getGridLabelRenderer().setGridColor(MainApp.sResources.getColor(R.color.graphgrid));
bgGraph.getGridLabelRenderer().reloadStyles();
iobGraph.getGridLabelRenderer().setGridColor(MainApp.sResources.getColor(R.color.graphgrid));
@ -358,34 +348,29 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
switch (buttonView.getId()) {
case R.id.overview_showprediction:
SP.putBoolean("showprediction", showPredictionView.isChecked());
updateGUI("onPredictionCheckedChanged");
break;
case R.id.overview_showbasals:
SP.putBoolean("showbasals", showBasalsView.isChecked());
updateGUI("onBasalsCheckedChanged");
break;
case R.id.overview_showiob:
SP.putBoolean("showiob", showIobView.isChecked());
updateGUI("onIobCheckedChanged");
break;
case R.id.overview_showcob:
showDeviationsView.setOnCheckedChangeListener(null);
showDeviationsView.setChecked(false);
showDeviationsView.setOnCheckedChangeListener(this);
SP.putBoolean("showcob", showCobView.isChecked());
SP.putBoolean("showdeviations", showDeviationsView.isChecked());
updateGUI("onCobCheckedChanged");
break;
case R.id.overview_showdeviations:
showCobView.setOnCheckedChangeListener(null);
showCobView.setChecked(false);
showCobView.setOnCheckedChangeListener(this);
SP.putBoolean("showcob", showCobView.isChecked());
SP.putBoolean("showdeviations", showDeviationsView.isChecked());
updateGUI("onDeviationsCheckedChanged");
break;
case R.id.overview_showratios:
break;
}
SP.putBoolean("showiob", showIobView.isChecked());
SP.putBoolean("showprediction", showPredictionView.isChecked());
SP.putBoolean("showbasals", showBasalsView.isChecked());
SP.putBoolean("showcob", showCobView.isChecked());
SP.putBoolean("showdeviations", showDeviationsView.isChecked());
SP.putBoolean("showratios", showRatiosView.isChecked());
scheduleUpdateGUI("onGraphCheckboxesCheckedChanged");
}
@Override
@ -1289,15 +1274,18 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
FixedLineGraphSeries<DataPoint> iobSeries;
FixedLineGraphSeries<DataPoint> cobSeries;
BarGraphSeries<DeviationDataPoint> devSeries;
LineGraphSeries<DataPoint> ratioSeries;
Double maxIobValueFound = 0d;
Double maxCobValueFound = 0d;
Double maxDevValueFound = 0d;
Double maxRatioValueFound = 0d;
if (showIobView.isChecked() || showCobView.isChecked() || showDeviationsView.isChecked()) {
if (showIobView.isChecked() || showCobView.isChecked() || showDeviationsView.isChecked() || showRatiosView.isChecked()) {
//Date start = new Date();
List<DataPoint> iobArray = new ArrayList<>();
List<DataPoint> cobArray = new ArrayList<>();
List<DeviationDataPoint> devArray = new ArrayList<>();
List<DataPoint> ratioArray = new ArrayList<>();
double lastIob = 0;
int lastCob = 0;
for (long time = fromTime; time <= now; time += 5 * 60 * 1000L) {
@ -1311,7 +1299,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
lastIob = iob;
}
}
if (showCobView.isChecked() || showDeviationsView.isChecked()) {
if (showCobView.isChecked() || showDeviationsView.isChecked() || showRatiosView.isChecked()) {
AutosensData autosensData = IobCobCalculatorPlugin.getAutosensData(time);
if (autosensData != null && showCobView.isChecked()) {
int cob = (int) autosensData.cob;
@ -1331,6 +1319,10 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
devArray.add(new DeviationDataPoint(time, autosensData.deviation, color));
maxDevValueFound = Math.max(maxDevValueFound, Math.abs(autosensData.deviation));
}
if (autosensData != null && showRatiosView.isChecked()) {
ratioArray.add(new DataPoint(time, autosensData.autosensRatio));
maxRatioValueFound = Math.max(maxRatioValueFound, Math.abs(autosensData.autosensRatio));
}
}
}
//Profiler.log(log, "IOB processed", start);
@ -1343,18 +1335,49 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
iobSeries.setThickness(3);
if (showIobView.isChecked() && (showCobView.isChecked() || showDeviationsView.isChecked())) {
List<DataPoint> cobArrayRescaled = new ArrayList<>();
List<DeviationDataPoint> devArrayRescaled = new ArrayList<>();
for (int ci = 0; ci < cobArray.size(); ci++) {
cobArrayRescaled.add(new DataPoint(cobArray.get(ci).getX(), cobArray.get(ci).getY() * maxIobValueFound / maxCobValueFound / 2));
}
for (int ci = 0; ci < devArray.size(); ci++) {
devArrayRescaled.add(new DeviationDataPoint(devArray.get(ci).getX(), devArray.get(ci).getY() * maxIobValueFound / maxDevValueFound, devArray.get(ci).color));
}
cobArray = cobArrayRescaled;
devArray = devArrayRescaled;
Double maxByScale = null;
int graphsToShow = 0;
if (showIobView.isChecked()) {
if (maxByScale == null) maxByScale = maxIobValueFound;
graphsToShow++;
}
if (showCobView.isChecked()) {
if (maxByScale == null) maxByScale = maxCobValueFound;
graphsToShow++;
}
if (showDeviationsView.isChecked()) {
if (maxByScale == null) maxByScale = maxDevValueFound;
graphsToShow++;
}
if (showRatiosView.isChecked()) {
if (maxByScale == null) maxByScale = maxRatioValueFound;
graphsToShow++;
}
if (graphsToShow > 1) {
if (!maxByScale.equals(maxCobValueFound)) {
List<DataPoint> cobArrayRescaled = new ArrayList<>();
for (int ci = 0; ci < cobArray.size(); ci++) {
cobArrayRescaled.add(new DataPoint(cobArray.get(ci).getX(), cobArray.get(ci).getY() * maxByScale / maxCobValueFound / 2));
}
cobArray = cobArrayRescaled;
}
if (!maxByScale.equals(maxDevValueFound)) {
List<DeviationDataPoint> devArrayRescaled = new ArrayList<>();
for (int ci = 0; ci < devArray.size(); ci++) {
devArrayRescaled.add(new DeviationDataPoint(devArray.get(ci).getX(), devArray.get(ci).getY() * maxByScale / maxDevValueFound, devArray.get(ci).color));
}
devArray = devArrayRescaled;
}
if (!maxByScale.equals(maxRatioValueFound)) {
List<DataPoint> ratioArrayRescaled = new ArrayList<>();
for (int ci = 0; ci < ratioArray.size(); ci++) {
ratioArrayRescaled.add(new DataPoint(ratioArray.get(ci).getX(), (ratioArray.get(ci).getY() - 1) * maxByScale / maxRatioValueFound));
}
ratioArray = ratioArrayRescaled;
}
}
// COB
DataPoint[] cobData = new DataPoint[cobArray.size()];
cobData = cobArray.toArray(cobData);
@ -1374,9 +1397,13 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
return data.color;
}
});
//devSeries.setBackgroundColor(0xB0FFFFFF & MainApp.sResources.getColor(R.color.cob)); //50%
//devSeries.setColor(MainApp.sResources.getColor(R.color.cob));
//devSeries.setThickness(3);
// RATIOS
DataPoint[] ratioData = new DataPoint[ratioArray.size()];
ratioData = ratioArray.toArray(ratioData);
ratioSeries = new LineGraphSeries<>(ratioData);
ratioSeries.setColor(MainApp.sResources.getColor(R.color.ratio));
ratioSeries.setThickness(3);
iobGraph.getSeries().clear();
@ -1389,6 +1416,9 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
if (showDeviationsView.isChecked() && devData.length > 0) {
addSeriesWithoutInvalidate(devSeries, iobGraph);
}
if (showRatiosView.isChecked() && ratioData.length > 0) {
addSeriesWithoutInvalidate(ratioSeries, iobGraph);
}
iobGraph.setVisibility(View.VISIBLE);
} else {
iobGraph.setVisibility(View.GONE);
@ -1591,20 +1621,18 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
//Notifications
public static class RecyclerViewAdapter extends RecyclerView.Adapter<RecyclerViewAdapter.NotificationsViewHolder> {
static class RecyclerViewAdapter extends RecyclerView.Adapter<RecyclerViewAdapter.NotificationsViewHolder> {
List<Notification> notificationsList;
RecyclerViewAdapter(List<Notification> notificationsList) {
this.notificationsList = notificationsList;
log.debug("RecyclerViewAdapter");
}
@Override
public NotificationsViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {
View v = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.overview_notification_item, viewGroup, false);
NotificationsViewHolder notificationsViewHolder = new NotificationsViewHolder(v);
return notificationsViewHolder;
return new NotificationsViewHolder(v);
}
@Override
@ -1635,7 +1663,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
super.onAttachedToRecyclerView(recyclerView);
}
public static class NotificationsViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
static class NotificationsViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
CardView cv;
TextView time;
TextView text;

View file

@ -287,6 +287,22 @@
android:layout_marginBottom="-5dp"
android:layout_marginTop="-9dp"
app:buttonTint="@color/deviations" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="@string/ratio_short"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textStyle="bold" />
<CheckBox
android:id="@+id/overview_showratios"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="-5dp"
android:layout_marginTop="-9dp" />
</LinearLayout>
<LinearLayout

View file

@ -286,6 +286,22 @@
android:layout_marginBottom="-5dp"
android:layout_marginTop="-9dp"
app:buttonTint="@color/deviations" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="@string/ratio_short"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textStyle="bold" />
<CheckBox
android:id="@+id/overview_showratios"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="-5dp"
android:layout_marginTop="-9dp" />
</LinearLayout>
<LinearLayout

View file

@ -502,6 +502,22 @@
android:layout_marginBottom="-5dp"
android:layout_marginTop="-9dp"
app:buttonTint="@color/deviations" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="@string/ratio_short"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textStyle="bold" />
<CheckBox
android:id="@+id/overview_showratios"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="-5dp"
android:layout_marginTop="-9dp" />
</LinearLayout>
<LinearLayout

View file

@ -4,6 +4,7 @@
<color name="basal">#00ffff</color>
<color name="iob">#FFFB8C00</color>
<color name="cob">#8BC34A</color>
<color name="ratio">#FFFFFF</color>
<color name="inrange">#00FF00</color>
<color name="low">#FF0000</color>
<color name="high">#FFFF00</color>

View file

@ -646,4 +646,8 @@
<string name="nsalarm_urgentstaledata">Urgent stale data</string>
<string name="nsalarm_staledatavalue_label">Stale data threshold [min]</string>
<string name="nsalarm_urgent_staledatavalue_label">Urgent stale data threshold [min]</string>
<string name="openapsama_autosens_period">Interval for autosens [h]</string>
<string name="openapsama_autosens_period_summary">Amount of hours in the past for sensitivity detection (carbs absorption time is excluded)</string>
<string name="key_openapsama_autosens_period" translatable="false">openapsama_autosens_period</string>
<string name="ratio_short">RAT</string>
</resources>

View file

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:validate="http://schemas.android.com/apk/res-auto">
<PreferenceCategory
android:key="openapsama"
android:title="@string/openapsama">
@ -9,6 +10,21 @@
android:key="openapsama_useautosens"
android:title="@string/openapsama_useautosens" />
<com.andreabaccega.widget.ValidatingEditTextPreference
validate:maxNumber="24"
validate:minNumber="4"
validate:testType="numericRange"
android:defaultValue="24"
android:dependency="openapsama_useautosens"
android:dialogMessage="@string/openapsama_autosens_period_summary"
android:digits="0123456789"
android:inputType="number"
android:key="@string/key_openapsama_autosens_period"
android:maxLines="20"
android:selectAllOnFocus="true"
android:singleLine="true"
android:title="@string/openapsama_autosens_period" />
</PreferenceCategory>
</PreferenceScreen>