use bg targets in overview from nightscout
This commit is contained in:
parent
a3d32fcb44
commit
877b760aef
4 changed files with 29 additions and 5 deletions
|
@ -37,7 +37,7 @@
|
||||||
<ConfirmationsSetting value="0" id="Add" />
|
<ConfirmationsSetting value="0" id="Add" />
|
||||||
<ConfirmationsSetting value="0" id="Remove" />
|
<ConfirmationsSetting value="0" id="Remove" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectType">
|
<component name="ProjectType">
|
||||||
|
|
|
@ -36,6 +36,7 @@ import info.nightscout.androidaps.Config;
|
||||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderFragment;
|
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderFragment;
|
||||||
import info.nightscout.androidaps.plugins.Objectives.ObjectivesFragment;
|
import info.nightscout.androidaps.plugins.Objectives.ObjectivesFragment;
|
||||||
|
import info.nightscout.androidaps.plugins.Overview.OverviewFragment;
|
||||||
import info.nightscout.androidaps.plugins.SourceNSClient.SourceNSClientFragment;
|
import info.nightscout.androidaps.plugins.SourceNSClient.SourceNSClientFragment;
|
||||||
import info.nightscout.androidaps.plugins.SourceXdrip.SourceXdripFragment;
|
import info.nightscout.androidaps.plugins.SourceXdrip.SourceXdripFragment;
|
||||||
import info.nightscout.androidaps.receivers.NSClientDataReceiver;
|
import info.nightscout.androidaps.receivers.NSClientDataReceiver;
|
||||||
|
@ -169,6 +170,26 @@ public class DataService extends IntentService {
|
||||||
} else {
|
} else {
|
||||||
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.resources.getString(R.string.unsupportedclientver));
|
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.resources.getString(R.string.unsupportedclientver));
|
||||||
}
|
}
|
||||||
|
if (bundles.containsKey("status")) {
|
||||||
|
try {
|
||||||
|
JSONObject statusJson = new JSONObject(bundles.getString("status"));
|
||||||
|
if (statusJson.has("settings")) {
|
||||||
|
JSONObject settings = statusJson.getJSONObject("settings");
|
||||||
|
if (settings.has("thresholds")) {
|
||||||
|
JSONObject thresholds = settings.getJSONObject("thresholds");
|
||||||
|
OverviewFragment overviewFragment = (OverviewFragment) MainActivity.getSpecificPlugin(OverviewFragment.class);
|
||||||
|
if (thresholds.has("bgTargetTop")) {
|
||||||
|
overviewFragment.bgTargetHigh = thresholds.getDouble("bgTargetTop");
|
||||||
|
}
|
||||||
|
if (thresholds.has("bgTargetBottom")) {
|
||||||
|
overviewFragment.bgTargetLow = thresholds.getDouble("bgTargetBottom");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (JSONException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (intent.getAction().equals(Intents.ACTION_NEW_DEVICESTATUS)) {
|
if (intent.getAction().equals(Intents.ACTION_NEW_DEVICESTATUS)) {
|
||||||
if (nsClientEnabled) {
|
if (nsClientEnabled) {
|
||||||
|
|
|
@ -183,7 +183,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
QueryBuilder<BgReading, Long> queryBuilder = daoBgreadings.queryBuilder();
|
QueryBuilder<BgReading, Long> queryBuilder = daoBgreadings.queryBuilder();
|
||||||
queryBuilder.orderBy("timeIndex", true);
|
queryBuilder.orderBy("timeIndex", true);
|
||||||
Where where = queryBuilder.where();
|
Where where = queryBuilder.where();
|
||||||
where.ge("timeIndex", (long) Math.ceil(mills / 60000d));
|
where.ge("timeIndex", mills);
|
||||||
PreparedQuery<BgReading> preparedQuery = queryBuilder.prepare();
|
PreparedQuery<BgReading> preparedQuery = queryBuilder.prepare();
|
||||||
bgReadings = daoBgreadings.query(preparedQuery);
|
bgReadings = daoBgreadings.query(preparedQuery);
|
||||||
return bgReadings;
|
return bgReadings;
|
||||||
|
|
|
@ -88,6 +88,9 @@ public class OverviewFragment extends Fragment implements PluginBase {
|
||||||
Handler loopHandler = new Handler();
|
Handler loopHandler = new Handler();
|
||||||
Runnable refreshLoop = null;
|
Runnable refreshLoop = null;
|
||||||
|
|
||||||
|
public Double bgTargetLow = 80d;
|
||||||
|
public Double bgTargetHigh = 180d;
|
||||||
|
|
||||||
public OverviewFragment() {
|
public OverviewFragment() {
|
||||||
super();
|
super();
|
||||||
registerBus();
|
registerBus();
|
||||||
|
@ -473,8 +476,8 @@ public class OverviewFragment extends Fragment implements PluginBase {
|
||||||
long toTime = calendar.getTimeInMillis() + 100000; // little bit more to avoid wrong rounding
|
long toTime = calendar.getTimeInMillis() + 100000; // little bit more to avoid wrong rounding
|
||||||
long fromTime = toTime - hoursToFetch * 60 * 60 * 1000l;
|
long fromTime = toTime - hoursToFetch * 60 * 60 * 1000l;
|
||||||
|
|
||||||
Double lowLine = NSProfile.toUnits(80d, 4d, units); // TODO: make this customisable
|
Double lowLine = NSProfile.fromMgdlToUnits(bgTargetLow, units);
|
||||||
Double highLine = NSProfile.toUnits(180d, 10d, units);
|
Double highLine = NSProfile.fromMgdlToUnits(bgTargetHigh, units);
|
||||||
|
|
||||||
BarGraphSeries<DataPoint> basalsSeries = null;
|
BarGraphSeries<DataPoint> basalsSeries = null;
|
||||||
LineGraphSeries<DataPoint> seriesLow = null;
|
LineGraphSeries<DataPoint> seriesLow = null;
|
||||||
|
|
Loading…
Reference in a new issue