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
|
2019-12-27 04:17:49 +01:00
|
|
|
import dagger.android.ContributesAndroidInjector
|
2019-12-26 17:50:16 +01:00
|
|
|
import info.nightscout.androidaps.MainApp
|
2019-12-26 23:26:00 +01:00
|
|
|
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction
|
|
|
|
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctionImplementation
|
2019-12-27 04:17:49 +01:00
|
|
|
import info.nightscout.androidaps.plugins.general.automation.actions.ActionSendSMS
|
|
|
|
import info.nightscout.androidaps.queue.commands.CommandSetProfile
|
|
|
|
import info.nightscout.androidaps.services.DataService
|
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-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-23 13:27:15 +01:00
|
|
|
class AppModule {
|
2019-12-13 02:12:19 +01:00
|
|
|
|
|
|
|
@Provides
|
|
|
|
@Singleton
|
2019-12-21 20:17:08 +01:00
|
|
|
fun provideSharedPreferences(context: Context): SP {
|
2019-12-26 15:12:12 +01:00
|
|
|
return SPImplementation(PreferenceManager.getDefaultSharedPreferences(context))
|
2019-12-13 02:12:19 +01:00
|
|
|
}
|
|
|
|
|
2019-12-26 23:26:00 +01:00
|
|
|
@Provides
|
|
|
|
@Singleton
|
2019-12-27 04:17:49 +01:00
|
|
|
fun provideProfileFunction(sp: SP): ProfileFunction {
|
2019-12-26 23:26:00 +01:00
|
|
|
return ProfileFunctionImplementation(sp)
|
|
|
|
}
|
|
|
|
|
2019-12-26 17:50:16 +01:00
|
|
|
@Provides
|
|
|
|
@Singleton
|
|
|
|
fun provideResources(mainApp: MainApp): ResourceHelper {
|
|
|
|
return ResourceHelperImplementation(mainApp)
|
|
|
|
}
|
|
|
|
|
2019-12-21 20:17:08 +01:00
|
|
|
@Module
|
|
|
|
interface AppBindings {
|
2019-12-13 02:12:19 +01:00
|
|
|
|
2019-12-27 04:17:49 +01:00
|
|
|
@ContributesAndroidInjector
|
|
|
|
fun bindDataService(): DataService
|
|
|
|
|
|
|
|
@ContributesAndroidInjector
|
|
|
|
fun bindCommandSetProfile(): CommandSetProfile
|
|
|
|
|
|
|
|
@ContributesAndroidInjector
|
|
|
|
fun bindActionSendSMS(): ActionSendSMS
|
|
|
|
|
2019-12-21 20:17:08 +01:00
|
|
|
@Binds
|
2019-12-26 17:50:16 +01:00
|
|
|
fun bindContext(mainApp: MainApp): Context
|
2019-12-13 02:12:19 +01:00
|
|
|
}
|
|
|
|
}
|