remove dependencies from setup wizard
This commit is contained in:
parent
dd9518b73b
commit
72505b6093
11 changed files with 60 additions and 21 deletions
|
@ -0,0 +1,9 @@
|
||||||
|
package info.nightscout.rx.events
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
|
||||||
|
// Pass RL status to setup wizard
|
||||||
|
class EventSWRLStatus(val status: String) : EventStatus() {
|
||||||
|
|
||||||
|
override fun getStatus(context: Context): String = status
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
package info.nightscout.rx.events
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
|
||||||
|
// Pass pump status to setup wizard
|
||||||
|
class EventSWSyncStatus(val status: String) : EventStatus() {
|
||||||
|
|
||||||
|
override fun getStatus(context: Context): String = status
|
||||||
|
}
|
|
@ -9,7 +9,6 @@ import androidx.appcompat.app.AppCompatActivity
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.androidaps.R
|
import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.data.ProfileSealed
|
import info.nightscout.androidaps.data.ProfileSealed
|
||||||
import info.nightscout.androidaps.plugins.pump.common.events.EventRileyLinkDeviceStatusChange
|
|
||||||
import info.nightscout.androidaps.setupwizard.elements.SWBreak
|
import info.nightscout.androidaps.setupwizard.elements.SWBreak
|
||||||
import info.nightscout.androidaps.setupwizard.elements.SWButton
|
import info.nightscout.androidaps.setupwizard.elements.SWButton
|
||||||
import info.nightscout.androidaps.setupwizard.elements.SWEditEncryptedPassword
|
import info.nightscout.androidaps.setupwizard.elements.SWEditEncryptedPassword
|
||||||
|
@ -41,12 +40,10 @@ import info.nightscout.interfaces.pump.OmnipodEros
|
||||||
import info.nightscout.interfaces.queue.CommandQueue
|
import info.nightscout.interfaces.queue.CommandQueue
|
||||||
import info.nightscout.interfaces.ui.ActivityNames
|
import info.nightscout.interfaces.ui.ActivityNames
|
||||||
import info.nightscout.interfaces.utils.HardLimits
|
import info.nightscout.interfaces.utils.HardLimits
|
||||||
import info.nightscout.plugins.constraints.objectives.ObjectivesFragment
|
|
||||||
import info.nightscout.plugins.constraints.objectives.ObjectivesPlugin
|
|
||||||
import info.nightscout.plugins.profile.ProfilePlugin
|
|
||||||
import info.nightscout.plugins.sync.nsShared.events.EventNSClientStatus
|
|
||||||
import info.nightscout.rx.bus.RxBus
|
import info.nightscout.rx.bus.RxBus
|
||||||
import info.nightscout.rx.events.EventPumpStatusChanged
|
import info.nightscout.rx.events.EventPumpStatusChanged
|
||||||
|
import info.nightscout.rx.events.EventSWRLStatus
|
||||||
|
import info.nightscout.rx.events.EventSWSyncStatus
|
||||||
import info.nightscout.rx.events.EventSWUpdate
|
import info.nightscout.rx.events.EventSWUpdate
|
||||||
import info.nightscout.shared.interfaces.ResourceHelper
|
import info.nightscout.shared.interfaces.ResourceHelper
|
||||||
import info.nightscout.shared.sharedPreferences.SP
|
import info.nightscout.shared.sharedPreferences.SP
|
||||||
|
@ -61,10 +58,8 @@ class SWDefinition @Inject constructor(
|
||||||
private val rh: ResourceHelper,
|
private val rh: ResourceHelper,
|
||||||
private val sp: SP,
|
private val sp: SP,
|
||||||
private val profileFunction: ProfileFunction,
|
private val profileFunction: ProfileFunction,
|
||||||
private val profilePlugin: ProfilePlugin,
|
|
||||||
private val activePlugin: ActivePlugin,
|
private val activePlugin: ActivePlugin,
|
||||||
private val commandQueue: CommandQueue,
|
private val commandQueue: CommandQueue,
|
||||||
private val objectivesPlugin: ObjectivesPlugin,
|
|
||||||
private val configBuilder: ConfigBuilder,
|
private val configBuilder: ConfigBuilder,
|
||||||
private val loop: Loop,
|
private val loop: Loop,
|
||||||
private val importExportPrefs: ImportExportPrefs,
|
private val importExportPrefs: ImportExportPrefs,
|
||||||
|
@ -224,7 +219,7 @@ class SWDefinition @Inject constructor(
|
||||||
)
|
)
|
||||||
.add(SWBreak(injector))
|
.add(SWBreak(injector))
|
||||||
.add(
|
.add(
|
||||||
SWEventListener(injector, EventNSClientStatus::class.java)
|
SWEventListener(injector, EventSWSyncStatus::class.java)
|
||||||
.label(R.string.status)
|
.label(R.string.status)
|
||||||
.initialStatus(activePlugin.firstActiveSync?.status ?: "")
|
.initialStatus(activePlugin.firstActiveSync?.status ?: "")
|
||||||
)
|
)
|
||||||
|
@ -332,10 +327,10 @@ class SWDefinition @Inject constructor(
|
||||||
//.add(ProfileFragment())
|
//.add(ProfileFragment())
|
||||||
)
|
)
|
||||||
.validator {
|
.validator {
|
||||||
profilePlugin.profile?.getDefaultProfile()?.let { ProfileSealed.Pure(it).isValid("StartupWizard", activePlugin.activePump, config, rh, rxBus, hardLimits, false).isValid }
|
activePlugin.activeProfileSource.profile?.getDefaultProfile()?.let { ProfileSealed.Pure(it).isValid("StartupWizard", activePlugin.activePump, config, rh, rxBus, hardLimits, false).isValid }
|
||||||
?: false
|
?: false
|
||||||
}
|
}
|
||||||
.visibility { profilePlugin.isEnabled() }
|
.visibility { (activePlugin.activeProfileSource as PluginBase).isEnabled() }
|
||||||
|
|
||||||
private val screenProfileSwitch get() = SWScreen(injector, R.string.careportal_profileswitch)
|
private val screenProfileSwitch get() = SWScreen(injector, R.string.careportal_profileswitch)
|
||||||
.skippable(false)
|
.skippable(false)
|
||||||
|
@ -368,7 +363,7 @@ class SWDefinition @Inject constructor(
|
||||||
activePump is OmnipodEros && !activePump.isRileyLinkReady()
|
activePump is OmnipodEros && !activePump.isRileyLinkReady()
|
||||||
})
|
})
|
||||||
.add( // Omnipod Eros only
|
.add( // Omnipod Eros only
|
||||||
SWEventListener(injector, EventRileyLinkDeviceStatusChange::class.java)
|
SWEventListener(injector, EventSWRLStatus::class.java)
|
||||||
.label(R.string.setupwizard_pump_riley_link_status)
|
.label(R.string.setupwizard_pump_riley_link_status)
|
||||||
.visibility { activePlugin.activePump is OmnipodEros })
|
.visibility { activePlugin.activePump is OmnipodEros })
|
||||||
.add(SWButton(injector)
|
.add(SWButton(injector)
|
||||||
|
@ -466,10 +461,11 @@ class SWDefinition @Inject constructor(
|
||||||
.add(SWBreak(injector))
|
.add(SWBreak(injector))
|
||||||
.add(
|
.add(
|
||||||
SWFragment(injector, this)
|
SWFragment(injector, this)
|
||||||
.add(ObjectivesFragment())
|
.add(activity.supportFragmentManager.fragmentFactory.instantiate(ClassLoader.getSystemClassLoader(), (activePlugin.activeObjectives as PluginBase).pluginDescription.fragmentClass!!))
|
||||||
|
//.add(ObjectivesFragment())
|
||||||
)
|
)
|
||||||
.validator { objectivesPlugin.objectives[Objectives.FIRST_OBJECTIVE].isStarted }
|
.validator { activePlugin.activeObjectives?.isStarted(Objectives.FIRST_OBJECTIVE) ?: false}
|
||||||
.visibility { !objectivesPlugin.objectives[Objectives.FIRST_OBJECTIVE].isStarted && config.APS }
|
.visibility { config.APS && !(activePlugin.activeObjectives?.isStarted(Objectives.FIRST_OBJECTIVE) ?: false) }
|
||||||
|
|
||||||
private fun swDefinitionFull() = // List all the screens here
|
private fun swDefinitionFull() = // List all the screens here
|
||||||
add(screenSetupWizard)
|
add(screenSetupWizard)
|
||||||
|
|
|
@ -10,16 +10,16 @@ import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.activities.NoSplashAppCompatActivity
|
import info.nightscout.androidaps.activities.NoSplashAppCompatActivity
|
||||||
import info.nightscout.androidaps.databinding.ActivitySetupwizardBinding
|
import info.nightscout.androidaps.databinding.ActivitySetupwizardBinding
|
||||||
import info.nightscout.androidaps.logging.UserEntryLogger
|
import info.nightscout.androidaps.logging.UserEntryLogger
|
||||||
import info.nightscout.androidaps.plugins.pump.common.events.EventRileyLinkDeviceStatusChange
|
|
||||||
import info.nightscout.androidaps.setupwizard.elements.SWItem
|
import info.nightscout.androidaps.setupwizard.elements.SWItem
|
||||||
import info.nightscout.core.fabric.FabricPrivacy
|
import info.nightscout.core.fabric.FabricPrivacy
|
||||||
import info.nightscout.core.ui.dialogs.OKDialog
|
import info.nightscout.core.ui.dialogs.OKDialog
|
||||||
import info.nightscout.interfaces.locale.LocaleHelper.update
|
import info.nightscout.interfaces.locale.LocaleHelper.update
|
||||||
import info.nightscout.plugins.sync.nsShared.events.EventNSClientStatus
|
|
||||||
import info.nightscout.rx.AapsSchedulers
|
import info.nightscout.rx.AapsSchedulers
|
||||||
import info.nightscout.rx.events.EventProfileStoreChanged
|
import info.nightscout.rx.events.EventProfileStoreChanged
|
||||||
import info.nightscout.rx.events.EventProfileSwitchChanged
|
import info.nightscout.rx.events.EventProfileSwitchChanged
|
||||||
import info.nightscout.rx.events.EventPumpStatusChanged
|
import info.nightscout.rx.events.EventPumpStatusChanged
|
||||||
|
import info.nightscout.rx.events.EventSWRLStatus
|
||||||
|
import info.nightscout.rx.events.EventSWSyncStatus
|
||||||
import info.nightscout.rx.events.EventSWUpdate
|
import info.nightscout.rx.events.EventSWUpdate
|
||||||
import info.nightscout.shared.sharedPreferences.SP
|
import info.nightscout.shared.sharedPreferences.SP
|
||||||
import io.reactivex.rxjava3.disposables.CompositeDisposable
|
import io.reactivex.rxjava3.disposables.CompositeDisposable
|
||||||
|
@ -80,11 +80,11 @@ class SetupWizardActivity : NoSplashAppCompatActivity() {
|
||||||
.observeOn(aapsSchedulers.main)
|
.observeOn(aapsSchedulers.main)
|
||||||
.subscribe({ updateButtons() }, fabricPrivacy::logException)
|
.subscribe({ updateButtons() }, fabricPrivacy::logException)
|
||||||
disposable += rxBus
|
disposable += rxBus
|
||||||
.toObservable(EventRileyLinkDeviceStatusChange::class.java)
|
.toObservable(EventSWRLStatus::class.java)
|
||||||
.observeOn(aapsSchedulers.main)
|
.observeOn(aapsSchedulers.main)
|
||||||
.subscribe({ updateButtons() }, fabricPrivacy::logException)
|
.subscribe({ updateButtons() }, fabricPrivacy::logException)
|
||||||
disposable += rxBus
|
disposable += rxBus
|
||||||
.toObservable(EventNSClientStatus::class.java)
|
.toObservable(EventSWSyncStatus::class.java)
|
||||||
.observeOn(aapsSchedulers.main)
|
.observeOn(aapsSchedulers.main)
|
||||||
.subscribe({ updateButtons() }, fabricPrivacy::logException)
|
.subscribe({ updateButtons() }, fabricPrivacy::logException)
|
||||||
disposable += rxBus
|
disposable += rxBus
|
||||||
|
|
|
@ -16,4 +16,5 @@ interface Objectives {
|
||||||
}
|
}
|
||||||
|
|
||||||
fun isAccomplished(index: Int): Boolean
|
fun isAccomplished(index: Int): Boolean
|
||||||
|
fun isStarted(index: Int): Boolean
|
||||||
}
|
}
|
|
@ -149,5 +149,6 @@ class ObjectivesPlugin @Inject constructor(
|
||||||
return value
|
return value
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun isAccomplished(index: Int) = objectives[Objectives.MAXIOB_OBJECTIVE].isAccomplished
|
override fun isAccomplished(index: Int) = objectives[index].isAccomplished
|
||||||
|
override fun isStarted(index: Int): Boolean = objectives[index].isStarted
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,6 +40,7 @@ import info.nightscout.rx.events.EventAppExit
|
||||||
import info.nightscout.rx.events.EventChargingState
|
import info.nightscout.rx.events.EventChargingState
|
||||||
import info.nightscout.rx.events.EventNetworkChange
|
import info.nightscout.rx.events.EventNetworkChange
|
||||||
import info.nightscout.rx.events.EventPreferenceChange
|
import info.nightscout.rx.events.EventPreferenceChange
|
||||||
|
import info.nightscout.rx.events.EventSWSyncStatus
|
||||||
import info.nightscout.rx.logging.AAPSLogger
|
import info.nightscout.rx.logging.AAPSLogger
|
||||||
import info.nightscout.rx.logging.LTag
|
import info.nightscout.rx.logging.LTag
|
||||||
import info.nightscout.shared.interfaces.ResourceHelper
|
import info.nightscout.shared.interfaces.ResourceHelper
|
||||||
|
@ -92,10 +93,12 @@ class NSClientPlugin @Inject constructor(
|
||||||
disposable += rxBus
|
disposable += rxBus
|
||||||
.toObservable(EventNSClientStatus::class.java)
|
.toObservable(EventNSClientStatus::class.java)
|
||||||
.observeOn(aapsSchedulers.io)
|
.observeOn(aapsSchedulers.io)
|
||||||
.subscribe({ event: EventNSClientStatus ->
|
.subscribe({ event ->
|
||||||
if (event.version == NsClient.Version.V1) {
|
if (event.version == NsClient.Version.V1) {
|
||||||
status = event.getStatus(context)
|
status = event.getStatus(context)
|
||||||
rxBus.send(EventNSClientUpdateGUI())
|
rxBus.send(EventNSClientUpdateGUI())
|
||||||
|
// Pass to setup wizard
|
||||||
|
rxBus.send(EventSWSyncStatus(event.getStatus(context)))
|
||||||
}
|
}
|
||||||
}, fabricPrivacy::logException)
|
}, fabricPrivacy::logException)
|
||||||
disposable += rxBus
|
disposable += rxBus
|
||||||
|
|
|
@ -42,6 +42,7 @@ import info.nightscout.rx.bus.RxBus
|
||||||
import info.nightscout.rx.events.EventChargingState
|
import info.nightscout.rx.events.EventChargingState
|
||||||
import info.nightscout.rx.events.EventNetworkChange
|
import info.nightscout.rx.events.EventNetworkChange
|
||||||
import info.nightscout.rx.events.EventPreferenceChange
|
import info.nightscout.rx.events.EventPreferenceChange
|
||||||
|
import info.nightscout.rx.events.EventSWSyncStatus
|
||||||
import info.nightscout.rx.logging.AAPSLogger
|
import info.nightscout.rx.logging.AAPSLogger
|
||||||
import info.nightscout.rx.logging.LTag
|
import info.nightscout.rx.logging.LTag
|
||||||
import info.nightscout.sdk.NSAndroidClientImpl
|
import info.nightscout.sdk.NSAndroidClientImpl
|
||||||
|
@ -149,6 +150,8 @@ class NSClientV3Plugin @Inject constructor(
|
||||||
if (event.version == NsClient.Version.V3) {
|
if (event.version == NsClient.Version.V3) {
|
||||||
status = event.getStatus(context)
|
status = event.getStatus(context)
|
||||||
rxBus.send(EventNSClientUpdateGUI())
|
rxBus.send(EventNSClientUpdateGUI())
|
||||||
|
// Pass to setup wizard
|
||||||
|
rxBus.send(EventSWSyncStatus(event.getStatus(context)))
|
||||||
}
|
}
|
||||||
}, fabricPrivacy::logException)
|
}, fabricPrivacy::logException)
|
||||||
disposable += rxBus
|
disposable += rxBus
|
||||||
|
|
|
@ -11,6 +11,7 @@ import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotifi
|
||||||
import info.nightscout.androidaps.plugins.pump.common.PumpPluginAbstract
|
import info.nightscout.androidaps.plugins.pump.common.PumpPluginAbstract
|
||||||
import info.nightscout.androidaps.plugins.pump.common.data.PumpStatus
|
import info.nightscout.androidaps.plugins.pump.common.data.PumpStatus
|
||||||
import info.nightscout.androidaps.plugins.pump.common.defs.PumpDriverState
|
import info.nightscout.androidaps.plugins.pump.common.defs.PumpDriverState
|
||||||
|
import info.nightscout.androidaps.plugins.pump.common.events.EventRileyLinkDeviceStatusChange
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkConst
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkConst
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkPumpDevice
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkPumpDevice
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkPumpInfo
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkPumpInfo
|
||||||
|
@ -67,6 +68,7 @@ import info.nightscout.rx.AapsSchedulers
|
||||||
import info.nightscout.rx.bus.RxBus
|
import info.nightscout.rx.bus.RxBus
|
||||||
import info.nightscout.rx.events.EventRefreshButtonState
|
import info.nightscout.rx.events.EventRefreshButtonState
|
||||||
import info.nightscout.rx.events.EventRefreshOverview
|
import info.nightscout.rx.events.EventRefreshOverview
|
||||||
|
import info.nightscout.rx.events.EventSWRLStatus
|
||||||
import info.nightscout.rx.logging.AAPSLogger
|
import info.nightscout.rx.logging.AAPSLogger
|
||||||
import info.nightscout.rx.logging.LTag
|
import info.nightscout.rx.logging.LTag
|
||||||
import info.nightscout.shared.interfaces.ResourceHelper
|
import info.nightscout.shared.interfaces.ResourceHelper
|
||||||
|
@ -157,6 +159,13 @@ class MedtronicPumpPlugin @Inject constructor(
|
||||||
}.start()
|
}.start()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Pass only to setup wizard
|
||||||
|
disposable.add(
|
||||||
|
rxBus
|
||||||
|
.toObservable(EventRileyLinkDeviceStatusChange::class.java)
|
||||||
|
.observeOn(aapsSchedulers.io)
|
||||||
|
.subscribe({ event: EventRileyLinkDeviceStatusChange -> rxBus.send(EventSWRLStatus(event.getStatus(context))) }, fabricPrivacy::logException)
|
||||||
|
)
|
||||||
super.onStart()
|
super.onStart()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -108,6 +108,7 @@ import info.nightscout.rx.events.EventAppExit;
|
||||||
import info.nightscout.rx.events.EventAppInitialized;
|
import info.nightscout.rx.events.EventAppInitialized;
|
||||||
import info.nightscout.rx.events.EventPreferenceChange;
|
import info.nightscout.rx.events.EventPreferenceChange;
|
||||||
import info.nightscout.rx.events.EventRefreshOverview;
|
import info.nightscout.rx.events.EventRefreshOverview;
|
||||||
|
import info.nightscout.rx.events.EventSWRLStatus;
|
||||||
import info.nightscout.rx.logging.AAPSLogger;
|
import info.nightscout.rx.logging.AAPSLogger;
|
||||||
import info.nightscout.rx.logging.LTag;
|
import info.nightscout.rx.logging.LTag;
|
||||||
import info.nightscout.shared.interfaces.ResourceHelper;
|
import info.nightscout.shared.interfaces.ResourceHelper;
|
||||||
|
@ -326,6 +327,13 @@ public class OmnipodErosPumpPlugin extends PumpPluginBase implements Pump, Riley
|
||||||
.observeOn(aapsSchedulers.getIo())
|
.observeOn(aapsSchedulers.getIo())
|
||||||
.subscribe(event -> handlePodFaultEvent(), fabricPrivacy::logException)
|
.subscribe(event -> handlePodFaultEvent(), fabricPrivacy::logException)
|
||||||
);
|
);
|
||||||
|
// Pass only to setup wizard
|
||||||
|
disposable.add(rxBus
|
||||||
|
.toObservable(EventRileyLinkDeviceStatusChange.class)
|
||||||
|
.observeOn(aapsSchedulers.getIo())
|
||||||
|
.subscribe(event -> rxBus.send(new EventSWRLStatus(event.getStatus(context))),
|
||||||
|
fabricPrivacy::logException)
|
||||||
|
);
|
||||||
disposable.add(rxBus
|
disposable.add(rxBus
|
||||||
.toObservable(EventPreferenceChange.class)
|
.toObservable(EventPreferenceChange.class)
|
||||||
.observeOn(aapsSchedulers.getIo())
|
.observeOn(aapsSchedulers.getIo())
|
||||||
|
|
|
@ -66,7 +66,7 @@ abstract class PumpPluginAbstract protected constructor(
|
||||||
var pumpSyncStorage: PumpSyncStorage
|
var pumpSyncStorage: PumpSyncStorage
|
||||||
) : PumpPluginBase(pluginDescription, injector, aapsLogger, rh, commandQueue), Pump, Constraints, info.nightscout.androidaps.plugins.pump.common.sync.PumpSyncEntriesCreator {
|
) : PumpPluginBase(pluginDescription, injector, aapsLogger, rh, commandQueue), Pump, Constraints, info.nightscout.androidaps.plugins.pump.common.sync.PumpSyncEntriesCreator {
|
||||||
|
|
||||||
private val disposable = CompositeDisposable()
|
protected val disposable = CompositeDisposable()
|
||||||
|
|
||||||
// Pump capabilities
|
// Pump capabilities
|
||||||
final override var pumpDescription = PumpDescription()
|
final override var pumpDescription = PumpDescription()
|
||||||
|
|
Loading…
Reference in a new issue