hide preference for bg upload if needed

This commit is contained in:
Milos Kozak 2022-11-29 18:10:55 +01:00
parent 38394faced
commit df63495795
4 changed files with 15 additions and 3 deletions

View file

@ -0,0 +1,4 @@
package info.nightscout.interfaces.source
interface DoingOwnUploadSource {
}

View file

@ -19,6 +19,7 @@ import info.nightscout.interfaces.plugin.PluginBase
import info.nightscout.interfaces.plugin.PluginDescription import info.nightscout.interfaces.plugin.PluginDescription
import info.nightscout.interfaces.plugin.PluginType import info.nightscout.interfaces.plugin.PluginType
import info.nightscout.interfaces.source.BgSource import info.nightscout.interfaces.source.BgSource
import info.nightscout.interfaces.source.DoingOwnUploadSource
import info.nightscout.interfaces.source.NSClientSource import info.nightscout.interfaces.source.NSClientSource
import info.nightscout.plugins.R import info.nightscout.plugins.R
import info.nightscout.rx.bus.RxBus import info.nightscout.rx.bus.RxBus
@ -50,7 +51,7 @@ class NSClientSourcePlugin @Inject constructor(
.shortName(R.string.ns_client_bg_short) .shortName(R.string.ns_client_bg_short)
.description(R.string.description_source_ns_client), .description(R.string.description_source_ns_client),
aapsLogger, rh, injector aapsLogger, rh, injector
), BgSource, NSClientSource { ), BgSource, NSClientSource, DoingOwnUploadSource {
private var lastBGTimeStamp: Long = 0 private var lastBGTimeStamp: Long = 0
private var isAdvancedFilteringEnabled = false private var isAdvancedFilteringEnabled = false

View file

@ -15,6 +15,7 @@ import info.nightscout.interfaces.plugin.PluginBase
import info.nightscout.interfaces.plugin.PluginDescription import info.nightscout.interfaces.plugin.PluginDescription
import info.nightscout.interfaces.plugin.PluginType import info.nightscout.interfaces.plugin.PluginType
import info.nightscout.interfaces.source.BgSource import info.nightscout.interfaces.source.BgSource
import info.nightscout.interfaces.source.DoingOwnUploadSource
import info.nightscout.plugins.R import info.nightscout.plugins.R
import info.nightscout.rx.logging.AAPSLogger import info.nightscout.rx.logging.AAPSLogger
import info.nightscout.rx.logging.LTag import info.nightscout.rx.logging.LTag
@ -35,7 +36,7 @@ class XdripPlugin @Inject constructor(
.pluginName(R.string.xdrip) .pluginName(R.string.xdrip)
.description(R.string.description_source_xdrip), .description(R.string.description_source_xdrip),
aapsLogger, rh, injector aapsLogger, rh, injector
), BgSource { ), BgSource, DoingOwnUploadSource {
private var advancedFiltering = false private var advancedFiltering = false
override var sensorBatteryLevel = -1 override var sensorBatteryLevel = -1

View file

@ -16,9 +16,11 @@ import info.nightscout.core.utils.fabric.FabricPrivacy
import info.nightscout.interfaces.Config import info.nightscout.interfaces.Config
import info.nightscout.interfaces.Constants import info.nightscout.interfaces.Constants
import info.nightscout.interfaces.nsclient.NSAlarm import info.nightscout.interfaces.nsclient.NSAlarm
import info.nightscout.interfaces.plugin.ActivePlugin
import info.nightscout.interfaces.plugin.PluginBase import info.nightscout.interfaces.plugin.PluginBase
import info.nightscout.interfaces.plugin.PluginDescription import info.nightscout.interfaces.plugin.PluginDescription
import info.nightscout.interfaces.plugin.PluginType import info.nightscout.interfaces.plugin.PluginType
import info.nightscout.interfaces.source.DoingOwnUploadSource
import info.nightscout.interfaces.sync.DataSyncSelector import info.nightscout.interfaces.sync.DataSyncSelector
import info.nightscout.interfaces.sync.NsClient import info.nightscout.interfaces.sync.NsClient
import info.nightscout.interfaces.sync.Sync import info.nightscout.interfaces.sync.Sync
@ -61,7 +63,8 @@ class NSClientPlugin @Inject constructor(
private val nsClientReceiverDelegate: NsClientReceiverDelegate, private val nsClientReceiverDelegate: NsClientReceiverDelegate,
private val config: Config, private val config: Config,
private val dataSyncSelector: DataSyncSelector, private val dataSyncSelector: DataSyncSelector,
private val uiInteraction: UiInteraction private val uiInteraction: UiInteraction,
private val activePlugin: ActivePlugin
) : NsClient, Sync, PluginBase( ) : NsClient, Sync, PluginBase(
PluginDescription() PluginDescription()
.mainType(PluginType.SYNC) .mainType(PluginType.SYNC)
@ -141,6 +144,9 @@ class NSClientPlugin @Inject constructor(
preferenceFragment.findPreference<SwitchPreference>(rh.gs(R.string.key_ns_create_announcements_from_carbs_req))?.isVisible = false preferenceFragment.findPreference<SwitchPreference>(rh.gs(R.string.key_ns_create_announcements_from_carbs_req))?.isVisible = false
} }
preferenceFragment.findPreference<SwitchPreference>(rh.gs(R.string.key_ns_receive_tbr_eb))?.isVisible = config.isEngineeringMode() preferenceFragment.findPreference<SwitchPreference>(rh.gs(R.string.key_ns_receive_tbr_eb))?.isVisible = config.isEngineeringMode()
if (activePlugin.activeBgSource is DoingOwnUploadSource) {
preferenceFragment.findPreference<SwitchPreference>(rh.gs(R.string.key_do_ns_upload))?.isVisible = false
}
} }
override val hasWritePermission: Boolean get() = nsClientService?.hasWriteAuth ?: false override val hasWritePermission: Boolean get() = nsClientService?.hasWriteAuth ?: false