move ProfileStore

This commit is contained in:
Milos Kozak 2022-11-23 20:43:15 +01:00
parent 32bf2e592a
commit a451c64a84
17 changed files with 45 additions and 125 deletions

View file

@ -16,14 +16,13 @@ import androidx.work.WorkManager
import dagger.android.AndroidInjector
import dagger.android.DaggerApplication
import info.nightscout.androidaps.di.DaggerAppComponent
import info.nightscout.interfaces.logging.UserEntryLogger
import info.nightscout.androidaps.plugins.configBuilder.PluginStore
import info.nightscout.androidaps.receivers.BTReceiver
import info.nightscout.androidaps.receivers.ChargingStateReceiver
import info.nightscout.androidaps.receivers.KeepAliveWorker
import info.nightscout.androidaps.receivers.TimeDateOrTZChangeReceiver
import info.nightscout.androidaps.services.AlarmSoundServiceHelper
import info.nightscout.androidaps.utils.ProcessLifecycleListener
import info.nightscout.core.ui.locale.LocaleHelper
import info.nightscout.core.utils.receivers.NetworkChangeReceiver
import info.nightscout.core.versionChecker.VersionCheckerUtils
import info.nightscout.database.entities.TherapyEvent
@ -32,10 +31,11 @@ import info.nightscout.database.impl.AppRepository
import info.nightscout.database.impl.transactions.InsertIfNewByTimestampTherapyEventTransaction
import info.nightscout.database.impl.transactions.VersionChangeTransaction
import info.nightscout.implementation.db.CompatDBHelper
import info.nightscout.implementation.plugin.PluginStore
import info.nightscout.interfaces.Config
import info.nightscout.interfaces.ConfigBuilder
import info.nightscout.interfaces.LocalAlertUtils
import info.nightscout.core.ui.locale.LocaleHelper
import info.nightscout.interfaces.logging.UserEntryLogger
import info.nightscout.interfaces.notifications.Notification
import info.nightscout.interfaces.plugin.PluginBase
import info.nightscout.plugins.general.overview.notifications.NotificationStore

View file

@ -23,7 +23,6 @@ import info.nightscout.androidaps.danar.DanaRPlugin
import info.nightscout.androidaps.danars.DanaRSPlugin
import info.nightscout.androidaps.diaconn.DiaconnG8Plugin
import info.nightscout.androidaps.plugin.general.openhumans.OpenHumansUploaderPlugin
import info.nightscout.androidaps.plugins.configBuilder.PluginStore
import info.nightscout.androidaps.plugins.general.maintenance.MaintenancePlugin
import info.nightscout.androidaps.plugins.general.wear.WearPlugin
import info.nightscout.androidaps.plugins.pump.combo.ComboPlugin
@ -33,6 +32,7 @@ import info.nightscout.androidaps.plugins.pump.insight.LocalInsightPlugin
import info.nightscout.androidaps.plugins.pump.medtronic.MedtronicPumpPlugin
import info.nightscout.automation.AutomationPlugin
import info.nightscout.core.ui.dialogs.OKDialog
import info.nightscout.implementation.plugin.PluginStore
import info.nightscout.interfaces.Config
import info.nightscout.interfaces.plugin.PluginBase
import info.nightscout.interfaces.profile.Profile

View file

@ -6,9 +6,9 @@ import android.os.Bundle
import android.view.Menu
import android.view.MenuItem
import info.nightscout.androidaps.R
import info.nightscout.androidaps.plugins.configBuilder.PluginStore
import info.nightscout.core.activities.DaggerAppCompatActivityWithResult
import info.nightscout.core.ui.locale.LocaleHelper
import info.nightscout.implementation.plugin.PluginStore
import info.nightscout.interfaces.plugin.PluginBase
import info.nightscout.interfaces.protection.ProtectionCheck
import javax.inject.Inject

View file

@ -10,7 +10,6 @@ import info.nightscout.androidaps.MainApp
import info.nightscout.androidaps.implementations.ActivityNamesImpl
import info.nightscout.androidaps.implementations.ConfigImpl
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin
import info.nightscout.androidaps.plugins.configBuilder.PluginStore
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctionImpl
import info.nightscout.androidaps.plugins.general.maintenance.ImportExportPrefsImpl
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin
@ -98,7 +97,6 @@ open class AppModule {
@Binds fun bindContext(mainApp: MainApp): Context
@Binds fun bindInjector(mainApp: MainApp): HasAndroidInjector
@Binds fun bindActivePlugin(pluginStore: PluginStore): ActivePlugin
@Binds fun bindConfigInterface(config: ConfigImpl): Config
@Binds fun bindConfigBuilderInterface(configBuilderPlugin: ConfigBuilderPlugin): ConfigBuilder

View file

@ -3,16 +3,17 @@ package info.nightscout.androidaps.plugins.configBuilder
import androidx.fragment.app.FragmentActivity
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.R
import info.nightscout.interfaces.logging.UserEntryLogger
import info.nightscout.androidaps.plugins.configBuilder.events.EventConfigBuilderUpdateGui
import info.nightscout.core.ui.dialogs.OKDialog
import info.nightscout.database.entities.UserEntry.Action
import info.nightscout.database.entities.UserEntry.Sources
import info.nightscout.database.entities.ValueWithUnit
import info.nightscout.implementation.plugin.PluginStore
import info.nightscout.interfaces.ConfigBuilder
import info.nightscout.interfaces.aps.APS
import info.nightscout.interfaces.aps.Sensitivity
import info.nightscout.interfaces.insulin.Insulin
import info.nightscout.interfaces.logging.UserEntryLogger
import info.nightscout.interfaces.plugin.ActivePlugin
import info.nightscout.interfaces.plugin.PluginBase
import info.nightscout.interfaces.plugin.PluginDescription

View file

@ -1,5 +1,6 @@
package info.nightscout.implementation
import dagger.Reusable
import info.nightscout.core.main.R
import info.nightscout.database.entities.OfflineEvent
import info.nightscout.database.entities.TemporaryTarget
@ -10,9 +11,8 @@ import info.nightscout.database.entities.ValueWithUnit
import info.nightscout.interfaces.Translator
import info.nightscout.shared.interfaces.ResourceHelper
import javax.inject.Inject
import javax.inject.Singleton
@Singleton
@Reusable
class TranslatorImpl @Inject internal constructor(
private val rh: ResourceHelper
) : Translator {

View file

@ -1,5 +1,6 @@
package info.nightscout.implementation
import dagger.Reusable
import info.nightscout.androidaps.annotations.OpenForTesting
import info.nightscout.database.entities.UserEntry
import info.nightscout.database.entities.UserEntry.Action
@ -16,10 +17,9 @@ import info.nightscout.shared.utils.DateUtil
import io.reactivex.rxjava3.disposables.CompositeDisposable
import io.reactivex.rxjava3.kotlin.plusAssign
import javax.inject.Inject
import javax.inject.Singleton
@OpenForTesting
@Singleton
@Reusable
class UserEntryLoggerImpl @Inject constructor(
private val aapsLogger: AAPSLogger,
private val repository: AppRepository,

View file

@ -1,17 +1,8 @@
package info.nightscout.implementation.di
import android.content.Context
import dagger.Binds
import dagger.Lazy
import dagger.Module
import dagger.Provides
import dagger.Reusable
import info.nightscout.androidaps.plugins.general.maintenance.formats.EncryptedPrefsFormat
import info.nightscout.core.graph.OverviewData
import info.nightscout.core.utils.CryptoUtil
import info.nightscout.core.utils.fabric.FabricPrivacy
import info.nightscout.core.versionChecker.VersionCheckerUtils
import info.nightscout.database.impl.AppRepository
import info.nightscout.implementation.AndroidPermissionImpl
import info.nightscout.implementation.BolusTimerImpl
import info.nightscout.implementation.CarbTimerImpl
@ -26,6 +17,7 @@ import info.nightscout.implementation.androidNotification.NotificationHolderImpl
import info.nightscout.implementation.logging.LoggerUtilsImpl
import info.nightscout.implementation.maintenance.PrefFileListProviderImpl
import info.nightscout.implementation.overview.OverviewDataImpl
import info.nightscout.implementation.plugin.PluginStore
import info.nightscout.implementation.profiling.ProfilerImpl
import info.nightscout.implementation.protection.PasswordCheckImpl
import info.nightscout.implementation.protection.ProtectionCheckImpl
@ -42,7 +34,6 @@ import info.nightscout.implementation.stats.TirCalculatorImpl
import info.nightscout.interfaces.AndroidPermission
import info.nightscout.interfaces.BolusTimer
import info.nightscout.interfaces.CarbTimer
import info.nightscout.interfaces.Config
import info.nightscout.interfaces.LocalAlertUtils
import info.nightscout.interfaces.NotificationHolder
import info.nightscout.interfaces.Translator
@ -52,7 +43,6 @@ import info.nightscout.interfaces.logging.UserEntryLogger
import info.nightscout.interfaces.maintenance.PrefFileListProvider
import info.nightscout.interfaces.plugin.ActivePlugin
import info.nightscout.interfaces.profile.DefaultValueHelper
import info.nightscout.interfaces.profile.ProfileFunction
import info.nightscout.interfaces.profiling.Profiler
import info.nightscout.interfaces.protection.PasswordCheck
import info.nightscout.interfaces.protection.ProtectionCheck
@ -64,17 +54,10 @@ import info.nightscout.interfaces.queue.CommandQueue
import info.nightscout.interfaces.stats.DexcomTirCalculator
import info.nightscout.interfaces.stats.TddCalculator
import info.nightscout.interfaces.stats.TirCalculator
import info.nightscout.interfaces.storage.Storage
import info.nightscout.interfaces.ui.IconsProvider
import info.nightscout.interfaces.utils.HardLimits
import info.nightscout.interfaces.utils.TrendCalculator
import info.nightscout.rx.AapsSchedulers
import info.nightscout.rx.bus.RxBus
import info.nightscout.rx.logging.AAPSLogger
import info.nightscout.shared.interfaces.ResourceHelper
import info.nightscout.shared.sharedPreferences.SP
import info.nightscout.shared.utils.DateUtil
import javax.inject.Singleton
@Module(
includes = [
@ -85,87 +68,24 @@ import javax.inject.Singleton
@Suppress("unused")
open class ImplementationModule {
@Provides
@Singleton
fun provideResources(context: Context, fabricPrivacy: FabricPrivacy): ResourceHelper =
ResourceHelperImpl(context, fabricPrivacy)
@Provides
@Singleton
fun provideHardLimits(aapsLogger: AAPSLogger, rxBus: RxBus, sp: SP, rh: ResourceHelper, context: Context, repository: AppRepository): HardLimits =
HardLimitsImpl(aapsLogger, rxBus, sp, rh, context, repository)
@Provides
@Singleton
fun provideWarnColors(rh: ResourceHelper): WarnColors = WarnColorsImpl(rh)
@Provides
@Reusable
fun provideProfiler(aapsLogger: AAPSLogger): Profiler = ProfilerImpl(aapsLogger)
@Provides
@Singleton
fun provideLoggerUtils(prefFileListProvider: PrefFileListProvider): LoggerUtils = LoggerUtilsImpl(prefFileListProvider)
@Provides
@Reusable
fun providePasswordCheck(sp: SP, cryptoUtil: CryptoUtil): PasswordCheck = PasswordCheckImpl(sp, cryptoUtil)
@Provides
@Reusable
fun provideProtectionCheck(sp: SP, passwordCheck: PasswordCheck, dateUtil: DateUtil): ProtectionCheck = ProtectionCheckImpl(sp, passwordCheck, dateUtil)
@Provides
@Reusable
fun provideDefaultValueHelper(sp: SP, profileFunction: ProfileFunction): DefaultValueHelper = DefaultValueHelperImpl(sp, profileFunction)
@Provides
@Reusable
fun provideTranslator(rh: ResourceHelper): Translator = TranslatorImpl(rh)
@Provides
@Singleton
fun provideTemporaryBasalStorage(aapsLogger: AAPSLogger): TemporaryBasalStorage = TemporaryBasalStorageImpl(aapsLogger)
@Provides
@Singleton
fun provideDetailedBolusInfoStorage(aapsLogger: AAPSLogger): DetailedBolusInfoStorage = DetailedBolusInfoStorageImpl(aapsLogger)
@Provides
@Reusable
fun provideUserEntryLogger(
aapsLogger: AAPSLogger,
repository: AppRepository,
aapsSchedulers: AapsSchedulers,
dateUtil: DateUtil
): UserEntryLogger = UserEntryLoggerImpl(aapsLogger, repository, aapsSchedulers, dateUtil)
@Provides
@Singleton
fun provideOverviewData(
aapsLogger: AAPSLogger,
rh: ResourceHelper,
dateUtil: DateUtil,
sp: SP,
activePlugin: ActivePlugin,
defaultValueHelper: DefaultValueHelper,
profileFunction: ProfileFunction,
repository: AppRepository
): OverviewData = OverviewDataImpl(aapsLogger, rh, dateUtil, sp, activePlugin, defaultValueHelper, profileFunction, repository)
@Provides
@Reusable
fun providePrefFileListProvider(
rh: ResourceHelper,
config: Lazy<Config>,
encryptedPrefsFormat: EncryptedPrefsFormat,
storage: Storage,
versionCheckerUtils: VersionCheckerUtils,
context: Context
): PrefFileListProvider = PrefFileListProviderImpl(rh, config, encryptedPrefsFormat, storage, versionCheckerUtils, context)
@Module
interface Bindings {
@Binds fun bindActivePlugin(pluginStore: PluginStore): ActivePlugin
@Binds fun bindPrefFileListProvider(prefFileListProviderImpl: PrefFileListProviderImpl): PrefFileListProvider
@Binds fun bindOverviewData(overviewData: OverviewDataImpl): OverviewData
@Binds fun bindUserEntryLogger(userEntryLoggerImpl: UserEntryLoggerImpl): UserEntryLogger
@Binds fun bindDetailedBolusInfoStorage(detailedBolusInfoStorageImpl: DetailedBolusInfoStorageImpl): DetailedBolusInfoStorage
@Binds fun bindTemporaryBasalStorage(temporaryBasalStorageImpl: TemporaryBasalStorageImpl): TemporaryBasalStorage
@Binds fun bindTranslator(translatorImpl: TranslatorImpl): Translator
@Binds fun bindDefaultValueHelper(defaultValueHelperImpl: DefaultValueHelperImpl): DefaultValueHelper
@Binds fun bindProtectionCheck(protectionCheckImpl: ProtectionCheckImpl): ProtectionCheck
@Binds fun bindPasswordCheck(passwordCheckImpl: PasswordCheckImpl): PasswordCheck
@Binds fun bindLoggerUtils(loggerUtilsImpl: LoggerUtilsImpl): LoggerUtils
@Binds fun bindProfiler(profilerImpl: ProfilerImpl): Profiler
@Binds fun bindWarnColors(warnColorsImpl: WarnColorsImpl): WarnColors
@Binds fun bindHardLimits(hardLimitsImpl: HardLimitsImpl): HardLimits
@Binds fun bindResourceHelper(resourceHelperImpl: ResourceHelperImpl): ResourceHelper
@Binds fun bindTrendCalculatorInterface(trendCalculator: TrendCalculatorImpl): TrendCalculator
@Binds fun bindTddCalculatorInterface(tddCalculator: TddCalculatorImpl): TddCalculator
@Binds fun bindTirCalculatorInterface(tirCalculator: TirCalculatorImpl): TirCalculator

View file

@ -3,6 +3,7 @@ package info.nightscout.implementation.maintenance
import android.content.Context
import android.os.Environment
import dagger.Lazy
import dagger.Reusable
import info.nightscout.androidaps.annotations.OpenForTesting
import info.nightscout.androidaps.plugins.general.maintenance.formats.EncryptedPrefsFormat
import info.nightscout.core.main.R
@ -24,12 +25,11 @@ import org.joda.time.LocalDateTime
import org.joda.time.format.DateTimeFormat
import java.io.File
import javax.inject.Inject
import javax.inject.Singleton
import kotlin.math.abs
@Suppress("SpellCheckingInspection")
@OpenForTesting
@Singleton
@Reusable
class PrefFileListProviderImpl @Inject constructor(
private val rh: ResourceHelper,
private val config: Lazy<Config>,

View file

@ -1,6 +1,7 @@
package info.nightscout.androidaps.plugins.configBuilder
package info.nightscout.implementation.plugin
import info.nightscout.interfaces.Config
import info.nightscout.interfaces.ConfigBuilder
import info.nightscout.interfaces.Overview
import info.nightscout.interfaces.aps.APS
import info.nightscout.interfaces.aps.Sensitivity
@ -57,7 +58,7 @@ class PluginStore @Inject constructor(
override fun getSpecificPluginsListByInterface(interfaceClass: Class<*>): ArrayList<PluginBase> {
val newList = ArrayList<PluginBase>()
for (p in plugins) {
if (p.javaClass != ConfigBuilderPlugin::class.java && interfaceClass.isAssignableFrom(p.javaClass)) newList.add(p)
if (!interfaceClass.isAssignableFrom(ConfigBuilder::class.java) && interfaceClass.isAssignableFrom(p.javaClass)) newList.add(p)
}
return newList
}
@ -204,4 +205,4 @@ class PluginStore @Inject constructor(
override fun getPluginsList(): ArrayList<PluginBase> = ArrayList(plugins)
}
}

View file

@ -1,14 +1,14 @@
package info.nightscout.implementation.profiling
import dagger.Reusable
import info.nightscout.androidaps.annotations.OpenForTesting
import info.nightscout.interfaces.profiling.Profiler
import info.nightscout.rx.logging.AAPSLogger
import info.nightscout.rx.logging.LTag
import javax.inject.Inject
import javax.inject.Singleton
@OpenForTesting
@Singleton
@Reusable
class ProfilerImpl @Inject constructor(val aapsLogger: AAPSLogger) : Profiler {
override fun log(lTag: LTag, function: String, start: Long) {

View file

@ -12,15 +12,15 @@ import android.widget.EditText
import android.widget.TextView
import androidx.annotation.StringRes
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import dagger.Reusable
import info.nightscout.core.main.R
import info.nightscout.core.ui.toast.ToastUtils
import info.nightscout.core.utils.CryptoUtil
import info.nightscout.interfaces.protection.PasswordCheck
import info.nightscout.shared.sharedPreferences.SP
import javax.inject.Inject
import javax.inject.Singleton
@Singleton
@Reusable
class PasswordCheckImpl @Inject constructor(
private val sp: SP,
private val cryptoUtil: CryptoUtil

View file

@ -1,6 +1,7 @@
package info.nightscout.implementation.protection
import androidx.fragment.app.FragmentActivity
import dagger.Reusable
import info.nightscout.core.main.R
import info.nightscout.interfaces.protection.PasswordCheck
import info.nightscout.interfaces.protection.ProtectionCheck
@ -8,9 +9,8 @@ import info.nightscout.shared.sharedPreferences.SP
import info.nightscout.shared.utils.DateUtil
import java.util.concurrent.TimeUnit
import javax.inject.Inject
import javax.inject.Singleton
@Singleton
@Reusable
class ProtectionCheckImpl @Inject constructor(
private val sp: SP,
private val passwordCheck: PasswordCheck,

View file

@ -7,8 +7,8 @@ import info.nightscout.androidaps.plugins.pump.eopatch.event.EventDialog
import info.nightscout.androidaps.plugins.pump.eopatch.event.EventProgressDialog
import info.nightscout.androidaps.plugins.pump.eopatch.ui.dialogs.AlarmDialog
import info.nightscout.androidaps.plugins.pump.eopatch.ui.dialogs.ProgressDialogHelper
import info.nightscout.core.ui.R
import info.nightscout.core.ui.activities.DialogAppCompatActivity
import info.nightscout.core.main.R
import info.nightscout.rx.AapsSchedulers
import info.nightscout.rx.bus.RxBus
import info.nightscout.shared.sharedPreferences.SP

View file

@ -2,8 +2,8 @@ package info.nightscout.androidaps.plugins.pump.eopatch.ui
import android.os.Bundle
import info.nightscout.androidaps.plugins.pump.eopatch.ui.dialogs.ActivationNotCompleteDialog
import info.nightscout.core.ui.R
import info.nightscout.core.ui.activities.DialogAppCompatActivity
import info.nightscout.core.main.R
class DialogHelperActivity : DialogAppCompatActivity() {
@Override

View file

@ -9,7 +9,7 @@ import androidx.databinding.ViewDataBinding
import androidx.lifecycle.ViewModelProvider
import info.nightscout.androidaps.plugins.pump.eopatch.dagger.EopatchPluginQualifier
import info.nightscout.core.activities.NoSplashAppCompatActivity
import info.nightscout.core.main.R
import info.nightscout.core.ui.R
import info.nightscout.rx.AapsSchedulers
import io.reactivex.rxjava3.disposables.CompositeDisposable
import javax.inject.Inject

View file

@ -10,7 +10,6 @@ import android.view.ViewGroup
import android.view.Window
import android.view.WindowManager
import dagger.android.support.DaggerDialogFragment
import info.nightscout.core.main.R
import info.nightscout.androidaps.plugins.pump.eopatch.alarm.AlarmCode
import info.nightscout.androidaps.plugins.pump.eopatch.alarm.AlarmProcess
import info.nightscout.androidaps.plugins.pump.eopatch.alarm.IAlarmProcess
@ -19,10 +18,11 @@ import info.nightscout.androidaps.plugins.pump.eopatch.ble.IPatchManager
import info.nightscout.androidaps.plugins.pump.eopatch.databinding.DialogAlarmBinding
import info.nightscout.androidaps.plugins.pump.eopatch.ui.AlarmHelperActivity
import info.nightscout.androidaps.services.AlarmSoundServiceHelper
import info.nightscout.shared.utils.T
import info.nightscout.core.ui.R
import info.nightscout.rx.AapsSchedulers
import info.nightscout.rx.bus.RxBus
import info.nightscout.rx.logging.AAPSLogger
import info.nightscout.shared.utils.T
import io.reactivex.rxjava3.disposables.Disposable
import javax.inject.Inject