allow RandomBg upload
This commit is contained in:
parent
deb99f236b
commit
17d71d218b
1 changed files with 11 additions and 3 deletions
|
@ -12,12 +12,14 @@ import info.nightscout.androidaps.interfaces.PluginDescription
|
||||||
import info.nightscout.androidaps.interfaces.PluginType
|
import info.nightscout.androidaps.interfaces.PluginType
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.logging.LTag
|
import info.nightscout.androidaps.logging.LTag
|
||||||
|
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload
|
||||||
import info.nightscout.androidaps.plugins.pump.virtual.VirtualPumpPlugin
|
import info.nightscout.androidaps.plugins.pump.virtual.VirtualPumpPlugin
|
||||||
import info.nightscout.androidaps.utils.DateUtil
|
import info.nightscout.androidaps.utils.DateUtil
|
||||||
import info.nightscout.androidaps.utils.T
|
import info.nightscout.androidaps.utils.T
|
||||||
import info.nightscout.androidaps.utils.buildHelper.BuildHelper
|
import info.nightscout.androidaps.utils.buildHelper.BuildHelper
|
||||||
import info.nightscout.androidaps.utils.extensions.isRunningTest
|
import info.nightscout.androidaps.utils.extensions.isRunningTest
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
|
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
import javax.inject.Singleton
|
import javax.inject.Singleton
|
||||||
|
@ -29,13 +31,14 @@ class RandomBgPlugin @Inject constructor(
|
||||||
injector: HasAndroidInjector,
|
injector: HasAndroidInjector,
|
||||||
resourceHelper: ResourceHelper,
|
resourceHelper: ResourceHelper,
|
||||||
aapsLogger: AAPSLogger,
|
aapsLogger: AAPSLogger,
|
||||||
private val virtualPumpPlugin: VirtualPumpPlugin,
|
private val sp: SP,
|
||||||
private val buildHelper: BuildHelper
|
private val nsUpload: NSUpload
|
||||||
) : PluginBase(PluginDescription()
|
) : PluginBase(PluginDescription()
|
||||||
.mainType(PluginType.BGSOURCE)
|
.mainType(PluginType.BGSOURCE)
|
||||||
.fragmentClass(BGSourceFragment::class.java.name)
|
.fragmentClass(BGSourceFragment::class.java.name)
|
||||||
.pluginName(R.string.randombg)
|
.pluginName(R.string.randombg)
|
||||||
.shortName(R.string.randombg_short)
|
.shortName(R.string.randombg_short)
|
||||||
|
.preferencesId(R.xml.pref_bgsource)
|
||||||
.description(R.string.description_source_randombg),
|
.description(R.string.description_source_randombg),
|
||||||
aapsLogger, resourceHelper, injector
|
aapsLogger, resourceHelper, injector
|
||||||
), BgSourceInterface {
|
), BgSourceInterface {
|
||||||
|
@ -85,7 +88,12 @@ class RandomBgPlugin @Inject constructor(
|
||||||
bgReading.value = bgMgdl
|
bgReading.value = bgMgdl
|
||||||
bgReading.date = DateUtil.now()
|
bgReading.date = DateUtil.now()
|
||||||
bgReading.raw = bgMgdl
|
bgReading.raw = bgMgdl
|
||||||
MainApp.getDbHelper().createIfNotExists(bgReading, "RandomBG")
|
if (MainApp.getDbHelper().createIfNotExists(bgReading, "RandomBG")) {
|
||||||
|
if (sp.getBoolean(R.string.key_dexcomg5_nsupload, false))
|
||||||
|
nsUpload.uploadBg(bgReading, "AndroidAPS-RandomBG")
|
||||||
|
if (sp.getBoolean(R.string.key_dexcomg5_xdripupload, false))
|
||||||
|
nsUpload.sendToXdrip(bgReading)
|
||||||
|
}
|
||||||
aapsLogger.debug(LTag.BGSOURCE, "Generated BG: $bgReading")
|
aapsLogger.debug(LTag.BGSOURCE, "Generated BG: $bgReading")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue