move targets from fragment to plugin

This commit is contained in:
Milos Kozak 2016-08-10 23:27:26 +02:00
parent d2b01dcc32
commit d023e4ae32
4 changed files with 13 additions and 16 deletions

View file

@ -37,14 +37,12 @@ import info.nightscout.androidaps.events.EventNewBG;
import info.nightscout.androidaps.events.EventNewBasalProfile;
import info.nightscout.androidaps.events.EventTreatmentChange;
import info.nightscout.androidaps.interfaces.PumpInterface;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderFragment;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.plugins.DanaR.History.DanaRNSHistorySync;
import info.nightscout.androidaps.plugins.Objectives.ObjectivesFragment;
import info.nightscout.androidaps.plugins.Objectives.ObjectivesPlugin;
import info.nightscout.androidaps.plugins.Overview.OverviewFragment;
import info.nightscout.androidaps.plugins.SmsCommunicator.events.EventNewSMS;
import info.nightscout.androidaps.plugins.Overview.OverviewPlugin;
import info.nightscout.androidaps.plugins.SmsCommunicator.SmsCommunicatorFragment;
import info.nightscout.androidaps.plugins.SmsCommunicator.events.EventNewSMS;
import info.nightscout.androidaps.plugins.SourceNSClient.SourceNSClientFragment;
import info.nightscout.androidaps.plugins.SourceXdrip.SourceXdripFragment;
import info.nightscout.androidaps.receivers.DataReceiver;
@ -200,12 +198,11 @@ public class DataService extends IntentService {
JSONObject settings = statusJson.getJSONObject("settings");
if (settings.has("thresholds")) {
JSONObject thresholds = settings.getJSONObject("thresholds");
OverviewFragment overviewFragment = (OverviewFragment) MainApp.getSpecificPlugin(OverviewFragment.class);
if (overviewFragment != null && thresholds.has("bgTargetTop")) {
overviewFragment.bgTargetHigh = thresholds.getDouble("bgTargetTop");
if (thresholds.has("bgTargetTop")) {
OverviewPlugin.bgTargetHigh = thresholds.getDouble("bgTargetTop");
}
if (overviewFragment != null && thresholds.has("bgTargetBottom")) {
overviewFragment.bgTargetLow = thresholds.getDouble("bgTargetBottom");
if (thresholds.has("bgTargetBottom")) {
OverviewPlugin.bgTargetLow = thresholds.getDouble("bgTargetBottom");
}
}
}

View file

@ -98,9 +98,6 @@ public class OverviewFragment extends Fragment {
private static Handler sHandler;
private static HandlerThread sHandlerThread;
public Double bgTargetLow = 80d;
public Double bgTargetHigh = 180d;
public OverviewFragment() {
super();
if (sHandlerThread == null) {
@ -419,8 +416,8 @@ public class OverviewFragment extends Fragment {
long toTime = calendar.getTimeInMillis() + 100000; // little bit more to avoid wrong rounding
long fromTime = toTime - hoursToFetch * 60 * 60 * 1000L;
Double lowLine = NSProfile.fromMgdlToUnits(bgTargetLow, units);
Double highLine = NSProfile.fromMgdlToUnits(bgTargetHigh, units);
Double lowLine = NSProfile.fromMgdlToUnits(OverviewPlugin.bgTargetLow, units);
Double highLine = NSProfile.fromMgdlToUnits(OverviewPlugin.bgTargetHigh, units);
BarGraphSeries<DataPoint> basalsSeries = null;
LineGraphSeries<DataPoint> seriesLow = null;

View file

@ -9,6 +9,9 @@ import info.nightscout.androidaps.interfaces.PluginBase;
*/
public class OverviewPlugin implements PluginBase {
public static Double bgTargetLow = 80d;
public static Double bgTargetHigh = 180d;
@Override
public String getFragmentClass() {
return OverviewFragment.class.getName();

View file

@ -20,7 +20,7 @@
<color name="colorAffectingIOB">#830400</color>
<color name="colorNotEnded">#190084</color>
<color name="colorPumpLabel">#FF478EFF</color>
<color name="cardItemLabel">#779ECB</color>
<color name="colorPumpLabel">#779ECB</color>
<color name="cardItemLabel">#FF478EFF</color>
</resources>