Merge pull request #1651 from osodebailar/feature/cardview_for_nsclient_overview

Feature cardview for nsclient overview
This commit is contained in:
Milos Kozak 2022-04-19 22:43:30 +02:00 committed by GitHub
commit 8a1c112218
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 22 additions and 15 deletions

View file

@ -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("<span style=\"color:${rh.gcs(R.color.defaultText)}\">")
.append("<span style=\"color:${rh.gac(R.attr.nsTitleColor)}\">")
.append(rh.gs(R.string.pump))
.append(": </span>")
@ -248,7 +248,7 @@ class NSDeviceStatus @Inject constructor(
val openApsStatus: Spanned
get() {
val string = StringBuilder()
.append("<span style=\"color:${rh.gcs(R.color.defaultText)}\">")
.append("<span style=\"color:${rh.gac(R.attr.nsTitleColor)}\">")
.append(rh.gs(R.string.openaps_short))
.append(": </span>")
@ -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("<b>").append(dateUtil.minAgo(rh, deviceStatusData.openAPSData.clockEnacted)).append("</b> ").append(deviceStatusData.openAPSData.enacted!!.getString("reason")).append("<br>")
if (deviceStatusData.openAPSData.suggested != null) string.append("<b>").append(dateUtil.minAgo(rh, deviceStatusData.openAPSData.clockSuggested)).append("</b> ").append(deviceStatusData.openAPSData.suggested!!.getString("reason")).append("<br>")
if (deviceStatusData.openAPSData.enacted != null && deviceStatusData.openAPSData.clockEnacted != deviceStatusData.openAPSData.clockSuggested) string.append("<b>")
.append(dateUtil.minAgo(rh, deviceStatusData.openAPSData.clockEnacted)).append("</b> ").append(deviceStatusData.openAPSData.enacted!!.getString("reason")).append("<br>")
if (deviceStatusData.openAPSData.suggested != null) string.append("<b>").append(dateUtil.minAgo(rh, deviceStatusData.openAPSData.clockSuggested)).append("</b> ")
.append(deviceStatusData.openAPSData.suggested!!.getString("reason")).append("<br>")
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("<span style=\"color:${rh.gcs(R.color.defaultText)}\">")
string.append("<span style=\"color:${rh.gac(R.attr.nsTitleColor)}\">")
string.append(rh.gs(R.string.uploader_short))
string.append(": </span>")
val iterator: Iterator<*> = deviceStatusData.uploaderMap.entries.iterator()

View file

@ -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"

View file

@ -239,6 +239,8 @@
<item name="separatorColor">@color/sphere_plastic_grey</item>
<item name="isCompletedColor">@color/isCompleted</item>
<item name="isNotCompletedColor">@color/isNotCompleted</item>
<!---Nightscout client TitelColor -->
<item name="nsTitleColor">@color/defaulttext</item>
</style>
<style name="Aaps_ActionBarStyle" parent="@style/Widget.AppCompat.ActionBar">

View file

@ -213,4 +213,6 @@
<attr name="separatorColor" format="reference|color" />
<attr name="isCompletedColor" format="reference|color" />
<attr name="isNotCompletedColor" format="reference|color" />
<!---Nightscout client TitelColor -->
<attr name="nsTitleColor" format="reference|color" />
</resources>

View file

@ -60,7 +60,7 @@
<color name="errorAlertHeaderText">#FF000000</color>
<color name="helperProfile">#C803A9F4</color>
<color name="examinedProfile">#FFFF5555</color>
<color name="defaultText">#BBBBBB</color>
<color name="defaulttext">#666666</color>
<!-- Datepicker-->
<color name="dateTimePickerBackground">@color/white</color>

View file

@ -242,6 +242,8 @@
<item name="separatorColor">@color/sphere_plastic_grey</item>
<item name="isCompletedColor">@color/isCompleted</item>
<item name="isNotCompletedColor">@color/isNotCompleted</item>
<!---Nightscout client TitelColor -->
<item name="nsTitleColor">@color/defaulttext</item>
</style>
<style name="Aaps_ActionBarStyle" parent="@style/Widget.AppCompat.ActionBar">