wear: i11n complication and status message
This commit is contained in:
parent
87a0cb1923
commit
b58588daea
|
@ -16,13 +16,7 @@ import info.nightscout.core.wizard.BolusWizard
|
||||||
import info.nightscout.core.wizard.QuickWizard
|
import info.nightscout.core.wizard.QuickWizard
|
||||||
import info.nightscout.core.wizard.QuickWizardEntry
|
import info.nightscout.core.wizard.QuickWizardEntry
|
||||||
import info.nightscout.database.ValueWrapper
|
import info.nightscout.database.ValueWrapper
|
||||||
import info.nightscout.database.entities.Bolus
|
import info.nightscout.database.entities.*
|
||||||
import info.nightscout.database.entities.GlucoseValue
|
|
||||||
import info.nightscout.database.entities.TemporaryBasal
|
|
||||||
import info.nightscout.database.entities.TemporaryTarget
|
|
||||||
import info.nightscout.database.entities.TotalDailyDose
|
|
||||||
import info.nightscout.database.entities.UserEntry
|
|
||||||
import info.nightscout.database.entities.ValueWithUnit
|
|
||||||
import info.nightscout.database.entities.interfaces.end
|
import info.nightscout.database.entities.interfaces.end
|
||||||
import info.nightscout.database.impl.AppRepository
|
import info.nightscout.database.impl.AppRepository
|
||||||
import info.nightscout.database.impl.transactions.CancelCurrentTemporaryTargetIfAnyTransaction
|
import info.nightscout.database.impl.transactions.CancelCurrentTemporaryTargetIfAnyTransaction
|
||||||
|
@ -66,9 +60,7 @@ import io.reactivex.rxjava3.disposables.CompositeDisposable
|
||||||
import io.reactivex.rxjava3.kotlin.plusAssign
|
import io.reactivex.rxjava3.kotlin.plusAssign
|
||||||
import java.text.DateFormat
|
import java.text.DateFormat
|
||||||
import java.text.SimpleDateFormat
|
import java.text.SimpleDateFormat
|
||||||
import java.util.Date
|
import java.util.*
|
||||||
import java.util.LinkedList
|
|
||||||
import java.util.Locale
|
|
||||||
import java.util.concurrent.TimeUnit
|
import java.util.concurrent.TimeUnit
|
||||||
import java.util.stream.Collectors
|
import java.util.stream.Collectors
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
@ -317,14 +309,14 @@ class DataHandlerMobile @Inject constructor(
|
||||||
if (activePump.isBusy()) {
|
if (activePump.isBusy()) {
|
||||||
message += rh.gs(info.nightscout.core.ui.R.string.pump_busy)
|
message += rh.gs(info.nightscout.core.ui.R.string.pump_busy)
|
||||||
} else {
|
} else {
|
||||||
message += "trying to fetch data from pump."
|
message += rh.gs(R.string.pump_fetching_data)
|
||||||
commandQueue.loadTDDs(object : Callback() {
|
commandQueue.loadTDDs(object : Callback() {
|
||||||
override fun run() {
|
override fun run() {
|
||||||
val dummies1: MutableList<TotalDailyDose> = LinkedList()
|
val dummies1: MutableList<TotalDailyDose> = LinkedList()
|
||||||
val historyList1 = getTDDList(dummies1)
|
val historyList1 = getTDDList(dummies1)
|
||||||
val reloadMessage =
|
val reloadMessage =
|
||||||
if (isOldData(historyList1))
|
if (isOldData(historyList1))
|
||||||
"TDD: Still old data! Cannot load from pump.\n" + generateTDDMessage(historyList1, dummies1)
|
rh.gs(R.string.pump_old_data) + "\n" + generateTDDMessage(historyList1, dummies1)
|
||||||
else
|
else
|
||||||
generateTDDMessage(historyList1, dummies1)
|
generateTDDMessage(historyList1, dummies1)
|
||||||
rxBus.send(
|
rxBus.send(
|
||||||
|
@ -491,8 +483,8 @@ class DataHandlerMobile @Inject constructor(
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
var message = ""
|
var message = ""
|
||||||
message += rh.gs(info.nightscout.core.ui.R.string.bolus) + ": " + insulinAfterConstraints + "U\n"
|
message += rh.gs(info.nightscout.core.ui.R.string.bolus) + ": " + insulinAfterConstraints + rh.gs(R.string.units_short) + "\n"
|
||||||
message += rh.gs(info.nightscout.core.ui.R.string.carbs) + ": " + carbsAfterConstraints + "g"
|
message += rh.gs(info.nightscout.core.ui.R.string.carbs) + ": " + carbsAfterConstraints + rh.gs(R.string.grams_short)
|
||||||
if (insulinAfterConstraints - command.insulin != 0.0 || carbsAfterConstraints - command.carbs != 0)
|
if (insulinAfterConstraints - command.insulin != 0.0 || carbsAfterConstraints - command.carbs != 0)
|
||||||
message += "\n" + rh.gs(info.nightscout.core.ui.R.string.constraint_applied)
|
message += "\n" + rh.gs(info.nightscout.core.ui.R.string.constraint_applied)
|
||||||
rxBus.send(
|
rxBus.send(
|
||||||
|
@ -508,9 +500,9 @@ class DataHandlerMobile @Inject constructor(
|
||||||
private fun handleECarbsPreCheck(command: EventData.ActionECarbsPreCheck) {
|
private fun handleECarbsPreCheck(command: EventData.ActionECarbsPreCheck) {
|
||||||
val startTimeStamp = System.currentTimeMillis() + T.mins(command.carbsTimeShift.toLong()).msecs()
|
val startTimeStamp = System.currentTimeMillis() + T.mins(command.carbsTimeShift.toLong()).msecs()
|
||||||
val carbsAfterConstraints = constraintChecker.applyCarbsConstraints(Constraint(command.carbs)).value()
|
val carbsAfterConstraints = constraintChecker.applyCarbsConstraints(Constraint(command.carbs)).value()
|
||||||
var message = rh.gs(info.nightscout.core.ui.R.string.carbs) + ": " + carbsAfterConstraints + "g" +
|
var message = rh.gs(info.nightscout.core.ui.R.string.carbs) + ": " + carbsAfterConstraints + rh.gs(R.string.grams_short) +
|
||||||
"\n" + rh.gs(info.nightscout.core.ui.R.string.time) + ": " + dateUtil.timeString(startTimeStamp) +
|
"\n" + rh.gs(info.nightscout.core.ui.R.string.time) + ": " + dateUtil.timeString(startTimeStamp) +
|
||||||
"\n" + rh.gs(info.nightscout.core.ui.R.string.duration) + ": " + command.duration + "h"
|
"\n" + rh.gs(info.nightscout.core.ui.R.string.duration) + ": " + command.duration + rh.gs(R.string.hour_short)
|
||||||
if (carbsAfterConstraints - command.carbs != 0) {
|
if (carbsAfterConstraints - command.carbs != 0) {
|
||||||
message += "\n" + rh.gs(info.nightscout.core.ui.R.string.constraint_applied)
|
message += "\n" + rh.gs(info.nightscout.core.ui.R.string.constraint_applied)
|
||||||
}
|
}
|
||||||
|
@ -536,7 +528,7 @@ class DataHandlerMobile @Inject constructor(
|
||||||
else -> return
|
else -> return
|
||||||
}
|
}
|
||||||
val insulinAfterConstraints = constraintChecker.applyBolusConstraints(Constraint(amount)).value()
|
val insulinAfterConstraints = constraintChecker.applyBolusConstraints(Constraint(amount)).value()
|
||||||
var message = rh.gs(info.nightscout.core.ui.R.string.prime_fill) + ": " + insulinAfterConstraints + "U"
|
var message = rh.gs(info.nightscout.core.ui.R.string.prime_fill) + ": " + insulinAfterConstraints + rh.gs(R.string.units_short)
|
||||||
if (insulinAfterConstraints - amount != 0.0) message += "\n" + rh.gs(info.nightscout.core.ui.R.string.constraint_applied)
|
if (insulinAfterConstraints - amount != 0.0) message += "\n" + rh.gs(info.nightscout.core.ui.R.string.constraint_applied)
|
||||||
rxBus.send(
|
rxBus.send(
|
||||||
EventMobileToWear(
|
EventMobileToWear(
|
||||||
|
@ -550,7 +542,7 @@ class DataHandlerMobile @Inject constructor(
|
||||||
|
|
||||||
private fun handleFillPreCheck(command: EventData.ActionFillPreCheck) {
|
private fun handleFillPreCheck(command: EventData.ActionFillPreCheck) {
|
||||||
val insulinAfterConstraints = constraintChecker.applyBolusConstraints(Constraint(command.insulin)).value()
|
val insulinAfterConstraints = constraintChecker.applyBolusConstraints(Constraint(command.insulin)).value()
|
||||||
var message = rh.gs(info.nightscout.core.ui.R.string.prime_fill) + ": " + insulinAfterConstraints + "U"
|
var message = rh.gs(info.nightscout.core.ui.R.string.prime_fill) + ": " + insulinAfterConstraints + rh.gs(R.string.units_short)
|
||||||
if (insulinAfterConstraints - command.insulin != 0.0) message += "\n" + rh.gs(info.nightscout.core.ui.R.string.constraint_applied)
|
if (insulinAfterConstraints - command.insulin != 0.0) message += "\n" + rh.gs(info.nightscout.core.ui.R.string.constraint_applied)
|
||||||
rxBus.send(
|
rxBus.send(
|
||||||
EventMobileToWear(
|
EventMobileToWear(
|
||||||
|
@ -569,7 +561,7 @@ class DataHandlerMobile @Inject constructor(
|
||||||
EventMobileToWear(EventData.ActionProfileSwitchOpenActivity(T.msecs(activeProfileSwitch.value.originalTimeshift).hours().toInt(), activeProfileSwitch.value.originalPercentage))
|
EventMobileToWear(EventData.ActionProfileSwitchOpenActivity(T.msecs(activeProfileSwitch.value.originalTimeshift).hours().toInt(), activeProfileSwitch.value.originalPercentage))
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
sendError("No active profile switch!")
|
sendError(rh.gs(R.string.no_active_profile))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -578,7 +570,7 @@ class DataHandlerMobile @Inject constructor(
|
||||||
private fun handleProfileSwitchPreCheck(command: EventData.ActionProfileSwitchPreCheck) {
|
private fun handleProfileSwitchPreCheck(command: EventData.ActionProfileSwitchPreCheck) {
|
||||||
val activeProfileSwitch = repository.getEffectiveProfileSwitchActiveAt(dateUtil.now()).blockingGet()
|
val activeProfileSwitch = repository.getEffectiveProfileSwitchActiveAt(dateUtil.now()).blockingGet()
|
||||||
if (activeProfileSwitch is ValueWrapper.Absent) {
|
if (activeProfileSwitch is ValueWrapper.Absent) {
|
||||||
sendError("No active profile switch!")
|
sendError(rh.gs(R.string.no_active_profile))
|
||||||
}
|
}
|
||||||
if (command.percentage < Constants.CPP_MIN_PERCENTAGE || command.percentage > Constants.CPP_MAX_PERCENTAGE) {
|
if (command.percentage < Constants.CPP_MIN_PERCENTAGE || command.percentage > Constants.CPP_MAX_PERCENTAGE) {
|
||||||
sendError(rh.gs(info.nightscout.core.ui.R.string.valueoutofrange, "Profile-Percentage"))
|
sendError(rh.gs(info.nightscout.core.ui.R.string.valueoutofrange, "Profile-Percentage"))
|
||||||
|
@ -586,9 +578,7 @@ class DataHandlerMobile @Inject constructor(
|
||||||
if (command.timeShift < 0 || command.timeShift > 23) {
|
if (command.timeShift < 0 || command.timeShift > 23) {
|
||||||
sendError(rh.gs(info.nightscout.core.ui.R.string.valueoutofrange, "Profile-Timeshift"))
|
sendError(rh.gs(info.nightscout.core.ui.R.string.valueoutofrange, "Profile-Timeshift"))
|
||||||
}
|
}
|
||||||
val message = "Profile:" + "\n\n" +
|
val message = rh.gs(R.string.profile_message, command.timeShift, command.percentage)
|
||||||
"Timeshift: " + command.timeShift + "\n" +
|
|
||||||
"Percentage: " + command.percentage + "%"
|
|
||||||
rxBus.send(
|
rxBus.send(
|
||||||
EventMobileToWear(
|
EventMobileToWear(
|
||||||
EventData.ConfirmAction(
|
EventData.ConfirmAction(
|
||||||
|
@ -854,7 +844,7 @@ class DataHandlerMobile @Inject constructor(
|
||||||
repository.getCarbsDataFromTimeExpanded(startTimeWindow, true).blockingGet()
|
repository.getCarbsDataFromTimeExpanded(startTimeWindow, true).blockingGet()
|
||||||
.forEach { (_, _, _, isValid, _, _, timestamp, _, _, amount) -> boluses.add(EventData.TreatmentData.Treatment(timestamp, 0.0, amount, false, isValid)) }
|
.forEach { (_, _, _, isValid, _, _, timestamp, _, _, amount) -> boluses.add(EventData.TreatmentData.Treatment(timestamp, 0.0, amount, false, isValid)) }
|
||||||
val finalLastRun = loop.lastRun
|
val finalLastRun = loop.lastRun
|
||||||
if (sp.getBoolean("wear_predictions", true) && finalLastRun?.request?.hasPredictions == true && finalLastRun.constraintsProcessed != null) {
|
if (sp.getBoolean(rh.gs(R.string.key_wear_predictions), true) && finalLastRun?.request?.hasPredictions == true && finalLastRun.constraintsProcessed != null) {
|
||||||
val predArray = finalLastRun.constraintsProcessed!!.predictions
|
val predArray = finalLastRun.constraintsProcessed!!.predictions
|
||||||
.stream().map { bg: GlucoseValue -> GlucoseValueDataPoint(bg, defaultValueHelper, profileFunction, rh) }
|
.stream().map { bg: GlucoseValue -> GlucoseValueDataPoint(bg, defaultValueHelper, profileFunction, rh) }
|
||||||
.collect(Collectors.toList())
|
.collect(Collectors.toList())
|
||||||
|
@ -888,7 +878,8 @@ class DataHandlerMobile @Inject constructor(
|
||||||
iobSum = DecimalFormatter.to2Decimal(bolusIob.iob + basalIob.basaliob)
|
iobSum = DecimalFormatter.to2Decimal(bolusIob.iob + basalIob.basaliob)
|
||||||
iobDetail = "(${DecimalFormatter.to2Decimal(bolusIob.iob)}|${DecimalFormatter.to2Decimal(basalIob.basaliob)})"
|
iobDetail = "(${DecimalFormatter.to2Decimal(bolusIob.iob)}|${DecimalFormatter.to2Decimal(basalIob.basaliob)})"
|
||||||
cobString = iobCobCalculator.getCobInfo(false, "WatcherUpdaterService").generateCOBString()
|
cobString = iobCobCalculator.getCobInfo(false, "WatcherUpdaterService").generateCOBString()
|
||||||
currentBasal = iobCobCalculator.getTempBasalIncludingConvertedExtended(System.currentTimeMillis())?.toStringShort() ?: rh.gs(info.nightscout.core.ui.R.string.pump_base_basal_rate, profile.getBasal())
|
currentBasal =
|
||||||
|
iobCobCalculator.getTempBasalIncludingConvertedExtended(System.currentTimeMillis())?.toStringShort() ?: rh.gs(info.nightscout.core.ui.R.string.pump_base_basal_rate, profile.getBasal())
|
||||||
|
|
||||||
//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())
|
||||||
|
@ -962,22 +953,23 @@ class DataHandlerMobile @Inject constructor(
|
||||||
get() {
|
get() {
|
||||||
var ret = ""
|
var ret = ""
|
||||||
if (!config.APS) {
|
if (!config.APS) {
|
||||||
return "Targets only apply in APS mode!"
|
return rh.gs(R.string.target_only_aps_mode)
|
||||||
}
|
}
|
||||||
val profile = profileFunction.getProfile() ?: return "No profile set :("
|
val profile = profileFunction.getProfile() ?: return rh.gs(R.string.no_profile)
|
||||||
//Check for Temp-Target:
|
//Check for Temp-Target:
|
||||||
val tempTarget = repository.getTemporaryTargetActiveAt(dateUtil.now()).blockingGet()
|
val tempTarget = repository.getTemporaryTargetActiveAt(dateUtil.now()).blockingGet()
|
||||||
if (tempTarget is ValueWrapper.Existing) {
|
if (tempTarget is ValueWrapper.Existing) {
|
||||||
ret += "Temp Target: " + Profile.toTargetRangeString(tempTarget.value.lowTarget, tempTarget.value.lowTarget, GlucoseUnit.MGDL, profileFunction.getUnits())
|
val target = Profile.toTargetRangeString(tempTarget.value.lowTarget, tempTarget.value.lowTarget, GlucoseUnit.MGDL, profileFunction.getUnits())
|
||||||
ret += "\nuntil: " + dateUtil.timeString(tempTarget.value.end)
|
ret += rh.gs(R.string.temp_target) + ": " + target
|
||||||
|
ret += "\n"+ rh.gs(R.string.until) + ": " + dateUtil.timeString(tempTarget.value.end)
|
||||||
ret += "\n\n"
|
ret += "\n\n"
|
||||||
}
|
}
|
||||||
ret += "DEFAULT RANGE: "
|
ret += rh.gs(R.string.default_range) + ": "
|
||||||
ret += Profile.fromMgdlToUnits(profile.getTargetLowMgdl(), profileFunction.getUnits()).toString() + " - " + Profile.fromMgdlToUnits(
|
ret += Profile.fromMgdlToUnits(profile.getTargetLowMgdl(), profileFunction.getUnits()).toString() + " - " + Profile.fromMgdlToUnits(
|
||||||
profile.getTargetHighMgdl(),
|
profile.getTargetHighMgdl(),
|
||||||
profileFunction.getUnits()
|
profileFunction.getUnits()
|
||||||
)
|
)
|
||||||
ret += " target: " + Profile.fromMgdlToUnits(profile.getTargetMgdl(), profileFunction.getUnits())
|
ret += " " + rh.gs(R.string.target) + ": " + Profile.fromMgdlToUnits(profile.getTargetMgdl(), profileFunction.getUnits())
|
||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -986,17 +978,15 @@ class DataHandlerMobile @Inject constructor(
|
||||||
get() {
|
get() {
|
||||||
var ret = ""
|
var ret = ""
|
||||||
if (!config.APS)
|
if (!config.APS)
|
||||||
return "Only apply in APS mode!"
|
return rh.gs(R.string.aps_only)
|
||||||
val usedAPS = activePlugin.activeAPS
|
val usedAPS = activePlugin.activeAPS
|
||||||
val result = usedAPS.lastAPSResult ?: return "Last result not available!"
|
val result = usedAPS.lastAPSResult ?: return rh.gs(R.string.last_aps_result_na)
|
||||||
ret += if (!result.isChangeRequested) {
|
ret += if (!result.isChangeRequested) {
|
||||||
rh.gs(info.nightscout.core.ui.R.string.nochangerequested) + "\n"
|
rh.gs(info.nightscout.core.ui.R.string.nochangerequested) + "\n"
|
||||||
} else if (result.rate == 0.0 && result.duration == 0) {
|
} else if (result.rate == 0.0 && result.duration == 0) {
|
||||||
rh.gs(info.nightscout.core.ui.R.string.cancel_temp) + "\n"
|
rh.gs(info.nightscout.core.ui.R.string.cancel_temp) + "\n"
|
||||||
} else {
|
} else {
|
||||||
rh.gs(info.nightscout.core.ui.R.string.rate) + ": " + DecimalFormatter.to2Decimal(result.rate) + " U/h " +
|
rh.gs(R.string.rate_duration, result.rate, result.rate / activePlugin.activePump.baseBasalRate * 100, result.duration) + "\n"
|
||||||
"(" + DecimalFormatter.to2Decimal(result.rate / activePlugin.activePump.baseBasalRate * 100) + "%)\n" +
|
|
||||||
rh.gs(info.nightscout.core.ui.R.string.duration) + ": " + DecimalFormatter.to0Decimal(result.duration.toDouble()) + " min\n"
|
|
||||||
}
|
}
|
||||||
ret += "\n" + rh.gs(info.nightscout.core.ui.R.string.reason) + ": " + result.reason
|
ret += "\n" + rh.gs(info.nightscout.core.ui.R.string.reason) + ": " + result.reason
|
||||||
return ret
|
return ret
|
||||||
|
@ -1010,19 +1000,19 @@ class DataHandlerMobile @Inject constructor(
|
||||||
// decide if enabled/disabled closed/open; what Plugin as APS?
|
// decide if enabled/disabled closed/open; what Plugin as APS?
|
||||||
if ((loop as PluginBase).isEnabled()) {
|
if ((loop as PluginBase).isEnabled()) {
|
||||||
ret += if (constraintChecker.isClosedLoopAllowed().value()) {
|
ret += if (constraintChecker.isClosedLoopAllowed().value()) {
|
||||||
"CLOSED LOOP\n"
|
rh.gs(R.string.loop_status_closed) + "\n"
|
||||||
} else {
|
} else {
|
||||||
"OPEN LOOP\n"
|
rh.gs(R.string.loop_status_open) + "\n"
|
||||||
}
|
}
|
||||||
val aps = activePlugin.activeAPS
|
val aps = activePlugin.activeAPS
|
||||||
ret += "APS: " + (aps as PluginBase).name
|
ret += rh.gs(R.string.aps) + ": " + (aps as PluginBase).name
|
||||||
val lastRun = loop.lastRun
|
val lastRun = loop.lastRun
|
||||||
if (lastRun != null) {
|
if (lastRun != null) {
|
||||||
ret += "\nLast Run: " + dateUtil.timeString(lastRun.lastAPSRun)
|
ret += "\n" + rh.gs(R.string.last_run) + ": " + dateUtil.timeString(lastRun.lastAPSRun)
|
||||||
if (lastRun.lastTBREnact != 0L) ret += "\nLast Enact: " + dateUtil.timeString(lastRun.lastTBREnact)
|
if (lastRun.lastTBREnact != 0L) ret += "\n" + rh.gs(R.string.last_enact) + ": " + dateUtil.timeString(lastRun.lastTBREnact)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ret += "LOOP DISABLED\n"
|
ret += rh.gs(R.string.loop_status_disabled) + "\n"
|
||||||
}
|
}
|
||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
|
@ -1037,7 +1027,7 @@ class DataHandlerMobile @Inject constructor(
|
||||||
var historyList = repository.getLastTotalDailyDoses(10, false).blockingGet().toMutableList()
|
var historyList = repository.getLastTotalDailyDoses(10, false).blockingGet().toMutableList()
|
||||||
//var historyList = databaseHelper.getTDDs().toMutableList()
|
//var historyList = databaseHelper.getTDDs().toMutableList()
|
||||||
historyList = historyList.subList(0, min(10, historyList.size))
|
historyList = historyList.subList(0, min(10, historyList.size))
|
||||||
//fill single gaps - only needed for Dana*R data
|
// fill single gaps - only needed for Dana*R data
|
||||||
val dummies: MutableList<TotalDailyDose> = returnDummies
|
val dummies: MutableList<TotalDailyDose> = returnDummies
|
||||||
val df: DateFormat = SimpleDateFormat("dd.MM.", Locale.getDefault())
|
val df: DateFormat = SimpleDateFormat("dd.MM.", Locale.getDefault())
|
||||||
for (i in 0 until historyList.size - 1) {
|
for (i in 0 until historyList.size - 1) {
|
||||||
|
@ -1059,9 +1049,9 @@ class DataHandlerMobile @Inject constructor(
|
||||||
get() = if (totalAmount > 0) totalAmount else basalAmount + bolusAmount
|
get() = if (totalAmount > 0) totalAmount else basalAmount + bolusAmount
|
||||||
|
|
||||||
private fun generateTDDMessage(historyList: MutableList<TotalDailyDose>, dummies: MutableList<TotalDailyDose>): String {
|
private fun generateTDDMessage(historyList: MutableList<TotalDailyDose>, dummies: MutableList<TotalDailyDose>): String {
|
||||||
val profile = profileFunction.getProfile() ?: return "No profile loaded :("
|
val profile = profileFunction.getProfile() ?: return rh.gs(R.string.no_profile)
|
||||||
if (historyList.isEmpty()) {
|
if (historyList.isEmpty()) {
|
||||||
return "No history data!"
|
return rh.gs(R.string.no_history)
|
||||||
}
|
}
|
||||||
val df: DateFormat = SimpleDateFormat("dd.MM.", Locale.getDefault())
|
val df: DateFormat = SimpleDateFormat("dd.MM.", Locale.getDefault())
|
||||||
var message = ""
|
var message = ""
|
||||||
|
@ -1069,7 +1059,8 @@ class DataHandlerMobile @Inject constructor(
|
||||||
if (df.format(Date(historyList[0].timestamp)) == df.format(Date())) {
|
if (df.format(Date(historyList[0].timestamp)) == df.format(Date())) {
|
||||||
val tdd = historyList[0].total
|
val tdd = historyList[0].total
|
||||||
historyList.removeAt(0)
|
historyList.removeAt(0)
|
||||||
message += "Today: " + DecimalFormatter.to2Decimal(tdd) + "U " + (DecimalFormatter.to0Decimal(100 * tdd / refTDD) + "%") + "\n"
|
|
||||||
|
message += rh.gs(R.string.today) + ": " + rh.gs(R.string.tdd_line, tdd, 100 * tdd / refTDD) + "\n"
|
||||||
message += "\n"
|
message += "\n"
|
||||||
}
|
}
|
||||||
var weighted03 = 0.0
|
var weighted03 = 0.0
|
||||||
|
@ -1088,19 +1079,17 @@ class DataHandlerMobile @Inject constructor(
|
||||||
weighted03 = weighted03 * 0.7 + tdd * 0.3
|
weighted03 = weighted03 * 0.7 + tdd * 0.3
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
message += "weighted:\n"
|
message += rh.gs(R.string.weighted) + ":\n"
|
||||||
message += "0.3: " + DecimalFormatter.to2Decimal(weighted03) + "U " + (DecimalFormatter.to0Decimal(100 * weighted03 / refTDD) + "%") + "\n"
|
message += "0.3: " + rh.gs(R.string.tdd_line, weighted03, 100 * weighted03 / refTDD) + "\n"
|
||||||
message += "0.5: " + DecimalFormatter.to2Decimal(weighted05) + "U " + (DecimalFormatter.to0Decimal(100 * weighted05 / refTDD) + "%") + "\n"
|
message += "0.5: " + rh.gs(R.string.tdd_line, weighted05, 100 * weighted05 / refTDD) + "\n"
|
||||||
message += "0.7: " + DecimalFormatter.to2Decimal(weighted07) + "U " + (DecimalFormatter.to0Decimal(100 * weighted07 / refTDD) + "%") + "\n"
|
message += "0.7: " + rh.gs(R.string.tdd_line, weighted07, 100 * weighted07 / refTDD) + "\n"
|
||||||
message += "\n"
|
message += "\n"
|
||||||
historyList.reverse()
|
historyList.reverse()
|
||||||
//add TDDs:
|
// add TDDs:
|
||||||
for (record in historyList) {
|
for (record in historyList) {
|
||||||
val tdd = record.total
|
val tdd = record.total
|
||||||
message += df.format(Date(record.timestamp)) + " " + DecimalFormatter.to2Decimal(tdd) + "U " + (DecimalFormatter.to0Decimal(100 * tdd / refTDD) + "%") + (if (dummies.contains(
|
message += df.format(Date(record.timestamp)) + " " + rh.gs(R.string.tdd_line, tdd, 100 * tdd / refTDD)
|
||||||
record
|
message += (if (dummies.contains(record)) "x" else "") + "\n"
|
||||||
)
|
|
||||||
) "x" else "") + "\n"
|
|
||||||
}
|
}
|
||||||
return message
|
return message
|
||||||
}
|
}
|
||||||
|
@ -1112,11 +1101,11 @@ class DataHandlerMobile @Inject constructor(
|
||||||
|
|
||||||
val iobString =
|
val iobString =
|
||||||
if (sp.getBoolean(info.nightscout.core.utils.R.string.key_wear_detailediob, false)) "$iobSum $iobDetail"
|
if (sp.getBoolean(info.nightscout.core.utils.R.string.key_wear_detailediob, false)) "$iobSum $iobDetail"
|
||||||
else iobSum + "U"
|
else iobSum + rh.gs(R.string.units_short)
|
||||||
|
|
||||||
status += "$currentBasal $iobString"
|
status += "$currentBasal $iobString"
|
||||||
|
|
||||||
//add BGI if shown, otherwise return
|
// add BGI if shown, otherwise return
|
||||||
if (sp.getBoolean(info.nightscout.core.utils.R.string.key_wear_showbgi, false)) status += " $bgiString"
|
if (sp.getBoolean(info.nightscout.core.utils.R.string.key_wear_showbgi, false)) status += " $bgiString"
|
||||||
return status
|
return status
|
||||||
}
|
}
|
||||||
|
|
|
@ -402,5 +402,32 @@
|
||||||
<string name="ongoingnotificaction" translatable="false">Ongoing Notification</string>
|
<string name="ongoingnotificaction" translatable="false">Ongoing Notification</string>
|
||||||
<string name="description_persistent_notification">Shows an ongoing notification with a short overview of what your loop is doing</string>
|
<string name="description_persistent_notification">Shows an ongoing notification with a short overview of what your loop is doing</string>
|
||||||
<string name="old_data">OLD DATA</string>
|
<string name="old_data">OLD DATA</string>
|
||||||
|
<string name="pump_fetching_data">trying to fetch data from pump.</string>
|
||||||
|
<string name="pump_old_data">TDD: Still old data! Cannot load from pump.</string>
|
||||||
|
<string name="grams_short">g</string>
|
||||||
|
<string name="hour_short">h</string>
|
||||||
|
<string name="no_active_profile">No active profile switch!</string>
|
||||||
|
<string name="profile_message">Profile:\n\nTimeshift: %1$\nPercentage: %2$d%\"</string>
|
||||||
|
<string name="key_wear_predictions" translatable="false">wear_predictions</string>
|
||||||
|
<string name="tdd_line">%1$.2fU %1$.0f%</string>
|
||||||
|
<string name="no_profile">No profile loaded</string>
|
||||||
|
<string name="aps_only">Only apply in APS mode!</string>
|
||||||
|
<string name="last_aps_result_na">Last result not available!</string>
|
||||||
|
<string name="loop_status_closed">CLOSED LOOP</string>
|
||||||
|
<string name="loop_status_open">OPEN LOOP</string>
|
||||||
|
<string name="loop_status_disabled">LOOP DISABLED</string>
|
||||||
|
<string name="aps">APS</string>
|
||||||
|
<string name="last_run">Last run</string>
|
||||||
|
<string name="last_enact">Last Enact</string>
|
||||||
|
<string name="today">Today</string>
|
||||||
|
<string name="weighted">weighted</string>
|
||||||
|
<string name="target_only_aps_mode">Targets only apply in APS mode!</string>
|
||||||
|
<string name="no_history">No history data!</string>
|
||||||
|
<string name="units_short">U</string>
|
||||||
|
<string name="temp_target">Temp Target</string>
|
||||||
|
<string name="until">until</string>
|
||||||
|
<string name="default_range">DEFAULT RANGE</string>
|
||||||
|
<string name="target">target</string>
|
||||||
|
<string name="rate_duration">Rate: %1$.2fU/h (%2$.2f%) \nDuration %3$d% min</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -86,9 +86,9 @@ abstract class BaseComplicationProviderService : ComplicationProviderService() {
|
||||||
}
|
}
|
||||||
when (dataType) {
|
when (dataType) {
|
||||||
ComplicationData.TYPE_ICON, ComplicationData.TYPE_SHORT_TEXT, ComplicationData.TYPE_RANGED_VALUE -> if (since > 0) {
|
ComplicationData.TYPE_ICON, ComplicationData.TYPE_SHORT_TEXT, ComplicationData.TYPE_RANGED_VALUE -> if (since > 0) {
|
||||||
builder.setShortText(ComplicationText.plainText(displayFormat.shortTimeSince(since) + " old"))
|
builder.setShortText(ComplicationText.plainText(displayFormat.shortTimeSince(since) + " " + getString(R.string.old)))
|
||||||
} else {
|
} else {
|
||||||
builder.setShortText(ComplicationText.plainText("!err!"))
|
builder.setShortText(ComplicationText.plainText(getString(R.string.error)))
|
||||||
}
|
}
|
||||||
|
|
||||||
ComplicationData.TYPE_LONG_TEXT -> {
|
ComplicationData.TYPE_LONG_TEXT -> {
|
||||||
|
@ -126,9 +126,9 @@ abstract class BaseComplicationProviderService : ComplicationProviderService() {
|
||||||
}
|
}
|
||||||
when (dataType) {
|
when (dataType) {
|
||||||
ComplicationData.TYPE_ICON, ComplicationData.TYPE_SHORT_TEXT, ComplicationData.TYPE_RANGED_VALUE -> if (since > 0) {
|
ComplicationData.TYPE_ICON, ComplicationData.TYPE_SHORT_TEXT, ComplicationData.TYPE_RANGED_VALUE -> if (since > 0) {
|
||||||
builder.setShortText(ComplicationText.plainText(displayFormat.shortTimeSince(since) + " old"))
|
builder.setShortText(ComplicationText.plainText(displayFormat.shortTimeSince(since) + " " + getString(R.string.old)))
|
||||||
} else {
|
} else {
|
||||||
builder.setShortText(ComplicationText.plainText("!old!"))
|
builder.setShortText(ComplicationText.plainText(getString(R.string.old_warning)))
|
||||||
}
|
}
|
||||||
|
|
||||||
ComplicationData.TYPE_LONG_TEXT -> {
|
ComplicationData.TYPE_LONG_TEXT -> {
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package info.nightscout.androidaps.interaction.utils
|
package info.nightscout.androidaps.interaction.utils
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.interaction.utils.Pair.Companion.create
|
import info.nightscout.androidaps.interaction.utils.Pair.Companion.create
|
||||||
import javax.inject.Singleton
|
import javax.inject.Singleton
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
@ -20,6 +22,7 @@ class DisplayFormat @Inject internal constructor() {
|
||||||
|
|
||||||
@Inject lateinit var sp: SP
|
@Inject lateinit var sp: SP
|
||||||
@Inject lateinit var wearUtil: WearUtil
|
@Inject lateinit var wearUtil: WearUtil
|
||||||
|
@Inject lateinit var context: Context
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Maximal and minimal lengths of fields/labels shown in complications, in characters
|
* Maximal and minimal lengths of fields/labels shown in complications, in characters
|
||||||
|
@ -44,14 +47,14 @@ class DisplayFormat @Inject internal constructor() {
|
||||||
"$minutes'"
|
"$minutes'"
|
||||||
} else if (deltaTimeMs < Constants.DAY_IN_MS) {
|
} else if (deltaTimeMs < Constants.DAY_IN_MS) {
|
||||||
val hours = (deltaTimeMs / Constants.HOUR_IN_MS).toInt()
|
val hours = (deltaTimeMs / Constants.HOUR_IN_MS).toInt()
|
||||||
hours.toString() + "h"
|
hours.toString() + context.getString(R.string.hour_short)
|
||||||
} else {
|
} else {
|
||||||
val days = (deltaTimeMs / Constants.DAY_IN_MS).toInt()
|
val days = (deltaTimeMs / Constants.DAY_IN_MS).toInt()
|
||||||
if (days < 7) {
|
if (days < 7) {
|
||||||
days.toString() + "d"
|
days.toString() + context.getString(R.string.day_short)
|
||||||
} else {
|
} else {
|
||||||
val weeks = days / 7
|
val weeks = days / 7
|
||||||
weeks.toString() + "w"
|
weeks.toString() + context.getString(R.string.week_short)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -226,5 +226,12 @@
|
||||||
<string name="iob_0_00u">0,00U</string>
|
<string name="iob_0_00u">0,00U</string>
|
||||||
<string name="snooze_alert">AAPS Snooze Alert</string>
|
<string name="snooze_alert">AAPS Snooze Alert</string>
|
||||||
<string name="sending_snooze">Sending Snooze to AAPS</string>
|
<string name="sending_snooze">Sending Snooze to AAPS</string>
|
||||||
|
<string name="short_hour">h</string>
|
||||||
|
<string name="week_short">w</string>
|
||||||
|
<string name="day_short">d</string>
|
||||||
|
<string name="hour_short">h</string>
|
||||||
|
<string name="old">old</string>
|
||||||
|
<string name="old_warning">!old!</string>
|
||||||
|
<string name="error">!err!</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|
Loading…
Reference in a new issue