AndroidAPS/app/src/main/java/info/nightscout/androidaps/dependencyInjection/AppModule.kt

188 lines
10 KiB
Kotlin
Raw Normal View History

2019-12-13 02:12:19 +01:00
package info.nightscout.androidaps.dependencyInjection
import android.content.Context
import androidx.preference.PreferenceManager
2019-12-21 20:17:08 +01:00
import dagger.Binds
2019-12-13 02:12:19 +01:00
import dagger.Module
import dagger.Provides
import dagger.android.ContributesAndroidInjector
2020-01-10 02:27:14 +01:00
import dagger.android.HasAndroidInjector
2019-12-28 01:52:20 +01:00
import info.nightscout.androidaps.BuildConfig
2019-12-26 17:50:16 +01:00
import info.nightscout.androidaps.MainApp
2020-01-01 23:23:16 +01:00
import info.nightscout.androidaps.db.BgReading
import info.nightscout.androidaps.interfaces.ActivePluginProvider
import info.nightscout.androidaps.interfaces.CommandQueueProvider
2019-12-28 01:52:20 +01:00
import info.nightscout.androidaps.logging.AAPSLogger
import info.nightscout.androidaps.logging.AAPSLoggerDebug
import info.nightscout.androidaps.logging.AAPSLoggerProduction
2019-12-28 02:49:00 +01:00
import info.nightscout.androidaps.plugins.aps.openAPSMA.LoggerCallback
2019-12-30 00:53:44 +01:00
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin
2019-12-26 23:26:00 +01:00
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctionImplementation
2019-12-30 00:53:44 +01:00
import info.nightscout.androidaps.plugins.constraints.objectives.objectives.*
2020-01-05 12:02:32 +01:00
import info.nightscout.androidaps.plugins.general.automation.AutomationEvent
2020-01-02 19:20:36 +01:00
import info.nightscout.androidaps.plugins.general.automation.actions.*
2020-01-05 12:02:32 +01:00
import info.nightscout.androidaps.plugins.general.automation.elements.*
import info.nightscout.androidaps.plugins.general.automation.triggers.*
2020-01-01 23:23:16 +01:00
import info.nightscout.androidaps.plugins.general.overview.notifications.NotificationWithAction
2020-01-10 23:14:58 +01:00
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensData
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobOref1Thread
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobThread
2020-01-01 23:23:16 +01:00
import info.nightscout.androidaps.plugins.treatments.Treatment
2020-01-10 23:14:58 +01:00
import info.nightscout.androidaps.queue.CommandQueue
import info.nightscout.androidaps.queue.commands.*
2019-12-26 17:50:16 +01:00
import info.nightscout.androidaps.utils.resources.ResourceHelper
import info.nightscout.androidaps.utils.resources.ResourceHelperImplementation
2019-12-13 02:12:19 +01:00
import info.nightscout.androidaps.utils.sharedPreferences.SP
2019-12-26 15:12:12 +01:00
import info.nightscout.androidaps.utils.sharedPreferences.SPImplementation
2019-12-31 11:57:58 +01:00
import info.nightscout.androidaps.utils.wizard.BolusWizard
import info.nightscout.androidaps.utils.wizard.QuickWizardEntry
2019-12-13 02:12:19 +01:00
import javax.inject.Singleton
2019-12-21 20:17:08 +01:00
@Module(includes = [AppModule.AppBindings::class])
2019-12-30 23:26:48 +01:00
open class AppModule {
2019-12-13 02:12:19 +01:00
@Provides
@Singleton
2019-12-30 08:50:27 +01:00
fun provideSharedPreferences(context: Context, resourceHelper: ResourceHelper): SP {
return SPImplementation(PreferenceManager.getDefaultSharedPreferences(context), resourceHelper)
2019-12-13 02:12:19 +01:00
}
2019-12-26 23:26:00 +01:00
@Provides
@Singleton
2020-01-10 23:14:58 +01:00
fun provideProfileFunction(sp: SP): ProfileFunction {
return ProfileFunctionImplementation(sp)
2019-12-27 19:20:38 +01:00
}
2019-12-26 17:50:16 +01:00
@Provides
@Singleton
fun provideResources(mainApp: MainApp): ResourceHelper {
return ResourceHelperImplementation(mainApp)
}
2019-12-28 01:52:20 +01:00
@Provides
@Singleton
fun provideAAPSLogger(): AAPSLogger {
2020-01-12 23:43:44 +01:00
return AAPSLoggerProduction()
/* if (BuildConfig.DEBUG) {
2019-12-28 01:52:20 +01:00
AAPSLoggerDebug()
} else {
AAPSLoggerProduction()
}
2020-01-12 23:43:44 +01:00
*/
2019-12-28 01:52:20 +01:00
}
2019-12-21 20:17:08 +01:00
@Module
interface AppBindings {
2019-12-13 02:12:19 +01:00
2020-01-10 23:14:58 +01:00
@ContributesAndroidInjector fun commandQueueInjector(): CommandQueue
@ContributesAndroidInjector fun commandBolusInjector(): CommandBolus
@ContributesAndroidInjector
fun commandCancelExtendedBolusInjector(): CommandCancelExtendedBolus
@ContributesAndroidInjector fun commandCancelTempBasalInjector(): CommandCancelTempBasal
@ContributesAndroidInjector fun commandExtendedBolusInjector(): CommandExtendedBolus
@ContributesAndroidInjector
fun commandInsightSetTBROverNotificationInjector(): CommandInsightSetTBROverNotification
@ContributesAndroidInjector fun commandLoadEventsInjector(): CommandLoadEvents
@ContributesAndroidInjector fun commandLoadHistoryInjector(): CommandLoadHistory
2020-01-12 23:43:44 +01:00
@ContributesAndroidInjector fun commandLoadTDDsInjector(): CommandLoadTDDs
2020-01-10 23:14:58 +01:00
@ContributesAndroidInjector fun commandReadStatusInjector(): CommandReadStatus
2019-12-30 00:53:44 +01:00
@ContributesAndroidInjector fun commandSetProfileInjector(): CommandSetProfile
2020-01-10 23:14:58 +01:00
@ContributesAndroidInjector fun commandCommandSMBBolusInjector(): CommandSMBBolus
@ContributesAndroidInjector fun commandStartPumpInjector(): CommandStartPump
@ContributesAndroidInjector fun commandStopPumpInjector(): CommandStopPump
@ContributesAndroidInjector fun commandTempBasalAbsoluteInjector(): CommandTempBasalAbsolute
@ContributesAndroidInjector fun commandTempBasalPercentInjector(): CommandTempBasalPercent
2020-01-12 23:43:44 +01:00
@ContributesAndroidInjector fun commandSetUserSettingsInjector(): CommandSetUserSettings
2020-01-10 02:27:14 +01:00
2019-12-30 00:53:44 +01:00
@ContributesAndroidInjector fun objective0Injector(): Objective0
@ContributesAndroidInjector fun objective1Injector(): Objective1
@ContributesAndroidInjector fun objective2Injector(): Objective2
@ContributesAndroidInjector fun objective3Injector(): Objective3
@ContributesAndroidInjector fun objective5Injector(): Objective5
@ContributesAndroidInjector fun objective6Injector(): Objective6
2020-01-01 23:23:16 +01:00
2020-01-05 12:02:32 +01:00
@ContributesAndroidInjector fun automationEventInjector(): AutomationEvent
@ContributesAndroidInjector fun triggerInjector(): Trigger
@ContributesAndroidInjector fun triggerAutosensValueInjector(): TriggerAutosensValue
@ContributesAndroidInjector fun triggerBgInjector(): TriggerBg
@ContributesAndroidInjector fun triggerBolusAgoInjector(): TriggerBolusAgo
@ContributesAndroidInjector fun triggerCOBInjector(): TriggerCOB
@ContributesAndroidInjector fun triggerConnectorInjector(): TriggerConnector
@ContributesAndroidInjector fun triggerDeltaInjector(): TriggerDelta
@ContributesAndroidInjector fun triggerDummyInjector(): TriggerDummy
@ContributesAndroidInjector fun triggerIobInjector(): TriggerIob
@ContributesAndroidInjector fun triggerLocationInjector(): TriggerLocation
@ContributesAndroidInjector fun triggerProfilePercentInjector(): TriggerProfilePercent
2020-01-10 02:27:14 +01:00
@ContributesAndroidInjector
fun triggerPumpLastConnectionInjector(): TriggerPumpLastConnection
2020-01-05 12:02:32 +01:00
@ContributesAndroidInjector fun triggerRecurringTimeInjector(): TriggerRecurringTime
@ContributesAndroidInjector fun triggerTempTargetInjector(): TriggerTempTarget
@ContributesAndroidInjector fun triggerTime(): TriggerTime
@ContributesAndroidInjector fun triggerTimeRangeInjector(): TriggerTimeRange
@ContributesAndroidInjector fun triggerWifiSsidInjector(): TriggerWifiSsid
2020-01-02 19:20:36 +01:00
@ContributesAndroidInjector fun actionInjector(): Action
@ContributesAndroidInjector fun actionLoopDisableInjector(): ActionLoopDisable
@ContributesAndroidInjector fun actionLoopEnableInjector(): ActionLoopEnable
2020-01-05 12:02:32 +01:00
@ContributesAndroidInjector fun actionLoopResumeInjector(): ActionLoopResume
2020-01-02 19:20:36 +01:00
@ContributesAndroidInjector fun actionLoopSuspendInjector(): ActionLoopSuspend
@ContributesAndroidInjector fun actionNotificationInjector(): ActionNotification
@ContributesAndroidInjector fun actionProfileSwitchInjector(): ActionProfileSwitch
2020-01-10 23:14:58 +01:00
@ContributesAndroidInjector
fun actionProfileSwitchPercentInjector(): ActionProfileSwitchPercent
2020-01-02 19:20:36 +01:00
@ContributesAndroidInjector fun actionSendSMSInjector(): ActionSendSMS
@ContributesAndroidInjector fun actionStartTempTargetInjector(): ActionStartTempTarget
@ContributesAndroidInjector fun actionStopTempTargetInjector(): ActionStopTempTarget
@ContributesAndroidInjector fun actionDummyInjector(): ActionDummy
2020-01-05 12:02:32 +01:00
@ContributesAndroidInjector fun elementInjector(): Element
@ContributesAndroidInjector fun inputBgInjector(): InputBg
@ContributesAndroidInjector fun inputButtonInjector(): InputButton
2020-01-05 17:19:03 +01:00
@ContributesAndroidInjector fun comparatorInjector(): Comparator
@ContributesAndroidInjector fun comparatorExistsInjector(): ComparatorExists
2020-01-05 19:23:20 +01:00
@ContributesAndroidInjector fun inputDateTimeInjector(): InputDateTime
2020-01-05 12:02:32 +01:00
@ContributesAndroidInjector fun inputDeltaInjector(): InputDelta
@ContributesAndroidInjector fun inputDoubleInjector(): InputDouble
@ContributesAndroidInjector fun inputDurationInjector(): InputDuration
@ContributesAndroidInjector fun inputInsulinInjector(): InputInsulin
@ContributesAndroidInjector fun inputLocationModeInjector(): InputLocationMode
@ContributesAndroidInjector fun inputPercentInjector(): InputPercent
@ContributesAndroidInjector fun inputProfileNameInjector(): InputProfileName
@ContributesAndroidInjector fun inputStringInjector(): InputString
@ContributesAndroidInjector fun inputTempTargetInjector(): InputTempTarget
2020-01-05 17:19:03 +01:00
@ContributesAndroidInjector fun inputTimeRangeInjector(): InputTimeRange
2020-01-05 19:23:20 +01:00
@ContributesAndroidInjector fun inputTimeInjector(): InputTime
@ContributesAndroidInjector fun inputWeekDayInjector(): InputWeekDay
2020-01-05 12:02:32 +01:00
@ContributesAndroidInjector fun labelWithElementInjector(): LabelWithElement
@ContributesAndroidInjector fun staticLabelInjector(): StaticLabel
2020-01-10 23:14:58 +01:00
@ContributesAndroidInjector fun autosensDataInjector(): AutosensData
@ContributesAndroidInjector fun iobCobThreadInjector(): IobCobThread
@ContributesAndroidInjector fun iobCobOref1ThreadInjector(): IobCobOref1Thread
2020-01-01 23:23:16 +01:00
@ContributesAndroidInjector fun bgReadingInjector(): BgReading
@ContributesAndroidInjector fun treatmentInjector(): Treatment
@ContributesAndroidInjector fun notificationWithActionInjector(): NotificationWithAction
2019-12-30 00:53:44 +01:00
@ContributesAndroidInjector fun loggerCallbackInjector(): LoggerCallback
2019-12-31 11:57:58 +01:00
@ContributesAndroidInjector fun loggerBolusWizard(): BolusWizard
@ContributesAndroidInjector fun loggerQuickWizardEntry(): QuickWizardEntry
2019-12-28 01:14:04 +01:00
2019-12-30 00:53:44 +01:00
@Binds fun bindContext(mainApp: MainApp): Context
2020-01-10 02:27:14 +01:00
@Binds fun bindInjector(mainApp: MainApp): HasAndroidInjector
2020-01-10 23:14:58 +01:00
@Binds
fun bindActivePluginProvider(configBuilderPlugin: ConfigBuilderPlugin): ActivePluginProvider
2020-01-10 23:14:58 +01:00
@Binds fun commandQueueProvider(commandQueue: CommandQueue): CommandQueueProvider
2019-12-13 02:12:19 +01:00
}
}