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

87 lines
3.7 KiB
Kotlin
Raw Normal View History

2019-12-13 02:12:19 +01:00
package info.nightscout.androidaps.dependencyInjection
import android.content.Context
import android.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
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
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.*
import info.nightscout.androidaps.plugins.general.automation.actions.ActionSendSMS
2020-01-01 23:23:16 +01:00
import info.nightscout.androidaps.plugins.general.overview.notifications.NotificationWithAction
import info.nightscout.androidaps.plugins.treatments.Treatment
import info.nightscout.androidaps.queue.commands.CommandSetProfile
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
2019-12-30 00:53:44 +01:00
fun provideProfileFunction(sp: SP, configBuilderPlugin: ConfigBuilderPlugin): ProfileFunction {
return ProfileFunctionImplementation(sp, configBuilderPlugin)
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 {
return if (BuildConfig.DEBUG) {
AAPSLoggerDebug()
} else {
AAPSLoggerProduction()
}
}
2019-12-21 20:17:08 +01:00
@Module
interface AppBindings {
2019-12-13 02:12:19 +01:00
2019-12-30 00:53:44 +01:00
@ContributesAndroidInjector fun commandSetProfileInjector(): CommandSetProfile
@ContributesAndroidInjector fun actionSendSMSInjector(): ActionSendSMS
@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
@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
2019-12-13 02:12:19 +01:00
}
}