diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/data/NSDeviceStatus.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/data/NSDeviceStatus.kt index c0a7e3a9b5..0b1ecc3105 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/data/NSDeviceStatus.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/data/NSDeviceStatus.kt @@ -4,8 +4,6 @@ import android.text.Spanned import dagger.android.HasAndroidInjector import info.nightscout.androidaps.R import info.nightscout.androidaps.interfaces.Config -import info.nightscout.shared.logging.AAPSLogger -import info.nightscout.shared.logging.LTag import info.nightscout.androidaps.plugins.aps.loop.APSResult import info.nightscout.androidaps.plugins.configBuilder.RunningConfiguration import info.nightscout.androidaps.utils.DateUtil @@ -14,6 +12,8 @@ import info.nightscout.androidaps.utils.JsonHelper import info.nightscout.androidaps.utils.Round import info.nightscout.androidaps.utils.T import info.nightscout.androidaps.utils.resources.ResourceHelper +import info.nightscout.shared.logging.AAPSLogger +import info.nightscout.shared.logging.LTag import info.nightscout.shared.sharedPreferences.SP import org.json.JSONArray import org.json.JSONException @@ -88,7 +88,7 @@ class NSDeviceStatus @Inject constructor( fun handleNewData(deviceStatuses: JSONArray) { aapsLogger.debug(LTag.NSCLIENT, "Got NS deviceStatus: \$deviceStatuses") try { - for (i in deviceStatuses.length() -1 downTo 0) { + for (i in deviceStatuses.length() - 1 downTo 0) { val devicestatusJson = deviceStatuses.getJSONObject(i) if (devicestatusJson != null) { setData(devicestatusJson) @@ -157,7 +157,7 @@ class NSDeviceStatus @Inject constructor( //String[] ALL_STATUS_FIELDS = {"reservoir", "battery", "clock", "status", "device"}; val string = StringBuilder() - .append("") + .append("") .append(rh.gs(R.string.pump)) .append(": ") @@ -165,13 +165,13 @@ class NSDeviceStatus @Inject constructor( val level = when { pumpData.clock + nsSettingsStatus.extendedPumpSettings("urgentClock") * 60 * 1000L < dateUtil.now() -> Levels.URGENT pumpData.reservoir < nsSettingsStatus.extendedPumpSettings("urgentRes") -> Levels.URGENT - pumpData.isPercent && pumpData.percent < nsSettingsStatus.extendedPumpSettings("urgentBattP") -> Levels.URGENT + pumpData.isPercent && pumpData.percent < nsSettingsStatus.extendedPumpSettings("urgentBattP") -> Levels.URGENT !pumpData.isPercent && pumpData.voltage < nsSettingsStatus.extendedPumpSettings("urgentBattV") -> Levels.URGENT pumpData.clock + nsSettingsStatus.extendedPumpSettings("warnClock") * 60 * 1000L < dateUtil.now() -> Levels.WARN pumpData.reservoir < nsSettingsStatus.extendedPumpSettings("warnRes") -> Levels.WARN - pumpData.isPercent && pumpData.percent < nsSettingsStatus.extendedPumpSettings("warnBattP") -> Levels.WARN - !pumpData.isPercent && pumpData.voltage < nsSettingsStatus.extendedPumpSettings("warnBattV") -> Levels.WARN - else -> Levels.INFO + pumpData.isPercent && pumpData.percent < nsSettingsStatus.extendedPumpSettings("warnBattP") -> Levels.WARN + !pumpData.isPercent && pumpData.voltage < nsSettingsStatus.extendedPumpSettings("warnBattV") -> Levels.WARN + else -> Levels.INFO } string.append("") val fields = nsSettingsStatus.pumpExtendedSettingsFields() @@ -248,7 +248,7 @@ class NSDeviceStatus @Inject constructor( val openApsStatus: Spanned get() { val string = StringBuilder() - .append("") + .append("") .append(rh.gs(R.string.openaps_short)) .append(": ") @@ -256,7 +256,7 @@ class NSDeviceStatus @Inject constructor( val level = when { deviceStatusData.openAPSData.clockSuggested + T.mins(sp.getLong(R.string.key_nsalarm_urgent_staledatavalue, 31)).msecs() < dateUtil.now() -> Levels.URGENT deviceStatusData.openAPSData.clockSuggested + T.mins(sp.getLong(R.string.key_nsalarm_staledatavalue, 16)).msecs() < dateUtil.now() -> Levels.WARN - else -> Levels.INFO + else -> Levels.INFO } string.append("") if (deviceStatusData.openAPSData.clockSuggested != 0L) string.append(dateUtil.minAgo(rh, deviceStatusData.openAPSData.clockSuggested)).append(" ") @@ -268,8 +268,10 @@ class NSDeviceStatus @Inject constructor( get() { val string = StringBuilder() try { - if (deviceStatusData.openAPSData.enacted != null && deviceStatusData.openAPSData.clockEnacted != deviceStatusData.openAPSData.clockSuggested) string.append("").append(dateUtil.minAgo(rh, deviceStatusData.openAPSData.clockEnacted)).append(" ").append(deviceStatusData.openAPSData.enacted!!.getString("reason")).append("
") - if (deviceStatusData.openAPSData.suggested != null) string.append("").append(dateUtil.minAgo(rh, deviceStatusData.openAPSData.clockSuggested)).append(" ").append(deviceStatusData.openAPSData.suggested!!.getString("reason")).append("
") + if (deviceStatusData.openAPSData.enacted != null && deviceStatusData.openAPSData.clockEnacted != deviceStatusData.openAPSData.clockSuggested) string.append("") + .append(dateUtil.minAgo(rh, deviceStatusData.openAPSData.clockEnacted)).append(" ").append(deviceStatusData.openAPSData.enacted!!.getString("reason")).append("
") + if (deviceStatusData.openAPSData.suggested != null) string.append("").append(dateUtil.minAgo(rh, deviceStatusData.openAPSData.clockSuggested)).append(" ") + .append(deviceStatusData.openAPSData.suggested!!.getString("reason")).append("
") return fromHtml(string.toString()) } catch (e: JSONException) { aapsLogger.error("Unhandled exception", e) @@ -321,7 +323,7 @@ class NSDeviceStatus @Inject constructor( val uploaderStatusSpanned: Spanned get() { val string = StringBuilder() - string.append("") + string.append("") string.append(rh.gs(R.string.uploader_short)) string.append(": ") val iterator: Iterator<*> = deviceStatusData.uploaderMap.entries.iterator() diff --git a/app/src/main/res/layout/overview_fragment.xml b/app/src/main/res/layout/overview_fragment.xml index 3e605e196f..7190d24a58 100644 --- a/app/src/main/res/layout/overview_fragment.xml +++ b/app/src/main/res/layout/overview_fragment.xml @@ -135,7 +135,6 @@ android:id="@+id/nsclient" android:layout_width="match_parent" android:layout_height="wrap_content" - android:background="?attr/colorControlHighlight" app:alignContent="stretch" app:alignItems="stretch" app:flexDirection="row" diff --git a/core/src/main/res/values-night/styles.xml b/core/src/main/res/values-night/styles.xml index 3cec089184..c01067b4ff 100644 --- a/core/src/main/res/values-night/styles.xml +++ b/core/src/main/res/values-night/styles.xml @@ -239,6 +239,8 @@ @color/sphere_plastic_grey @color/isCompleted @color/isNotCompleted + + @color/defaulttext