:core:graph

This commit is contained in:
Milos Kozak 2022-11-22 21:39:19 +01:00
parent cb9ea1d06b
commit fda8498c8e
168 changed files with 799 additions and 568 deletions

View file

@ -188,6 +188,7 @@ dependencies {
implementation project(':app-wear-shared:shared') implementation project(':app-wear-shared:shared')
implementation project(':app-wear-shared:shared-impl') implementation project(':app-wear-shared:shared-impl')
implementation project(':core:core-main') implementation project(':core:core-main')
implementation project(':core:graph')
implementation project(':core:utils') implementation project(':core:utils')
implementation project(':core:ui') implementation project(':core:ui')
implementation project(':interfaces') implementation project(':interfaces')

View file

@ -17,11 +17,11 @@ import info.nightscout.androidaps.plugins.general.overview.OverviewMenus
import info.nightscout.androidaps.plugins.general.overview.events.EventUpdateOverviewGraph import info.nightscout.androidaps.plugins.general.overview.events.EventUpdateOverviewGraph
import info.nightscout.androidaps.plugins.general.overview.graphData.GraphData import info.nightscout.androidaps.plugins.general.overview.graphData.GraphData
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventIobCalculationProgress import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventIobCalculationProgress
import info.nightscout.androidaps.utils.DefaultValueHelper
import info.nightscout.androidaps.workflow.CalculationWorkflow import info.nightscout.androidaps.workflow.CalculationWorkflow
import info.nightscout.core.utils.fabric.FabricPrivacy import info.nightscout.core.utils.fabric.FabricPrivacy
import info.nightscout.interfaces.Config import info.nightscout.interfaces.Config
import info.nightscout.interfaces.plugin.ActivePlugin import info.nightscout.interfaces.plugin.ActivePlugin
import info.nightscout.interfaces.profile.DefaultValueHelper
import info.nightscout.rx.AapsSchedulers import info.nightscout.rx.AapsSchedulers
import info.nightscout.rx.events.EventAutosensCalculationFinished import info.nightscout.rx.events.EventAutosensCalculationFinished
import info.nightscout.rx.events.EventCustomCalculationFinished import info.nightscout.rx.events.EventCustomCalculationFinished

View file

@ -1,13 +1,14 @@
package info.nightscout.androidaps.activities package info.nightscout.androidaps.activities
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.plugins.general.overview.OverviewData
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin
import info.nightscout.androidaps.utils.DefaultValueHelper
import info.nightscout.androidaps.workflow.CalculationWorkflow import info.nightscout.androidaps.workflow.CalculationWorkflow
import info.nightscout.core.graph.OverviewData
import info.nightscout.core.utils.fabric.FabricPrivacy import info.nightscout.core.utils.fabric.FabricPrivacy
import info.nightscout.database.impl.AppRepository import info.nightscout.database.impl.AppRepository
import info.nightscout.implementation.overview.OverviewDataImpl
import info.nightscout.interfaces.plugin.ActivePlugin import info.nightscout.interfaces.plugin.ActivePlugin
import info.nightscout.interfaces.profile.DefaultValueHelper
import info.nightscout.interfaces.profile.ProfileFunction import info.nightscout.interfaces.profile.ProfileFunction
import info.nightscout.rx.AapsSchedulers import info.nightscout.rx.AapsSchedulers
import info.nightscout.rx.bus.RxBus import info.nightscout.rx.bus.RxBus
@ -41,7 +42,7 @@ class HistoryBrowserData @Inject constructor(
init { init {
// We don't want to use injected singletons but own instance working on top of different data // We don't want to use injected singletons but own instance working on top of different data
overviewData = overviewData =
OverviewData( OverviewDataImpl(
aapsLogger, aapsLogger,
rh, rh,
dateUtil, dateUtil,

View file

@ -31,7 +31,6 @@ import info.nightscout.androidaps.plugins.pump.eopatch.EopatchPumpPlugin
import info.nightscout.androidaps.plugins.pump.insight.LocalInsightPlugin import info.nightscout.androidaps.plugins.pump.insight.LocalInsightPlugin
import info.nightscout.androidaps.plugins.pump.medtronic.MedtronicPumpPlugin import info.nightscout.androidaps.plugins.pump.medtronic.MedtronicPumpPlugin
import info.nightscout.automation.AutomationPlugin import info.nightscout.automation.AutomationPlugin
import info.nightscout.core.profile.toCurrentUnits
import info.nightscout.core.ui.dialogs.OKDialog import info.nightscout.core.ui.dialogs.OKDialog
import info.nightscout.interfaces.Config import info.nightscout.interfaces.Config
import info.nightscout.interfaces.plugin.PluginBase import info.nightscout.interfaces.plugin.PluginBase

View file

@ -15,9 +15,9 @@ import info.nightscout.androidaps.diaconn.database.DiaconnHistoryDatabase
import info.nightscout.androidaps.insight.database.InsightDatabase import info.nightscout.androidaps.insight.database.InsightDatabase
import info.nightscout.androidaps.logging.UserEntryLogger import info.nightscout.androidaps.logging.UserEntryLogger
import info.nightscout.androidaps.plugins.general.maintenance.activities.LogSettingActivity import info.nightscout.androidaps.plugins.general.maintenance.activities.LogSettingActivity
import info.nightscout.androidaps.plugins.general.overview.OverviewData
import info.nightscout.androidaps.plugins.pump.omnipod.dash.history.database.DashHistoryDatabase import info.nightscout.androidaps.plugins.pump.omnipod.dash.history.database.DashHistoryDatabase
import info.nightscout.androidaps.plugins.pump.omnipod.eros.history.database.ErosHistoryDatabase import info.nightscout.androidaps.plugins.pump.omnipod.eros.history.database.ErosHistoryDatabase
import info.nightscout.core.graph.OverviewData
import info.nightscout.core.ui.dialogs.OKDialog import info.nightscout.core.ui.dialogs.OKDialog
import info.nightscout.core.utils.fabric.FabricPrivacy import info.nightscout.core.utils.fabric.FabricPrivacy
import info.nightscout.database.entities.UserEntry.Action import info.nightscout.database.entities.UserEntry.Action

View file

@ -42,12 +42,9 @@ import info.nightscout.androidaps.plugins.general.overview.events.EventUpdateOve
import info.nightscout.androidaps.plugins.general.overview.graphData.GraphData import info.nightscout.androidaps.plugins.general.overview.graphData.GraphData
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatusProvider import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatusProvider
import info.nightscout.androidaps.plugins.pump.omnipod.eros.OmnipodErosPumpPlugin import info.nightscout.androidaps.plugins.pump.omnipod.eros.OmnipodErosPumpPlugin
import info.nightscout.androidaps.utils.DefaultValueHelper
import info.nightscout.automation.AutomationPlugin import info.nightscout.automation.AutomationPlugin
import info.nightscout.core.graph.OverviewData
import info.nightscout.core.iob.displayText import info.nightscout.core.iob.displayText
import info.nightscout.core.profile.toSignedUnitsString
import info.nightscout.core.profile.toTargetRangeString
import info.nightscout.core.profile.toUnits
import info.nightscout.core.ui.UIRunnable import info.nightscout.core.ui.UIRunnable
import info.nightscout.core.ui.dialogs.OKDialog import info.nightscout.core.ui.dialogs.OKDialog
import info.nightscout.core.ui.elements.SingleClickButton import info.nightscout.core.ui.elements.SingleClickButton
@ -67,6 +64,7 @@ import info.nightscout.interfaces.constraints.Constraints
import info.nightscout.interfaces.iob.IobCobCalculator import info.nightscout.interfaces.iob.IobCobCalculator
import info.nightscout.interfaces.plugin.ActivePlugin import info.nightscout.interfaces.plugin.ActivePlugin
import info.nightscout.interfaces.plugin.PluginBase import info.nightscout.interfaces.plugin.PluginBase
import info.nightscout.interfaces.profile.DefaultValueHelper
import info.nightscout.interfaces.profile.Profile import info.nightscout.interfaces.profile.Profile
import info.nightscout.interfaces.profile.ProfileFunction import info.nightscout.interfaces.profile.ProfileFunction
import info.nightscout.interfaces.protection.ProtectionCheck import info.nightscout.interfaces.protection.ProtectionCheck
@ -555,7 +553,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
binding.buttonsLayout.quickWizardButton.visibility = View.VISIBLE binding.buttonsLayout.quickWizardButton.visibility = View.VISIBLE
val wizard = quickWizardEntry.doCalc(profile, profileName, lastBG, false) val wizard = quickWizardEntry.doCalc(profile, profileName, lastBG, false)
binding.buttonsLayout.quickWizardButton.text = quickWizardEntry.buttonText() + "\n" + rh.gs(R.string.format_carbs, quickWizardEntry.carbs()) + binding.buttonsLayout.quickWizardButton.text = quickWizardEntry.buttonText() + "\n" + rh.gs(R.string.format_carbs, quickWizardEntry.carbs()) +
" " + rh.gs(R.string.formatinsulinunits, wizard.calculatedTotalInsulin) " " + rh.gs(R.string.format_insulin_units, wizard.calculatedTotalInsulin)
if (wizard.calculatedTotalInsulin <= 0) binding.buttonsLayout.quickWizardButton.visibility = View.GONE if (wizard.calculatedTotalInsulin <= 0) binding.buttonsLayout.quickWizardButton.visibility = View.GONE
} else binding.buttonsLayout.quickWizardButton.visibility = View.GONE } else binding.buttonsLayout.quickWizardButton.visibility = View.GONE
} }

View file

@ -16,6 +16,7 @@ import info.nightscout.androidaps.plugins.general.overview.events.EventDismissNo
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification
import info.nightscout.androidaps.plugins.general.overview.events.EventUpdateOverviewCalcProgress import info.nightscout.androidaps.plugins.general.overview.events.EventUpdateOverviewCalcProgress
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventIobCalculationProgress import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventIobCalculationProgress
import info.nightscout.core.graph.OverviewData
import info.nightscout.core.ui.dialogs.OKDialog import info.nightscout.core.ui.dialogs.OKDialog
import info.nightscout.core.utils.fabric.FabricPrivacy import info.nightscout.core.utils.fabric.FabricPrivacy
import info.nightscout.interfaces.Config import info.nightscout.interfaces.Config

View file

@ -9,16 +9,14 @@ import com.jjoe64.graphview.series.LineGraphSeries
import com.jjoe64.graphview.series.Series import com.jjoe64.graphview.series.Series
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.R import info.nightscout.androidaps.R
import info.nightscout.androidaps.plugins.general.overview.OverviewData import info.nightscout.core.graph.OverviewData
import info.nightscout.androidaps.plugins.general.overview.graphExtensions.AreaGraphSeries import info.nightscout.core.graph.data.BolusDataPoint
import info.nightscout.androidaps.plugins.general.overview.graphExtensions.BolusDataPoint import info.nightscout.core.graph.data.EffectiveProfileSwitchDataPoint
import info.nightscout.androidaps.plugins.general.overview.graphExtensions.DoubleDataPoint import info.nightscout.core.graph.data.GlucoseValueDataPoint
import info.nightscout.androidaps.plugins.general.overview.graphExtensions.EffectiveProfileSwitchDataPoint import info.nightscout.core.graph.data.TimeAsXAxisLabelFormatter
import info.nightscout.androidaps.plugins.general.overview.graphExtensions.GlucoseValueDataPoint
import info.nightscout.androidaps.plugins.general.overview.graphExtensions.TimeAsXAxisLabelFormatter
import info.nightscout.androidaps.utils.DefaultValueHelper
import info.nightscout.core.ui.toast.ToastUtils import info.nightscout.core.ui.toast.ToastUtils
import info.nightscout.interfaces.GlucoseUnit import info.nightscout.interfaces.GlucoseUnit
import info.nightscout.interfaces.profile.DefaultValueHelper
import info.nightscout.interfaces.profile.ProfileFunction import info.nightscout.interfaces.profile.ProfileFunction
import info.nightscout.interfaces.utils.Round import info.nightscout.interfaces.utils.Round
import info.nightscout.rx.logging.AAPSLogger import info.nightscout.rx.logging.AAPSLogger
@ -66,10 +64,10 @@ class GraphData(
fun addInRangeArea(fromTime: Long, toTime: Long, lowLine: Double, highLine: Double) { fun addInRangeArea(fromTime: Long, toTime: Long, lowLine: Double, highLine: Double) {
val inRangeAreaDataPoints = arrayOf( val inRangeAreaDataPoints = arrayOf(
DoubleDataPoint(fromTime.toDouble(), lowLine, highLine), info.nightscout.core.graph.data.DoubleDataPoint(fromTime.toDouble(), lowLine, highLine),
DoubleDataPoint(toTime.toDouble(), lowLine, highLine) info.nightscout.core.graph.data.DoubleDataPoint(toTime.toDouble(), lowLine, highLine)
) )
addSeries(AreaGraphSeries(inRangeAreaDataPoints).also { addSeries(info.nightscout.core.graph.data.AreaGraphSeries(inRangeAreaDataPoints).also {
it.color = 0 it.color = 0
it.isDrawBackground = true it.isDrawBackground = true
it.backgroundColor = rh.gac(graph.context, R.attr.inRangeBackground) it.backgroundColor = rh.gac(graph.context, R.attr.inRangeBackground)

View file

@ -11,10 +11,8 @@ import info.nightscout.androidaps.R
import info.nightscout.androidaps.extensions.toStringShort import info.nightscout.androidaps.extensions.toStringShort
import info.nightscout.androidaps.extensions.valueToUnitsString import info.nightscout.androidaps.extensions.valueToUnitsString
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatusProvider import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatusProvider
import info.nightscout.androidaps.utils.DecimalFormatter
import info.nightscout.core.iob.generateCOBString import info.nightscout.core.iob.generateCOBString
import info.nightscout.core.iob.round import info.nightscout.core.iob.round
import info.nightscout.core.profile.toSignedUnitsString
import info.nightscout.core.utils.fabric.FabricPrivacy import info.nightscout.core.utils.fabric.FabricPrivacy
import info.nightscout.interfaces.Constants import info.nightscout.interfaces.Constants
import info.nightscout.interfaces.NotificationHolder import info.nightscout.interfaces.NotificationHolder
@ -26,6 +24,7 @@ import info.nightscout.interfaces.plugin.PluginType
import info.nightscout.interfaces.profile.Profile import info.nightscout.interfaces.profile.Profile
import info.nightscout.interfaces.profile.ProfileFunction import info.nightscout.interfaces.profile.ProfileFunction
import info.nightscout.interfaces.ui.IconsProvider import info.nightscout.interfaces.ui.IconsProvider
import info.nightscout.interfaces.utils.DecimalFormatter
import info.nightscout.rx.AapsSchedulers import info.nightscout.rx.AapsSchedulers
import info.nightscout.rx.bus.RxBus import info.nightscout.rx.bus.RxBus
import info.nightscout.rx.events.EventAutosensCalculationFinished import info.nightscout.rx.events.EventAutosensCalculationFinished

View file

@ -10,19 +10,14 @@ import info.nightscout.androidaps.extensions.total
import info.nightscout.androidaps.extensions.valueToUnits import info.nightscout.androidaps.extensions.valueToUnits
import info.nightscout.androidaps.extensions.valueToUnitsString import info.nightscout.androidaps.extensions.valueToUnitsString
import info.nightscout.androidaps.logging.UserEntryLogger import info.nightscout.androidaps.logging.UserEntryLogger
import info.nightscout.androidaps.plugins.general.overview.graphExtensions.GlucoseValueDataPoint
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatusProvider import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatusProvider
import info.nightscout.core.utils.receivers.ReceiverStatusStore
import info.nightscout.androidaps.services.AlarmSoundServiceHelper import info.nightscout.androidaps.services.AlarmSoundServiceHelper
import info.nightscout.androidaps.utils.DecimalFormatter import info.nightscout.core.graph.data.GlucoseValueDataPoint
import info.nightscout.androidaps.utils.DefaultValueHelper
import info.nightscout.core.iob.generateCOBString import info.nightscout.core.iob.generateCOBString
import info.nightscout.core.iob.round import info.nightscout.core.iob.round
import info.nightscout.core.profile.fromMgdlToUnits
import info.nightscout.core.profile.toMgdl
import info.nightscout.core.profile.toTargetRangeString
import info.nightscout.core.ui.toast.ToastUtils import info.nightscout.core.ui.toast.ToastUtils
import info.nightscout.core.utils.fabric.FabricPrivacy import info.nightscout.core.utils.fabric.FabricPrivacy
import info.nightscout.core.utils.receivers.ReceiverStatusStore
import info.nightscout.core.wizard.BolusWizard 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
@ -47,11 +42,13 @@ import info.nightscout.interfaces.constraints.Constraints
import info.nightscout.interfaces.iob.IobCobCalculator import info.nightscout.interfaces.iob.IobCobCalculator
import info.nightscout.interfaces.plugin.ActivePlugin import info.nightscout.interfaces.plugin.ActivePlugin
import info.nightscout.interfaces.plugin.PluginBase import info.nightscout.interfaces.plugin.PluginBase
import info.nightscout.interfaces.profile.DefaultValueHelper
import info.nightscout.interfaces.profile.Profile import info.nightscout.interfaces.profile.Profile
import info.nightscout.interfaces.profile.ProfileFunction import info.nightscout.interfaces.profile.ProfileFunction
import info.nightscout.interfaces.pump.DetailedBolusInfo import info.nightscout.interfaces.pump.DetailedBolusInfo
import info.nightscout.interfaces.queue.Callback import info.nightscout.interfaces.queue.Callback
import info.nightscout.interfaces.queue.CommandQueue import info.nightscout.interfaces.queue.CommandQueue
import info.nightscout.interfaces.utils.DecimalFormatter
import info.nightscout.interfaces.utils.HardLimits import info.nightscout.interfaces.utils.HardLimits
import info.nightscout.interfaces.utils.TrendCalculator import info.nightscout.interfaces.utils.TrendCalculator
import info.nightscout.plugins.sync.nsclient.data.ProcessedDeviceStatusData import info.nightscout.plugins.sync.nsclient.data.ProcessedDeviceStatusData

View file

@ -18,14 +18,14 @@ import dagger.android.AndroidInjection
import info.nightscout.androidaps.R import info.nightscout.androidaps.R
import info.nightscout.androidaps.plugins.general.wear.WearPlugin import info.nightscout.androidaps.plugins.general.wear.WearPlugin
import info.nightscout.androidaps.plugins.general.wear.events.EventWearUpdateGui import info.nightscout.androidaps.plugins.general.wear.events.EventWearUpdateGui
import info.nightscout.core.utils.receivers.ReceiverStatusStore
import info.nightscout.androidaps.utils.DefaultValueHelper
import info.nightscout.core.utils.fabric.FabricPrivacy import info.nightscout.core.utils.fabric.FabricPrivacy
import info.nightscout.core.utils.receivers.ReceiverStatusStore
import info.nightscout.database.impl.AppRepository import info.nightscout.database.impl.AppRepository
import info.nightscout.interfaces.Config import info.nightscout.interfaces.Config
import info.nightscout.interfaces.aps.Loop import info.nightscout.interfaces.aps.Loop
import info.nightscout.interfaces.iob.IobCobCalculator import info.nightscout.interfaces.iob.IobCobCalculator
import info.nightscout.interfaces.plugin.ActivePlugin import info.nightscout.interfaces.plugin.ActivePlugin
import info.nightscout.interfaces.profile.DefaultValueHelper
import info.nightscout.interfaces.profile.ProfileFunction import info.nightscout.interfaces.profile.ProfileFunction
import info.nightscout.rx.AapsSchedulers import info.nightscout.rx.AapsSchedulers
import info.nightscout.rx.bus.RxBus import info.nightscout.rx.bus.RxBus

View file

@ -10,9 +10,8 @@ import info.nightscout.androidaps.events.EventNewHistoryData
import info.nightscout.androidaps.extensions.convertedToAbsolute import info.nightscout.androidaps.extensions.convertedToAbsolute
import info.nightscout.androidaps.extensions.iobCalc import info.nightscout.androidaps.extensions.iobCalc
import info.nightscout.androidaps.extensions.toTemporaryBasal import info.nightscout.androidaps.extensions.toTemporaryBasal
import info.nightscout.androidaps.plugins.general.overview.OverviewData
import info.nightscout.androidaps.utils.DecimalFormatter
import info.nightscout.androidaps.workflow.CalculationWorkflow import info.nightscout.androidaps.workflow.CalculationWorkflow
import info.nightscout.core.graph.OverviewData
import info.nightscout.core.iob.combine import info.nightscout.core.iob.combine
import info.nightscout.core.iob.copy import info.nightscout.core.iob.copy
import info.nightscout.core.iob.determineBasalJson import info.nightscout.core.iob.determineBasalJson
@ -40,6 +39,7 @@ import info.nightscout.interfaces.plugin.PluginDescription
import info.nightscout.interfaces.plugin.PluginType import info.nightscout.interfaces.plugin.PluginType
import info.nightscout.interfaces.profile.Profile import info.nightscout.interfaces.profile.Profile
import info.nightscout.interfaces.profile.ProfileFunction import info.nightscout.interfaces.profile.ProfileFunction
import info.nightscout.interfaces.utils.DecimalFormatter
import info.nightscout.interfaces.utils.MidnightTime import info.nightscout.interfaces.utils.MidnightTime
import info.nightscout.rx.AapsSchedulers import info.nightscout.rx.AapsSchedulers
import info.nightscout.rx.bus.RxBus import info.nightscout.rx.bus.RxBus

View file

@ -11,7 +11,6 @@ import info.nightscout.androidaps.extensions.target
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.data.AutosensDataObject import info.nightscout.androidaps.plugins.iob.iobCobCalculator.data.AutosensDataObject
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventIobCalculationProgress import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventIobCalculationProgress
import info.nightscout.androidaps.utils.DecimalFormatter
import info.nightscout.androidaps.workflow.CalculationWorkflow import info.nightscout.androidaps.workflow.CalculationWorkflow
import info.nightscout.core.utils.fabric.FabricPrivacy import info.nightscout.core.utils.fabric.FabricPrivacy
import info.nightscout.core.utils.receivers.DataWorkerStorage import info.nightscout.core.utils.receivers.DataWorkerStorage
@ -26,6 +25,7 @@ import info.nightscout.interfaces.notifications.Notification
import info.nightscout.interfaces.plugin.ActivePlugin import info.nightscout.interfaces.plugin.ActivePlugin
import info.nightscout.interfaces.profile.ProfileFunction import info.nightscout.interfaces.profile.ProfileFunction
import info.nightscout.interfaces.profiling.Profiler import info.nightscout.interfaces.profiling.Profiler
import info.nightscout.interfaces.utils.DecimalFormatter
import info.nightscout.rx.bus.RxBus import info.nightscout.rx.bus.RxBus
import info.nightscout.rx.events.Event import info.nightscout.rx.events.Event
import info.nightscout.rx.events.EventAutosensCalculationFinished import info.nightscout.rx.events.EventAutosensCalculationFinished

View file

@ -10,7 +10,6 @@ import info.nightscout.androidaps.R
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.data.AutosensDataObject import info.nightscout.androidaps.plugins.iob.iobCobCalculator.data.AutosensDataObject
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventIobCalculationProgress import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventIobCalculationProgress
import info.nightscout.androidaps.utils.DecimalFormatter
import info.nightscout.androidaps.workflow.CalculationWorkflow import info.nightscout.androidaps.workflow.CalculationWorkflow
import info.nightscout.core.utils.fabric.FabricPrivacy import info.nightscout.core.utils.fabric.FabricPrivacy
import info.nightscout.core.utils.receivers.DataWorkerStorage import info.nightscout.core.utils.receivers.DataWorkerStorage
@ -24,6 +23,7 @@ import info.nightscout.interfaces.notifications.Notification
import info.nightscout.interfaces.plugin.ActivePlugin import info.nightscout.interfaces.plugin.ActivePlugin
import info.nightscout.interfaces.profile.ProfileFunction import info.nightscout.interfaces.profile.ProfileFunction
import info.nightscout.interfaces.profiling.Profiler import info.nightscout.interfaces.profiling.Profiler
import info.nightscout.interfaces.utils.DecimalFormatter
import info.nightscout.rx.bus.RxBus import info.nightscout.rx.bus.RxBus
import info.nightscout.rx.events.Event import info.nightscout.rx.events.Event
import info.nightscout.rx.events.EventAutosensCalculationFinished import info.nightscout.rx.events.EventAutosensCalculationFinished

View file

@ -11,10 +11,10 @@ import androidx.work.WorkManager
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.R import info.nightscout.androidaps.R
import info.nightscout.androidaps.events.EventNewHistoryData import info.nightscout.androidaps.events.EventNewHistoryData
import info.nightscout.androidaps.plugins.general.overview.OverviewData
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobOref1Worker import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobOref1Worker
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobOrefWorker import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobOrefWorker
import info.nightscout.core.graph.OverviewData
import info.nightscout.core.utils.fabric.FabricPrivacy import info.nightscout.core.utils.fabric.FabricPrivacy
import info.nightscout.core.utils.receivers.DataWorkerStorage import info.nightscout.core.utils.receivers.DataWorkerStorage
import info.nightscout.interfaces.iob.IobCobCalculator import info.nightscout.interfaces.iob.IobCobCalculator

View file

@ -9,9 +9,9 @@ import androidx.work.workDataOf
import com.jjoe64.graphview.series.LineGraphSeries import com.jjoe64.graphview.series.LineGraphSeries
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.R import info.nightscout.androidaps.R
import info.nightscout.androidaps.plugins.general.overview.OverviewData
import info.nightscout.androidaps.plugins.general.overview.graphExtensions.ScaledDataPoint
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventIobCalculationProgress import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventIobCalculationProgress
import info.nightscout.core.graph.OverviewData
import info.nightscout.core.graph.data.ScaledDataPoint
import info.nightscout.core.utils.receivers.DataWorkerStorage import info.nightscout.core.utils.receivers.DataWorkerStorage
import info.nightscout.interfaces.iob.IobCobCalculator import info.nightscout.interfaces.iob.IobCobCalculator
import info.nightscout.interfaces.profile.ProfileFunction import info.nightscout.interfaces.profile.ProfileFunction
@ -28,7 +28,7 @@ class PrepareBasalDataWorker(
@Inject lateinit var profileFunction: ProfileFunction @Inject lateinit var profileFunction: ProfileFunction
@Inject lateinit var rh: ResourceHelper @Inject lateinit var rh: ResourceHelper
@Inject lateinit var rxBus: RxBus @Inject lateinit var rxBus: RxBus
var ctx: Context private var ctx: Context
init { init {
(context.applicationContext as HasAndroidInjector).androidInjector().inject(this) (context.applicationContext as HasAndroidInjector).androidInjector().inject(this)
ctx = rh.getThemedCtx(context) ctx = rh.getThemedCtx(context)

View file

@ -5,16 +5,15 @@ import androidx.work.Worker
import androidx.work.WorkerParameters import androidx.work.WorkerParameters
import androidx.work.workDataOf import androidx.work.workDataOf
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.plugins.general.overview.OverviewData import info.nightscout.core.graph.OverviewData
import info.nightscout.androidaps.plugins.general.overview.graphExtensions.DataPointWithLabelInterface import info.nightscout.core.graph.data.DataPointWithLabelInterface
import info.nightscout.androidaps.plugins.general.overview.graphExtensions.GlucoseValueDataPoint import info.nightscout.core.graph.data.GlucoseValueDataPoint
import info.nightscout.androidaps.plugins.general.overview.graphExtensions.PointsWithLabelGraphSeries import info.nightscout.core.graph.data.PointsWithLabelGraphSeries
import info.nightscout.core.utils.receivers.DataWorkerStorage import info.nightscout.core.utils.receivers.DataWorkerStorage
import info.nightscout.androidaps.utils.DefaultValueHelper
import info.nightscout.core.profile.fromMgdlToUnits
import info.nightscout.database.impl.AppRepository import info.nightscout.database.impl.AppRepository
import info.nightscout.interfaces.GlucoseUnit import info.nightscout.interfaces.GlucoseUnit
import info.nightscout.interfaces.iob.IobCobCalculator import info.nightscout.interfaces.iob.IobCobCalculator
import info.nightscout.interfaces.profile.DefaultValueHelper
import info.nightscout.interfaces.profile.Profile import info.nightscout.interfaces.profile.Profile
import info.nightscout.interfaces.profile.ProfileFunction import info.nightscout.interfaces.profile.ProfileFunction
import info.nightscout.interfaces.utils.Round import info.nightscout.interfaces.utils.Round

View file

@ -5,10 +5,10 @@ import androidx.work.Worker
import androidx.work.WorkerParameters import androidx.work.WorkerParameters
import androidx.work.workDataOf import androidx.work.workDataOf
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.plugins.general.overview.OverviewData import info.nightscout.core.graph.OverviewData
import info.nightscout.androidaps.plugins.general.overview.graphExtensions.DataPointWithLabelInterface import info.nightscout.core.graph.data.DataPointWithLabelInterface
import info.nightscout.androidaps.plugins.general.overview.graphExtensions.InMemoryGlucoseValueDataPoint import info.nightscout.core.graph.data.InMemoryGlucoseValueDataPoint
import info.nightscout.androidaps.plugins.general.overview.graphExtensions.PointsWithLabelGraphSeries import info.nightscout.core.graph.data.PointsWithLabelGraphSeries
import info.nightscout.core.utils.receivers.DataWorkerStorage import info.nightscout.core.utils.receivers.DataWorkerStorage
import info.nightscout.interfaces.iob.IobCobCalculator import info.nightscout.interfaces.iob.IobCobCalculator
import info.nightscout.interfaces.profile.ProfileFunction import info.nightscout.interfaces.profile.ProfileFunction

View file

@ -10,19 +10,19 @@ import com.jjoe64.graphview.series.BarGraphSeries
import com.jjoe64.graphview.series.LineGraphSeries import com.jjoe64.graphview.series.LineGraphSeries
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.R import info.nightscout.androidaps.R
import info.nightscout.androidaps.plugins.general.overview.OverviewData
import info.nightscout.androidaps.plugins.general.overview.OverviewMenus import info.nightscout.androidaps.plugins.general.overview.OverviewMenus
import info.nightscout.androidaps.plugins.general.overview.graphExtensions.DataPointWithLabelInterface
import info.nightscout.androidaps.plugins.general.overview.graphExtensions.DeviationDataPoint
import info.nightscout.androidaps.plugins.general.overview.graphExtensions.FixedLineGraphSeries
import info.nightscout.androidaps.plugins.general.overview.graphExtensions.PointsWithLabelGraphSeries
import info.nightscout.androidaps.plugins.general.overview.graphExtensions.ScaledDataPoint
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.data.AutosensDataObject import info.nightscout.androidaps.plugins.iob.iobCobCalculator.data.AutosensDataObject
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventIobCalculationProgress import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventIobCalculationProgress
import info.nightscout.core.utils.receivers.DataWorkerStorage import info.nightscout.core.graph.OverviewData
import info.nightscout.androidaps.utils.DecimalFormatter import info.nightscout.core.graph.data.DataPointWithLabelInterface
import info.nightscout.core.graph.data.DeviationDataPoint
import info.nightscout.core.graph.data.FixedLineGraphSeries
import info.nightscout.core.graph.data.PointsWithLabelGraphSeries
import info.nightscout.core.graph.data.Scale
import info.nightscout.core.graph.data.ScaledDataPoint
import info.nightscout.core.iob.combine import info.nightscout.core.iob.combine
import info.nightscout.core.iob.copy import info.nightscout.core.iob.copy
import info.nightscout.core.utils.receivers.DataWorkerStorage
import info.nightscout.database.impl.AppRepository import info.nightscout.database.impl.AppRepository
import info.nightscout.database.impl.ValueWrapper import info.nightscout.database.impl.ValueWrapper
import info.nightscout.interfaces.aps.AutosensResult import info.nightscout.interfaces.aps.AutosensResult
@ -30,6 +30,7 @@ import info.nightscout.interfaces.aps.SMBDefaults
import info.nightscout.interfaces.iob.IobCobCalculator import info.nightscout.interfaces.iob.IobCobCalculator
import info.nightscout.interfaces.iob.IobTotal import info.nightscout.interfaces.iob.IobTotal
import info.nightscout.interfaces.profile.ProfileFunction import info.nightscout.interfaces.profile.ProfileFunction
import info.nightscout.interfaces.utils.DecimalFormatter
import info.nightscout.rx.bus.RxBus import info.nightscout.rx.bus.RxBus
import info.nightscout.rx.logging.AAPSLogger import info.nightscout.rx.logging.AAPSLogger
import info.nightscout.rx.logging.LTag import info.nightscout.rx.logging.LTag
@ -53,7 +54,7 @@ class PrepareIobAutosensGraphDataWorker(
@Inject lateinit var aapsLogger: AAPSLogger @Inject lateinit var aapsLogger: AAPSLogger
@Inject lateinit var repository: AppRepository @Inject lateinit var repository: AppRepository
@Inject lateinit var rxBus: RxBus @Inject lateinit var rxBus: RxBus
var ctx: Context private var ctx: Context
init { init {
(context.applicationContext as HasAndroidInjector).androidInjector().inject(this) (context.applicationContext as HasAndroidInjector).androidInjector().inject(this)
@ -96,6 +97,25 @@ class PrepareIobAutosensGraphDataWorker(
} }
} }
class AutosensDataPoint(
private val ad: AutosensDataObject,
private val scale: Scale,
private val chartTime: Long,
private val rh: ResourceHelper
) : DataPointWithLabelInterface {
override fun getX(): Double = chartTime.toDouble()
override fun getY(): Double = scale.transform(ad.cob)
override fun setY(y: Double) {}
override val label: String = ""
override val duration = 0L
override val shape = PointsWithLabelGraphSeries.Shape.COB_FAIL_OVER
override val size = 0.5f
override fun color(context: Context?): Int {
return rh.gac(context, R.attr.cobColor)
}
}
override fun doWork(): Result { override fun doWork(): Result {
val data = dataWorkerStorage.pickupObject(inputData.getLong(DataWorkerStorage.STORE_KEY, -1)) as PrepareIobAutosensData? val data = dataWorkerStorage.pickupObject(inputData.getLong(DataWorkerStorage.STORE_KEY, -1)) as PrepareIobAutosensData?
?: return Result.failure(workDataOf("Error" to "missing input data")) ?: return Result.failure(workDataOf("Error" to "missing input data"))
@ -171,9 +191,7 @@ class PrepareIobAutosensGraphDataWorker(
lastCob = cob lastCob = cob
} }
if (autosensData.failOverToMinAbsorptionRate) { if (autosensData.failOverToMinAbsorptionRate) {
autosensData.scale = data.overviewData.cobScale minFailOverActiveList.add(AutosensDataPoint(autosensData, data.overviewData.cobScale, time, rh))
autosensData.chartTime = time
minFailOverActiveList.add(autosensData)
} }
} }

View file

@ -5,16 +5,16 @@ import androidx.work.Worker
import androidx.work.WorkerParameters import androidx.work.WorkerParameters
import androidx.work.workDataOf import androidx.work.workDataOf
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.plugins.general.overview.OverviewData
import info.nightscout.androidaps.plugins.general.overview.OverviewMenus import info.nightscout.androidaps.plugins.general.overview.OverviewMenus
import info.nightscout.androidaps.plugins.general.overview.graphExtensions.DataPointWithLabelInterface import info.nightscout.core.graph.OverviewData
import info.nightscout.androidaps.plugins.general.overview.graphExtensions.GlucoseValueDataPoint import info.nightscout.core.graph.data.DataPointWithLabelInterface
import info.nightscout.androidaps.plugins.general.overview.graphExtensions.PointsWithLabelGraphSeries import info.nightscout.core.graph.data.GlucoseValueDataPoint
import info.nightscout.core.graph.data.PointsWithLabelGraphSeries
import info.nightscout.core.utils.receivers.DataWorkerStorage import info.nightscout.core.utils.receivers.DataWorkerStorage
import info.nightscout.androidaps.utils.DefaultValueHelper
import info.nightscout.database.impl.AppRepository import info.nightscout.database.impl.AppRepository
import info.nightscout.interfaces.Config import info.nightscout.interfaces.Config
import info.nightscout.interfaces.aps.Loop import info.nightscout.interfaces.aps.Loop
import info.nightscout.interfaces.profile.DefaultValueHelper
import info.nightscout.interfaces.profile.ProfileFunction import info.nightscout.interfaces.profile.ProfileFunction
import info.nightscout.plugins.sync.nsclient.data.ProcessedDeviceStatusData import info.nightscout.plugins.sync.nsclient.data.ProcessedDeviceStatusData
import info.nightscout.rx.bus.RxBus import info.nightscout.rx.bus.RxBus

View file

@ -9,10 +9,9 @@ import com.jjoe64.graphview.series.LineGraphSeries
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.R import info.nightscout.androidaps.R
import info.nightscout.androidaps.extensions.target import info.nightscout.androidaps.extensions.target
import info.nightscout.androidaps.plugins.general.overview.OverviewData
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventIobCalculationProgress import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventIobCalculationProgress
import info.nightscout.core.graph.OverviewData
import info.nightscout.core.utils.receivers.DataWorkerStorage import info.nightscout.core.utils.receivers.DataWorkerStorage
import info.nightscout.core.profile.fromMgdlToUnits
import info.nightscout.database.impl.AppRepository import info.nightscout.database.impl.AppRepository
import info.nightscout.database.impl.ValueWrapper import info.nightscout.database.impl.ValueWrapper
import info.nightscout.interfaces.aps.Loop import info.nightscout.interfaces.aps.Loop

View file

@ -5,24 +5,23 @@ import androidx.work.Worker
import androidx.work.WorkerParameters import androidx.work.WorkerParameters
import androidx.work.workDataOf import androidx.work.workDataOf
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.plugins.general.overview.OverviewData
import info.nightscout.androidaps.plugins.general.overview.graphExtensions.BolusDataPoint
import info.nightscout.androidaps.plugins.general.overview.graphExtensions.CarbsDataPoint
import info.nightscout.androidaps.plugins.general.overview.graphExtensions.DataPointWithLabelInterface
import info.nightscout.androidaps.plugins.general.overview.graphExtensions.EffectiveProfileSwitchDataPoint
import info.nightscout.androidaps.plugins.general.overview.graphExtensions.ExtendedBolusDataPoint
import info.nightscout.androidaps.plugins.general.overview.graphExtensions.PointsWithLabelGraphSeries
import info.nightscout.androidaps.plugins.general.overview.graphExtensions.TherapyEventDataPoint
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventIobCalculationProgress import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventIobCalculationProgress
import info.nightscout.core.graph.OverviewData
import info.nightscout.core.graph.data.BolusDataPoint
import info.nightscout.core.graph.data.CarbsDataPoint
import info.nightscout.core.graph.data.DataPointWithLabelInterface
import info.nightscout.core.graph.data.EffectiveProfileSwitchDataPoint
import info.nightscout.core.graph.data.ExtendedBolusDataPoint
import info.nightscout.core.graph.data.PointsWithLabelGraphSeries
import info.nightscout.core.graph.data.TherapyEventDataPoint
import info.nightscout.core.utils.receivers.DataWorkerStorage import info.nightscout.core.utils.receivers.DataWorkerStorage
import info.nightscout.androidaps.utils.DefaultValueHelper
import info.nightscout.androidaps.utils.Translator
import info.nightscout.core.profile.fromMgdlToUnits
import info.nightscout.database.entities.Bolus import info.nightscout.database.entities.Bolus
import info.nightscout.database.entities.TherapyEvent import info.nightscout.database.entities.TherapyEvent
import info.nightscout.database.impl.AppRepository import info.nightscout.database.impl.AppRepository
import info.nightscout.interfaces.GlucoseUnit import info.nightscout.interfaces.GlucoseUnit
import info.nightscout.interfaces.Translator
import info.nightscout.interfaces.plugin.ActivePlugin import info.nightscout.interfaces.plugin.ActivePlugin
import info.nightscout.interfaces.profile.DefaultValueHelper
import info.nightscout.interfaces.profile.Profile import info.nightscout.interfaces.profile.Profile
import info.nightscout.interfaces.profile.ProfileFunction import info.nightscout.interfaces.profile.ProfileFunction
import info.nightscout.interfaces.utils.Round import info.nightscout.interfaces.utils.Round

View file

@ -8,7 +8,6 @@ import info.nightscout.androidaps.extensions.shiftTargetBlock
import info.nightscout.androidaps.extensions.targetBlockValueBySeconds import info.nightscout.androidaps.extensions.targetBlockValueBySeconds
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification
import info.nightscout.core.main.R import info.nightscout.core.main.R
import info.nightscout.core.profile.toMgdl
import info.nightscout.core.utils.MidnightUtils import info.nightscout.core.utils.MidnightUtils
import info.nightscout.database.entities.EffectiveProfileSwitch import info.nightscout.database.entities.EffectiveProfileSwitch
import info.nightscout.database.entities.ProfileSwitch import info.nightscout.database.entities.ProfileSwitch

View file

@ -2,7 +2,6 @@ package info.nightscout.androidaps.extensions
import com.google.gson.Gson import com.google.gson.Gson
import com.google.gson.JsonSyntaxException import com.google.gson.JsonSyntaxException
import info.nightscout.core.profile.fromMgdlToUnits
import info.nightscout.database.entities.BolusCalculatorResult import info.nightscout.database.entities.BolusCalculatorResult
import info.nightscout.interfaces.profile.Profile import info.nightscout.interfaces.profile.Profile
import info.nightscout.interfaces.profile.ProfileFunction import info.nightscout.interfaces.profile.ProfileFunction

View file

@ -1,6 +1,5 @@
package info.nightscout.androidaps.extensions package info.nightscout.androidaps.extensions
import info.nightscout.androidaps.utils.DecimalFormatter
import info.nightscout.database.entities.Bolus import info.nightscout.database.entities.Bolus
import info.nightscout.database.entities.ExtendedBolus import info.nightscout.database.entities.ExtendedBolus
import info.nightscout.database.entities.TemporaryBasal import info.nightscout.database.entities.TemporaryBasal
@ -9,6 +8,7 @@ import info.nightscout.interfaces.aps.AutosensResult
import info.nightscout.interfaces.insulin.Insulin import info.nightscout.interfaces.insulin.Insulin
import info.nightscout.interfaces.iob.IobTotal import info.nightscout.interfaces.iob.IobTotal
import info.nightscout.interfaces.profile.Profile import info.nightscout.interfaces.profile.Profile
import info.nightscout.interfaces.utils.DecimalFormatter
import info.nightscout.shared.utils.DateUtil import info.nightscout.shared.utils.DateUtil
import info.nightscout.shared.utils.T import info.nightscout.shared.utils.T
import kotlin.math.ceil import kotlin.math.ceil
@ -30,8 +30,6 @@ fun ExtendedBolus.toStringFull(dateUtil: DateUtil): String =
fun ExtendedBolus.toStringMedium(dateUtil: DateUtil): String = fun ExtendedBolus.toStringMedium(dateUtil: DateUtil): String =
DecimalFormatter.to2Decimal(rate) + "U/h " + getPassedDurationToTimeInMinutes(dateUtil.now()) + "/" + T.msecs(duration).mins() + "'" DecimalFormatter.to2Decimal(rate) + "U/h " + getPassedDurationToTimeInMinutes(dateUtil.now()) + "/" + T.msecs(duration).mins() + "'"
fun ExtendedBolus.toStringTotal(): String = "${DecimalFormatter.to2Decimal(amount)}U ( ${DecimalFormatter.to2Decimal(rate)} U/h )"
fun ExtendedBolus.getPassedDurationToTimeInMinutes(time: Long): Int = fun ExtendedBolus.getPassedDurationToTimeInMinutes(time: Long): Int =
((min(time, end) - timestamp) / 60.0 / 1000).roundToInt() ((min(time, end) - timestamp) / 60.0 / 1000).roundToInt()

View file

@ -1,10 +1,10 @@
package info.nightscout.androidaps.extensions package info.nightscout.androidaps.extensions
import info.nightscout.androidaps.utils.DecimalFormatter
import info.nightscout.database.entities.GlucoseValue import info.nightscout.database.entities.GlucoseValue
import info.nightscout.interfaces.Constants import info.nightscout.interfaces.Constants
import info.nightscout.interfaces.GlucoseUnit import info.nightscout.interfaces.GlucoseUnit
import info.nightscout.interfaces.utils.DecimalFormatter
import info.nightscout.shared.utils.DateUtil import info.nightscout.shared.utils.DateUtil
import org.json.JSONObject import org.json.JSONObject

View file

@ -1,11 +1,11 @@
package info.nightscout.androidaps.extensions package info.nightscout.androidaps.extensions
import info.nightscout.androidaps.data.ProfileSealed import info.nightscout.androidaps.data.ProfileSealed
import info.nightscout.androidaps.utils.DecimalFormatter
import info.nightscout.database.entities.ProfileSwitch import info.nightscout.database.entities.ProfileSwitch
import info.nightscout.interfaces.Constants import info.nightscout.interfaces.Constants
import info.nightscout.interfaces.GlucoseUnit import info.nightscout.interfaces.GlucoseUnit
import info.nightscout.interfaces.profile.PureProfile import info.nightscout.interfaces.profile.PureProfile
import info.nightscout.interfaces.utils.DecimalFormatter
import info.nightscout.interfaces.utils.JsonHelper import info.nightscout.interfaces.utils.JsonHelper
import info.nightscout.shared.utils.DateUtil import info.nightscout.shared.utils.DateUtil
import info.nightscout.shared.utils.T import info.nightscout.shared.utils.T

View file

@ -1,6 +1,5 @@
package info.nightscout.androidaps.extensions package info.nightscout.androidaps.extensions
import info.nightscout.androidaps.utils.DecimalFormatter
import info.nightscout.database.entities.Bolus import info.nightscout.database.entities.Bolus
import info.nightscout.database.entities.TemporaryBasal import info.nightscout.database.entities.TemporaryBasal
import info.nightscout.database.entities.interfaces.end import info.nightscout.database.entities.interfaces.end
@ -8,6 +7,7 @@ import info.nightscout.interfaces.aps.AutosensResult
import info.nightscout.interfaces.insulin.Insulin import info.nightscout.interfaces.insulin.Insulin
import info.nightscout.interfaces.iob.IobTotal import info.nightscout.interfaces.iob.IobTotal
import info.nightscout.interfaces.profile.Profile import info.nightscout.interfaces.profile.Profile
import info.nightscout.interfaces.utils.DecimalFormatter
import info.nightscout.shared.utils.DateUtil import info.nightscout.shared.utils.DateUtil
import info.nightscout.shared.utils.T import info.nightscout.shared.utils.T
import kotlin.math.ceil import kotlin.math.ceil

View file

@ -1,12 +1,11 @@
package info.nightscout.androidaps.extensions package info.nightscout.androidaps.extensions
import info.nightscout.androidaps.utils.DecimalFormatter
import info.nightscout.core.main.R import info.nightscout.core.main.R
import info.nightscout.core.profile.toTargetRangeString
import info.nightscout.database.entities.TemporaryTarget import info.nightscout.database.entities.TemporaryTarget
import info.nightscout.interfaces.Constants import info.nightscout.interfaces.Constants
import info.nightscout.interfaces.GlucoseUnit import info.nightscout.interfaces.GlucoseUnit
import info.nightscout.interfaces.profile.Profile import info.nightscout.interfaces.profile.Profile
import info.nightscout.interfaces.utils.DecimalFormatter
import info.nightscout.shared.interfaces.ResourceHelper import info.nightscout.shared.interfaces.ResourceHelper
import info.nightscout.shared.utils.DateUtil import info.nightscout.shared.utils.DateUtil
import java.util.concurrent.TimeUnit import java.util.concurrent.TimeUnit

View file

@ -37,9 +37,9 @@ fun TotalDailyDose.toTableRow(context: Context, rh: ResourceHelper, dateUtil: Da
row.layoutParams = TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, TableRow.LayoutParams.WRAP_CONTENT) row.layoutParams = TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, TableRow.LayoutParams.WRAP_CONTENT)
row.gravity = Gravity.CENTER_HORIZONTAL row.gravity = Gravity.CENTER_HORIZONTAL
row.addView(TextView(context).apply { gravity = Gravity.CENTER_HORIZONTAL; layoutParams = lp.apply { column = 0 }; text = dateUtil.dateStringShort(timestamp) }) row.addView(TextView(context).apply { gravity = Gravity.CENTER_HORIZONTAL; layoutParams = lp.apply { column = 0 }; text = dateUtil.dateStringShort(timestamp) })
row.addView(TextView(context).apply { gravity = Gravity.CENTER_HORIZONTAL; layoutParams = lp.apply { column = 1 }; text = rh.gs(R.string.formatinsulinunits1, total) }) row.addView(TextView(context).apply { gravity = Gravity.CENTER_HORIZONTAL; layoutParams = lp.apply { column = 1 }; text = rh.gs(R.string.format_insulin_units1, total) })
row.addView(TextView(context).apply { gravity = Gravity.CENTER_HORIZONTAL; layoutParams = lp.apply { column = 2 }; text = rh.gs(R.string.formatinsulinunits1, bolusAmount) }) row.addView(TextView(context).apply { gravity = Gravity.CENTER_HORIZONTAL; layoutParams = lp.apply { column = 2 }; text = rh.gs(R.string.format_insulin_units1, bolusAmount) })
row.addView(TextView(context).apply { gravity = Gravity.CENTER_HORIZONTAL; layoutParams = lp.apply { column = 3 }; text = rh.gs(R.string.formatinsulinunits1, basalAmount) }) row.addView(TextView(context).apply { gravity = Gravity.CENTER_HORIZONTAL; layoutParams = lp.apply { column = 3 }; text = rh.gs(R.string.format_insulin_units1, basalAmount) })
row.addView(TextView(context).apply { gravity = Gravity.CENTER_HORIZONTAL; layoutParams = lp.apply { column = 4 }; text = rh.gs(R.string.formatPercent, basalPct) }) row.addView(TextView(context).apply { gravity = Gravity.CENTER_HORIZONTAL; layoutParams = lp.apply { column = 4 }; text = rh.gs(R.string.formatPercent, basalPct) })
if (includeCarbs) if (includeCarbs)
row.addView(TextView(context).apply { gravity = Gravity.CENTER_HORIZONTAL; layoutParams = lp.apply { column = 5 }; text = rh.gs(R.string.format_carbs, carbs.toInt()) }) row.addView(TextView(context).apply { gravity = Gravity.CENTER_HORIZONTAL; layoutParams = lp.apply { column = 5 }; text = rh.gs(R.string.format_carbs, carbs.toInt()) })
@ -54,9 +54,9 @@ fun TotalDailyDose.toTableRow(context: Context, rh: ResourceHelper, days: Int, i
row.layoutParams = TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, TableRow.LayoutParams.WRAP_CONTENT) row.layoutParams = TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, TableRow.LayoutParams.WRAP_CONTENT)
row.gravity = Gravity.CENTER_HORIZONTAL row.gravity = Gravity.CENTER_HORIZONTAL
row.addView(TextView(context).apply { gravity = Gravity.CENTER_HORIZONTAL; layoutParams = lp.apply { column = 0 }; text = "%02d".format(days) + " " + rh.gs(R.string.days) }) row.addView(TextView(context).apply { gravity = Gravity.CENTER_HORIZONTAL; layoutParams = lp.apply { column = 0 }; text = "%02d".format(days) + " " + rh.gs(R.string.days) })
row.addView(TextView(context).apply { gravity = Gravity.CENTER_HORIZONTAL; layoutParams = lp.apply { column = 1 }; text = rh.gs(R.string.formatinsulinunits1, total) }) row.addView(TextView(context).apply { gravity = Gravity.CENTER_HORIZONTAL; layoutParams = lp.apply { column = 1 }; text = rh.gs(R.string.format_insulin_units1, total) })
row.addView(TextView(context).apply { gravity = Gravity.CENTER_HORIZONTAL; layoutParams = lp.apply { column = 2 }; text = rh.gs(R.string.formatinsulinunits1, bolusAmount) }) row.addView(TextView(context).apply { gravity = Gravity.CENTER_HORIZONTAL; layoutParams = lp.apply { column = 2 }; text = rh.gs(R.string.format_insulin_units1, bolusAmount) })
row.addView(TextView(context).apply { gravity = Gravity.CENTER_HORIZONTAL; layoutParams = lp.apply { column = 3 }; text = rh.gs(R.string.formatinsulinunits1, basalAmount) }) row.addView(TextView(context).apply { gravity = Gravity.CENTER_HORIZONTAL; layoutParams = lp.apply { column = 3 }; text = rh.gs(R.string.format_insulin_units1, basalAmount) })
row.addView(TextView(context).apply { gravity = Gravity.CENTER_HORIZONTAL; layoutParams = lp.apply { column = 4 }; text = rh.gs(R.string.formatPercent, basalPct) }) row.addView(TextView(context).apply { gravity = Gravity.CENTER_HORIZONTAL; layoutParams = lp.apply { column = 4 }; text = rh.gs(R.string.formatPercent, basalPct) })
if (includeCarbs) if (includeCarbs)
row.addView(TextView(context).apply { gravity = Gravity.CENTER_HORIZONTAL; layoutParams = lp.apply { column = 5 }; text = rh.gs(R.string.format_carbs, carbs.toInt()) }) row.addView(TextView(context).apply { gravity = Gravity.CENTER_HORIZONTAL; layoutParams = lp.apply { column = 5 }; text = rh.gs(R.string.format_carbs, carbs.toInt()) })

View file

@ -4,7 +4,6 @@ import android.text.Spanned
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.extensions.convertedToAbsolute import info.nightscout.androidaps.extensions.convertedToAbsolute
import info.nightscout.androidaps.extensions.convertedToPercent import info.nightscout.androidaps.extensions.convertedToPercent
import info.nightscout.androidaps.utils.DecimalFormatter
import info.nightscout.core.main.R import info.nightscout.core.main.R
import info.nightscout.database.entities.GlucoseValue import info.nightscout.database.entities.GlucoseValue
import info.nightscout.interfaces.aps.APSResult import info.nightscout.interfaces.aps.APSResult
@ -15,6 +14,7 @@ import info.nightscout.interfaces.iob.IobTotal
import info.nightscout.interfaces.plugin.ActivePlugin import info.nightscout.interfaces.plugin.ActivePlugin
import info.nightscout.interfaces.profile.ProfileFunction import info.nightscout.interfaces.profile.ProfileFunction
import info.nightscout.interfaces.pump.defs.PumpDescription import info.nightscout.interfaces.pump.defs.PumpDescription
import info.nightscout.interfaces.utils.DecimalFormatter
import info.nightscout.interfaces.utils.HtmlHelper.fromHtml import info.nightscout.interfaces.utils.HtmlHelper.fromHtml
import info.nightscout.rx.logging.AAPSLogger import info.nightscout.rx.logging.AAPSLogger
import info.nightscout.rx.logging.LTag import info.nightscout.rx.logging.LTag

View file

@ -1,10 +1,6 @@
package info.nightscout.androidaps.plugins.iob.iobCobCalculator.data package info.nightscout.androidaps.plugins.iob.iobCobCalculator.data
import android.content.Context
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.plugins.general.overview.graphExtensions.DataPointWithLabelInterface
import info.nightscout.androidaps.plugins.general.overview.graphExtensions.PointsWithLabelGraphSeries
import info.nightscout.androidaps.plugins.general.overview.graphExtensions.Scale
import info.nightscout.core.main.R import info.nightscout.core.main.R
import info.nightscout.interfaces.Constants import info.nightscout.interfaces.Constants
import info.nightscout.interfaces.aps.AutosensData import info.nightscout.interfaces.aps.AutosensData
@ -19,7 +15,7 @@ import java.util.Locale
import javax.inject.Inject import javax.inject.Inject
import kotlin.math.min import kotlin.math.min
class AutosensDataObject(injector: HasAndroidInjector) : DataPointWithLabelInterface, AutosensData { class AutosensDataObject(injector: HasAndroidInjector) : AutosensData {
@Inject lateinit var aapsLogger: AAPSLogger @Inject lateinit var aapsLogger: AAPSLogger
@Inject lateinit var sp: SP @Inject lateinit var sp: SP
@ -29,7 +25,6 @@ class AutosensDataObject(injector: HasAndroidInjector) : DataPointWithLabelInter
override var time = 0L override var time = 0L
override var bg = 0.0 // mgdl override var bg = 0.0 // mgdl
var chartTime: Long = 0
override var pastSensitivity = "" override var pastSensitivity = ""
override var deviation = 0.0 override var deviation = 0.0
override var validDeviation = false override var validDeviation = false
@ -121,22 +116,6 @@ class AutosensDataObject(injector: HasAndroidInjector) : DataPointWithLabelInter
i++ i++
} }
} }
// ------- DataPointWithLabelInterface ------
var scale: Scale? = null
override fun getX(): Double = chartTime.toDouble()
override fun getY(): Double = scale!!.transform(cob)
override fun setY(y: Double) {}
override val label: String = ""
override val duration = 0L
override val shape = PointsWithLabelGraphSeries.Shape.COB_FAIL_OVER
override val size = 0.5f
override fun color(context: Context?): Int {
return rh.gac(context,R.attr.cobColor)
}
init { init {
injector.androidInjector().inject(this) injector.androidInjector().inject(this)
} }

View file

@ -35,7 +35,6 @@ import info.nightscout.androidaps.utils.textValidator.validators.RegexpValidator
import info.nightscout.androidaps.utils.textValidator.validators.Validator import info.nightscout.androidaps.utils.textValidator.validators.Validator
import info.nightscout.androidaps.utils.textValidator.validators.WebUrlValidator import info.nightscout.androidaps.utils.textValidator.validators.WebUrlValidator
import info.nightscout.core.main.R import info.nightscout.core.main.R
import info.nightscout.core.profile.fromMgdlToUnits
import info.nightscout.interfaces.profile.Profile import info.nightscout.interfaces.profile.Profile
import info.nightscout.interfaces.profile.ProfileFunction import info.nightscout.interfaces.profile.ProfileFunction
import javax.inject.Inject import javax.inject.Inject

View file

@ -6,8 +6,6 @@ import androidx.preference.EditTextPreference
import androidx.preference.PreferenceViewHolder import androidx.preference.PreferenceViewHolder
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.core.main.R import info.nightscout.core.main.R
import info.nightscout.core.profile.fromMgdlToUnits
import info.nightscout.core.profile.toMgdl
import info.nightscout.interfaces.profile.Profile import info.nightscout.interfaces.profile.Profile
import info.nightscout.interfaces.profile.ProfileFunction import info.nightscout.interfaces.profile.ProfileFunction
import info.nightscout.shared.SafeParse import info.nightscout.shared.SafeParse

View file

@ -1,7 +1,6 @@
package info.nightscout.androidaps.utils.textValidator.validators package info.nightscout.androidaps.utils.textValidator.validators
import android.widget.EditText import android.widget.EditText
import info.nightscout.core.profile.fromMgdlToUnits
import info.nightscout.interfaces.profile.Profile import info.nightscout.interfaces.profile.Profile
import info.nightscout.interfaces.profile.ProfileFunction import info.nightscout.interfaces.profile.ProfileFunction

View file

@ -2,10 +2,7 @@ package info.nightscout.androidaps.utils.userEntry
import android.text.Spanned import android.text.Spanned
import dagger.Reusable import dagger.Reusable
import info.nightscout.androidaps.utils.DecimalFormatter
import info.nightscout.androidaps.utils.Translator
import info.nightscout.core.main.R import info.nightscout.core.main.R
import info.nightscout.core.profile.toUnitsString
import info.nightscout.database.entities.UserEntry import info.nightscout.database.entities.UserEntry
import info.nightscout.database.entities.UserEntry.Action import info.nightscout.database.entities.UserEntry.Action
import info.nightscout.database.entities.UserEntry.ColorGroup import info.nightscout.database.entities.UserEntry.ColorGroup
@ -13,8 +10,10 @@ import info.nightscout.database.entities.UserEntry.Sources
import info.nightscout.database.entities.ValueWithUnit import info.nightscout.database.entities.ValueWithUnit
import info.nightscout.interfaces.Constants import info.nightscout.interfaces.Constants
import info.nightscout.interfaces.GlucoseUnit import info.nightscout.interfaces.GlucoseUnit
import info.nightscout.interfaces.Translator
import info.nightscout.interfaces.profile.Profile import info.nightscout.interfaces.profile.Profile
import info.nightscout.interfaces.profile.ProfileFunction import info.nightscout.interfaces.profile.ProfileFunction
import info.nightscout.interfaces.utils.DecimalFormatter
import info.nightscout.interfaces.utils.HtmlHelper import info.nightscout.interfaces.utils.HtmlHelper
import info.nightscout.shared.interfaces.ResourceHelper import info.nightscout.shared.interfaces.ResourceHelper
import info.nightscout.shared.utils.DateUtil import info.nightscout.shared.utils.DateUtil

View file

@ -1,8 +1,8 @@
package info.nightscout.core.iob package info.nightscout.core.iob
import info.nightscout.androidaps.utils.DecimalFormatter
import info.nightscout.core.main.R import info.nightscout.core.main.R
import info.nightscout.interfaces.iob.CobInfo import info.nightscout.interfaces.iob.CobInfo
import info.nightscout.interfaces.utils.DecimalFormatter
import info.nightscout.shared.interfaces.ResourceHelper import info.nightscout.shared.interfaces.ResourceHelper
import info.nightscout.shared.utils.DateUtil import info.nightscout.shared.utils.DateUtil

View file

@ -1,7 +1,7 @@
package info.nightscout.core.iob package info.nightscout.core.iob
import info.nightscout.androidaps.utils.DecimalFormatter
import info.nightscout.interfaces.iob.GlucoseStatus import info.nightscout.interfaces.iob.GlucoseStatus
import info.nightscout.interfaces.utils.DecimalFormatter
import info.nightscout.interfaces.utils.Round import info.nightscout.interfaces.utils.Round
fun GlucoseStatus.log(): String = "Glucose: " + DecimalFormatter.to0Decimal(glucose) + " mg/dl " + fun GlucoseStatus.log(): String = "Glucose: " + DecimalFormatter.to0Decimal(glucose) + " mg/dl " +

View file

@ -1,63 +0,0 @@
package info.nightscout.core.profile
import info.nightscout.androidaps.utils.DecimalFormatter
import info.nightscout.interfaces.Constants
import info.nightscout.interfaces.GlucoseUnit
import info.nightscout.interfaces.profile.Profile
import info.nightscout.interfaces.profile.ProfileFunction
/*
* Units conversion
*/
fun Profile.Companion.fromMgdlToUnits(value: Double, units: GlucoseUnit): Double =
if (units == GlucoseUnit.MGDL) value else value * Constants.MGDL_TO_MMOLL
fun Profile.Companion.fromMmolToUnits(value: Double, units: GlucoseUnit): Double =
if (units == GlucoseUnit.MMOL) value else value * Constants.MMOLL_TO_MGDL
fun Profile.Companion.toUnits(valueInMgdl: Double, valueInMmol: Double, units: GlucoseUnit): Double =
if (units == GlucoseUnit.MGDL) valueInMgdl else valueInMmol
fun Profile.Companion.toUnitsString(valueInMgdl: Double, valueInMmol: Double, units: GlucoseUnit): String =
if (units == GlucoseUnit.MGDL) DecimalFormatter.to0Decimal(valueInMgdl) else DecimalFormatter.to1Decimal(valueInMmol)
fun Profile.Companion.toSignedUnitsString(valueInMgdl: Double, valueInMmol: Double, units: GlucoseUnit): String =
if (units == GlucoseUnit.MGDL) (if (valueInMgdl > 0) "+" else "") + DecimalFormatter.to0Decimal(valueInMgdl)
else (if (valueInMmol > 0) "+" else "") + DecimalFormatter.to1Decimal(valueInMmol)
fun Profile.Companion.isMgdl(anyBg: Double) = anyBg >= 39
fun Profile.Companion.isMmol(anyBg: Double) = anyBg < 39
fun Profile.Companion.unit(anyBg: Double) = if (isMgdl(anyBg)) GlucoseUnit.MGDL else GlucoseUnit.MMOL
fun Profile.Companion.toCurrentUnits(profileFunction: ProfileFunction, anyBg: Double): Double =
if (isMmol(anyBg)) fromMmolToUnits(anyBg, profileFunction.getUnits())
else fromMgdlToUnits(anyBg, profileFunction.getUnits())
fun Profile.Companion.toCurrentUnits(units: GlucoseUnit, anyBg: Double): Double =
if (isMmol(anyBg)) fromMmolToUnits(anyBg, units)
else fromMgdlToUnits(anyBg, units)
fun Profile.Companion.toCurrentUnitsString(profileFunction: ProfileFunction, anyBg: Double): String =
if (isMmol(anyBg)) toUnitsString(anyBg * Constants.MMOLL_TO_MGDL, anyBg, profileFunction.getUnits())
else toUnitsString(anyBg, anyBg * Constants.MGDL_TO_MMOLL, profileFunction.getUnits())
fun Profile.Companion.toMgdl(value: Double): Double =
if (isMgdl(value)) value else value * Constants.MMOLL_TO_MGDL
fun Profile.Companion.toMgdl(value: Double, units: GlucoseUnit): Double =
if (units == GlucoseUnit.MGDL) value else value * Constants.MMOLL_TO_MGDL
fun Profile.Companion.toMmol(value: Double, units: GlucoseUnit): Double =
if (units == GlucoseUnit.MGDL) value * Constants.MGDL_TO_MMOLL else value
// targets are stored in mg/dl but profile vary
fun Profile.Companion.toTargetRangeString(low: Double, high: Double, sourceUnits: GlucoseUnit, units: GlucoseUnit): String {
val lowMgdl = toMgdl(low, sourceUnits)
val highMgdl = toMgdl(high, sourceUnits)
val lowMmol = toMmol(low, sourceUnits)
val highMmol = toMmol(high, sourceUnits)
return if (low == high) toUnitsString(lowMgdl, lowMmol, units)
else toUnitsString(lowMgdl, lowMmol, units) + " - " + toUnitsString(highMgdl, highMmol, units)
}

View file

@ -1,7 +1,7 @@
package info.nightscout.core.pump package info.nightscout.core.pump
import info.nightscout.androidaps.utils.DecimalFormatter
import info.nightscout.interfaces.pump.PumpEnactResult import info.nightscout.interfaces.pump.PumpEnactResult
import info.nightscout.interfaces.utils.DecimalFormatter
import info.nightscout.shared.interfaces.ResourceHelper import info.nightscout.shared.interfaces.ResourceHelper
fun PumpEnactResult.toHtml(rh: ResourceHelper): String { fun PumpEnactResult.toHtml(rh: ResourceHelper): String {

View file

@ -1,8 +1,8 @@
package info.nightscout.core.pump package info.nightscout.core.pump
import info.nightscout.androidaps.utils.DecimalFormatter
import info.nightscout.interfaces.profile.Profile import info.nightscout.interfaces.profile.Profile
import info.nightscout.interfaces.pump.PumpSync import info.nightscout.interfaces.pump.PumpSync
import info.nightscout.interfaces.utils.DecimalFormatter
import info.nightscout.shared.utils.DateUtil import info.nightscout.shared.utils.DateUtil
import info.nightscout.shared.utils.T import info.nightscout.shared.utils.T
import kotlin.math.ceil import kotlin.math.ceil

View file

@ -10,8 +10,6 @@ import info.nightscout.androidaps.logging.UserEntryLogger
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatusProvider import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatusProvider
import info.nightscout.core.iob.round import info.nightscout.core.iob.round
import info.nightscout.core.main.R import info.nightscout.core.main.R
import info.nightscout.core.profile.fromMgdlToUnits
import info.nightscout.core.profile.toMgdl
import info.nightscout.core.ui.dialogs.OKDialog import info.nightscout.core.ui.dialogs.OKDialog
import info.nightscout.core.utils.extensions.formatColor import info.nightscout.core.utils.extensions.formatColor
import info.nightscout.database.entities.BolusCalculatorResult import info.nightscout.database.entities.BolusCalculatorResult
@ -327,7 +325,7 @@ class BolusWizard @Inject constructor(
val actions: LinkedList<String> = LinkedList() val actions: LinkedList<String> = LinkedList()
if (insulinAfterConstraints > 0) { if (insulinAfterConstraints > 0) {
val pct = if (percentageCorrection != 100) " ($percentageCorrection%)" else "" val pct = if (percentageCorrection != 100) " ($percentageCorrection%)" else ""
actions.add(rh.gs(R.string.bolus) + ": " + rh.gs(R.string.formatinsulinunits, insulinAfterConstraints).formatColor(context, rh, R.attr.bolusColor) + pct) actions.add(rh.gs(R.string.bolus) + ": " + rh.gs(R.string.format_insulin_units, insulinAfterConstraints).formatColor(context, rh, R.attr.bolusColor) + pct)
} }
if (carbs > 0 && !advisor) { if (carbs > 0 && !advisor) {
var timeShift = "" var timeShift = ""

View file

@ -15,8 +15,6 @@
<string name="connecting">Connecting</string> <string name="connecting">Connecting</string>
<string name="disconnected">Disconnected</string> <string name="disconnected">Disconnected</string>
<string name="androidaps_start">AAPS started</string> <string name="androidaps_start">AAPS started</string>
<string name="formatinsulinunits1">%1$.1f U</string>
<string name="formatinsulinunits">%1$.2f U</string>
<string name="formatsignedinsulinunits">%1$+.2f U</string> <string name="formatsignedinsulinunits">%1$+.2f U</string>
<string name="format_carbs">%1$d g</string> <string name="format_carbs">%1$d g</string>
<string name="reservoirvalue">%1$.0f / %2$d U</string> <string name="reservoirvalue">%1$.0f / %2$d U</string>
@ -26,7 +24,6 @@
<string name="pumpbusy">Pump is busy</string> <string name="pumpbusy">Pump is busy</string>
<string name="connectionerror">Pump connection error</string> <string name="connectionerror">Pump connection error</string>
<string name="objectives">Objectives</string> <string name="objectives">Objectives</string>
<string name="close">Close</string>
<string name="please_wait">Please wait…</string> <string name="please_wait">Please wait…</string>
<string name="mute">Mute</string> <string name="mute">Mute</string>
<string name="reload">Reload</string> <string name="reload">Reload</string>

View file

@ -5,11 +5,11 @@ import dagger.android.AndroidInjector
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.data.ProfileSealed import info.nightscout.androidaps.data.ProfileSealed
import info.nightscout.androidaps.extensions.pureProfileFromJson import info.nightscout.androidaps.extensions.pureProfileFromJson
import info.nightscout.androidaps.utils.DefaultValueHelper
import info.nightscout.core.profile.ProfileStoreObject import info.nightscout.core.profile.ProfileStoreObject
import info.nightscout.database.impl.AppRepository import info.nightscout.database.impl.AppRepository
import info.nightscout.interfaces.Config import info.nightscout.interfaces.Config
import info.nightscout.interfaces.plugin.ActivePlugin import info.nightscout.interfaces.plugin.ActivePlugin
import info.nightscout.interfaces.profile.DefaultValueHelper
import info.nightscout.interfaces.profile.Profile import info.nightscout.interfaces.profile.Profile
import info.nightscout.interfaces.profile.ProfileFunction import info.nightscout.interfaces.profile.ProfileFunction
import info.nightscout.interfaces.profile.ProfileStore import info.nightscout.interfaces.profile.ProfileStore

View file

@ -7,12 +7,6 @@ import info.nightscout.androidaps.TestBase
import info.nightscout.androidaps.TestPumpPlugin import info.nightscout.androidaps.TestPumpPlugin
import info.nightscout.androidaps.extensions.pureProfileFromJson import info.nightscout.androidaps.extensions.pureProfileFromJson
import info.nightscout.core.main.R import info.nightscout.core.main.R
import info.nightscout.core.profile.fromMgdlToUnits
import info.nightscout.core.profile.toMgdl
import info.nightscout.core.profile.toMmol
import info.nightscout.core.profile.toTargetRangeString
import info.nightscout.core.profile.toUnits
import info.nightscout.core.profile.toUnitsString
import info.nightscout.interfaces.Config import info.nightscout.interfaces.Config
import info.nightscout.interfaces.GlucoseUnit import info.nightscout.interfaces.GlucoseUnit
import info.nightscout.interfaces.plugin.ActivePlugin import info.nightscout.interfaces.plugin.ActivePlugin

View file

@ -1,5 +1,6 @@
package info.nightscout.androidaps.utils package info.nightscout.androidaps.utils
import info.nightscout.interfaces.utils.DecimalFormatter
import org.junit.Assert import org.junit.Assert
import org.junit.Test import org.junit.Test

1
core/graph/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
/build

28
core/graph/build.gradle Normal file
View file

@ -0,0 +1,28 @@
plugins {
id 'com.android.library'
id 'kotlin-android'
id 'kotlin-kapt'
id 'kotlin-parcelize'
id 'kotlin-allopen'
id 'com.hiya.jacoco-android'
}
apply from: "${project.rootDir}/core/core-main/android_dependencies.gradle"
apply from: "${project.rootDir}/core/core-main/android_module_dependencies.gradle"
apply from: "${project.rootDir}/core/core-main/allopen_dependencies.gradle"
apply from: "${project.rootDir}/core/core-main/test_dependencies.gradle"
apply from: "${project.rootDir}/core/core-main/jacoco_global.gradle"
dependencies {
implementation project(':graphview')
implementation project(':app-wear-shared:shared')
implementation project(':database:entities')
implementation project(':interfaces')
implementation project(':core:ui')
api "com.google.android.material:material:$material_version"
}
android {
namespace 'info.nightscout.core.graph'
}

View file

21
core/graph/proguard-rules.pro vendored Normal file
View file

@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile

View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest>
</manifest>

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.utils.ui package info.nightscout.core.graph
import android.content.Context import android.content.Context
import android.util.AttributeSet import android.util.AttributeSet
@ -6,7 +6,6 @@ import com.jjoe64.graphview.DefaultLabelFormatter
import com.jjoe64.graphview.GraphView import com.jjoe64.graphview.GraphView
import com.jjoe64.graphview.series.DataPoint import com.jjoe64.graphview.series.DataPoint
import com.jjoe64.graphview.series.LineGraphSeries import com.jjoe64.graphview.series.LineGraphSeries
import info.nightscout.core.main.R
import info.nightscout.interfaces.profile.Profile import info.nightscout.interfaces.profile.Profile
import info.nightscout.interfaces.utils.Round import info.nightscout.interfaces.utils.Round
import java.text.NumberFormat import java.text.NumberFormat

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.utils.ui package info.nightscout.core.graph
import android.content.Context import android.content.Context
import android.util.AttributeSet import android.util.AttributeSet
@ -6,7 +6,6 @@ import com.jjoe64.graphview.DefaultLabelFormatter
import com.jjoe64.graphview.GraphView import com.jjoe64.graphview.GraphView
import com.jjoe64.graphview.series.DataPoint import com.jjoe64.graphview.series.DataPoint
import com.jjoe64.graphview.series.LineGraphSeries import com.jjoe64.graphview.series.LineGraphSeries
import info.nightscout.core.main.R
import info.nightscout.interfaces.profile.Profile import info.nightscout.interfaces.profile.Profile
import info.nightscout.interfaces.utils.Round import info.nightscout.interfaces.utils.Round
import java.text.NumberFormat import java.text.NumberFormat

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.utils.ui package info.nightscout.core.graph
import android.content.Context import android.content.Context
import android.util.AttributeSet import android.util.AttributeSet
@ -6,8 +6,8 @@ import com.jjoe64.graphview.DefaultLabelFormatter
import com.jjoe64.graphview.GraphView import com.jjoe64.graphview.GraphView
import com.jjoe64.graphview.series.DataPoint import com.jjoe64.graphview.series.DataPoint
import com.jjoe64.graphview.series.LineGraphSeries import com.jjoe64.graphview.series.LineGraphSeries
import info.nightscout.core.main.R import info.nightscout.interfaces.Constants
import info.nightscout.core.profile.fromMgdlToUnits import info.nightscout.interfaces.GlucoseUnit
import info.nightscout.interfaces.profile.Profile import info.nightscout.interfaces.profile.Profile
import info.nightscout.interfaces.utils.Round import info.nightscout.interfaces.utils.Round
import java.text.NumberFormat import java.text.NumberFormat
@ -19,13 +19,16 @@ class IsfProfileGraph : GraphView {
constructor(context: Context?) : super(context) constructor(context: Context?) : super(context)
constructor(context: Context?, attrs: AttributeSet?) : super(context, attrs) constructor(context: Context?, attrs: AttributeSet?) : super(context, attrs)
private fun fromMgdlToUnits(value: Double, units: GlucoseUnit): Double =
if (units == GlucoseUnit.MGDL) value else value * Constants.MGDL_TO_MMOLL
fun show(profile: Profile) { fun show(profile: Profile) {
removeAllSeries() removeAllSeries()
val isfArray: MutableList<DataPoint> = ArrayList() val isfArray: MutableList<DataPoint> = ArrayList()
var maxIsf = 0.0 var maxIsf = 0.0
val units = profile.units val units = profile.units
for (hour in 0..23) { for (hour in 0..23) {
val isf = Profile.fromMgdlToUnits(profile.getIsfMgdlTimeFromMidnight(hour * 60 * 60), units) val isf = fromMgdlToUnits(profile.getIsfMgdlTimeFromMidnight(hour * 60 * 60), units)
maxIsf = max(maxIsf, isf) maxIsf = max(maxIsf, isf)
isfArray.add(DataPoint(hour.toDouble(), isf)) isfArray.add(DataPoint(hour.toDouble(), isf))
isfArray.add(DataPoint((hour + 1).toDouble(), isf)) isfArray.add(DataPoint((hour + 1).toDouble(), isf))
@ -59,7 +62,7 @@ class IsfProfileGraph : GraphView {
// isf 1 // isf 1
val isfArray1: MutableList<DataPoint> = ArrayList() val isfArray1: MutableList<DataPoint> = ArrayList()
for (hour in 0..23) { for (hour in 0..23) {
val isf = Profile.fromMgdlToUnits(profile1.getIsfMgdlTimeFromMidnight(hour * 60 * 60), units) val isf = fromMgdlToUnits(profile1.getIsfMgdlTimeFromMidnight(hour * 60 * 60), units)
minIsf = min(minIsf, isf) minIsf = min(minIsf, isf)
maxIsf = max(maxIsf, isf) maxIsf = max(maxIsf, isf)
isfArray1.add(DataPoint(hour.toDouble(), isf)) isfArray1.add(DataPoint(hour.toDouble(), isf))
@ -73,7 +76,7 @@ class IsfProfileGraph : GraphView {
// isf 2 // isf 2
val isfArray2: MutableList<DataPoint> = ArrayList() val isfArray2: MutableList<DataPoint> = ArrayList()
for (hour in 0..23) { for (hour in 0..23) {
val isf = Profile.fromMgdlToUnits(profile2.getIsfMgdlTimeFromMidnight(hour * 60 * 60), units) val isf = fromMgdlToUnits(profile2.getIsfMgdlTimeFromMidnight(hour * 60 * 60), units)
minIsf = min(minIsf, isf) minIsf = min(minIsf, isf)
maxIsf = max(maxIsf, isf) maxIsf = max(maxIsf, isf)
isfArray2.add(DataPoint(hour.toDouble(), isf)) isfArray2.add(DataPoint(hour.toDouble(), isf))

View file

@ -0,0 +1,151 @@
package info.nightscout.core.graph
import android.content.Context
import androidx.annotation.AttrRes
import androidx.annotation.ColorInt
import androidx.annotation.DrawableRes
import com.jjoe64.graphview.series.BarGraphSeries
import com.jjoe64.graphview.series.DataPoint
import com.jjoe64.graphview.series.LineGraphSeries
import info.nightscout.core.graph.data.DataPointWithLabelInterface
import info.nightscout.core.graph.data.DeviationDataPoint
import info.nightscout.core.graph.data.FixedLineGraphSeries
import info.nightscout.core.graph.data.PointsWithLabelGraphSeries
import info.nightscout.core.graph.data.Scale
import info.nightscout.core.graph.data.ScaledDataPoint
import info.nightscout.database.entities.GlucoseValue
import info.nightscout.database.entities.TemporaryTarget
import info.nightscout.interfaces.aps.AutosensData
import info.nightscout.interfaces.iob.CobInfo
import info.nightscout.interfaces.iob.IobCobCalculator
import info.nightscout.interfaces.iob.IobTotal
interface OverviewData {
var rangeToDisplay: Int // for graph
var toTime: Long
var fromTime: Long
var endTime: Long
fun reset()
fun initRange()
/*
* PUMP STATUS
*/
var pumpStatus: String
/*
* CALC PROGRESS
*/
var calcProgressPct: Int
/*
* BG
*/
val lastBg: GlucoseValue?
val isLow: Boolean
val isHigh: Boolean
@ColorInt fun lastBgColor(context: Context?): Int
val lastBgDescription: String
val isActualBg: Boolean
/*
* TEMPORARY BASAL
*/
fun temporaryBasalText(iobCobCalculator: IobCobCalculator): String
fun temporaryBasalDialogText(iobCobCalculator: IobCobCalculator): String
@DrawableRes fun temporaryBasalIcon(iobCobCalculator: IobCobCalculator): Int
@AttrRes fun temporaryBasalColor(context: Context?, iobCobCalculator: IobCobCalculator): Int
/*
* EXTENDED BOLUS
*/
fun extendedBolusText(iobCobCalculator: IobCobCalculator): String
fun extendedBolusDialogText(iobCobCalculator: IobCobCalculator): String
/*
* IOB, COB
*/
fun bolusIob(iobCobCalculator: IobCobCalculator): IobTotal
fun basalIob(iobCobCalculator: IobCobCalculator): IobTotal
fun cobInfo(iobCobCalculator: IobCobCalculator): CobInfo
val lastCarbsTime: Long
fun iobText(iobCobCalculator: IobCobCalculator): String
fun iobDialogText(iobCobCalculator: IobCobCalculator): String
/*
* TEMP TARGET
*/
val temporaryTarget: TemporaryTarget?
/*
* SENSITIVITY
*/
fun lastAutosensData(iobCobCalculator: IobCobCalculator): AutosensData?
/*
* Graphs
*/
var bgReadingsArray: List<GlucoseValue>
var maxBgValue: Double
var bucketedGraphSeries: PointsWithLabelGraphSeries<DataPointWithLabelInterface>
var bgReadingGraphSeries: PointsWithLabelGraphSeries<DataPointWithLabelInterface>
var predictionsGraphSeries: PointsWithLabelGraphSeries<DataPointWithLabelInterface>
val basalScale: Scale
var baseBasalGraphSeries: LineGraphSeries<ScaledDataPoint>
var tempBasalGraphSeries: LineGraphSeries<ScaledDataPoint>
var basalLineGraphSeries: LineGraphSeries<ScaledDataPoint>
var absoluteBasalGraphSeries: LineGraphSeries<ScaledDataPoint>
var temporaryTargetSeries: LineGraphSeries<DataPoint>
var maxIAValue: Double
val actScale: Scale
var activitySeries: FixedLineGraphSeries<ScaledDataPoint>
var activityPredictionSeries: FixedLineGraphSeries<ScaledDataPoint>
var maxEpsValue: Double
val epsScale: Scale
var epsSeries: PointsWithLabelGraphSeries<DataPointWithLabelInterface>
var maxTreatmentsValue: Double
var treatmentsSeries: PointsWithLabelGraphSeries<DataPointWithLabelInterface>
var maxTherapyEventValue: Double
var therapyEventSeries: PointsWithLabelGraphSeries<DataPointWithLabelInterface>
var maxIobValueFound: Double
val iobScale: Scale
var iobSeries: FixedLineGraphSeries<ScaledDataPoint>
var absIobSeries: FixedLineGraphSeries<ScaledDataPoint>
var iobPredictions1Series: PointsWithLabelGraphSeries<DataPointWithLabelInterface>
var maxBGIValue: Double
val bgiScale: Scale
var minusBgiSeries: FixedLineGraphSeries<ScaledDataPoint>
var minusBgiHistSeries: FixedLineGraphSeries<ScaledDataPoint>
var maxCobValueFound: Double
val cobScale: Scale
var cobSeries: FixedLineGraphSeries<ScaledDataPoint>
var cobMinFailOverSeries: PointsWithLabelGraphSeries<DataPointWithLabelInterface>
var maxDevValueFound: Double
val devScale: Scale
var deviationsSeries: BarGraphSeries<DeviationDataPoint>
var maxRatioValueFound: Double //even if sens data equals 0 for all the period, minimum scale is between 95% and 105%
var minRatioValueFound: Double
val ratioScale: Scale
var ratioSeries: LineGraphSeries<ScaledDataPoint>
var maxFromMaxValueFound: Double
var maxFromMinValueFound: Double
val dsMaxScale: Scale
val dsMinScale: Scale
var dsMaxSeries: LineGraphSeries<ScaledDataPoint>
var dsMinSeries: LineGraphSeries<ScaledDataPoint>
}

View file

@ -1,13 +1,12 @@
package info.nightscout.androidaps.utils.ui package info.nightscout.core.graph
import android.content.Context import android.content.Context
import android.util.AttributeSet import android.util.AttributeSet
import com.jjoe64.graphview.DefaultLabelFormatter import com.jjoe64.graphview.DefaultLabelFormatter
import com.jjoe64.graphview.GraphView import com.jjoe64.graphview.GraphView
import info.nightscout.androidaps.plugins.general.overview.graphExtensions.AreaGraphSeries import info.nightscout.core.graph.data.AreaGraphSeries
import info.nightscout.androidaps.plugins.general.overview.graphExtensions.DoubleDataPoint import info.nightscout.core.graph.data.DoubleDataPoint
import info.nightscout.core.main.R import info.nightscout.interfaces.Constants
import info.nightscout.core.profile.fromMgdlToUnits
import info.nightscout.interfaces.GlucoseUnit import info.nightscout.interfaces.GlucoseUnit
import info.nightscout.interfaces.profile.Profile import info.nightscout.interfaces.profile.Profile
import info.nightscout.interfaces.utils.Round import info.nightscout.interfaces.utils.Round
@ -20,6 +19,9 @@ class TargetBgProfileGraph : GraphView {
constructor(context: Context?) : super(context) constructor(context: Context?) : super(context)
constructor(context: Context?, attrs: AttributeSet?) : super(context, attrs) constructor(context: Context?, attrs: AttributeSet?) : super(context, attrs)
private fun fromMgdlToUnits(value: Double, units: GlucoseUnit): Double =
if (units == GlucoseUnit.MGDL) value else value * Constants.MGDL_TO_MMOLL
fun show(profile: Profile) { fun show(profile: Profile) {
removeAllSeries() removeAllSeries()
@ -27,8 +29,8 @@ class TargetBgProfileGraph : GraphView {
var maxValue = 0.0 var maxValue = 0.0
val units = profile.units val units = profile.units
for (hour in 0..23) { for (hour in 0..23) {
val valueLow = Profile.fromMgdlToUnits(profile.getTargetLowMgdlTimeFromMidnight(hour * 60 * 60), units) val valueLow = fromMgdlToUnits(profile.getTargetLowMgdlTimeFromMidnight(hour * 60 * 60), units)
val valueHigh = Profile.fromMgdlToUnits(profile.getTargetHighMgdlTimeFromMidnight(hour * 60 * 60), units) val valueHigh = fromMgdlToUnits(profile.getTargetHighMgdlTimeFromMidnight(hour * 60 * 60), units)
maxValue = max(maxValue, valueHigh) maxValue = max(maxValue, valueHigh)
targetArray.add(DoubleDataPoint(hour.toDouble(), valueLow, valueHigh)) targetArray.add(DoubleDataPoint(hour.toDouble(), valueLow, valueHigh))
targetArray.add(DoubleDataPoint((hour + 1).toDouble(), valueLow, valueHigh)) targetArray.add(DoubleDataPoint((hour + 1).toDouble(), valueLow, valueHigh))
@ -60,8 +62,8 @@ class TargetBgProfileGraph : GraphView {
var maxValue = 0.0 var maxValue = 0.0
val units = profile1.units val units = profile1.units
for (hour in 0..23) { for (hour in 0..23) {
val valueLow = Profile.fromMgdlToUnits(profile1.getTargetLowMgdlTimeFromMidnight(hour * 60 * 60), units) val valueLow = fromMgdlToUnits(profile1.getTargetLowMgdlTimeFromMidnight(hour * 60 * 60), units)
val valueHigh = Profile.fromMgdlToUnits(profile1.getTargetHighMgdlTimeFromMidnight(hour * 60 * 60), units) val valueHigh = fromMgdlToUnits(profile1.getTargetHighMgdlTimeFromMidnight(hour * 60 * 60), units)
minValue = min(minValue, valueLow) minValue = min(minValue, valueLow)
maxValue = max(maxValue, valueHigh) maxValue = max(maxValue, valueHigh)
targetArray1.add(DoubleDataPoint(hour.toDouble(), valueLow, valueHigh)) targetArray1.add(DoubleDataPoint(hour.toDouble(), valueLow, valueHigh))
@ -74,8 +76,8 @@ class TargetBgProfileGraph : GraphView {
val targetArray2: MutableList<DoubleDataPoint> = ArrayList() val targetArray2: MutableList<DoubleDataPoint> = ArrayList()
for (hour in 0..23) { for (hour in 0..23) {
val valueLow = Profile.fromMgdlToUnits(profile2.getTargetLowMgdlTimeFromMidnight(hour * 60 * 60), units) val valueLow = fromMgdlToUnits(profile2.getTargetLowMgdlTimeFromMidnight(hour * 60 * 60), units)
val valueHigh = Profile.fromMgdlToUnits(profile2.getTargetHighMgdlTimeFromMidnight(hour * 60 * 60), units) val valueHigh = fromMgdlToUnits(profile2.getTargetHighMgdlTimeFromMidnight(hour * 60 * 60), units)
minValue = min(minValue, valueLow) minValue = min(minValue, valueLow)
maxValue = max(maxValue, valueHigh) maxValue = max(maxValue, valueHigh)
targetArray2.add(DoubleDataPoint(hour.toDouble(), valueLow, valueHigh)) targetArray2.add(DoubleDataPoint(hour.toDouble(), valueLow, valueHigh))

View file

@ -17,7 +17,7 @@
* with the "Linking Exception" along with this program; if not, * with the "Linking Exception" along with this program; if not,
* write to the author Jonas Gehring <g.jjoe64@gmail.com>. * write to the author Jonas Gehring <g.jjoe64@gmail.com>.
*/ */
package info.nightscout.androidaps.plugins.general.overview.graphExtensions; package info.nightscout.core.graph.data;
import android.graphics.Canvas; import android.graphics.Canvas;
import android.graphics.Color; import android.graphics.Color;

View file

@ -1,11 +1,11 @@
package info.nightscout.androidaps.plugins.general.overview.graphExtensions package info.nightscout.core.graph.data
import android.content.Context import android.content.Context
import info.nightscout.androidaps.utils.DecimalFormatter import info.nightscout.core.graph.R
import info.nightscout.androidaps.utils.DefaultValueHelper
import info.nightscout.core.main.R
import info.nightscout.database.entities.Bolus import info.nightscout.database.entities.Bolus
import info.nightscout.interfaces.plugin.ActivePlugin import info.nightscout.interfaces.plugin.ActivePlugin
import info.nightscout.interfaces.profile.DefaultValueHelper
import info.nightscout.interfaces.utils.DecimalFormatter
import info.nightscout.shared.interfaces.ResourceHelper import info.nightscout.shared.interfaces.ResourceHelper
class BolusDataPoint( class BolusDataPoint(

View file

@ -1,7 +1,7 @@
package info.nightscout.androidaps.plugins.general.overview.graphExtensions package info.nightscout.core.graph.data
import android.content.Context import android.content.Context
import info.nightscout.core.main.R import info.nightscout.core.graph.R
import info.nightscout.database.entities.Carbs import info.nightscout.database.entities.Carbs
import info.nightscout.shared.interfaces.ResourceHelper import info.nightscout.shared.interfaces.ResourceHelper

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.plugins.general.overview.graphExtensions package info.nightscout.core.graph.data
import android.content.Context import android.content.Context
import com.jjoe64.graphview.series.DataPointInterface import com.jjoe64.graphview.series.DataPointInterface

View file

@ -1,3 +1,3 @@
package info.nightscout.androidaps.plugins.general.overview.graphExtensions package info.nightscout.core.graph.data
class DeviationDataPoint(x: Double, y: Double, var color: Int, scale: Scale) : ScaledDataPoint(x, y, scale) class DeviationDataPoint(x: Double, y: Double, var color: Int, scale: Scale) : ScaledDataPoint(x, y, scale)

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.plugins.general.overview.graphExtensions package info.nightscout.core.graph.data
import com.jjoe64.graphview.series.DataPointInterface import com.jjoe64.graphview.series.DataPointInterface

View file

@ -1,7 +1,7 @@
package info.nightscout.androidaps.plugins.general.overview.graphExtensions package info.nightscout.core.graph.data
import android.content.Context import android.content.Context
import info.nightscout.core.main.R import info.nightscout.core.graph.R
import info.nightscout.database.entities.EffectiveProfileSwitch import info.nightscout.database.entities.EffectiveProfileSwitch
import info.nightscout.shared.interfaces.ResourceHelper import info.nightscout.shared.interfaces.ResourceHelper
import info.nightscout.shared.utils.T import info.nightscout.shared.utils.T

View file

@ -1,9 +1,9 @@
package info.nightscout.androidaps.plugins.general.overview.graphExtensions package info.nightscout.core.graph.data
import android.content.Context import android.content.Context
import info.nightscout.androidaps.extensions.toStringTotal import info.nightscout.core.graph.R
import info.nightscout.core.main.R
import info.nightscout.database.entities.ExtendedBolus import info.nightscout.database.entities.ExtendedBolus
import info.nightscout.interfaces.utils.DecimalFormatter
import info.nightscout.shared.interfaces.ResourceHelper import info.nightscout.shared.interfaces.ResourceHelper
class ExtendedBolusDataPoint( class ExtendedBolusDataPoint(
@ -26,4 +26,6 @@ class ExtendedBolusDataPoint(
override fun setY(y: Double) { override fun setY(y: Double) {
yValue = y yValue = y
} }
private fun ExtendedBolus.toStringTotal(): String = "${DecimalFormatter.to2Decimal(amount)}U ( ${DecimalFormatter.to2Decimal(rate)} U/h )"
} }

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.plugins.general.overview.graphExtensions; package info.nightscout.core.graph.data;
import android.graphics.Canvas; import android.graphics.Canvas;
import android.graphics.Color; import android.graphics.Color;

View file

@ -1,12 +1,11 @@
package info.nightscout.androidaps.plugins.general.overview.graphExtensions package info.nightscout.core.graph.data
import android.content.Context import android.content.Context
import info.nightscout.androidaps.utils.DefaultValueHelper import info.nightscout.core.graph.R
import info.nightscout.core.main.R
import info.nightscout.core.profile.toCurrentUnitsString
import info.nightscout.database.entities.GlucoseValue import info.nightscout.database.entities.GlucoseValue
import info.nightscout.interfaces.Constants import info.nightscout.interfaces.Constants
import info.nightscout.interfaces.GlucoseUnit import info.nightscout.interfaces.GlucoseUnit
import info.nightscout.interfaces.profile.DefaultValueHelper
import info.nightscout.interfaces.profile.Profile import info.nightscout.interfaces.profile.Profile
import info.nightscout.interfaces.profile.ProfileFunction import info.nightscout.interfaces.profile.ProfileFunction
import info.nightscout.shared.interfaces.ResourceHelper import info.nightscout.shared.interfaces.ResourceHelper

View file

@ -1,7 +1,7 @@
package info.nightscout.androidaps.plugins.general.overview.graphExtensions package info.nightscout.core.graph.data
import android.content.Context import android.content.Context
import info.nightscout.core.main.R import info.nightscout.core.graph.R
import info.nightscout.interfaces.Constants import info.nightscout.interfaces.Constants
import info.nightscout.interfaces.GlucoseUnit import info.nightscout.interfaces.GlucoseUnit
import info.nightscout.interfaces.iob.InMemoryGlucoseValue import info.nightscout.interfaces.iob.InMemoryGlucoseValue

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.plugins.general.overview.graphExtensions; package info.nightscout.core.graph.data;
import android.graphics.Canvas; import android.graphics.Canvas;
import android.graphics.Color; import android.graphics.Color;
@ -17,7 +17,7 @@ import com.jjoe64.graphview.series.BaseSeries;
import java.util.Iterator; import java.util.Iterator;
import info.nightscout.core.main.R; import info.nightscout.core.graph.R;
/** /**
* Series that plots the data as points. * Series that plots the data as points.
@ -96,7 +96,6 @@ public class PointsWithLabelGraphSeries<E extends DataPointWithLabelInterface> e
* @param isSecondScale whether it is the second scale * @param isSecondScale whether it is the second scale
*/ */
@Override @Override
@SuppressWarnings({"deprecation"})
public void draw(GraphView graphView, Canvas canvas, boolean isSecondScale) { public void draw(GraphView graphView, Canvas canvas, boolean isSecondScale) {
// Convert the sp to pixels // Convert the sp to pixels
float scaledTextSize = spSize * graphView.getContext().getResources().getDisplayMetrics().scaledDensity; float scaledTextSize = spSize * graphView.getContext().getResources().getDisplayMetrics().scaledDensity;

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.plugins.general.overview.graphExtensions package info.nightscout.core.graph.data
class Scale(var shift: Double = 0.0, var multiplier: Double = 1.0) { class Scale(var shift: Double = 0.0, var multiplier: Double = 1.0) {

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.plugins.general.overview.graphExtensions package info.nightscout.core.graph.data
import com.jjoe64.graphview.series.DataPointInterface import com.jjoe64.graphview.series.DataPointInterface

View file

@ -1,12 +1,10 @@
package info.nightscout.androidaps.plugins.general.overview.graphExtensions package info.nightscout.core.graph.data
import android.content.Context import android.content.Context
import info.nightscout.androidaps.utils.Translator import info.nightscout.core.graph.R
import info.nightscout.core.main.R
import info.nightscout.core.profile.fromMgdlToUnits
import info.nightscout.core.profile.toUnits
import info.nightscout.database.entities.TherapyEvent import info.nightscout.database.entities.TherapyEvent
import info.nightscout.interfaces.Constants import info.nightscout.interfaces.Constants
import info.nightscout.interfaces.Translator
import info.nightscout.interfaces.profile.Profile import info.nightscout.interfaces.profile.Profile
import info.nightscout.interfaces.profile.ProfileFunction import info.nightscout.interfaces.profile.ProfileFunction
import info.nightscout.shared.interfaces.ResourceHelper import info.nightscout.shared.interfaces.ResourceHelper

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.plugins.general.overview.graphExtensions; package info.nightscout.core.graph.data;
import com.jjoe64.graphview.DefaultLabelFormatter; import com.jjoe64.graphview.DefaultLabelFormatter;
@ -29,10 +29,11 @@ public class TimeAsXAxisLabelFormatter extends DefaultLabelFormatter {
// Fatal Exception: java.lang.NullPointerException // Fatal Exception: java.lang.NullPointerException
// Attempt to invoke virtual method 'double com.jjoe64.graphview.Viewport.getMaxY(boolean)' on a null object reference // Attempt to invoke virtual method 'double com.jjoe64.graphview.Viewport.getMaxY(boolean)' on a null object reference
// com.jjoe64.graphview.DefaultLabelFormatter.formatLabel (DefaultLabelFormatter.java:89) // com.jjoe64.graphview.DefaultLabelFormatter.formatLabel (DefaultLabelFormatter.java:89)
// info.nightscout.androidaps.plugins.general.overview.graphExtensions.TimeAsXAxisLabelFormatter.formatLabel (TimeAsXAxisLabelFormatter.java:26) // info.nightscout.core.graph.data.TimeAsXAxisLabelFormatter.formatLabel (TimeAsXAxisLabelFormatter.java:26)
// com.jjoe64.graphview.GridLabelRenderer.drawVerticalSteps (GridLabelRenderer.java:1057) // com.jjoe64.graphview.GridLabelRenderer.drawVerticalSteps (GridLabelRenderer.java:1057)
// com.jjoe64.graphview.GridLabelRenderer.draw (GridLabelRenderer.java:866) // com.jjoe64.graphview.GridLabelRenderer.draw (GridLabelRenderer.java:866)
// com.jjoe64.graphview.GraphView.onDraw (GraphView.java:296) // com.jjoe64.graphview.GraphView.onDraw (GraphView.java:296)
//noinspection ConstantConditions
return super.formatLabel(value, isValueX); return super.formatLabel(value, isValueX);
} catch (Exception ignored) { } catch (Exception ignored) {
return ""; return "";

View file

@ -5,5 +5,5 @@
android:viewportHeight="24"> android:viewportHeight="24">
<path <path
android:pathData="M20.132,10.032c-0.141,-0.437 -0.519,-0.756 -0.975,-0.822L14.96,8.6l-1.878,-3.803c-0.406,-0.825 -1.758,-0.825 -2.164,0L9.04,8.6L4.842,9.21C4.388,9.276 4.01,9.594 3.868,10.032c-0.142,0.437 -0.024,0.917 0.305,1.237l3.038,2.96L6.495,18.41c-0.078,0.454 0.108,0.912 0.48,1.181c0.21,0.153 0.459,0.231 0.709,0.231c0.192,0 0.385,-0.047 0.561,-0.14L12,17.71l3.755,1.973c0.409,0.213 0.898,0.181 1.273,-0.091c0.371,-0.269 0.557,-0.729 0.479,-1.181l-0.717,-4.182l3.037,-2.96C20.155,10.948 20.275,10.468 20.132,10.032zM18.689,10.686l-3.16,3.081l0.746,4.35c0.014,0.087 -0.021,0.174 -0.092,0.225c-0.04,0.03 -0.087,0.044 -0.135,0.044c-0.036,0 -0.073,-0.008 -0.108,-0.027l-3.907,-2.053L8.126,18.36c-0.075,0.044 -0.17,0.036 -0.242,-0.017c-0.07,-0.051 -0.106,-0.138 -0.091,-0.225l0.746,-4.35l-3.162,-3.081c-0.063,-0.061 -0.085,-0.153 -0.058,-0.236c0.027,-0.083 0.099,-0.143 0.185,-0.156L9.874,9.66l1.954,-3.959c0.078,-0.158 0.334,-0.158 0.412,0l1.953,3.959l4.369,0.634c0.087,0.013 0.158,0.073 0.185,0.156S18.753,10.625 18.689,10.686z" android:pathData="M20.132,10.032c-0.141,-0.437 -0.519,-0.756 -0.975,-0.822L14.96,8.6l-1.878,-3.803c-0.406,-0.825 -1.758,-0.825 -2.164,0L9.04,8.6L4.842,9.21C4.388,9.276 4.01,9.594 3.868,10.032c-0.142,0.437 -0.024,0.917 0.305,1.237l3.038,2.96L6.495,18.41c-0.078,0.454 0.108,0.912 0.48,1.181c0.21,0.153 0.459,0.231 0.709,0.231c0.192,0 0.385,-0.047 0.561,-0.14L12,17.71l3.755,1.973c0.409,0.213 0.898,0.181 1.273,-0.091c0.371,-0.269 0.557,-0.729 0.479,-1.181l-0.717,-4.182l3.037,-2.96C20.155,10.948 20.275,10.468 20.132,10.032zM18.689,10.686l-3.16,3.081l0.746,4.35c0.014,0.087 -0.021,0.174 -0.092,0.225c-0.04,0.03 -0.087,0.044 -0.135,0.044c-0.036,0 -0.073,-0.008 -0.108,-0.027l-3.907,-2.053L8.126,18.36c-0.075,0.044 -0.17,0.036 -0.242,-0.017c-0.07,-0.051 -0.106,-0.138 -0.091,-0.225l0.746,-4.35l-3.162,-3.081c-0.063,-0.061 -0.085,-0.153 -0.058,-0.236c0.027,-0.083 0.099,-0.143 0.185,-0.156L9.874,9.66l1.954,-3.959c0.078,-0.158 0.334,-0.158 0.412,0l1.953,3.959l4.369,0.634c0.087,0.013 0.158,0.073 0.185,0.156S18.753,10.625 18.689,10.686z"
android:fillColor="?attr/profileColor"/> android:fillColor="?attr/profileColor" />
</vector> </vector>

View file

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="format_carbs">%1$d g</string>
</resources>

View file

@ -1,23 +0,0 @@
package info.nightscout.core.ui
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.platform.app.InstrumentationRegistry
import org.junit.Assert.*
import org.junit.Test
import org.junit.runner.RunWith
/**
* Instrumented test, which will execute on an Android device.
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
@RunWith(AndroidJUnit4::class)
class ExampleInstrumentedTest {
@Test
fun useAppContext() {
// Context of the app under test.
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
assertEquals("info.nightscout.core.ui.test", appContext.packageName)
}
}

View file

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<inset xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
tools:ignore="PrivateResource"
android:insetLeft="16dp"
android:insetTop="16dp"
android:insetRight="16dp"
android:insetBottom="16dp">
<shape android:shape="rectangle">
<corners android:radius="2dp" />
<solid android:color="@color/background_floating_material_dark" />
<stroke
android:color="@color/errorAlertBackground"
android:width="3dp" />
</shape>
</inset>

View file

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<inset xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
tools:ignore="PrivateResource"
android:insetLeft="16dp"
android:insetTop="16dp"
android:insetRight="16dp"
android:insetBottom="16dp">
<shape android:shape="rectangle">
<corners android:radius="2dp" />
<solid android:color="@color/background_floating_material_dark" />
<stroke
android:color="@color/warningAlertBackground"
android:width="3dp" />
</shape>
</inset>

View file

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 24 KiB

View file

@ -8,6 +8,7 @@
<string name="dismiss">DISMISS</string> <string name="dismiss">DISMISS</string>
<string name="yes">Yes</string> <string name="yes">Yes</string>
<string name="no">No</string> <string name="no">No</string>
<string name="close">Close</string>
<!-- TwoMessagesDialog --> <!-- TwoMessagesDialog -->
<string name="password_preferences_decrypt_prompt">You will be asked for master password, which is needed to decrypt imported preferences.</string> <string name="password_preferences_decrypt_prompt">You will be asked for master password, which is needed to decrypt imported preferences.</string>

View file

@ -1,17 +0,0 @@
package info.nightscout.core.ui
import org.junit.Assert.*
import org.junit.Test
/**
* Example local unit test, which will execute on the development machine (host).
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
class ExampleUnitTest {
@Test
fun addition_isCorrect() {
assertEquals(4, 2 + 2)
}
}

View file

@ -29,6 +29,8 @@ files:
translation: /core/utils/src/main/res/values-%android_code%/strings.xml translation: /core/utils/src/main/res/values-%android_code%/strings.xml
- source: /core/ui/src/main/res/values/strings.xml - source: /core/ui/src/main/res/values/strings.xml
translation: /core/ui/src/main/res/values-%android_code%/strings.xml translation: /core/ui/src/main/res/values-%android_code%/strings.xml
- source: /core/graph/src/main/res/values/strings.xml
translation: /core/graph/src/main/res/values-%android_code%/strings.xml
- source: /app-wear-shared/shared/src/main/res/values/strings.xml - source: /app-wear-shared/shared/src/main/res/values/strings.xml
translation: /app-wear-shared/shared/src/main/res/values-%android_code%/strings.xml translation: /app-wear-shared/shared/src/main/res/values-%android_code%/strings.xml
- source: /app-wear-shared/rx/src/main/res/values/strings.xml - source: /app-wear-shared/rx/src/main/res/values/strings.xml

View file

@ -18,16 +18,17 @@ android {
dependencies { dependencies {
implementation project(':app-wear-shared:rx') implementation project(':app-wear-shared:rx')
implementation project(':app-wear-shared:shared') implementation project(':app-wear-shared:shared')
implementation project(path: ':graphview')
implementation project(':database:entities') implementation project(':database:entities')
implementation project(':database:impl') implementation project(':database:impl')
implementation project(':plugins:automation') implementation project(':plugins:automation')
implementation project(':interfaces') implementation project(':interfaces')
implementation project(':core:core-main') implementation project(':core:core-main')
implementation project(':core:utils') implementation project(':core:graph')
implementation project(':core:ui') implementation project(':core:ui')
implementation project(':core:utils')
implementation project(':ui') implementation project(':ui')
// Protection // Protection
api 'androidx.biometric:biometric:1.1.0' api 'androidx.biometric:biometric:1.1.0'
} }

View file

@ -1,10 +1,10 @@
package info.nightscout.androidaps.utils package info.nightscout.implementation
import info.nightscout.androidaps.annotations.OpenForTesting import info.nightscout.androidaps.annotations.OpenForTesting
import info.nightscout.core.main.R import info.nightscout.core.main.R
import info.nightscout.core.profile.toCurrentUnits
import info.nightscout.interfaces.Constants import info.nightscout.interfaces.Constants
import info.nightscout.interfaces.GlucoseUnit import info.nightscout.interfaces.GlucoseUnit
import info.nightscout.interfaces.profile.DefaultValueHelper
import info.nightscout.interfaces.profile.Profile import info.nightscout.interfaces.profile.Profile
import info.nightscout.interfaces.profile.ProfileFunction import info.nightscout.interfaces.profile.ProfileFunction
import info.nightscout.shared.sharedPreferences.SP import info.nightscout.shared.sharedPreferences.SP
@ -13,10 +13,10 @@ import javax.inject.Singleton
@OpenForTesting @OpenForTesting
@Singleton @Singleton
class DefaultValueHelper @Inject constructor( class DefaultValueHelperImpl @Inject constructor(
private val sp: SP, private val sp: SP,
private val profileFunction: ProfileFunction private val profileFunction: ProfileFunction
) { ) : DefaultValueHelper {
/** /**
* returns the corresponding EatingSoon TempTarget based on the given units (MMOL / MGDL) * returns the corresponding EatingSoon TempTarget based on the given units (MMOL / MGDL)
@ -53,14 +53,14 @@ class DefaultValueHelper @Inject constructor(
* *
* @return * @return
*/ */
fun determineEatingSoonTT(): Double { override fun determineEatingSoonTT(): Double {
val units = profileFunction.getUnits() val units = profileFunction.getUnits()
var value = sp.getDouble(R.string.key_eatingsoon_target, getDefaultEatingSoonTT(units)) var value = sp.getDouble(R.string.key_eatingsoon_target, getDefaultEatingSoonTT(units))
value = Profile.toCurrentUnits(profileFunction, value) value = Profile.toCurrentUnits(profileFunction, value)
return if (value > 0) value else getDefaultEatingSoonTT(units) return if (value > 0) value else getDefaultEatingSoonTT(units)
} }
fun determineEatingSoonTTDuration(): Int { override fun determineEatingSoonTTDuration(): Int {
val value = sp.getInt(R.string.key_eatingsoon_duration, Constants.defaultEatingSoonTTDuration) val value = sp.getInt(R.string.key_eatingsoon_duration, Constants.defaultEatingSoonTTDuration)
return if (value > 0) value else Constants.defaultEatingSoonTTDuration return if (value > 0) value else Constants.defaultEatingSoonTTDuration
} }
@ -70,14 +70,14 @@ class DefaultValueHelper @Inject constructor(
* *
* @return * @return
*/ */
fun determineActivityTT(): Double { override fun determineActivityTT(): Double {
val units = profileFunction.getUnits() val units = profileFunction.getUnits()
var value = sp.getDouble(R.string.key_activity_target, getDefaultActivityTT(units)) var value = sp.getDouble(R.string.key_activity_target, getDefaultActivityTT(units))
value = Profile.toCurrentUnits(profileFunction, value) value = Profile.toCurrentUnits(profileFunction, value)
return if (value > 0) value else getDefaultActivityTT(units) return if (value > 0) value else getDefaultActivityTT(units)
} }
fun determineActivityTTDuration(): Int { override fun determineActivityTTDuration(): Int {
val value = sp.getInt(R.string.key_activity_duration, Constants.defaultActivityTTDuration) val value = sp.getInt(R.string.key_activity_duration, Constants.defaultActivityTTDuration)
return if (value > 0) value else Constants.defaultActivityTTDuration return if (value > 0) value else Constants.defaultActivityTTDuration
} }
@ -87,29 +87,29 @@ class DefaultValueHelper @Inject constructor(
* *
* @return * @return
*/ */
fun determineHypoTT(): Double { override fun determineHypoTT(): Double {
val units = profileFunction.getUnits() val units = profileFunction.getUnits()
var value = sp.getDouble(R.string.key_hypo_target, getDefaultHypoTT(units)) var value = sp.getDouble(R.string.key_hypo_target, getDefaultHypoTT(units))
value = Profile.toCurrentUnits(profileFunction, value) value = Profile.toCurrentUnits(profileFunction, value)
return if (value > 0) value else getDefaultHypoTT(units) return if (value > 0) value else getDefaultHypoTT(units)
} }
fun determineHypoTTDuration(): Int { override fun determineHypoTTDuration(): Int {
val value = sp.getInt(R.string.key_hypo_duration, Constants.defaultHypoTTDuration) val value = sp.getInt(R.string.key_hypo_duration, Constants.defaultHypoTTDuration)
return if (value > 0) value else Constants.defaultHypoTTDuration return if (value > 0) value else Constants.defaultHypoTTDuration
} }
var bgTargetLow = 80.0 override var bgTargetLow = 80.0
var bgTargetHigh = 180.0 override var bgTargetHigh = 180.0
fun determineHighLine(): Double { override fun determineHighLine(): Double {
var highLineSetting = sp.getDouble(R.string.key_high_mark, bgTargetHigh) var highLineSetting = sp.getDouble(R.string.key_high_mark, bgTargetHigh)
if (highLineSetting < 1) highLineSetting = Constants.HIGH_MARK if (highLineSetting < 1) highLineSetting = Constants.HIGH_MARK
highLineSetting = Profile.toCurrentUnits(profileFunction, highLineSetting) highLineSetting = Profile.toCurrentUnits(profileFunction, highLineSetting)
return highLineSetting return highLineSetting
} }
fun determineLowLine(): Double { override fun determineLowLine(): Double {
var lowLineSetting = sp.getDouble(R.string.key_low_mark, bgTargetLow) var lowLineSetting = sp.getDouble(R.string.key_low_mark, bgTargetLow)
if (lowLineSetting < 1) lowLineSetting = Constants.LOW_MARK if (lowLineSetting < 1) lowLineSetting = Constants.LOW_MARK
lowLineSetting = Profile.toCurrentUnits(profileFunction, lowLineSetting) lowLineSetting = Profile.toCurrentUnits(profileFunction, lowLineSetting)

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.utils package info.nightscout.implementation
import info.nightscout.core.main.R import info.nightscout.core.main.R
import info.nightscout.database.entities.OfflineEvent import info.nightscout.database.entities.OfflineEvent
@ -7,16 +7,17 @@ import info.nightscout.database.entities.TherapyEvent
import info.nightscout.database.entities.UserEntry.Action import info.nightscout.database.entities.UserEntry.Action
import info.nightscout.database.entities.UserEntry.Sources import info.nightscout.database.entities.UserEntry.Sources
import info.nightscout.database.entities.ValueWithUnit import info.nightscout.database.entities.ValueWithUnit
import info.nightscout.interfaces.Translator
import info.nightscout.shared.interfaces.ResourceHelper import info.nightscout.shared.interfaces.ResourceHelper
import javax.inject.Inject import javax.inject.Inject
import javax.inject.Singleton import javax.inject.Singleton
@Singleton @Singleton
class Translator @Inject internal constructor( class TranslatorImpl @Inject internal constructor(
private val rh: ResourceHelper private val rh: ResourceHelper
) { ) : Translator {
fun translate(action: Action): String = when (action) { override fun translate(action: Action): String = when (action) {
Action.BOLUS -> rh.gs(R.string.uel_bolus) Action.BOLUS -> rh.gs(R.string.uel_bolus)
Action.BOLUS_CALCULATOR_RESULT -> rh.gs(R.string.uel_bolus_calculator) Action.BOLUS_CALCULATOR_RESULT -> rh.gs(R.string.uel_bolus_calculator)
Action.BOLUS_CALCULATOR_RESULT_REMOVED -> rh.gs(R.string.uel_bolus_calculator) Action.BOLUS_CALCULATOR_RESULT_REMOVED -> rh.gs(R.string.uel_bolus_calculator)
@ -105,7 +106,7 @@ class Translator @Inject internal constructor(
Action.UNKNOWN -> rh.gs(R.string.unknown) Action.UNKNOWN -> rh.gs(R.string.unknown)
} }
fun translate(units: ValueWithUnit?): String = when (units) { override fun translate(units: ValueWithUnit?): String = when (units) {
is ValueWithUnit.Gram -> rh.gs(R.string.shortgram) is ValueWithUnit.Gram -> rh.gs(R.string.shortgram)
is ValueWithUnit.Hour -> rh.gs(R.string.shorthour) is ValueWithUnit.Hour -> rh.gs(R.string.shorthour)
is ValueWithUnit.Insulin -> rh.gs(R.string.insulin_unit_shortname) is ValueWithUnit.Insulin -> rh.gs(R.string.insulin_unit_shortname)
@ -117,7 +118,7 @@ class Translator @Inject internal constructor(
else -> "" else -> ""
} }
fun translate(meterType: TherapyEvent.MeterType?): String = when (meterType) { override fun translate(meterType: TherapyEvent.MeterType?): String = when (meterType) {
TherapyEvent.MeterType.FINGER -> rh.gs(R.string.glucosetype_finger) TherapyEvent.MeterType.FINGER -> rh.gs(R.string.glucosetype_finger)
TherapyEvent.MeterType.SENSOR -> rh.gs(R.string.glucosetype_sensor) TherapyEvent.MeterType.SENSOR -> rh.gs(R.string.glucosetype_sensor)
TherapyEvent.MeterType.MANUAL -> rh.gs(R.string.manual) TherapyEvent.MeterType.MANUAL -> rh.gs(R.string.manual)
@ -125,7 +126,7 @@ class Translator @Inject internal constructor(
else -> rh.gs(R.string.unknown) else -> rh.gs(R.string.unknown)
} }
fun translate(type: TherapyEvent.Type?): String = when (type) { override fun translate(type: TherapyEvent.Type?): String = when (type) {
TherapyEvent.Type.FINGER_STICK_BG_VALUE -> rh.gs(R.string.careportal_bgcheck) TherapyEvent.Type.FINGER_STICK_BG_VALUE -> rh.gs(R.string.careportal_bgcheck)
TherapyEvent.Type.SNACK_BOLUS -> rh.gs(R.string.careportal_snackbolus) TherapyEvent.Type.SNACK_BOLUS -> rh.gs(R.string.careportal_snackbolus)
TherapyEvent.Type.MEAL_BOLUS -> rh.gs(R.string.careportal_mealbolus) TherapyEvent.Type.MEAL_BOLUS -> rh.gs(R.string.careportal_mealbolus)
@ -176,7 +177,7 @@ class Translator @Inject internal constructor(
else -> rh.gs(R.string.unknown) else -> rh.gs(R.string.unknown)
} }
fun translate(reason: TemporaryTarget.Reason?): String = when (reason) { override fun translate(reason: TemporaryTarget.Reason?): String = when (reason) {
TemporaryTarget.Reason.CUSTOM -> rh.gs(R.string.custom) TemporaryTarget.Reason.CUSTOM -> rh.gs(R.string.custom)
TemporaryTarget.Reason.HYPOGLYCEMIA -> rh.gs(R.string.hypo) TemporaryTarget.Reason.HYPOGLYCEMIA -> rh.gs(R.string.hypo)
TemporaryTarget.Reason.EATING_SOON -> rh.gs(R.string.eatingsoon) TemporaryTarget.Reason.EATING_SOON -> rh.gs(R.string.eatingsoon)
@ -187,7 +188,7 @@ class Translator @Inject internal constructor(
else -> rh.gs(R.string.unknown) else -> rh.gs(R.string.unknown)
} }
fun translate(reason: OfflineEvent.Reason?): String = when (reason) { override fun translate(reason: OfflineEvent.Reason?): String = when (reason) {
OfflineEvent.Reason.SUSPEND -> rh.gs(R.string.uel_suspend) OfflineEvent.Reason.SUSPEND -> rh.gs(R.string.uel_suspend)
OfflineEvent.Reason.DISABLE_LOOP -> rh.gs(R.string.disableloop) OfflineEvent.Reason.DISABLE_LOOP -> rh.gs(R.string.disableloop)
OfflineEvent.Reason.DISCONNECT_PUMP -> rh.gs(R.string.uel_disconnect) OfflineEvent.Reason.DISCONNECT_PUMP -> rh.gs(R.string.uel_disconnect)
@ -196,7 +197,7 @@ class Translator @Inject internal constructor(
else -> rh.gs(R.string.unknown) else -> rh.gs(R.string.unknown)
} }
fun translate(source: Sources): String = when (source) { override fun translate(source: Sources): String = when (source) {
/* /*
Sources.TreatmentDialog -> TODO() Sources.TreatmentDialog -> TODO()
Sources.InsulinDialog -> TODO() Sources.InsulinDialog -> TODO()

View file

@ -6,20 +6,28 @@ import dagger.Module
import dagger.Provides import dagger.Provides
import info.nightscout.androidaps.plugins.constraints.versionChecker.VersionCheckerUtils import info.nightscout.androidaps.plugins.constraints.versionChecker.VersionCheckerUtils
import info.nightscout.androidaps.plugins.general.maintenance.formats.EncryptedPrefsFormat import info.nightscout.androidaps.plugins.general.maintenance.formats.EncryptedPrefsFormat
import info.nightscout.core.graph.OverviewData
import info.nightscout.core.utils.CryptoUtil import info.nightscout.core.utils.CryptoUtil
import info.nightscout.core.utils.fabric.FabricPrivacy import info.nightscout.core.utils.fabric.FabricPrivacy
import info.nightscout.database.impl.AppRepository import info.nightscout.database.impl.AppRepository
import info.nightscout.implementation.DefaultValueHelperImpl
import info.nightscout.implementation.HardLimitsImpl import info.nightscout.implementation.HardLimitsImpl
import info.nightscout.implementation.TranslatorImpl
import info.nightscout.implementation.logging.LoggerUtilsImpl import info.nightscout.implementation.logging.LoggerUtilsImpl
import info.nightscout.implementation.maintenance.PrefFileListProviderImpl import info.nightscout.implementation.maintenance.PrefFileListProviderImpl
import info.nightscout.implementation.overview.OverviewDataImpl
import info.nightscout.implementation.profiling.ProfilerImpl import info.nightscout.implementation.profiling.ProfilerImpl
import info.nightscout.implementation.protection.PasswordCheckImpl import info.nightscout.implementation.protection.PasswordCheckImpl
import info.nightscout.implementation.protection.ProtectionCheckImpl import info.nightscout.implementation.protection.ProtectionCheckImpl
import info.nightscout.implementation.pump.WarnColorsImpl import info.nightscout.implementation.pump.WarnColorsImpl
import info.nightscout.implementation.resources.ResourceHelperImpl import info.nightscout.implementation.resources.ResourceHelperImpl
import info.nightscout.interfaces.Config import info.nightscout.interfaces.Config
import info.nightscout.interfaces.Translator
import info.nightscout.interfaces.logging.LoggerUtils import info.nightscout.interfaces.logging.LoggerUtils
import info.nightscout.interfaces.maintenance.PrefFileListProvider import info.nightscout.interfaces.maintenance.PrefFileListProvider
import info.nightscout.interfaces.plugin.ActivePlugin
import info.nightscout.interfaces.profile.DefaultValueHelper
import info.nightscout.interfaces.profile.ProfileFunction
import info.nightscout.interfaces.profiling.Profiler import info.nightscout.interfaces.profiling.Profiler
import info.nightscout.interfaces.protection.PasswordCheck import info.nightscout.interfaces.protection.PasswordCheck
import info.nightscout.interfaces.protection.ProtectionCheck import info.nightscout.interfaces.protection.ProtectionCheck
@ -72,6 +80,27 @@ open class ImplementationModule {
@Singleton @Singleton
fun provideProtectionCheck(sp: SP, passwordCheck: PasswordCheck, dateUtil: DateUtil): ProtectionCheck = ProtectionCheckImpl(sp, passwordCheck, dateUtil) fun provideProtectionCheck(sp: SP, passwordCheck: PasswordCheck, dateUtil: DateUtil): ProtectionCheck = ProtectionCheckImpl(sp, passwordCheck, dateUtil)
@Provides
@Singleton
fun provideDefaultValueHelper(sp: SP, profileFunction: ProfileFunction): DefaultValueHelper = DefaultValueHelperImpl(sp, profileFunction)
@Provides
@Singleton
fun provideTranslator(rh: ResourceHelper): Translator = TranslatorImpl(rh)
@Provides
@Singleton
fun provideOverviewData(
aapsLogger: AAPSLogger,
rh: ResourceHelper,
dateUtil: DateUtil,
sp: SP,
activePlugin: ActivePlugin,
defaultValueHelper: DefaultValueHelper,
profileFunction: ProfileFunction,
repository: AppRepository
): OverviewData = OverviewDataImpl(aapsLogger, rh, dateUtil, sp, activePlugin, defaultValueHelper, profileFunction, repository)
@Provides @Provides
@Singleton @Singleton
fun providePrefFileListProvider( fun providePrefFileListProvider(

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.plugins.general.overview package info.nightscout.implementation.overview
import android.content.Context import android.content.Context
import androidx.annotation.AttrRes import androidx.annotation.AttrRes
@ -12,13 +12,13 @@ import info.nightscout.androidaps.extensions.isInProgress
import info.nightscout.androidaps.extensions.toStringFull import info.nightscout.androidaps.extensions.toStringFull
import info.nightscout.androidaps.extensions.toStringShort import info.nightscout.androidaps.extensions.toStringShort
import info.nightscout.androidaps.extensions.valueToUnits import info.nightscout.androidaps.extensions.valueToUnits
import info.nightscout.androidaps.plugins.general.overview.graphExtensions.DataPointWithLabelInterface import info.nightscout.core.graph.OverviewData
import info.nightscout.androidaps.plugins.general.overview.graphExtensions.DeviationDataPoint import info.nightscout.core.graph.data.DataPointWithLabelInterface
import info.nightscout.androidaps.plugins.general.overview.graphExtensions.FixedLineGraphSeries import info.nightscout.core.graph.data.DeviationDataPoint
import info.nightscout.androidaps.plugins.general.overview.graphExtensions.PointsWithLabelGraphSeries import info.nightscout.core.graph.data.FixedLineGraphSeries
import info.nightscout.androidaps.plugins.general.overview.graphExtensions.Scale import info.nightscout.core.graph.data.PointsWithLabelGraphSeries
import info.nightscout.androidaps.plugins.general.overview.graphExtensions.ScaledDataPoint import info.nightscout.core.graph.data.Scale
import info.nightscout.androidaps.utils.DefaultValueHelper import info.nightscout.core.graph.data.ScaledDataPoint
import info.nightscout.core.iob.round import info.nightscout.core.iob.round
import info.nightscout.core.main.R import info.nightscout.core.main.R
import info.nightscout.database.entities.GlucoseValue import info.nightscout.database.entities.GlucoseValue
@ -30,6 +30,7 @@ import info.nightscout.interfaces.iob.CobInfo
import info.nightscout.interfaces.iob.IobCobCalculator import info.nightscout.interfaces.iob.IobCobCalculator
import info.nightscout.interfaces.iob.IobTotal import info.nightscout.interfaces.iob.IobTotal
import info.nightscout.interfaces.plugin.ActivePlugin import info.nightscout.interfaces.plugin.ActivePlugin
import info.nightscout.interfaces.profile.DefaultValueHelper
import info.nightscout.interfaces.profile.ProfileFunction import info.nightscout.interfaces.profile.ProfileFunction
import info.nightscout.rx.logging.AAPSLogger import info.nightscout.rx.logging.AAPSLogger
import info.nightscout.shared.interfaces.ResourceHelper import info.nightscout.shared.interfaces.ResourceHelper
@ -41,7 +42,7 @@ import javax.inject.Inject
import javax.inject.Singleton import javax.inject.Singleton
@Singleton @Singleton
class OverviewData @Inject constructor( class OverviewDataImpl @Inject constructor(
private val aapsLogger: AAPSLogger, private val aapsLogger: AAPSLogger,
private val rh: ResourceHelper, private val rh: ResourceHelper,
private val dateUtil: DateUtil, private val dateUtil: DateUtil,
@ -50,14 +51,14 @@ class OverviewData @Inject constructor(
private val defaultValueHelper: DefaultValueHelper, private val defaultValueHelper: DefaultValueHelper,
private val profileFunction: ProfileFunction, private val profileFunction: ProfileFunction,
private val repository: AppRepository private val repository: AppRepository
) { ) : OverviewData {
var rangeToDisplay = 6 // for graph override var rangeToDisplay = 6 // for graph
var toTime: Long = 0 override var toTime: Long = 0
var fromTime: Long = 0 override var fromTime: Long = 0
var endTime: Long = 0 override var endTime: Long = 0
fun reset() { override fun reset() {
pumpStatus = "" pumpStatus = ""
calcProgressPct = 100 calcProgressPct = 100
bgReadingsArray = ArrayList() bgReadingsArray = ArrayList()
@ -86,7 +87,7 @@ class OverviewData @Inject constructor(
epsSeries = PointsWithLabelGraphSeries() epsSeries = PointsWithLabelGraphSeries()
} }
fun initRange() { override fun initRange() {
rangeToDisplay = sp.getInt(R.string.key_rangetodisplay, 6) rangeToDisplay = sp.getInt(R.string.key_rangetodisplay, 6)
val calendar = Calendar.getInstance().also { val calendar = Calendar.getInstance().also {
@ -106,51 +107,51 @@ class OverviewData @Inject constructor(
* PUMP STATUS * PUMP STATUS
*/ */
var pumpStatus: String = "" override var pumpStatus: String = ""
/* /*
* CALC PROGRESS * CALC PROGRESS
*/ */
var calcProgressPct: Int = 100 override var calcProgressPct: Int = 100
/* /*
* BG * BG
*/ */
val lastBg: GlucoseValue? override val lastBg: GlucoseValue?
get() = get() =
repository.getLastGlucoseValueWrapped().blockingGet().let { gvWrapped -> repository.getLastGlucoseValueWrapped().blockingGet().let { gvWrapped ->
if (gvWrapped is ValueWrapper.Existing) gvWrapped.value if (gvWrapped is ValueWrapper.Existing) gvWrapped.value
else null else null
} }
val isLow: Boolean override val isLow: Boolean
get() = lastBg?.let { lastBg -> get() = lastBg?.let { lastBg ->
lastBg.valueToUnits(profileFunction.getUnits()) < defaultValueHelper.determineLowLine() lastBg.valueToUnits(profileFunction.getUnits()) < defaultValueHelper.determineLowLine()
} ?: false } ?: false
val isHigh: Boolean override val isHigh: Boolean
get() = lastBg?.let { lastBg -> get() = lastBg?.let { lastBg ->
lastBg.valueToUnits(profileFunction.getUnits()) > defaultValueHelper.determineHighLine() lastBg.valueToUnits(profileFunction.getUnits()) > defaultValueHelper.determineHighLine()
} ?: false } ?: false
@ColorInt @ColorInt
fun lastBgColor(context: Context?): Int = override fun lastBgColor(context: Context?): Int =
when { when {
isLow -> rh.gac(context, R.attr.bgLow) isLow -> rh.gac(context, R.attr.bgLow)
isHigh -> rh.gac(context, R.attr.highColor) isHigh -> rh.gac(context, R.attr.highColor)
else -> rh.gac(context, R.attr.bgInRange) else -> rh.gac(context, R.attr.bgInRange)
} }
val lastBgDescription: String override val lastBgDescription: String
get() = when { get() = when {
isLow -> rh.gs(R.string.a11y_low) isLow -> rh.gs(R.string.a11y_low)
isHigh -> rh.gs(R.string.a11y_high) isHigh -> rh.gs(R.string.a11y_high)
else -> rh.gs(R.string.a11y_inrange) else -> rh.gs(R.string.a11y_inrange)
} }
val isActualBg: Boolean override val isActualBg: Boolean
get() = get() =
lastBg?.let { lastBg -> lastBg?.let { lastBg ->
lastBg.timestamp > dateUtil.now() - T.mins(9).msecs() lastBg.timestamp > dateUtil.now() - T.mins(9).msecs()
@ -160,7 +161,7 @@ class OverviewData @Inject constructor(
* TEMPORARY BASAL * TEMPORARY BASAL
*/ */
fun temporaryBasalText(iobCobCalculator: IobCobCalculator): String = override fun temporaryBasalText(iobCobCalculator: IobCobCalculator): String =
profileFunction.getProfile()?.let { profile -> profileFunction.getProfile()?.let { profile ->
var temporaryBasal = iobCobCalculator.getTempBasalIncludingConvertedExtended(dateUtil.now()) var temporaryBasal = iobCobCalculator.getTempBasalIncludingConvertedExtended(dateUtil.now())
if (temporaryBasal?.isInProgress == false) temporaryBasal = null if (temporaryBasal?.isInProgress == false) temporaryBasal = null
@ -168,7 +169,7 @@ class OverviewData @Inject constructor(
?: rh.gs(R.string.pump_basebasalrate, profile.getBasal()) ?: rh.gs(R.string.pump_basebasalrate, profile.getBasal())
} ?: rh.gs(R.string.value_unavailable_short) } ?: rh.gs(R.string.value_unavailable_short)
fun temporaryBasalDialogText(iobCobCalculator: IobCobCalculator): String = override fun temporaryBasalDialogText(iobCobCalculator: IobCobCalculator): String =
profileFunction.getProfile()?.let { profile -> profileFunction.getProfile()?.let { profile ->
iobCobCalculator.getTempBasalIncludingConvertedExtended(dateUtil.now())?.let { temporaryBasal -> iobCobCalculator.getTempBasalIncludingConvertedExtended(dateUtil.now())?.let { temporaryBasal ->
"${rh.gs(R.string.base_basal_rate_label)}: ${rh.gs(R.string.pump_basebasalrate, profile.getBasal())}" + "${rh.gs(R.string.base_basal_rate_label)}: ${rh.gs(R.string.pump_basebasalrate, profile.getBasal())}" +
@ -177,7 +178,7 @@ class OverviewData @Inject constructor(
?: "${rh.gs(R.string.base_basal_rate_label)}: ${rh.gs(R.string.pump_basebasalrate, profile.getBasal())}" ?: "${rh.gs(R.string.base_basal_rate_label)}: ${rh.gs(R.string.pump_basebasalrate, profile.getBasal())}"
} ?: rh.gs(R.string.value_unavailable_short) } ?: rh.gs(R.string.value_unavailable_short)
@DrawableRes fun temporaryBasalIcon(iobCobCalculator: IobCobCalculator): Int = @DrawableRes override fun temporaryBasalIcon(iobCobCalculator: IobCobCalculator): Int =
profileFunction.getProfile()?.let { profile -> profileFunction.getProfile()?.let { profile ->
iobCobCalculator.getTempBasalIncludingConvertedExtended(dateUtil.now())?.let { temporaryBasal -> iobCobCalculator.getTempBasalIncludingConvertedExtended(dateUtil.now())?.let { temporaryBasal ->
val percentRate = temporaryBasal.convertedToPercent(dateUtil.now(), profile) val percentRate = temporaryBasal.convertedToPercent(dateUtil.now(), profile)
@ -189,50 +190,54 @@ class OverviewData @Inject constructor(
} }
} ?: R.drawable.ic_cp_basal_no_tbr } ?: R.drawable.ic_cp_basal_no_tbr
@AttrRes fun temporaryBasalColor(context: Context?, iobCobCalculator: IobCobCalculator): Int = iobCobCalculator.getTempBasalIncludingConvertedExtended(dateUtil.now())?.let { rh.gac(context, R @AttrRes override fun temporaryBasalColor(context: Context?, iobCobCalculator: IobCobCalculator): Int = iobCobCalculator.getTempBasalIncludingConvertedExtended(dateUtil.now())?.let {
.attr.basal) } rh.gac(
context, R
.attr.basal
)
}
?: rh.gac(context, R.attr.defaultTextColor) ?: rh.gac(context, R.attr.defaultTextColor)
/* /*
* EXTENDED BOLUS * EXTENDED BOLUS
*/ */
fun extendedBolusText(iobCobCalculator: IobCobCalculator): String = override fun extendedBolusText(iobCobCalculator: IobCobCalculator): String =
iobCobCalculator.getExtendedBolus(dateUtil.now())?.let { extendedBolus -> iobCobCalculator.getExtendedBolus(dateUtil.now())?.let { extendedBolus ->
if (!extendedBolus.isInProgress(dateUtil)) "" if (!extendedBolus.isInProgress(dateUtil)) ""
else if (!activePlugin.activePump.isFakingTempsByExtendedBoluses) rh.gs(R.string.pump_basebasalrate, extendedBolus.rate) else if (!activePlugin.activePump.isFakingTempsByExtendedBoluses) rh.gs(R.string.pump_basebasalrate, extendedBolus.rate)
else "" else ""
} ?: "" } ?: ""
fun extendedBolusDialogText(iobCobCalculator: IobCobCalculator): String = override fun extendedBolusDialogText(iobCobCalculator: IobCobCalculator): String =
iobCobCalculator.getExtendedBolus(dateUtil.now())?.toStringFull(dateUtil) ?: "" iobCobCalculator.getExtendedBolus(dateUtil.now())?.toStringFull(dateUtil) ?: ""
/* /*
* IOB, COB * IOB, COB
*/ */
fun bolusIob(iobCobCalculator: IobCobCalculator): IobTotal = iobCobCalculator.calculateIobFromBolus().round() override fun bolusIob(iobCobCalculator: IobCobCalculator): IobTotal = iobCobCalculator.calculateIobFromBolus().round()
fun basalIob(iobCobCalculator: IobCobCalculator): IobTotal = iobCobCalculator.calculateIobFromTempBasalsIncludingConvertedExtended().round() override fun basalIob(iobCobCalculator: IobCobCalculator): IobTotal = iobCobCalculator.calculateIobFromTempBasalsIncludingConvertedExtended().round()
fun cobInfo(iobCobCalculator: IobCobCalculator): CobInfo = iobCobCalculator.getCobInfo(true, "Overview COB") override fun cobInfo(iobCobCalculator: IobCobCalculator): CobInfo = iobCobCalculator.getCobInfo(true, "Overview COB")
val lastCarbsTime: Long override val lastCarbsTime: Long
get() = repository.getLastCarbsRecordWrapped().blockingGet().let { lastCarbs -> get() = repository.getLastCarbsRecordWrapped().blockingGet().let { lastCarbs ->
if (lastCarbs is ValueWrapper.Existing) lastCarbs.value.timestamp else 0L if (lastCarbs is ValueWrapper.Existing) lastCarbs.value.timestamp else 0L
} }
fun iobText(iobCobCalculator: IobCobCalculator): String = override fun iobText(iobCobCalculator: IobCobCalculator): String =
rh.gs(R.string.formatinsulinunits, bolusIob(iobCobCalculator).iob + basalIob(iobCobCalculator).basaliob) rh.gs(R.string.format_insulin_units, bolusIob(iobCobCalculator).iob + basalIob(iobCobCalculator).basaliob)
fun iobDialogText(iobCobCalculator: IobCobCalculator): String = override fun iobDialogText(iobCobCalculator: IobCobCalculator): String =
rh.gs(R.string.formatinsulinunits, bolusIob(iobCobCalculator).iob + basalIob(iobCobCalculator).basaliob) + "\n" + rh.gs(R.string.format_insulin_units, bolusIob(iobCobCalculator).iob + basalIob(iobCobCalculator).basaliob) + "\n" +
rh.gs(R.string.bolus) + ": " + rh.gs(R.string.formatinsulinunits, bolusIob(iobCobCalculator).iob) + "\n" + rh.gs(R.string.bolus) + ": " + rh.gs(R.string.format_insulin_units, bolusIob(iobCobCalculator).iob) + "\n" +
rh.gs(R.string.basal) + ": " + rh.gs(R.string.formatinsulinunits, basalIob(iobCobCalculator).basaliob) rh.gs(R.string.basal) + ": " + rh.gs(R.string.format_insulin_units, basalIob(iobCobCalculator).basaliob)
/* /*
* TEMP TARGET * TEMP TARGET
*/ */
val temporaryTarget: TemporaryTarget? override val temporaryTarget: TemporaryTarget?
get() = get() =
repository.getTemporaryTargetActiveAt(dateUtil.now()).blockingGet().let { tempTarget -> repository.getTemporaryTargetActiveAt(dateUtil.now()).blockingGet().let { tempTarget ->
if (tempTarget is ValueWrapper.Existing) tempTarget.value if (tempTarget is ValueWrapper.Existing) tempTarget.value
@ -243,69 +248,77 @@ class OverviewData @Inject constructor(
* SENSITIVITY * SENSITIVITY
*/ */
fun lastAutosensData(iobCobCalculator: IobCobCalculator) : AutosensData? = iobCobCalculator.ads.getLastAutosensData("Overview", aapsLogger, dateUtil) override fun lastAutosensData(iobCobCalculator: IobCobCalculator): AutosensData? = iobCobCalculator.ads.getLastAutosensData("Overview", aapsLogger, dateUtil)
/* /*
* Graphs * Graphs
*/ */
var bgReadingsArray: List<GlucoseValue> = ArrayList() override var bgReadingsArray: List<GlucoseValue> = ArrayList()
var maxBgValue = Double.MIN_VALUE override var maxBgValue = Double.MIN_VALUE
var bucketedGraphSeries: PointsWithLabelGraphSeries<DataPointWithLabelInterface> = PointsWithLabelGraphSeries() override var bucketedGraphSeries: PointsWithLabelGraphSeries<DataPointWithLabelInterface> =
var bgReadingGraphSeries: PointsWithLabelGraphSeries<DataPointWithLabelInterface> = PointsWithLabelGraphSeries() PointsWithLabelGraphSeries()
var predictionsGraphSeries: PointsWithLabelGraphSeries<DataPointWithLabelInterface> = PointsWithLabelGraphSeries() override var bgReadingGraphSeries: PointsWithLabelGraphSeries<DataPointWithLabelInterface> =
PointsWithLabelGraphSeries()
override var predictionsGraphSeries: PointsWithLabelGraphSeries<DataPointWithLabelInterface> =
PointsWithLabelGraphSeries()
val basalScale = Scale() override val basalScale = Scale()
var baseBasalGraphSeries: LineGraphSeries<ScaledDataPoint> = LineGraphSeries() override var baseBasalGraphSeries: LineGraphSeries<ScaledDataPoint> = LineGraphSeries()
var tempBasalGraphSeries: LineGraphSeries<ScaledDataPoint> = LineGraphSeries() override var tempBasalGraphSeries: LineGraphSeries<ScaledDataPoint> = LineGraphSeries()
var basalLineGraphSeries: LineGraphSeries<ScaledDataPoint> = LineGraphSeries() override var basalLineGraphSeries: LineGraphSeries<ScaledDataPoint> = LineGraphSeries()
var absoluteBasalGraphSeries: LineGraphSeries<ScaledDataPoint> = LineGraphSeries() override var absoluteBasalGraphSeries: LineGraphSeries<ScaledDataPoint> = LineGraphSeries()
var temporaryTargetSeries: LineGraphSeries<DataPoint> = LineGraphSeries() override var temporaryTargetSeries: LineGraphSeries<DataPoint> = LineGraphSeries()
var maxIAValue = 0.0 override var maxIAValue = 0.0
val actScale = Scale() override val actScale = Scale()
var activitySeries: FixedLineGraphSeries<ScaledDataPoint> = FixedLineGraphSeries() override var activitySeries: FixedLineGraphSeries<ScaledDataPoint> = FixedLineGraphSeries()
var activityPredictionSeries: FixedLineGraphSeries<ScaledDataPoint> = FixedLineGraphSeries() override var activityPredictionSeries: FixedLineGraphSeries<ScaledDataPoint> = FixedLineGraphSeries()
var maxEpsValue = 0.0 override var maxEpsValue = 0.0
val epsScale = Scale() override val epsScale = Scale()
var epsSeries: PointsWithLabelGraphSeries<DataPointWithLabelInterface> = PointsWithLabelGraphSeries() override var epsSeries: PointsWithLabelGraphSeries<DataPointWithLabelInterface> =
var maxTreatmentsValue = 0.0 PointsWithLabelGraphSeries()
var treatmentsSeries: PointsWithLabelGraphSeries<DataPointWithLabelInterface> = PointsWithLabelGraphSeries() override var maxTreatmentsValue = 0.0
var maxTherapyEventValue = 0.0 override var treatmentsSeries: PointsWithLabelGraphSeries<DataPointWithLabelInterface> =
var therapyEventSeries: PointsWithLabelGraphSeries<DataPointWithLabelInterface> = PointsWithLabelGraphSeries() PointsWithLabelGraphSeries()
override var maxTherapyEventValue = 0.0
override var therapyEventSeries: PointsWithLabelGraphSeries<DataPointWithLabelInterface> =
PointsWithLabelGraphSeries()
var maxIobValueFound = Double.MIN_VALUE override var maxIobValueFound = Double.MIN_VALUE
val iobScale = Scale() override val iobScale = Scale()
var iobSeries: FixedLineGraphSeries<ScaledDataPoint> = FixedLineGraphSeries() override var iobSeries: FixedLineGraphSeries<ScaledDataPoint> = FixedLineGraphSeries()
var absIobSeries: FixedLineGraphSeries<ScaledDataPoint> = FixedLineGraphSeries() override var absIobSeries: FixedLineGraphSeries<ScaledDataPoint> = FixedLineGraphSeries()
var iobPredictions1Series: PointsWithLabelGraphSeries<DataPointWithLabelInterface> = PointsWithLabelGraphSeries() override var iobPredictions1Series: PointsWithLabelGraphSeries<DataPointWithLabelInterface> =
PointsWithLabelGraphSeries()
//var iobPredictions2Series: PointsWithLabelGraphSeries<DataPointWithLabelInterface> = PointsWithLabelGraphSeries() //var iobPredictions2Series: PointsWithLabelGraphSeries<DataPointWithLabelInterface> = PointsWithLabelGraphSeries()
var maxBGIValue = Double.MIN_VALUE override var maxBGIValue = Double.MIN_VALUE
val bgiScale = Scale() override val bgiScale = Scale()
var minusBgiSeries: FixedLineGraphSeries<ScaledDataPoint> = FixedLineGraphSeries() override var minusBgiSeries: FixedLineGraphSeries<ScaledDataPoint> = FixedLineGraphSeries()
var minusBgiHistSeries: FixedLineGraphSeries<ScaledDataPoint> = FixedLineGraphSeries() override var minusBgiHistSeries: FixedLineGraphSeries<ScaledDataPoint> = FixedLineGraphSeries()
var maxCobValueFound = Double.MIN_VALUE override var maxCobValueFound = Double.MIN_VALUE
val cobScale = Scale() override val cobScale = Scale()
var cobSeries: FixedLineGraphSeries<ScaledDataPoint> = FixedLineGraphSeries() override var cobSeries: FixedLineGraphSeries<ScaledDataPoint> = FixedLineGraphSeries()
var cobMinFailOverSeries: PointsWithLabelGraphSeries<DataPointWithLabelInterface> = PointsWithLabelGraphSeries() override var cobMinFailOverSeries: PointsWithLabelGraphSeries<DataPointWithLabelInterface> =
PointsWithLabelGraphSeries()
var maxDevValueFound = Double.MIN_VALUE override var maxDevValueFound = Double.MIN_VALUE
val devScale = Scale() override val devScale = Scale()
var deviationsSeries: BarGraphSeries<DeviationDataPoint> = BarGraphSeries() override var deviationsSeries: BarGraphSeries<DeviationDataPoint> = BarGraphSeries()
var maxRatioValueFound = 5.0 //even if sens data equals 0 for all the period, minimum scale is between 95% and 105% override var maxRatioValueFound = 5.0 //even if sens data equals 0 for all the period, minimum scale is between 95% and 105%
var minRatioValueFound = -maxRatioValueFound override var minRatioValueFound = -maxRatioValueFound
val ratioScale = Scale() override val ratioScale = Scale()
var ratioSeries: LineGraphSeries<ScaledDataPoint> = LineGraphSeries() override var ratioSeries: LineGraphSeries<ScaledDataPoint> = LineGraphSeries()
var maxFromMaxValueFound = Double.MIN_VALUE override var maxFromMaxValueFound = Double.MIN_VALUE
var maxFromMinValueFound = Double.MIN_VALUE override var maxFromMinValueFound = Double.MIN_VALUE
val dsMaxScale = Scale() override val dsMaxScale = Scale()
val dsMinScale = Scale() override val dsMinScale = Scale()
var dsMaxSeries: LineGraphSeries<ScaledDataPoint> = LineGraphSeries() override var dsMaxSeries: LineGraphSeries<ScaledDataPoint> = LineGraphSeries()
var dsMinSeries: LineGraphSeries<ScaledDataPoint> = LineGraphSeries() override var dsMinSeries: LineGraphSeries<ScaledDataPoint> = LineGraphSeries()
} }

View file

@ -39,7 +39,7 @@ class CommandBolus(
} }
override fun log(): String { override fun log(): String {
return (if (detailedBolusInfo.insulin > 0) "BOLUS " + rh.gs(R.string.formatinsulinunits, detailedBolusInfo.insulin) else "") + return (if (detailedBolusInfo.insulin > 0) "BOLUS " + rh.gs(R.string.format_insulin_units, detailedBolusInfo.insulin) else "") +
if (detailedBolusInfo.carbs > 0) "CARBS " + rh.gs(R.string.format_carbs, detailedBolusInfo.carbs.toInt()) else "" if (detailedBolusInfo.carbs > 0) "CARBS " + rh.gs(R.string.format_carbs, detailedBolusInfo.carbs.toInt()) else ""
} }

View file

@ -42,7 +42,7 @@ class CommandSMBBolus(
override fun status(): String = rh.gs(R.string.smb_bolus_u, detailedBolusInfo.insulin) override fun status(): String = rh.gs(R.string.smb_bolus_u, detailedBolusInfo.insulin)
override fun log(): String = "SMB BOLUS ${rh.gs(R.string.formatinsulinunits, detailedBolusInfo.insulin)}" override fun log(): String = "SMB BOLUS ${rh.gs(R.string.format_insulin_units, detailedBolusInfo.insulin)}"
override fun cancel() { override fun cancel() {
aapsLogger.debug(LTag.PUMPQUEUE, "Result cancel") aapsLogger.debug(LTag.PUMPQUEUE, "Result cancel")
callback?.result(PumpEnactResult(injector).success(false).comment(info.nightscout.core.main.R.string.connectiontimedout))?.run() callback?.result(PumpEnactResult(injector).success(false).comment(info.nightscout.core.main.R.string.connectiontimedout))?.run()

View file

@ -6,8 +6,6 @@ import android.graphics.Typeface
import android.view.Gravity import android.view.Gravity
import android.widget.TableRow import android.widget.TableRow
import android.widget.TextView import android.widget.TextView
import info.nightscout.core.profile.toCurrentUnitsString
import info.nightscout.core.profile.toUnitsString
import info.nightscout.implementation.R import info.nightscout.implementation.R
import info.nightscout.interfaces.Constants import info.nightscout.interfaces.Constants
import info.nightscout.interfaces.profile.Profile import info.nightscout.interfaces.profile.Profile

View file

@ -8,7 +8,6 @@ import android.view.Gravity
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.TableLayout import android.widget.TableLayout
import android.widget.TextView import android.widget.TextView
import info.nightscout.core.profile.toCurrentUnitsString
import info.nightscout.database.impl.AppRepository import info.nightscout.database.impl.AppRepository
import info.nightscout.implementation.R import info.nightscout.implementation.R
import info.nightscout.interfaces.Constants import info.nightscout.interfaces.Constants

View file

@ -149,7 +149,7 @@ class CommandQueueImplementationTest : TestBaseWithProfile() {
val percentageConstraint = Constraint(0) val percentageConstraint = Constraint(0)
`when`(constraintChecker.applyBasalPercentConstraints(anyObject(), anyObject())).thenReturn(percentageConstraint) `when`(constraintChecker.applyBasalPercentConstraints(anyObject(), anyObject())).thenReturn(percentageConstraint)
`when`(rh.gs(R.string.connectiontimedout)).thenReturn("Connection timed out") `when`(rh.gs(R.string.connectiontimedout)).thenReturn("Connection timed out")
`when`(rh.gs(R.string.formatinsulinunits)).thenReturn("%1\$.2f U") `when`(rh.gs(R.string.format_insulin_units)).thenReturn("%1\$.2f U")
`when`(rh.gs(R.string.goingtodeliver)).thenReturn("Going to deliver %1\$.2f U") `when`(rh.gs(R.string.goingtodeliver)).thenReturn("Going to deliver %1\$.2f U")
} }

View file

@ -29,10 +29,10 @@ import info.nightscout.androidaps.plugins.pump.insight.descriptors.CartridgeStat
import info.nightscout.androidaps.plugins.pump.insight.descriptors.InsightState; import info.nightscout.androidaps.plugins.pump.insight.descriptors.InsightState;
import info.nightscout.androidaps.plugins.pump.insight.descriptors.TotalDailyDose; import info.nightscout.androidaps.plugins.pump.insight.descriptors.TotalDailyDose;
import info.nightscout.androidaps.plugins.pump.insight.events.EventLocalInsightUpdateGUI; import info.nightscout.androidaps.plugins.pump.insight.events.EventLocalInsightUpdateGUI;
import info.nightscout.androidaps.utils.DecimalFormatter;
import info.nightscout.core.utils.fabric.FabricPrivacy; import info.nightscout.core.utils.fabric.FabricPrivacy;
import info.nightscout.interfaces.queue.Callback; import info.nightscout.interfaces.queue.Callback;
import info.nightscout.interfaces.queue.CommandQueue; import info.nightscout.interfaces.queue.CommandQueue;
import info.nightscout.interfaces.utils.DecimalFormatter;
import info.nightscout.rx.AapsSchedulers; import info.nightscout.rx.AapsSchedulers;
import info.nightscout.rx.bus.RxBus; import info.nightscout.rx.bus.RxBus;
import info.nightscout.shared.interfaces.ResourceHelper; import info.nightscout.shared.interfaces.ResourceHelper;

View file

@ -0,0 +1,18 @@
package info.nightscout.interfaces
import info.nightscout.database.entities.OfflineEvent
import info.nightscout.database.entities.TemporaryTarget
import info.nightscout.database.entities.TherapyEvent
import info.nightscout.database.entities.UserEntry
import info.nightscout.database.entities.ValueWithUnit
interface Translator {
fun translate(action: UserEntry.Action): String
fun translate(units: ValueWithUnit?): String
fun translate(meterType: TherapyEvent.MeterType?): String
fun translate(type: TherapyEvent.Type?): String
fun translate(reason: TemporaryTarget.Reason?): String
fun translate(reason: OfflineEvent.Reason?): String
fun translate(source: UserEntry.Sources): String
}

View file

@ -0,0 +1,34 @@
package info.nightscout.interfaces.profile
interface DefaultValueHelper {
/**
* returns the configured EatingSoon TempTarget, if this is set to 0, the Default-Value is returned.
*
* @return
*/
fun determineEatingSoonTT(): Double
fun determineEatingSoonTTDuration(): Int
/**
* returns the configured Activity TempTarget, if this is set to 0, the Default-Value is returned.
*
* @return
*/
fun determineActivityTT(): Double
fun determineActivityTTDuration(): Int
/**
* returns the configured Hypo TempTarget, if this is set to 0, the Default-Value is returned.
*
* @return
*/
fun determineHypoTT(): Double
fun determineHypoTTDuration(): Int
var bgTargetLow: Double
var bgTargetHigh: Double
fun determineHighLine(): Double
fun determineLowLine(): Double
}

Some files were not shown because too many files have changed in this diff Show more