adding color for warn levels of cage,sage...
This commit is contained in:
parent
29bbc9dfec
commit
5e418c5916
|
@ -32,6 +32,8 @@ import info.nightscout.androidaps.plugins.Overview.OverviewFragment;
|
||||||
import info.nightscout.utils.FabricPrivacy;
|
import info.nightscout.utils.FabricPrivacy;
|
||||||
|
|
||||||
public class CareportalFragment extends SubscriberFragment implements View.OnClickListener {
|
public class CareportalFragment extends SubscriberFragment implements View.OnClickListener {
|
||||||
|
private static Logger log = LoggerFactory.getLogger(CareportalFragment.class);
|
||||||
|
|
||||||
TextView iage;
|
TextView iage;
|
||||||
TextView cage;
|
TextView cage;
|
||||||
TextView sage;
|
TextView sage;
|
||||||
|
@ -218,34 +220,43 @@ public class CareportalFragment extends SubscriberFragment implements View.OnCli
|
||||||
public void run() {
|
public void run() {
|
||||||
CareportalEvent careportalEvent;
|
CareportalEvent careportalEvent;
|
||||||
NSSettingsStatus nsSettings = new NSSettingsStatus().getInstance();
|
NSSettingsStatus nsSettings = new NSSettingsStatus().getInstance();
|
||||||
JSONObject extendedSettings = nsSettings.getExtendedSettings();
|
JSONObject extendedSettings = nsSettings.getExtendedValues();
|
||||||
|
double iageUrgent = 7 * 24;
|
||||||
|
double iageWarn = 5 * 24;
|
||||||
|
double cageUrgent = 3 * 24;
|
||||||
|
double cageWarn = 2 * 24;
|
||||||
|
double sageUrgent = 7 * 24;
|
||||||
|
double sageWarn = 6 * 24;
|
||||||
|
double pbageUrgent = 10 * 24;
|
||||||
|
double pbageWarn = 15 * 24;
|
||||||
|
log.debug("Values from NSSettings "+extendedSettings.toString());
|
||||||
// Thresholds in NS are in hours
|
// Thresholds in NS are in hours
|
||||||
double iageThreshold = 7*24;
|
try {
|
||||||
double cageThreshold = 3*24;
|
iageUrgent = extendedSettings.getDouble("iageUrgent");
|
||||||
double sageThreshold = 7*24;
|
iageWarn = extendedSettings.getDouble("iageWarn");
|
||||||
double pbageThreshold = 15*24;
|
cageUrgent = extendedSettings.getDouble("cageUrgent");
|
||||||
// log.debug("NSExtendedSettings are "+extendedSettings.toString());
|
cageWarn = extendedSettings.getDouble("cageWarn");
|
||||||
// try {
|
sageUrgent = extendedSettings.getDouble("sageUrgent");
|
||||||
JSONObject iageSettings = extendedSettings.optJSONObject("iage");
|
sageWarn = extendedSettings.getDouble("sageWarn");
|
||||||
if(iageSettings != null)
|
pbageUrgent = extendedSettings.getDouble("pbageUrgent");
|
||||||
iageThreshold = iageSettings.optDouble("urgent", 7*24);
|
pbageWarn = extendedSettings.getDouble("pbageWarn");
|
||||||
JSONObject cageSettings = extendedSettings.optJSONObject("cage");
|
|
||||||
if(cageSettings != null)
|
} catch (JSONException e) {
|
||||||
cageThreshold = cageSettings.optDouble("urgent", 3*24);
|
log.error("Unhandled exception", e);
|
||||||
// log.debug("cageThreshold is "+cageThreshold);
|
}
|
||||||
JSONObject sageSettings = extendedSettings.optJSONObject("sage");
|
|
||||||
if(sageSettings != null)
|
|
||||||
sageThreshold = sageSettings.optDouble("urgent", 7*24);
|
|
||||||
// } catch (JSONException e) {
|
|
||||||
// log.error("Unhandled exception", e);
|
|
||||||
// }
|
|
||||||
String notavailable = OverviewFragment.shorttextmode ? "-" : MainApp.sResources.getString(R.string.notavailable);
|
String notavailable = OverviewFragment.shorttextmode ? "-" : MainApp.sResources.getString(R.string.notavailable);
|
||||||
if (sage != null) {
|
if (sage != null) {
|
||||||
careportalEvent = MainApp.getDbHelper().getLastCareportalEvent(CareportalEvent.SENSORCHANGE);
|
careportalEvent = MainApp.getDbHelper().getLastCareportalEvent(CareportalEvent.SENSORCHANGE);
|
||||||
if(careportalEvent != null) {
|
if(careportalEvent != null) {
|
||||||
if(careportalEvent.isOlderThan( sageThreshold/24)){
|
if(careportalEvent.isOlderThan( sageUrgent/24)){
|
||||||
sage.setTextColor(MainApp.sResources.getColor(R.color.low));
|
sage.setTextColor(MainApp.sResources.getColor(R.color.low));
|
||||||
sage.setText(careportalEvent.age());
|
sage.setText(careportalEvent.age());
|
||||||
|
} else if(careportalEvent.isOlderThan( sageWarn/24)){
|
||||||
|
sage.setTextColor(MainApp.sResources.getColor(R.color.high));
|
||||||
|
sage.setText(careportalEvent.age());
|
||||||
} else {
|
} else {
|
||||||
sage.setText(careportalEvent.age());
|
sage.setText(careportalEvent.age());
|
||||||
}
|
}
|
||||||
|
@ -257,9 +268,12 @@ public class CareportalFragment extends SubscriberFragment implements View.OnCli
|
||||||
if (iage != null) {
|
if (iage != null) {
|
||||||
careportalEvent = MainApp.getDbHelper().getLastCareportalEvent(CareportalEvent.INSULINCHANGE);
|
careportalEvent = MainApp.getDbHelper().getLastCareportalEvent(CareportalEvent.INSULINCHANGE);
|
||||||
if(careportalEvent != null) {
|
if(careportalEvent != null) {
|
||||||
if(careportalEvent.isOlderThan(iageThreshold/24)){
|
if(careportalEvent.isOlderThan(iageUrgent/24)){
|
||||||
iage.setTextColor(MainApp.sResources.getColor(R.color.low));
|
iage.setTextColor(MainApp.sResources.getColor(R.color.low));
|
||||||
iage.setText(careportalEvent.age());
|
iage.setText(careportalEvent.age());
|
||||||
|
} else if(careportalEvent.isOlderThan( iageWarn/24)) {
|
||||||
|
iage.setTextColor(MainApp.sResources.getColor(R.color.high));
|
||||||
|
iage.setText(careportalEvent.age());
|
||||||
} else {
|
} else {
|
||||||
iage.setText(careportalEvent.age());
|
iage.setText(careportalEvent.age());
|
||||||
}
|
}
|
||||||
|
@ -271,9 +285,12 @@ public class CareportalFragment extends SubscriberFragment implements View.OnCli
|
||||||
if (cage != null) {
|
if (cage != null) {
|
||||||
careportalEvent = MainApp.getDbHelper().getLastCareportalEvent(CareportalEvent.SITECHANGE);
|
careportalEvent = MainApp.getDbHelper().getLastCareportalEvent(CareportalEvent.SITECHANGE);
|
||||||
if (careportalEvent != null) {
|
if (careportalEvent != null) {
|
||||||
if(careportalEvent.isOlderThan(cageThreshold/24)){
|
if(careportalEvent.isOlderThan(cageUrgent/24)){
|
||||||
cage.setTextColor(MainApp.sResources.getColor(R.color.low));
|
cage.setTextColor(MainApp.sResources.getColor(R.color.low));
|
||||||
cage.setText(careportalEvent.age());
|
cage.setText(careportalEvent.age());
|
||||||
|
} else if(careportalEvent.isOlderThan( cageWarn/24)) {
|
||||||
|
cage.setTextColor(MainApp.sResources.getColor(R.color.high));
|
||||||
|
cage.setText(careportalEvent.age());
|
||||||
} else {
|
} else {
|
||||||
cage.setText(careportalEvent.age());
|
cage.setText(careportalEvent.age());
|
||||||
}
|
}
|
||||||
|
@ -285,9 +302,12 @@ public class CareportalFragment extends SubscriberFragment implements View.OnCli
|
||||||
if (pbage != null) {
|
if (pbage != null) {
|
||||||
careportalEvent = MainApp.getDbHelper().getLastCareportalEvent(CareportalEvent.PUMPBATTERYCHANGE);
|
careportalEvent = MainApp.getDbHelper().getLastCareportalEvent(CareportalEvent.PUMPBATTERYCHANGE);
|
||||||
if(careportalEvent != null) {
|
if(careportalEvent != null) {
|
||||||
if(careportalEvent.isOlderThan(pbageThreshold/24)){
|
if(careportalEvent.isOlderThan(pbageUrgent/24)){
|
||||||
pbage.setTextColor(MainApp.sResources.getColor(R.color.low));
|
pbage.setTextColor(MainApp.sResources.getColor(R.color.low));
|
||||||
pbage.setText(careportalEvent.age());
|
pbage.setText(careportalEvent.age());
|
||||||
|
} else if(careportalEvent.isOlderThan( pbageWarn/24)) {
|
||||||
|
pbage.setTextColor(MainApp.sResources.getColor(R.color.high));
|
||||||
|
pbage.setText(careportalEvent.age());
|
||||||
} else {
|
} else {
|
||||||
pbage.setText(careportalEvent.age());
|
pbage.setText(careportalEvent.age());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue