diff --git a/app/src/main/java/info/nightscout/androidaps/Config.java b/app/src/main/java/info/nightscout/androidaps/Config.java index afb40421df..a12e0a9ea0 100644 --- a/app/src/main/java/info/nightscout/androidaps/Config.java +++ b/app/src/main/java/info/nightscout/androidaps/Config.java @@ -23,8 +23,6 @@ public class Config { public static final boolean SMSCOMMUNICATORENABLED = !BuildConfig.NSCLIENTOLNY && !BuildConfig.G5UPLOADER; - public static final boolean displayDeviationSlope = false; - public static final boolean detailedLog = true; public static final boolean logFunctionCalls = true; public static final boolean logIncommingData = true; diff --git a/app/src/main/java/info/nightscout/androidaps/HistoryBrowseActivity.java b/app/src/main/java/info/nightscout/androidaps/HistoryBrowseActivity.java index a9243ab995..cf3d1fc34c 100644 --- a/app/src/main/java/info/nightscout/androidaps/HistoryBrowseActivity.java +++ b/app/src/main/java/info/nightscout/androidaps/HistoryBrowseActivity.java @@ -46,7 +46,7 @@ public class HistoryBrowseActivity extends AppCompatActivity { ImageButton chartButton; boolean showBasal = true; - boolean showIob, showCob, showDev, showRat; + boolean showIob, showCob, showDev, showRat, showDevslope; @BindView(R.id.historybrowse_date) @@ -267,6 +267,7 @@ public class HistoryBrowseActivity extends AppCompatActivity { boolean useCobForScale = false; boolean useDevForScale = false; boolean useRatioForScale = false; + boolean useDevSlopeForScale = false; if (showIob) { useIobForScale = true; @@ -276,6 +277,8 @@ public class HistoryBrowseActivity extends AppCompatActivity { useDevForScale = true; } else if (showRat) { useRatioForScale = true; + } else if (showDevslope) { + useDevSlopeForScale = true; } if (showIob) @@ -286,6 +289,8 @@ public class HistoryBrowseActivity extends AppCompatActivity { secondGraphData.addDeviations(fromTime, toTime, useDevForScale, 1d); if (showRat) secondGraphData.addRatio(fromTime, toTime, useRatioForScale, 1d); + if (showDevslope) + secondGraphData.addDeviationSlope(fromTime, toTime, useDevSlopeForScale, 1d); // **** NOW line **** // set manual x bounds to have nice steps @@ -293,7 +298,7 @@ public class HistoryBrowseActivity extends AppCompatActivity { secondGraphData.addNowLine(pointer); // do GUI update - if (showIob || showCob || showDev || showRat) { + if (showIob || showCob || showDev || showRat || showDevslope) { iobGraph.setVisibility(View.VISIBLE); } else { iobGraph.setVisibility(View.GONE); @@ -354,23 +359,31 @@ public class HistoryBrowseActivity extends AppCompatActivity { item.setCheckable(true); item.setChecked(showRat); + if (MainApp.devBranch) { + item = popup.getMenu().add(Menu.NONE, OverviewFragment.CHARTTYPE.DEVSLOPE.ordinal(), Menu.NONE, "Deviation slope"); + title = item.getTitle(); + s = new SpannableString(title); + s.setSpan(new ForegroundColorSpan(ResourcesCompat.getColor(getResources(), R.color.devslopepos, null)), 0, s.length(), 0); + item.setTitle(s); + item.setCheckable(true); + item.setChecked(showDevslope); + } + popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { if (item.getItemId() == OverviewFragment.CHARTTYPE.BAS.ordinal()) { showBasal = !item.isChecked(); - } else if (item.getItemId() == OverviewFragment.CHARTTYPE.IOB.ordinal()) { showIob = !item.isChecked(); - } else if (item.getItemId() == OverviewFragment.CHARTTYPE.COB.ordinal()) { showCob = !item.isChecked(); - } else if (item.getItemId() == OverviewFragment.CHARTTYPE.DEV.ordinal()) { showDev = !item.isChecked(); - } else if (item.getItemId() == OverviewFragment.CHARTTYPE.SEN.ordinal()) { showRat = !item.isChecked(); + } else if (item.getItemId() == OverviewFragment.CHARTTYPE.DEVSLOPE.ordinal()) { + showDevslope = !item.isChecked(); } updateGUI("onGraphCheckboxesCheckedChanged"); return true; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java index 26f20a7eb9..8f00c18d75 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java @@ -184,9 +184,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener, final Object updateSync = new Object(); - public enum CHARTTYPE {PRE, BAS, IOB, COB, DEV, SEN} - - ; + public enum CHARTTYPE {PRE, BAS, IOB, COB, DEV, SEN, DEVSLOPE} private static final ScheduledExecutorService worker = Executors.newSingleThreadScheduledExecutor(); private static ScheduledFuture scheduledUpdate = null; @@ -410,26 +408,33 @@ public class OverviewFragment extends Fragment implements View.OnClickListener, item.setCheckable(true); item.setChecked(SP.getBoolean("showratios", false)); + if (MainApp.devBranch) { + item = popup.getMenu().add(Menu.NONE, CHARTTYPE.DEVSLOPE.ordinal(), Menu.NONE, "Deviation slope"); + title = item.getTitle(); + s = new SpannableString(title); + s.setSpan(new ForegroundColorSpan(ResourcesCompat.getColor(getResources(), R.color.devslopepos, null)), 0, s.length(), 0); + item.setTitle(s); + item.setCheckable(true); + item.setChecked(SP.getBoolean("showdevslope", false)); + } + popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { if (item.getItemId() == CHARTTYPE.PRE.ordinal()) { SP.putBoolean("showprediction", !item.isChecked()); - } else if (item.getItemId() == CHARTTYPE.BAS.ordinal()) { SP.putBoolean("showbasals", !item.isChecked()); - } else if (item.getItemId() == CHARTTYPE.IOB.ordinal()) { SP.putBoolean("showiob", !item.isChecked()); - } else if (item.getItemId() == CHARTTYPE.COB.ordinal()) { SP.putBoolean("showcob", !item.isChecked()); - } else if (item.getItemId() == CHARTTYPE.DEV.ordinal()) { SP.putBoolean("showdeviations", !item.isChecked()); - } else if (item.getItemId() == CHARTTYPE.SEN.ordinal()) { SP.putBoolean("showratios", !item.isChecked()); + } else if (item.getItemId() == CHARTTYPE.DEVSLOPE.ordinal()) { + SP.putBoolean("showdevslope", !item.isChecked()); } scheduleUpdateGUI("onGraphCheckboxesCheckedChanged"); return true; @@ -1387,7 +1392,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener, useDevForScale = true; } else if (SP.getBoolean("showratios", false)) { useRatioForScale = true; - } else if (Config.displayDeviationSlope) { + } else if (SP.getBoolean("showdevslope", false)) { useDSForScale = true; } @@ -1399,7 +1404,7 @@ 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 (Config.displayDeviationSlope) + if (SP.getBoolean("showdevslope", false)) secondGraphData.addDeviationSlope(fromTime, now, useDSForScale, 1d); // **** NOW line **** @@ -1411,7 +1416,11 @@ public class OverviewFragment extends Fragment implements View.OnClickListener, FragmentActivity activity = getActivity(); if (activity != null) { activity.runOnUiThread(() -> { - if (SP.getBoolean("showiob", true) || SP.getBoolean("showcob", true) || SP.getBoolean("showdeviations", false) || SP.getBoolean("showratios", false) || Config.displayDeviationSlope) { + if (SP.getBoolean("showiob", true) + || SP.getBoolean("showcob", true) + || SP.getBoolean("showdeviations", false) + || SP.getBoolean("showratios", false) + || SP.getBoolean("showdevslope", false)) { iobGraph.setVisibility(View.VISIBLE); } else { iobGraph.setVisibility(View.GONE); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/graphData/GraphData.java b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/graphData/GraphData.java index 06ea2d6d65..1bf59db4de 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/graphData/GraphData.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/graphData/GraphData.java @@ -108,7 +108,7 @@ public class GraphData { inRangeAreaSeries = new AreaGraphSeries<>(inRangeAreaDataPoints); inRangeAreaSeries.setColor(0); inRangeAreaSeries.setDrawBackground(true); - inRangeAreaSeries.setBackgroundColor(MainApp.sResources.getColor(R.color.inrangebackground)); + inRangeAreaSeries.setBackgroundColor(MainApp.gc(R.color.inrangebackground)); addSeries(inRangeAreaSeries); } @@ -184,14 +184,14 @@ public class GraphData { baseBasal = baseBasalArray.toArray(baseBasal); baseBasalsSeries = new LineGraphSeries<>(baseBasal); baseBasalsSeries.setDrawBackground(true); - baseBasalsSeries.setBackgroundColor(MainApp.sResources.getColor(R.color.basebasal)); + baseBasalsSeries.setBackgroundColor(MainApp.gc(R.color.basebasal)); baseBasalsSeries.setThickness(0); ScaledDataPoint[] tempBasal = new ScaledDataPoint[tempBasalArray.size()]; tempBasal = tempBasalArray.toArray(tempBasal); tempBasalsSeries = new LineGraphSeries<>(tempBasal); tempBasalsSeries.setDrawBackground(true); - tempBasalsSeries.setBackgroundColor(MainApp.sResources.getColor(R.color.tempbasal)); + tempBasalsSeries.setBackgroundColor(MainApp.gc(R.color.tempbasal)); tempBasalsSeries.setThickness(0); ScaledDataPoint[] basalLine = new ScaledDataPoint[basalLineArray.size()]; @@ -201,7 +201,7 @@ public class GraphData { paint.setStyle(Paint.Style.STROKE); paint.setStrokeWidth(MainApp.instance().getApplicationContext().getResources().getDisplayMetrics().scaledDensity * 2); paint.setPathEffect(new DashPathEffect(new float[]{2, 4}, 0)); - paint.setColor(MainApp.sResources.getColor(R.color.basal)); + paint.setColor(MainApp.gc(R.color.basal)); basalsLineSeries.setCustomPaint(paint); ScaledDataPoint[] absoluteBasalLine = new ScaledDataPoint[absoluteBasalLineArray.size()]; @@ -210,7 +210,7 @@ public class GraphData { Paint absolutePaint = new Paint(); absolutePaint.setStyle(Paint.Style.STROKE); absolutePaint.setStrokeWidth(MainApp.instance().getApplicationContext().getResources().getDisplayMetrics().scaledDensity * 2); - absolutePaint.setColor(MainApp.sResources.getColor(R.color.basal)); + absolutePaint.setColor(MainApp.gc(R.color.basal)); absoluteBasalsLineSeries.setCustomPaint(absolutePaint); basalScale.setMultiplier(maxY * scale / maxBasalValueFound); @@ -259,7 +259,7 @@ public class GraphData { targets = targetsSeriesArray.toArray(targets); targetsSeries = new LineGraphSeries<>(targets); targetsSeries.setDrawBackground(false); - targetsSeries.setColor(MainApp.sResources.getColor(R.color.tempTargetBackground)); + targetsSeries.setColor(MainApp.gc(R.color.tempTargetBackground)); targetsSeries.setThickness(2); addSeries(targetsSeries); @@ -351,8 +351,8 @@ public class GraphData { iobData = iobArray.toArray(iobData); iobSeries = new FixedLineGraphSeries<>(iobData); iobSeries.setDrawBackground(true); - iobSeries.setBackgroundColor(0x80FFFFFF & MainApp.sResources.getColor(R.color.iob)); //50% - iobSeries.setColor(MainApp.sResources.getColor(R.color.iob)); + iobSeries.setBackgroundColor(0x80FFFFFF & MainApp.gc(R.color.iob)); //50% + iobSeries.setColor(MainApp.gc(R.color.iob)); iobSeries.setThickness(3); if (useForScale) @@ -395,8 +395,8 @@ public class GraphData { cobData = cobArray.toArray(cobData); cobSeries = new FixedLineGraphSeries<>(cobData); cobSeries.setDrawBackground(true); - cobSeries.setBackgroundColor(0xB0FFFFFF & MainApp.sResources.getColor(R.color.cob)); //50% - cobSeries.setColor(MainApp.sResources.getColor(R.color.cob)); + cobSeries.setBackgroundColor(0xB0FFFFFF & MainApp.gc(R.color.cob)); //50% + cobSeries.setColor(MainApp.gc(R.color.cob)); cobSeries.setThickness(3); if (useForScale) @@ -477,7 +477,7 @@ public class GraphData { ScaledDataPoint[] ratioData = new ScaledDataPoint[ratioArray.size()]; ratioData = ratioArray.toArray(ratioData); ratioSeries = new LineGraphSeries<>(ratioData); - ratioSeries.setColor(MainApp.sResources.getColor(R.color.ratio)); + ratioSeries.setColor(MainApp.gc(R.color.ratio)); ratioSeries.setThickness(3); if (useForScale) @@ -513,13 +513,13 @@ public class GraphData { ScaledDataPoint[] ratioMaxData = new ScaledDataPoint[dsMaxArray.size()]; ratioMaxData = dsMaxArray.toArray(ratioMaxData); dsMaxSeries = new LineGraphSeries<>(ratioMaxData); - dsMaxSeries.setColor(Color.MAGENTA); + dsMaxSeries.setColor(MainApp.gc(R.color.devslopepos)); dsMaxSeries.setThickness(3); ScaledDataPoint[] ratioMinData = new ScaledDataPoint[dsMinArray.size()]; ratioMinData = dsMinArray.toArray(ratioMinData); dsMinSeries = new LineGraphSeries<>(ratioMinData); - dsMinSeries.setColor(Color.YELLOW); + dsMinSeries.setColor(MainApp.gc(R.color.devslopeneg)); dsMinSeries.setThickness(3); if (useForScale) diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index a0b229946e..4aa21abf19 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -8,6 +8,8 @@ #ffea00 #ff9500 #FFFFFF + #FFFFFF00 + #FFFF00FF #00FF00 #FF0000 #FFFF00