Insulin activity scale detection

This commit is contained in:
Milos Kozak 2019-08-15 17:54:57 +02:00
parent bfedc3d9d7
commit 0bdaa17082
4 changed files with 24 additions and 33 deletions

View file

@ -3,7 +3,9 @@ package info.nightscout.androidaps.plugins.general.overview;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.NotificationManager;
import androidx.arch.core.util.Function;
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
@ -12,6 +14,7 @@ import android.graphics.Color;
import android.graphics.Paint;
import android.os.Bundle;
import android.os.Handler;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import androidx.fragment.app.FragmentManager;
@ -20,6 +23,7 @@ import androidx.appcompat.app.AlertDialog;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.appcompat.widget.PopupMenu;
import androidx.recyclerview.widget.RecyclerView;
import android.text.SpannableString;
import android.text.style.ForegroundColorSpan;
import android.util.DisplayMetrics;
@ -350,7 +354,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
else
predictionsAvailable = false;
MenuItem item,dividerItem;
MenuItem item, dividerItem;
CharSequence title;
int titleMaxChars = 0;
SpannableString s;
@ -444,7 +448,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
}
// Fairly good guestimate for required divider text size...
title = new String(new char[titleMaxChars+10]).replace("\0", "_");
title = new String(new char[titleMaxChars + 10]).replace("\0", "_");
dividerItem.setTitle(title);
popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
@ -1465,13 +1469,13 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
// set manual x bounds to have nice steps
graphData.formatAxis(fromTime, endTime);
if(SP.getBoolean("showactivityprimary", true)) {
graphData.addActivity(fromTime, endTime, false,1d);
}
// Treatments
graphData.addTreatments(fromTime, endTime);
if (SP.getBoolean("showactivityprimary", true)) {
graphData.addActivity(fromTime, endTime, false, 0.8d);
}
// add basal data
if (pump.getPumpDescription().isTempBasalCapable && SP.getBoolean("showbasals", true)) {
graphData.addBasals(fromTime, now, lowLine / graphData.maxY / 1.2d);
@ -1518,8 +1522,8 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
secondGraphData.addDeviations(fromTime, now, useDevForScale, 1d);
if (SP.getBoolean("showratios", false))
secondGraphData.addRatio(fromTime, now, useRatioForScale, 1d);
if(SP.getBoolean("showactivitysecondary", true))
secondGraphData.addActivity(fromTime, endTime, useIAForScale,useIAForScale ? 2d: 1d);
if (SP.getBoolean("showactivitysecondary", true))
secondGraphData.addActivity(fromTime, endTime, useIAForScale, 0.8d);
if (SP.getBoolean("showdevslope", false) && MainApp.devBranch)
secondGraphData.addDeviationSlope(fromTime, now, useDSForScale, 1d);

View file

@ -357,7 +357,8 @@ public class GraphData {
double now = System.currentTimeMillis();
Scale actScale = new Scale();
IobTotal total = null;
IobTotal total;
double maxIAValue = 0;
for (long time = fromTime; time <= toTime; time += 5 * 60 * 1000L) {
Profile profile = ProfileFunctions.getInstance().getProfile(time);
@ -370,6 +371,7 @@ public class GraphData {
actArrayHist.add(new ScaledDataPoint(time, act, actScale));
else
actArrayPred.add(new ScaledDataPoint(time, act, actScale));
if (act > maxIAValue) maxIAValue = act;
}
ScaledDataPoint[] actData = new ScaledDataPoint[actArrayHist.size()];
@ -392,7 +394,6 @@ public class GraphData {
paint.setColor(MainApp.gc(R.color.activity));
actSeriesPred.setCustomPaint(paint);
double maxIAValue = SP.getDouble(R.string.key_scale_insulin_activity, 0.05);
if (useForScale) {
maxY = maxIAValue;
minY = -maxIAValue;

View file

@ -1440,8 +1440,6 @@
<string name="old_version">old version</string>
<string name="very_old_version">very old version</string>
<string name="new_version_warning">New version for at least %1$d days available! Fallback to LGS after 60 days, loop will be disabled after 90 days</string>
<string name="key_scale_insulin_activity" translatable="false">scale_insulin_activity</string>
<string name="scale_insulin_activity">Graph scale insulin activity [U/min]</string>
<string name="twohours">2h</string>
<string name="formatinsulinunits">%1$.2fU</string>

View file

@ -10,18 +10,6 @@
android:title="@string/keep_screen_on_title"
android:summary="@string/keep_screen_on_summary"/>
<com.andreabaccega.widget.ValidatingEditTextPreference
android:defaultValue="0.05"
android:inputType="numberDecimal"
android:key="@string/key_scale_insulin_activity"
android:maxLines="1"
android:selectAllOnFocus="true"
android:singleLine="true"
android:title="@string/scale_insulin_activity"
validate:floatmaxNumber="10.0"
validate:floatminNumber="0.0"
validate:testType="floatNumericRange" />
<PreferenceScreen android:title="@string/overview_buttons_selection">
<SwitchPreference