diff --git a/app/src/main/java/info/nightscout/androidaps/dependencyInjection/AppModule.kt b/app/src/main/java/info/nightscout/androidaps/dependencyInjection/AppModule.kt index da8551af0b..35ef24854b 100644 --- a/app/src/main/java/info/nightscout/androidaps/dependencyInjection/AppModule.kt +++ b/app/src/main/java/info/nightscout/androidaps/dependencyInjection/AppModule.kt @@ -15,6 +15,7 @@ import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin import info.nightscout.androidaps.plugins.configBuilder.PluginStore import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctionImplementation import info.nightscout.androidaps.plugins.general.maintenance.ImportExportPrefsImpl +import info.nightscout.androidaps.plugins.general.maintenance.PrefFileListProvider import info.nightscout.androidaps.plugins.general.nsclient.DataSyncSelectorImplementation import info.nightscout.androidaps.plugins.general.smsCommunicator.SmsCommunicatorPlugin import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin @@ -22,6 +23,8 @@ import info.nightscout.androidaps.plugins.pump.PumpSyncImplementation import info.nightscout.androidaps.queue.CommandQueue import info.nightscout.androidaps.utils.DateUtil import info.nightscout.androidaps.utils.androidNotification.NotificationHolderImpl +import info.nightscout.androidaps.utils.buildHelper.BuildHelper +import info.nightscout.androidaps.utils.buildHelper.BuildHelperImpl import info.nightscout.androidaps.utils.buildHelper.ConfigImpl import info.nightscout.androidaps.utils.resources.IconsProviderImplementation import info.nightscout.androidaps.utils.resources.ResourceHelper @@ -56,6 +59,10 @@ open class AppModule { @Singleton fun provideStorage(): Storage = FileStorage() + @Provides + @Singleton + fun provideBuildHelper(config: Config, fileListProvider: PrefFileListProvider): BuildHelper = BuildHelperImpl(config, fileListProvider) + @Provides @Singleton internal fun provideSchedulers(): AapsSchedulers = DefaultAapsSchedulers() diff --git a/app/src/main/java/info/nightscout/androidaps/utils/buildHelper/BuildHelper.kt b/app/src/main/java/info/nightscout/androidaps/utils/buildHelper/BuildHelperImpl.kt similarity index 75% rename from app/src/main/java/info/nightscout/androidaps/utils/buildHelper/BuildHelper.kt rename to app/src/main/java/info/nightscout/androidaps/utils/buildHelper/BuildHelperImpl.kt index 04dbd0d789..b2bb3d99db 100644 --- a/app/src/main/java/info/nightscout/androidaps/utils/buildHelper/BuildHelper.kt +++ b/app/src/main/java/info/nightscout/androidaps/utils/buildHelper/BuildHelperImpl.kt @@ -4,14 +4,11 @@ import info.nightscout.androidaps.BuildConfig import info.nightscout.androidaps.interfaces.Config import info.nightscout.androidaps.plugins.general.maintenance.PrefFileListProvider import java.io.File -import javax.inject.Inject -import javax.inject.Singleton -@Singleton -class BuildHelper @Inject constructor( +class BuildHelperImpl constructor( private val config: Config, fileListProvider: PrefFileListProvider -) { +) : BuildHelper { private var devBranch = false private var engineeringMode = false @@ -23,11 +20,10 @@ class BuildHelper @Inject constructor( devBranch = BuildConfig.VERSION.contains("-") || BuildConfig.VERSION.matches(Regex(".*[a-zA-Z]+.*")) } - fun isEngineeringModeOrRelease(): Boolean = + override fun isEngineeringModeOrRelease(): Boolean = if (!config.APS) true else engineeringMode || !devBranch - fun isEngineeringMode(): Boolean = - engineeringMode + override fun isEngineeringMode(): Boolean = engineeringMode - fun isDev(): Boolean = devBranch + override fun isDev(): Boolean = devBranch } \ No newline at end of file diff --git a/app/src/test/java/info/nightscout/androidaps/interfaces/ConstraintsCheckerTest.kt b/app/src/test/java/info/nightscout/androidaps/interfaces/ConstraintsCheckerTest.kt index 545364ac3f..3235a110c0 100644 --- a/app/src/test/java/info/nightscout/androidaps/interfaces/ConstraintsCheckerTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/interfaces/ConstraintsCheckerTest.kt @@ -19,7 +19,6 @@ import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker import info.nightscout.androidaps.plugins.constraints.objectives.ObjectivesPlugin import info.nightscout.androidaps.plugins.constraints.objectives.objectives.Objective import info.nightscout.androidaps.plugins.constraints.safety.SafetyPlugin -import info.nightscout.androidaps.plugins.general.maintenance.LoggerUtils import info.nightscout.androidaps.plugins.general.maintenance.PrefFileListProvider import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatusProvider import info.nightscout.androidaps.plugins.pump.combo.ComboPlugin diff --git a/app/src/test/java/info/nightscout/androidaps/queue/QueueThreadTest.kt b/app/src/test/java/info/nightscout/androidaps/queue/QueueThreadTest.kt index 000d1e9015..22ddbebd53 100644 --- a/app/src/test/java/info/nightscout/androidaps/queue/QueueThreadTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/queue/QueueThreadTest.kt @@ -12,7 +12,6 @@ import info.nightscout.androidaps.interfaces.Constraint import info.nightscout.androidaps.interfaces.PumpDescription import info.nightscout.androidaps.interfaces.PumpSync import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker -import info.nightscout.androidaps.plugins.general.maintenance.LoggerUtils import info.nightscout.androidaps.plugins.general.maintenance.PrefFileListProvider import info.nightscout.androidaps.plugins.pump.virtual.VirtualPumpPlugin import info.nightscout.androidaps.queue.commands.Command diff --git a/core/src/main/java/info/nightscout/androidaps/utils/buildHelper/BuildHelper.kt b/core/src/main/java/info/nightscout/androidaps/utils/buildHelper/BuildHelper.kt new file mode 100644 index 0000000000..ca6a251f65 --- /dev/null +++ b/core/src/main/java/info/nightscout/androidaps/utils/buildHelper/BuildHelper.kt @@ -0,0 +1,8 @@ +package info.nightscout.androidaps.utils.buildHelper + +interface BuildHelper { + + fun isEngineeringModeOrRelease(): Boolean + fun isEngineeringMode(): Boolean + fun isDev(): Boolean +}