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.logging.AAPSLogger
|
||||
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.utils.DateUtil
|
||||
import info.nightscout.androidaps.utils.T
|
||||
import info.nightscout.androidaps.utils.buildHelper.BuildHelper
|
||||
import info.nightscout.androidaps.utils.extensions.isRunningTest
|
||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||
import java.util.*
|
||||
import javax.inject.Inject
|
||||
import javax.inject.Singleton
|
||||
|
@ -29,13 +31,14 @@ class RandomBgPlugin @Inject constructor(
|
|||
injector: HasAndroidInjector,
|
||||
resourceHelper: ResourceHelper,
|
||||
aapsLogger: AAPSLogger,
|
||||
private val virtualPumpPlugin: VirtualPumpPlugin,
|
||||
private val buildHelper: BuildHelper
|
||||
private val sp: SP,
|
||||
private val nsUpload: NSUpload
|
||||
) : PluginBase(PluginDescription()
|
||||
.mainType(PluginType.BGSOURCE)
|
||||
.fragmentClass(BGSourceFragment::class.java.name)
|
||||
.pluginName(R.string.randombg)
|
||||
.shortName(R.string.randombg_short)
|
||||
.preferencesId(R.xml.pref_bgsource)
|
||||
.description(R.string.description_source_randombg),
|
||||
aapsLogger, resourceHelper, injector
|
||||
), BgSourceInterface {
|
||||
|
@ -85,7 +88,12 @@ class RandomBgPlugin @Inject constructor(
|
|||
bgReading.value = bgMgdl
|
||||
bgReading.date = DateUtil.now()
|
||||
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")
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue