Merge pull request #2682 from Philoul/wear/movePrefToWatch

Move 3 Wear Display settings from AAPS to Watch
This commit is contained in:
Milos Kozak 2023-08-19 16:17:11 +02:00 committed by GitHub
commit ca25a337b5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 111 additions and 90 deletions

View file

@ -17,7 +17,7 @@ import java.util.zip.ZipEntry
import java.util.zip.ZipInputStream import java.util.zip.ZipInputStream
import java.util.zip.ZipOutputStream import java.util.zip.ZipOutputStream
val CUSTOM_VERSION = "0.8" val CUSTOM_VERSION = "0.9"
enum class CustomWatchfaceDrawableDataKey(val key: String, @DrawableRes val icon: Int?, val fileName: String) { enum class CustomWatchfaceDrawableDataKey(val key: String, @DrawableRes val icon: Int?, val fileName: String) {
UNKNOWN("unknown", null, "Unknown"), UNKNOWN("unknown", null, "Unknown"),
CUSTOM_WATCHFACE("customWatchface", R.drawable.watchface_custom, "CustomWatchface"), CUSTOM_WATCHFACE("customWatchface", R.drawable.watchface_custom, "CustomWatchface"),
@ -98,9 +98,9 @@ enum class CustomWatchfaceMetadataKey(val key: String, @StringRes val label: Int
CWF_AUTHOR_VERSION("author_version", R.string.metadata_label_watchface_name_version), CWF_AUTHOR_VERSION("author_version", R.string.metadata_label_watchface_name_version),
CWF_COMMENT("comment", R.string.metadata_label_watchface_comment), // label not planed to be used for CWF_COMMENT CWF_COMMENT("comment", R.string.metadata_label_watchface_comment), // label not planed to be used for CWF_COMMENT
CWF_AUTHORIZATION("cwf_authorization", R.string.metadata_label_watchface_authorization), CWF_AUTHORIZATION("cwf_authorization", R.string.metadata_label_watchface_authorization),
CWF_PREF_AAPS_DETAILED_IOB("key_wear_detailediob", R.string.metadata_label_watchface_pref), CWF_PREF_WATCH_SHOW_DETAILED_IOB("key_show_detailed_iob", R.string.metadata_label_watchface_pref),
CWF_PREF_AAPS_DETAILED_DELTA("key_wear_detailed_delta", R.string.metadata_label_watchface_pref), CWF_PREF_WATCH_SHOW_DETAILED_DELTA("key_show_detailed_delta", R.string.metadata_label_watchface_pref),
CWF_PREF_AAPS_BGI("key_wear_showbgi", R.string.metadata_label_watchface_pref), CWF_PREF_WATCH_SHOW_BGI("key_show_bgi", R.string.metadata_label_watchface_pref),
CWF_PREF_WATCH_SHOW_IOB("key_show_iob", R.string.metadata_label_watchface_pref), CWF_PREF_WATCH_SHOW_IOB("key_show_iob", R.string.metadata_label_watchface_pref),
CWF_PREF_WATCH_SHOW_COB("key_show_cob", R.string.metadata_label_watchface_pref), CWF_PREF_WATCH_SHOW_COB("key_show_cob", R.string.metadata_label_watchface_pref),
CWF_PREF_WATCH_SHOW_DELTA("key_show_delta", R.string.metadata_label_watchface_pref), CWF_PREF_WATCH_SHOW_DELTA("key_show_delta", R.string.metadata_label_watchface_pref),

View file

@ -173,7 +173,9 @@ sealed class EventData : Event() {
val glucoseUnits: String = "-", val glucoseUnits: String = "-",
val slopeArrow: String = "--", val slopeArrow: String = "--",
val delta: String = "--", val delta: String = "--",
val deltaDetailed: String = "--",
val avgDelta: String = "--", val avgDelta: String = "--",
val avgDeltaDetailed: String = "--",
val sgvLevel: Long = 0, val sgvLevel: Long = 0,
val sgv: Double, val sgv: Double,
val high: Double, // highLine val high: Double, // highLine
@ -243,14 +245,12 @@ sealed class EventData : Event() {
val externalStatus: String, val externalStatus: String,
val iobSum: String, val iobSum: String,
val iobDetail: String, val iobDetail: String,
val detailedIob: Boolean,
val cob: String, val cob: String,
val currentBasal: String, val currentBasal: String,
val battery: String, val battery: String,
val rigBattery: String, val rigBattery: String,
val openApsStatus: Long, val openApsStatus: Long,
val bgi: String, val bgi: String,
val showBgi: Boolean,
val batteryLevel: Int val batteryLevel: Int
) : EventData() ) : EventData()

View file

@ -119,11 +119,4 @@ class WearFragment : DaggerFragment() {
private fun loadCustom(cwf: CustomWatchfaceData) { private fun loadCustom(cwf: CustomWatchfaceData) {
wearPlugin.savedCustomWatchface = cwf wearPlugin.savedCustomWatchface = cwf
} }
// This class containt mapping between keys used within json of Custom Watchface and preferences
enum class PrefMap(val key: String, @StringRes val prefKey: Int) {
DETAILED_IOB(CustomWatchfaceMetadataKey.CWF_PREF_AAPS_DETAILED_IOB.key, info.nightscout.core.utils.R.string.key_wear_detailediob),
CWF_PREF_AAPS_DETAILED_DELTA(CustomWatchfaceMetadataKey.CWF_PREF_AAPS_DETAILED_DELTA.key, info.nightscout.core.utils.R.string.key_wear_detailed_delta),
CWF_PREF_AAPS_BGI(CustomWatchfaceMetadataKey.CWF_PREF_AAPS_BGI.key, info.nightscout.core.utils.R.string.key_wear_showbgi)
}
} }

View file

@ -119,11 +119,6 @@ class WearPlugin @Inject constructor(
newCwf.metadata[CustomWatchfaceMetadataKey.CWF_AUTHORIZATION] = sp.getBoolean(info.nightscout.core.utils.R.string.key_wear_custom_watchface_autorization, false).toString() newCwf.metadata[CustomWatchfaceMetadataKey.CWF_AUTHORIZATION] = sp.getBoolean(info.nightscout.core.utils.R.string.key_wear_custom_watchface_autorization, false).toString()
rxBus.send(EventMobileDataToWear(EventData.ActionSetCustomWatchface(newCwf))) rxBus.send(EventMobileDataToWear(EventData.ActionSetCustomWatchface(newCwf)))
} }
if (cwf_authorization) {
WearFragment.PrefMap.values().forEach { pref ->
cwf.metadata[CustomWatchfaceMetadataKey.fromKey(pref.key)]?.toBooleanStrictOrNull()?.let { sp.putBoolean(pref.prefKey, it) }
}
}
} }
} }

View file

@ -913,7 +913,7 @@ class DataHandlerMobile @Inject constructor(
//bgi //bgi
val bgi = -(bolusIob.activity + basalIob.activity) * 5 * Profile.fromMgdlToUnits(profile.getIsfMgdl(), profileFunction.getUnits()) val bgi = -(bolusIob.activity + basalIob.activity) * 5 * Profile.fromMgdlToUnits(profile.getIsfMgdl(), profileFunction.getUnits())
bgiString = "" + (if (bgi >= 0) "+" else "") + DecimalFormatter.to1Decimal(bgi) bgiString = "" + (if (bgi >= 0) "+" else "") + DecimalFormatter.to1Decimal(bgi)
status = generateStatusString(profile, currentBasal, iobSum, iobDetail, bgiString) status = generateStatusString(profile)
} }
//batteries //batteries
@ -930,14 +930,12 @@ class DataHandlerMobile @Inject constructor(
externalStatus = status, externalStatus = status,
iobSum = iobSum, iobSum = iobSum,
iobDetail = iobDetail, iobDetail = iobDetail,
detailedIob = sp.getBoolean(info.nightscout.core.utils.R.string.key_wear_detailediob, false),
cob = cobString, cob = cobString,
currentBasal = currentBasal, currentBasal = currentBasal,
battery = phoneBattery.toString(), battery = phoneBattery.toString(),
rigBattery = rigBattery, rigBattery = rigBattery,
openApsStatus = openApsStatus, openApsStatus = openApsStatus,
bgi = bgiString, bgi = bgiString,
showBgi = sp.getBoolean(info.nightscout.core.utils.R.string.key_wear_showbgi, false),
batteryLevel = if (phoneBattery >= 30) 1 else 0 batteryLevel = if (phoneBattery >= 30) 1 else 0
) )
) )
@ -945,15 +943,23 @@ class DataHandlerMobile @Inject constructor(
} }
private fun deltaString(deltaMGDL: Double, deltaMMOL: Double, units: GlucoseUnit): String { private fun deltaString(deltaMGDL: Double, deltaMMOL: Double, units: GlucoseUnit): String {
val detailed = sp.getBoolean(info.nightscout.core.utils.R.string.key_wear_detailed_delta, false)
var deltaString = if (deltaMGDL >= 0) "+" else "-" var deltaString = if (deltaMGDL >= 0) "+" else "-"
deltaString += if (units == GlucoseUnit.MGDL) { deltaString += if (units == GlucoseUnit.MGDL) {
if (detailed) DecimalFormatter.to1Decimal(abs(deltaMGDL)) else DecimalFormatter.to0Decimal(abs(deltaMGDL)) DecimalFormatter.to0Decimal(abs(deltaMGDL))
} else { } else {
if (detailed) DecimalFormatter.to2Decimal(abs(deltaMMOL)) else DecimalFormatter.to1Decimal(abs(deltaMMOL)) DecimalFormatter.to1Decimal(abs(deltaMMOL))
} }
return deltaString return deltaString
} }
private fun deltaStringDetailed(deltaMGDL: Double, deltaMMOL: Double, units: GlucoseUnit): String {
var deltaStringDetailed = if (deltaMGDL >= 0) "+" else "-"
deltaStringDetailed += if (units == GlucoseUnit.MGDL) {
DecimalFormatter.to1Decimal(abs(deltaMGDL))
} else {
DecimalFormatter.to2Decimal(abs(deltaMMOL))
}
return deltaStringDetailed
}
private fun getSingleBG(glucoseValue: InMemoryGlucoseValue): EventData.SingleBg { private fun getSingleBG(glucoseValue: InMemoryGlucoseValue): EventData.SingleBg {
val glucoseStatus = glucoseStatusProvider.getGlucoseStatusData(true) val glucoseStatus = glucoseStatusProvider.getGlucoseStatusData(true)
@ -967,7 +973,9 @@ class DataHandlerMobile @Inject constructor(
glucoseUnits = units.asText, glucoseUnits = units.asText,
slopeArrow = trendCalculator.getTrendArrow(glucoseValue).symbol, slopeArrow = trendCalculator.getTrendArrow(glucoseValue).symbol,
delta = glucoseStatus?.let { deltaString(it.delta, it.delta * Constants.MGDL_TO_MMOLL, units) } ?: "--", delta = glucoseStatus?.let { deltaString(it.delta, it.delta * Constants.MGDL_TO_MMOLL, units) } ?: "--",
deltaDetailed = glucoseStatus?.let { deltaStringDetailed(it.delta, it.delta * Constants.MGDL_TO_MMOLL, units) } ?: "--",
avgDelta = glucoseStatus?.let { deltaString(it.shortAvgDelta, it.shortAvgDelta * Constants.MGDL_TO_MMOLL, units) } ?: "--", avgDelta = glucoseStatus?.let { deltaString(it.shortAvgDelta, it.shortAvgDelta * Constants.MGDL_TO_MMOLL, units) } ?: "--",
avgDeltaDetailed = glucoseStatus?.let { deltaStringDetailed(it.shortAvgDelta, it.shortAvgDelta * Constants.MGDL_TO_MMOLL, units) } ?: "--",
sgvLevel = if (glucoseValue.recalculated > highLine) 1L else if (glucoseValue.recalculated < lowLine) -1L else 0L, sgvLevel = if (glucoseValue.recalculated > highLine) 1L else if (glucoseValue.recalculated < lowLine) -1L else 0L,
sgv = glucoseValue.recalculated, sgv = glucoseValue.recalculated,
high = highLine, high = highLine,
@ -1123,19 +1131,10 @@ class DataHandlerMobile @Inject constructor(
return message return message
} }
private fun generateStatusString(profile: Profile?, currentBasal: String, iobSum: String, iobDetail: String, bgiString: String): String { private fun generateStatusString(profile: Profile?): String {
var status = "" var status = ""
profile ?: return rh.gs(info.nightscout.core.ui.R.string.noprofile) profile ?: return rh.gs(info.nightscout.core.ui.R.string.noprofile)
if (!(loop as PluginBase).isEnabled()) status += rh.gs(R.string.disabled_loop) + "\n" 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 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="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="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="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--> <!-- Food-->
<string name="food_short">Food</string> <string name="food_short">Food</string>
@ -355,8 +351,6 @@
<string name="wear_wizard_settings_summary">Calculations included in the Wizard result:</string> <string name="wear_wizard_settings_summary">Calculations included in the Wizard result:</string>
<string name="wear_display_settings">Display Settings</string> <string name="wear_display_settings">Display Settings</string>
<string name="wear_general_settings">General Settings</string> <string name="wear_general_settings">General Settings</string>
<string name="wear_detailed_delta_title">Show detailed delta</string>
<string name="wear_detailed_delta_summary">Show delta with one more decimal place</string>
<string name="wear_notifysmb_title">Notify on SMB</string> <string name="wear_notifysmb_title">Notify on SMB</string>
<string name="wear_notifysmb_summary">Show SMB on the watch like a standard bolus.</string> <string name="wear_notifysmb_summary">Show SMB on the watch like a standard bolus.</string>
<string name="wear_predictions_summary">Show the predictions on the watchface.</string> <string name="wear_predictions_summary">Show the predictions on the watchface.</string>

View file

@ -53,23 +53,6 @@
<PreferenceCategory <PreferenceCategory
android:title="@string/wear_display_settings"> 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 <SwitchPreference
android:defaultValue="true" android:defaultValue="true"
android:key="wear_predictions" android:key="wear_predictions"

View file

@ -20,7 +20,9 @@ class RawDisplayData {
glucoseUnits = "-", glucoseUnits = "-",
slopeArrow = "--", slopeArrow = "--",
delta = "--", delta = "--",
deltaDetailed = "--",
avgDelta = "--", avgDelta = "--",
avgDeltaDetailed = "--",
sgvLevel = 0, sgvLevel = 0,
sgv = 0.0, sgv = 0.0,
high = 0.0, high = 0.0,
@ -32,14 +34,12 @@ class RawDisplayData {
externalStatus = "no status", externalStatus = "no status",
iobSum = "IOB", iobSum = "IOB",
iobDetail = "-.--", iobDetail = "-.--",
detailedIob = false,
cob = "--g", cob = "--g",
currentBasal = "-.--U/h", currentBasal = "-.--U/h",
battery = "--", battery = "--",
rigBattery = "--", rigBattery = "--",
openApsStatus = -1, openApsStatus = -1,
bgi = "--", bgi = "--",
showBgi = false,
batteryLevel = 1 batteryLevel = 1
) )

View file

@ -61,24 +61,26 @@ class DisplayFormat @Inject internal constructor() {
fun shortTrend(raw: RawDisplayData): String { fun shortTrend(raw: RawDisplayData): String {
var minutes = "--" var minutes = "--"
val rawDelta = if (sp.getBoolean(R.string.key_show_detailed_delta, false)) raw.singleBg.deltaDetailed else raw.singleBg.delta
if (raw.singleBg.timeStamp > 0) { if (raw.singleBg.timeStamp > 0) {
minutes = shortTimeSince(raw.singleBg.timeStamp) minutes = shortTimeSince(raw.singleBg.timeStamp)
} }
if (minutes.length + raw.singleBg.delta.length + deltaSymbol().length + 1 <= MAX_FIELD_LEN_SHORT) { if (minutes.length + rawDelta.length + deltaSymbol().length + 1 <= MAX_FIELD_LEN_SHORT) {
return minutes + " " + deltaSymbol() + raw.singleBg.delta return minutes + " " + deltaSymbol() + rawDelta
} }
// that only optimizes obvious things like 0 before . or at end, + at beginning // that only optimizes obvious things like 0 before . or at end, + at beginning
val delta = SmallestDoubleString(raw.singleBg.delta).minimise(MAX_FIELD_LEN_SHORT - 1) val delta = SmallestDoubleString(rawDelta).minimise(MAX_FIELD_LEN_SHORT - 1)
if (minutes.length + delta.length + deltaSymbol().length + 1 <= MAX_FIELD_LEN_SHORT) { if (minutes.length + delta.length + deltaSymbol().length + 1 <= MAX_FIELD_LEN_SHORT) {
return minutes + " " + deltaSymbol() + delta return minutes + " " + deltaSymbol() + delta
} }
val shortDelta = SmallestDoubleString(raw.singleBg.delta).minimise(MAX_FIELD_LEN_SHORT - (1 + minutes.length)) val shortDelta = SmallestDoubleString(rawDelta).minimise(MAX_FIELD_LEN_SHORT - (1 + minutes.length))
return "$minutes $shortDelta" return "$minutes $shortDelta"
} }
fun longGlucoseLine(raw: RawDisplayData): String { fun longGlucoseLine(raw: RawDisplayData): String {
return raw.singleBg.sgvString + raw.singleBg.slopeArrow + " " + deltaSymbol() + SmallestDoubleString(raw.singleBg.delta).minimise(8) + " (" + shortTimeSince(raw.singleBg.timeStamp) + ")" val rawDelta = if (sp.getBoolean(R.string.key_show_detailed_delta, false)) raw.singleBg.deltaDetailed else raw.singleBg.delta
return raw.singleBg.sgvString + raw.singleBg.slopeArrow + " " + deltaSymbol() + SmallestDoubleString(rawDelta).minimise(8) + " (" + shortTimeSince(raw.singleBg.timeStamp) + ")"
} }
fun longDetailsLine(raw: RawDisplayData): String { fun longDetailsLine(raw: RawDisplayData): String {

View file

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

View file

@ -25,7 +25,7 @@ class BigChartWatchface : BaseWatchFace() {
@SuppressLint("SetTextI18n") @SuppressLint("SetTextI18n")
override fun setDataFields() { override fun setDataFields() {
super.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() { override fun setColorLowRes() {

View file

@ -154,10 +154,19 @@ class CircleWatchface : WatchFace() {
//Also possible: View.INVISIBLE instead of View.GONE (no layout change) //Also possible: View.INVISIBLE instead of View.GONE (no layout change)
mSgv?.visibility = View.INVISIBLE 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) var textView = myLayout?.findViewById<TextView>(R.id.statusString)
if (sp.getBoolean(R.string.key_show_external_status, true)) { if (sp.getBoolean(R.string.key_show_external_status, true)) {
textView?.visibility = View.VISIBLE textView?.visibility = View.VISIBLE
textView?.text = status.externalStatus textView?.text = externalStatus
textView?.setTextColor(textColor) textView?.setTextColor(textColor)
} else { } else {
//Also possible: View.INVISIBLE instead of View.GONE (no layout change) //Also possible: View.INVISIBLE instead of View.GONE (no layout change)
@ -178,9 +187,10 @@ class CircleWatchface : WatchFace() {
textView?.visibility = View.INVISIBLE textView?.visibility = View.INVISIBLE
} }
textView = myLayout?.findViewById(R.id.deltaString) textView = myLayout?.findViewById(R.id.deltaString)
val detailedDelta = sp.getBoolean(R.string.key_show_detailed_delta, false)
if (sp.getBoolean(R.string.key_show_delta, true)) { if (sp.getBoolean(R.string.key_show_delta, true)) {
textView?.visibility = View.VISIBLE textView?.visibility = View.VISIBLE
textView?.text = singleBg.delta textView?.text = if (detailedDelta) singleBg.deltaDetailed else singleBg.delta
textView?.setTextColor(textColor) textView?.setTextColor(textColor)
if (sp.getBoolean(R.string.key_show_big_numbers, false)) { if (sp.getBoolean(R.string.key_show_big_numbers, false)) {
textView?.setTextSize(TypedValue.COMPLEX_UNIT_SP, 25f) textView?.setTextSize(TypedValue.COMPLEX_UNIT_SP, 25f)
@ -188,7 +198,7 @@ class CircleWatchface : WatchFace() {
textView?.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18f) textView?.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18f)
} }
if (sp.getBoolean(R.string.key_show_avg_delta, true)) { if (sp.getBoolean(R.string.key_show_avg_delta, true)) {
textView?.append(" " + singleBg.avgDelta) textView?.append(" " + if (detailedDelta) singleBg.avgDeltaDetailed else singleBg.avgDelta)
} }
} else { } else {
//Also possible: View.INVISIBLE instead of View.GONE (no layout change) //Also possible: View.INVISIBLE instead of View.GONE (no layout change)

View file

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

View file

@ -492,15 +492,18 @@ class CustomWatchface : BaseWatchFace() {
// This class containt mapping between keys used within json of Custom Watchface and preferences // This class containt mapping between keys used within json of Custom Watchface and preferences
private enum class PrefMap(val key: String, @StringRes val prefKey: Int) { private enum class PrefMap(val key: String, @StringRes val prefKey: Int) {
SHOW_IOB(CustomWatchfaceMetadataKey.CWF_PREF_WATCH_SHOW_IOB.key, R.string.key_show_iob), SHOW_IOB(CustomWatchfaceMetadataKey.CWF_PREF_WATCH_SHOW_IOB.key, R.string.key_show_iob),
SHOW_DETAILED_IOB(CustomWatchfaceMetadataKey.CWF_PREF_WATCH_SHOW_DETAILED_IOB.key, R.string.key_show_detailed_iob),
SHOW_COB(CustomWatchfaceMetadataKey.CWF_PREF_WATCH_SHOW_COB.key, R.string.key_show_cob), SHOW_COB(CustomWatchfaceMetadataKey.CWF_PREF_WATCH_SHOW_COB.key, R.string.key_show_cob),
SHOW_DELTA(CustomWatchfaceMetadataKey.CWF_PREF_WATCH_SHOW_DELTA.key, R.string.key_show_delta), SHOW_DELTA(CustomWatchfaceMetadataKey.CWF_PREF_WATCH_SHOW_DELTA.key, R.string.key_show_delta),
SHOW_AVG_DELTA(CustomWatchfaceMetadataKey.CWF_PREF_WATCH_SHOW_AVG_DELTA.key, R.string.key_show_avg_delta), SHOW_AVG_DELTA(CustomWatchfaceMetadataKey.CWF_PREF_WATCH_SHOW_AVG_DELTA.key, R.string.key_show_avg_delta),
SHOW_DETAILED_DELTA(CustomWatchfaceMetadataKey.CWF_PREF_WATCH_SHOW_DETAILED_DELTA.key, R.string.key_show_detailed_delta),
SHOW_UPLOADER_BATTERY(CustomWatchfaceMetadataKey.CWF_PREF_WATCH_SHOW_UPLOADER_BATTERY.key, R.string.key_show_uploader_battery), SHOW_UPLOADER_BATTERY(CustomWatchfaceMetadataKey.CWF_PREF_WATCH_SHOW_UPLOADER_BATTERY.key, R.string.key_show_uploader_battery),
SHOW_RIG_BATTERY(CustomWatchfaceMetadataKey.CWF_PREF_WATCH_SHOW_RIG_BATTERY.key, R.string.key_show_rig_battery), SHOW_RIG_BATTERY(CustomWatchfaceMetadataKey.CWF_PREF_WATCH_SHOW_RIG_BATTERY.key, R.string.key_show_rig_battery),
SHOW_TEMP_BASAL(CustomWatchfaceMetadataKey.CWF_PREF_WATCH_SHOW_TEMP_BASAL.key, R.string.key_show_temp_basal), SHOW_TEMP_BASAL(CustomWatchfaceMetadataKey.CWF_PREF_WATCH_SHOW_TEMP_BASAL.key, R.string.key_show_temp_basal),
SHOW_DIRECTION(CustomWatchfaceMetadataKey.CWF_PREF_WATCH_SHOW_DIRECTION.key, R.string.key_show_direction), SHOW_DIRECTION(CustomWatchfaceMetadataKey.CWF_PREF_WATCH_SHOW_DIRECTION.key, R.string.key_show_direction),
SHOW_AGO(CustomWatchfaceMetadataKey.CWF_PREF_WATCH_SHOW_AGO.key, R.string.key_show_ago), SHOW_AGO(CustomWatchfaceMetadataKey.CWF_PREF_WATCH_SHOW_AGO.key, R.string.key_show_ago),
SHOW_BG(CustomWatchfaceMetadataKey.CWF_PREF_WATCH_SHOW_BG.key, R.string.key_show_bg) SHOW_BG(CustomWatchfaceMetadataKey.CWF_PREF_WATCH_SHOW_BG.key, R.string.key_show_bg),
SHOW_BGI(CustomWatchfaceMetadataKey.CWF_PREF_WATCH_SHOW_BGI.key, R.string.key_show_bgi)
} }
} }

View file

@ -86,6 +86,8 @@ abstract class BaseWatchFace : WatchFace() {
var dividerMatchesBg = false var dividerMatchesBg = false
var pointSize = 2 var pointSize = 2
var enableSecond = false var enableSecond = false
var detailedIob = false
var externalStatus = ""
val showSecond: Boolean val showSecond: Boolean
get() = enableSecond && currentWatchMode == WatchMode.INTERACTIVE get() = enableSecond && currentWatchMode == WatchMode.INTERACTIVE
@ -294,23 +296,26 @@ abstract class BaseWatchFace : WatchFace() {
@SuppressLint("SetTextI18n") @SuppressLint("SetTextI18n")
open fun setDataFields() { open fun setDataFields() {
detailedIob = sp.getBoolean(R.string.key_show_detailed_iob, false)
val showBgi = sp.getBoolean(R.string.key_show_bgi, false)
val detailedDelta = sp.getBoolean(R.string.key_show_detailed_delta, false)
setDateAndTime() setDateAndTime()
binding.sgv?.text = singleBg.sgvString binding.sgv?.text = singleBg.sgvString
binding.sgv?.visibility = sp.getBoolean(R.string.key_show_bg, true).toVisibilityKeepSpace() binding.sgv?.visibility = sp.getBoolean(R.string.key_show_bg, true).toVisibilityKeepSpace()
strikeThroughSgvIfNeeded() strikeThroughSgvIfNeeded()
binding.direction?.text = "${singleBg.slopeArrow}\uFE0E" binding.direction?.text = "${singleBg.slopeArrow}\uFE0E"
binding.direction?.visibility = sp.getBoolean(R.string.key_show_direction, true).toVisibility() binding.direction?.visibility = sp.getBoolean(R.string.key_show_direction, true).toVisibility()
binding.delta?.text = singleBg.delta binding.delta?.text = if (detailedDelta) singleBg.deltaDetailed else singleBg.delta
binding.delta?.visibility = sp.getBoolean(R.string.key_show_delta, true).toVisibility() binding.delta?.visibility = sp.getBoolean(R.string.key_show_delta, true).toVisibility()
binding.avgDelta?.text = singleBg.avgDelta binding.avgDelta?.text = if (detailedDelta) singleBg.avgDeltaDetailed else singleBg.avgDelta
binding.avgDelta?.visibility = sp.getBoolean(R.string.key_show_avg_delta, true).toVisibility() binding.avgDelta?.visibility = sp.getBoolean(R.string.key_show_avg_delta, true).toVisibility()
binding.cob1?.visibility = sp.getBoolean(R.string.key_show_cob, true).toVisibility() binding.cob1?.visibility = sp.getBoolean(R.string.key_show_cob, true).toVisibility()
binding.cob2?.text = status.cob binding.cob2?.text = status.cob
binding.cob2?.visibility = sp.getBoolean(R.string.key_show_cob, true).toVisibility() 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.iob1?.visibility = sp.getBoolean(R.string.key_show_iob, true).toVisibility()
binding.iob2?.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.iob1?.text = if (detailedIob) status.iobSum else getString(R.string.activity_IOB)
binding.iob2?.text = if (status.detailedIob) status.iobDetail else status.iobSum binding.iob2?.text = if (detailedIob) status.iobDetail else status.iobSum
binding.timestamp.visibility = sp.getBoolean(R.string.key_show_ago, true).toVisibility() 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.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() binding.uploaderBattery?.visibility = sp.getBoolean(R.string.key_show_uploader_battery, true).toVisibility()
@ -325,8 +330,15 @@ abstract class BaseWatchFace : WatchFace() {
binding.basalRate?.text = status.currentBasal binding.basalRate?.text = status.currentBasal
binding.basalRate?.visibility = sp.getBoolean(R.string.key_show_temp_basal, true).toVisibility() binding.basalRate?.visibility = sp.getBoolean(R.string.key_show_temp_basal, true).toVisibility()
binding.bgi?.text = status.bgi binding.bgi?.text = status.bgi
binding.bgi?.visibility = status.showBgi.toVisibility() binding.bgi?.visibility = sp.getBoolean(R.string.key_show_bgi, true).toVisibility()
binding.status?.text = status.externalStatus 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.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() binding.loop?.visibility = sp.getBoolean(R.string.key_show_external_status, true).toVisibility()
if (status.openApsStatus != -1L) { if (status.openApsStatus != -1L) {

View file

@ -86,7 +86,7 @@ class BgGraphBuilder(
lines.add(highValuesLine()) lines.add(highValuesLine())
var minChart = lowMark var minChart = lowMark
var maxChart = highMark var maxChart = highMark
for ((_, _, _, _, _, _, _, sgv) in bgDataList) { for ((_, _, _, _, _, _, _, _, _, sgv) in bgDataList) {
if (sgv > maxChart) maxChart = sgv if (sgv > maxChart) maxChart = sgv
if (sgv < minChart) minChart = sgv if (sgv < minChart) minChart = sgv
} }
@ -197,7 +197,7 @@ class BgGraphBuilder(
private fun addPredictionLines(lines: MutableList<Line>) { private fun addPredictionLines(lines: MutableList<Line>) {
val values: MutableMap<Int, MutableList<PointValue>> = HashMap() val values: MutableMap<Int, MutableList<PointValue>> = HashMap()
val endTime = getPredictionEndTime() val endTime = getPredictionEndTime()
for ((timeStamp, _, _, _, _, _, _, sgv, _, _, color) in predictionsList) { for ((timeStamp, _, _, _, _, _, _, _, _, sgv, _, _, color) in predictionsList) {
if (timeStamp <= endTime) { if (timeStamp <= endTime) {
val value = min(sgv, UPPER_CUTOFF_SGV) val value = min(sgv, UPPER_CUTOFF_SGV)
if (!values.containsKey(color)) { if (!values.containsKey(color)) {
@ -262,7 +262,7 @@ class BgGraphBuilder(
} }
private fun addBgReadingValues() { private fun addBgReadingValues() {
for ((timeStamp, _, _, _, _, _, _, sgv) in bgDataList) { for ((timeStamp, _, _, _,_, _, _, _, _, sgv) in bgDataList) {
if (timeStamp > startingTime) { if (timeStamp > startingTime) {
when { when {
sgv >= 450 -> highValues.add(PointValue(fuzz(timeStamp), 450.toFloat())) sgv >= 450 -> highValues.add(PointValue(fuzz(timeStamp), 450.toFloat()))

View file

@ -23,16 +23,20 @@
<string name="msg_warning_old">AAPS data is %1$s old! Check your sensor, xDrip+, NS, AAPS config or other!</string> <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_vibrate_on_bolus">Vibrate on Bolus</string>
<string name="pref_units_for_actions">Units for Actions</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_date">Show Date</string>
<string name="pref_show_iob">Show IOB</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_cob">Show COB</string>
<string name="pref_show_delta">Show Delta</string> <string name="pref_show_delta">Show Delta</string>
<string name="pref_show_detailed_delta">Show detailed Delta</string>
<string name="pref_show_avgdelta">Show AvgDelta</string> <string name="pref_show_avgdelta">Show AvgDelta</string>
<string name="pref_show_phone_battery">Show Phone Battery</string> <string name="pref_show_phone_battery">Show Phone Battery</string>
<string name="pref_show_rig_battery">Show Rig Battery</string> <string name="pref_show_rig_battery">Show Rig Battery</string>
<string name="pref_show_basal_rate">Show Basal Rate</string> <string name="pref_show_basal_rate">Show Basal Rate</string>
<string name="pref_show_loop_status">Show Loop Status</string> <string name="pref_show_loop_status">Show Loop Status</string>
<string name="pref_show_bg">Show BG</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_direction_arrow">Show Direction Arrow</string>
<string name="pref_show_ago">Show Ago</string> <string name="pref_show_ago">Show Ago</string>
<string name="pref_dark" comment="Enables dark visual theme">Dark</string> <string name="pref_dark" comment="Enables dark visual theme">Dark</string>
@ -187,10 +191,12 @@
<string name="key_show_date" translatable="false">show_date</string> <string name="key_show_date" translatable="false">show_date</string>
<string name="key_show_cob" translatable="false">show_cob</string> <string name="key_show_cob" translatable="false">show_cob</string>
<string name="key_show_bg" translatable="false">showBG</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_external_status" translatable="false">showExternalStatus</string>
<string name="key_show_ago" translatable="false">showAgo</string> <string name="key_show_ago" translatable="false">showAgo</string>
<string name="key_show_big_numbers" translatable="false">showBigNumbers</string> <string name="key_show_big_numbers" translatable="false">showBigNumbers</string>
<string name="key_show_delta" translatable="false">showDelta</string> <string name="key_show_delta" translatable="false">showDelta</string>
<string name="key_show_detailed_delta" translatable="false">showDetailedDelta</string>
<string name="key_show_avg_delta" translatable="false">showAvgDelta</string> <string name="key_show_avg_delta" translatable="false">showAvgDelta</string>
<string name="key_show_ring_history" translatable="false">showRingHistory</string> <string name="key_show_ring_history" translatable="false">showRingHistory</string>
<string name="key_digital_style_frame_style" translatable="false">digital_style_frame_style</string> <string name="key_digital_style_frame_style" translatable="false">digital_style_frame_style</string>
@ -199,6 +205,7 @@
<string name="key_digital_style_frame_color_opacity" translatable="false">digital_style_frame_color_opacity</string> <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_direction" translatable="false">show_direction</string>
<string name="key_show_iob" translatable="false">show_iob</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_uploader_battery" translatable="false">show_uploader_battery</string>
<string name="key_show_rig_battery" translatable="false">show_rig_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> <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" <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"> 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 <CheckBoxPreference
android:defaultValue="true" android:defaultValue="true"
android:key="@string/key_show_iob" android:key="@string/key_show_iob"
@ -10,6 +18,14 @@
app:wear_iconOff="@drawable/settings_off" app:wear_iconOff="@drawable/settings_off"
app:wear_iconOn="@drawable/settings_on" /> 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 <CheckBoxPreference
android:defaultValue="true" android:defaultValue="true"
android:key="@string/key_show_cob" android:key="@string/key_show_cob"
@ -19,10 +35,10 @@
app:wear_iconOn="@drawable/settings_on" /> app:wear_iconOn="@drawable/settings_on" />
<CheckBoxPreference <CheckBoxPreference
android:defaultValue="true" android:defaultValue="false"
android:key="@string/key_show_bg" android:key="@string/key_show_bgi"
android:summary="Show BG." android:summary="Show BGI"
android:title="@string/pref_show_bg" android:title="@string/pref_show_bgi"
app:wear_iconOff="@drawable/settings_off" app:wear_iconOff="@drawable/settings_off"
app:wear_iconOn="@drawable/settings_on" /> app:wear_iconOn="@drawable/settings_on" />
@ -41,6 +57,15 @@
android:title="@string/pref_show_avgdelta" android:title="@string/pref_show_avgdelta"
app:wear_iconOff="@drawable/settings_off" app:wear_iconOff="@drawable/settings_off"
app:wear_iconOn="@drawable/settings_on" /> app:wear_iconOn="@drawable/settings_on" />
<CheckBoxPreference
android:defaultValue="false"
android:key="@string/key_show_detailed_delta"
android:summary="Show delta with one more decimal place"
android:title="@string/pref_show_detailed_delta"
app:wear_iconOff="@drawable/settings_off"
app:wear_iconOn="@drawable/settings_on" />
<CheckBoxPreference <CheckBoxPreference
android:defaultValue="true" android:defaultValue="true"
android:key="@string/key_show_direction" android:key="@string/key_show_direction"

View file

@ -30,6 +30,8 @@ class RawDataMocker(wearUtil: WearUtil) {
"", "",
d, d,
deltaString, deltaString,
deltaString,
"",
"", "",
0, 0,
0.0, 0.0,
@ -48,6 +50,8 @@ class RawDataMocker(wearUtil: WearUtil) {
"", "",
"", "",
delta, delta,
delta,
"",
"", "",
0, 0,
0.0, 0.0,
@ -64,14 +68,12 @@ class RawDataMocker(wearUtil: WearUtil) {
"", "",
iob, iob,
"", "",
true,
cob, cob,
br, br,
"", "",
"", "",
0L, 0L,
"", "",
true,
0 0
) )
return raw return raw
@ -83,14 +85,12 @@ class RawDataMocker(wearUtil: WearUtil) {
"", "",
iob, iob,
iob2, iob2,
true,
"", "",
"", "",
"", "",
"", "",
0L, 0L,
"", "",
true,
0 0
) )
return raw return raw
@ -102,14 +102,12 @@ class RawDataMocker(wearUtil: WearUtil) {
"", "",
"", "",
"", "",
true,
cob!!, cob!!,
"", "",
"", "",
"", "",
0L, 0L,
"", "",
true,
0 0
) )
return raw return raw