Integrate info fields from swissalpine/dev-work

This commit is contained in:
Nico Schmitz 2018-06-13 00:07:13 +02:00
parent 5ba6f02b93
commit f28fca668f
2 changed files with 132 additions and 0 deletions

View file

@ -95,6 +95,7 @@ import info.nightscout.androidaps.plugins.IobCobCalculator.events.EventIobCalcul
import info.nightscout.androidaps.plugins.Loop.LoopPlugin; import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
import info.nightscout.androidaps.plugins.Loop.events.EventNewOpenLoopNotification; import info.nightscout.androidaps.plugins.Loop.events.EventNewOpenLoopNotification;
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSDeviceStatus; import info.nightscout.androidaps.plugins.NSClientInternal.data.NSDeviceStatus;
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSSettingsStatus;
import info.nightscout.androidaps.plugins.Overview.Dialogs.CalibrationDialog; import info.nightscout.androidaps.plugins.Overview.Dialogs.CalibrationDialog;
import info.nightscout.androidaps.plugins.Overview.Dialogs.ErrorHelperActivity; import info.nightscout.androidaps.plugins.Overview.Dialogs.ErrorHelperActivity;
import info.nightscout.androidaps.plugins.Overview.Dialogs.NewCarbsDialog; import info.nightscout.androidaps.plugins.Overview.Dialogs.NewCarbsDialog;
@ -154,6 +155,12 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
TextView sage; TextView sage;
TextView pbage; TextView pbage;
TextView iageView;
TextView cageView;
TextView reservoirView;
TextView sageView;
TextView pbageView;
RecyclerView notificationsView; RecyclerView notificationsView;
LinearLayoutManager llm; LinearLayoutManager llm;
@ -252,6 +259,12 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
sage = (TextView) view.findViewById(R.id.careportal_sensorage); sage = (TextView) view.findViewById(R.id.careportal_sensorage);
pbage = (TextView) view.findViewById(R.id.careportal_pbage); pbage = (TextView) view.findViewById(R.id.careportal_pbage);
iageView = (TextView) view.findViewById(R.id.overview_insulinage);
cageView = (TextView) view.findViewById(R.id.overview_canulaage);
reservoirView = (TextView) view.findViewById(R.id.overview_reservoirlevel);
sageView = (TextView) view.findViewById(R.id.overview_sensorage);
pbageView = (TextView) view.findViewById(R.id.overview_pbage);
bgGraph = (GraphView) view.findViewById(R.id.overview_bggraph); bgGraph = (GraphView) view.findViewById(R.id.overview_bggraph);
iobGraph = (GraphView) view.findViewById(R.id.overview_iobgraph); iobGraph = (GraphView) view.findViewById(R.id.overview_iobgraph);
@ -1304,6 +1317,67 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
cobView.setText(cobText); cobView.setText(cobText);
} }
CareportalEvent careportalEvent;
NSSettingsStatus nsSettings = new NSSettingsStatus().getInstance();
double iageUrgent = nsSettings.getExtendedWarnValue("iage", "urgent", 120);
double iageWarn = nsSettings.getExtendedWarnValue("iage", "warn", 96);
double cageUrgent = nsSettings.getExtendedWarnValue("cage", "urgent", 48);
double cageWarn = nsSettings.getExtendedWarnValue("cage", "warn", 24);
double sageUrgent = nsSettings.getExtendedWarnValue("sage", "urgent", 504);
double sageWarn = nsSettings.getExtendedWarnValue("sage", "warn", 336);
double pbageUrgent = nsSettings.getExtendedWarnValue("pgage", "urgent", 672);
double pbageWarn = nsSettings.getExtendedWarnValue("pgage", "warn", 504);
if (cageView != null) {
careportalEvent = MainApp.getDbHelper().getLastCareportalEvent(CareportalEvent.SITECHANGE);
if (careportalEvent != null) {
cageView.setTextColor(determineTextColor(careportalEvent, cageWarn, cageUrgent));
cageView.setText("CAN"); //: " + careportalEvent.age());
} else {
cageView.setText("n/a");
}
}
if (iageView != null) {
careportalEvent = MainApp.getDbHelper().getLastCareportalEvent(CareportalEvent.INSULINCHANGE);
if (careportalEvent != null) {
iageView.setTextColor(determineTextColor(careportalEvent, iageWarn, iageUrgent));
iageView.setText("INS"); //: + careportalEvent.age());
} else {
iageView.setText("n/a");
}
}
if (reservoirView != null) {
if (pump.isInitialized() && pump.getReservoirLevel() < 50) {
reservoirView.setTextColor(MainApp.gc(R.color.low));
} else {
reservoirView.setTextColor(MainApp.gc(R.color.colorLightGray));
}
reservoirView.setText("RES");
}
if (sageView != null) {
careportalEvent = MainApp.getDbHelper().getLastCareportalEvent(CareportalEvent.SENSORCHANGE);
if (careportalEvent != null) {
sageView.setTextColor(determineTextColor(careportalEvent, sageWarn, sageUrgent));
sageView.setText("SEN"); // + careportalEvent.age());
} else {
sageView.setText("n/a");
}
}
if (pbageView != null) {
careportalEvent = MainApp.getDbHelper().getLastCareportalEvent(CareportalEvent.PUMPBATTERYCHANGE);
if (careportalEvent != null) {
pbageView.setTextColor(determineTextColor(careportalEvent, pbageWarn, pbageUrgent));
pbageView.setText("BAT"); //careportalEvent.age());
} else {
pbageView.setText("n/a");
}
}
final boolean predictionsAvailable = finalLastRun != null && finalLastRun.request.hasPredictions; final boolean predictionsAvailable = finalLastRun != null && finalLastRun.request.hasPredictions;
// pump status from ns // pump status from ns
if (pumpDeviceStatusView != null) { if (pumpDeviceStatusView != null) {
@ -1466,4 +1540,14 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
} }
} }
public static int determineTextColor(CareportalEvent careportalEvent, double warnThreshold, double urgentThreshold) {
if (careportalEvent.isOlderThan(urgentThreshold)) {
return MainApp.gc(R.color.low);
} else if (careportalEvent.isOlderThan(warnThreshold)) {
return MainApp.gc(R.color.high);
} else {
return MainApp.gc(R.color.colorLightGray);
}
}
} }

View file

@ -183,6 +183,54 @@
</LinearLayout> </LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:orientation="horizontal">
<TextView
android:id="@+id/overview_canulaage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="0dp"
android:text=""
android:textSize="14sp" />
<TextView
android:id="@+id/overview_insulinage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="10dp"
android:text=""
android:textSize="14sp" />
<TextView
android:id="@+id/overview_reservoirlevel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="10dp"
android:text=""
android:textSize="14sp" />
<TextView
android:id="@+id/overview_sensorage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="10dp"
android:text=""
android:textSize="14sp" />
<TextView
android:id="@+id/overview_pbage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="10dp"
android:text=""
android:textSize="14sp" />
</LinearLayout>
<TextView <TextView
android:id="@+id/overview_extendedbolus" android:id="@+id/overview_extendedbolus"
android:layout_width="match_parent" android:layout_width="match_parent"