remove :database:impl dependency
This commit is contained in:
parent
0571c00c74
commit
828d6b41de
|
@ -4,9 +4,9 @@ import info.nightscout.androidaps.extensions.fromConstant
|
||||||
import info.nightscout.core.main.R
|
import info.nightscout.core.main.R
|
||||||
import info.nightscout.core.profile.ProfileSealed
|
import info.nightscout.core.profile.ProfileSealed
|
||||||
import info.nightscout.core.utils.fabric.FabricPrivacy
|
import info.nightscout.core.utils.fabric.FabricPrivacy
|
||||||
|
import info.nightscout.database.ValueWrapper
|
||||||
import info.nightscout.database.entities.ProfileSwitch
|
import info.nightscout.database.entities.ProfileSwitch
|
||||||
import info.nightscout.database.impl.AppRepository
|
import info.nightscout.database.impl.AppRepository
|
||||||
import info.nightscout.database.impl.ValueWrapper
|
|
||||||
import info.nightscout.database.impl.transactions.InsertOrUpdateProfileSwitch
|
import info.nightscout.database.impl.transactions.InsertOrUpdateProfileSwitch
|
||||||
import info.nightscout.interfaces.Config
|
import info.nightscout.interfaces.Config
|
||||||
import info.nightscout.interfaces.Constants
|
import info.nightscout.interfaces.Constants
|
||||||
|
|
|
@ -23,8 +23,8 @@ 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.core.utils.receivers.DataWorkerStorage
|
||||||
import info.nightscout.core.workflow.CalculationWorkflow
|
import info.nightscout.core.workflow.CalculationWorkflow
|
||||||
|
import info.nightscout.database.ValueWrapper
|
||||||
import info.nightscout.database.impl.AppRepository
|
import info.nightscout.database.impl.AppRepository
|
||||||
import info.nightscout.database.impl.ValueWrapper
|
|
||||||
import info.nightscout.interfaces.aps.AutosensResult
|
import info.nightscout.interfaces.aps.AutosensResult
|
||||||
import info.nightscout.interfaces.aps.SMBDefaults
|
import info.nightscout.interfaces.aps.SMBDefaults
|
||||||
import info.nightscout.interfaces.iob.IobCobCalculator
|
import info.nightscout.interfaces.iob.IobCobCalculator
|
||||||
|
|
|
@ -12,8 +12,8 @@ import info.nightscout.androidaps.extensions.target
|
||||||
import info.nightscout.core.graph.OverviewData
|
import info.nightscout.core.graph.OverviewData
|
||||||
import info.nightscout.core.utils.receivers.DataWorkerStorage
|
import info.nightscout.core.utils.receivers.DataWorkerStorage
|
||||||
import info.nightscout.core.workflow.CalculationWorkflow
|
import info.nightscout.core.workflow.CalculationWorkflow
|
||||||
|
import info.nightscout.database.ValueWrapper
|
||||||
import info.nightscout.database.impl.AppRepository
|
import info.nightscout.database.impl.AppRepository
|
||||||
import info.nightscout.database.impl.ValueWrapper
|
|
||||||
import info.nightscout.interfaces.aps.Loop
|
import info.nightscout.interfaces.aps.Loop
|
||||||
import info.nightscout.interfaces.profile.Profile
|
import info.nightscout.interfaces.profile.Profile
|
||||||
import info.nightscout.interfaces.profile.ProfileFunction
|
import info.nightscout.interfaces.profile.ProfileFunction
|
||||||
|
|
|
@ -17,7 +17,6 @@ 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(':database:entities')
|
implementation project(':database:entities')
|
||||||
implementation project(':database:impl')
|
|
||||||
implementation project(':interfaces')
|
implementation project(':interfaces')
|
||||||
implementation project(':core:graph')
|
implementation project(':core:graph')
|
||||||
implementation project(':core:ui')
|
implementation project(':core:ui')
|
||||||
|
|
|
@ -1,20 +1,8 @@
|
||||||
package info.nightscout.core.pump
|
package info.nightscout.core.pump
|
||||||
|
|
||||||
import com.google.gson.Gson
|
import com.google.gson.Gson
|
||||||
import info.nightscout.database.impl.transactions.InsertOrUpdateBolusTransaction
|
|
||||||
import info.nightscout.database.impl.transactions.InsertOrUpdateCarbsTransaction
|
|
||||||
import info.nightscout.interfaces.pump.DetailedBolusInfo
|
import info.nightscout.interfaces.pump.DetailedBolusInfo
|
||||||
|
|
||||||
fun DetailedBolusInfo.insertCarbsTransaction(): InsertOrUpdateCarbsTransaction {
|
|
||||||
if (carbs == 0.0) throw IllegalStateException("carbs == 0.0")
|
|
||||||
return InsertOrUpdateCarbsTransaction(createCarbs()!!)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun DetailedBolusInfo.insertBolusTransaction(): InsertOrUpdateBolusTransaction {
|
|
||||||
if (insulin == 0.0) throw IllegalStateException("insulin == 0.0")
|
|
||||||
return InsertOrUpdateBolusTransaction(createBolus()!!)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun DetailedBolusInfo.toJsonString(): String = Gson().toJson(this)
|
fun DetailedBolusInfo.toJsonString(): String = Gson().toJson(this)
|
||||||
|
|
||||||
// Cannot access Companion extension from java so create common
|
// Cannot access Companion extension from java so create common
|
||||||
|
|
|
@ -6,7 +6,6 @@ import com.google.common.base.Joiner
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.androidaps.extensions.highValueToUnitsToString
|
import info.nightscout.androidaps.extensions.highValueToUnitsToString
|
||||||
import info.nightscout.androidaps.extensions.lowValueToUnitsToString
|
import info.nightscout.androidaps.extensions.lowValueToUnitsToString
|
||||||
import info.nightscout.interfaces.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
|
||||||
|
@ -18,16 +17,16 @@ import info.nightscout.database.entities.TemporaryTarget
|
||||||
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.database.impl.AppRepository
|
|
||||||
import info.nightscout.database.impl.transactions.InsertOrUpdateBolusCalculatorResultTransaction
|
|
||||||
import info.nightscout.interfaces.BolusTimer
|
import info.nightscout.interfaces.BolusTimer
|
||||||
import info.nightscout.interfaces.CarbTimer
|
import info.nightscout.interfaces.CarbTimer
|
||||||
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.constraints.Constraint
|
import info.nightscout.interfaces.constraints.Constraint
|
||||||
import info.nightscout.interfaces.constraints.Constraints
|
import info.nightscout.interfaces.constraints.Constraints
|
||||||
|
import info.nightscout.interfaces.db.PersistenceLayer
|
||||||
import info.nightscout.interfaces.iob.GlucoseStatus
|
import info.nightscout.interfaces.iob.GlucoseStatus
|
||||||
import info.nightscout.interfaces.iob.IobCobCalculator
|
import info.nightscout.interfaces.iob.IobCobCalculator
|
||||||
|
import info.nightscout.interfaces.logging.UserEntryLogger
|
||||||
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.Profile
|
import info.nightscout.interfaces.profile.Profile
|
||||||
|
@ -48,8 +47,6 @@ import info.nightscout.shared.interfaces.ResourceHelper
|
||||||
import info.nightscout.shared.sharedPreferences.SP
|
import info.nightscout.shared.sharedPreferences.SP
|
||||||
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 io.reactivex.rxjava3.disposables.CompositeDisposable
|
|
||||||
import io.reactivex.rxjava3.kotlin.plusAssign
|
|
||||||
import java.util.LinkedList
|
import java.util.LinkedList
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
import kotlin.math.abs
|
import kotlin.math.abs
|
||||||
|
@ -76,10 +73,9 @@ class BolusWizard @Inject constructor(
|
||||||
@Inject lateinit var carbTimer: CarbTimer
|
@Inject lateinit var carbTimer: CarbTimer
|
||||||
@Inject lateinit var bolusTimer: BolusTimer
|
@Inject lateinit var bolusTimer: BolusTimer
|
||||||
@Inject lateinit var glucoseStatusProvider: GlucoseStatusProvider
|
@Inject lateinit var glucoseStatusProvider: GlucoseStatusProvider
|
||||||
@Inject lateinit var repository: AppRepository
|
|
||||||
@Inject lateinit var activityNames: ActivityNames
|
@Inject lateinit var activityNames: ActivityNames
|
||||||
|
@Inject lateinit var persistenceLayer: PersistenceLayer
|
||||||
|
|
||||||
private val disposable = CompositeDisposable()
|
|
||||||
|
|
||||||
var timeStamp : Long
|
var timeStamp : Long
|
||||||
|
|
||||||
|
@ -495,12 +491,7 @@ class BolusWizard @Inject constructor(
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
disposable += repository.runTransactionForResult(InsertOrUpdateBolusCalculatorResultTransaction(bolusCalculatorResult!!))
|
bolusCalculatorResult?.let { persistenceLayer.insertOrUpdate(it) }
|
||||||
.subscribe(
|
|
||||||
{ result -> result.inserted.forEach { inserted -> aapsLogger.debug(LTag.DATABASE, "Inserted bolusCalculatorResult $inserted") } },
|
|
||||||
{ aapsLogger.error(LTag.DATABASE, "Error while saving bolusCalculatorResult", it) }
|
|
||||||
)
|
|
||||||
|
|
||||||
}
|
}
|
||||||
if (useAlarm && carbs > 0 && carbTime > 0) {
|
if (useAlarm && carbs > 0 && carbTime > 0) {
|
||||||
carbTimer.scheduleTimeToEatReminder(T.mins(carbTime.toLong()).secs().toInt())
|
carbTimer.scheduleTimeToEatReminder(T.mins(carbTime.toLong()).secs().toInt())
|
||||||
|
|
|
@ -7,10 +7,10 @@ import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatusProv
|
||||||
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.utils.MidnightUtils
|
import info.nightscout.core.utils.MidnightUtils
|
||||||
|
import info.nightscout.database.ValueWrapper
|
||||||
import info.nightscout.database.entities.GlucoseValue
|
import info.nightscout.database.entities.GlucoseValue
|
||||||
import info.nightscout.database.impl.AppRepository
|
|
||||||
import info.nightscout.database.impl.ValueWrapper
|
|
||||||
import info.nightscout.interfaces.aps.Loop
|
import info.nightscout.interfaces.aps.Loop
|
||||||
|
import info.nightscout.interfaces.db.PersistenceLayer
|
||||||
import info.nightscout.interfaces.iob.IobCobCalculator
|
import info.nightscout.interfaces.iob.IobCobCalculator
|
||||||
import info.nightscout.interfaces.plugin.PluginBase
|
import info.nightscout.interfaces.plugin.PluginBase
|
||||||
import info.nightscout.interfaces.profile.Profile
|
import info.nightscout.interfaces.profile.Profile
|
||||||
|
@ -32,7 +32,7 @@ class QuickWizardEntry @Inject constructor(private val injector: HasAndroidInjec
|
||||||
@Inject lateinit var profileFunction: ProfileFunction
|
@Inject lateinit var profileFunction: ProfileFunction
|
||||||
@Inject lateinit var loop: Loop
|
@Inject lateinit var loop: Loop
|
||||||
@Inject lateinit var iobCobCalculator: IobCobCalculator
|
@Inject lateinit var iobCobCalculator: IobCobCalculator
|
||||||
@Inject lateinit var repository: AppRepository
|
@Inject lateinit var persistenceLayer: PersistenceLayer
|
||||||
@Inject lateinit var dateUtil: DateUtil
|
@Inject lateinit var dateUtil: DateUtil
|
||||||
@Inject lateinit var glucoseStatusProvider: GlucoseStatusProvider
|
@Inject lateinit var glucoseStatusProvider: GlucoseStatusProvider
|
||||||
|
|
||||||
|
@ -109,7 +109,7 @@ class QuickWizardEntry @Inject constructor(private val injector: HasAndroidInjec
|
||||||
fun isActive(): Boolean = time.secondsFromMidnight() >= validFrom() && time.secondsFromMidnight() <= validTo() && forDevice(DEVICE_PHONE)
|
fun isActive(): Boolean = time.secondsFromMidnight() >= validFrom() && time.secondsFromMidnight() <= validTo() && forDevice(DEVICE_PHONE)
|
||||||
|
|
||||||
fun doCalc(profile: Profile, profileName: String, lastBG: GlucoseValue, _synchronized: Boolean): BolusWizard {
|
fun doCalc(profile: Profile, profileName: String, lastBG: GlucoseValue, _synchronized: Boolean): BolusWizard {
|
||||||
val dbRecord = repository.getTemporaryTargetActiveAt(dateUtil.now()).blockingGet()
|
val dbRecord = persistenceLayer.getTemporaryTargetActiveAt(dateUtil.now()).blockingGet()
|
||||||
val tempTarget = if (dbRecord is ValueWrapper.Existing) dbRecord.value else null
|
val tempTarget = if (dbRecord is ValueWrapper.Existing) dbRecord.value else null
|
||||||
//BG
|
//BG
|
||||||
var bg = 0.0
|
var bg = 0.0
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
package info.nightscout.database
|
||||||
|
|
||||||
|
sealed class ValueWrapper<T> {
|
||||||
|
data class Existing<T>(val value: T) : ValueWrapper<T>()
|
||||||
|
class Absent<T> : ValueWrapper<T>()
|
||||||
|
}
|
|
@ -1,5 +1,6 @@
|
||||||
package info.nightscout.database.impl
|
package info.nightscout.database.impl
|
||||||
|
|
||||||
|
import info.nightscout.database.ValueWrapper
|
||||||
import info.nightscout.database.annotations.DbOpenForTesting
|
import info.nightscout.database.annotations.DbOpenForTesting
|
||||||
import info.nightscout.database.entities.Bolus
|
import info.nightscout.database.entities.Bolus
|
||||||
import info.nightscout.database.entities.BolusCalculatorResult
|
import info.nightscout.database.entities.BolusCalculatorResult
|
||||||
|
@ -949,7 +950,3 @@ inline fun <reified T : Any> Maybe<T>.toWrappedSingle(): Single<ValueWrapper<T>>
|
||||||
.switchIfEmpty(Maybe.just(ValueWrapper.Absent()))
|
.switchIfEmpty(Maybe.just(ValueWrapper.Absent()))
|
||||||
.toSingle()
|
.toSingle()
|
||||||
|
|
||||||
sealed class ValueWrapper<T> {
|
|
||||||
data class Existing<T>(val value: T) : ValueWrapper<T>()
|
|
||||||
class Absent<T> : ValueWrapper<T>()
|
|
||||||
}
|
|
|
@ -1,17 +1,17 @@
|
||||||
package info.nightscout.implementation
|
package info.nightscout.implementation
|
||||||
|
|
||||||
import info.nightscout.interfaces.logging.UserEntryLogger
|
|
||||||
import info.nightscout.core.events.EventNewNotification
|
import info.nightscout.core.events.EventNewNotification
|
||||||
|
import info.nightscout.database.ValueWrapper
|
||||||
import info.nightscout.database.entities.TherapyEvent
|
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.database.impl.AppRepository
|
import info.nightscout.database.impl.AppRepository
|
||||||
import info.nightscout.database.impl.ValueWrapper
|
|
||||||
import info.nightscout.database.impl.transactions.InsertTherapyEventAnnouncementTransaction
|
import info.nightscout.database.impl.transactions.InsertTherapyEventAnnouncementTransaction
|
||||||
import info.nightscout.interfaces.Config
|
import info.nightscout.interfaces.Config
|
||||||
import info.nightscout.interfaces.Constants
|
import info.nightscout.interfaces.Constants
|
||||||
import info.nightscout.interfaces.LocalAlertUtils
|
import info.nightscout.interfaces.LocalAlertUtils
|
||||||
|
import info.nightscout.interfaces.logging.UserEntryLogger
|
||||||
import info.nightscout.interfaces.notifications.Notification
|
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
|
||||||
|
|
|
@ -0,0 +1,67 @@
|
||||||
|
package info.nightscout.implementation.db
|
||||||
|
|
||||||
|
import dagger.Reusable
|
||||||
|
import dagger.android.HasAndroidInjector
|
||||||
|
import info.nightscout.database.ValueWrapper
|
||||||
|
import info.nightscout.database.entities.Bolus
|
||||||
|
import info.nightscout.database.entities.BolusCalculatorResult
|
||||||
|
import info.nightscout.database.entities.Carbs
|
||||||
|
import info.nightscout.database.entities.TemporaryTarget
|
||||||
|
import info.nightscout.database.impl.AppRepository
|
||||||
|
import info.nightscout.database.impl.transactions.InsertOrUpdateBolusCalculatorResultTransaction
|
||||||
|
import info.nightscout.database.impl.transactions.InsertOrUpdateBolusTransaction
|
||||||
|
import info.nightscout.database.impl.transactions.InsertOrUpdateCarbsTransaction
|
||||||
|
import info.nightscout.interfaces.db.PersistenceLayer
|
||||||
|
import info.nightscout.interfaces.pump.PumpEnactResult
|
||||||
|
import info.nightscout.interfaces.queue.Callback
|
||||||
|
import info.nightscout.rx.logging.AAPSLogger
|
||||||
|
import info.nightscout.rx.logging.LTag
|
||||||
|
import io.reactivex.rxjava3.core.Single
|
||||||
|
import io.reactivex.rxjava3.disposables.CompositeDisposable
|
||||||
|
import io.reactivex.rxjava3.kotlin.plusAssign
|
||||||
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
@Reusable
|
||||||
|
class PersistenceLayerImpl @Inject constructor(
|
||||||
|
private val aapsLogger: AAPSLogger,
|
||||||
|
private val repository: AppRepository
|
||||||
|
) : PersistenceLayer {
|
||||||
|
|
||||||
|
private val disposable = CompositeDisposable()
|
||||||
|
|
||||||
|
override fun insertOrUpdate(bolusCalculatorResult: BolusCalculatorResult) {
|
||||||
|
disposable += repository.runTransactionForResult(InsertOrUpdateBolusCalculatorResultTransaction(bolusCalculatorResult))
|
||||||
|
.subscribe(
|
||||||
|
{ result -> result.inserted.forEach { inserted -> aapsLogger.debug(LTag.DATABASE, "Inserted bolusCalculatorResult $inserted") } },
|
||||||
|
{ aapsLogger.error(LTag.DATABASE, "Error while saving bolusCalculatorResult", it) }
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun insertOrUpdateBolus(bolus: Bolus) {
|
||||||
|
disposable += repository.runTransactionForResult(InsertOrUpdateBolusTransaction(bolus))
|
||||||
|
.subscribe(
|
||||||
|
{ result -> result.inserted.forEach { aapsLogger.debug(LTag.DATABASE, "Inserted bolus $it") } },
|
||||||
|
{ aapsLogger.error(LTag.DATABASE, "Error while saving bolus", it) }
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun insertOrUpdateCarbs(carbs: Carbs, callback: Callback?, injector: HasAndroidInjector?) {
|
||||||
|
disposable += repository.runTransactionForResult(InsertOrUpdateCarbsTransaction(carbs))
|
||||||
|
.subscribe(
|
||||||
|
{ result ->
|
||||||
|
result.inserted.forEach { aapsLogger.debug(LTag.DATABASE, "Inserted carbs $it") }
|
||||||
|
injector?.let { injector ->
|
||||||
|
callback?.result(PumpEnactResult(injector).enacted(false).success(true))?.run()
|
||||||
|
}
|
||||||
|
|
||||||
|
}, {
|
||||||
|
aapsLogger.error(LTag.DATABASE, "Error while saving carbs", it)
|
||||||
|
injector?.let { injector ->
|
||||||
|
callback?.result(PumpEnactResult(injector).enacted(false).success(false))?.run()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getTemporaryTargetActiveAt(timestamp: Long): Single<ValueWrapper<TemporaryTarget>> = repository.getTemporaryTargetActiveAt(timestamp)
|
||||||
|
}
|
|
@ -14,6 +14,7 @@ import info.nightscout.implementation.TrendCalculatorImpl
|
||||||
import info.nightscout.implementation.UserEntryLoggerImpl
|
import info.nightscout.implementation.UserEntryLoggerImpl
|
||||||
import info.nightscout.implementation.XDripBroadcastImpl
|
import info.nightscout.implementation.XDripBroadcastImpl
|
||||||
import info.nightscout.implementation.androidNotification.NotificationHolderImpl
|
import info.nightscout.implementation.androidNotification.NotificationHolderImpl
|
||||||
|
import info.nightscout.implementation.db.PersistenceLayerImpl
|
||||||
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.overview.OverviewDataImpl
|
||||||
|
@ -38,6 +39,7 @@ import info.nightscout.interfaces.LocalAlertUtils
|
||||||
import info.nightscout.interfaces.NotificationHolder
|
import info.nightscout.interfaces.NotificationHolder
|
||||||
import info.nightscout.interfaces.Translator
|
import info.nightscout.interfaces.Translator
|
||||||
import info.nightscout.interfaces.XDripBroadcast
|
import info.nightscout.interfaces.XDripBroadcast
|
||||||
|
import info.nightscout.interfaces.db.PersistenceLayer
|
||||||
import info.nightscout.interfaces.logging.LoggerUtils
|
import info.nightscout.interfaces.logging.LoggerUtils
|
||||||
import info.nightscout.interfaces.logging.UserEntryLogger
|
import info.nightscout.interfaces.logging.UserEntryLogger
|
||||||
import info.nightscout.interfaces.maintenance.PrefFileListProvider
|
import info.nightscout.interfaces.maintenance.PrefFileListProvider
|
||||||
|
@ -70,6 +72,7 @@ open class ImplementationModule {
|
||||||
|
|
||||||
@Module
|
@Module
|
||||||
interface Bindings {
|
interface Bindings {
|
||||||
|
@Binds fun bindPersistenceLayer(persistenceLayerImpl: PersistenceLayerImpl): PersistenceLayer
|
||||||
@Binds fun bindActivePlugin(pluginStore: PluginStore): ActivePlugin
|
@Binds fun bindActivePlugin(pluginStore: PluginStore): ActivePlugin
|
||||||
@Binds fun bindPrefFileListProvider(prefFileListProviderImpl: PrefFileListProviderImpl): PrefFileListProvider
|
@Binds fun bindPrefFileListProvider(prefFileListProviderImpl: PrefFileListProviderImpl): PrefFileListProvider
|
||||||
@Binds fun bindOverviewData(overviewData: OverviewDataImpl): OverviewData
|
@Binds fun bindOverviewData(overviewData: OverviewDataImpl): OverviewData
|
||||||
|
|
|
@ -21,10 +21,10 @@ import info.nightscout.core.graph.data.Scale
|
||||||
import info.nightscout.core.graph.data.ScaledDataPoint
|
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.ValueWrapper
|
||||||
import info.nightscout.database.entities.GlucoseValue
|
import info.nightscout.database.entities.GlucoseValue
|
||||||
import info.nightscout.database.entities.TemporaryTarget
|
import info.nightscout.database.entities.TemporaryTarget
|
||||||
import info.nightscout.database.impl.AppRepository
|
import info.nightscout.database.impl.AppRepository
|
||||||
import info.nightscout.database.impl.ValueWrapper
|
|
||||||
import info.nightscout.interfaces.aps.AutosensData
|
import info.nightscout.interfaces.aps.AutosensData
|
||||||
import info.nightscout.interfaces.iob.CobInfo
|
import info.nightscout.interfaces.iob.CobInfo
|
||||||
import info.nightscout.interfaces.iob.IobCobCalculator
|
import info.nightscout.interfaces.iob.IobCobCalculator
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
package info.nightscout.implementation.pump
|
package info.nightscout.implementation.pump
|
||||||
|
|
||||||
import info.nightscout.interfaces.logging.UserEntryLogger
|
|
||||||
import info.nightscout.core.events.EventNewNotification
|
import info.nightscout.core.events.EventNewNotification
|
||||||
import info.nightscout.core.main.R
|
import info.nightscout.core.main.R
|
||||||
import info.nightscout.core.pump.fromDbPumpType
|
import info.nightscout.core.pump.fromDbPumpType
|
||||||
import info.nightscout.core.pump.toDbPumpType
|
import info.nightscout.core.pump.toDbPumpType
|
||||||
import info.nightscout.core.pump.toDbSource
|
import info.nightscout.core.pump.toDbSource
|
||||||
|
import info.nightscout.database.ValueWrapper
|
||||||
import info.nightscout.database.entities.Bolus
|
import info.nightscout.database.entities.Bolus
|
||||||
import info.nightscout.database.entities.Carbs
|
import info.nightscout.database.entities.Carbs
|
||||||
import info.nightscout.database.entities.ExtendedBolus
|
import info.nightscout.database.entities.ExtendedBolus
|
||||||
|
@ -16,7 +16,6 @@ import info.nightscout.database.entities.UserEntry
|
||||||
import info.nightscout.database.entities.ValueWithUnit
|
import info.nightscout.database.entities.ValueWithUnit
|
||||||
import info.nightscout.database.entities.embedments.InterfaceIDs
|
import info.nightscout.database.entities.embedments.InterfaceIDs
|
||||||
import info.nightscout.database.impl.AppRepository
|
import info.nightscout.database.impl.AppRepository
|
||||||
import info.nightscout.database.impl.ValueWrapper
|
|
||||||
import info.nightscout.database.impl.transactions.InsertBolusWithTempIdTransaction
|
import info.nightscout.database.impl.transactions.InsertBolusWithTempIdTransaction
|
||||||
import info.nightscout.database.impl.transactions.InsertIfNewByTimestampCarbsTransaction
|
import info.nightscout.database.impl.transactions.InsertIfNewByTimestampCarbsTransaction
|
||||||
import info.nightscout.database.impl.transactions.InsertIfNewByTimestampTherapyEventTransaction
|
import info.nightscout.database.impl.transactions.InsertIfNewByTimestampTherapyEventTransaction
|
||||||
|
@ -33,6 +32,7 @@ import info.nightscout.database.impl.transactions.SyncPumpExtendedBolusTransacti
|
||||||
import info.nightscout.database.impl.transactions.SyncPumpTemporaryBasalTransaction
|
import info.nightscout.database.impl.transactions.SyncPumpTemporaryBasalTransaction
|
||||||
import info.nightscout.database.impl.transactions.SyncPumpTotalDailyDoseTransaction
|
import info.nightscout.database.impl.transactions.SyncPumpTotalDailyDoseTransaction
|
||||||
import info.nightscout.database.impl.transactions.SyncTemporaryBasalWithTempIdTransaction
|
import info.nightscout.database.impl.transactions.SyncTemporaryBasalWithTempIdTransaction
|
||||||
|
import info.nightscout.interfaces.logging.UserEntryLogger
|
||||||
import info.nightscout.interfaces.notifications.Notification
|
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
|
||||||
|
|
|
@ -12,13 +12,12 @@ import info.nightscout.androidaps.annotations.OpenForTesting
|
||||||
import info.nightscout.androidaps.extensions.getCustomizedName
|
import info.nightscout.androidaps.extensions.getCustomizedName
|
||||||
import info.nightscout.core.events.EventNewNotification
|
import info.nightscout.core.events.EventNewNotification
|
||||||
import info.nightscout.core.profile.ProfileSealed
|
import info.nightscout.core.profile.ProfileSealed
|
||||||
import info.nightscout.core.pump.insertCarbsTransaction
|
|
||||||
import info.nightscout.core.utils.fabric.FabricPrivacy
|
import info.nightscout.core.utils.fabric.FabricPrivacy
|
||||||
|
import info.nightscout.database.ValueWrapper
|
||||||
import info.nightscout.database.entities.EffectiveProfileSwitch
|
import info.nightscout.database.entities.EffectiveProfileSwitch
|
||||||
import info.nightscout.database.entities.ProfileSwitch
|
import info.nightscout.database.entities.ProfileSwitch
|
||||||
import info.nightscout.database.entities.interfaces.end
|
import info.nightscout.database.entities.interfaces.end
|
||||||
import info.nightscout.database.impl.AppRepository
|
import info.nightscout.database.impl.AppRepository
|
||||||
import info.nightscout.database.impl.ValueWrapper
|
|
||||||
import info.nightscout.implementation.R
|
import info.nightscout.implementation.R
|
||||||
import info.nightscout.implementation.queue.commands.CommandBolus
|
import info.nightscout.implementation.queue.commands.CommandBolus
|
||||||
import info.nightscout.implementation.queue.commands.CommandCancelExtendedBolus
|
import info.nightscout.implementation.queue.commands.CommandCancelExtendedBolus
|
||||||
|
@ -41,6 +40,7 @@ import info.nightscout.interfaces.AndroidPermission
|
||||||
import info.nightscout.interfaces.Config
|
import info.nightscout.interfaces.Config
|
||||||
import info.nightscout.interfaces.constraints.Constraint
|
import info.nightscout.interfaces.constraints.Constraint
|
||||||
import info.nightscout.interfaces.constraints.Constraints
|
import info.nightscout.interfaces.constraints.Constraints
|
||||||
|
import info.nightscout.interfaces.db.PersistenceLayer
|
||||||
import info.nightscout.interfaces.notifications.Notification
|
import info.nightscout.interfaces.notifications.Notification
|
||||||
import info.nightscout.interfaces.plugin.ActivePlugin
|
import info.nightscout.interfaces.plugin.ActivePlugin
|
||||||
import info.nightscout.interfaces.profile.Profile
|
import info.nightscout.interfaces.profile.Profile
|
||||||
|
@ -68,7 +68,6 @@ import info.nightscout.shared.sharedPreferences.SP
|
||||||
import info.nightscout.shared.utils.DateUtil
|
import info.nightscout.shared.utils.DateUtil
|
||||||
import io.reactivex.rxjava3.disposables.CompositeDisposable
|
import io.reactivex.rxjava3.disposables.CompositeDisposable
|
||||||
import io.reactivex.rxjava3.kotlin.plusAssign
|
import io.reactivex.rxjava3.kotlin.plusAssign
|
||||||
import io.reactivex.rxjava3.kotlin.subscribeBy
|
|
||||||
import java.util.LinkedList
|
import java.util.LinkedList
|
||||||
import java.util.concurrent.TimeUnit
|
import java.util.concurrent.TimeUnit
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
@ -92,7 +91,8 @@ class CommandQueueImplementation @Inject constructor(
|
||||||
private val repository: AppRepository,
|
private val repository: AppRepository,
|
||||||
private val fabricPrivacy: FabricPrivacy,
|
private val fabricPrivacy: FabricPrivacy,
|
||||||
private val androidPermission: AndroidPermission,
|
private val androidPermission: AndroidPermission,
|
||||||
private val activityNames: ActivityNames
|
private val activityNames: ActivityNames,
|
||||||
|
private val persistenceLayer: PersistenceLayer
|
||||||
) : CommandQueue {
|
) : CommandQueue {
|
||||||
|
|
||||||
private val disposable = CompositeDisposable()
|
private val disposable = CompositeDisposable()
|
||||||
|
@ -230,7 +230,7 @@ class CommandQueueImplementation @Inject constructor(
|
||||||
val tempCommandQueue = CommandQueueImplementation(
|
val tempCommandQueue = CommandQueueImplementation(
|
||||||
injector, aapsLogger, rxBus, aapsSchedulers, rh,
|
injector, aapsLogger, rxBus, aapsSchedulers, rh,
|
||||||
constraintChecker, profileFunction, activePlugin, context, sp,
|
constraintChecker, profileFunction, activePlugin, context, sp,
|
||||||
config, dateUtil, repository, fabricPrivacy, androidPermission, activityNames
|
config, dateUtil, repository, fabricPrivacy, androidPermission, activityNames, persistenceLayer
|
||||||
)
|
)
|
||||||
tempCommandQueue.readStatus(reason, callback)
|
tempCommandQueue.readStatus(reason, callback)
|
||||||
tempCommandQueue.disposable.clear()
|
tempCommandQueue.disposable.clear()
|
||||||
|
@ -266,18 +266,7 @@ class CommandQueueImplementation @Inject constructor(
|
||||||
carbsRunnable = Runnable {
|
carbsRunnable = Runnable {
|
||||||
aapsLogger.debug(LTag.PUMPQUEUE, "Going to store carbs")
|
aapsLogger.debug(LTag.PUMPQUEUE, "Going to store carbs")
|
||||||
detailedBolusInfo.carbs = originalCarbs
|
detailedBolusInfo.carbs = originalCarbs
|
||||||
disposable += repository.runTransactionForResult(detailedBolusInfo.insertCarbsTransaction())
|
persistenceLayer.insertOrUpdateCarbs(detailedBolusInfo.createCarbs(), callback, injector)
|
||||||
.subscribeBy(
|
|
||||||
onSuccess = { result ->
|
|
||||||
result.inserted.forEach { aapsLogger.debug(LTag.DATABASE, "Inserted carbs $it") }
|
|
||||||
callback?.result(PumpEnactResult(injector).enacted(false).success(true))?.run()
|
|
||||||
|
|
||||||
},
|
|
||||||
onError = {
|
|
||||||
aapsLogger.error(LTag.DATABASE, "Error while saving carbs", it)
|
|
||||||
callback?.result(PumpEnactResult(injector).enacted(false).success(false))?.run()
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
// Do not process carbs anymore
|
// Do not process carbs anymore
|
||||||
detailedBolusInfo.carbs = 0.0
|
detailedBolusInfo.carbs = 0.0
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
package info.nightscout.implementation.queue.commands
|
package info.nightscout.implementation.queue.commands
|
||||||
|
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
|
import info.nightscout.database.ValueWrapper
|
||||||
import info.nightscout.database.impl.AppRepository
|
import info.nightscout.database.impl.AppRepository
|
||||||
import info.nightscout.database.impl.ValueWrapper
|
|
||||||
import info.nightscout.implementation.R
|
import info.nightscout.implementation.R
|
||||||
import info.nightscout.interfaces.Config
|
import info.nightscout.interfaces.Config
|
||||||
import info.nightscout.interfaces.plugin.ActivePlugin
|
import info.nightscout.interfaces.plugin.ActivePlugin
|
||||||
|
|
|
@ -8,11 +8,11 @@ import android.view.ViewGroup
|
||||||
import android.widget.TableLayout
|
import android.widget.TableLayout
|
||||||
import android.widget.TableRow
|
import android.widget.TableRow
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
|
import info.nightscout.database.ValueWrapper
|
||||||
import info.nightscout.database.entities.Bolus
|
import info.nightscout.database.entities.Bolus
|
||||||
import info.nightscout.database.entities.TotalDailyDose
|
import info.nightscout.database.entities.TotalDailyDose
|
||||||
import info.nightscout.database.entities.embedments.InterfaceIDs
|
import info.nightscout.database.entities.embedments.InterfaceIDs
|
||||||
import info.nightscout.database.impl.AppRepository
|
import info.nightscout.database.impl.AppRepository
|
||||||
import info.nightscout.database.impl.ValueWrapper
|
|
||||||
import info.nightscout.implementation.R
|
import info.nightscout.implementation.R
|
||||||
import info.nightscout.interfaces.iob.IobCobCalculator
|
import info.nightscout.interfaces.iob.IobCobCalculator
|
||||||
import info.nightscout.interfaces.plugin.ActivePlugin
|
import info.nightscout.interfaces.plugin.ActivePlugin
|
||||||
|
|
|
@ -8,9 +8,9 @@ import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.androidaps.TestBaseWithProfile
|
import info.nightscout.androidaps.TestBaseWithProfile
|
||||||
import info.nightscout.androidaps.TestPumpPlugin
|
import info.nightscout.androidaps.TestPumpPlugin
|
||||||
import info.nightscout.core.utils.fabric.FabricPrivacy
|
import info.nightscout.core.utils.fabric.FabricPrivacy
|
||||||
|
import info.nightscout.database.ValueWrapper
|
||||||
import info.nightscout.database.entities.Bolus
|
import info.nightscout.database.entities.Bolus
|
||||||
import info.nightscout.database.impl.AppRepository
|
import info.nightscout.database.impl.AppRepository
|
||||||
import info.nightscout.database.impl.ValueWrapper
|
|
||||||
import info.nightscout.implementation.R
|
import info.nightscout.implementation.R
|
||||||
import info.nightscout.implementation.queue.commands.CommandBolus
|
import info.nightscout.implementation.queue.commands.CommandBolus
|
||||||
import info.nightscout.implementation.queue.commands.CommandCustomCommand
|
import info.nightscout.implementation.queue.commands.CommandCustomCommand
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
package info.nightscout.interfaces.db
|
||||||
|
|
||||||
|
import dagger.android.HasAndroidInjector
|
||||||
|
import info.nightscout.database.ValueWrapper
|
||||||
|
import info.nightscout.database.entities.Bolus
|
||||||
|
import info.nightscout.database.entities.BolusCalculatorResult
|
||||||
|
import info.nightscout.database.entities.Carbs
|
||||||
|
import info.nightscout.database.entities.TemporaryTarget
|
||||||
|
import info.nightscout.interfaces.queue.Callback
|
||||||
|
import io.reactivex.rxjava3.core.Single
|
||||||
|
|
||||||
|
interface PersistenceLayer {
|
||||||
|
|
||||||
|
fun insertOrUpdate(bolusCalculatorResult: BolusCalculatorResult)
|
||||||
|
fun insertOrUpdateCarbs(carbs: Carbs, callback: Callback? = null, injector: HasAndroidInjector? = null)
|
||||||
|
fun insertOrUpdateBolus(bolus: Bolus)
|
||||||
|
|
||||||
|
fun getTemporaryTargetActiveAt(timestamp: Long): Single<ValueWrapper<TemporaryTarget>>
|
||||||
|
}
|
|
@ -97,7 +97,7 @@ class DetailedBolusInfo {
|
||||||
glucoseType = glucoseType?.toDbMeterType()
|
glucoseType = glucoseType?.toDbMeterType()
|
||||||
)
|
)
|
||||||
|
|
||||||
fun createBolus(): Bolus? =
|
fun createBolus(): Bolus =
|
||||||
if (insulin != 0.0)
|
if (insulin != 0.0)
|
||||||
Bolus(
|
Bolus(
|
||||||
timestamp = bolusTimestamp ?: timestamp,
|
timestamp = bolusTimestamp ?: timestamp,
|
||||||
|
@ -105,9 +105,9 @@ class DetailedBolusInfo {
|
||||||
type = bolusType.toDBbBolusType(),
|
type = bolusType.toDBbBolusType(),
|
||||||
notes = notes,
|
notes = notes,
|
||||||
)
|
)
|
||||||
else null
|
else throw IllegalStateException("insulin == 0.0")
|
||||||
|
|
||||||
fun createCarbs(): Carbs? =
|
fun createCarbs(): Carbs =
|
||||||
if (carbs != 0.0)
|
if (carbs != 0.0)
|
||||||
Carbs(
|
Carbs(
|
||||||
timestamp = carbsTimestamp ?: timestamp,
|
timestamp = carbsTimestamp ?: timestamp,
|
||||||
|
@ -115,7 +115,7 @@ class DetailedBolusInfo {
|
||||||
duration = carbsDuration,
|
duration = carbsDuration,
|
||||||
notes = notes,
|
notes = notes,
|
||||||
)
|
)
|
||||||
else null
|
else throw IllegalStateException("carbs == 0.0")
|
||||||
|
|
||||||
fun copy(): DetailedBolusInfo {
|
fun copy(): DetailedBolusInfo {
|
||||||
val n = DetailedBolusInfo()
|
val n = DetailedBolusInfo()
|
||||||
|
|
|
@ -7,8 +7,8 @@ import info.nightscout.androidaps.extensions.target
|
||||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatusProvider
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatusProvider
|
||||||
import info.nightscout.core.utils.MidnightUtils
|
import info.nightscout.core.utils.MidnightUtils
|
||||||
import info.nightscout.core.utils.fabric.FabricPrivacy
|
import info.nightscout.core.utils.fabric.FabricPrivacy
|
||||||
|
import info.nightscout.database.ValueWrapper
|
||||||
import info.nightscout.database.impl.AppRepository
|
import info.nightscout.database.impl.AppRepository
|
||||||
import info.nightscout.database.impl.ValueWrapper
|
|
||||||
import info.nightscout.interfaces.aps.APS
|
import info.nightscout.interfaces.aps.APS
|
||||||
import info.nightscout.interfaces.aps.AutosensResult
|
import info.nightscout.interfaces.aps.AutosensResult
|
||||||
import info.nightscout.interfaces.aps.DetermineBasalAdapter
|
import info.nightscout.interfaces.aps.DetermineBasalAdapter
|
||||||
|
|
|
@ -8,8 +8,8 @@ import info.nightscout.androidaps.annotations.OpenForTesting
|
||||||
import info.nightscout.androidaps.extensions.target
|
import info.nightscout.androidaps.extensions.target
|
||||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatusProvider
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatusProvider
|
||||||
import info.nightscout.core.utils.MidnightUtils
|
import info.nightscout.core.utils.MidnightUtils
|
||||||
|
import info.nightscout.database.ValueWrapper
|
||||||
import info.nightscout.database.impl.AppRepository
|
import info.nightscout.database.impl.AppRepository
|
||||||
import info.nightscout.database.impl.ValueWrapper
|
|
||||||
import info.nightscout.interfaces.aps.APS
|
import info.nightscout.interfaces.aps.APS
|
||||||
import info.nightscout.interfaces.aps.AutosensResult
|
import info.nightscout.interfaces.aps.AutosensResult
|
||||||
import info.nightscout.interfaces.aps.DetermineBasalAdapter
|
import info.nightscout.interfaces.aps.DetermineBasalAdapter
|
||||||
|
|
|
@ -3,13 +3,13 @@ package info.nightscout.automation.triggers
|
||||||
import android.widget.LinearLayout
|
import android.widget.LinearLayout
|
||||||
import com.google.common.base.Optional
|
import com.google.common.base.Optional
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.database.impl.ValueWrapper
|
|
||||||
import info.nightscout.automation.R
|
import info.nightscout.automation.R
|
||||||
import info.nightscout.automation.elements.Comparator
|
import info.nightscout.automation.elements.Comparator
|
||||||
import info.nightscout.automation.elements.InputDuration
|
import info.nightscout.automation.elements.InputDuration
|
||||||
import info.nightscout.automation.elements.LabelWithElement
|
import info.nightscout.automation.elements.LabelWithElement
|
||||||
import info.nightscout.automation.elements.LayoutBuilder
|
import info.nightscout.automation.elements.LayoutBuilder
|
||||||
import info.nightscout.automation.elements.StaticLabel
|
import info.nightscout.automation.elements.StaticLabel
|
||||||
|
import info.nightscout.database.ValueWrapper
|
||||||
import info.nightscout.database.entities.Bolus
|
import info.nightscout.database.entities.Bolus
|
||||||
import info.nightscout.interfaces.utils.JsonHelper
|
import info.nightscout.interfaces.utils.JsonHelper
|
||||||
import info.nightscout.interfaces.utils.JsonHelper.safeGetString
|
import info.nightscout.interfaces.utils.JsonHelper.safeGetString
|
||||||
|
|
|
@ -3,14 +3,13 @@ package info.nightscout.automation.triggers
|
||||||
import android.widget.LinearLayout
|
import android.widget.LinearLayout
|
||||||
import com.google.common.base.Optional
|
import com.google.common.base.Optional
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.database.impl.ValueWrapper
|
|
||||||
import info.nightscout.interfaces.utils.JsonHelper
|
|
||||||
import info.nightscout.automation.R
|
import info.nightscout.automation.R
|
||||||
import info.nightscout.automation.elements.ComparatorExists
|
import info.nightscout.automation.elements.ComparatorExists
|
||||||
import info.nightscout.automation.elements.LayoutBuilder
|
import info.nightscout.automation.elements.LayoutBuilder
|
||||||
import info.nightscout.automation.elements.StaticLabel
|
import info.nightscout.automation.elements.StaticLabel
|
||||||
|
import info.nightscout.database.ValueWrapper
|
||||||
|
import info.nightscout.interfaces.utils.JsonHelper
|
||||||
import info.nightscout.rx.logging.LTag
|
import info.nightscout.rx.logging.LTag
|
||||||
|
|
||||||
import org.json.JSONObject
|
import org.json.JSONObject
|
||||||
|
|
||||||
class TriggerTempTarget(injector: HasAndroidInjector) : Trigger(injector) {
|
class TriggerTempTarget(injector: HasAndroidInjector) : Trigger(injector) {
|
||||||
|
|
|
@ -9,7 +9,7 @@ import info.nightscout.automation.elements.InputBg
|
||||||
import info.nightscout.automation.elements.LabelWithElement
|
import info.nightscout.automation.elements.LabelWithElement
|
||||||
import info.nightscout.automation.elements.LayoutBuilder
|
import info.nightscout.automation.elements.LayoutBuilder
|
||||||
import info.nightscout.automation.elements.StaticLabel
|
import info.nightscout.automation.elements.StaticLabel
|
||||||
import info.nightscout.database.impl.ValueWrapper
|
import info.nightscout.database.ValueWrapper
|
||||||
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
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
package info.nightscout.automation.triggers
|
package info.nightscout.automation.triggers
|
||||||
|
|
||||||
import com.google.common.base.Optional
|
import com.google.common.base.Optional
|
||||||
import info.nightscout.database.impl.ValueWrapper
|
|
||||||
import info.nightscout.automation.elements.Comparator
|
import info.nightscout.automation.elements.Comparator
|
||||||
|
import info.nightscout.database.ValueWrapper
|
||||||
import info.nightscout.database.entities.Bolus
|
import info.nightscout.database.entities.Bolus
|
||||||
import io.reactivex.rxjava3.core.Single
|
import io.reactivex.rxjava3.core.Single
|
||||||
import org.json.JSONException
|
import org.json.JSONException
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
package info.nightscout.automation.triggers
|
package info.nightscout.automation.triggers
|
||||||
|
|
||||||
import com.google.common.base.Optional
|
import com.google.common.base.Optional
|
||||||
import info.nightscout.database.impl.ValueWrapper
|
|
||||||
import info.nightscout.automation.R
|
import info.nightscout.automation.R
|
||||||
import info.nightscout.automation.elements.Comparator
|
import info.nightscout.automation.elements.Comparator
|
||||||
|
import info.nightscout.database.ValueWrapper
|
||||||
import info.nightscout.database.entities.TemporaryTarget
|
import info.nightscout.database.entities.TemporaryTarget
|
||||||
import info.nightscout.interfaces.GlucoseUnit
|
import info.nightscout.interfaces.GlucoseUnit
|
||||||
import io.reactivex.rxjava3.core.Single
|
import io.reactivex.rxjava3.core.Single
|
||||||
|
|
|
@ -16,16 +16,15 @@ import info.nightscout.androidaps.annotations.OpenForTesting
|
||||||
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.extensions.plannedRemainingMinutes
|
import info.nightscout.androidaps.extensions.plannedRemainingMinutes
|
||||||
import info.nightscout.interfaces.logging.UserEntryLogger
|
|
||||||
import info.nightscout.core.events.EventNewNotification
|
import info.nightscout.core.events.EventNewNotification
|
||||||
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.utils.receivers.ReceiverStatusStore
|
||||||
|
import info.nightscout.database.ValueWrapper
|
||||||
import info.nightscout.database.entities.OfflineEvent
|
import info.nightscout.database.entities.OfflineEvent
|
||||||
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.database.impl.AppRepository
|
import info.nightscout.database.impl.AppRepository
|
||||||
import info.nightscout.database.impl.ValueWrapper
|
|
||||||
import info.nightscout.database.impl.transactions.InsertAndCancelCurrentOfflineEventTransaction
|
import info.nightscout.database.impl.transactions.InsertAndCancelCurrentOfflineEventTransaction
|
||||||
import info.nightscout.database.impl.transactions.InsertTherapyEventAnnouncementTransaction
|
import info.nightscout.database.impl.transactions.InsertTherapyEventAnnouncementTransaction
|
||||||
import info.nightscout.interfaces.Config
|
import info.nightscout.interfaces.Config
|
||||||
|
@ -36,6 +35,7 @@ import info.nightscout.interfaces.aps.Loop.LastRun
|
||||||
import info.nightscout.interfaces.constraints.Constraint
|
import info.nightscout.interfaces.constraints.Constraint
|
||||||
import info.nightscout.interfaces.constraints.Constraints
|
import info.nightscout.interfaces.constraints.Constraints
|
||||||
import info.nightscout.interfaces.iob.IobCobCalculator
|
import info.nightscout.interfaces.iob.IobCobCalculator
|
||||||
|
import info.nightscout.interfaces.logging.UserEntryLogger
|
||||||
import info.nightscout.interfaces.notifications.Notification
|
import info.nightscout.interfaces.notifications.Notification
|
||||||
import info.nightscout.interfaces.plugin.ActivePlugin
|
import info.nightscout.interfaces.plugin.ActivePlugin
|
||||||
import info.nightscout.interfaces.plugin.PluginBase
|
import info.nightscout.interfaces.plugin.PluginBase
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
package info.nightscout.plugins.constraints.objectives.objectives
|
package info.nightscout.plugins.constraints.objectives.objectives
|
||||||
|
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
|
import info.nightscout.database.ValueWrapper
|
||||||
import info.nightscout.database.impl.AppRepository
|
import info.nightscout.database.impl.AppRepository
|
||||||
import info.nightscout.database.impl.ValueWrapper
|
|
||||||
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
|
||||||
|
|
|
@ -12,18 +12,18 @@ import androidx.core.content.ContextCompat
|
||||||
import dagger.android.support.DaggerFragment
|
import dagger.android.support.DaggerFragment
|
||||||
import info.nightscout.androidaps.extensions.toStringMedium
|
import info.nightscout.androidaps.extensions.toStringMedium
|
||||||
import info.nightscout.androidaps.extensions.toStringShort
|
import info.nightscout.androidaps.extensions.toStringShort
|
||||||
import info.nightscout.interfaces.logging.UserEntryLogger
|
|
||||||
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
|
||||||
import info.nightscout.core.utils.fabric.FabricPrivacy
|
import info.nightscout.core.utils.fabric.FabricPrivacy
|
||||||
|
import info.nightscout.database.ValueWrapper
|
||||||
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.impl.AppRepository
|
import info.nightscout.database.impl.AppRepository
|
||||||
import info.nightscout.database.impl.ValueWrapper
|
|
||||||
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.logging.UserEntryLogger
|
||||||
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.protection.ProtectionCheck
|
import info.nightscout.interfaces.protection.ProtectionCheck
|
||||||
|
|
|
@ -18,6 +18,7 @@ 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
|
||||||
|
import info.nightscout.database.ValueWrapper
|
||||||
import info.nightscout.database.entities.Bolus
|
import info.nightscout.database.entities.Bolus
|
||||||
import info.nightscout.database.entities.GlucoseValue
|
import info.nightscout.database.entities.GlucoseValue
|
||||||
import info.nightscout.database.entities.TemporaryBasal
|
import info.nightscout.database.entities.TemporaryBasal
|
||||||
|
@ -27,7 +28,6 @@ import info.nightscout.database.entities.UserEntry
|
||||||
import info.nightscout.database.entities.ValueWithUnit
|
import info.nightscout.database.entities.ValueWithUnit
|
||||||
import info.nightscout.database.entities.interfaces.end
|
import info.nightscout.database.entities.interfaces.end
|
||||||
import info.nightscout.database.impl.AppRepository
|
import info.nightscout.database.impl.AppRepository
|
||||||
import info.nightscout.database.impl.ValueWrapper
|
|
||||||
import info.nightscout.database.impl.transactions.CancelCurrentTemporaryTargetIfAnyTransaction
|
import info.nightscout.database.impl.transactions.CancelCurrentTemporaryTargetIfAnyTransaction
|
||||||
import info.nightscout.database.impl.transactions.InsertAndCancelCurrentTemporaryTargetTransaction
|
import info.nightscout.database.impl.transactions.InsertAndCancelCurrentTemporaryTargetTransaction
|
||||||
import info.nightscout.interfaces.Config
|
import info.nightscout.interfaces.Config
|
||||||
|
|
|
@ -15,12 +15,12 @@ import info.nightscout.core.iob.plus
|
||||||
import info.nightscout.core.iob.round
|
import info.nightscout.core.iob.round
|
||||||
import info.nightscout.core.utils.fabric.FabricPrivacy
|
import info.nightscout.core.utils.fabric.FabricPrivacy
|
||||||
import info.nightscout.core.workflow.CalculationWorkflow
|
import info.nightscout.core.workflow.CalculationWorkflow
|
||||||
|
import info.nightscout.database.ValueWrapper
|
||||||
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
|
||||||
import info.nightscout.database.entities.interfaces.end
|
import info.nightscout.database.entities.interfaces.end
|
||||||
import info.nightscout.database.impl.AppRepository
|
import info.nightscout.database.impl.AppRepository
|
||||||
import info.nightscout.database.impl.ValueWrapper
|
|
||||||
import info.nightscout.interfaces.Constants
|
import info.nightscout.interfaces.Constants
|
||||||
import info.nightscout.interfaces.aps.AutosensData
|
import info.nightscout.interfaces.aps.AutosensData
|
||||||
import info.nightscout.interfaces.aps.AutosensDataStore
|
import info.nightscout.interfaces.aps.AutosensDataStore
|
||||||
|
|
|
@ -12,8 +12,8 @@ import info.nightscout.core.events.EventNewNotification
|
||||||
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.core.workflow.CalculationWorkflow
|
import info.nightscout.core.workflow.CalculationWorkflow
|
||||||
|
import info.nightscout.database.ValueWrapper
|
||||||
import info.nightscout.database.impl.AppRepository
|
import info.nightscout.database.impl.AppRepository
|
||||||
import info.nightscout.database.impl.ValueWrapper
|
|
||||||
import info.nightscout.interfaces.Config
|
import info.nightscout.interfaces.Config
|
||||||
import info.nightscout.interfaces.Constants
|
import info.nightscout.interfaces.Constants
|
||||||
import info.nightscout.interfaces.aps.AutosensData
|
import info.nightscout.interfaces.aps.AutosensData
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package info.nightscout.plugins.sync.nsclient
|
package info.nightscout.plugins.sync.nsclient
|
||||||
|
|
||||||
import info.nightscout.androidaps.extensions.toJson
|
import info.nightscout.androidaps.extensions.toJson
|
||||||
|
import info.nightscout.database.ValueWrapper
|
||||||
import info.nightscout.database.entities.Bolus
|
import info.nightscout.database.entities.Bolus
|
||||||
import info.nightscout.database.entities.BolusCalculatorResult
|
import info.nightscout.database.entities.BolusCalculatorResult
|
||||||
import info.nightscout.database.entities.Carbs
|
import info.nightscout.database.entities.Carbs
|
||||||
|
@ -15,7 +16,6 @@ import info.nightscout.database.entities.TemporaryBasal
|
||||||
import info.nightscout.database.entities.TemporaryTarget
|
import info.nightscout.database.entities.TemporaryTarget
|
||||||
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.database.impl.ValueWrapper
|
|
||||||
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.sync.DataSyncSelector
|
import info.nightscout.interfaces.sync.DataSyncSelector
|
||||||
|
|
|
@ -2,9 +2,9 @@ package info.nightscout.plugins.ui
|
||||||
|
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import androidx.annotation.StringRes
|
import androidx.annotation.StringRes
|
||||||
|
import info.nightscout.database.ValueWrapper
|
||||||
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.database.impl.ValueWrapper
|
|
||||||
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.pump.WarnColors
|
import info.nightscout.interfaces.pump.WarnColors
|
||||||
|
|
|
@ -18,21 +18,21 @@ import dagger.android.support.DaggerFragment
|
||||||
import info.nightscout.androidaps.extensions.friendlyDescription
|
import info.nightscout.androidaps.extensions.friendlyDescription
|
||||||
import info.nightscout.androidaps.extensions.highValueToUnitsToString
|
import info.nightscout.androidaps.extensions.highValueToUnitsToString
|
||||||
import info.nightscout.androidaps.extensions.lowValueToUnitsToString
|
import info.nightscout.androidaps.extensions.lowValueToUnitsToString
|
||||||
import info.nightscout.interfaces.logging.UserEntryLogger
|
|
||||||
import info.nightscout.core.ui.dialogs.OKDialog
|
import info.nightscout.core.ui.dialogs.OKDialog
|
||||||
import info.nightscout.core.ui.toast.ToastUtils
|
import info.nightscout.core.ui.toast.ToastUtils
|
||||||
import info.nightscout.core.utils.ActionModeHelper
|
import info.nightscout.core.utils.ActionModeHelper
|
||||||
import info.nightscout.core.utils.fabric.FabricPrivacy
|
import info.nightscout.core.utils.fabric.FabricPrivacy
|
||||||
|
import info.nightscout.database.ValueWrapper
|
||||||
import info.nightscout.database.entities.TemporaryTarget
|
import info.nightscout.database.entities.TemporaryTarget
|
||||||
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.database.entities.interfaces.end
|
import info.nightscout.database.entities.interfaces.end
|
||||||
import info.nightscout.database.impl.AppRepository
|
import info.nightscout.database.impl.AppRepository
|
||||||
import info.nightscout.database.impl.ValueWrapper
|
|
||||||
import info.nightscout.database.impl.transactions.InvalidateTemporaryTargetTransaction
|
import info.nightscout.database.impl.transactions.InvalidateTemporaryTargetTransaction
|
||||||
import info.nightscout.interfaces.Config
|
import info.nightscout.interfaces.Config
|
||||||
import info.nightscout.interfaces.Translator
|
import info.nightscout.interfaces.Translator
|
||||||
|
import info.nightscout.interfaces.logging.UserEntryLogger
|
||||||
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
|
||||||
|
|
|
@ -18,11 +18,11 @@ import dagger.android.support.DaggerFragment
|
||||||
import info.nightscout.androidaps.extensions.iobCalc
|
import info.nightscout.androidaps.extensions.iobCalc
|
||||||
import info.nightscout.androidaps.extensions.toStringFull
|
import info.nightscout.androidaps.extensions.toStringFull
|
||||||
import info.nightscout.androidaps.extensions.toTemporaryBasal
|
import info.nightscout.androidaps.extensions.toTemporaryBasal
|
||||||
import info.nightscout.interfaces.logging.UserEntryLogger
|
|
||||||
import info.nightscout.core.ui.dialogs.OKDialog
|
import info.nightscout.core.ui.dialogs.OKDialog
|
||||||
import info.nightscout.core.ui.toast.ToastUtils
|
import info.nightscout.core.ui.toast.ToastUtils
|
||||||
import info.nightscout.core.utils.ActionModeHelper
|
import info.nightscout.core.utils.ActionModeHelper
|
||||||
import info.nightscout.core.utils.fabric.FabricPrivacy
|
import info.nightscout.core.utils.fabric.FabricPrivacy
|
||||||
|
import info.nightscout.database.ValueWrapper
|
||||||
import info.nightscout.database.entities.ExtendedBolus
|
import info.nightscout.database.entities.ExtendedBolus
|
||||||
import info.nightscout.database.entities.TemporaryBasal
|
import info.nightscout.database.entities.TemporaryBasal
|
||||||
import info.nightscout.database.entities.UserEntry.Action
|
import info.nightscout.database.entities.UserEntry.Action
|
||||||
|
@ -30,10 +30,10 @@ import info.nightscout.database.entities.UserEntry.Sources
|
||||||
import info.nightscout.database.entities.ValueWithUnit
|
import info.nightscout.database.entities.ValueWithUnit
|
||||||
import info.nightscout.database.entities.interfaces.end
|
import info.nightscout.database.entities.interfaces.end
|
||||||
import info.nightscout.database.impl.AppRepository
|
import info.nightscout.database.impl.AppRepository
|
||||||
import info.nightscout.database.impl.ValueWrapper
|
|
||||||
import info.nightscout.database.impl.transactions.InvalidateExtendedBolusTransaction
|
import info.nightscout.database.impl.transactions.InvalidateExtendedBolusTransaction
|
||||||
import info.nightscout.database.impl.transactions.InvalidateTemporaryBasalTransaction
|
import info.nightscout.database.impl.transactions.InvalidateTemporaryBasalTransaction
|
||||||
import info.nightscout.interfaces.iob.IobTotal
|
import info.nightscout.interfaces.iob.IobTotal
|
||||||
|
import info.nightscout.interfaces.logging.UserEntryLogger
|
||||||
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.rx.AapsSchedulers
|
import info.nightscout.rx.AapsSchedulers
|
||||||
|
|
|
@ -8,7 +8,6 @@ import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import com.google.common.base.Joiner
|
import com.google.common.base.Joiner
|
||||||
import info.nightscout.core.pump.insertBolusTransaction
|
|
||||||
import info.nightscout.core.ui.dialogs.OKDialog
|
import info.nightscout.core.ui.dialogs.OKDialog
|
||||||
import info.nightscout.core.ui.toast.ToastUtils
|
import info.nightscout.core.ui.toast.ToastUtils
|
||||||
import info.nightscout.core.utils.extensions.formatColor
|
import info.nightscout.core.utils.extensions.formatColor
|
||||||
|
@ -25,6 +24,7 @@ import info.nightscout.interfaces.Constants.INSULIN_PLUS3_DEFAULT
|
||||||
import info.nightscout.interfaces.GlucoseUnit
|
import info.nightscout.interfaces.GlucoseUnit
|
||||||
import info.nightscout.interfaces.constraints.Constraint
|
import info.nightscout.interfaces.constraints.Constraint
|
||||||
import info.nightscout.interfaces.constraints.Constraints
|
import info.nightscout.interfaces.constraints.Constraints
|
||||||
|
import info.nightscout.interfaces.db.PersistenceLayer
|
||||||
import info.nightscout.interfaces.logging.UserEntryLogger
|
import info.nightscout.interfaces.logging.UserEntryLogger
|
||||||
import info.nightscout.interfaces.plugin.ActivePlugin
|
import info.nightscout.interfaces.plugin.ActivePlugin
|
||||||
import info.nightscout.interfaces.profile.DefaultValueHelper
|
import info.nightscout.interfaces.profile.DefaultValueHelper
|
||||||
|
@ -69,6 +69,7 @@ class InsulinDialog : DialogFragmentWithDate() {
|
||||||
@Inject lateinit var uel: UserEntryLogger
|
@Inject lateinit var uel: UserEntryLogger
|
||||||
@Inject lateinit var protectionCheck: ProtectionCheck
|
@Inject lateinit var protectionCheck: ProtectionCheck
|
||||||
@Inject lateinit var activityNames: ActivityNames
|
@Inject lateinit var activityNames: ActivityNames
|
||||||
|
@Inject lateinit var persistenceLayer: PersistenceLayer
|
||||||
|
|
||||||
private var queryingProtection = false
|
private var queryingProtection = false
|
||||||
private val disposable = CompositeDisposable()
|
private val disposable = CompositeDisposable()
|
||||||
|
@ -253,11 +254,7 @@ class InsulinDialog : DialogFragmentWithDate() {
|
||||||
ValueWithUnit.SimpleString(rh.gsNotLocalised(R.string.record)),
|
ValueWithUnit.SimpleString(rh.gsNotLocalised(R.string.record)),
|
||||||
ValueWithUnit.Insulin(insulinAfterConstraints),
|
ValueWithUnit.Insulin(insulinAfterConstraints),
|
||||||
ValueWithUnit.Minute(timeOffset).takeIf { timeOffset != 0 })
|
ValueWithUnit.Minute(timeOffset).takeIf { timeOffset != 0 })
|
||||||
disposable += repository.runTransactionForResult(detailedBolusInfo.insertBolusTransaction())
|
persistenceLayer.insertOrUpdateBolus(detailedBolusInfo.createBolus())
|
||||||
.subscribe(
|
|
||||||
{ result -> result.inserted.forEach { aapsLogger.debug(LTag.DATABASE, "Inserted bolus $it") } },
|
|
||||||
{ aapsLogger.error(LTag.DATABASE, "Error while saving bolus", it) }
|
|
||||||
)
|
|
||||||
if (timeOffset == 0)
|
if (timeOffset == 0)
|
||||||
bolusTimer.removeAutomationEventBolusReminder()
|
bolusTimer.removeAutomationEventBolusReminder()
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -13,8 +13,8 @@ import info.nightscout.androidaps.extensions.getCustomizedName
|
||||||
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.ProfileSealed
|
import info.nightscout.core.profile.ProfileSealed
|
||||||
|
import info.nightscout.database.ValueWrapper
|
||||||
import info.nightscout.database.impl.AppRepository
|
import info.nightscout.database.impl.AppRepository
|
||||||
import info.nightscout.database.impl.ValueWrapper
|
|
||||||
import info.nightscout.interfaces.Config
|
import info.nightscout.interfaces.Config
|
||||||
import info.nightscout.interfaces.Constants
|
import info.nightscout.interfaces.Constants
|
||||||
import info.nightscout.interfaces.plugin.ActivePlugin
|
import info.nightscout.interfaces.plugin.ActivePlugin
|
||||||
|
|
|
@ -8,19 +8,19 @@ import android.view.ViewGroup
|
||||||
import android.widget.ArrayAdapter
|
import android.widget.ArrayAdapter
|
||||||
import com.google.common.base.Joiner
|
import com.google.common.base.Joiner
|
||||||
import com.google.common.collect.Lists
|
import com.google.common.collect.Lists
|
||||||
import info.nightscout.interfaces.logging.UserEntryLogger
|
|
||||||
import info.nightscout.core.ui.dialogs.OKDialog
|
import info.nightscout.core.ui.dialogs.OKDialog
|
||||||
import info.nightscout.core.ui.toast.ToastUtils
|
import info.nightscout.core.ui.toast.ToastUtils
|
||||||
|
import info.nightscout.database.ValueWrapper
|
||||||
import info.nightscout.database.entities.TemporaryTarget
|
import info.nightscout.database.entities.TemporaryTarget
|
||||||
import info.nightscout.database.entities.UserEntry
|
import info.nightscout.database.entities.UserEntry
|
||||||
import info.nightscout.database.entities.ValueWithUnit
|
import info.nightscout.database.entities.ValueWithUnit
|
||||||
import info.nightscout.database.impl.AppRepository
|
import info.nightscout.database.impl.AppRepository
|
||||||
import info.nightscout.database.impl.ValueWrapper
|
|
||||||
import info.nightscout.database.impl.transactions.CancelCurrentTemporaryTargetIfAnyTransaction
|
import info.nightscout.database.impl.transactions.CancelCurrentTemporaryTargetIfAnyTransaction
|
||||||
import info.nightscout.database.impl.transactions.InsertAndCancelCurrentTemporaryTargetTransaction
|
import info.nightscout.database.impl.transactions.InsertAndCancelCurrentTemporaryTargetTransaction
|
||||||
import info.nightscout.interfaces.Constants
|
import info.nightscout.interfaces.Constants
|
||||||
import info.nightscout.interfaces.GlucoseUnit
|
import info.nightscout.interfaces.GlucoseUnit
|
||||||
import info.nightscout.interfaces.constraints.Constraints
|
import info.nightscout.interfaces.constraints.Constraints
|
||||||
|
import info.nightscout.interfaces.logging.UserEntryLogger
|
||||||
import info.nightscout.interfaces.profile.DefaultValueHelper
|
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
|
||||||
|
|
|
@ -8,9 +8,6 @@ import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import com.google.common.base.Joiner
|
import com.google.common.base.Joiner
|
||||||
import info.nightscout.interfaces.logging.UserEntryLogger
|
|
||||||
import info.nightscout.core.pump.insertBolusTransaction
|
|
||||||
import info.nightscout.core.pump.insertCarbsTransaction
|
|
||||||
import info.nightscout.core.ui.dialogs.OKDialog
|
import info.nightscout.core.ui.dialogs.OKDialog
|
||||||
import info.nightscout.core.ui.toast.ToastUtils
|
import info.nightscout.core.ui.toast.ToastUtils
|
||||||
import info.nightscout.core.utils.extensions.formatColor
|
import info.nightscout.core.utils.extensions.formatColor
|
||||||
|
@ -20,6 +17,8 @@ import info.nightscout.database.impl.AppRepository
|
||||||
import info.nightscout.interfaces.Config
|
import info.nightscout.interfaces.Config
|
||||||
import info.nightscout.interfaces.constraints.Constraint
|
import info.nightscout.interfaces.constraints.Constraint
|
||||||
import info.nightscout.interfaces.constraints.Constraints
|
import info.nightscout.interfaces.constraints.Constraints
|
||||||
|
import info.nightscout.interfaces.db.PersistenceLayer
|
||||||
|
import info.nightscout.interfaces.logging.UserEntryLogger
|
||||||
import info.nightscout.interfaces.plugin.ActivePlugin
|
import info.nightscout.interfaces.plugin.ActivePlugin
|
||||||
import info.nightscout.interfaces.protection.ProtectionCheck
|
import info.nightscout.interfaces.protection.ProtectionCheck
|
||||||
import info.nightscout.interfaces.pump.DetailedBolusInfo
|
import info.nightscout.interfaces.pump.DetailedBolusInfo
|
||||||
|
@ -34,7 +33,6 @@ import info.nightscout.shared.interfaces.ResourceHelper
|
||||||
import info.nightscout.ui.R
|
import info.nightscout.ui.R
|
||||||
import info.nightscout.ui.databinding.DialogTreatmentBinding
|
import info.nightscout.ui.databinding.DialogTreatmentBinding
|
||||||
import io.reactivex.rxjava3.disposables.CompositeDisposable
|
import io.reactivex.rxjava3.disposables.CompositeDisposable
|
||||||
import io.reactivex.rxjava3.kotlin.plusAssign
|
|
||||||
import java.text.DecimalFormat
|
import java.text.DecimalFormat
|
||||||
import java.util.LinkedList
|
import java.util.LinkedList
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
@ -52,6 +50,7 @@ class TreatmentDialog : DialogFragmentWithDate() {
|
||||||
@Inject lateinit var repository: AppRepository
|
@Inject lateinit var repository: AppRepository
|
||||||
@Inject lateinit var protectionCheck: ProtectionCheck
|
@Inject lateinit var protectionCheck: ProtectionCheck
|
||||||
@Inject lateinit var activityNames: ActivityNames
|
@Inject lateinit var activityNames: ActivityNames
|
||||||
|
@Inject lateinit var persistenceLayer: PersistenceLayer
|
||||||
|
|
||||||
private var queryingProtection = false
|
private var queryingProtection = false
|
||||||
private val disposable = CompositeDisposable()
|
private val disposable = CompositeDisposable()
|
||||||
|
@ -167,17 +166,9 @@ class TreatmentDialog : DialogFragmentWithDate() {
|
||||||
ValueWithUnit.Insulin(insulinAfterConstraints).takeIf { insulinAfterConstraints != 0.0 },
|
ValueWithUnit.Insulin(insulinAfterConstraints).takeIf { insulinAfterConstraints != 0.0 },
|
||||||
ValueWithUnit.Gram(carbsAfterConstraints).takeIf { carbsAfterConstraints != 0 })
|
ValueWithUnit.Gram(carbsAfterConstraints).takeIf { carbsAfterConstraints != 0 })
|
||||||
if (detailedBolusInfo.insulin > 0)
|
if (detailedBolusInfo.insulin > 0)
|
||||||
disposable += repository.runTransactionForResult(detailedBolusInfo.insertBolusTransaction())
|
persistenceLayer.insertOrUpdateBolus(detailedBolusInfo.createBolus())
|
||||||
.subscribe(
|
|
||||||
{ result -> result.inserted.forEach { aapsLogger.debug(LTag.DATABASE, "Inserted bolus $it") } },
|
|
||||||
{ aapsLogger.error(LTag.DATABASE, "Error while saving bolus", it) }
|
|
||||||
)
|
|
||||||
if (detailedBolusInfo.carbs > 0)
|
if (detailedBolusInfo.carbs > 0)
|
||||||
disposable += repository.runTransactionForResult(detailedBolusInfo.insertCarbsTransaction())
|
persistenceLayer.insertOrUpdateCarbs(detailedBolusInfo.createCarbs())
|
||||||
.subscribe(
|
|
||||||
{ result -> result.inserted.forEach { aapsLogger.debug(LTag.DATABASE, "Inserted carbs $it") } },
|
|
||||||
{ aapsLogger.error(LTag.DATABASE, "Error while saving carbs", it) }
|
|
||||||
)
|
|
||||||
} else {
|
} else {
|
||||||
if (detailedBolusInfo.insulin > 0) {
|
if (detailedBolusInfo.insulin > 0) {
|
||||||
uel.log(action, UserEntry.Sources.TreatmentDialog,
|
uel.log(action, UserEntry.Sources.TreatmentDialog,
|
||||||
|
@ -193,13 +184,8 @@ class TreatmentDialog : DialogFragmentWithDate() {
|
||||||
} else {
|
} else {
|
||||||
uel.log(action, UserEntry.Sources.TreatmentDialog,
|
uel.log(action, UserEntry.Sources.TreatmentDialog,
|
||||||
ValueWithUnit.Gram(carbsAfterConstraints).takeIf { carbsAfterConstraints != 0 })
|
ValueWithUnit.Gram(carbsAfterConstraints).takeIf { carbsAfterConstraints != 0 })
|
||||||
if (detailedBolusInfo.carbs > 0) {
|
if (detailedBolusInfo.carbs > 0)
|
||||||
disposable += repository.runTransactionForResult(detailedBolusInfo.insertCarbsTransaction())
|
persistenceLayer.insertOrUpdateCarbs(detailedBolusInfo.createCarbs())
|
||||||
.subscribe(
|
|
||||||
{ result -> result.inserted.forEach { aapsLogger.debug(LTag.DATABASE, "Inserted carbs $it") } },
|
|
||||||
{ aapsLogger.error(LTag.DATABASE, "Error while saving carbs", it) }
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
@ -25,8 +25,8 @@ import info.nightscout.core.ui.toast.ToastUtils
|
||||||
import info.nightscout.core.utils.extensions.formatColor
|
import info.nightscout.core.utils.extensions.formatColor
|
||||||
import info.nightscout.core.utils.fabric.FabricPrivacy
|
import info.nightscout.core.utils.fabric.FabricPrivacy
|
||||||
import info.nightscout.core.wizard.BolusWizard
|
import info.nightscout.core.wizard.BolusWizard
|
||||||
|
import info.nightscout.database.ValueWrapper
|
||||||
import info.nightscout.database.impl.AppRepository
|
import info.nightscout.database.impl.AppRepository
|
||||||
import info.nightscout.database.impl.ValueWrapper
|
|
||||||
import info.nightscout.interfaces.Constants
|
import info.nightscout.interfaces.Constants
|
||||||
import info.nightscout.interfaces.GlucoseUnit
|
import info.nightscout.interfaces.GlucoseUnit
|
||||||
import info.nightscout.interfaces.constraints.Constraint
|
import info.nightscout.interfaces.constraints.Constraint
|
||||||
|
|
Loading…
Reference in a new issue