Move Detailed Delta preference to Watch
This commit is contained in:
parent
e08159709f
commit
ba64d0f833
12 changed files with 47 additions and 23 deletions
|
@ -173,7 +173,9 @@ sealed class EventData : Event() {
|
|||
val glucoseUnits: String = "-",
|
||||
val slopeArrow: String = "--",
|
||||
val delta: String = "--",
|
||||
val deltaDetailed: String = "--",
|
||||
val avgDelta: String = "--",
|
||||
val avgDeltaDetailed: String = "--",
|
||||
val sgvLevel: Long = 0,
|
||||
val sgv: Double,
|
||||
val high: Double, // highLine
|
||||
|
|
|
@ -943,15 +943,23 @@ class DataHandlerMobile @Inject constructor(
|
|||
}
|
||||
|
||||
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 "-"
|
||||
deltaString += if (units == GlucoseUnit.MGDL) {
|
||||
if (detailed) DecimalFormatter.to1Decimal(abs(deltaMGDL)) else DecimalFormatter.to0Decimal(abs(deltaMGDL))
|
||||
DecimalFormatter.to0Decimal(abs(deltaMGDL))
|
||||
} else {
|
||||
if (detailed) DecimalFormatter.to2Decimal(abs(deltaMMOL)) else DecimalFormatter.to1Decimal(abs(deltaMMOL))
|
||||
DecimalFormatter.to1Decimal(abs(deltaMMOL))
|
||||
}
|
||||
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 {
|
||||
val glucoseStatus = glucoseStatusProvider.getGlucoseStatusData(true)
|
||||
|
@ -965,7 +973,9 @@ class DataHandlerMobile @Inject constructor(
|
|||
glucoseUnits = units.asText,
|
||||
slopeArrow = trendCalculator.getTrendArrow(glucoseValue).symbol,
|
||||
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) } ?: "--",
|
||||
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,
|
||||
sgv = glucoseValue.recalculated,
|
||||
high = highLine,
|
||||
|
|
|
@ -351,8 +351,6 @@
|
|||
<string name="wear_wizard_settings_summary">Calculations included in the Wizard result:</string>
|
||||
<string name="wear_display_settings">Display 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_summary">Show SMB on the watch like a standard bolus.</string>
|
||||
<string name="wear_predictions_summary">Show the predictions on the watchface.</string>
|
||||
|
|
|
@ -53,12 +53,6 @@
|
|||
<PreferenceCategory
|
||||
android:title="@string/wear_display_settings">
|
||||
|
||||
<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="true"
|
||||
android:key="wear_predictions"
|
||||
|
|
|
@ -20,7 +20,9 @@ class RawDisplayData {
|
|||
glucoseUnits = "-",
|
||||
slopeArrow = "--",
|
||||
delta = "--",
|
||||
deltaDetailed = "--",
|
||||
avgDelta = "--",
|
||||
avgDeltaDetailed = "--",
|
||||
sgvLevel = 0,
|
||||
sgv = 0.0,
|
||||
high = 0.0,
|
||||
|
|
|
@ -61,24 +61,26 @@ class DisplayFormat @Inject internal constructor() {
|
|||
|
||||
fun shortTrend(raw: RawDisplayData): String {
|
||||
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) {
|
||||
minutes = shortTimeSince(raw.singleBg.timeStamp)
|
||||
}
|
||||
if (minutes.length + raw.singleBg.delta.length + deltaSymbol().length + 1 <= MAX_FIELD_LEN_SHORT) {
|
||||
return minutes + " " + deltaSymbol() + raw.singleBg.delta
|
||||
if (minutes.length + rawDelta.length + deltaSymbol().length + 1 <= MAX_FIELD_LEN_SHORT) {
|
||||
return minutes + " " + deltaSymbol() + rawDelta
|
||||
}
|
||||
|
||||
// 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) {
|
||||
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"
|
||||
}
|
||||
|
||||
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 {
|
||||
|
|
|
@ -187,9 +187,10 @@ class CircleWatchface : WatchFace() {
|
|||
textView?.visibility = View.INVISIBLE
|
||||
}
|
||||
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)) {
|
||||
textView?.visibility = View.VISIBLE
|
||||
textView?.text = singleBg.delta
|
||||
textView?.text = if (detailedDelta) singleBg.deltaDetailed else singleBg.delta
|
||||
textView?.setTextColor(textColor)
|
||||
if (sp.getBoolean(R.string.key_show_big_numbers, false)) {
|
||||
textView?.setTextSize(TypedValue.COMPLEX_UNIT_SP, 25f)
|
||||
|
@ -197,7 +198,7 @@ class CircleWatchface : WatchFace() {
|
|||
textView?.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18f)
|
||||
}
|
||||
if (sp.getBoolean(R.string.key_show_avg_delta, true)) {
|
||||
textView?.append(" " + singleBg.avgDelta)
|
||||
textView?.append(" " + if (detailedDelta) singleBg.avgDeltaDetailed else singleBg.avgDelta)
|
||||
}
|
||||
} else {
|
||||
//Also possible: View.INVISIBLE instead of View.GONE (no layout change)
|
||||
|
|
|
@ -298,15 +298,16 @@ abstract class BaseWatchFace : WatchFace() {
|
|||
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()
|
||||
binding.sgv?.text = singleBg.sgvString
|
||||
binding.sgv?.visibility = sp.getBoolean(R.string.key_show_bg, true).toVisibilityKeepSpace()
|
||||
strikeThroughSgvIfNeeded()
|
||||
binding.direction?.text = "${singleBg.slopeArrow}\uFE0E"
|
||||
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.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.cob1?.visibility = sp.getBoolean(R.string.key_show_cob, true).toVisibility()
|
||||
binding.cob2?.text = status.cob
|
||||
|
|
|
@ -86,7 +86,7 @@ class BgGraphBuilder(
|
|||
lines.add(highValuesLine())
|
||||
var minChart = lowMark
|
||||
var maxChart = highMark
|
||||
for ((_, _, _, _, _, _, _, sgv) in bgDataList) {
|
||||
for ((_, _, _, _, _, _, _, _, _, sgv) in bgDataList) {
|
||||
if (sgv > maxChart) maxChart = sgv
|
||||
if (sgv < minChart) minChart = sgv
|
||||
}
|
||||
|
@ -197,7 +197,7 @@ class BgGraphBuilder(
|
|||
private fun addPredictionLines(lines: MutableList<Line>) {
|
||||
val values: MutableMap<Int, MutableList<PointValue>> = HashMap()
|
||||
val endTime = getPredictionEndTime()
|
||||
for ((timeStamp, _, _, _, _, _, _, sgv, _, _, color) in predictionsList) {
|
||||
for ((timeStamp, _, _, _, _, _, _, _, _, sgv, _, _, color) in predictionsList) {
|
||||
if (timeStamp <= endTime) {
|
||||
val value = min(sgv, UPPER_CUTOFF_SGV)
|
||||
if (!values.containsKey(color)) {
|
||||
|
@ -262,7 +262,7 @@ class BgGraphBuilder(
|
|||
}
|
||||
|
||||
private fun addBgReadingValues() {
|
||||
for ((timeStamp, _, _, _, _, _, _, sgv) in bgDataList) {
|
||||
for ((timeStamp, _, _, _,_, _, _, _, _, sgv) in bgDataList) {
|
||||
if (timeStamp > startingTime) {
|
||||
when {
|
||||
sgv >= 450 -> highValues.add(PointValue(fuzz(timeStamp), 450.toFloat()))
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
<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_detailed_delta">Show detailed Delta</string>
|
||||
<string name="pref_show_avgdelta">Show AvgDelta</string>
|
||||
<string name="pref_show_phone_battery">Show Phone Battery</string>
|
||||
<string name="pref_show_rig_battery">Show Rig Battery</string>
|
||||
|
@ -195,6 +196,7 @@
|
|||
<string name="key_show_ago" translatable="false">showAgo</string>
|
||||
<string name="key_show_big_numbers" translatable="false">showBigNumbers</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_ring_history" translatable="false">showRingHistory</string>
|
||||
<string name="key_digital_style_frame_style" translatable="false">digital_style_frame_style</string>
|
||||
|
|
|
@ -58,6 +58,14 @@
|
|||
app:wear_iconOff="@drawable/settings_off"
|
||||
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
|
||||
android:defaultValue="true"
|
||||
android:key="@string/key_show_direction"
|
||||
|
|
|
@ -30,6 +30,8 @@ class RawDataMocker(wearUtil: WearUtil) {
|
|||
"",
|
||||
d,
|
||||
deltaString,
|
||||
deltaString,
|
||||
"",
|
||||
"",
|
||||
0,
|
||||
0.0,
|
||||
|
@ -48,6 +50,8 @@ class RawDataMocker(wearUtil: WearUtil) {
|
|||
"",
|
||||
"",
|
||||
delta,
|
||||
delta,
|
||||
"",
|
||||
"",
|
||||
0,
|
||||
0.0,
|
||||
|
|
Loading…
Reference in a new issue