Move Detailed IOB and SHow BGI preferences to Watch

This commit is contained in:
Philoul 2023-08-19 13:46:31 +02:00
parent d065f1fd86
commit e08159709f
13 changed files with 56 additions and 50 deletions

View file

@ -243,14 +243,12 @@ sealed class EventData : Event() {
val externalStatus: String,
val iobSum: String,
val iobDetail: String,
val detailedIob: Boolean,
val cob: String,
val currentBasal: String,
val battery: String,
val rigBattery: String,
val openApsStatus: Long,
val bgi: String,
val showBgi: Boolean,
val batteryLevel: Int
) : EventData()

View file

@ -913,7 +913,7 @@ class DataHandlerMobile @Inject constructor(
//bgi
val bgi = -(bolusIob.activity + basalIob.activity) * 5 * Profile.fromMgdlToUnits(profile.getIsfMgdl(), profileFunction.getUnits())
bgiString = "" + (if (bgi >= 0) "+" else "") + DecimalFormatter.to1Decimal(bgi)
status = generateStatusString(profile, currentBasal, iobSum, iobDetail, bgiString)
status = generateStatusString(profile)
}
//batteries
@ -930,14 +930,12 @@ class DataHandlerMobile @Inject constructor(
externalStatus = status,
iobSum = iobSum,
iobDetail = iobDetail,
detailedIob = sp.getBoolean(info.nightscout.core.utils.R.string.key_wear_detailediob, false),
cob = cobString,
currentBasal = currentBasal,
battery = phoneBattery.toString(),
rigBattery = rigBattery,
openApsStatus = openApsStatus,
bgi = bgiString,
showBgi = sp.getBoolean(info.nightscout.core.utils.R.string.key_wear_showbgi, false),
batteryLevel = if (phoneBattery >= 30) 1 else 0
)
)
@ -1123,19 +1121,10 @@ class DataHandlerMobile @Inject constructor(
return message
}
private fun generateStatusString(profile: Profile?, currentBasal: String, iobSum: String, iobDetail: String, bgiString: String): String {
private fun generateStatusString(profile: Profile?): String {
var status = ""
profile ?: return rh.gs(info.nightscout.core.ui.R.string.noprofile)
if (!(loop as PluginBase).isEnabled()) status += rh.gs(R.string.disabled_loop) + "\n"
val iobString =
if (sp.getBoolean(info.nightscout.core.utils.R.string.key_wear_detailediob, false)) "$iobSum $iobDetail"
else iobSum + rh.gs(R.string.units_short)
status += "$currentBasal $iobString"
// add BGI if shown, otherwise return
if (sp.getBoolean(info.nightscout.core.utils.R.string.key_wear_showbgi, false)) status += " $bgiString"
return status
}

View file

@ -112,11 +112,7 @@
<string name="sms_wrong_tbr_duration">TBR duration must be a multiple of %1$d minutes and greater than 0.</string>
<string name="a11y_otp_qr_code">QR Code for setup one time password</string>
<string name="xdrip_status_detailed_iob_title">Show detailed IOB</string>
<string name="xdrip_status_detailed_iob_summary">Break down IOB into bolus and basal IOB on the watchface</string>
<string name="disabled_loop">Loop Disabled</string>
<string name="xdrip_status_show_bgi_title">Show BGI</string>
<string name="xdrip_status_show_bgi_summary">Add BGI to status line</string>
<!-- Food-->
<string name="food_short">Food</string>

View file

@ -53,23 +53,12 @@
<PreferenceCategory
android:title="@string/wear_display_settings">
<SwitchPreference
android:defaultValue="false"
android:key="@string/key_wear_detailediob"
android:summary="@string/xdrip_status_detailed_iob_summary"
android:title="@string/xdrip_status_detailed_iob_title" />
<SwitchPreference
android:defaultValue="false"
android:key="@string/key_wear_detailed_delta"
android:summary="@string/wear_detailed_delta_summary"
android:title="@string/wear_detailed_delta_title" />
<SwitchPreference
android:defaultValue="false"
android:key="@string/key_wear_showbgi"
android:summary="@string/xdrip_status_show_bgi_summary"
android:title="@string/xdrip_status_show_bgi_title" />
<SwitchPreference
android:defaultValue="true"
android:key="wear_predictions"

View file

@ -32,14 +32,12 @@ class RawDisplayData {
externalStatus = "no status",
iobSum = "IOB",
iobDetail = "-.--",
detailedIob = false,
cob = "--g",
currentBasal = "-.--U/h",
battery = "--",
rigBattery = "--",
openApsStatus = -1,
bgi = "--",
showBgi = false,
batteryLevel = 1
)

View file

@ -161,7 +161,7 @@ class AapsV2Watchface : BaseWatchFace() {
}
private fun setTextSizes() {
if (status.detailedIob) {
if (detailedIob) {
binding.iob1.textSize = 14f
binding.iob2.textSize = 10f
} else {

View file

@ -25,7 +25,7 @@ class BigChartWatchface : BaseWatchFace() {
@SuppressLint("SetTextI18n")
override fun setDataFields() {
super.setDataFields()
binding.status?.text = status.externalStatus + if (sp.getBoolean(R.string.key_show_cob, true)) (" " + this.status.cob) else ""
binding.status?.text = externalStatus + if (sp.getBoolean(R.string.key_show_cob, true)) (" " + this.status.cob) else ""
}
override fun setColorLowRes() {

View file

@ -154,10 +154,19 @@ class CircleWatchface : WatchFace() {
//Also possible: View.INVISIBLE instead of View.GONE (no layout change)
mSgv?.visibility = View.INVISIBLE
}
val detailedIob = sp.getBoolean(R.string.key_show_detailed_iob, false)
val showBgi = sp.getBoolean(R.string.key_show_bgi, false)
val iobString =
if (detailedIob) "${status.iobSum} ${status.iobDetail}"
else status.iobSum + getString(R.string.units_short)
val externalStatus = if (showBgi)
"${status.externalStatus} ${iobString} ${status.bgi}"
else
"${status.externalStatus} ${iobString}"
var textView = myLayout?.findViewById<TextView>(R.id.statusString)
if (sp.getBoolean(R.string.key_show_external_status, true)) {
textView?.visibility = View.VISIBLE
textView?.text = status.externalStatus
textView?.text = externalStatus
textView?.setTextColor(textColor)
} else {
//Also possible: View.INVISIBLE instead of View.GONE (no layout change)

View file

@ -50,7 +50,7 @@ class CockpitWatchface : BaseWatchFace() {
}
private fun setTextSizes() {
if (status.detailedIob) {
if (detailedIob) {
if (bIsRound) binding.iob2.textSize = 10f
else binding.iob2.textSize = 9f
} else {

View file

@ -86,6 +86,8 @@ abstract class BaseWatchFace : WatchFace() {
var dividerMatchesBg = false
var pointSize = 2
var enableSecond = false
var detailedIob = false
var externalStatus = ""
val showSecond: Boolean
get() = enableSecond && currentWatchMode == WatchMode.INTERACTIVE
@ -294,6 +296,8 @@ abstract class BaseWatchFace : WatchFace() {
@SuppressLint("SetTextI18n")
open fun setDataFields() {
detailedIob = sp.getBoolean(R.string.key_show_detailed_iob, false)
val showBgi = sp.getBoolean(R.string.key_show_bgi, false)
setDateAndTime()
binding.sgv?.text = singleBg.sgvString
binding.sgv?.visibility = sp.getBoolean(R.string.key_show_bg, true).toVisibilityKeepSpace()
@ -309,8 +313,8 @@ abstract class BaseWatchFace : WatchFace() {
binding.cob2?.visibility = sp.getBoolean(R.string.key_show_cob, true).toVisibility()
binding.iob1?.visibility = sp.getBoolean(R.string.key_show_iob, true).toVisibility()
binding.iob2?.visibility = sp.getBoolean(R.string.key_show_iob, true).toVisibility()
binding.iob1?.text = if (status.detailedIob) status.iobSum else getString(R.string.activity_IOB)
binding.iob2?.text = if (status.detailedIob) status.iobDetail else status.iobSum
binding.iob1?.text = if (detailedIob) status.iobSum else getString(R.string.activity_IOB)
binding.iob2?.text = if (detailedIob) status.iobDetail else status.iobSum
binding.timestamp.visibility = sp.getBoolean(R.string.key_show_ago, true).toVisibility()
binding.timestamp.text = readingAge(if (binding.AAPSv2 != null) true else sp.getBoolean(R.string.key_show_external_status, true))
binding.uploaderBattery?.visibility = sp.getBoolean(R.string.key_show_uploader_battery, true).toVisibility()
@ -325,8 +329,15 @@ abstract class BaseWatchFace : WatchFace() {
binding.basalRate?.text = status.currentBasal
binding.basalRate?.visibility = sp.getBoolean(R.string.key_show_temp_basal, true).toVisibility()
binding.bgi?.text = status.bgi
binding.bgi?.visibility = status.showBgi.toVisibility()
binding.status?.text = status.externalStatus
binding.bgi?.visibility = sp.getBoolean(R.string.key_show_bgi, true).toVisibility()
val iobString =
if (detailedIob) "${status.iobSum} ${status.iobDetail}"
else status.iobSum + getString(R.string.units_short)
externalStatus = if (showBgi)
"${status.externalStatus} ${iobString} ${status.bgi}"
else
"${status.externalStatus} ${iobString}"
binding.status?.text = externalStatus
binding.status?.visibility = sp.getBoolean(R.string.key_show_external_status, true).toVisibility()
binding.loop?.visibility = sp.getBoolean(R.string.key_show_external_status, true).toVisibility()
if (status.openApsStatus != -1L) {

View file

@ -23,8 +23,10 @@
<string name="msg_warning_old">AAPS data is %1$s old! Check your sensor, xDrip+, NS, AAPS config or other!</string>
<string name="pref_vibrate_on_bolus">Vibrate on Bolus</string>
<string name="pref_units_for_actions">Units for Actions</string>
<string name="units_short">U</string>
<string name="pref_show_date">Show Date</string>
<string name="pref_show_iob">Show IOB</string>
<string name="pref_show_detailed_iob">Show detailed IOB</string>
<string name="pref_show_cob">Show COB</string>
<string name="pref_show_delta">Show Delta</string>
<string name="pref_show_avgdelta">Show AvgDelta</string>
@ -33,6 +35,7 @@
<string name="pref_show_basal_rate">Show Basal Rate</string>
<string name="pref_show_loop_status">Show Loop Status</string>
<string name="pref_show_bg">Show BG</string>
<string name="pref_show_bgi">Show BGI</string>
<string name="pref_show_direction_arrow">Show Direction Arrow</string>
<string name="pref_show_ago">Show Ago</string>
<string name="pref_dark" comment="Enables dark visual theme">Dark</string>
@ -187,6 +190,7 @@
<string name="key_show_date" translatable="false">show_date</string>
<string name="key_show_cob" translatable="false">show_cob</string>
<string name="key_show_bg" translatable="false">showBG</string>
<string name="key_show_bgi" translatable="false">showBGI</string>
<string name="key_show_external_status" translatable="false">showExternalStatus</string>
<string name="key_show_ago" translatable="false">showAgo</string>
<string name="key_show_big_numbers" translatable="false">showBigNumbers</string>
@ -199,6 +203,7 @@
<string name="key_digital_style_frame_color_opacity" translatable="false">digital_style_frame_color_opacity</string>
<string name="key_show_direction" translatable="false">show_direction</string>
<string name="key_show_iob" translatable="false">show_iob</string>
<string name="key_show_detailed_iob" translatable="false">show_detailed_iob</string>
<string name="key_show_uploader_battery" translatable="false">show_uploader_battery</string>
<string name="key_show_rig_battery" translatable="false">show_rig_battery</string>
<string name="key_show_temp_basal" translatable="false">show_temp_basal</string>

View file

@ -2,6 +2,14 @@
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<CheckBoxPreference
android:defaultValue="true"
android:key="@string/key_show_bg"
android:summary="Show BG."
android:title="@string/pref_show_bg"
app:wear_iconOff="@drawable/settings_off"
app:wear_iconOn="@drawable/settings_on" />
<CheckBoxPreference
android:defaultValue="true"
android:key="@string/key_show_iob"
@ -10,6 +18,14 @@
app:wear_iconOff="@drawable/settings_off"
app:wear_iconOn="@drawable/settings_on" />
<CheckBoxPreference
android:defaultValue="false"
android:key="@string/key_show_detailed_iob"
android:summary="Break down IOB into bolus and basal IOB on the watchface"
android:title="@string/pref_show_detailed_iob"
app:wear_iconOff="@drawable/settings_off"
app:wear_iconOn="@drawable/settings_on" />
<CheckBoxPreference
android:defaultValue="true"
android:key="@string/key_show_cob"
@ -19,10 +35,10 @@
app:wear_iconOn="@drawable/settings_on" />
<CheckBoxPreference
android:defaultValue="true"
android:key="@string/key_show_bg"
android:summary="Show BG."
android:title="@string/pref_show_bg"
android:defaultValue="false"
android:key="@string/key_show_bgi"
android:summary="Show BGI"
android:title="@string/pref_show_bgi"
app:wear_iconOff="@drawable/settings_off"
app:wear_iconOn="@drawable/settings_on" />
@ -41,6 +57,7 @@
android:title="@string/pref_show_avgdelta"
app:wear_iconOff="@drawable/settings_off"
app:wear_iconOn="@drawable/settings_on" />
<CheckBoxPreference
android:defaultValue="true"
android:key="@string/key_show_direction"

View file

@ -64,14 +64,12 @@ class RawDataMocker(wearUtil: WearUtil) {
"",
iob,
"",
true,
cob,
br,
"",
"",
0L,
"",
true,
0
)
return raw
@ -83,14 +81,12 @@ class RawDataMocker(wearUtil: WearUtil) {
"",
iob,
iob2,
true,
"",
"",
"",
"",
0L,
"",
true,
0
)
return raw
@ -102,14 +98,12 @@ class RawDataMocker(wearUtil: WearUtil) {
"",
"",
"",
true,
cob!!,
"",
"",
"",
0L,
"",
true,
0
)
return raw