commit
86ca5f30fc
204 changed files with 3127 additions and 568 deletions
|
@ -235,6 +235,7 @@ dependencies {
|
||||||
wearApp project(':wear')
|
wearApp project(':wear')
|
||||||
|
|
||||||
implementation project(':core')
|
implementation project(':core')
|
||||||
|
implementation project(':database')
|
||||||
implementation project(':dana')
|
implementation project(':dana')
|
||||||
implementation project(':danars')
|
implementation project(':danars')
|
||||||
implementation project(':danar')
|
implementation project(':danar')
|
||||||
|
|
BIN
app/jacoco.exec
BIN
app/jacoco.exec
Binary file not shown.
|
@ -57,10 +57,10 @@ import info.nightscout.androidaps.utils.extensions.isRunningRealPumpTest
|
||||||
import info.nightscout.androidaps.utils.locale.LocaleHelper
|
import info.nightscout.androidaps.utils.locale.LocaleHelper
|
||||||
import info.nightscout.androidaps.utils.protection.ProtectionCheck
|
import info.nightscout.androidaps.utils.protection.ProtectionCheck
|
||||||
import info.nightscout.androidaps.utils.resources.IconsProvider
|
import info.nightscout.androidaps.utils.resources.IconsProvider
|
||||||
|
import info.nightscout.androidaps.utils.rx.AapsSchedulers
|
||||||
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||||
import info.nightscout.androidaps.utils.tabs.TabPageAdapter
|
import info.nightscout.androidaps.utils.tabs.TabPageAdapter
|
||||||
import info.nightscout.androidaps.utils.ui.UIRunnable
|
import info.nightscout.androidaps.utils.ui.UIRunnable
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
|
||||||
import io.reactivex.disposables.CompositeDisposable
|
import io.reactivex.disposables.CompositeDisposable
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
@ -71,6 +71,7 @@ class MainActivity : NoSplashAppCompatActivity() {
|
||||||
private val disposable = CompositeDisposable()
|
private val disposable = CompositeDisposable()
|
||||||
|
|
||||||
@Inject lateinit var aapsLogger: AAPSLogger
|
@Inject lateinit var aapsLogger: AAPSLogger
|
||||||
|
@Inject lateinit var aapsSchedulers: AapsSchedulers
|
||||||
@Inject lateinit var rxBus: RxBusWrapper
|
@Inject lateinit var rxBus: RxBusWrapper
|
||||||
@Inject lateinit var androidPermission: AndroidPermission
|
@Inject lateinit var androidPermission: AndroidPermission
|
||||||
@Inject lateinit var sp: SP
|
@Inject lateinit var sp: SP
|
||||||
|
@ -125,7 +126,7 @@ class MainActivity : NoSplashAppCompatActivity() {
|
||||||
setupViews()
|
setupViews()
|
||||||
disposable.add(rxBus
|
disposable.add(rxBus
|
||||||
.toObservable(EventRebuildTabs::class.java)
|
.toObservable(EventRebuildTabs::class.java)
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(aapsSchedulers.main)
|
||||||
.subscribe({
|
.subscribe({
|
||||||
if (it.recreate) recreate()
|
if (it.recreate) recreate()
|
||||||
else setupViews()
|
else setupViews()
|
||||||
|
@ -134,7 +135,7 @@ class MainActivity : NoSplashAppCompatActivity() {
|
||||||
)
|
)
|
||||||
disposable.add(rxBus
|
disposable.add(rxBus
|
||||||
.toObservable(EventPreferenceChange::class.java)
|
.toObservable(EventPreferenceChange::class.java)
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(aapsSchedulers.main)
|
||||||
.subscribe({ processPreferenceChange(it) }, fabricPrivacy::logException)
|
.subscribe({ processPreferenceChange(it) }, fabricPrivacy::logException)
|
||||||
)
|
)
|
||||||
if (!sp.getBoolean(R.string.key_setupwizard_processed, false) && !isRunningRealPumpTest()) {
|
if (!sp.getBoolean(R.string.key_setupwizard_processed, false) && !isRunningRealPumpTest()) {
|
||||||
|
|
|
@ -17,6 +17,8 @@ import info.nightscout.androidaps.plugins.general.nsclient.UploadQueue
|
||||||
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin
|
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin
|
||||||
import info.nightscout.androidaps.queue.CommandQueue
|
import info.nightscout.androidaps.queue.CommandQueue
|
||||||
import info.nightscout.androidaps.utils.androidNotification.NotificationHolder
|
import info.nightscout.androidaps.utils.androidNotification.NotificationHolder
|
||||||
|
import info.nightscout.androidaps.utils.rx.AapsSchedulers
|
||||||
|
import info.nightscout.androidaps.utils.rx.DefaultAapsSchedulers
|
||||||
import info.nightscout.androidaps.utils.storage.FileStorage
|
import info.nightscout.androidaps.utils.storage.FileStorage
|
||||||
import info.nightscout.androidaps.utils.storage.Storage
|
import info.nightscout.androidaps.utils.storage.Storage
|
||||||
import javax.inject.Singleton
|
import javax.inject.Singleton
|
||||||
|
@ -46,6 +48,10 @@ open class AppModule {
|
||||||
return FileStorage()
|
return FileStorage()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
@Singleton
|
||||||
|
internal fun provideSchedulers(): AapsSchedulers = DefaultAapsSchedulers()
|
||||||
|
|
||||||
@Module
|
@Module
|
||||||
interface AppBindings {
|
interface AppBindings {
|
||||||
|
|
||||||
|
|
|
@ -36,9 +36,9 @@ import info.nightscout.androidaps.utils.SafeParse
|
||||||
import info.nightscout.androidaps.utils.ToastUtils
|
import info.nightscout.androidaps.utils.ToastUtils
|
||||||
import info.nightscout.androidaps.utils.extensions.toVisibility
|
import info.nightscout.androidaps.utils.extensions.toVisibility
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
|
import info.nightscout.androidaps.utils.rx.AapsSchedulers
|
||||||
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||||
import info.nightscout.androidaps.utils.wizard.BolusWizard
|
import info.nightscout.androidaps.utils.wizard.BolusWizard
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
|
||||||
import io.reactivex.disposables.CompositeDisposable
|
import io.reactivex.disposables.CompositeDisposable
|
||||||
import java.text.DecimalFormat
|
import java.text.DecimalFormat
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
@ -48,6 +48,7 @@ import kotlin.math.abs
|
||||||
class WizardDialog : DaggerDialogFragment() {
|
class WizardDialog : DaggerDialogFragment() {
|
||||||
|
|
||||||
@Inject lateinit var aapsLogger: AAPSLogger
|
@Inject lateinit var aapsLogger: AAPSLogger
|
||||||
|
@Inject lateinit var aapsSchedulers: AapsSchedulers
|
||||||
@Inject lateinit var constraintChecker: ConstraintChecker
|
@Inject lateinit var constraintChecker: ConstraintChecker
|
||||||
@Inject lateinit var mainApp: MainApp
|
@Inject lateinit var mainApp: MainApp
|
||||||
@Inject lateinit var sp: SP
|
@Inject lateinit var sp: SP
|
||||||
|
@ -188,10 +189,10 @@ class WizardDialog : DaggerDialogFragment() {
|
||||||
// bus
|
// bus
|
||||||
disposable.add(rxBus
|
disposable.add(rxBus
|
||||||
.toObservable(EventAutosensCalculationFinished::class.java)
|
.toObservable(EventAutosensCalculationFinished::class.java)
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(aapsSchedulers.main)
|
||||||
.subscribe({
|
.subscribe({
|
||||||
activity?.runOnUiThread { calculateInsulin() }
|
activity?.runOnUiThread { calculateInsulin() }
|
||||||
}, { fabricPrivacy.logException(it) })
|
}, fabricPrivacy::logException)
|
||||||
)
|
)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,10 +32,9 @@ import info.nightscout.androidaps.utils.FabricPrivacy
|
||||||
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.toVisibility
|
import info.nightscout.androidaps.utils.extensions.toVisibility
|
||||||
|
import info.nightscout.androidaps.utils.rx.AapsSchedulers
|
||||||
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
|
||||||
import io.reactivex.disposables.CompositeDisposable
|
import io.reactivex.disposables.CompositeDisposable
|
||||||
import io.reactivex.schedulers.Schedulers
|
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import kotlinx.coroutines.withContext
|
import kotlinx.coroutines.withContext
|
||||||
|
@ -46,6 +45,7 @@ class HistoryBrowseActivity : NoSplashAppCompatActivity() {
|
||||||
|
|
||||||
@Inject lateinit var injector: HasAndroidInjector
|
@Inject lateinit var injector: HasAndroidInjector
|
||||||
@Inject lateinit var aapsLogger: AAPSLogger
|
@Inject lateinit var aapsLogger: AAPSLogger
|
||||||
|
@Inject lateinit var aapsSchedulers: AapsSchedulers
|
||||||
@Inject lateinit var rxBus: RxBusWrapper
|
@Inject lateinit var rxBus: RxBusWrapper
|
||||||
@Inject lateinit var sp: SP
|
@Inject lateinit var sp: SP
|
||||||
@Inject lateinit var profileFunction: ProfileFunction
|
@Inject lateinit var profileFunction: ProfileFunction
|
||||||
|
@ -173,7 +173,7 @@ class HistoryBrowseActivity : NoSplashAppCompatActivity() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
disposable.add(rxBus
|
disposable.add(rxBus
|
||||||
.toObservable(EventAutosensCalculationFinished::class.java)
|
.toObservable(EventAutosensCalculationFinished::class.java)
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(aapsSchedulers.io)
|
||||||
.subscribe({
|
.subscribe({
|
||||||
// catch only events from iobCobCalculatorPluginHistory
|
// catch only events from iobCobCalculatorPluginHistory
|
||||||
if (it.cause is EventCustomCalculationFinished) {
|
if (it.cause is EventCustomCalculationFinished) {
|
||||||
|
@ -183,7 +183,7 @@ class HistoryBrowseActivity : NoSplashAppCompatActivity() {
|
||||||
)
|
)
|
||||||
disposable.add(rxBus
|
disposable.add(rxBus
|
||||||
.toObservable(EventAutosensBgLoaded::class.java)
|
.toObservable(EventAutosensBgLoaded::class.java)
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(aapsSchedulers.io)
|
||||||
.subscribe({
|
.subscribe({
|
||||||
// catch only events from iobCobCalculatorPluginHistory
|
// catch only events from iobCobCalculatorPluginHistory
|
||||||
if (it.cause is EventCustomCalculationFinished) {
|
if (it.cause is EventCustomCalculationFinished) {
|
||||||
|
@ -193,12 +193,12 @@ class HistoryBrowseActivity : NoSplashAppCompatActivity() {
|
||||||
)
|
)
|
||||||
disposable.add(rxBus
|
disposable.add(rxBus
|
||||||
.toObservable(EventIobCalculationProgress::class.java)
|
.toObservable(EventIobCalculationProgress::class.java)
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(aapsSchedulers.main)
|
||||||
.subscribe({ binding.overviewIobcalculationprogess.text = it.progress }, fabricPrivacy::logException)
|
.subscribe({ binding.overviewIobcalculationprogess.text = it.progress }, fabricPrivacy::logException)
|
||||||
)
|
)
|
||||||
disposable.add(rxBus
|
disposable.add(rxBus
|
||||||
.toObservable(EventRefreshOverview::class.java)
|
.toObservable(EventRefreshOverview::class.java)
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(aapsSchedulers.main)
|
||||||
.subscribe({
|
.subscribe({
|
||||||
if (it.now) {
|
if (it.now) {
|
||||||
updateGUI("EventRefreshOverview", bgOnly = false)
|
updateGUI("EventRefreshOverview", bgOnly = false)
|
||||||
|
@ -308,7 +308,6 @@ class HistoryBrowseActivity : NoSplashAppCompatActivity() {
|
||||||
// **** BG ****
|
// **** BG ****
|
||||||
graphData.addBgReadings(fromTime, toTime, lowLine, highLine, null)
|
graphData.addBgReadings(fromTime, toTime, lowLine, highLine, null)
|
||||||
|
|
||||||
|
|
||||||
// add target line
|
// add target line
|
||||||
graphData.addTargetLine(fromTime, toTime, profile, null)
|
graphData.addTargetLine(fromTime, toTime, profile, null)
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,7 @@ import info.nightscout.androidaps.plugins.sensitivity.SensitivityWeightedAverage
|
||||||
import info.nightscout.androidaps.utils.DateUtil
|
import info.nightscout.androidaps.utils.DateUtil
|
||||||
import info.nightscout.androidaps.utils.FabricPrivacy
|
import info.nightscout.androidaps.utils.FabricPrivacy
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
|
import info.nightscout.androidaps.utils.rx.AapsSchedulers
|
||||||
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
import javax.inject.Singleton
|
import javax.inject.Singleton
|
||||||
|
@ -20,6 +21,7 @@ import javax.inject.Singleton
|
||||||
class IobCobCalculatorPluginHistory @Inject constructor(
|
class IobCobCalculatorPluginHistory @Inject constructor(
|
||||||
injector: HasAndroidInjector,
|
injector: HasAndroidInjector,
|
||||||
aapsLogger: AAPSLogger,
|
aapsLogger: AAPSLogger,
|
||||||
|
aapsSchedulers: AapsSchedulers,
|
||||||
rxBus: RxBusWrapper,
|
rxBus: RxBusWrapper,
|
||||||
sp: SP,
|
sp: SP,
|
||||||
resourceHelper: ResourceHelper,
|
resourceHelper: ResourceHelper,
|
||||||
|
@ -31,7 +33,7 @@ class IobCobCalculatorPluginHistory @Inject constructor(
|
||||||
sensitivityWeightedAveragePlugin: SensitivityWeightedAveragePlugin,
|
sensitivityWeightedAveragePlugin: SensitivityWeightedAveragePlugin,
|
||||||
fabricPrivacy: FabricPrivacy,
|
fabricPrivacy: FabricPrivacy,
|
||||||
dateUtil: DateUtil
|
dateUtil: DateUtil
|
||||||
) : IobCobCalculatorPlugin(injector, aapsLogger, rxBus, sp, resourceHelper, profileFunction,
|
) : IobCobCalculatorPlugin(injector, aapsLogger, aapsSchedulers, rxBus, sp, resourceHelper, profileFunction,
|
||||||
activePlugin, treatmentsPluginHistory, sensitivityOref1Plugin, sensitivityAAPSPlugin, sensitivityWeightedAveragePlugin, fabricPrivacy, dateUtil) {
|
activePlugin, treatmentsPluginHistory, sensitivityOref1Plugin, sensitivityAAPSPlugin, sensitivityWeightedAveragePlugin, fabricPrivacy, dateUtil) {
|
||||||
|
|
||||||
override fun onStart() { // do not attach to rxbus
|
override fun onStart() { // do not attach to rxbus
|
||||||
|
|
|
@ -13,6 +13,7 @@ import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin
|
||||||
import info.nightscout.androidaps.utils.DateUtil
|
import info.nightscout.androidaps.utils.DateUtil
|
||||||
import info.nightscout.androidaps.utils.FabricPrivacy
|
import info.nightscout.androidaps.utils.FabricPrivacy
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
|
import info.nightscout.androidaps.utils.rx.AapsSchedulers
|
||||||
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
import javax.inject.Singleton
|
import javax.inject.Singleton
|
||||||
|
@ -21,6 +22,7 @@ import javax.inject.Singleton
|
||||||
class TreatmentsPluginHistory @Inject constructor(
|
class TreatmentsPluginHistory @Inject constructor(
|
||||||
injector: HasAndroidInjector,
|
injector: HasAndroidInjector,
|
||||||
aapsLogger: AAPSLogger,
|
aapsLogger: AAPSLogger,
|
||||||
|
aapsSchedulers: AapsSchedulers,
|
||||||
rxBus: RxBusWrapper,
|
rxBus: RxBusWrapper,
|
||||||
resourceHelper: ResourceHelper,
|
resourceHelper: ResourceHelper,
|
||||||
context: Context,
|
context: Context,
|
||||||
|
@ -31,7 +33,7 @@ class TreatmentsPluginHistory @Inject constructor(
|
||||||
fabricPrivacy: FabricPrivacy,
|
fabricPrivacy: FabricPrivacy,
|
||||||
dateUtil: DateUtil,
|
dateUtil: DateUtil,
|
||||||
uploadQueue: UploadQueue
|
uploadQueue: UploadQueue
|
||||||
) : TreatmentsPlugin(injector, aapsLogger, rxBus, resourceHelper, context, sp, profileFunction, activePlugin, nsUpload, fabricPrivacy, dateUtil, uploadQueue) {
|
) : TreatmentsPlugin(injector, aapsLogger, rxBus, aapsSchedulers, resourceHelper, context, sp, profileFunction, activePlugin, nsUpload, fabricPrivacy, dateUtil, uploadQueue) {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
onStart()
|
onStart()
|
||||||
|
|
|
@ -17,13 +17,15 @@ import info.nightscout.androidaps.utils.FabricPrivacy
|
||||||
import info.nightscout.androidaps.utils.HtmlHelper
|
import info.nightscout.androidaps.utils.HtmlHelper
|
||||||
import info.nightscout.androidaps.utils.extensions.plusAssign
|
import info.nightscout.androidaps.utils.extensions.plusAssign
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
|
import info.nightscout.androidaps.utils.rx.AapsSchedulers
|
||||||
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
|
||||||
import io.reactivex.disposables.CompositeDisposable
|
import io.reactivex.disposables.CompositeDisposable
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class LoopFragment : DaggerFragment() {
|
class LoopFragment : DaggerFragment() {
|
||||||
|
|
||||||
@Inject lateinit var aapsLogger: AAPSLogger
|
@Inject lateinit var aapsLogger: AAPSLogger
|
||||||
|
@Inject lateinit var aapsSchedulers: AapsSchedulers
|
||||||
@Inject lateinit var rxBus: RxBusWrapper
|
@Inject lateinit var rxBus: RxBusWrapper
|
||||||
@Inject lateinit var sp: SP
|
@Inject lateinit var sp: SP
|
||||||
@Inject lateinit var resourceHelper: ResourceHelper
|
@Inject lateinit var resourceHelper: ResourceHelper
|
||||||
|
@ -59,18 +61,18 @@ class LoopFragment : DaggerFragment() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
disposable += rxBus
|
disposable += rxBus
|
||||||
.toObservable(EventLoopUpdateGui::class.java)
|
.toObservable(EventLoopUpdateGui::class.java)
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(aapsSchedulers.main)
|
||||||
.subscribe({
|
.subscribe({
|
||||||
updateGUI()
|
updateGUI()
|
||||||
}, { fabricPrivacy.logException(it) })
|
}, fabricPrivacy::logException)
|
||||||
|
|
||||||
disposable += rxBus
|
disposable += rxBus
|
||||||
.toObservable(EventLoopSetLastRunGui::class.java)
|
.toObservable(EventLoopSetLastRunGui::class.java)
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(aapsSchedulers.main)
|
||||||
.subscribe({
|
.subscribe({
|
||||||
clearGUI()
|
clearGUI()
|
||||||
binding.lastrun.text = it.text
|
binding.lastrun.text = it.text
|
||||||
}, { fabricPrivacy.logException(it) })
|
}, fabricPrivacy::logException)
|
||||||
|
|
||||||
updateGUI()
|
updateGUI()
|
||||||
sp.putBoolean(R.string.key_objectiveuseloop, true)
|
sp.putBoolean(R.string.key_objectiveuseloop, true)
|
||||||
|
|
|
@ -72,15 +72,16 @@ import info.nightscout.androidaps.utils.FabricPrivacy;
|
||||||
import info.nightscout.androidaps.utils.HardLimits;
|
import info.nightscout.androidaps.utils.HardLimits;
|
||||||
import info.nightscout.androidaps.utils.T;
|
import info.nightscout.androidaps.utils.T;
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper;
|
import info.nightscout.androidaps.utils.resources.ResourceHelper;
|
||||||
|
import info.nightscout.androidaps.utils.rx.AapsSchedulers;
|
||||||
import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
||||||
import io.reactivex.disposables.CompositeDisposable;
|
import io.reactivex.disposables.CompositeDisposable;
|
||||||
import io.reactivex.schedulers.Schedulers;
|
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
public class LoopPlugin extends PluginBase implements LoopInterface {
|
public class LoopPlugin extends PluginBase implements LoopInterface {
|
||||||
private final HasAndroidInjector injector;
|
private final HasAndroidInjector injector;
|
||||||
private final SP sp;
|
private final SP sp;
|
||||||
private final RxBusWrapper rxBus;
|
private final RxBusWrapper rxBus;
|
||||||
|
private final AapsSchedulers aapsSchedulers;
|
||||||
private final ConstraintChecker constraintChecker;
|
private final ConstraintChecker constraintChecker;
|
||||||
private final ResourceHelper resourceHelper;
|
private final ResourceHelper resourceHelper;
|
||||||
private final ProfileFunction profileFunction;
|
private final ProfileFunction profileFunction;
|
||||||
|
@ -123,6 +124,7 @@ public class LoopPlugin extends PluginBase implements LoopInterface {
|
||||||
public LoopPlugin(
|
public LoopPlugin(
|
||||||
HasAndroidInjector injector,
|
HasAndroidInjector injector,
|
||||||
AAPSLogger aapsLogger,
|
AAPSLogger aapsLogger,
|
||||||
|
AapsSchedulers aapsSchedulers,
|
||||||
RxBusWrapper rxBus,
|
RxBusWrapper rxBus,
|
||||||
SP sp,
|
SP sp,
|
||||||
Config config,
|
Config config,
|
||||||
|
@ -153,6 +155,7 @@ public class LoopPlugin extends PluginBase implements LoopInterface {
|
||||||
aapsLogger, resourceHelper, injector
|
aapsLogger, resourceHelper, injector
|
||||||
);
|
);
|
||||||
this.injector = injector;
|
this.injector = injector;
|
||||||
|
this.aapsSchedulers = aapsSchedulers;
|
||||||
this.sp = sp;
|
this.sp = sp;
|
||||||
this.rxBus = rxBus;
|
this.rxBus = rxBus;
|
||||||
this.constraintChecker = constraintChecker;
|
this.constraintChecker = constraintChecker;
|
||||||
|
@ -181,7 +184,7 @@ public class LoopPlugin extends PluginBase implements LoopInterface {
|
||||||
super.onStart();
|
super.onStart();
|
||||||
disposable.add(rxBus
|
disposable.add(rxBus
|
||||||
.toObservable(EventTempTargetChange.class)
|
.toObservable(EventTempTargetChange.class)
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(aapsSchedulers.getIo())
|
||||||
.subscribe(event -> invoke("EventTempTargetChange", true), fabricPrivacy::logException)
|
.subscribe(event -> invoke("EventTempTargetChange", true), fabricPrivacy::logException)
|
||||||
);
|
);
|
||||||
/*
|
/*
|
||||||
|
@ -193,7 +196,7 @@ public class LoopPlugin extends PluginBase implements LoopInterface {
|
||||||
*/
|
*/
|
||||||
disposable.add(rxBus
|
disposable.add(rxBus
|
||||||
.toObservable(EventAutosensCalculationFinished.class)
|
.toObservable(EventAutosensCalculationFinished.class)
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(aapsSchedulers.getIo())
|
||||||
.subscribe(event -> {
|
.subscribe(event -> {
|
||||||
// Autosens calculation not triggered by a new BG
|
// Autosens calculation not triggered by a new BG
|
||||||
if (!(event.getCause() instanceof EventNewBG)) return;
|
if (!(event.getCause() instanceof EventNewBG)) return;
|
||||||
|
|
|
@ -18,7 +18,7 @@ import info.nightscout.androidaps.utils.FabricPrivacy
|
||||||
import info.nightscout.androidaps.utils.JSONFormatter
|
import info.nightscout.androidaps.utils.JSONFormatter
|
||||||
import info.nightscout.androidaps.utils.extensions.plusAssign
|
import info.nightscout.androidaps.utils.extensions.plusAssign
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
import info.nightscout.androidaps.utils.rx.AapsSchedulers
|
||||||
import io.reactivex.disposables.CompositeDisposable
|
import io.reactivex.disposables.CompositeDisposable
|
||||||
import org.json.JSONArray
|
import org.json.JSONArray
|
||||||
import org.json.JSONException
|
import org.json.JSONException
|
||||||
|
@ -29,6 +29,7 @@ class OpenAPSAMAFragment : DaggerFragment() {
|
||||||
private var disposable: CompositeDisposable = CompositeDisposable()
|
private var disposable: CompositeDisposable = CompositeDisposable()
|
||||||
|
|
||||||
@Inject lateinit var aapsLogger: AAPSLogger
|
@Inject lateinit var aapsLogger: AAPSLogger
|
||||||
|
@Inject lateinit var aapsSchedulers: AapsSchedulers
|
||||||
@Inject lateinit var rxBus: RxBusWrapper
|
@Inject lateinit var rxBus: RxBusWrapper
|
||||||
@Inject lateinit var resourceHelper: ResourceHelper
|
@Inject lateinit var resourceHelper: ResourceHelper
|
||||||
@Inject lateinit var fabricPrivacy: FabricPrivacy
|
@Inject lateinit var fabricPrivacy: FabricPrivacy
|
||||||
|
@ -61,16 +62,16 @@ class OpenAPSAMAFragment : DaggerFragment() {
|
||||||
|
|
||||||
disposable += rxBus
|
disposable += rxBus
|
||||||
.toObservable(EventOpenAPSUpdateGui::class.java)
|
.toObservable(EventOpenAPSUpdateGui::class.java)
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(aapsSchedulers.main)
|
||||||
.subscribe({
|
.subscribe({
|
||||||
updateGUI()
|
updateGUI()
|
||||||
}, { fabricPrivacy.logException(it) })
|
}, fabricPrivacy::logException)
|
||||||
disposable += rxBus
|
disposable += rxBus
|
||||||
.toObservable(EventOpenAPSUpdateResultGui::class.java)
|
.toObservable(EventOpenAPSUpdateResultGui::class.java)
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(aapsSchedulers.main)
|
||||||
.subscribe({
|
.subscribe({
|
||||||
updateResultGUI(it.text)
|
updateResultGUI(it.text)
|
||||||
}, { fabricPrivacy.logException(it) })
|
}, fabricPrivacy::logException)
|
||||||
|
|
||||||
updateGUI()
|
updateGUI()
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,16 +19,18 @@ import info.nightscout.androidaps.utils.FabricPrivacy
|
||||||
import info.nightscout.androidaps.utils.JSONFormatter
|
import info.nightscout.androidaps.utils.JSONFormatter
|
||||||
import info.nightscout.androidaps.utils.extensions.plusAssign
|
import info.nightscout.androidaps.utils.extensions.plusAssign
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
import info.nightscout.androidaps.utils.rx.AapsSchedulers
|
||||||
import io.reactivex.disposables.CompositeDisposable
|
import io.reactivex.disposables.CompositeDisposable
|
||||||
import org.json.JSONArray
|
import org.json.JSONArray
|
||||||
import org.json.JSONException
|
import org.json.JSONException
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class OpenAPSSMBFragment : DaggerFragment() {
|
class OpenAPSSMBFragment : DaggerFragment() {
|
||||||
|
|
||||||
private var disposable: CompositeDisposable = CompositeDisposable()
|
private var disposable: CompositeDisposable = CompositeDisposable()
|
||||||
|
|
||||||
@Inject lateinit var aapsLogger: AAPSLogger
|
@Inject lateinit var aapsLogger: AAPSLogger
|
||||||
|
@Inject lateinit var aapsSchedulers: AapsSchedulers
|
||||||
@Inject lateinit var rxBus: RxBusWrapper
|
@Inject lateinit var rxBus: RxBusWrapper
|
||||||
@Inject lateinit var resourceHelper: ResourceHelper
|
@Inject lateinit var resourceHelper: ResourceHelper
|
||||||
@Inject lateinit var fabricPrivacy: FabricPrivacy
|
@Inject lateinit var fabricPrivacy: FabricPrivacy
|
||||||
|
@ -60,16 +62,16 @@ class OpenAPSSMBFragment : DaggerFragment() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
disposable += rxBus
|
disposable += rxBus
|
||||||
.toObservable(EventOpenAPSUpdateGui::class.java)
|
.toObservable(EventOpenAPSUpdateGui::class.java)
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(aapsSchedulers.main)
|
||||||
.subscribe({
|
.subscribe({
|
||||||
updateGUI()
|
updateGUI()
|
||||||
}, { fabricPrivacy.logException(it) })
|
}, fabricPrivacy::logException)
|
||||||
disposable += rxBus
|
disposable += rxBus
|
||||||
.toObservable(EventOpenAPSUpdateResultGui::class.java)
|
.toObservable(EventOpenAPSUpdateResultGui::class.java)
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(aapsSchedulers.main)
|
||||||
.subscribe({
|
.subscribe({
|
||||||
updateResultGUI(it.text)
|
updateResultGUI(it.text)
|
||||||
}, { fabricPrivacy.logException(it) })
|
}, fabricPrivacy::logException)
|
||||||
|
|
||||||
updateGUI()
|
updateGUI()
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,13 +22,14 @@ import info.nightscout.androidaps.utils.extensions.plusAssign
|
||||||
import info.nightscout.androidaps.utils.extensions.toVisibility
|
import info.nightscout.androidaps.utils.extensions.toVisibility
|
||||||
import info.nightscout.androidaps.utils.protection.ProtectionCheck
|
import info.nightscout.androidaps.utils.protection.ProtectionCheck
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
import info.nightscout.androidaps.utils.rx.AapsSchedulers
|
||||||
import io.reactivex.disposables.CompositeDisposable
|
import io.reactivex.disposables.CompositeDisposable
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class ConfigBuilderFragment : DaggerFragment() {
|
class ConfigBuilderFragment : DaggerFragment() {
|
||||||
|
|
||||||
|
@Inject lateinit var aapsSchedulers: AapsSchedulers
|
||||||
@Inject lateinit var rxBus: RxBusWrapper
|
@Inject lateinit var rxBus: RxBusWrapper
|
||||||
@Inject lateinit var resourceHelper: ResourceHelper
|
@Inject lateinit var resourceHelper: ResourceHelper
|
||||||
@Inject lateinit var configBuilderPlugin: ConfigBuilderPlugin
|
@Inject lateinit var configBuilderPlugin: ConfigBuilderPlugin
|
||||||
|
@ -77,10 +78,10 @@ class ConfigBuilderFragment : DaggerFragment() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
disposable += rxBus
|
disposable += rxBus
|
||||||
.toObservable(EventConfigBuilderUpdateGui::class.java)
|
.toObservable(EventConfigBuilderUpdateGui::class.java)
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(aapsSchedulers.main)
|
||||||
.subscribe({
|
.subscribe({
|
||||||
for (pluginViewHolder in pluginViewHolders) pluginViewHolder.update()
|
for (pluginViewHolder in pluginViewHolders) pluginViewHolder.update()
|
||||||
}, { fabricPrivacy.logException(it) })
|
}, fabricPrivacy::logException)
|
||||||
updateGUI()
|
updateGUI()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,8 +35,8 @@ import info.nightscout.androidaps.utils.SntpClient
|
||||||
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
|
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
|
||||||
import info.nightscout.androidaps.utils.extensions.plusAssign
|
import info.nightscout.androidaps.utils.extensions.plusAssign
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
|
import info.nightscout.androidaps.utils.rx.AapsSchedulers
|
||||||
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
|
||||||
import io.reactivex.disposables.CompositeDisposable
|
import io.reactivex.disposables.CompositeDisposable
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
@ -44,6 +44,7 @@ class ObjectivesFragment : DaggerFragment() {
|
||||||
|
|
||||||
@Inject lateinit var rxBus: RxBusWrapper
|
@Inject lateinit var rxBus: RxBusWrapper
|
||||||
@Inject lateinit var aapsLogger: AAPSLogger
|
@Inject lateinit var aapsLogger: AAPSLogger
|
||||||
|
@Inject lateinit var aapsSchedulers: AapsSchedulers
|
||||||
@Inject lateinit var sp: SP
|
@Inject lateinit var sp: SP
|
||||||
@Inject lateinit var resourceHelper: ResourceHelper
|
@Inject lateinit var resourceHelper: ResourceHelper
|
||||||
@Inject lateinit var fabricPrivacy: FabricPrivacy
|
@Inject lateinit var fabricPrivacy: FabricPrivacy
|
||||||
|
@ -92,11 +93,10 @@ class ObjectivesFragment : DaggerFragment() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
disposable += rxBus
|
disposable += rxBus
|
||||||
.toObservable(EventObjectivesUpdateGui::class.java)
|
.toObservable(EventObjectivesUpdateGui::class.java)
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(aapsSchedulers.main)
|
||||||
.subscribe({
|
.subscribe({
|
||||||
binding.recyclerview.adapter?.notifyDataSetChanged()
|
binding.recyclerview.adapter?.notifyDataSetChanged()
|
||||||
}, { fabricPrivacy.logException(it) }
|
}, fabricPrivacy::logException)
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Synchronized
|
@Synchronized
|
||||||
|
|
|
@ -36,10 +36,10 @@ import info.nightscout.androidaps.utils.extensions.plusAssign
|
||||||
import info.nightscout.androidaps.utils.extensions.toVisibility
|
import info.nightscout.androidaps.utils.extensions.toVisibility
|
||||||
import info.nightscout.androidaps.utils.protection.ProtectionCheck
|
import info.nightscout.androidaps.utils.protection.ProtectionCheck
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
|
import info.nightscout.androidaps.utils.rx.AapsSchedulers
|
||||||
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||||
import info.nightscout.androidaps.utils.ui.SingleClickButton
|
import info.nightscout.androidaps.utils.ui.SingleClickButton
|
||||||
import info.nightscout.androidaps.utils.ui.UIRunnable
|
import info.nightscout.androidaps.utils.ui.UIRunnable
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
|
||||||
import io.reactivex.disposables.CompositeDisposable
|
import io.reactivex.disposables.CompositeDisposable
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
@ -47,6 +47,7 @@ import javax.inject.Inject
|
||||||
class ActionsFragment : DaggerFragment() {
|
class ActionsFragment : DaggerFragment() {
|
||||||
|
|
||||||
@Inject lateinit var aapsLogger: AAPSLogger
|
@Inject lateinit var aapsLogger: AAPSLogger
|
||||||
|
@Inject lateinit var aapsSchedulers: AapsSchedulers
|
||||||
@Inject lateinit var rxBus: RxBusWrapper
|
@Inject lateinit var rxBus: RxBusWrapper
|
||||||
@Inject lateinit var sp: SP
|
@Inject lateinit var sp: SP
|
||||||
@Inject lateinit var profileFunction: ProfileFunction
|
@Inject lateinit var profileFunction: ProfileFunction
|
||||||
|
@ -223,27 +224,27 @@ class ActionsFragment : DaggerFragment() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
disposable += rxBus
|
disposable += rxBus
|
||||||
.toObservable(EventInitializationChanged::class.java)
|
.toObservable(EventInitializationChanged::class.java)
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(aapsSchedulers.main)
|
||||||
.subscribe({ updateGui() }, fabricPrivacy::logException)
|
.subscribe({ updateGui() }, fabricPrivacy::logException)
|
||||||
disposable += rxBus
|
disposable += rxBus
|
||||||
.toObservable(EventRefreshOverview::class.java)
|
.toObservable(EventRefreshOverview::class.java)
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(aapsSchedulers.main)
|
||||||
.subscribe({ updateGui() }, fabricPrivacy::logException)
|
.subscribe({ updateGui() }, fabricPrivacy::logException)
|
||||||
disposable += rxBus
|
disposable += rxBus
|
||||||
.toObservable(EventExtendedBolusChange::class.java)
|
.toObservable(EventExtendedBolusChange::class.java)
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(aapsSchedulers.main)
|
||||||
.subscribe({ updateGui() }, fabricPrivacy::logException)
|
.subscribe({ updateGui() }, fabricPrivacy::logException)
|
||||||
disposable += rxBus
|
disposable += rxBus
|
||||||
.toObservable(EventTempBasalChange::class.java)
|
.toObservable(EventTempBasalChange::class.java)
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(aapsSchedulers.main)
|
||||||
.subscribe({ updateGui() }, fabricPrivacy::logException)
|
.subscribe({ updateGui() }, fabricPrivacy::logException)
|
||||||
disposable += rxBus
|
disposable += rxBus
|
||||||
.toObservable(EventCustomActionsChanged::class.java)
|
.toObservable(EventCustomActionsChanged::class.java)
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(aapsSchedulers.main)
|
||||||
.subscribe({ updateGui() }, fabricPrivacy::logException)
|
.subscribe({ updateGui() }, fabricPrivacy::logException)
|
||||||
disposable += rxBus
|
disposable += rxBus
|
||||||
.toObservable(EventCareportalEventChange::class.java)
|
.toObservable(EventCareportalEventChange::class.java)
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(aapsSchedulers.main)
|
||||||
.subscribe({ updateGui() }, fabricPrivacy::logException)
|
.subscribe({ updateGui() }, fabricPrivacy::logException)
|
||||||
updateGui()
|
updateGui()
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,13 +35,14 @@ import info.nightscout.androidaps.utils.alertDialogs.OKDialog.showConfirmation
|
||||||
import info.nightscout.androidaps.utils.extensions.plusAssign
|
import info.nightscout.androidaps.utils.extensions.plusAssign
|
||||||
import info.nightscout.androidaps.utils.extensions.toVisibility
|
import info.nightscout.androidaps.utils.extensions.toVisibility
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
import info.nightscout.androidaps.utils.rx.AapsSchedulers
|
||||||
import io.reactivex.disposables.CompositeDisposable
|
import io.reactivex.disposables.CompositeDisposable
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class AutomationFragment : DaggerFragment(), OnStartDragListener {
|
class AutomationFragment : DaggerFragment(), OnStartDragListener {
|
||||||
|
|
||||||
|
@Inject lateinit var aapsSchedulers: AapsSchedulers
|
||||||
@Inject lateinit var resourceHelper: ResourceHelper
|
@Inject lateinit var resourceHelper: ResourceHelper
|
||||||
@Inject lateinit var rxBus: RxBusWrapper
|
@Inject lateinit var rxBus: RxBusWrapper
|
||||||
@Inject lateinit var fabricPrivacy: FabricPrivacy
|
@Inject lateinit var fabricPrivacy: FabricPrivacy
|
||||||
|
@ -93,16 +94,16 @@ class AutomationFragment : DaggerFragment(), OnStartDragListener {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
disposable += rxBus
|
disposable += rxBus
|
||||||
.toObservable(EventAutomationUpdateGui::class.java)
|
.toObservable(EventAutomationUpdateGui::class.java)
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(aapsSchedulers.main)
|
||||||
.subscribe({
|
.subscribe({
|
||||||
updateGui()
|
updateGui()
|
||||||
}, { fabricPrivacy.logException(it) })
|
}, fabricPrivacy::logException)
|
||||||
disposable += rxBus
|
disposable += rxBus
|
||||||
.toObservable(EventAutomationDataChanged::class.java)
|
.toObservable(EventAutomationDataChanged::class.java)
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(aapsSchedulers.main)
|
||||||
.subscribe({
|
.subscribe({
|
||||||
eventListAdapter.notifyDataSetChanged()
|
eventListAdapter.notifyDataSetChanged()
|
||||||
}, { fabricPrivacy.logException(it) })
|
}, fabricPrivacy::logException)
|
||||||
updateGui()
|
updateGui()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,9 +32,9 @@ import info.nightscout.androidaps.utils.FabricPrivacy
|
||||||
import info.nightscout.androidaps.utils.T
|
import info.nightscout.androidaps.utils.T
|
||||||
import info.nightscout.androidaps.utils.extensions.plusAssign
|
import info.nightscout.androidaps.utils.extensions.plusAssign
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
|
import info.nightscout.androidaps.utils.rx.AapsSchedulers
|
||||||
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||||
import io.reactivex.disposables.CompositeDisposable
|
import io.reactivex.disposables.CompositeDisposable
|
||||||
import io.reactivex.schedulers.Schedulers
|
|
||||||
import org.json.JSONArray
|
import org.json.JSONArray
|
||||||
import org.json.JSONException
|
import org.json.JSONException
|
||||||
import org.json.JSONObject
|
import org.json.JSONObject
|
||||||
|
@ -54,6 +54,7 @@ class AutomationPlugin @Inject constructor(
|
||||||
private val rxBus: RxBusWrapper,
|
private val rxBus: RxBusWrapper,
|
||||||
private val constraintChecker: ConstraintChecker,
|
private val constraintChecker: ConstraintChecker,
|
||||||
aapsLogger: AAPSLogger,
|
aapsLogger: AAPSLogger,
|
||||||
|
private val aapsSchedulers: AapsSchedulers,
|
||||||
private val config: Config,
|
private val config: Config,
|
||||||
private val locationServiceHelper: LocationServiceHelper,
|
private val locationServiceHelper: LocationServiceHelper,
|
||||||
private val dateUtil: DateUtil
|
private val dateUtil: DateUtil
|
||||||
|
@ -103,7 +104,7 @@ class AutomationPlugin @Inject constructor(
|
||||||
|
|
||||||
disposable += rxBus
|
disposable += rxBus
|
||||||
.toObservable(EventPreferenceChange::class.java)
|
.toObservable(EventPreferenceChange::class.java)
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(aapsSchedulers.io)
|
||||||
.subscribe({ e ->
|
.subscribe({ e ->
|
||||||
if (e.isChanged(resourceHelper, R.string.key_location)) {
|
if (e.isChanged(resourceHelper, R.string.key_location)) {
|
||||||
locationServiceHelper.stopService(context)
|
locationServiceHelper.stopService(context)
|
||||||
|
@ -112,11 +113,11 @@ class AutomationPlugin @Inject constructor(
|
||||||
}, fabricPrivacy::logException)
|
}, fabricPrivacy::logException)
|
||||||
disposable += rxBus
|
disposable += rxBus
|
||||||
.toObservable(EventAutomationDataChanged::class.java)
|
.toObservable(EventAutomationDataChanged::class.java)
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(aapsSchedulers.io)
|
||||||
.subscribe({ storeToSP() }, fabricPrivacy::logException)
|
.subscribe({ storeToSP() }, fabricPrivacy::logException)
|
||||||
disposable += rxBus
|
disposable += rxBus
|
||||||
.toObservable(EventLocationChange::class.java)
|
.toObservable(EventLocationChange::class.java)
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(aapsSchedulers.io)
|
||||||
.subscribe({ e ->
|
.subscribe({ e ->
|
||||||
e?.let {
|
e?.let {
|
||||||
aapsLogger.debug(LTag.AUTOMATION, "Grabbed location: $it.location.latitude $it.location.longitude Provider: $it.location.provider")
|
aapsLogger.debug(LTag.AUTOMATION, "Grabbed location: $it.location.latitude $it.location.longitude Provider: $it.location.provider")
|
||||||
|
@ -125,19 +126,19 @@ class AutomationPlugin @Inject constructor(
|
||||||
}, fabricPrivacy::logException)
|
}, fabricPrivacy::logException)
|
||||||
disposable += rxBus
|
disposable += rxBus
|
||||||
.toObservable(EventChargingState::class.java)
|
.toObservable(EventChargingState::class.java)
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(aapsSchedulers.io)
|
||||||
.subscribe({ processActions() }, fabricPrivacy::logException)
|
.subscribe({ processActions() }, fabricPrivacy::logException)
|
||||||
disposable += rxBus
|
disposable += rxBus
|
||||||
.toObservable(EventNetworkChange::class.java)
|
.toObservable(EventNetworkChange::class.java)
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(aapsSchedulers.io)
|
||||||
.subscribe({ processActions() }, fabricPrivacy::logException)
|
.subscribe({ processActions() }, fabricPrivacy::logException)
|
||||||
disposable += rxBus
|
disposable += rxBus
|
||||||
.toObservable(EventAutosensCalculationFinished::class.java)
|
.toObservable(EventAutosensCalculationFinished::class.java)
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(aapsSchedulers.io)
|
||||||
.subscribe({ processActions() }, fabricPrivacy::logException)
|
.subscribe({ processActions() }, fabricPrivacy::logException)
|
||||||
disposable += rxBus
|
disposable += rxBus
|
||||||
.toObservable(EventBTChange::class.java)
|
.toObservable(EventBTChange::class.java)
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(aapsSchedulers.io)
|
||||||
.subscribe({
|
.subscribe({
|
||||||
aapsLogger.debug(LTag.AUTOMATION, "Grabbed new BT event: $it")
|
aapsLogger.debug(LTag.AUTOMATION, "Grabbed new BT event: $it")
|
||||||
btConnects.add(it)
|
btConnects.add(it)
|
||||||
|
|
|
@ -9,7 +9,7 @@ import android.widget.LinearLayout
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import info.nightscout.androidaps.MainApp
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.androidaps.R
|
import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.databinding.AutomationDialogEventBinding
|
import info.nightscout.androidaps.databinding.AutomationDialogEventBinding
|
||||||
import info.nightscout.androidaps.dialogs.DialogFragmentWithDate
|
import info.nightscout.androidaps.dialogs.DialogFragmentWithDate
|
||||||
|
@ -27,14 +27,15 @@ import info.nightscout.androidaps.utils.FabricPrivacy
|
||||||
import info.nightscout.androidaps.utils.ToastUtils
|
import info.nightscout.androidaps.utils.ToastUtils
|
||||||
import info.nightscout.androidaps.utils.extensions.plusAssign
|
import info.nightscout.androidaps.utils.extensions.plusAssign
|
||||||
import info.nightscout.androidaps.utils.extensions.toVisibility
|
import info.nightscout.androidaps.utils.extensions.toVisibility
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
import info.nightscout.androidaps.utils.rx.AapsSchedulers
|
||||||
import io.reactivex.disposables.CompositeDisposable
|
import io.reactivex.disposables.CompositeDisposable
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class EditEventDialog : DialogFragmentWithDate() {
|
class EditEventDialog : DialogFragmentWithDate() {
|
||||||
|
|
||||||
|
@Inject lateinit var aapsSchedulers: AapsSchedulers
|
||||||
@Inject lateinit var rxBus: RxBusWrapper
|
@Inject lateinit var rxBus: RxBusWrapper
|
||||||
@Inject lateinit var mainApp: MainApp
|
@Inject lateinit var injector: HasAndroidInjector
|
||||||
@Inject lateinit var fabricPrivacy: FabricPrivacy
|
@Inject lateinit var fabricPrivacy: FabricPrivacy
|
||||||
@Inject lateinit var automationPlugin: AutomationPlugin
|
@Inject lateinit var automationPlugin: AutomationPlugin
|
||||||
|
|
||||||
|
@ -52,11 +53,11 @@ class EditEventDialog : DialogFragmentWithDate() {
|
||||||
|
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
|
||||||
savedInstanceState: Bundle?): View {
|
savedInstanceState: Bundle?): View {
|
||||||
event = AutomationEvent(mainApp)
|
event = AutomationEvent(injector)
|
||||||
// load data from bundle
|
// load data from bundle
|
||||||
(savedInstanceState ?: arguments)?.let { bundle ->
|
(savedInstanceState ?: arguments)?.let { bundle ->
|
||||||
position = bundle.getInt("position", -1)
|
position = bundle.getInt("position", -1)
|
||||||
bundle.getString("event")?.let { event = AutomationEvent(mainApp).fromJSON(it) }
|
bundle.getString("event")?.let { event = AutomationEvent(injector).fromJSON(it) }
|
||||||
}
|
}
|
||||||
|
|
||||||
onCreateViewGeneral()
|
onCreateViewGeneral()
|
||||||
|
@ -94,28 +95,28 @@ class EditEventDialog : DialogFragmentWithDate() {
|
||||||
|
|
||||||
disposable += rxBus
|
disposable += rxBus
|
||||||
.toObservable(EventAutomationUpdateGui::class.java)
|
.toObservable(EventAutomationUpdateGui::class.java)
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(aapsSchedulers.main)
|
||||||
.subscribe({
|
.subscribe({
|
||||||
actionListAdapter?.notifyDataSetChanged()
|
actionListAdapter?.notifyDataSetChanged()
|
||||||
showPreconditions()
|
showPreconditions()
|
||||||
}, fabricPrivacy::logException)
|
}, fabricPrivacy::logException)
|
||||||
disposable += rxBus
|
disposable += rxBus
|
||||||
.toObservable(EventAutomationAddAction::class.java)
|
.toObservable(EventAutomationAddAction::class.java)
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(aapsSchedulers.main)
|
||||||
.subscribe({
|
.subscribe({
|
||||||
event.addAction(it.action)
|
event.addAction(it.action)
|
||||||
actionListAdapter?.notifyDataSetChanged()
|
actionListAdapter?.notifyDataSetChanged()
|
||||||
}, fabricPrivacy::logException)
|
}, fabricPrivacy::logException)
|
||||||
disposable += rxBus
|
disposable += rxBus
|
||||||
.toObservable(EventAutomationUpdateTrigger::class.java)
|
.toObservable(EventAutomationUpdateTrigger::class.java)
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(aapsSchedulers.main)
|
||||||
.subscribe({
|
.subscribe({
|
||||||
event.trigger = it.trigger
|
event.trigger = it.trigger
|
||||||
binding.triggerDescription.text = event.trigger.friendlyDescription()
|
binding.triggerDescription.text = event.trigger.friendlyDescription()
|
||||||
}, fabricPrivacy::logException)
|
}, fabricPrivacy::logException)
|
||||||
disposable += rxBus
|
disposable += rxBus
|
||||||
.toObservable(EventAutomationUpdateAction::class.java)
|
.toObservable(EventAutomationUpdateAction::class.java)
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(aapsSchedulers.main)
|
||||||
.subscribe({
|
.subscribe({
|
||||||
event.actions[it.position] = it.action
|
event.actions[it.position] = it.action
|
||||||
actionListAdapter?.notifyDataSetChanged()
|
actionListAdapter?.notifyDataSetChanged()
|
||||||
|
|
|
@ -4,7 +4,7 @@ import android.os.Bundle
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import info.nightscout.androidaps.MainApp
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.androidaps.databinding.AutomationDialogEditTriggerBinding
|
import info.nightscout.androidaps.databinding.AutomationDialogEditTriggerBinding
|
||||||
import info.nightscout.androidaps.dialogs.DialogFragmentWithDate
|
import info.nightscout.androidaps.dialogs.DialogFragmentWithDate
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
|
@ -17,15 +17,16 @@ import info.nightscout.androidaps.plugins.general.automation.triggers.TriggerCon
|
||||||
import info.nightscout.androidaps.plugins.general.automation.triggers.TriggerDummy
|
import info.nightscout.androidaps.plugins.general.automation.triggers.TriggerDummy
|
||||||
import info.nightscout.androidaps.utils.FabricPrivacy
|
import info.nightscout.androidaps.utils.FabricPrivacy
|
||||||
import info.nightscout.androidaps.utils.extensions.plusAssign
|
import info.nightscout.androidaps.utils.extensions.plusAssign
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
import info.nightscout.androidaps.utils.rx.AapsSchedulers
|
||||||
import io.reactivex.disposables.CompositeDisposable
|
import io.reactivex.disposables.CompositeDisposable
|
||||||
import org.json.JSONObject
|
import org.json.JSONObject
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class EditTriggerDialog : DialogFragmentWithDate() {
|
class EditTriggerDialog : DialogFragmentWithDate() {
|
||||||
|
|
||||||
|
@Inject lateinit var aapsSchedulers: AapsSchedulers
|
||||||
@Inject lateinit var rxBus: RxBusWrapper
|
@Inject lateinit var rxBus: RxBusWrapper
|
||||||
@Inject lateinit var mainApp: MainApp
|
@Inject lateinit var injector: HasAndroidInjector
|
||||||
@Inject lateinit var fabricPrivacy: FabricPrivacy
|
@Inject lateinit var fabricPrivacy: FabricPrivacy
|
||||||
|
|
||||||
private var disposable: CompositeDisposable = CompositeDisposable()
|
private var disposable: CompositeDisposable = CompositeDisposable()
|
||||||
|
@ -42,7 +43,7 @@ class EditTriggerDialog : DialogFragmentWithDate() {
|
||||||
savedInstanceState: Bundle?): View {
|
savedInstanceState: Bundle?): View {
|
||||||
// load data from bundle
|
// load data from bundle
|
||||||
(savedInstanceState ?: arguments)?.let { bundle ->
|
(savedInstanceState ?: arguments)?.let { bundle ->
|
||||||
bundle.getString("trigger")?.let { triggers = TriggerDummy(mainApp).instantiate(JSONObject(it)) }
|
bundle.getString("trigger")?.let { triggers = TriggerDummy(injector).instantiate(JSONObject(it)) }
|
||||||
}
|
}
|
||||||
|
|
||||||
onCreateViewGeneral()
|
onCreateViewGeneral()
|
||||||
|
@ -55,28 +56,28 @@ class EditTriggerDialog : DialogFragmentWithDate() {
|
||||||
|
|
||||||
disposable += rxBus
|
disposable += rxBus
|
||||||
.toObservable(EventTriggerChanged::class.java)
|
.toObservable(EventTriggerChanged::class.java)
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(aapsSchedulers.main)
|
||||||
.subscribe({
|
.subscribe({
|
||||||
binding.layoutTrigger.removeAllViews()
|
binding.layoutTrigger.removeAllViews()
|
||||||
triggers?.generateDialog(binding.layoutTrigger)
|
triggers?.generateDialog(binding.layoutTrigger)
|
||||||
}, { fabricPrivacy.logException(it) })
|
}, fabricPrivacy::logException)
|
||||||
disposable += rxBus
|
disposable += rxBus
|
||||||
.toObservable(EventTriggerRemove::class.java)
|
.toObservable(EventTriggerRemove::class.java)
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(aapsSchedulers.main)
|
||||||
.subscribe({
|
.subscribe({
|
||||||
findParent(triggers, it.trigger)?.list?.remove(it.trigger)
|
findParent(triggers, it.trigger)?.list?.remove(it.trigger)
|
||||||
binding.layoutTrigger.removeAllViews()
|
binding.layoutTrigger.removeAllViews()
|
||||||
triggers?.generateDialog(binding.layoutTrigger)
|
triggers?.generateDialog(binding.layoutTrigger)
|
||||||
}, { fabricPrivacy.logException(it) })
|
}, fabricPrivacy::logException)
|
||||||
|
|
||||||
disposable += rxBus
|
disposable += rxBus
|
||||||
.toObservable(EventTriggerClone::class.java)
|
.toObservable(EventTriggerClone::class.java)
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(aapsSchedulers.main)
|
||||||
.subscribe({
|
.subscribe({
|
||||||
findParent(triggers, it.trigger)?.list?.add(it.trigger.duplicate())
|
findParent(triggers, it.trigger)?.list?.add(it.trigger.duplicate())
|
||||||
binding.layoutTrigger.removeAllViews()
|
binding.layoutTrigger.removeAllViews()
|
||||||
triggers?.generateDialog(binding.layoutTrigger)
|
triggers?.generateDialog(binding.layoutTrigger)
|
||||||
}, { fabricPrivacy.logException(it) })
|
}, fabricPrivacy::logException)
|
||||||
|
|
||||||
// display root trigger
|
// display root trigger
|
||||||
triggers?.generateDialog(binding.layoutTrigger)
|
triggers?.generateDialog(binding.layoutTrigger)
|
||||||
|
|
|
@ -30,8 +30,8 @@ import info.nightscout.androidaps.services.Intents
|
||||||
import info.nightscout.androidaps.utils.DefaultValueHelper
|
import info.nightscout.androidaps.utils.DefaultValueHelper
|
||||||
import info.nightscout.androidaps.utils.FabricPrivacy
|
import info.nightscout.androidaps.utils.FabricPrivacy
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
|
import info.nightscout.androidaps.utils.rx.AapsSchedulers
|
||||||
import io.reactivex.disposables.CompositeDisposable
|
import io.reactivex.disposables.CompositeDisposable
|
||||||
import io.reactivex.schedulers.Schedulers
|
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
import javax.inject.Singleton
|
import javax.inject.Singleton
|
||||||
|
|
||||||
|
@ -40,6 +40,7 @@ class DataBroadcastPlugin @Inject constructor(
|
||||||
injector: HasAndroidInjector,
|
injector: HasAndroidInjector,
|
||||||
aapsLogger: AAPSLogger,
|
aapsLogger: AAPSLogger,
|
||||||
resourceHelper: ResourceHelper,
|
resourceHelper: ResourceHelper,
|
||||||
|
private val aapsSchedulers: AapsSchedulers,
|
||||||
private val context: Context,
|
private val context: Context,
|
||||||
private val fabricPrivacy: FabricPrivacy,
|
private val fabricPrivacy: FabricPrivacy,
|
||||||
private val rxBus: RxBusWrapper,
|
private val rxBus: RxBusWrapper,
|
||||||
|
@ -67,32 +68,32 @@ class DataBroadcastPlugin @Inject constructor(
|
||||||
super.onStart()
|
super.onStart()
|
||||||
disposable.add(rxBus
|
disposable.add(rxBus
|
||||||
.toObservable(EventOpenAPSUpdateGui::class.java)
|
.toObservable(EventOpenAPSUpdateGui::class.java)
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(aapsSchedulers.io)
|
||||||
.subscribe({ sendData(it) }) { fabricPrivacy.logException(it) })
|
.subscribe({ sendData(it) }, fabricPrivacy::logException))
|
||||||
disposable.add(rxBus
|
disposable.add(rxBus
|
||||||
.toObservable(EventExtendedBolusChange::class.java)
|
.toObservable(EventExtendedBolusChange::class.java)
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(aapsSchedulers.io)
|
||||||
.subscribe({ sendData(it) }) { fabricPrivacy.logException(it) })
|
.subscribe({ sendData(it) }, fabricPrivacy::logException))
|
||||||
disposable.add(rxBus
|
disposable.add(rxBus
|
||||||
.toObservable(EventTempBasalChange::class.java)
|
.toObservable(EventTempBasalChange::class.java)
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(aapsSchedulers.io)
|
||||||
.subscribe({ sendData(it) }) { fabricPrivacy.logException(it) })
|
.subscribe({ sendData(it) }, fabricPrivacy::logException))
|
||||||
disposable.add(rxBus
|
disposable.add(rxBus
|
||||||
.toObservable(EventTreatmentChange::class.java)
|
.toObservable(EventTreatmentChange::class.java)
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(aapsSchedulers.io)
|
||||||
.subscribe({ sendData(it) }) { fabricPrivacy.logException(it) })
|
.subscribe({ sendData(it) }, fabricPrivacy::logException))
|
||||||
disposable.add(rxBus
|
disposable.add(rxBus
|
||||||
.toObservable(EventNewBasalProfile::class.java)
|
.toObservable(EventNewBasalProfile::class.java)
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(aapsSchedulers.io)
|
||||||
.subscribe({ sendData(it) }) { fabricPrivacy.logException(it) })
|
.subscribe({ sendData(it) }, fabricPrivacy::logException))
|
||||||
disposable.add(rxBus
|
disposable.add(rxBus
|
||||||
.toObservable(EventAutosensCalculationFinished::class.java)
|
.toObservable(EventAutosensCalculationFinished::class.java)
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(aapsSchedulers.io)
|
||||||
.subscribe({ sendData(it) }) { fabricPrivacy.logException(it) })
|
.subscribe({ sendData(it) }, fabricPrivacy::logException))
|
||||||
disposable.add(rxBus
|
disposable.add(rxBus
|
||||||
.toObservable(EventOverviewBolusProgress::class.java)
|
.toObservable(EventOverviewBolusProgress::class.java)
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(aapsSchedulers.io)
|
||||||
.subscribe({ sendData(it) }) { fabricPrivacy.logException(it) })
|
.subscribe({ sendData(it) }, fabricPrivacy::logException))
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onStop() {
|
override fun onStop() {
|
||||||
|
|
|
@ -24,7 +24,7 @@ import info.nightscout.androidaps.plugins.general.nsclient.NSUpload
|
||||||
import info.nightscout.androidaps.utils.FabricPrivacy
|
import info.nightscout.androidaps.utils.FabricPrivacy
|
||||||
import info.nightscout.androidaps.utils.alertDialogs.OKDialog.showConfirmation
|
import info.nightscout.androidaps.utils.alertDialogs.OKDialog.showConfirmation
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
import info.nightscout.androidaps.utils.rx.AapsSchedulers
|
||||||
import io.reactivex.disposables.CompositeDisposable
|
import io.reactivex.disposables.CompositeDisposable
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
@ -32,6 +32,7 @@ import kotlin.collections.ArrayList
|
||||||
|
|
||||||
class FoodFragment : DaggerFragment() {
|
class FoodFragment : DaggerFragment() {
|
||||||
|
|
||||||
|
@Inject lateinit var aapsSchedulers: AapsSchedulers
|
||||||
@Inject lateinit var rxBus: RxBusWrapper
|
@Inject lateinit var rxBus: RxBusWrapper
|
||||||
@Inject lateinit var resourceHelper: ResourceHelper
|
@Inject lateinit var resourceHelper: ResourceHelper
|
||||||
@Inject lateinit var fabricPrivacy: FabricPrivacy
|
@Inject lateinit var fabricPrivacy: FabricPrivacy
|
||||||
|
@ -106,8 +107,8 @@ class FoodFragment : DaggerFragment() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
disposable.add(rxBus
|
disposable.add(rxBus
|
||||||
.toObservable(EventFoodDatabaseChanged::class.java)
|
.toObservable(EventFoodDatabaseChanged::class.java)
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(aapsSchedulers.main)
|
||||||
.subscribe({ updateGui() }) { fabricPrivacy.logException(it) }
|
.subscribe({ updateGui() }, fabricPrivacy::logException)
|
||||||
)
|
)
|
||||||
updateGui()
|
updateGui()
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,8 +36,8 @@ import info.nightscout.androidaps.logging.AAPSLogger;
|
||||||
import info.nightscout.androidaps.logging.LTag;
|
import info.nightscout.androidaps.logging.LTag;
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper;
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper;
|
||||||
import info.nightscout.androidaps.utils.FabricPrivacy;
|
import info.nightscout.androidaps.utils.FabricPrivacy;
|
||||||
|
import info.nightscout.androidaps.utils.rx.AapsSchedulers;
|
||||||
import io.reactivex.disposables.CompositeDisposable;
|
import io.reactivex.disposables.CompositeDisposable;
|
||||||
import io.reactivex.schedulers.Schedulers;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by mike on 24.09.2017.
|
* Created by mike on 24.09.2017.
|
||||||
|
@ -47,6 +47,7 @@ public class FoodService extends OrmLiteBaseService<DatabaseHelper> {
|
||||||
@Inject AAPSLogger aapsLogger;
|
@Inject AAPSLogger aapsLogger;
|
||||||
@Inject RxBusWrapper rxBus;
|
@Inject RxBusWrapper rxBus;
|
||||||
@Inject FabricPrivacy fabricPrivacy;
|
@Inject FabricPrivacy fabricPrivacy;
|
||||||
|
@Inject AapsSchedulers aapsSchedulers;
|
||||||
|
|
||||||
private final CompositeDisposable disposable = new CompositeDisposable();
|
private final CompositeDisposable disposable = new CompositeDisposable();
|
||||||
|
|
||||||
|
@ -59,7 +60,7 @@ public class FoodService extends OrmLiteBaseService<DatabaseHelper> {
|
||||||
dbInitialize();
|
dbInitialize();
|
||||||
disposable.add(rxBus
|
disposable.add(rxBus
|
||||||
.toObservable(EventNsFood.class)
|
.toObservable(EventNsFood.class)
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(aapsSchedulers.getIo())
|
||||||
.subscribe(event -> {
|
.subscribe(event -> {
|
||||||
int mode = event.getMode();
|
int mode = event.getMode();
|
||||||
JSONArray array = event.getFoods();
|
JSONArray array = event.getFoods();
|
||||||
|
|
|
@ -3,7 +3,6 @@ package info.nightscout.androidaps.plugins.general.nsclient;
|
||||||
|
|
||||||
import android.graphics.Paint;
|
import android.graphics.Paint;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.text.Html;
|
|
||||||
import android.text.Spanned;
|
import android.text.Spanned;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
@ -25,8 +24,8 @@ import info.nightscout.androidaps.utils.FabricPrivacy;
|
||||||
import info.nightscout.androidaps.utils.HtmlHelper;
|
import info.nightscout.androidaps.utils.HtmlHelper;
|
||||||
import info.nightscout.androidaps.utils.alertDialogs.OKDialog;
|
import info.nightscout.androidaps.utils.alertDialogs.OKDialog;
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper;
|
import info.nightscout.androidaps.utils.resources.ResourceHelper;
|
||||||
|
import info.nightscout.androidaps.utils.rx.AapsSchedulers;
|
||||||
import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
|
||||||
import io.reactivex.disposables.CompositeDisposable;
|
import io.reactivex.disposables.CompositeDisposable;
|
||||||
|
|
||||||
public class NSClientFragment extends DaggerFragment implements View.OnClickListener, CompoundButton.OnCheckedChangeListener {
|
public class NSClientFragment extends DaggerFragment implements View.OnClickListener, CompoundButton.OnCheckedChangeListener {
|
||||||
|
@ -36,6 +35,7 @@ public class NSClientFragment extends DaggerFragment implements View.OnClickList
|
||||||
@Inject RxBusWrapper rxBus;
|
@Inject RxBusWrapper rxBus;
|
||||||
@Inject UploadQueue uploadQueue;
|
@Inject UploadQueue uploadQueue;
|
||||||
@Inject FabricPrivacy fabricPrivacy;
|
@Inject FabricPrivacy fabricPrivacy;
|
||||||
|
@Inject AapsSchedulers aapsSchedulers;
|
||||||
|
|
||||||
private final CompositeDisposable disposable = new CompositeDisposable();
|
private final CompositeDisposable disposable = new CompositeDisposable();
|
||||||
|
|
||||||
|
@ -93,7 +93,7 @@ public class NSClientFragment extends DaggerFragment implements View.OnClickList
|
||||||
super.onResume();
|
super.onResume();
|
||||||
disposable.add(rxBus
|
disposable.add(rxBus
|
||||||
.toObservable(EventNSClientUpdateGUI.class)
|
.toObservable(EventNSClientUpdateGUI.class)
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(aapsSchedulers.getMain())
|
||||||
.subscribe(event -> updateGui(), fabricPrivacy::logException)
|
.subscribe(event -> updateGui(), fabricPrivacy::logException)
|
||||||
);
|
);
|
||||||
updateGui();
|
updateGui();
|
||||||
|
|
|
@ -59,9 +59,9 @@ import info.nightscout.androidaps.utils.JsonHelper;
|
||||||
import info.nightscout.androidaps.utils.ToastUtils;
|
import info.nightscout.androidaps.utils.ToastUtils;
|
||||||
import info.nightscout.androidaps.utils.buildHelper.BuildHelper;
|
import info.nightscout.androidaps.utils.buildHelper.BuildHelper;
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper;
|
import info.nightscout.androidaps.utils.resources.ResourceHelper;
|
||||||
|
import info.nightscout.androidaps.utils.rx.AapsSchedulers;
|
||||||
import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
||||||
import io.reactivex.disposables.CompositeDisposable;
|
import io.reactivex.disposables.CompositeDisposable;
|
||||||
import io.reactivex.schedulers.Schedulers;
|
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
public class NSClientPlugin extends PluginBase {
|
public class NSClientPlugin extends PluginBase {
|
||||||
|
@ -71,6 +71,7 @@ public class NSClientPlugin extends PluginBase {
|
||||||
private final RxBusWrapper rxBus;
|
private final RxBusWrapper rxBus;
|
||||||
private final ResourceHelper resourceHelper;
|
private final ResourceHelper resourceHelper;
|
||||||
private final Context context;
|
private final Context context;
|
||||||
|
private final AapsSchedulers aapsSchedulers;
|
||||||
private final FabricPrivacy fabricPrivacy;
|
private final FabricPrivacy fabricPrivacy;
|
||||||
private final SP sp;
|
private final SP sp;
|
||||||
private final Config config;
|
private final Config config;
|
||||||
|
@ -96,6 +97,7 @@ public class NSClientPlugin extends PluginBase {
|
||||||
public NSClientPlugin(
|
public NSClientPlugin(
|
||||||
HasAndroidInjector injector,
|
HasAndroidInjector injector,
|
||||||
AAPSLogger aapsLogger,
|
AAPSLogger aapsLogger,
|
||||||
|
AapsSchedulers aapsSchedulers,
|
||||||
RxBusWrapper rxBus,
|
RxBusWrapper rxBus,
|
||||||
ResourceHelper resourceHelper,
|
ResourceHelper resourceHelper,
|
||||||
Context context,
|
Context context,
|
||||||
|
@ -119,6 +121,7 @@ public class NSClientPlugin extends PluginBase {
|
||||||
);
|
);
|
||||||
|
|
||||||
this.aapsLogger = aapsLogger;
|
this.aapsLogger = aapsLogger;
|
||||||
|
this.aapsSchedulers = aapsSchedulers;
|
||||||
this.rxBus = rxBus;
|
this.rxBus = rxBus;
|
||||||
this.resourceHelper = resourceHelper;
|
this.resourceHelper = resourceHelper;
|
||||||
this.context = context;
|
this.context = context;
|
||||||
|
@ -158,7 +161,7 @@ public class NSClientPlugin extends PluginBase {
|
||||||
nsClientReceiverDelegate.grabReceiversState();
|
nsClientReceiverDelegate.grabReceiversState();
|
||||||
disposable.add(rxBus
|
disposable.add(rxBus
|
||||||
.toObservable(EventNSClientStatus.class)
|
.toObservable(EventNSClientStatus.class)
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(aapsSchedulers.getIo())
|
||||||
.subscribe(event -> {
|
.subscribe(event -> {
|
||||||
status = event.getStatus(resourceHelper);
|
status = event.getStatus(resourceHelper);
|
||||||
rxBus.send(new EventNSClientUpdateGUI());
|
rxBus.send(new EventNSClientUpdateGUI());
|
||||||
|
@ -166,17 +169,17 @@ public class NSClientPlugin extends PluginBase {
|
||||||
);
|
);
|
||||||
disposable.add(rxBus
|
disposable.add(rxBus
|
||||||
.toObservable(EventNetworkChange.class)
|
.toObservable(EventNetworkChange.class)
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(aapsSchedulers.getIo())
|
||||||
.subscribe(event -> nsClientReceiverDelegate.onStatusEvent(event), fabricPrivacy::logException)
|
.subscribe(event -> nsClientReceiverDelegate.onStatusEvent(event), fabricPrivacy::logException)
|
||||||
);
|
);
|
||||||
disposable.add(rxBus
|
disposable.add(rxBus
|
||||||
.toObservable(EventPreferenceChange.class)
|
.toObservable(EventPreferenceChange.class)
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(aapsSchedulers.getIo())
|
||||||
.subscribe(event -> nsClientReceiverDelegate.onStatusEvent(event), fabricPrivacy::logException)
|
.subscribe(event -> nsClientReceiverDelegate.onStatusEvent(event), fabricPrivacy::logException)
|
||||||
);
|
);
|
||||||
disposable.add(rxBus
|
disposable.add(rxBus
|
||||||
.toObservable(EventAppExit.class)
|
.toObservable(EventAppExit.class)
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(aapsSchedulers.getIo())
|
||||||
.subscribe(event -> {
|
.subscribe(event -> {
|
||||||
if (nsClientService != null) {
|
if (nsClientService != null) {
|
||||||
context.unbindService(mConnection);
|
context.unbindService(mConnection);
|
||||||
|
@ -185,7 +188,7 @@ public class NSClientPlugin extends PluginBase {
|
||||||
);
|
);
|
||||||
disposable.add(rxBus
|
disposable.add(rxBus
|
||||||
.toObservable(EventNSClientNewLog.class)
|
.toObservable(EventNSClientNewLog.class)
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(aapsSchedulers.getIo())
|
||||||
.subscribe(event -> {
|
.subscribe(event -> {
|
||||||
addToLog(event);
|
addToLog(event);
|
||||||
aapsLogger.debug(LTag.NSCLIENT, event.getAction() + " " + event.getLogText());
|
aapsLogger.debug(LTag.NSCLIENT, event.getAction() + " " + event.getLogText());
|
||||||
|
@ -193,12 +196,12 @@ public class NSClientPlugin extends PluginBase {
|
||||||
);
|
);
|
||||||
disposable.add(rxBus
|
disposable.add(rxBus
|
||||||
.toObservable(EventChargingState.class)
|
.toObservable(EventChargingState.class)
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(aapsSchedulers.getIo())
|
||||||
.subscribe(event -> nsClientReceiverDelegate.onStatusEvent(event), fabricPrivacy::logException)
|
.subscribe(event -> nsClientReceiverDelegate.onStatusEvent(event), fabricPrivacy::logException)
|
||||||
);
|
);
|
||||||
disposable.add(rxBus
|
disposable.add(rxBus
|
||||||
.toObservable(EventNSClientResend.class)
|
.toObservable(EventNSClientResend.class)
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(aapsSchedulers.getIo())
|
||||||
.subscribe(event -> resend(event.getReason()), fabricPrivacy::logException)
|
.subscribe(event -> resend(event.getReason()), fabricPrivacy::logException)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,9 +68,9 @@ import info.nightscout.androidaps.utils.JsonHelper;
|
||||||
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.resources.ResourceHelper;
|
import info.nightscout.androidaps.utils.resources.ResourceHelper;
|
||||||
|
import info.nightscout.androidaps.utils.rx.AapsSchedulers;
|
||||||
import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
||||||
import io.reactivex.disposables.CompositeDisposable;
|
import io.reactivex.disposables.CompositeDisposable;
|
||||||
import io.reactivex.schedulers.Schedulers;
|
|
||||||
import io.socket.client.IO;
|
import io.socket.client.IO;
|
||||||
import io.socket.client.Socket;
|
import io.socket.client.Socket;
|
||||||
import io.socket.emitter.Emitter;
|
import io.socket.emitter.Emitter;
|
||||||
|
@ -78,6 +78,7 @@ import io.socket.emitter.Emitter;
|
||||||
public class NSClientService extends DaggerService {
|
public class NSClientService extends DaggerService {
|
||||||
@Inject HasAndroidInjector injector;
|
@Inject HasAndroidInjector injector;
|
||||||
@Inject AAPSLogger aapsLogger;
|
@Inject AAPSLogger aapsLogger;
|
||||||
|
@Inject AapsSchedulers aapsSchedulers;
|
||||||
@Inject NSSettingsStatus nsSettingsStatus;
|
@Inject NSSettingsStatus nsSettingsStatus;
|
||||||
@Inject NSDeviceStatus nsDeviceStatus;
|
@Inject NSDeviceStatus nsDeviceStatus;
|
||||||
@Inject DatabaseHelperInterface databaseHelper;
|
@Inject DatabaseHelperInterface databaseHelper;
|
||||||
|
@ -147,7 +148,7 @@ public class NSClientService extends DaggerService {
|
||||||
|
|
||||||
disposable.add(rxBus
|
disposable.add(rxBus
|
||||||
.toObservable(EventConfigBuilderChange.class)
|
.toObservable(EventConfigBuilderChange.class)
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(aapsSchedulers.getIo())
|
||||||
.subscribe(event -> {
|
.subscribe(event -> {
|
||||||
if (nsEnabled != nsClientPlugin.isEnabled(PluginType.GENERAL)) {
|
if (nsEnabled != nsClientPlugin.isEnabled(PluginType.GENERAL)) {
|
||||||
latestDateInReceivedData = 0;
|
latestDateInReceivedData = 0;
|
||||||
|
@ -158,7 +159,7 @@ public class NSClientService extends DaggerService {
|
||||||
);
|
);
|
||||||
disposable.add(rxBus
|
disposable.add(rxBus
|
||||||
.toObservable(EventPreferenceChange.class)
|
.toObservable(EventPreferenceChange.class)
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(aapsSchedulers.getIo())
|
||||||
.subscribe(event -> {
|
.subscribe(event -> {
|
||||||
if (event.isChanged(resourceHelper, R.string.key_nsclientinternal_url) ||
|
if (event.isChanged(resourceHelper, R.string.key_nsclientinternal_url) ||
|
||||||
event.isChanged(resourceHelper, R.string.key_nsclientinternal_api_secret) ||
|
event.isChanged(resourceHelper, R.string.key_nsclientinternal_api_secret) ||
|
||||||
|
@ -172,7 +173,7 @@ public class NSClientService extends DaggerService {
|
||||||
);
|
);
|
||||||
disposable.add(rxBus
|
disposable.add(rxBus
|
||||||
.toObservable(EventAppExit.class)
|
.toObservable(EventAppExit.class)
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(aapsSchedulers.getIo())
|
||||||
.subscribe(event -> {
|
.subscribe(event -> {
|
||||||
aapsLogger.debug(LTag.NSCLIENT, "EventAppExit received");
|
aapsLogger.debug(LTag.NSCLIENT, "EventAppExit received");
|
||||||
destroy();
|
destroy();
|
||||||
|
@ -181,7 +182,7 @@ public class NSClientService extends DaggerService {
|
||||||
);
|
);
|
||||||
disposable.add(rxBus
|
disposable.add(rxBus
|
||||||
.toObservable(EventNSClientRestart.class)
|
.toObservable(EventNSClientRestart.class)
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(aapsSchedulers.getIo())
|
||||||
.subscribe(event -> {
|
.subscribe(event -> {
|
||||||
latestDateInReceivedData = 0;
|
latestDateInReceivedData = 0;
|
||||||
restart();
|
restart();
|
||||||
|
@ -189,17 +190,17 @@ public class NSClientService extends DaggerService {
|
||||||
);
|
);
|
||||||
disposable.add(rxBus
|
disposable.add(rxBus
|
||||||
.toObservable(NSAuthAck.class)
|
.toObservable(NSAuthAck.class)
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(aapsSchedulers.getIo())
|
||||||
.subscribe(this::processAuthAck, fabricPrivacy::logException)
|
.subscribe(this::processAuthAck, fabricPrivacy::logException)
|
||||||
);
|
);
|
||||||
disposable.add(rxBus
|
disposable.add(rxBus
|
||||||
.toObservable(NSUpdateAck.class)
|
.toObservable(NSUpdateAck.class)
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(aapsSchedulers.getIo())
|
||||||
.subscribe(this::processUpdateAck, fabricPrivacy::logException)
|
.subscribe(this::processUpdateAck, fabricPrivacy::logException)
|
||||||
);
|
);
|
||||||
disposable.add(rxBus
|
disposable.add(rxBus
|
||||||
.toObservable(NSAddAck.class)
|
.toObservable(NSAddAck.class)
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(aapsSchedulers.getIo())
|
||||||
.subscribe(this::processAddAck, fabricPrivacy::logException)
|
.subscribe(this::processAddAck, fabricPrivacy::logException)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,11 +18,10 @@ import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
|
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
|
||||||
import info.nightscout.androidaps.utils.extensions.plusAssign
|
import info.nightscout.androidaps.utils.extensions.plusAssign
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
|
import info.nightscout.androidaps.utils.rx.AapsSchedulers
|
||||||
import io.reactivex.BackpressureStrategy
|
import io.reactivex.BackpressureStrategy
|
||||||
import io.reactivex.Single
|
import io.reactivex.Single
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
|
||||||
import io.reactivex.disposables.CompositeDisposable
|
import io.reactivex.disposables.CompositeDisposable
|
||||||
import io.reactivex.schedulers.Schedulers
|
|
||||||
import java.util.concurrent.TimeUnit
|
import java.util.concurrent.TimeUnit
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
@ -37,25 +36,23 @@ class OpenHumansFragment : DaggerFragment() {
|
||||||
private var queueSizeValue = 0L
|
private var queueSizeValue = 0L
|
||||||
private val compositeDisposable = CompositeDisposable()
|
private val compositeDisposable = CompositeDisposable()
|
||||||
|
|
||||||
@Inject
|
@Inject lateinit var rxBus: RxBusWrapper
|
||||||
lateinit var rxBus: RxBusWrapper
|
@Inject lateinit var openHumansUploader: OpenHumansUploader
|
||||||
|
@Inject lateinit var resourceHelper: ResourceHelper
|
||||||
@Inject
|
@Inject lateinit var aapsSchedulers: AapsSchedulers
|
||||||
lateinit var openHumansUploader: OpenHumansUploader
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
lateinit var resourceHelper: ResourceHelper
|
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
compositeDisposable += Single.fromCallable { MainApp.getDbHelper().ohQueueSize }
|
compositeDisposable += Single.fromCallable { MainApp.getDbHelper().ohQueueSize }
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(aapsSchedulers.io)
|
||||||
.repeatWhen { rxBus.toObservable(UpdateViewEvent::class.java)
|
.repeatWhen {
|
||||||
.cast(Any::class.java)
|
rxBus.toObservable(UpdateViewEvent::class.java)
|
||||||
.mergeWith(rxBus.toObservable(UpdateQueueEvent::class.java)
|
.cast(Any::class.java)
|
||||||
.throttleLatest(5, TimeUnit.SECONDS))
|
.mergeWith(rxBus.toObservable(UpdateQueueEvent::class.java)
|
||||||
.toFlowable(BackpressureStrategy.LATEST) }
|
.throttleLatest(5, TimeUnit.SECONDS))
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.toFlowable(BackpressureStrategy.LATEST)
|
||||||
|
}
|
||||||
|
.observeOn(aapsSchedulers.main)
|
||||||
.subscribe({
|
.subscribe({
|
||||||
queueSizeValue = it
|
queueSizeValue = it
|
||||||
updateGUI()
|
updateGUI()
|
||||||
|
|
|
@ -14,8 +14,8 @@ import androidx.fragment.app.FragmentActivity
|
||||||
import dagger.android.support.DaggerDialogFragment
|
import dagger.android.support.DaggerDialogFragment
|
||||||
import info.nightscout.androidaps.R
|
import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.activities.NoSplashAppCompatActivity
|
import info.nightscout.androidaps.activities.NoSplashAppCompatActivity
|
||||||
|
import info.nightscout.androidaps.utils.rx.AapsSchedulers
|
||||||
import io.reactivex.disposables.Disposable
|
import io.reactivex.disposables.Disposable
|
||||||
import io.reactivex.schedulers.Schedulers
|
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class OpenHumansLoginActivity : NoSplashAppCompatActivity() {
|
class OpenHumansLoginActivity : NoSplashAppCompatActivity() {
|
||||||
|
@ -45,8 +45,8 @@ class OpenHumansLoginActivity : NoSplashAppCompatActivity() {
|
||||||
|
|
||||||
class ExchangeAuthTokenDialog : DaggerDialogFragment() {
|
class ExchangeAuthTokenDialog : DaggerDialogFragment() {
|
||||||
|
|
||||||
@Inject
|
@Inject lateinit var openHumansUploader: OpenHumansUploader
|
||||||
lateinit var openHumansUploader: OpenHumansUploader
|
@Inject lateinit var aapsSchedulers: AapsSchedulers
|
||||||
|
|
||||||
private var disposable: Disposable? = null
|
private var disposable: Disposable? = null
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ class OpenHumansLoginActivity : NoSplashAppCompatActivity() {
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
disposable = openHumansUploader.login(arguments?.getString("authToken")!!).subscribeOn(Schedulers.io()).subscribe({
|
disposable = openHumansUploader.login(arguments?.getString("authToken")!!).subscribeOn(aapsSchedulers.io).subscribe({
|
||||||
dismiss()
|
dismiss()
|
||||||
SetupDoneDialog().show(parentFragmentManager, "SetupDoneDialog")
|
SetupDoneDialog().show(parentFragmentManager, "SetupDoneDialog")
|
||||||
}, {
|
}, {
|
||||||
|
|
|
@ -27,13 +27,13 @@ import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin
|
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin
|
||||||
import info.nightscout.androidaps.utils.extensions.plusAssign
|
import info.nightscout.androidaps.utils.extensions.plusAssign
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
|
import info.nightscout.androidaps.utils.rx.AapsSchedulers
|
||||||
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||||
import io.reactivex.Completable
|
import io.reactivex.Completable
|
||||||
import io.reactivex.Observable
|
import io.reactivex.Observable
|
||||||
import io.reactivex.Single
|
import io.reactivex.Single
|
||||||
import io.reactivex.disposables.CompositeDisposable
|
import io.reactivex.disposables.CompositeDisposable
|
||||||
import io.reactivex.disposables.Disposable
|
import io.reactivex.disposables.Disposable
|
||||||
import io.reactivex.schedulers.Schedulers
|
|
||||||
import org.json.JSONArray
|
import org.json.JSONArray
|
||||||
import org.json.JSONException
|
import org.json.JSONException
|
||||||
import org.json.JSONObject
|
import org.json.JSONObject
|
||||||
|
@ -52,10 +52,11 @@ class OpenHumansUploader @Inject constructor(
|
||||||
injector: HasAndroidInjector,
|
injector: HasAndroidInjector,
|
||||||
resourceHelper: ResourceHelper,
|
resourceHelper: ResourceHelper,
|
||||||
aapsLogger: AAPSLogger,
|
aapsLogger: AAPSLogger,
|
||||||
val sp: SP,
|
private val aapsSchedulers: AapsSchedulers,
|
||||||
val rxBus: RxBusWrapper,
|
private val sp: SP,
|
||||||
val context: Context,
|
private val rxBus: RxBusWrapper,
|
||||||
val treatmentsPlugin: TreatmentsPlugin
|
private val context: Context,
|
||||||
|
private val treatmentsPlugin: TreatmentsPlugin
|
||||||
) : PluginBase(
|
) : PluginBase(
|
||||||
PluginDescription()
|
PluginDescription()
|
||||||
.mainType(PluginType.GENERAL)
|
.mainType(PluginType.GENERAL)
|
||||||
|
@ -85,6 +86,7 @@ class OpenHumansUploader @Inject constructor(
|
||||||
}
|
}
|
||||||
|
|
||||||
private val openHumansAPI = OpenHumansAPI(OPEN_HUMANS_URL, CLIENT_ID, CLIENT_SECRET, REDIRECT_URL)
|
private val openHumansAPI = OpenHumansAPI(OPEN_HUMANS_URL, CLIENT_ID, CLIENT_SECRET, REDIRECT_URL)
|
||||||
|
|
||||||
@Suppress("PrivatePropertyName")
|
@Suppress("PrivatePropertyName")
|
||||||
private val FILE_NAME_DATE_FORMAT = SimpleDateFormat("yyyyMMdd'T'HHmmss", Locale.US).apply { timeZone = TimeZone.getTimeZone("UTC") }
|
private val FILE_NAME_DATE_FORMAT = SimpleDateFormat("yyyyMMdd'T'HHmmss", Locale.US).apply { timeZone = TimeZone.getTimeZone("UTC") }
|
||||||
|
|
||||||
|
@ -401,7 +403,7 @@ class OpenHumansUploader @Inject constructor(
|
||||||
wakeLock.release()
|
wakeLock.release()
|
||||||
}
|
}
|
||||||
.onErrorComplete()
|
.onErrorComplete()
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(aapsSchedulers.io)
|
||||||
.subscribe()
|
.subscribe()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -59,12 +59,11 @@ import info.nightscout.androidaps.utils.buildHelper.BuildHelper
|
||||||
import info.nightscout.androidaps.utils.extensions.toVisibility
|
import info.nightscout.androidaps.utils.extensions.toVisibility
|
||||||
import info.nightscout.androidaps.utils.protection.ProtectionCheck
|
import info.nightscout.androidaps.utils.protection.ProtectionCheck
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
|
import info.nightscout.androidaps.utils.rx.AapsSchedulers
|
||||||
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||||
import info.nightscout.androidaps.utils.ui.UIRunnable
|
import info.nightscout.androidaps.utils.ui.UIRunnable
|
||||||
import info.nightscout.androidaps.utils.wizard.QuickWizard
|
import info.nightscout.androidaps.utils.wizard.QuickWizard
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
|
||||||
import io.reactivex.disposables.CompositeDisposable
|
import io.reactivex.disposables.CompositeDisposable
|
||||||
import io.reactivex.schedulers.Schedulers
|
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import kotlinx.coroutines.withContext
|
import kotlinx.coroutines.withContext
|
||||||
|
@ -80,6 +79,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
|
||||||
|
|
||||||
@Inject lateinit var injector: HasAndroidInjector
|
@Inject lateinit var injector: HasAndroidInjector
|
||||||
@Inject lateinit var aapsLogger: AAPSLogger
|
@Inject lateinit var aapsLogger: AAPSLogger
|
||||||
|
@Inject lateinit var aapsSchedulers: AapsSchedulers
|
||||||
@Inject lateinit var sp: SP
|
@Inject lateinit var sp: SP
|
||||||
@Inject lateinit var rxBus: RxBusWrapper
|
@Inject lateinit var rxBus: RxBusWrapper
|
||||||
@Inject lateinit var resourceHelper: ResourceHelper
|
@Inject lateinit var resourceHelper: ResourceHelper
|
||||||
|
@ -209,63 +209,63 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
|
||||||
super.onResume()
|
super.onResume()
|
||||||
disposable.add(rxBus
|
disposable.add(rxBus
|
||||||
.toObservable(EventRefreshOverview::class.java)
|
.toObservable(EventRefreshOverview::class.java)
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(aapsSchedulers.main)
|
||||||
.subscribe({
|
.subscribe({
|
||||||
if (it.now) updateGUI(it.from)
|
if (it.now) updateGUI(it.from)
|
||||||
else scheduleUpdateGUI(it.from)
|
else scheduleUpdateGUI(it.from)
|
||||||
}) { fabricPrivacy.logException(it) })
|
}, fabricPrivacy::logException))
|
||||||
disposable.add(rxBus
|
disposable.add(rxBus
|
||||||
.toObservable(EventExtendedBolusChange::class.java)
|
.toObservable(EventExtendedBolusChange::class.java)
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(aapsSchedulers.io)
|
||||||
.subscribe({ scheduleUpdateGUI("EventExtendedBolusChange") }) { fabricPrivacy.logException(it) })
|
.subscribe({ scheduleUpdateGUI("EventExtendedBolusChange") }, fabricPrivacy::logException))
|
||||||
disposable.add(rxBus
|
disposable.add(rxBus
|
||||||
.toObservable(EventTempBasalChange::class.java)
|
.toObservable(EventTempBasalChange::class.java)
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(aapsSchedulers.io)
|
||||||
.subscribe({ scheduleUpdateGUI("EventTempBasalChange") }) { fabricPrivacy.logException(it) })
|
.subscribe({ scheduleUpdateGUI("EventTempBasalChange") }, fabricPrivacy::logException))
|
||||||
disposable.add(rxBus
|
disposable.add(rxBus
|
||||||
.toObservable(EventTreatmentChange::class.java)
|
.toObservable(EventTreatmentChange::class.java)
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(aapsSchedulers.io)
|
||||||
.subscribe({ scheduleUpdateGUI("EventTreatmentChange") }) { fabricPrivacy.logException(it) })
|
.subscribe({ scheduleUpdateGUI("EventTreatmentChange") }, fabricPrivacy::logException))
|
||||||
disposable.add(rxBus
|
disposable.add(rxBus
|
||||||
.toObservable(EventTempTargetChange::class.java)
|
.toObservable(EventTempTargetChange::class.java)
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(aapsSchedulers.io)
|
||||||
.subscribe({ scheduleUpdateGUI("EventTempTargetChange") }) { fabricPrivacy.logException(it) })
|
.subscribe({ scheduleUpdateGUI("EventTempTargetChange") }, fabricPrivacy::logException))
|
||||||
disposable.add(rxBus
|
disposable.add(rxBus
|
||||||
.toObservable(EventAcceptOpenLoopChange::class.java)
|
.toObservable(EventAcceptOpenLoopChange::class.java)
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(aapsSchedulers.io)
|
||||||
.subscribe({ scheduleUpdateGUI("EventAcceptOpenLoopChange") }) { fabricPrivacy.logException(it) })
|
.subscribe({ scheduleUpdateGUI("EventAcceptOpenLoopChange") }, fabricPrivacy::logException))
|
||||||
disposable.add(rxBus
|
disposable.add(rxBus
|
||||||
.toObservable(EventCareportalEventChange::class.java)
|
.toObservable(EventCareportalEventChange::class.java)
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(aapsSchedulers.io)
|
||||||
.subscribe({ scheduleUpdateGUI("EventCareportalEventChange") }) { fabricPrivacy.logException(it) })
|
.subscribe({ scheduleUpdateGUI("EventCareportalEventChange") }, fabricPrivacy::logException))
|
||||||
disposable.add(rxBus
|
disposable.add(rxBus
|
||||||
.toObservable(EventInitializationChanged::class.java)
|
.toObservable(EventInitializationChanged::class.java)
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(aapsSchedulers.io)
|
||||||
.subscribe({ scheduleUpdateGUI("EventInitializationChanged") }) { fabricPrivacy.logException(it) })
|
.subscribe({ scheduleUpdateGUI("EventInitializationChanged") }, fabricPrivacy::logException))
|
||||||
disposable.add(rxBus
|
disposable.add(rxBus
|
||||||
.toObservable(EventAutosensCalculationFinished::class.java)
|
.toObservable(EventAutosensCalculationFinished::class.java)
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(aapsSchedulers.io)
|
||||||
.subscribe({ scheduleUpdateGUI("EventAutosensCalculationFinished") }) { fabricPrivacy.logException(it) })
|
.subscribe({ scheduleUpdateGUI("EventAutosensCalculationFinished") }, fabricPrivacy::logException))
|
||||||
disposable.add(rxBus
|
disposable.add(rxBus
|
||||||
.toObservable(EventProfileNeedsUpdate::class.java)
|
.toObservable(EventProfileNeedsUpdate::class.java)
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(aapsSchedulers.io)
|
||||||
.subscribe({ scheduleUpdateGUI("EventProfileNeedsUpdate") }) { fabricPrivacy.logException(it) })
|
.subscribe({ scheduleUpdateGUI("EventProfileNeedsUpdate") }, fabricPrivacy::logException))
|
||||||
disposable.add(rxBus
|
disposable.add(rxBus
|
||||||
.toObservable(EventPreferenceChange::class.java)
|
.toObservable(EventPreferenceChange::class.java)
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(aapsSchedulers.io)
|
||||||
.subscribe({ scheduleUpdateGUI("EventPreferenceChange") }) { fabricPrivacy.logException(it) })
|
.subscribe({ scheduleUpdateGUI("EventPreferenceChange") }, fabricPrivacy::logException))
|
||||||
disposable.add(rxBus
|
disposable.add(rxBus
|
||||||
.toObservable(EventNewOpenLoopNotification::class.java)
|
.toObservable(EventNewOpenLoopNotification::class.java)
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(aapsSchedulers.io)
|
||||||
.subscribe({ scheduleUpdateGUI("EventNewOpenLoopNotification") }) { fabricPrivacy.logException(it) })
|
.subscribe({ scheduleUpdateGUI("EventNewOpenLoopNotification") }, fabricPrivacy::logException))
|
||||||
disposable.add(rxBus
|
disposable.add(rxBus
|
||||||
.toObservable(EventPumpStatusChanged::class.java)
|
.toObservable(EventPumpStatusChanged::class.java)
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(aapsSchedulers.main)
|
||||||
.subscribe({ updatePumpStatus(it) }) { fabricPrivacy.logException(it) })
|
.subscribe({ updatePumpStatus(it) }, fabricPrivacy::logException))
|
||||||
disposable.add(rxBus
|
disposable.add(rxBus
|
||||||
.toObservable(EventIobCalculationProgress::class.java)
|
.toObservable(EventIobCalculationProgress::class.java)
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(aapsSchedulers.main)
|
||||||
.subscribe({ binding.graphsLayout.iobCalculationProgress.text = it.progress }) { fabricPrivacy.logException(it) })
|
.subscribe({ binding.graphsLayout.iobCalculationProgress.text = it.progress }, fabricPrivacy::logException))
|
||||||
|
|
||||||
refreshLoop = Runnable {
|
refreshLoop = Runnable {
|
||||||
scheduleUpdateGUI("refreshLoop")
|
scheduleUpdateGUI("refreshLoop")
|
||||||
|
|
|
@ -16,12 +16,11 @@ import info.nightscout.androidaps.plugins.general.overview.events.EventDismissNo
|
||||||
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification
|
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification
|
||||||
import info.nightscout.androidaps.plugins.general.overview.notifications.NotificationStore
|
import info.nightscout.androidaps.plugins.general.overview.notifications.NotificationStore
|
||||||
import info.nightscout.androidaps.utils.FabricPrivacy
|
import info.nightscout.androidaps.utils.FabricPrivacy
|
||||||
import info.nightscout.androidaps.utils.extensions.plusAssign
|
|
||||||
import info.nightscout.androidaps.utils.extensions.*
|
import info.nightscout.androidaps.utils.extensions.*
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
|
import info.nightscout.androidaps.utils.rx.AapsSchedulers
|
||||||
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||||
import io.reactivex.disposables.CompositeDisposable
|
import io.reactivex.disposables.CompositeDisposable
|
||||||
import io.reactivex.schedulers.Schedulers
|
|
||||||
import org.json.JSONObject
|
import org.json.JSONObject
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
import javax.inject.Singleton
|
import javax.inject.Singleton
|
||||||
|
@ -34,6 +33,7 @@ class OverviewPlugin @Inject constructor(
|
||||||
private val rxBus: RxBusWrapper,
|
private val rxBus: RxBusWrapper,
|
||||||
private val sp: SP,
|
private val sp: SP,
|
||||||
aapsLogger: AAPSLogger,
|
aapsLogger: AAPSLogger,
|
||||||
|
private val aapsSchedulers: AapsSchedulers,
|
||||||
resourceHelper: ResourceHelper,
|
resourceHelper: ResourceHelper,
|
||||||
private val config: Config
|
private val config: Config
|
||||||
) : PluginBase(PluginDescription()
|
) : PluginBase(PluginDescription()
|
||||||
|
@ -56,18 +56,18 @@ class OverviewPlugin @Inject constructor(
|
||||||
notificationStore.createNotificationChannel()
|
notificationStore.createNotificationChannel()
|
||||||
disposable += rxBus
|
disposable += rxBus
|
||||||
.toObservable(EventNewNotification::class.java)
|
.toObservable(EventNewNotification::class.java)
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(aapsSchedulers.io)
|
||||||
.subscribe({ n ->
|
.subscribe({ n ->
|
||||||
if (notificationStore.add(n.notification))
|
if (notificationStore.add(n.notification))
|
||||||
rxBus.send(EventRefreshOverview("EventNewNotification"))
|
rxBus.send(EventRefreshOverview("EventNewNotification"))
|
||||||
}, { fabricPrivacy.logException(it) })
|
}, fabricPrivacy::logException)
|
||||||
disposable += rxBus
|
disposable += rxBus
|
||||||
.toObservable(EventDismissNotification::class.java)
|
.toObservable(EventDismissNotification::class.java)
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(aapsSchedulers.io)
|
||||||
.subscribe({ n ->
|
.subscribe({ n ->
|
||||||
if (notificationStore.remove(n.id))
|
if (notificationStore.remove(n.id))
|
||||||
rxBus.send(EventRefreshOverview("EventDismissNotification"))
|
rxBus.send(EventRefreshOverview("EventDismissNotification"))
|
||||||
}, { fabricPrivacy.logException(it) })
|
}, fabricPrivacy::logException)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onStop() {
|
override fun onStop() {
|
||||||
|
|
|
@ -18,13 +18,14 @@ import info.nightscout.androidaps.plugins.general.overview.events.EventQuickWiza
|
||||||
import info.nightscout.androidaps.utils.DateUtil
|
import info.nightscout.androidaps.utils.DateUtil
|
||||||
import info.nightscout.androidaps.utils.FabricPrivacy
|
import info.nightscout.androidaps.utils.FabricPrivacy
|
||||||
import info.nightscout.androidaps.utils.extensions.plusAssign
|
import info.nightscout.androidaps.utils.extensions.plusAssign
|
||||||
|
import info.nightscout.androidaps.utils.rx.AapsSchedulers
|
||||||
import info.nightscout.androidaps.utils.wizard.QuickWizard
|
import info.nightscout.androidaps.utils.wizard.QuickWizard
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
|
||||||
import io.reactivex.disposables.CompositeDisposable
|
import io.reactivex.disposables.CompositeDisposable
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class QuickWizardListActivity : NoSplashAppCompatActivity() {
|
class QuickWizardListActivity : NoSplashAppCompatActivity() {
|
||||||
|
|
||||||
|
@Inject lateinit var aapsSchedulers: AapsSchedulers
|
||||||
@Inject lateinit var rxBus: RxBusWrapper
|
@Inject lateinit var rxBus: RxBusWrapper
|
||||||
@Inject lateinit var fabricPrivacy: FabricPrivacy
|
@Inject lateinit var fabricPrivacy: FabricPrivacy
|
||||||
@Inject lateinit var quickWizard: QuickWizard
|
@Inject lateinit var quickWizard: QuickWizard
|
||||||
|
@ -95,11 +96,11 @@ class QuickWizardListActivity : NoSplashAppCompatActivity() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
disposable += rxBus
|
disposable += rxBus
|
||||||
.toObservable(EventQuickWizardChange::class.java)
|
.toObservable(EventQuickWizardChange::class.java)
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(aapsSchedulers.main)
|
||||||
.subscribe({
|
.subscribe({
|
||||||
val adapter = RecyclerViewAdapter(supportFragmentManager)
|
val adapter = RecyclerViewAdapter(supportFragmentManager)
|
||||||
binding.recyclerview.swapAdapter(adapter, false)
|
binding.recyclerview.swapAdapter(adapter, false)
|
||||||
}, { fabricPrivacy.logException(it) })
|
}, fabricPrivacy::logException)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onPause() {
|
override fun onPause() {
|
||||||
|
|
|
@ -12,8 +12,8 @@ import info.nightscout.androidaps.logging.LTag
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
import info.nightscout.androidaps.utils.FabricPrivacy
|
import info.nightscout.androidaps.utils.FabricPrivacy
|
||||||
import info.nightscout.androidaps.utils.androidNotification.NotificationHolder
|
import info.nightscout.androidaps.utils.androidNotification.NotificationHolder
|
||||||
|
import info.nightscout.androidaps.utils.rx.AapsSchedulers
|
||||||
import io.reactivex.disposables.CompositeDisposable
|
import io.reactivex.disposables.CompositeDisposable
|
||||||
import io.reactivex.schedulers.Schedulers
|
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -21,6 +21,7 @@ import javax.inject.Inject
|
||||||
*/
|
*/
|
||||||
class DummyService : DaggerService() {
|
class DummyService : DaggerService() {
|
||||||
|
|
||||||
|
@Inject lateinit var aapsSchedulers: AapsSchedulers
|
||||||
@Inject lateinit var rxBus: RxBusWrapper
|
@Inject lateinit var rxBus: RxBusWrapper
|
||||||
@Inject lateinit var aapsLogger: AAPSLogger
|
@Inject lateinit var aapsLogger: AAPSLogger
|
||||||
@Inject lateinit var fabricPrivacy: FabricPrivacy
|
@Inject lateinit var fabricPrivacy: FabricPrivacy
|
||||||
|
@ -47,7 +48,7 @@ class DummyService : DaggerService() {
|
||||||
}
|
}
|
||||||
disposable.add(rxBus
|
disposable.add(rxBus
|
||||||
.toObservable(EventAppExit::class.java)
|
.toObservable(EventAppExit::class.java)
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(aapsSchedulers.io)
|
||||||
.subscribe({
|
.subscribe({
|
||||||
aapsLogger.debug(LTag.CORE, "EventAppExit received")
|
aapsLogger.debug(LTag.CORE, "EventAppExit received")
|
||||||
stopSelf()
|
stopSelf()
|
||||||
|
|
|
@ -7,10 +7,8 @@ import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import androidx.core.app.NotificationCompat
|
import androidx.core.app.NotificationCompat
|
||||||
import androidx.core.app.RemoteInput
|
import androidx.core.app.RemoteInput
|
||||||
import androidx.core.app.TaskStackBuilder
|
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.androidaps.Constants
|
import info.nightscout.androidaps.Constants
|
||||||
import info.nightscout.androidaps.MainActivity
|
|
||||||
import info.nightscout.androidaps.R
|
import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.data.Profile
|
import info.nightscout.androidaps.data.Profile
|
||||||
import info.nightscout.androidaps.events.*
|
import info.nightscout.androidaps.events.*
|
||||||
|
@ -26,8 +24,8 @@ import info.nightscout.androidaps.utils.androidNotification.NotificationHolder
|
||||||
import info.nightscout.androidaps.utils.androidNotification.openAppIntent
|
import info.nightscout.androidaps.utils.androidNotification.openAppIntent
|
||||||
import info.nightscout.androidaps.utils.resources.IconsProvider
|
import info.nightscout.androidaps.utils.resources.IconsProvider
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
|
import info.nightscout.androidaps.utils.rx.AapsSchedulers
|
||||||
import io.reactivex.disposables.CompositeDisposable
|
import io.reactivex.disposables.CompositeDisposable
|
||||||
import io.reactivex.schedulers.Schedulers
|
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
import javax.inject.Singleton
|
import javax.inject.Singleton
|
||||||
|
|
||||||
|
@ -37,6 +35,7 @@ class PersistentNotificationPlugin @Inject constructor(
|
||||||
injector: HasAndroidInjector,
|
injector: HasAndroidInjector,
|
||||||
aapsLogger: AAPSLogger,
|
aapsLogger: AAPSLogger,
|
||||||
resourceHelper: ResourceHelper,
|
resourceHelper: ResourceHelper,
|
||||||
|
private val aapsSchedulers: AapsSchedulers,
|
||||||
private val profileFunction: ProfileFunction,
|
private val profileFunction: ProfileFunction,
|
||||||
private val fabricPrivacy: FabricPrivacy,
|
private val fabricPrivacy: FabricPrivacy,
|
||||||
private val activePlugins: ActivePluginProvider,
|
private val activePlugins: ActivePluginProvider,
|
||||||
|
@ -74,36 +73,36 @@ class PersistentNotificationPlugin @Inject constructor(
|
||||||
createNotificationChannel() // make sure channels exist before triggering updates through the bus
|
createNotificationChannel() // make sure channels exist before triggering updates through the bus
|
||||||
disposable.add(rxBus
|
disposable.add(rxBus
|
||||||
.toObservable(EventRefreshOverview::class.java)
|
.toObservable(EventRefreshOverview::class.java)
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(aapsSchedulers.io)
|
||||||
.subscribe({ triggerNotificationUpdate() }) { fabricPrivacy.logException(it) })
|
.subscribe({ triggerNotificationUpdate() }, fabricPrivacy::logException))
|
||||||
disposable.add(rxBus
|
disposable.add(rxBus
|
||||||
.toObservable(EventExtendedBolusChange::class.java)
|
.toObservable(EventExtendedBolusChange::class.java)
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(aapsSchedulers.io)
|
||||||
.subscribe({ triggerNotificationUpdate() }) { fabricPrivacy.logException(it) })
|
.subscribe({ triggerNotificationUpdate() }, fabricPrivacy::logException))
|
||||||
disposable.add(rxBus
|
disposable.add(rxBus
|
||||||
.toObservable(EventTempBasalChange::class.java)
|
.toObservable(EventTempBasalChange::class.java)
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(aapsSchedulers.io)
|
||||||
.subscribe({ triggerNotificationUpdate() }) { fabricPrivacy.logException(it) })
|
.subscribe({ triggerNotificationUpdate() }, fabricPrivacy::logException))
|
||||||
disposable.add(rxBus
|
disposable.add(rxBus
|
||||||
.toObservable(EventTreatmentChange::class.java)
|
.toObservable(EventTreatmentChange::class.java)
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(aapsSchedulers.io)
|
||||||
.subscribe({ triggerNotificationUpdate() }) { fabricPrivacy.logException(it) })
|
.subscribe({ triggerNotificationUpdate() }, fabricPrivacy::logException))
|
||||||
disposable.add(rxBus
|
disposable.add(rxBus
|
||||||
.toObservable(EventInitializationChanged::class.java)
|
.toObservable(EventInitializationChanged::class.java)
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(aapsSchedulers.io)
|
||||||
.subscribe({ triggerNotificationUpdate() }) { fabricPrivacy.logException(it) })
|
.subscribe({ triggerNotificationUpdate() }, fabricPrivacy::logException))
|
||||||
disposable.add(rxBus
|
disposable.add(rxBus
|
||||||
.toObservable(EventNewBasalProfile::class.java)
|
.toObservable(EventNewBasalProfile::class.java)
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(aapsSchedulers.io)
|
||||||
.subscribe({ triggerNotificationUpdate() }) { fabricPrivacy.logException(it) })
|
.subscribe({ triggerNotificationUpdate() }, fabricPrivacy::logException))
|
||||||
disposable.add(rxBus
|
disposable.add(rxBus
|
||||||
.toObservable(EventAutosensCalculationFinished::class.java)
|
.toObservable(EventAutosensCalculationFinished::class.java)
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(aapsSchedulers.io)
|
||||||
.subscribe({ triggerNotificationUpdate() }) { fabricPrivacy.logException(it) })
|
.subscribe({ triggerNotificationUpdate() }, fabricPrivacy::logException))
|
||||||
disposable.add(rxBus
|
disposable.add(rxBus
|
||||||
.toObservable(EventPreferenceChange::class.java)
|
.toObservable(EventPreferenceChange::class.java)
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(aapsSchedulers.io)
|
||||||
.subscribe({ triggerNotificationUpdate() }) { fabricPrivacy.logException(it) })
|
.subscribe({ triggerNotificationUpdate() }, fabricPrivacy::logException))
|
||||||
triggerNotificationUpdate()
|
triggerNotificationUpdate()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ import info.nightscout.androidaps.utils.DateUtil
|
||||||
import info.nightscout.androidaps.utils.FabricPrivacy
|
import info.nightscout.androidaps.utils.FabricPrivacy
|
||||||
import info.nightscout.androidaps.utils.HtmlHelper
|
import info.nightscout.androidaps.utils.HtmlHelper
|
||||||
import info.nightscout.androidaps.utils.extensions.plusAssign
|
import info.nightscout.androidaps.utils.extensions.plusAssign
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
import info.nightscout.androidaps.utils.rx.AapsSchedulers
|
||||||
import io.reactivex.disposables.CompositeDisposable
|
import io.reactivex.disposables.CompositeDisposable
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
@ -20,6 +20,7 @@ import kotlin.math.max
|
||||||
|
|
||||||
class SmsCommunicatorFragment : DaggerFragment() {
|
class SmsCommunicatorFragment : DaggerFragment() {
|
||||||
|
|
||||||
|
@Inject lateinit var aapsSchedulers: AapsSchedulers
|
||||||
@Inject lateinit var fabricPrivacy: FabricPrivacy
|
@Inject lateinit var fabricPrivacy: FabricPrivacy
|
||||||
@Inject lateinit var rxBus: RxBusWrapper
|
@Inject lateinit var rxBus: RxBusWrapper
|
||||||
@Inject lateinit var smsCommunicatorPlugin: SmsCommunicatorPlugin
|
@Inject lateinit var smsCommunicatorPlugin: SmsCommunicatorPlugin
|
||||||
|
@ -45,8 +46,8 @@ class SmsCommunicatorFragment : DaggerFragment() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
disposable += rxBus
|
disposable += rxBus
|
||||||
.toObservable(EventSmsCommunicatorUpdateGui::class.java)
|
.toObservable(EventSmsCommunicatorUpdateGui::class.java)
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(aapsSchedulers.main)
|
||||||
.subscribe({ updateGui() }) { fabricPrivacy.logException(it) }
|
.subscribe({ updateGui() }, fabricPrivacy::logException)
|
||||||
updateGui()
|
updateGui()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,10 +38,10 @@ import info.nightscout.androidaps.receivers.BundleStore
|
||||||
import info.nightscout.androidaps.utils.*
|
import info.nightscout.androidaps.utils.*
|
||||||
import info.nightscout.androidaps.utils.extensions.plusAssign
|
import info.nightscout.androidaps.utils.extensions.plusAssign
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
|
import info.nightscout.androidaps.utils.rx.AapsSchedulers
|
||||||
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||||
import info.nightscout.androidaps.utils.textValidator.ValidatingEditTextPreference
|
import info.nightscout.androidaps.utils.textValidator.ValidatingEditTextPreference
|
||||||
import io.reactivex.disposables.CompositeDisposable
|
import io.reactivex.disposables.CompositeDisposable
|
||||||
import io.reactivex.schedulers.Schedulers
|
|
||||||
import org.apache.commons.lang3.StringUtils
|
import org.apache.commons.lang3.StringUtils
|
||||||
import java.text.Normalizer
|
import java.text.Normalizer
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
@ -55,6 +55,7 @@ class SmsCommunicatorPlugin @Inject constructor(
|
||||||
injector: HasAndroidInjector,
|
injector: HasAndroidInjector,
|
||||||
aapsLogger: AAPSLogger,
|
aapsLogger: AAPSLogger,
|
||||||
resourceHelper: ResourceHelper,
|
resourceHelper: ResourceHelper,
|
||||||
|
private val aapsSchedulers: AapsSchedulers,
|
||||||
private val sp: SP,
|
private val sp: SP,
|
||||||
private val constraintChecker: ConstraintChecker,
|
private val constraintChecker: ConstraintChecker,
|
||||||
private val rxBus: RxBusWrapper,
|
private val rxBus: RxBusWrapper,
|
||||||
|
@ -107,8 +108,8 @@ class SmsCommunicatorPlugin @Inject constructor(
|
||||||
super.onStart()
|
super.onStart()
|
||||||
disposable += rxBus
|
disposable += rxBus
|
||||||
.toObservable(EventPreferenceChange::class.java)
|
.toObservable(EventPreferenceChange::class.java)
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(aapsSchedulers.io)
|
||||||
.subscribe({ event: EventPreferenceChange? -> processSettings(event) }) { fabricPrivacy.logException(it) }
|
.subscribe({ event: EventPreferenceChange? -> processSettings(event) }, fabricPrivacy::logException)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onStop() {
|
override fun onStop() {
|
||||||
|
|
|
@ -15,17 +15,19 @@ import info.nightscout.androidaps.plugins.general.tidepool.events.EventTidepoolR
|
||||||
import info.nightscout.androidaps.plugins.general.tidepool.events.EventTidepoolUpdateGUI
|
import info.nightscout.androidaps.plugins.general.tidepool.events.EventTidepoolUpdateGUI
|
||||||
import info.nightscout.androidaps.utils.FabricPrivacy
|
import info.nightscout.androidaps.utils.FabricPrivacy
|
||||||
import info.nightscout.androidaps.utils.extensions.plusAssign
|
import info.nightscout.androidaps.utils.extensions.plusAssign
|
||||||
|
import info.nightscout.androidaps.utils.rx.AapsSchedulers
|
||||||
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
|
||||||
import io.reactivex.disposables.CompositeDisposable
|
import io.reactivex.disposables.CompositeDisposable
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class TidepoolFragment : DaggerFragment() {
|
class TidepoolFragment : DaggerFragment() {
|
||||||
|
|
||||||
@Inject lateinit var rxBus: RxBusWrapper
|
@Inject lateinit var rxBus: RxBusWrapper
|
||||||
@Inject lateinit var tidepoolPlugin: TidepoolPlugin
|
@Inject lateinit var tidepoolPlugin: TidepoolPlugin
|
||||||
@Inject lateinit var tidepoolUploader: TidepoolUploader
|
@Inject lateinit var tidepoolUploader: TidepoolUploader
|
||||||
@Inject lateinit var sp: SP
|
@Inject lateinit var sp: SP
|
||||||
@Inject lateinit var fabricPrivacy: FabricPrivacy
|
@Inject lateinit var fabricPrivacy: FabricPrivacy
|
||||||
|
@Inject lateinit var aapsSchedulers: AapsSchedulers
|
||||||
|
|
||||||
private var disposable: CompositeDisposable = CompositeDisposable()
|
private var disposable: CompositeDisposable = CompositeDisposable()
|
||||||
|
|
||||||
|
@ -53,7 +55,7 @@ class TidepoolFragment : DaggerFragment() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
disposable += rxBus
|
disposable += rxBus
|
||||||
.toObservable(EventTidepoolUpdateGUI::class.java)
|
.toObservable(EventTidepoolUpdateGUI::class.java)
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(aapsSchedulers.main)
|
||||||
.subscribe({
|
.subscribe({
|
||||||
if (_binding == null) return@subscribe
|
if (_binding == null) return@subscribe
|
||||||
tidepoolPlugin.updateLog()
|
tidepoolPlugin.updateLog()
|
||||||
|
@ -61,7 +63,7 @@ class TidepoolFragment : DaggerFragment() {
|
||||||
binding.status.text = tidepoolUploader.connectionStatus.name
|
binding.status.text = tidepoolUploader.connectionStatus.name
|
||||||
binding.log.text = tidepoolPlugin.textLog
|
binding.log.text = tidepoolPlugin.textLog
|
||||||
binding.logscrollview.fullScroll(ScrollView.FOCUS_DOWN)
|
binding.logscrollview.fullScroll(ScrollView.FOCUS_DOWN)
|
||||||
}, { fabricPrivacy.logException(it) })
|
}, fabricPrivacy::logException)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Synchronized
|
@Synchronized
|
||||||
|
@ -76,5 +78,4 @@ class TidepoolFragment : DaggerFragment() {
|
||||||
_binding = null
|
_binding = null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,9 +32,9 @@ import info.nightscout.androidaps.utils.T
|
||||||
import info.nightscout.androidaps.utils.ToastUtils
|
import info.nightscout.androidaps.utils.ToastUtils
|
||||||
import info.nightscout.androidaps.utils.extensions.plusAssign
|
import info.nightscout.androidaps.utils.extensions.plusAssign
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
|
import info.nightscout.androidaps.utils.rx.AapsSchedulers
|
||||||
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||||
import io.reactivex.disposables.CompositeDisposable
|
import io.reactivex.disposables.CompositeDisposable
|
||||||
import io.reactivex.schedulers.Schedulers
|
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
import javax.inject.Singleton
|
import javax.inject.Singleton
|
||||||
|
@ -44,6 +44,7 @@ class TidepoolPlugin @Inject constructor(
|
||||||
injector: HasAndroidInjector,
|
injector: HasAndroidInjector,
|
||||||
aapsLogger: AAPSLogger,
|
aapsLogger: AAPSLogger,
|
||||||
resourceHelper: ResourceHelper,
|
resourceHelper: ResourceHelper,
|
||||||
|
private val aapsSchedulers: AapsSchedulers,
|
||||||
private val rxBus: RxBusWrapper,
|
private val rxBus: RxBusWrapper,
|
||||||
private val context: Context,
|
private val context: Context,
|
||||||
private val fabricPrivacy: FabricPrivacy,
|
private val fabricPrivacy: FabricPrivacy,
|
||||||
|
@ -71,11 +72,11 @@ class TidepoolPlugin @Inject constructor(
|
||||||
super.onStart()
|
super.onStart()
|
||||||
disposable += rxBus
|
disposable += rxBus
|
||||||
.toObservable(EventTidepoolDoUpload::class.java)
|
.toObservable(EventTidepoolDoUpload::class.java)
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(aapsSchedulers.io)
|
||||||
.subscribe({ doUpload() }, { fabricPrivacy.logException(it) })
|
.subscribe({ doUpload() }, fabricPrivacy::logException)
|
||||||
disposable += rxBus
|
disposable += rxBus
|
||||||
.toObservable(EventTidepoolResetData::class.java)
|
.toObservable(EventTidepoolResetData::class.java)
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(aapsSchedulers.io)
|
||||||
.subscribe({
|
.subscribe({
|
||||||
if (tidepoolUploader.connectionStatus != CONNECTED) {
|
if (tidepoolUploader.connectionStatus != CONNECTED) {
|
||||||
aapsLogger.debug(LTag.TIDEPOOL, "Not connected for delete Dataset")
|
aapsLogger.debug(LTag.TIDEPOOL, "Not connected for delete Dataset")
|
||||||
|
@ -84,18 +85,14 @@ class TidepoolPlugin @Inject constructor(
|
||||||
sp.putLong(R.string.key_tidepool_last_end, 0)
|
sp.putLong(R.string.key_tidepool_last_end, 0)
|
||||||
tidepoolUploader.doLogin()
|
tidepoolUploader.doLogin()
|
||||||
}
|
}
|
||||||
}, {
|
}, fabricPrivacy::logException)
|
||||||
fabricPrivacy.logException(it)
|
|
||||||
})
|
|
||||||
disposable += rxBus
|
disposable += rxBus
|
||||||
.toObservable(EventTidepoolStatus::class.java)
|
.toObservable(EventTidepoolStatus::class.java)
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(aapsSchedulers.io)
|
||||||
.subscribe({ event -> addToLog(event) }, {
|
.subscribe({ event -> addToLog(event) }, fabricPrivacy::logException)
|
||||||
fabricPrivacy.logException(it)
|
|
||||||
})
|
|
||||||
disposable += rxBus
|
disposable += rxBus
|
||||||
.toObservable(EventNewBG::class.java)
|
.toObservable(EventNewBG::class.java)
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(aapsSchedulers.io)
|
||||||
.filter { it.bgReading != null } // better would be optional in API level >24
|
.filter { it.bgReading != null } // better would be optional in API level >24
|
||||||
.map { it.bgReading }
|
.map { it.bgReading }
|
||||||
.subscribe({ bgReading ->
|
.subscribe({ bgReading ->
|
||||||
|
@ -106,27 +103,21 @@ class TidepoolPlugin @Inject constructor(
|
||||||
&& (!sp.getBoolean(R.string.key_tidepool_only_while_unmetered, false) || receiverStatusStore.isWifiConnected)
|
&& (!sp.getBoolean(R.string.key_tidepool_only_while_unmetered, false) || receiverStatusStore.isWifiConnected)
|
||||||
&& rateLimit.rateLimit("tidepool-new-data-upload", T.mins(4).secs().toInt()))
|
&& rateLimit.rateLimit("tidepool-new-data-upload", T.mins(4).secs().toInt()))
|
||||||
doUpload()
|
doUpload()
|
||||||
}, {
|
}, fabricPrivacy::logException)
|
||||||
fabricPrivacy.logException(it)
|
|
||||||
})
|
|
||||||
disposable += rxBus
|
disposable += rxBus
|
||||||
.toObservable(EventPreferenceChange::class.java)
|
.toObservable(EventPreferenceChange::class.java)
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(aapsSchedulers.io)
|
||||||
.subscribe({ event ->
|
.subscribe({ event ->
|
||||||
if (event.isChanged(resourceHelper, R.string.key_tidepool_dev_servers)
|
if (event.isChanged(resourceHelper, R.string.key_tidepool_dev_servers)
|
||||||
|| event.isChanged(resourceHelper, R.string.key_tidepool_username)
|
|| event.isChanged(resourceHelper, R.string.key_tidepool_username)
|
||||||
|| event.isChanged(resourceHelper, R.string.key_tidepool_password)
|
|| event.isChanged(resourceHelper, R.string.key_tidepool_password)
|
||||||
)
|
)
|
||||||
tidepoolUploader.resetInstance()
|
tidepoolUploader.resetInstance()
|
||||||
}, {
|
}, fabricPrivacy::logException)
|
||||||
fabricPrivacy.logException(it)
|
|
||||||
})
|
|
||||||
disposable += rxBus
|
disposable += rxBus
|
||||||
.toObservable(EventNetworkChange::class.java)
|
.toObservable(EventNetworkChange::class.java)
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(aapsSchedulers.io)
|
||||||
.subscribe({}, {
|
.subscribe({}, fabricPrivacy::logException) // TODO start upload on wifi connect
|
||||||
fabricPrivacy.logException(it)
|
|
||||||
}) // TODO start upload on wifi connect
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -150,7 +141,7 @@ class TidepoolPlugin @Inject constructor(
|
||||||
private fun doUpload() =
|
private fun doUpload() =
|
||||||
when (tidepoolUploader.connectionStatus) {
|
when (tidepoolUploader.connectionStatus) {
|
||||||
DISCONNECTED -> tidepoolUploader.doLogin(true)
|
DISCONNECTED -> tidepoolUploader.doLogin(true)
|
||||||
CONNECTED -> tidepoolUploader.doUpload()
|
CONNECTED -> tidepoolUploader.doUpload()
|
||||||
|
|
||||||
else -> {
|
else -> {
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,8 +10,8 @@ import info.nightscout.androidaps.interfaces.PluginBase
|
||||||
import info.nightscout.androidaps.interfaces.PluginDescription
|
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.plugins.aps.loop.LoopPlugin
|
|
||||||
import info.nightscout.androidaps.plugins.aps.events.EventOpenAPSUpdateGui
|
import info.nightscout.androidaps.plugins.aps.events.EventOpenAPSUpdateGui
|
||||||
|
import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
import info.nightscout.androidaps.plugins.general.overview.events.EventDismissBolusProgressIfRunning
|
import info.nightscout.androidaps.plugins.general.overview.events.EventDismissBolusProgressIfRunning
|
||||||
import info.nightscout.androidaps.plugins.general.overview.events.EventOverviewBolusProgress
|
import info.nightscout.androidaps.plugins.general.overview.events.EventOverviewBolusProgress
|
||||||
|
@ -19,9 +19,9 @@ import info.nightscout.androidaps.plugins.general.wear.wearintegration.WatchUpda
|
||||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventAutosensCalculationFinished
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventAutosensCalculationFinished
|
||||||
import info.nightscout.androidaps.utils.FabricPrivacy
|
import info.nightscout.androidaps.utils.FabricPrivacy
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
|
import info.nightscout.androidaps.utils.rx.AapsSchedulers
|
||||||
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||||
import io.reactivex.disposables.CompositeDisposable
|
import io.reactivex.disposables.CompositeDisposable
|
||||||
import io.reactivex.schedulers.Schedulers
|
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
import javax.inject.Singleton
|
import javax.inject.Singleton
|
||||||
|
|
||||||
|
@ -30,6 +30,7 @@ class WearPlugin @Inject constructor(
|
||||||
injector: HasAndroidInjector,
|
injector: HasAndroidInjector,
|
||||||
aapsLogger: AAPSLogger,
|
aapsLogger: AAPSLogger,
|
||||||
resourceHelper: ResourceHelper,
|
resourceHelper: ResourceHelper,
|
||||||
|
private val aapsSchedulers: AapsSchedulers,
|
||||||
private val sp: SP,
|
private val sp: SP,
|
||||||
private val mainApp: MainApp,
|
private val mainApp: MainApp,
|
||||||
private val fabricPrivacy: FabricPrivacy,
|
private val fabricPrivacy: FabricPrivacy,
|
||||||
|
@ -52,57 +53,57 @@ class WearPlugin @Inject constructor(
|
||||||
super.onStart()
|
super.onStart()
|
||||||
disposable.add(rxBus
|
disposable.add(rxBus
|
||||||
.toObservable(EventOpenAPSUpdateGui::class.java)
|
.toObservable(EventOpenAPSUpdateGui::class.java)
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(aapsSchedulers.io)
|
||||||
.subscribe({ sendDataToWatch(status = true, basals = true, bgValue = false) }) { fabricPrivacy.logException(it) })
|
.subscribe({ sendDataToWatch(status = true, basals = true, bgValue = false) }, fabricPrivacy::logException))
|
||||||
disposable.add(rxBus
|
disposable.add(rxBus
|
||||||
.toObservable(EventExtendedBolusChange::class.java)
|
.toObservable(EventExtendedBolusChange::class.java)
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(aapsSchedulers.io)
|
||||||
.subscribe({ sendDataToWatch(status = true, basals = true, bgValue = false) }) { fabricPrivacy.logException(it) })
|
.subscribe({ sendDataToWatch(status = true, basals = true, bgValue = false) }, fabricPrivacy::logException))
|
||||||
disposable.add(rxBus
|
disposable.add(rxBus
|
||||||
.toObservable(EventTempBasalChange::class.java)
|
.toObservable(EventTempBasalChange::class.java)
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(aapsSchedulers.io)
|
||||||
.subscribe({ sendDataToWatch(status = true, basals = true, bgValue = false) }) { fabricPrivacy.logException(it) })
|
.subscribe({ sendDataToWatch(status = true, basals = true, bgValue = false) }, fabricPrivacy::logException))
|
||||||
disposable.add(rxBus
|
disposable.add(rxBus
|
||||||
.toObservable(EventTreatmentChange::class.java)
|
.toObservable(EventTreatmentChange::class.java)
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(aapsSchedulers.io)
|
||||||
.subscribe({ sendDataToWatch(status = true, basals = true, bgValue = false) }) { fabricPrivacy.logException(it) })
|
.subscribe({ sendDataToWatch(status = true, basals = true, bgValue = false) }, fabricPrivacy::logException))
|
||||||
disposable.add(rxBus
|
disposable.add(rxBus
|
||||||
.toObservable(EventNewBasalProfile::class.java)
|
.toObservable(EventNewBasalProfile::class.java)
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(aapsSchedulers.io)
|
||||||
.subscribe({ sendDataToWatch(status = false, basals = true, bgValue = false) }) { fabricPrivacy.logException(it) })
|
.subscribe({ sendDataToWatch(status = false, basals = true, bgValue = false) }, fabricPrivacy::logException))
|
||||||
disposable.add(rxBus
|
disposable.add(rxBus
|
||||||
.toObservable(EventAutosensCalculationFinished::class.java)
|
.toObservable(EventAutosensCalculationFinished::class.java)
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(aapsSchedulers.io)
|
||||||
.subscribe({ sendDataToWatch(status = true, basals = true, bgValue = true) }) { fabricPrivacy.logException(it) })
|
.subscribe({ sendDataToWatch(status = true, basals = true, bgValue = true) }, fabricPrivacy::logException))
|
||||||
disposable.add(rxBus
|
disposable.add(rxBus
|
||||||
.toObservable(EventPreferenceChange::class.java)
|
.toObservable(EventPreferenceChange::class.java)
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(aapsSchedulers.io)
|
||||||
.subscribe({
|
.subscribe({
|
||||||
// possibly new high or low mark
|
// possibly new high or low mark
|
||||||
resendDataToWatch()
|
resendDataToWatch()
|
||||||
// status may be formatted differently
|
// status may be formatted differently
|
||||||
sendDataToWatch(status = true, basals = false, bgValue = false)
|
sendDataToWatch(status = true, basals = false, bgValue = false)
|
||||||
}) { fabricPrivacy.logException(it) })
|
}, fabricPrivacy::logException))
|
||||||
disposable.add(rxBus
|
disposable.add(rxBus
|
||||||
.toObservable(EventRefreshOverview::class.java)
|
.toObservable(EventRefreshOverview::class.java)
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(aapsSchedulers.io)
|
||||||
.subscribe({
|
.subscribe({
|
||||||
if (WatchUpdaterService.shouldReportLoopStatus(loopPlugin.get().isEnabled(PluginType.LOOP)))
|
if (WatchUpdaterService.shouldReportLoopStatus(loopPlugin.get().isEnabled(PluginType.LOOP)))
|
||||||
sendDataToWatch(status = true, basals = false, bgValue = false)
|
sendDataToWatch(status = true, basals = false, bgValue = false)
|
||||||
}) { fabricPrivacy.logException(it) })
|
}, fabricPrivacy::logException))
|
||||||
disposable.add(rxBus
|
disposable.add(rxBus
|
||||||
.toObservable(EventBolusRequested::class.java)
|
.toObservable(EventBolusRequested::class.java)
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(aapsSchedulers.io)
|
||||||
.subscribe({ event: EventBolusRequested ->
|
.subscribe({ event: EventBolusRequested ->
|
||||||
val status = String.format(resourceHelper.gs(R.string.bolusrequested), event.amount)
|
val status = String.format(resourceHelper.gs(R.string.bolusrequested), event.amount)
|
||||||
val intent = Intent(mainApp, WatchUpdaterService::class.java).setAction(WatchUpdaterService.ACTION_SEND_BOLUSPROGRESS)
|
val intent = Intent(mainApp, WatchUpdaterService::class.java).setAction(WatchUpdaterService.ACTION_SEND_BOLUSPROGRESS)
|
||||||
intent.putExtra("progresspercent", 0)
|
intent.putExtra("progresspercent", 0)
|
||||||
intent.putExtra("progressstatus", status)
|
intent.putExtra("progressstatus", status)
|
||||||
mainApp.startService(intent)
|
mainApp.startService(intent)
|
||||||
}) { fabricPrivacy.logException(it) })
|
}, fabricPrivacy::logException))
|
||||||
disposable.add(rxBus
|
disposable.add(rxBus
|
||||||
.toObservable(EventDismissBolusProgressIfRunning::class.java)
|
.toObservable(EventDismissBolusProgressIfRunning::class.java)
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(aapsSchedulers.io)
|
||||||
.subscribe({ event: EventDismissBolusProgressIfRunning ->
|
.subscribe({ event: EventDismissBolusProgressIfRunning ->
|
||||||
if (event.result == null) return@subscribe
|
if (event.result == null) return@subscribe
|
||||||
val status: String = if (event.result!!.success) {
|
val status: String = if (event.result!!.success) {
|
||||||
|
@ -114,10 +115,10 @@ class WearPlugin @Inject constructor(
|
||||||
intent.putExtra("progresspercent", 100)
|
intent.putExtra("progresspercent", 100)
|
||||||
intent.putExtra("progressstatus", status)
|
intent.putExtra("progressstatus", status)
|
||||||
mainApp.startService(intent)
|
mainApp.startService(intent)
|
||||||
}) { fabricPrivacy.logException(it) })
|
}, fabricPrivacy::logException))
|
||||||
disposable.add(rxBus
|
disposable.add(rxBus
|
||||||
.toObservable(EventOverviewBolusProgress::class.java)
|
.toObservable(EventOverviewBolusProgress::class.java)
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(aapsSchedulers.io)
|
||||||
.subscribe({ event: EventOverviewBolusProgress ->
|
.subscribe({ event: EventOverviewBolusProgress ->
|
||||||
if (!event.isSMB() || sp.getBoolean("wear_notifySMB", true)) {
|
if (!event.isSMB() || sp.getBoolean("wear_notifySMB", true)) {
|
||||||
val intent = Intent(mainApp, WatchUpdaterService::class.java).setAction(WatchUpdaterService.ACTION_SEND_BOLUSPROGRESS)
|
val intent = Intent(mainApp, WatchUpdaterService::class.java).setAction(WatchUpdaterService.ACTION_SEND_BOLUSPROGRESS)
|
||||||
|
@ -125,7 +126,7 @@ class WearPlugin @Inject constructor(
|
||||||
intent.putExtra("progressstatus", event.status)
|
intent.putExtra("progressstatus", event.status)
|
||||||
mainApp.startService(intent)
|
mainApp.startService(intent)
|
||||||
}
|
}
|
||||||
}) { fabricPrivacy.logException(it) })
|
}, fabricPrivacy::logException))
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onStop() {
|
override fun onStop() {
|
||||||
|
|
|
@ -11,19 +11,19 @@ import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
||||||
import info.nightscout.androidaps.interfaces.PluginBase
|
import info.nightscout.androidaps.interfaces.PluginBase
|
||||||
import info.nightscout.androidaps.interfaces.PluginDescription
|
import info.nightscout.androidaps.interfaces.PluginDescription
|
||||||
import info.nightscout.androidaps.interfaces.PluginType
|
import info.nightscout.androidaps.interfaces.PluginType
|
||||||
|
import info.nightscout.androidaps.interfaces.ProfileFunction
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin
|
import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
import info.nightscout.androidaps.interfaces.ProfileFunction
|
|
||||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin
|
||||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventAutosensCalculationFinished
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventAutosensCalculationFinished
|
||||||
import info.nightscout.androidaps.utils.DecimalFormatter
|
import info.nightscout.androidaps.utils.DecimalFormatter
|
||||||
import info.nightscout.androidaps.utils.FabricPrivacy
|
import info.nightscout.androidaps.utils.FabricPrivacy
|
||||||
import info.nightscout.androidaps.utils.extensions.plusAssign
|
import info.nightscout.androidaps.utils.extensions.plusAssign
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
|
import info.nightscout.androidaps.utils.rx.AapsSchedulers
|
||||||
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||||
import io.reactivex.disposables.CompositeDisposable
|
import io.reactivex.disposables.CompositeDisposable
|
||||||
import io.reactivex.schedulers.Schedulers
|
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
import javax.inject.Singleton
|
import javax.inject.Singleton
|
||||||
|
|
||||||
|
@ -33,6 +33,7 @@ class StatusLinePlugin @Inject constructor(
|
||||||
private val sp: SP,
|
private val sp: SP,
|
||||||
private val profileFunction: ProfileFunction,
|
private val profileFunction: ProfileFunction,
|
||||||
resourceHelper: ResourceHelper,
|
resourceHelper: ResourceHelper,
|
||||||
|
private val aapsSchedulers: AapsSchedulers,
|
||||||
private val context: Context,
|
private val context: Context,
|
||||||
private val fabricPrivacy: FabricPrivacy,
|
private val fabricPrivacy: FabricPrivacy,
|
||||||
private val activePlugin: ActivePluginProvider,
|
private val activePlugin: ActivePluginProvider,
|
||||||
|
@ -56,6 +57,7 @@ class StatusLinePlugin @Inject constructor(
|
||||||
private var lastLoopStatus = false
|
private var lastLoopStatus = false
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
//broadcast related constants
|
//broadcast related constants
|
||||||
@Suppress("SpellCheckingInspection")
|
@Suppress("SpellCheckingInspection")
|
||||||
private const val EXTRA_STATUSLINE = "com.eveningoutpost.dexdrip.Extras.Statusline"
|
private const val EXTRA_STATUSLINE = "com.eveningoutpost.dexdrip.Extras.Statusline"
|
||||||
|
@ -70,29 +72,29 @@ class StatusLinePlugin @Inject constructor(
|
||||||
override fun onStart() {
|
override fun onStart() {
|
||||||
super.onStart()
|
super.onStart()
|
||||||
disposable += rxBus.toObservable(EventRefreshOverview::class.java)
|
disposable += rxBus.toObservable(EventRefreshOverview::class.java)
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(aapsSchedulers.io)
|
||||||
.subscribe({ if (lastLoopStatus != loopPlugin.isEnabled(PluginType.LOOP)) sendStatus() }) { fabricPrivacy.logException(it) }
|
.subscribe({ if (lastLoopStatus != loopPlugin.isEnabled(PluginType.LOOP)) sendStatus() }, fabricPrivacy::logException)
|
||||||
disposable += rxBus.toObservable(EventExtendedBolusChange::class.java)
|
disposable += rxBus.toObservable(EventExtendedBolusChange::class.java)
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(aapsSchedulers.io)
|
||||||
.subscribe({ sendStatus() }) { fabricPrivacy.logException(it) }
|
.subscribe({ sendStatus() }, fabricPrivacy::logException)
|
||||||
disposable += rxBus.toObservable(EventTempBasalChange::class.java)
|
disposable += rxBus.toObservable(EventTempBasalChange::class.java)
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(aapsSchedulers.io)
|
||||||
.subscribe({ sendStatus() }) { fabricPrivacy.logException(it) }
|
.subscribe({ sendStatus() }, fabricPrivacy::logException)
|
||||||
disposable += rxBus.toObservable(EventTreatmentChange::class.java)
|
disposable += rxBus.toObservable(EventTreatmentChange::class.java)
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(aapsSchedulers.io)
|
||||||
.subscribe({ sendStatus() }) { fabricPrivacy.logException(it) }
|
.subscribe({ sendStatus() }, fabricPrivacy::logException)
|
||||||
disposable += rxBus.toObservable(EventConfigBuilderChange::class.java)
|
disposable += rxBus.toObservable(EventConfigBuilderChange::class.java)
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(aapsSchedulers.io)
|
||||||
.subscribe({ sendStatus() }) { fabricPrivacy.logException(it) }
|
.subscribe({ sendStatus() }, fabricPrivacy::logException)
|
||||||
disposable += rxBus.toObservable(EventAutosensCalculationFinished::class.java)
|
disposable += rxBus.toObservable(EventAutosensCalculationFinished::class.java)
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(aapsSchedulers.io)
|
||||||
.subscribe({ sendStatus() }) { fabricPrivacy.logException(it) }
|
.subscribe({ sendStatus() }, fabricPrivacy::logException)
|
||||||
disposable += rxBus.toObservable(EventPreferenceChange::class.java)
|
disposable += rxBus.toObservable(EventPreferenceChange::class.java)
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(aapsSchedulers.io)
|
||||||
.subscribe({ sendStatus() }) { fabricPrivacy.logException(it) }
|
.subscribe({ sendStatus() }, fabricPrivacy::logException)
|
||||||
disposable += rxBus.toObservable(EventAppInitialized::class.java)
|
disposable += rxBus.toObservable(EventAppInitialized::class.java)
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(aapsSchedulers.io)
|
||||||
.subscribe({ sendStatus() }) { fabricPrivacy.logException(it) }
|
.subscribe({ sendStatus() }, fabricPrivacy::logException)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onStop() {
|
override fun onStop() {
|
||||||
|
|
|
@ -23,6 +23,7 @@ import info.nightscout.androidaps.data.MealData;
|
||||||
import info.nightscout.androidaps.data.Profile;
|
import info.nightscout.androidaps.data.Profile;
|
||||||
import info.nightscout.androidaps.db.BgReading;
|
import info.nightscout.androidaps.db.BgReading;
|
||||||
import info.nightscout.androidaps.db.TemporaryBasal;
|
import info.nightscout.androidaps.db.TemporaryBasal;
|
||||||
|
import info.nightscout.androidaps.db.Treatment;
|
||||||
import info.nightscout.androidaps.events.Event;
|
import info.nightscout.androidaps.events.Event;
|
||||||
import info.nightscout.androidaps.events.EventAppInitialized;
|
import info.nightscout.androidaps.events.EventAppInitialized;
|
||||||
import info.nightscout.androidaps.events.EventConfigBuilderChange;
|
import info.nightscout.androidaps.events.EventConfigBuilderChange;
|
||||||
|
@ -34,32 +35,32 @@ import info.nightscout.androidaps.interfaces.IobCobCalculatorInterface;
|
||||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||||
import info.nightscout.androidaps.interfaces.PluginDescription;
|
import info.nightscout.androidaps.interfaces.PluginDescription;
|
||||||
import info.nightscout.androidaps.interfaces.PluginType;
|
import info.nightscout.androidaps.interfaces.PluginType;
|
||||||
|
import info.nightscout.androidaps.interfaces.ProfileFunction;
|
||||||
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.bus.RxBusWrapper;
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper;
|
||||||
import info.nightscout.androidaps.interfaces.ProfileFunction;
|
|
||||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.data.AutosensData;
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.data.AutosensData;
|
||||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventNewHistoryBgData;
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventNewHistoryBgData;
|
||||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventNewHistoryData;
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventNewHistoryData;
|
||||||
import info.nightscout.androidaps.plugins.sensitivity.SensitivityAAPSPlugin;
|
import info.nightscout.androidaps.plugins.sensitivity.SensitivityAAPSPlugin;
|
||||||
import info.nightscout.androidaps.plugins.sensitivity.SensitivityOref1Plugin;
|
import info.nightscout.androidaps.plugins.sensitivity.SensitivityOref1Plugin;
|
||||||
import info.nightscout.androidaps.plugins.sensitivity.SensitivityWeightedAveragePlugin;
|
import info.nightscout.androidaps.plugins.sensitivity.SensitivityWeightedAveragePlugin;
|
||||||
import info.nightscout.androidaps.db.Treatment;
|
|
||||||
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin;
|
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin;
|
||||||
import info.nightscout.androidaps.utils.DateUtil;
|
import info.nightscout.androidaps.utils.DateUtil;
|
||||||
import info.nightscout.androidaps.utils.DecimalFormatter;
|
import info.nightscout.androidaps.utils.DecimalFormatter;
|
||||||
import info.nightscout.androidaps.utils.FabricPrivacy;
|
import info.nightscout.androidaps.utils.FabricPrivacy;
|
||||||
import info.nightscout.androidaps.utils.T;
|
import info.nightscout.androidaps.utils.T;
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper;
|
import info.nightscout.androidaps.utils.resources.ResourceHelper;
|
||||||
|
import info.nightscout.androidaps.utils.rx.AapsSchedulers;
|
||||||
import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
||||||
import io.reactivex.disposables.CompositeDisposable;
|
import io.reactivex.disposables.CompositeDisposable;
|
||||||
import io.reactivex.schedulers.Schedulers;
|
|
||||||
|
|
||||||
import static info.nightscout.androidaps.utils.DateUtil.now;
|
import static info.nightscout.androidaps.utils.DateUtil.now;
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
public class IobCobCalculatorPlugin extends PluginBase implements IobCobCalculatorInterface {
|
public class IobCobCalculatorPlugin extends PluginBase implements IobCobCalculatorInterface {
|
||||||
private final HasAndroidInjector injector;
|
private final HasAndroidInjector injector;
|
||||||
|
private final AapsSchedulers aapsSchedulers;
|
||||||
private final SP sp;
|
private final SP sp;
|
||||||
private final RxBusWrapper rxBus;
|
private final RxBusWrapper rxBus;
|
||||||
private final ResourceHelper resourceHelper;
|
private final ResourceHelper resourceHelper;
|
||||||
|
@ -96,6 +97,7 @@ public class IobCobCalculatorPlugin extends PluginBase implements IobCobCalculat
|
||||||
public IobCobCalculatorPlugin(
|
public IobCobCalculatorPlugin(
|
||||||
HasAndroidInjector injector,
|
HasAndroidInjector injector,
|
||||||
AAPSLogger aapsLogger,
|
AAPSLogger aapsLogger,
|
||||||
|
AapsSchedulers aapsSchedulers,
|
||||||
RxBusWrapper rxBus,
|
RxBusWrapper rxBus,
|
||||||
SP sp,
|
SP sp,
|
||||||
ResourceHelper resourceHelper,
|
ResourceHelper resourceHelper,
|
||||||
|
@ -117,6 +119,7 @@ public class IobCobCalculatorPlugin extends PluginBase implements IobCobCalculat
|
||||||
aapsLogger, resourceHelper, injector
|
aapsLogger, resourceHelper, injector
|
||||||
);
|
);
|
||||||
this.injector = injector;
|
this.injector = injector;
|
||||||
|
this.aapsSchedulers = aapsSchedulers;
|
||||||
this.sp = sp;
|
this.sp = sp;
|
||||||
this.rxBus = rxBus;
|
this.rxBus = rxBus;
|
||||||
this.resourceHelper = resourceHelper;
|
this.resourceHelper = resourceHelper;
|
||||||
|
@ -136,7 +139,7 @@ public class IobCobCalculatorPlugin extends PluginBase implements IobCobCalculat
|
||||||
// EventConfigBuilderChange
|
// EventConfigBuilderChange
|
||||||
disposable.add(rxBus
|
disposable.add(rxBus
|
||||||
.toObservable(EventConfigBuilderChange.class)
|
.toObservable(EventConfigBuilderChange.class)
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(aapsSchedulers.getIo())
|
||||||
.subscribe(event -> {
|
.subscribe(event -> {
|
||||||
stopCalculation("onEventConfigBuilderChange");
|
stopCalculation("onEventConfigBuilderChange");
|
||||||
synchronized (dataLock) {
|
synchronized (dataLock) {
|
||||||
|
@ -149,7 +152,7 @@ public class IobCobCalculatorPlugin extends PluginBase implements IobCobCalculat
|
||||||
// EventNewBasalProfile
|
// EventNewBasalProfile
|
||||||
disposable.add(rxBus
|
disposable.add(rxBus
|
||||||
.toObservable(EventNewBasalProfile.class)
|
.toObservable(EventNewBasalProfile.class)
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(aapsSchedulers.getIo())
|
||||||
.subscribe(event -> {
|
.subscribe(event -> {
|
||||||
if (event == null) { // on init no need of reset
|
if (event == null) { // on init no need of reset
|
||||||
return;
|
return;
|
||||||
|
@ -165,7 +168,7 @@ public class IobCobCalculatorPlugin extends PluginBase implements IobCobCalculat
|
||||||
// EventNewBG .... cannot be used for invalidating because only event with last BG is fired
|
// EventNewBG .... cannot be used for invalidating because only event with last BG is fired
|
||||||
disposable.add(rxBus
|
disposable.add(rxBus
|
||||||
.toObservable(EventNewBG.class)
|
.toObservable(EventNewBG.class)
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(aapsSchedulers.getIo())
|
||||||
.subscribe(event -> {
|
.subscribe(event -> {
|
||||||
stopCalculation("onEventNewBG");
|
stopCalculation("onEventNewBG");
|
||||||
runCalculation("onEventNewBG", System.currentTimeMillis(), true, true, event);
|
runCalculation("onEventNewBG", System.currentTimeMillis(), true, true, event);
|
||||||
|
@ -174,7 +177,7 @@ public class IobCobCalculatorPlugin extends PluginBase implements IobCobCalculat
|
||||||
// EventPreferenceChange
|
// EventPreferenceChange
|
||||||
disposable.add(rxBus
|
disposable.add(rxBus
|
||||||
.toObservable(EventPreferenceChange.class)
|
.toObservable(EventPreferenceChange.class)
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(aapsSchedulers.getIo())
|
||||||
.subscribe(event -> {
|
.subscribe(event -> {
|
||||||
if (event.isChanged(resourceHelper, R.string.key_openapsama_autosens_period) ||
|
if (event.isChanged(resourceHelper, R.string.key_openapsama_autosens_period) ||
|
||||||
event.isChanged(resourceHelper, R.string.key_age) ||
|
event.isChanged(resourceHelper, R.string.key_age) ||
|
||||||
|
@ -197,19 +200,19 @@ public class IobCobCalculatorPlugin extends PluginBase implements IobCobCalculat
|
||||||
// EventAppInitialized
|
// EventAppInitialized
|
||||||
disposable.add(rxBus
|
disposable.add(rxBus
|
||||||
.toObservable(EventAppInitialized.class)
|
.toObservable(EventAppInitialized.class)
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(aapsSchedulers.getIo())
|
||||||
.subscribe(event -> runCalculation("onEventAppInitialized", System.currentTimeMillis(), true, true, event), fabricPrivacy::logException)
|
.subscribe(event -> runCalculation("onEventAppInitialized", System.currentTimeMillis(), true, true, event), fabricPrivacy::logException)
|
||||||
);
|
);
|
||||||
// EventNewHistoryData
|
// EventNewHistoryData
|
||||||
disposable.add(rxBus
|
disposable.add(rxBus
|
||||||
.toObservable(EventNewHistoryData.class)
|
.toObservable(EventNewHistoryData.class)
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(aapsSchedulers.getIo())
|
||||||
.subscribe(event -> newHistoryData(event, false), fabricPrivacy::logException)
|
.subscribe(event -> newHistoryData(event, false), fabricPrivacy::logException)
|
||||||
);
|
);
|
||||||
// EventNewHistoryBgData
|
// EventNewHistoryBgData
|
||||||
disposable.add(rxBus
|
disposable.add(rxBus
|
||||||
.toObservable(EventNewHistoryBgData.class)
|
.toObservable(EventNewHistoryBgData.class)
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(aapsSchedulers.getIo())
|
||||||
.subscribe(event -> newHistoryData(new EventNewHistoryData(event.getTimestamp()), true), fabricPrivacy::logException)
|
.subscribe(event -> newHistoryData(new EventNewHistoryData(event.getTimestamp()), true), fabricPrivacy::logException)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ import info.nightscout.androidaps.utils.*
|
||||||
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
|
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
|
||||||
import info.nightscout.androidaps.utils.extensions.plusAssign
|
import info.nightscout.androidaps.utils.extensions.plusAssign
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
import info.nightscout.androidaps.utils.rx.AapsSchedulers
|
||||||
import io.reactivex.disposables.CompositeDisposable
|
import io.reactivex.disposables.CompositeDisposable
|
||||||
import java.text.DecimalFormat
|
import java.text.DecimalFormat
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
@ -37,6 +37,7 @@ class LocalProfileFragment : DaggerFragment() {
|
||||||
@Inject lateinit var localProfilePlugin: LocalProfilePlugin
|
@Inject lateinit var localProfilePlugin: LocalProfilePlugin
|
||||||
@Inject lateinit var hardLimits: HardLimits
|
@Inject lateinit var hardLimits: HardLimits
|
||||||
@Inject lateinit var dateUtil: DateUtil
|
@Inject lateinit var dateUtil: DateUtil
|
||||||
|
@Inject lateinit var aapsSchedulers: AapsSchedulers
|
||||||
|
|
||||||
private var disposable: CompositeDisposable = CompositeDisposable()
|
private var disposable: CompositeDisposable = CompositeDisposable()
|
||||||
|
|
||||||
|
@ -213,9 +214,8 @@ class LocalProfileFragment : DaggerFragment() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
disposable += rxBus
|
disposable += rxBus
|
||||||
.toObservable(EventLocalProfileChanged::class.java)
|
.toObservable(EventLocalProfileChanged::class.java)
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(aapsSchedulers.main)
|
||||||
.subscribe({ build() }, { fabricPrivacy.logException(it) }
|
.subscribe({ build() },fabricPrivacy::logException)
|
||||||
)
|
|
||||||
build()
|
build()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ import info.nightscout.androidaps.utils.FabricPrivacy
|
||||||
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
|
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
|
||||||
import info.nightscout.androidaps.utils.extensions.plusAssign
|
import info.nightscout.androidaps.utils.extensions.plusAssign
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
import info.nightscout.androidaps.utils.rx.AapsSchedulers
|
||||||
import io.reactivex.disposables.CompositeDisposable
|
import io.reactivex.disposables.CompositeDisposable
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
@ -31,6 +31,7 @@ class NSProfileFragment : DaggerFragment() {
|
||||||
@Inject lateinit var fabricPrivacy: FabricPrivacy
|
@Inject lateinit var fabricPrivacy: FabricPrivacy
|
||||||
@Inject lateinit var profileFunction: ProfileFunction
|
@Inject lateinit var profileFunction: ProfileFunction
|
||||||
@Inject lateinit var nsProfilePlugin: NSProfilePlugin
|
@Inject lateinit var nsProfilePlugin: NSProfilePlugin
|
||||||
|
@Inject lateinit var aapsSchedulers: AapsSchedulers
|
||||||
|
|
||||||
private var disposable: CompositeDisposable = CompositeDisposable()
|
private var disposable: CompositeDisposable = CompositeDisposable()
|
||||||
|
|
||||||
|
@ -117,8 +118,8 @@ class NSProfileFragment : DaggerFragment() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
disposable += rxBus
|
disposable += rxBus
|
||||||
.toObservable(EventNSProfileUpdateGUI::class.java)
|
.toObservable(EventNSProfileUpdateGUI::class.java)
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(aapsSchedulers.main)
|
||||||
.subscribe({ updateGUI() }, { fabricPrivacy.logException(it) })
|
.subscribe({ updateGUI() }, fabricPrivacy::logException)
|
||||||
updateGUI()
|
updateGUI()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.combo;
|
package info.nightscout.androidaps.plugins.pump.combo;
|
||||||
|
|
||||||
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.graphics.Typeface;
|
import android.graphics.Typeface;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
@ -28,8 +27,8 @@ import info.nightscout.androidaps.queue.events.EventQueueChanged;
|
||||||
import info.nightscout.androidaps.utils.DateUtil;
|
import info.nightscout.androidaps.utils.DateUtil;
|
||||||
import info.nightscout.androidaps.utils.FabricPrivacy;
|
import info.nightscout.androidaps.utils.FabricPrivacy;
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper;
|
import info.nightscout.androidaps.utils.resources.ResourceHelper;
|
||||||
|
import info.nightscout.androidaps.utils.rx.AapsSchedulers;
|
||||||
import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
|
||||||
import io.reactivex.disposables.CompositeDisposable;
|
import io.reactivex.disposables.CompositeDisposable;
|
||||||
|
|
||||||
public class ComboFragment extends DaggerFragment implements View.OnClickListener {
|
public class ComboFragment extends DaggerFragment implements View.OnClickListener {
|
||||||
|
@ -39,6 +38,7 @@ public class ComboFragment extends DaggerFragment implements View.OnClickListene
|
||||||
@Inject RxBusWrapper rxBus;
|
@Inject RxBusWrapper rxBus;
|
||||||
@Inject SP sp;
|
@Inject SP sp;
|
||||||
@Inject FabricPrivacy fabricPrivacy;
|
@Inject FabricPrivacy fabricPrivacy;
|
||||||
|
@Inject AapsSchedulers aapsSchedulers;
|
||||||
|
|
||||||
private final CompositeDisposable disposable = new CompositeDisposable();
|
private final CompositeDisposable disposable = new CompositeDisposable();
|
||||||
|
|
||||||
|
@ -81,12 +81,12 @@ public class ComboFragment extends DaggerFragment implements View.OnClickListene
|
||||||
super.onResume();
|
super.onResume();
|
||||||
disposable.add(rxBus
|
disposable.add(rxBus
|
||||||
.toObservable(EventComboPumpUpdateGUI.class)
|
.toObservable(EventComboPumpUpdateGUI.class)
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(aapsSchedulers.getMain())
|
||||||
.subscribe(event -> updateGui(), fabricPrivacy::logException)
|
.subscribe(event -> updateGui(), fabricPrivacy::logException)
|
||||||
);
|
);
|
||||||
disposable.add(rxBus
|
disposable.add(rxBus
|
||||||
.toObservable(EventQueueChanged.class)
|
.toObservable(EventQueueChanged.class)
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(aapsSchedulers.getMain())
|
||||||
.subscribe(event -> updateGui(), fabricPrivacy::logException)
|
.subscribe(event -> updateGui(), fabricPrivacy::logException)
|
||||||
);
|
);
|
||||||
updateGui();
|
updateGui();
|
||||||
|
|
|
@ -35,7 +35,7 @@ import info.nightscout.androidaps.utils.DateUtil;
|
||||||
import info.nightscout.androidaps.utils.DecimalFormatter;
|
import info.nightscout.androidaps.utils.DecimalFormatter;
|
||||||
import info.nightscout.androidaps.utils.FabricPrivacy;
|
import info.nightscout.androidaps.utils.FabricPrivacy;
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper;
|
import info.nightscout.androidaps.utils.resources.ResourceHelper;
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
import info.nightscout.androidaps.utils.rx.AapsSchedulers;
|
||||||
import io.reactivex.disposables.CompositeDisposable;
|
import io.reactivex.disposables.CompositeDisposable;
|
||||||
|
|
||||||
public class LocalInsightFragment extends DaggerFragment implements View.OnClickListener {
|
public class LocalInsightFragment extends DaggerFragment implements View.OnClickListener {
|
||||||
|
@ -45,6 +45,7 @@ public class LocalInsightFragment extends DaggerFragment implements View.OnClick
|
||||||
@Inject ResourceHelper resourceHelper;
|
@Inject ResourceHelper resourceHelper;
|
||||||
@Inject FabricPrivacy fabricPrivacy;
|
@Inject FabricPrivacy fabricPrivacy;
|
||||||
@Inject DateUtil dateUtil;
|
@Inject DateUtil dateUtil;
|
||||||
|
@Inject AapsSchedulers aapsSchedulers;
|
||||||
|
|
||||||
private final CompositeDisposable disposable = new CompositeDisposable();
|
private final CompositeDisposable disposable = new CompositeDisposable();
|
||||||
|
|
||||||
|
@ -80,7 +81,7 @@ public class LocalInsightFragment extends DaggerFragment implements View.OnClick
|
||||||
super.onResume();
|
super.onResume();
|
||||||
disposable.add(rxBus
|
disposable.add(rxBus
|
||||||
.toObservable(EventLocalInsightUpdateGUI.class)
|
.toObservable(EventLocalInsightUpdateGUI.class)
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(aapsSchedulers.getMain())
|
||||||
.subscribe(event -> updateGUI(), fabricPrivacy::logException)
|
.subscribe(event -> updateGUI(), fabricPrivacy::logException)
|
||||||
);
|
);
|
||||||
updateGUI();
|
updateGUI();
|
||||||
|
|
|
@ -17,7 +17,7 @@ import info.nightscout.androidaps.utils.FabricPrivacy
|
||||||
import info.nightscout.androidaps.utils.T
|
import info.nightscout.androidaps.utils.T
|
||||||
import info.nightscout.androidaps.utils.extensions.plusAssign
|
import info.nightscout.androidaps.utils.extensions.plusAssign
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
import info.nightscout.androidaps.utils.rx.AapsSchedulers
|
||||||
import io.reactivex.disposables.CompositeDisposable
|
import io.reactivex.disposables.CompositeDisposable
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
@ -28,6 +28,7 @@ class VirtualPumpFragment : DaggerFragment() {
|
||||||
@Inject lateinit var fabricPrivacy: FabricPrivacy
|
@Inject lateinit var fabricPrivacy: FabricPrivacy
|
||||||
@Inject lateinit var virtualPumpPlugin: VirtualPumpPlugin
|
@Inject lateinit var virtualPumpPlugin: VirtualPumpPlugin
|
||||||
@Inject lateinit var treatmentsPlugin: TreatmentsPlugin
|
@Inject lateinit var treatmentsPlugin: TreatmentsPlugin
|
||||||
|
@Inject lateinit var aapsSchedulers: AapsSchedulers
|
||||||
|
|
||||||
private val disposable = CompositeDisposable()
|
private val disposable = CompositeDisposable()
|
||||||
|
|
||||||
|
@ -57,16 +58,16 @@ class VirtualPumpFragment : DaggerFragment() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
disposable += rxBus
|
disposable += rxBus
|
||||||
.toObservable(EventVirtualPumpUpdateGui::class.java)
|
.toObservable(EventVirtualPumpUpdateGui::class.java)
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(aapsSchedulers.main)
|
||||||
.subscribe({ updateGui() }, { fabricPrivacy.logException(it) })
|
.subscribe({ updateGui() }, fabricPrivacy::logException)
|
||||||
disposable += rxBus
|
disposable += rxBus
|
||||||
.toObservable(EventTempBasalChange::class.java)
|
.toObservable(EventTempBasalChange::class.java)
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(aapsSchedulers.main)
|
||||||
.subscribe({ updateGui() }, { fabricPrivacy.logException(it) })
|
.subscribe({ updateGui() }, fabricPrivacy::logException)
|
||||||
disposable += rxBus
|
disposable += rxBus
|
||||||
.toObservable(EventExtendedBolusChange::class.java)
|
.toObservable(EventExtendedBolusChange::class.java)
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(aapsSchedulers.main)
|
||||||
.subscribe({ updateGui() }, { fabricPrivacy.logException(it) })
|
.subscribe({ updateGui() }, fabricPrivacy::logException)
|
||||||
loopHandler.postDelayed(refreshLoop, T.mins(1).msecs())
|
loopHandler.postDelayed(refreshLoop, T.mins(1).msecs())
|
||||||
updateGui()
|
updateGui()
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,22 +20,22 @@ import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
import info.nightscout.androidaps.plugins.common.ManufacturerType
|
import info.nightscout.androidaps.plugins.common.ManufacturerType
|
||||||
import info.nightscout.androidaps.plugins.general.actions.defs.CustomAction
|
import info.nightscout.androidaps.plugins.general.actions.defs.CustomAction
|
||||||
import info.nightscout.androidaps.plugins.general.actions.defs.CustomActionType
|
import info.nightscout.androidaps.plugins.general.actions.defs.CustomActionType
|
||||||
import info.nightscout.androidaps.queue.commands.CustomCommand
|
|
||||||
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification
|
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification
|
||||||
import info.nightscout.androidaps.plugins.general.overview.events.EventOverviewBolusProgress
|
import info.nightscout.androidaps.plugins.general.overview.events.EventOverviewBolusProgress
|
||||||
import info.nightscout.androidaps.plugins.general.overview.notifications.Notification
|
import info.nightscout.androidaps.plugins.general.overview.notifications.Notification
|
||||||
import info.nightscout.androidaps.plugins.pump.common.defs.PumpType
|
import info.nightscout.androidaps.plugins.pump.common.defs.PumpType
|
||||||
import info.nightscout.androidaps.plugins.pump.virtual.events.EventVirtualPumpUpdateGui
|
import info.nightscout.androidaps.plugins.pump.virtual.events.EventVirtualPumpUpdateGui
|
||||||
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin
|
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin
|
||||||
|
import info.nightscout.androidaps.queue.commands.CustomCommand
|
||||||
import info.nightscout.androidaps.utils.DateUtil
|
import info.nightscout.androidaps.utils.DateUtil
|
||||||
import info.nightscout.androidaps.utils.FabricPrivacy
|
import info.nightscout.androidaps.utils.FabricPrivacy
|
||||||
import info.nightscout.androidaps.utils.InstanceId.instanceId
|
import info.nightscout.androidaps.utils.InstanceId.instanceId
|
||||||
import info.nightscout.androidaps.utils.TimeChangeType
|
import info.nightscout.androidaps.utils.TimeChangeType
|
||||||
import info.nightscout.androidaps.utils.extensions.plusAssign
|
import info.nightscout.androidaps.utils.extensions.plusAssign
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
|
import info.nightscout.androidaps.utils.rx.AapsSchedulers
|
||||||
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||||
import io.reactivex.disposables.CompositeDisposable
|
import io.reactivex.disposables.CompositeDisposable
|
||||||
import io.reactivex.schedulers.Schedulers
|
|
||||||
import org.json.JSONException
|
import org.json.JSONException
|
||||||
import org.json.JSONObject
|
import org.json.JSONObject
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
@ -49,6 +49,7 @@ class VirtualPumpPlugin @Inject constructor(
|
||||||
private val rxBus: RxBusWrapper,
|
private val rxBus: RxBusWrapper,
|
||||||
private var fabricPrivacy: FabricPrivacy,
|
private var fabricPrivacy: FabricPrivacy,
|
||||||
resourceHelper: ResourceHelper,
|
resourceHelper: ResourceHelper,
|
||||||
|
private val aapsSchedulers: AapsSchedulers,
|
||||||
private val sp: SP,
|
private val sp: SP,
|
||||||
private val profileFunction: ProfileFunction,
|
private val profileFunction: ProfileFunction,
|
||||||
private val treatmentsPlugin: TreatmentsPlugin,
|
private val treatmentsPlugin: TreatmentsPlugin,
|
||||||
|
@ -67,7 +68,6 @@ class VirtualPumpPlugin @Inject constructor(
|
||||||
injector, aapsLogger, resourceHelper, commandQueue
|
injector, aapsLogger, resourceHelper, commandQueue
|
||||||
), PumpInterface {
|
), PumpInterface {
|
||||||
|
|
||||||
|
|
||||||
private val disposable = CompositeDisposable()
|
private val disposable = CompositeDisposable()
|
||||||
var batteryPercent = 50
|
var batteryPercent = 50
|
||||||
var reservoirInUnits = 50
|
var reservoirInUnits = 50
|
||||||
|
@ -112,8 +112,8 @@ class VirtualPumpPlugin @Inject constructor(
|
||||||
super.onStart()
|
super.onStart()
|
||||||
disposable += rxBus
|
disposable += rxBus
|
||||||
.toObservable(EventPreferenceChange::class.java)
|
.toObservable(EventPreferenceChange::class.java)
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(aapsSchedulers.io)
|
||||||
.subscribe({ event: EventPreferenceChange -> if (event.isChanged(resourceHelper, R.string.key_virtualpump_type)) refreshConfiguration() }) { fabricPrivacy.logException(it) }
|
.subscribe({ event: EventPreferenceChange -> if (event.isChanged(resourceHelper, R.string.key_virtualpump_type)) refreshConfiguration() }, fabricPrivacy::logException)
|
||||||
refreshConfiguration()
|
refreshConfiguration()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@ import info.nightscout.androidaps.utils.T
|
||||||
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
|
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
|
||||||
import info.nightscout.androidaps.utils.extensions.toVisibility
|
import info.nightscout.androidaps.utils.extensions.toVisibility
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
import info.nightscout.androidaps.utils.rx.AapsSchedulers
|
||||||
import io.reactivex.disposables.CompositeDisposable
|
import io.reactivex.disposables.CompositeDisposable
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
@ -41,6 +41,7 @@ class BGSourceFragment : DaggerFragment() {
|
||||||
@Inject lateinit var profileFunction: ProfileFunction
|
@Inject lateinit var profileFunction: ProfileFunction
|
||||||
@Inject lateinit var dateUtil: DateUtil
|
@Inject lateinit var dateUtil: DateUtil
|
||||||
@Inject lateinit var databaseHelper: DatabaseHelperInterface
|
@Inject lateinit var databaseHelper: DatabaseHelperInterface
|
||||||
|
@Inject lateinit var aapsSchedulers: AapsSchedulers
|
||||||
|
|
||||||
private val disposable = CompositeDisposable()
|
private val disposable = CompositeDisposable()
|
||||||
private val millsToThePast = T.hours(12).msecs()
|
private val millsToThePast = T.hours(12).msecs()
|
||||||
|
@ -68,13 +69,13 @@ class BGSourceFragment : DaggerFragment() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
disposable.add(rxBus
|
disposable.add(rxBus
|
||||||
.toObservable(EventNewBG::class.java)
|
.toObservable(EventNewBG::class.java)
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(aapsSchedulers.main)
|
||||||
.subscribe({ updateGUI() }) { fabricPrivacy.logException(it) }
|
.subscribe({ updateGUI() }, fabricPrivacy::logException)
|
||||||
)
|
)
|
||||||
disposable.add(rxBus
|
disposable.add(rxBus
|
||||||
.toObservable(EventNewHistoryBgData::class.java)
|
.toObservable(EventNewHistoryBgData::class.java)
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(aapsSchedulers.main)
|
||||||
.subscribe({ updateGUI() }) { fabricPrivacy.logException(it) }
|
.subscribe({ updateGUI() }, fabricPrivacy::logException)
|
||||||
)
|
)
|
||||||
updateGUI()
|
updateGUI()
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,8 +49,8 @@ import info.nightscout.androidaps.plugins.pump.medtronic.data.MedtronicHistoryDa
|
||||||
import info.nightscout.androidaps.utils.DateUtil;
|
import info.nightscout.androidaps.utils.DateUtil;
|
||||||
import info.nightscout.androidaps.utils.FabricPrivacy;
|
import info.nightscout.androidaps.utils.FabricPrivacy;
|
||||||
import info.nightscout.androidaps.utils.JsonHelper;
|
import info.nightscout.androidaps.utils.JsonHelper;
|
||||||
|
import info.nightscout.androidaps.utils.rx.AapsSchedulers;
|
||||||
import io.reactivex.disposables.CompositeDisposable;
|
import io.reactivex.disposables.CompositeDisposable;
|
||||||
import io.reactivex.schedulers.Schedulers;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -65,6 +65,7 @@ public class TreatmentService extends OrmLiteBaseService<DatabaseHelper> {
|
||||||
@Inject MedtronicPumpPlugin medtronicPumpPlugin;
|
@Inject MedtronicPumpPlugin medtronicPumpPlugin;
|
||||||
@Inject DatabaseHelperInterface databaseHelper;
|
@Inject DatabaseHelperInterface databaseHelper;
|
||||||
@Inject OpenHumansUploader openHumansUploader;
|
@Inject OpenHumansUploader openHumansUploader;
|
||||||
|
@Inject AapsSchedulers aapsSchedulers;
|
||||||
|
|
||||||
private final CompositeDisposable disposable = new CompositeDisposable();
|
private final CompositeDisposable disposable = new CompositeDisposable();
|
||||||
|
|
||||||
|
@ -77,7 +78,7 @@ public class TreatmentService extends OrmLiteBaseService<DatabaseHelper> {
|
||||||
dbInitialize();
|
dbInitialize();
|
||||||
disposable.add(rxBus
|
disposable.add(rxBus
|
||||||
.toObservable(EventNsTreatment.class)
|
.toObservable(EventNsTreatment.class)
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(aapsSchedulers.getIo())
|
||||||
.subscribe(event -> {
|
.subscribe(event -> {
|
||||||
int mode = event.getMode();
|
int mode = event.getMode();
|
||||||
JSONObject payload = event.getPayload();
|
JSONObject payload = event.getPayload();
|
||||||
|
|
|
@ -17,7 +17,7 @@ import info.nightscout.androidaps.utils.FabricPrivacy
|
||||||
import info.nightscout.androidaps.utils.extensions.plusAssign
|
import info.nightscout.androidaps.utils.extensions.plusAssign
|
||||||
import info.nightscout.androidaps.utils.extensions.toVisibility
|
import info.nightscout.androidaps.utils.extensions.toVisibility
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
import info.nightscout.androidaps.utils.rx.AapsSchedulers
|
||||||
import io.reactivex.disposables.CompositeDisposable
|
import io.reactivex.disposables.CompositeDisposable
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
@ -28,6 +28,7 @@ class TreatmentsFragment : DaggerFragment() {
|
||||||
@Inject lateinit var fabricPrivacy: FabricPrivacy
|
@Inject lateinit var fabricPrivacy: FabricPrivacy
|
||||||
@Inject lateinit var activePlugin: ActivePluginProvider
|
@Inject lateinit var activePlugin: ActivePluginProvider
|
||||||
@Inject lateinit var treatmentsPlugin: TreatmentsPlugin
|
@Inject lateinit var treatmentsPlugin: TreatmentsPlugin
|
||||||
|
@Inject lateinit var aapsSchedulers: AapsSchedulers
|
||||||
|
|
||||||
private val disposable = CompositeDisposable()
|
private val disposable = CompositeDisposable()
|
||||||
|
|
||||||
|
@ -76,7 +77,7 @@ class TreatmentsFragment : DaggerFragment() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
disposable += rxBus
|
disposable += rxBus
|
||||||
.toObservable(EventExtendedBolusChange::class.java)
|
.toObservable(EventExtendedBolusChange::class.java)
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(aapsSchedulers.main)
|
||||||
.subscribe({ updateGui() }, fabricPrivacy::logException)
|
.subscribe({ updateGui() }, fabricPrivacy::logException)
|
||||||
updateGui()
|
updateGui()
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,14 +62,15 @@ import info.nightscout.androidaps.utils.DateUtil;
|
||||||
import info.nightscout.androidaps.utils.FabricPrivacy;
|
import info.nightscout.androidaps.utils.FabricPrivacy;
|
||||||
import info.nightscout.androidaps.utils.T;
|
import info.nightscout.androidaps.utils.T;
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper;
|
import info.nightscout.androidaps.utils.resources.ResourceHelper;
|
||||||
|
import info.nightscout.androidaps.utils.rx.AapsSchedulers;
|
||||||
import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
||||||
import io.reactivex.disposables.CompositeDisposable;
|
import io.reactivex.disposables.CompositeDisposable;
|
||||||
import io.reactivex.schedulers.Schedulers;
|
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface {
|
public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface {
|
||||||
|
|
||||||
private final Context context;
|
private final Context context;
|
||||||
|
private final AapsSchedulers aapsSchedulers;
|
||||||
private final SP sp;
|
private final SP sp;
|
||||||
private final RxBusWrapper rxBus;
|
private final RxBusWrapper rxBus;
|
||||||
private final ResourceHelper resourceHelper;
|
private final ResourceHelper resourceHelper;
|
||||||
|
@ -98,6 +99,7 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface
|
||||||
HasAndroidInjector injector,
|
HasAndroidInjector injector,
|
||||||
AAPSLogger aapsLogger,
|
AAPSLogger aapsLogger,
|
||||||
RxBusWrapper rxBus,
|
RxBusWrapper rxBus,
|
||||||
|
AapsSchedulers aapsSchedulers,
|
||||||
ResourceHelper resourceHelper,
|
ResourceHelper resourceHelper,
|
||||||
Context context,
|
Context context,
|
||||||
SP sp,
|
SP sp,
|
||||||
|
@ -122,6 +124,7 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface
|
||||||
this.resourceHelper = resourceHelper;
|
this.resourceHelper = resourceHelper;
|
||||||
this.context = context;
|
this.context = context;
|
||||||
this.rxBus = rxBus;
|
this.rxBus = rxBus;
|
||||||
|
this.aapsSchedulers = aapsSchedulers;
|
||||||
this.sp = sp;
|
this.sp = sp;
|
||||||
this.profileFunction = profileFunction;
|
this.profileFunction = profileFunction;
|
||||||
this.activePlugin = activePlugin;
|
this.activePlugin = activePlugin;
|
||||||
|
@ -138,7 +141,7 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface
|
||||||
super.onStart();
|
super.onStart();
|
||||||
disposable.add(rxBus
|
disposable.add(rxBus
|
||||||
.toObservable(EventReloadTreatmentData.class)
|
.toObservable(EventReloadTreatmentData.class)
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(aapsSchedulers.getIo())
|
||||||
.subscribe(event -> {
|
.subscribe(event -> {
|
||||||
getAapsLogger().debug(LTag.DATATREATMENTS, "EventReloadTreatmentData");
|
getAapsLogger().debug(LTag.DATATREATMENTS, "EventReloadTreatmentData");
|
||||||
initializeTreatmentData(range());
|
initializeTreatmentData(range());
|
||||||
|
@ -150,19 +153,19 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface
|
||||||
));
|
));
|
||||||
disposable.add(rxBus
|
disposable.add(rxBus
|
||||||
.toObservable(EventReloadProfileSwitchData.class)
|
.toObservable(EventReloadProfileSwitchData.class)
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(aapsSchedulers.getIo())
|
||||||
.subscribe(event -> initializeProfileSwitchData(range()),
|
.subscribe(event -> initializeProfileSwitchData(range()),
|
||||||
fabricPrivacy::logException
|
fabricPrivacy::logException
|
||||||
));
|
));
|
||||||
disposable.add(rxBus
|
disposable.add(rxBus
|
||||||
.toObservable(EventTempTargetChange.class)
|
.toObservable(EventTempTargetChange.class)
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(aapsSchedulers.getIo())
|
||||||
.subscribe(event -> initializeTempTargetData(range()),
|
.subscribe(event -> initializeTempTargetData(range()),
|
||||||
fabricPrivacy::logException
|
fabricPrivacy::logException
|
||||||
));
|
));
|
||||||
disposable.add(rxBus
|
disposable.add(rxBus
|
||||||
.toObservable(EventReloadTempBasalData.class)
|
.toObservable(EventReloadTempBasalData.class)
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(aapsSchedulers.getIo())
|
||||||
.subscribe(event -> {
|
.subscribe(event -> {
|
||||||
getAapsLogger().debug(LTag.DATATREATMENTS, "EventReloadTempBasalData");
|
getAapsLogger().debug(LTag.DATATREATMENTS, "EventReloadTempBasalData");
|
||||||
initializeTempBasalData(range());
|
initializeTempBasalData(range());
|
||||||
|
|
|
@ -28,8 +28,8 @@ import info.nightscout.androidaps.utils.FabricPrivacy
|
||||||
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
|
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
|
||||||
import info.nightscout.androidaps.utils.buildHelper.BuildHelper
|
import info.nightscout.androidaps.utils.buildHelper.BuildHelper
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
|
import info.nightscout.androidaps.utils.rx.AapsSchedulers
|
||||||
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
|
||||||
import io.reactivex.disposables.CompositeDisposable
|
import io.reactivex.disposables.CompositeDisposable
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
@ -47,6 +47,7 @@ class TreatmentsBolusFragment : DaggerFragment() {
|
||||||
@Inject lateinit var uploadQueue: UploadQueue
|
@Inject lateinit var uploadQueue: UploadQueue
|
||||||
@Inject lateinit var dateUtil: DateUtil
|
@Inject lateinit var dateUtil: DateUtil
|
||||||
@Inject lateinit var buildHelper: BuildHelper
|
@Inject lateinit var buildHelper: BuildHelper
|
||||||
|
@Inject lateinit var aapsSchedulers: AapsSchedulers
|
||||||
|
|
||||||
private var _binding: TreatmentsBolusFragmentBinding? = null
|
private var _binding: TreatmentsBolusFragmentBinding? = null
|
||||||
|
|
||||||
|
@ -94,13 +95,13 @@ class TreatmentsBolusFragment : DaggerFragment() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
disposable.add(rxBus
|
disposable.add(rxBus
|
||||||
.toObservable(EventTreatmentChange::class.java)
|
.toObservable(EventTreatmentChange::class.java)
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(aapsSchedulers.main)
|
||||||
.subscribe({ updateGui() }) { fabricPrivacy.logException(it) }
|
.subscribe({ updateGui() }, fabricPrivacy::logException)
|
||||||
)
|
)
|
||||||
disposable.add(rxBus
|
disposable.add(rxBus
|
||||||
.toObservable(EventAutosensCalculationFinished::class.java)
|
.toObservable(EventAutosensCalculationFinished::class.java)
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(aapsSchedulers.main)
|
||||||
.subscribe({ updateGui() }) { fabricPrivacy.logException(it) }
|
.subscribe({ updateGui() }, fabricPrivacy::logException)
|
||||||
)
|
)
|
||||||
updateGui()
|
updateGui()
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,8 +25,8 @@ import info.nightscout.androidaps.utils.Translator
|
||||||
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
|
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
|
||||||
import info.nightscout.androidaps.utils.buildHelper.BuildHelper
|
import info.nightscout.androidaps.utils.buildHelper.BuildHelper
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
|
import info.nightscout.androidaps.utils.rx.AapsSchedulers
|
||||||
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
|
||||||
import io.reactivex.disposables.CompositeDisposable
|
import io.reactivex.disposables.CompositeDisposable
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
@ -43,6 +43,7 @@ class TreatmentsCareportalFragment : DaggerFragment() {
|
||||||
@Inject lateinit var uploadQueue: UploadQueue
|
@Inject lateinit var uploadQueue: UploadQueue
|
||||||
@Inject lateinit var dateUtil: DateUtil
|
@Inject lateinit var dateUtil: DateUtil
|
||||||
@Inject lateinit var buildHelper: BuildHelper
|
@Inject lateinit var buildHelper: BuildHelper
|
||||||
|
@Inject lateinit var aapsSchedulers: AapsSchedulers
|
||||||
|
|
||||||
private var _binding: TreatmentsCareportalFragmentBinding? = null
|
private var _binding: TreatmentsCareportalFragmentBinding? = null
|
||||||
|
|
||||||
|
@ -93,7 +94,7 @@ class TreatmentsCareportalFragment : DaggerFragment() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
disposable.add(rxBus
|
disposable.add(rxBus
|
||||||
.toObservable(EventCareportalEventChange::class.java)
|
.toObservable(EventCareportalEventChange::class.java)
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(aapsSchedulers.main)
|
||||||
.subscribe({ updateGui() }, fabricPrivacy::logException)
|
.subscribe({ updateGui() }, fabricPrivacy::logException)
|
||||||
)
|
)
|
||||||
updateGui()
|
updateGui()
|
||||||
|
|
|
@ -29,7 +29,7 @@ import info.nightscout.androidaps.utils.DateUtil
|
||||||
import info.nightscout.androidaps.utils.FabricPrivacy
|
import info.nightscout.androidaps.utils.FabricPrivacy
|
||||||
import info.nightscout.androidaps.utils.alertDialogs.OKDialog.showConfirmation
|
import info.nightscout.androidaps.utils.alertDialogs.OKDialog.showConfirmation
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
import info.nightscout.androidaps.utils.rx.AapsSchedulers
|
||||||
import io.reactivex.disposables.CompositeDisposable
|
import io.reactivex.disposables.CompositeDisposable
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
@ -45,6 +45,7 @@ class TreatmentsExtendedBolusesFragment : DaggerFragment() {
|
||||||
@Inject lateinit var uploadQueue: UploadQueue
|
@Inject lateinit var uploadQueue: UploadQueue
|
||||||
@Inject lateinit var profileFunction: ProfileFunction
|
@Inject lateinit var profileFunction: ProfileFunction
|
||||||
@Inject lateinit var dateUtil: DateUtil
|
@Inject lateinit var dateUtil: DateUtil
|
||||||
|
@Inject lateinit var aapsSchedulers: AapsSchedulers
|
||||||
|
|
||||||
private var _binding: TreatmentsExtendedbolusFragmentBinding? = null
|
private var _binding: TreatmentsExtendedbolusFragmentBinding? = null
|
||||||
|
|
||||||
|
@ -135,13 +136,13 @@ class TreatmentsExtendedBolusesFragment : DaggerFragment() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
disposable.add(rxBus
|
disposable.add(rxBus
|
||||||
.toObservable(EventExtendedBolusChange::class.java)
|
.toObservable(EventExtendedBolusChange::class.java)
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(aapsSchedulers.main)
|
||||||
.subscribe({ updateGui() }) { fabricPrivacy.logException(it) }
|
.subscribe({ updateGui() }, fabricPrivacy::logException)
|
||||||
)
|
)
|
||||||
disposable.add(rxBus
|
disposable.add(rxBus
|
||||||
.toObservable(EventAutosensCalculationFinished::class.java)
|
.toObservable(EventAutosensCalculationFinished::class.java)
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(aapsSchedulers.main)
|
||||||
.subscribe({ updateGui() }) { fabricPrivacy.logException(it) }
|
.subscribe({ updateGui() }, fabricPrivacy::logException)
|
||||||
)
|
)
|
||||||
updateGui()
|
updateGui()
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,8 +30,8 @@ import info.nightscout.androidaps.utils.alertDialogs.OKDialog
|
||||||
import info.nightscout.androidaps.utils.buildHelper.BuildHelper
|
import info.nightscout.androidaps.utils.buildHelper.BuildHelper
|
||||||
import info.nightscout.androidaps.utils.extensions.toVisibility
|
import info.nightscout.androidaps.utils.extensions.toVisibility
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
|
import info.nightscout.androidaps.utils.rx.AapsSchedulers
|
||||||
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
|
||||||
import io.reactivex.disposables.CompositeDisposable
|
import io.reactivex.disposables.CompositeDisposable
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
@ -48,6 +48,7 @@ class TreatmentsProfileSwitchFragment : DaggerFragment() {
|
||||||
@Inject lateinit var uploadQueue: UploadQueue
|
@Inject lateinit var uploadQueue: UploadQueue
|
||||||
@Inject lateinit var dateUtil: DateUtil
|
@Inject lateinit var dateUtil: DateUtil
|
||||||
@Inject lateinit var buildHelper: BuildHelper
|
@Inject lateinit var buildHelper: BuildHelper
|
||||||
|
@Inject lateinit var aapsSchedulers: AapsSchedulers
|
||||||
|
|
||||||
private var _binding: TreatmentsProfileswitchFragmentBinding? = null
|
private var _binding: TreatmentsProfileswitchFragmentBinding? = null
|
||||||
|
|
||||||
|
@ -80,7 +81,7 @@ class TreatmentsProfileSwitchFragment : DaggerFragment() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
disposable.add(rxBus
|
disposable.add(rxBus
|
||||||
.toObservable(EventProfileNeedsUpdate::class.java)
|
.toObservable(EventProfileNeedsUpdate::class.java)
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(aapsSchedulers.main)
|
||||||
.subscribe({ updateGUI() }, fabricPrivacy::logException)
|
.subscribe({ updateGUI() }, fabricPrivacy::logException)
|
||||||
)
|
)
|
||||||
updateGUI()
|
updateGUI()
|
||||||
|
|
|
@ -30,8 +30,8 @@ import info.nightscout.androidaps.utils.FabricPrivacy
|
||||||
import info.nightscout.androidaps.utils.alertDialogs.OKDialog.showConfirmation
|
import info.nightscout.androidaps.utils.alertDialogs.OKDialog.showConfirmation
|
||||||
import info.nightscout.androidaps.utils.buildHelper.BuildHelper
|
import info.nightscout.androidaps.utils.buildHelper.BuildHelper
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
|
import info.nightscout.androidaps.utils.rx.AapsSchedulers
|
||||||
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
|
||||||
import io.reactivex.disposables.CompositeDisposable
|
import io.reactivex.disposables.CompositeDisposable
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
@ -47,6 +47,7 @@ class TreatmentsTempTargetFragment : DaggerFragment() {
|
||||||
@Inject lateinit var fabricPrivacy: FabricPrivacy
|
@Inject lateinit var fabricPrivacy: FabricPrivacy
|
||||||
@Inject lateinit var dateUtil: DateUtil
|
@Inject lateinit var dateUtil: DateUtil
|
||||||
@Inject lateinit var buildHelper: BuildHelper
|
@Inject lateinit var buildHelper: BuildHelper
|
||||||
|
@Inject lateinit var aapsSchedulers: AapsSchedulers
|
||||||
|
|
||||||
private val disposable = CompositeDisposable()
|
private val disposable = CompositeDisposable()
|
||||||
|
|
||||||
|
@ -80,7 +81,7 @@ class TreatmentsTempTargetFragment : DaggerFragment() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
disposable.add(rxBus
|
disposable.add(rxBus
|
||||||
.toObservable(EventTempTargetChange::class.java)
|
.toObservable(EventTempTargetChange::class.java)
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(aapsSchedulers.main)
|
||||||
.subscribe({ updateGui() }, fabricPrivacy::logException)
|
.subscribe({ updateGui() }, fabricPrivacy::logException)
|
||||||
)
|
)
|
||||||
updateGui()
|
updateGui()
|
||||||
|
|
|
@ -27,7 +27,7 @@ import info.nightscout.androidaps.utils.DateUtil
|
||||||
import info.nightscout.androidaps.utils.FabricPrivacy
|
import info.nightscout.androidaps.utils.FabricPrivacy
|
||||||
import info.nightscout.androidaps.utils.alertDialogs.OKDialog.showConfirmation
|
import info.nightscout.androidaps.utils.alertDialogs.OKDialog.showConfirmation
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
import info.nightscout.androidaps.utils.rx.AapsSchedulers
|
||||||
import io.reactivex.disposables.CompositeDisposable
|
import io.reactivex.disposables.CompositeDisposable
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
@ -41,6 +41,7 @@ class TreatmentsTemporaryBasalsFragment : DaggerFragment() {
|
||||||
@Inject lateinit var activePlugin: ActivePluginProvider
|
@Inject lateinit var activePlugin: ActivePluginProvider
|
||||||
@Inject lateinit var profileFunction: ProfileFunction
|
@Inject lateinit var profileFunction: ProfileFunction
|
||||||
@Inject lateinit var dateUtil: DateUtil
|
@Inject lateinit var dateUtil: DateUtil
|
||||||
|
@Inject lateinit var aapsSchedulers: AapsSchedulers
|
||||||
|
|
||||||
private var _binding: TreatmentsTempbasalsFragmentBinding? = null
|
private var _binding: TreatmentsTempbasalsFragmentBinding? = null
|
||||||
|
|
||||||
|
@ -63,12 +64,12 @@ class TreatmentsTemporaryBasalsFragment : DaggerFragment() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
disposable.add(rxBus
|
disposable.add(rxBus
|
||||||
.toObservable(EventTempBasalChange::class.java)
|
.toObservable(EventTempBasalChange::class.java)
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(aapsSchedulers.main)
|
||||||
.subscribe({ updateGui() }, fabricPrivacy::logException)
|
.subscribe({ updateGui() }, fabricPrivacy::logException)
|
||||||
)
|
)
|
||||||
disposable.add(rxBus
|
disposable.add(rxBus
|
||||||
.toObservable(EventAutosensCalculationFinished::class.java)
|
.toObservable(EventAutosensCalculationFinished::class.java)
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(aapsSchedulers.main)
|
||||||
.subscribe({ updateGui() }, fabricPrivacy::logException)
|
.subscribe({ updateGui() }, fabricPrivacy::logException)
|
||||||
)
|
)
|
||||||
updateGui()
|
updateGui()
|
||||||
|
|
|
@ -25,7 +25,6 @@ import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.logging.LTag
|
import info.nightscout.androidaps.logging.LTag
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker
|
import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker
|
||||||
import info.nightscout.androidaps.queue.commands.CustomCommand
|
|
||||||
import info.nightscout.androidaps.plugins.general.overview.events.EventDismissBolusProgressIfRunning
|
import info.nightscout.androidaps.plugins.general.overview.events.EventDismissBolusProgressIfRunning
|
||||||
import info.nightscout.androidaps.plugins.general.overview.events.EventDismissNotification
|
import info.nightscout.androidaps.plugins.general.overview.events.EventDismissNotification
|
||||||
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification
|
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification
|
||||||
|
@ -36,9 +35,9 @@ import info.nightscout.androidaps.utils.FabricPrivacy
|
||||||
import info.nightscout.androidaps.utils.HtmlHelper
|
import info.nightscout.androidaps.utils.HtmlHelper
|
||||||
import info.nightscout.androidaps.utils.buildHelper.BuildHelper
|
import info.nightscout.androidaps.utils.buildHelper.BuildHelper
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
|
import info.nightscout.androidaps.utils.rx.AapsSchedulers
|
||||||
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||||
import io.reactivex.disposables.CompositeDisposable
|
import io.reactivex.disposables.CompositeDisposable
|
||||||
import io.reactivex.schedulers.Schedulers
|
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
import javax.inject.Singleton
|
import javax.inject.Singleton
|
||||||
|
@ -87,16 +86,17 @@ import javax.inject.Singleton
|
||||||
@Singleton
|
@Singleton
|
||||||
class CommandQueue @Inject constructor(
|
class CommandQueue @Inject constructor(
|
||||||
private val injector: HasAndroidInjector,
|
private val injector: HasAndroidInjector,
|
||||||
val aapsLogger: AAPSLogger,
|
private val aapsLogger: AAPSLogger,
|
||||||
val rxBus: RxBusWrapper,
|
private val rxBus: RxBusWrapper,
|
||||||
val resourceHelper: ResourceHelper,
|
private val aapsSchedulers: AapsSchedulers,
|
||||||
val constraintChecker: ConstraintChecker,
|
private val resourceHelper: ResourceHelper,
|
||||||
val profileFunction: ProfileFunction,
|
private val constraintChecker: ConstraintChecker,
|
||||||
val activePlugin: Lazy<ActivePluginProvider>,
|
private val profileFunction: ProfileFunction,
|
||||||
val context: Context,
|
private val activePlugin: Lazy<ActivePluginProvider>,
|
||||||
val sp: SP,
|
private val context: Context,
|
||||||
|
private val sp: SP,
|
||||||
private val buildHelper: BuildHelper,
|
private val buildHelper: BuildHelper,
|
||||||
val fabricPrivacy: FabricPrivacy
|
private val fabricPrivacy: FabricPrivacy
|
||||||
) : CommandQueueProvider {
|
) : CommandQueueProvider {
|
||||||
|
|
||||||
private val disposable = CompositeDisposable()
|
private val disposable = CompositeDisposable()
|
||||||
|
@ -109,7 +109,7 @@ class CommandQueue @Inject constructor(
|
||||||
init {
|
init {
|
||||||
disposable.add(rxBus
|
disposable.add(rxBus
|
||||||
.toObservable(EventProfileNeedsUpdate::class.java)
|
.toObservable(EventProfileNeedsUpdate::class.java)
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(aapsSchedulers.io)
|
||||||
.subscribe({
|
.subscribe({
|
||||||
aapsLogger.debug(LTag.PROFILE, "onProfileSwitch")
|
aapsLogger.debug(LTag.PROFILE, "onProfileSwitch")
|
||||||
profileFunction.getProfile()?.let {
|
profileFunction.getProfile()?.let {
|
||||||
|
@ -127,7 +127,7 @@ class CommandQueue @Inject constructor(
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}) { exception: Throwable -> fabricPrivacy.logException(exception) }
|
}, fabricPrivacy::logException)
|
||||||
)
|
)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -208,7 +208,7 @@ class CommandQueue @Inject constructor(
|
||||||
|
|
||||||
override fun independentConnect(reason: String, callback: Callback?) {
|
override fun independentConnect(reason: String, callback: Callback?) {
|
||||||
aapsLogger.debug(LTag.PUMPQUEUE, "Starting new queue")
|
aapsLogger.debug(LTag.PUMPQUEUE, "Starting new queue")
|
||||||
val tempCommandQueue = CommandQueue(injector, aapsLogger, rxBus, resourceHelper, constraintChecker, profileFunction, activePlugin, context, sp, buildHelper, fabricPrivacy)
|
val tempCommandQueue = CommandQueue(injector, aapsLogger, rxBus, aapsSchedulers, resourceHelper, constraintChecker, profileFunction, activePlugin, context, sp, buildHelper, fabricPrivacy)
|
||||||
tempCommandQueue.readStatus(reason, callback)
|
tempCommandQueue.readStatus(reason, callback)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -292,7 +292,7 @@ class CommandQueue @Inject constructor(
|
||||||
}
|
}
|
||||||
removeAll(CommandType.BOLUS)
|
removeAll(CommandType.BOLUS)
|
||||||
removeAll(CommandType.SMB_BOLUS)
|
removeAll(CommandType.SMB_BOLUS)
|
||||||
Thread(Runnable { activePlugin.get().activePump.stopBolusDelivering() }).run()
|
Thread { activePlugin.get().activePump.stopBolusDelivering() }.run()
|
||||||
}
|
}
|
||||||
|
|
||||||
// returns true if command is queued
|
// returns true if command is queued
|
||||||
|
@ -500,7 +500,7 @@ class CommandQueue @Inject constructor(
|
||||||
|
|
||||||
@Synchronized
|
@Synchronized
|
||||||
override fun isCustomCommandInQueue(customCommandType: Class<out CustomCommand>): Boolean {
|
override fun isCustomCommandInQueue(customCommandType: Class<out CustomCommand>): Boolean {
|
||||||
if(isCustomCommandRunning(customCommandType)) {
|
if (isCustomCommandRunning(customCommandType)) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
synchronized(queue) {
|
synchronized(queue) {
|
||||||
|
|
|
@ -25,9 +25,9 @@ import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
import info.nightscout.androidaps.utils.FabricPrivacy
|
import info.nightscout.androidaps.utils.FabricPrivacy
|
||||||
import info.nightscout.androidaps.utils.T
|
import info.nightscout.androidaps.utils.T
|
||||||
import info.nightscout.androidaps.utils.androidNotification.NotificationHolder
|
import info.nightscout.androidaps.utils.androidNotification.NotificationHolder
|
||||||
|
import info.nightscout.androidaps.utils.rx.AapsSchedulers
|
||||||
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||||
import io.reactivex.disposables.CompositeDisposable
|
import io.reactivex.disposables.CompositeDisposable
|
||||||
import io.reactivex.schedulers.Schedulers
|
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class LocationService : DaggerService() {
|
class LocationService : DaggerService() {
|
||||||
|
@ -35,6 +35,7 @@ class LocationService : DaggerService() {
|
||||||
@Inject lateinit var aapsLogger: AAPSLogger
|
@Inject lateinit var aapsLogger: AAPSLogger
|
||||||
@Inject lateinit var rxBus: RxBusWrapper
|
@Inject lateinit var rxBus: RxBusWrapper
|
||||||
@Inject lateinit var sp: SP
|
@Inject lateinit var sp: SP
|
||||||
|
@Inject lateinit var aapsSchedulers: AapsSchedulers
|
||||||
@Inject lateinit var fabricPrivacy: FabricPrivacy
|
@Inject lateinit var fabricPrivacy: FabricPrivacy
|
||||||
@Inject lateinit var notificationHolder: NotificationHolder
|
@Inject lateinit var notificationHolder: NotificationHolder
|
||||||
@Inject lateinit var lastLocationDataContainer: LastLocationDataContainer
|
@Inject lateinit var lastLocationDataContainer: LastLocationDataContainer
|
||||||
|
@ -137,11 +138,11 @@ class LocationService : DaggerService() {
|
||||||
}
|
}
|
||||||
disposable.add(rxBus
|
disposable.add(rxBus
|
||||||
.toObservable(EventAppExit::class.java)
|
.toObservable(EventAppExit::class.java)
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(aapsSchedulers.io)
|
||||||
.subscribe({
|
.subscribe({
|
||||||
aapsLogger.debug(LTag.LOCATION, "EventAppExit received")
|
aapsLogger.debug(LTag.LOCATION, "EventAppExit received")
|
||||||
stopSelf()
|
stopSelf()
|
||||||
}) { fabricPrivacy.logException(it) }
|
}, fabricPrivacy::logException)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,8 +7,9 @@ import android.widget.TextView
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.androidaps.events.EventStatus
|
import info.nightscout.androidaps.events.EventStatus
|
||||||
import info.nightscout.androidaps.setupwizard.elements.SWItem
|
import info.nightscout.androidaps.setupwizard.elements.SWItem
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
import info.nightscout.androidaps.utils.rx.AapsSchedulers
|
||||||
import io.reactivex.disposables.CompositeDisposable
|
import io.reactivex.disposables.CompositeDisposable
|
||||||
|
import javax.inject.Inject
|
||||||
|
|
||||||
class SWEventListener constructor(
|
class SWEventListener constructor(
|
||||||
injector: HasAndroidInjector,
|
injector: HasAndroidInjector,
|
||||||
|
@ -21,11 +22,13 @@ class SWEventListener constructor(
|
||||||
private var textView: TextView? = null
|
private var textView: TextView? = null
|
||||||
private var visibilityValidator: SWValidator? = null
|
private var visibilityValidator: SWValidator? = null
|
||||||
|
|
||||||
|
@Inject lateinit var aapsSchedulers: AapsSchedulers
|
||||||
|
|
||||||
// TODO: Adrian how to clear disposable in this case?
|
// TODO: Adrian how to clear disposable in this case?
|
||||||
init {
|
init {
|
||||||
disposable.add(rxBus
|
disposable.add(rxBus
|
||||||
.toObservable(clazz)
|
.toObservable(clazz)
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(aapsSchedulers.main)
|
||||||
.subscribe { event: Any ->
|
.subscribe { event: Any ->
|
||||||
status = (event as EventStatus).getStatus(resourceHelper)
|
status = (event as EventStatus).getStatus(resourceHelper)
|
||||||
@SuppressLint("SetTextI18n")
|
@SuppressLint("SetTextI18n")
|
||||||
|
|
|
@ -21,8 +21,8 @@ import info.nightscout.androidaps.setupwizard.events.EventSWUpdate
|
||||||
import info.nightscout.androidaps.utils.FabricPrivacy
|
import info.nightscout.androidaps.utils.FabricPrivacy
|
||||||
import info.nightscout.androidaps.utils.alertDialogs.OKDialog.showConfirmation
|
import info.nightscout.androidaps.utils.alertDialogs.OKDialog.showConfirmation
|
||||||
import info.nightscout.androidaps.utils.locale.LocaleHelper.update
|
import info.nightscout.androidaps.utils.locale.LocaleHelper.update
|
||||||
|
import info.nightscout.androidaps.utils.rx.AapsSchedulers
|
||||||
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
|
||||||
import io.reactivex.disposables.CompositeDisposable
|
import io.reactivex.disposables.CompositeDisposable
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
import kotlin.math.max
|
import kotlin.math.max
|
||||||
|
@ -36,6 +36,7 @@ class SetupWizardActivity : NoSplashAppCompatActivity() {
|
||||||
@Inject lateinit var rxBus: RxBusWrapper
|
@Inject lateinit var rxBus: RxBusWrapper
|
||||||
@Inject lateinit var sp: SP
|
@Inject lateinit var sp: SP
|
||||||
@Inject lateinit var fabricPrivacy: FabricPrivacy
|
@Inject lateinit var fabricPrivacy: FabricPrivacy
|
||||||
|
@Inject lateinit var aapsSchedulers: AapsSchedulers
|
||||||
|
|
||||||
private val disposable = CompositeDisposable()
|
private val disposable = CompositeDisposable()
|
||||||
private lateinit var screens: List<SWScreen>
|
private lateinit var screens: List<SWScreen>
|
||||||
|
@ -77,36 +78,36 @@ class SetupWizardActivity : NoSplashAppCompatActivity() {
|
||||||
swDefinition.activity = this
|
swDefinition.activity = this
|
||||||
disposable.add(rxBus
|
disposable.add(rxBus
|
||||||
.toObservable(EventPumpStatusChanged::class.java)
|
.toObservable(EventPumpStatusChanged::class.java)
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(aapsSchedulers.main)
|
||||||
.subscribe({ updateButtons() }) { fabricPrivacy.logException(it) }
|
.subscribe({ updateButtons() }, fabricPrivacy::logException)
|
||||||
)
|
)
|
||||||
disposable.add(rxBus
|
disposable.add(rxBus
|
||||||
.toObservable(EventRileyLinkDeviceStatusChange::class.java)
|
.toObservable(EventRileyLinkDeviceStatusChange::class.java)
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(aapsSchedulers.main)
|
||||||
.subscribe({ updateButtons() }) { fabricPrivacy.logException(it) }
|
.subscribe({ updateButtons() }, fabricPrivacy::logException)
|
||||||
)
|
)
|
||||||
disposable.add(rxBus
|
disposable.add(rxBus
|
||||||
.toObservable(EventNSClientStatus::class.java)
|
.toObservable(EventNSClientStatus::class.java)
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(aapsSchedulers.main)
|
||||||
.subscribe({ updateButtons() }) { fabricPrivacy.logException(it) }
|
.subscribe({ updateButtons() }, fabricPrivacy::logException)
|
||||||
)
|
)
|
||||||
disposable.add(rxBus
|
disposable.add(rxBus
|
||||||
.toObservable(EventProfileNeedsUpdate::class.java)
|
.toObservable(EventProfileNeedsUpdate::class.java)
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(aapsSchedulers.main)
|
||||||
.subscribe({ updateButtons() }) { fabricPrivacy.logException(it) }
|
.subscribe({ updateButtons() }, fabricPrivacy::logException)
|
||||||
)
|
)
|
||||||
disposable.add(rxBus
|
disposable.add(rxBus
|
||||||
.toObservable(EventProfileStoreChanged::class.java)
|
.toObservable(EventProfileStoreChanged::class.java)
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(aapsSchedulers.main)
|
||||||
.subscribe({ updateButtons() }) { fabricPrivacy.logException(it) }
|
.subscribe({ updateButtons() }, fabricPrivacy::logException)
|
||||||
)
|
)
|
||||||
disposable.add(rxBus
|
disposable.add(rxBus
|
||||||
.toObservable(EventSWUpdate::class.java)
|
.toObservable(EventSWUpdate::class.java)
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(aapsSchedulers.main)
|
||||||
.subscribe({ event: EventSWUpdate ->
|
.subscribe({ event: EventSWUpdate ->
|
||||||
if (event.redraw) generateLayout()
|
if (event.redraw) generateLayout()
|
||||||
updateButtons()
|
updateButtons()
|
||||||
}) { fabricPrivacy.logException(it) }
|
}, fabricPrivacy::logException)
|
||||||
)
|
)
|
||||||
updateButtons()
|
updateButtons()
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
package info.nightscout.androidaps.utils.stats
|
package info.nightscout.androidaps.utils.stats
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
import android.text.Spanned
|
import android.text.Spanned
|
||||||
import android.util.LongSparseArray
|
import android.util.LongSparseArray
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.androidaps.MainApp
|
|
||||||
import info.nightscout.androidaps.R
|
import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.db.TDD
|
import info.nightscout.androidaps.db.TDD
|
||||||
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
||||||
|
@ -21,6 +21,7 @@ import info.nightscout.androidaps.utils.HtmlHelper
|
||||||
import info.nightscout.androidaps.utils.MidnightTime
|
import info.nightscout.androidaps.utils.MidnightTime
|
||||||
import info.nightscout.androidaps.utils.T
|
import info.nightscout.androidaps.utils.T
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
|
import info.nightscout.androidaps.utils.rx.AapsSchedulers
|
||||||
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
@ -29,15 +30,16 @@ class TddCalculator @Inject constructor(
|
||||||
aapsLogger: AAPSLogger,
|
aapsLogger: AAPSLogger,
|
||||||
rxBus: RxBusWrapper,
|
rxBus: RxBusWrapper,
|
||||||
resourceHelper: ResourceHelper,
|
resourceHelper: ResourceHelper,
|
||||||
val mainApp: MainApp,
|
context: Context,
|
||||||
val sp: SP,
|
private val aapsSchedulers: AapsSchedulers,
|
||||||
val activePlugin: ActivePluginProvider,
|
private val sp: SP,
|
||||||
val profileFunction: ProfileFunction,
|
private val activePlugin: ActivePluginProvider,
|
||||||
|
private val profileFunction: ProfileFunction,
|
||||||
fabricPrivacy: FabricPrivacy,
|
fabricPrivacy: FabricPrivacy,
|
||||||
nsUpload: NSUpload,
|
nsUpload: NSUpload,
|
||||||
private val dateUtil: DateUtil,
|
private val dateUtil: DateUtil,
|
||||||
uploadQueue: UploadQueue
|
uploadQueue: UploadQueue
|
||||||
) : TreatmentsPlugin(injector, aapsLogger, rxBus, resourceHelper, mainApp, sp, profileFunction, activePlugin, nsUpload, fabricPrivacy, dateUtil, uploadQueue) {
|
) : TreatmentsPlugin(injector, aapsLogger, rxBus, aapsSchedulers, resourceHelper, context, sp, profileFunction, activePlugin, nsUpload, fabricPrivacy, dateUtil, uploadQueue) {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
service = TreatmentService(injector) // plugin is not started
|
service = TreatmentService(injector) // plugin is not started
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
package info.nightscout.androidaps
|
package info.nightscout.androidaps
|
||||||
|
|
||||||
import info.nightscout.androidaps.logging.AAPSLoggerTest
|
import info.nightscout.androidaps.logging.AAPSLoggerTest
|
||||||
|
import info.nightscout.androidaps.utils.rx.AapsSchedulers
|
||||||
|
import info.nightscout.androidaps.utils.rx.TestAapsSchedulers
|
||||||
import org.junit.Before
|
import org.junit.Before
|
||||||
import org.junit.Rule
|
import org.junit.Rule
|
||||||
import org.mockito.Mockito
|
import org.mockito.Mockito
|
||||||
|
@ -11,6 +13,7 @@ import java.util.*
|
||||||
open class TestBase {
|
open class TestBase {
|
||||||
|
|
||||||
val aapsLogger = AAPSLoggerTest()
|
val aapsLogger = AAPSLoggerTest()
|
||||||
|
val aapsSchedulers: AapsSchedulers = TestAapsSchedulers()
|
||||||
|
|
||||||
// Add a JUnit rule that will setup the @Mock annotated vars and log.
|
// Add a JUnit rule that will setup the @Mock annotated vars and log.
|
||||||
// Another possibility would be to add `MockitoAnnotations.initMocks(this) to the setup method.
|
// Another possibility would be to add `MockitoAnnotations.initMocks(this) to the setup method.
|
||||||
|
|
|
@ -14,6 +14,8 @@ import info.nightscout.androidaps.utils.DateUtil
|
||||||
import info.nightscout.androidaps.utils.DefaultValueHelper
|
import info.nightscout.androidaps.utils.DefaultValueHelper
|
||||||
import info.nightscout.androidaps.utils.FabricPrivacy
|
import info.nightscout.androidaps.utils.FabricPrivacy
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
|
import info.nightscout.androidaps.utils.rx.AapsSchedulers
|
||||||
|
import info.nightscout.androidaps.utils.rx.TestAapsSchedulers
|
||||||
import org.json.JSONObject
|
import org.json.JSONObject
|
||||||
import org.junit.Before
|
import org.junit.Before
|
||||||
import org.mockito.Mock
|
import org.mockito.Mock
|
||||||
|
@ -29,7 +31,7 @@ open class TestBaseWithProfile : TestBase() {
|
||||||
@Mock lateinit var defaultValueHelper: DefaultValueHelper
|
@Mock lateinit var defaultValueHelper: DefaultValueHelper
|
||||||
@Mock lateinit var dateUtil: DateUtil
|
@Mock lateinit var dateUtil: DateUtil
|
||||||
|
|
||||||
val rxBus = RxBusWrapper()
|
val rxBus = RxBusWrapper(aapsSchedulers)
|
||||||
|
|
||||||
val profileInjector = HasAndroidInjector {
|
val profileInjector = HasAndroidInjector {
|
||||||
AndroidInjector {
|
AndroidInjector {
|
||||||
|
@ -57,7 +59,7 @@ open class TestBaseWithProfile : TestBase() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
lateinit var validProfileJSON: String
|
private lateinit var validProfileJSON: String
|
||||||
lateinit var validProfile: Profile
|
lateinit var validProfile: Profile
|
||||||
val TESTPROFILENAME = "someProfile"
|
val TESTPROFILENAME = "someProfile"
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,6 @@ package info.nightscout.androidaps.danars.comm
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.androidaps.Config
|
|
||||||
import info.nightscout.androidaps.danars.DanaRSPlugin
|
import info.nightscout.androidaps.danars.DanaRSPlugin
|
||||||
import info.nightscout.androidaps.interfaces.CommandQueueProvider
|
import info.nightscout.androidaps.interfaces.CommandQueueProvider
|
||||||
import info.nightscout.androidaps.interfaces.Constraint
|
import info.nightscout.androidaps.interfaces.Constraint
|
||||||
|
@ -55,7 +54,7 @@ class DanaRS_Packet_Bolus_Set_Step_Bolus_StartTest : DanaRSTestBase() {
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
fun mock() {
|
fun mock() {
|
||||||
danaRSPlugin = DanaRSPlugin(HasAndroidInjector { AndroidInjector { Unit } }, aapsLogger, rxBus, context, resourceHelper, constraintChecker, profileFunction, activePluginProvider, sp, commandQueue, danaPump, detailedBolusInfoStorage, fabricPrivacy, dateUtil)
|
danaRSPlugin = DanaRSPlugin({ AndroidInjector { } }, aapsLogger, aapsSchedulers, rxBus, context, resourceHelper, constraintChecker, profileFunction, activePluginProvider, sp, commandQueue, danaPump, detailedBolusInfoStorage, fabricPrivacy, dateUtil)
|
||||||
Mockito.`when`(constraintChecker.applyBolusConstraints(anyObject())).thenReturn(Constraint(0.0))
|
Mockito.`when`(constraintChecker.applyBolusConstraints(anyObject())).thenReturn(Constraint(0.0))
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -68,7 +68,7 @@ class DanaRS_Packet_Notify_Delivery_Rate_DisplayTest : DanaRSTestBase() {
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
fun mock() {
|
fun mock() {
|
||||||
danaRSPlugin = DanaRSPlugin(HasAndroidInjector { AndroidInjector { Unit } }, aapsLogger, rxBus, context, resourceHelper, constraintChecker, profileFunction, activePluginProvider, sp, commandQueue, danaPump, detailedBolusInfoStorage, fabricPrivacy, dateUtil)
|
danaRSPlugin = DanaRSPlugin(HasAndroidInjector { AndroidInjector { Unit } }, aapsLogger, aapsSchedulers, rxBus, context, resourceHelper, constraintChecker, profileFunction, activePluginProvider, sp, commandQueue, danaPump, detailedBolusInfoStorage, fabricPrivacy, dateUtil)
|
||||||
danaPump.bolusingTreatment = Treatment(packetInjector)
|
danaPump.bolusingTreatment = Treatment(packetInjector)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -117,8 +117,8 @@ class ConstraintsCheckerTest : TestBaseWithProfile() {
|
||||||
hardLimits = HardLimits(aapsLogger, rxBus, sp, resourceHelper, context, nsUpload)
|
hardLimits = HardLimits(aapsLogger, rxBus, sp, resourceHelper, context, nsUpload)
|
||||||
objectivesPlugin = ObjectivesPlugin(injector, aapsLogger, resourceHelper, activePlugin, sp, Config())
|
objectivesPlugin = ObjectivesPlugin(injector, aapsLogger, resourceHelper, activePlugin, sp, Config())
|
||||||
comboPlugin = ComboPlugin(injector, aapsLogger, rxBus, resourceHelper, profileFunction, treatmentsPlugin, sp, commandQueue, context)
|
comboPlugin = ComboPlugin(injector, aapsLogger, rxBus, resourceHelper, profileFunction, treatmentsPlugin, sp, commandQueue, context)
|
||||||
danaRPlugin = DanaRPlugin(injector, aapsLogger, rxBus, context, resourceHelper, constraintChecker, activePlugin, sp, commandQueue, danaPump, dateUtil, fabricPrivacy)
|
danaRPlugin = DanaRPlugin(injector, aapsLogger, aapsSchedulers, rxBus, context, resourceHelper, constraintChecker, activePlugin, sp, commandQueue, danaPump, dateUtil, fabricPrivacy)
|
||||||
danaRSPlugin = DanaRSPlugin(injector, aapsLogger, rxBus, context, resourceHelper, constraintChecker, profileFunction, activePluginProvider, sp, commandQueue, danaPump, detailedBolusInfoStorage, fabricPrivacy, dateUtil)
|
danaRSPlugin = DanaRSPlugin(injector, aapsLogger, aapsSchedulers, rxBus, context, resourceHelper, constraintChecker, profileFunction, activePluginProvider, sp, commandQueue, danaPump, detailedBolusInfoStorage, fabricPrivacy, dateUtil)
|
||||||
insightPlugin = LocalInsightPlugin(injector, aapsLogger, rxBus, resourceHelper, treatmentsPlugin, sp, commandQueue, profileFunction, nsUpload, context, uploadQueue, Config(), dateUtil)
|
insightPlugin = LocalInsightPlugin(injector, aapsLogger, rxBus, resourceHelper, treatmentsPlugin, sp, commandQueue, profileFunction, nsUpload, context, uploadQueue, Config(), dateUtil)
|
||||||
openAPSSMBPlugin = OpenAPSSMBPlugin(injector, aapsLogger, rxBus, constraintChecker, resourceHelper, profileFunction, context, activePlugin, treatmentsPlugin, iobCobCalculatorPlugin, hardLimits, profiler, fabricPrivacy, sp)
|
openAPSSMBPlugin = OpenAPSSMBPlugin(injector, aapsLogger, rxBus, constraintChecker, resourceHelper, profileFunction, context, activePlugin, treatmentsPlugin, iobCobCalculatorPlugin, hardLimits, profiler, fabricPrivacy, sp)
|
||||||
openAPSAMAPlugin = OpenAPSAMAPlugin(injector, aapsLogger, rxBus, constraintChecker, resourceHelper, profileFunction, context, activePlugin, treatmentsPlugin, iobCobCalculatorPlugin, hardLimits, profiler, fabricPrivacy)
|
openAPSAMAPlugin = OpenAPSAMAPlugin(injector, aapsLogger, rxBus, constraintChecker, resourceHelper, profileFunction, context, activePlugin, treatmentsPlugin, iobCobCalculatorPlugin, hardLimits, profiler, fabricPrivacy)
|
||||||
|
|
|
@ -39,7 +39,7 @@ import org.powermock.modules.junit4.PowerMockRunner
|
||||||
class LoopPluginTest : TestBase() {
|
class LoopPluginTest : TestBase() {
|
||||||
|
|
||||||
@Mock lateinit var sp: SP
|
@Mock lateinit var sp: SP
|
||||||
private val rxBus: RxBusWrapper = RxBusWrapper()
|
private val rxBus: RxBusWrapper = RxBusWrapper(aapsSchedulers)
|
||||||
@Mock lateinit var constraintChecker: ConstraintChecker
|
@Mock lateinit var constraintChecker: ConstraintChecker
|
||||||
@Mock lateinit var resourceHelper: ResourceHelper
|
@Mock lateinit var resourceHelper: ResourceHelper
|
||||||
@Mock lateinit var profileFunction: ProfileFunction
|
@Mock lateinit var profileFunction: ProfileFunction
|
||||||
|
@ -62,7 +62,7 @@ class LoopPluginTest : TestBase() {
|
||||||
@Before fun prepareMock() {
|
@Before fun prepareMock() {
|
||||||
hardLimits = HardLimits(aapsLogger, rxBus, sp, resourceHelper, context, nsUpload)
|
hardLimits = HardLimits(aapsLogger, rxBus, sp, resourceHelper, context, nsUpload)
|
||||||
|
|
||||||
loopPlugin = LoopPlugin(injector, aapsLogger, rxBus, sp, Config(), constraintChecker, resourceHelper, profileFunction, context, commandQueue, activePlugin, treatmentsPlugin, virtualPumpPlugin, actionStringHandler, iobCobCalculatorPlugin, receiverStatusStore, fabricPrivacy, nsUpload, hardLimits)
|
loopPlugin = LoopPlugin(injector, aapsLogger, aapsSchedulers, rxBus, sp, Config(), constraintChecker, resourceHelper, profileFunction, context, commandQueue, activePlugin, treatmentsPlugin, virtualPumpPlugin, actionStringHandler, iobCobCalculatorPlugin, receiverStatusStore, fabricPrivacy, nsUpload, hardLimits)
|
||||||
`when`(activePlugin.activePump).thenReturn(virtualPumpPlugin)
|
`when`(activePlugin.activePump).thenReturn(virtualPumpPlugin)
|
||||||
`when`(context.getSystemService(Context.NOTIFICATION_SERVICE)).thenReturn(notificationManager)
|
`when`(context.getSystemService(Context.NOTIFICATION_SERVICE)).thenReturn(notificationManager)
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ class ConfigBuilderPluginTest : TestBase() {
|
||||||
@Mock lateinit var commandQueue: CommandQueueProvider
|
@Mock lateinit var commandQueue: CommandQueueProvider
|
||||||
@Mock lateinit var activePlugin: ActivePluginProvider
|
@Mock lateinit var activePlugin: ActivePluginProvider
|
||||||
|
|
||||||
lateinit var configBuilderPlugin: ConfigBuilderPlugin
|
private lateinit var configBuilderPlugin: ConfigBuilderPlugin
|
||||||
|
|
||||||
val injector = HasAndroidInjector {
|
val injector = HasAndroidInjector {
|
||||||
AndroidInjector {
|
AndroidInjector {
|
||||||
|
@ -43,6 +43,6 @@ class ConfigBuilderPluginTest : TestBase() {
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
fun prepareMock() {
|
fun prepareMock() {
|
||||||
configBuilderPlugin = ConfigBuilderPlugin(injector, aapsLogger, resourceHelper, sp, RxBusWrapper(), activePlugin)
|
configBuilderPlugin = ConfigBuilderPlugin(injector, aapsLogger, resourceHelper, sp, RxBusWrapper(aapsSchedulers), activePlugin)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -4,7 +4,6 @@ import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.androidaps.TestBase
|
import info.nightscout.androidaps.TestBase
|
||||||
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
|
||||||
import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin
|
import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
|
@ -27,13 +26,13 @@ class DstHelperPluginTest : TestBase() {
|
||||||
@Mock lateinit var activePlugin: ActivePluginProvider
|
@Mock lateinit var activePlugin: ActivePluginProvider
|
||||||
@Mock lateinit var loopPlugin: LoopPlugin
|
@Mock lateinit var loopPlugin: LoopPlugin
|
||||||
|
|
||||||
lateinit var plugin: DstHelperPlugin
|
private lateinit var plugin: DstHelperPlugin
|
||||||
|
|
||||||
val injector = HasAndroidInjector { AndroidInjector { } }
|
val injector = HasAndroidInjector { AndroidInjector { } }
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
fun mock() {
|
fun mock() {
|
||||||
plugin = DstHelperPlugin(injector, aapsLogger, RxBusWrapper(), resourceHelper, sp, activePlugin, loopPlugin)
|
plugin = DstHelperPlugin(injector, aapsLogger, RxBusWrapper(aapsSchedulers), resourceHelper, sp, activePlugin, loopPlugin)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -4,7 +4,6 @@ import android.content.Context
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.androidaps.TestBase
|
import info.nightscout.androidaps.TestBase
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||||
|
@ -13,10 +12,11 @@ import org.junit.Test
|
||||||
import org.mockito.Mock
|
import org.mockito.Mock
|
||||||
|
|
||||||
class SignatureVerifierPluginTest : TestBase() {
|
class SignatureVerifierPluginTest : TestBase() {
|
||||||
|
|
||||||
@Mock lateinit var resourceHelper: ResourceHelper
|
@Mock lateinit var resourceHelper: ResourceHelper
|
||||||
@Mock lateinit var sp: SP
|
@Mock lateinit var sp: SP
|
||||||
@Mock lateinit var context: Context
|
@Mock lateinit var context: Context
|
||||||
private val rxBus = RxBusWrapper()
|
private val rxBus = RxBusWrapper(aapsSchedulers)
|
||||||
|
|
||||||
val injector = HasAndroidInjector { AndroidInjector { } }
|
val injector = HasAndroidInjector { AndroidInjector { } }
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
package info.nightscout.androidaps.plugins.constraints.storage
|
package info.nightscout.androidaps.plugins.constraints.storage
|
||||||
|
|
||||||
import android.os.Environment
|
|
||||||
import android.os.StatFs
|
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.androidaps.TestBase
|
import info.nightscout.androidaps.TestBase
|
||||||
|
@ -14,26 +12,25 @@ import org.junit.Before
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
import org.mockito.Mock
|
import org.mockito.Mock
|
||||||
import org.powermock.core.classloader.annotations.PrepareForTest
|
|
||||||
import org.powermock.modules.junit4.PowerMockRunner
|
import org.powermock.modules.junit4.PowerMockRunner
|
||||||
|
|
||||||
@RunWith(PowerMockRunner::class)
|
@RunWith(PowerMockRunner::class)
|
||||||
class StorageConstraintPluginTest : TestBase() {
|
class StorageConstraintPluginTest : TestBase() {
|
||||||
|
|
||||||
@Mock lateinit var resourceHelper: ResourceHelper
|
@Mock lateinit var resourceHelper: ResourceHelper
|
||||||
private val rxBusWrapper = RxBusWrapper()
|
private val rxBusWrapper = RxBusWrapper(aapsSchedulers)
|
||||||
|
|
||||||
lateinit var storageConstraintPlugin: StorageConstraintPlugin
|
private lateinit var storageConstraintPlugin: StorageConstraintPlugin
|
||||||
|
|
||||||
@Before fun prepareMock() {
|
@Before fun prepareMock() {
|
||||||
storageConstraintPlugin = StorageConstraintPlugin(HasAndroidInjector { AndroidInjector { } }, aapsLogger, resourceHelper, rxBusWrapper)
|
storageConstraintPlugin = StorageConstraintPlugin({ AndroidInjector { } }, aapsLogger, resourceHelper, rxBusWrapper)
|
||||||
}
|
}
|
||||||
|
|
||||||
class MockedStorageConstraintPlugin constructor(
|
class MockedStorageConstraintPlugin constructor(
|
||||||
injector: HasAndroidInjector,
|
injector: HasAndroidInjector,
|
||||||
aapsLogger: AAPSLogger,
|
aapsLogger: AAPSLogger,
|
||||||
resourceHelper: ResourceHelper,
|
resourceHelper: ResourceHelper,
|
||||||
private val rxBus: RxBusWrapper
|
rxBus: RxBusWrapper
|
||||||
) : StorageConstraintPlugin(injector, aapsLogger, resourceHelper, rxBus) {
|
) : StorageConstraintPlugin(injector, aapsLogger, resourceHelper, rxBus) {
|
||||||
|
|
||||||
var memSize = 150L
|
var memSize = 150L
|
||||||
|
@ -41,7 +38,7 @@ class StorageConstraintPluginTest : TestBase() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun isLoopInvocationAllowedTest() {
|
@Test fun isLoopInvocationAllowedTest() {
|
||||||
val mocked = MockedStorageConstraintPlugin(HasAndroidInjector { AndroidInjector { } }, aapsLogger, resourceHelper, rxBusWrapper)
|
val mocked = MockedStorageConstraintPlugin({ AndroidInjector { } }, aapsLogger, resourceHelper, rxBusWrapper)
|
||||||
// Set free space under 200(Mb) to disable loop
|
// Set free space under 200(Mb) to disable loop
|
||||||
mocked.memSize = 150L
|
mocked.memSize = 150L
|
||||||
Assert.assertEquals(false, mocked.isClosedLoopAllowed(Constraint(true)).value())
|
Assert.assertEquals(false, mocked.isClosedLoopAllowed(Constraint(true)).value())
|
||||||
|
|
|
@ -21,7 +21,7 @@ class VersionCheckerUtilsKtTest : TestBase() {
|
||||||
@Mock lateinit var context: Context
|
@Mock lateinit var context: Context
|
||||||
val config = Config()
|
val config = Config()
|
||||||
|
|
||||||
val rxBus = RxBusWrapper()
|
private val rxBus = RxBusWrapper(aapsSchedulers)
|
||||||
|
|
||||||
@Before fun setup() {
|
@Before fun setup() {
|
||||||
versionCheckerUtils = VersionCheckerUtils(aapsLogger, sp, resourceHelper, rxBus, config, context)
|
versionCheckerUtils = VersionCheckerUtils(aapsLogger, sp, resourceHelper, rxBus, config, context)
|
||||||
|
|
|
@ -3,7 +3,6 @@ package info.nightscout.androidaps.plugins.general.automation
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.androidaps.TestBase
|
import info.nightscout.androidaps.TestBase
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
|
||||||
import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin
|
import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin
|
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin
|
||||||
|
@ -36,7 +35,7 @@ class AutomationEventTest : TestBase() {
|
||||||
it.loopPlugin = loopPlugin
|
it.loopPlugin = loopPlugin
|
||||||
it.resourceHelper = resourceHelper
|
it.resourceHelper = resourceHelper
|
||||||
it.configBuilderPlugin = configBuilderPlugin
|
it.configBuilderPlugin = configBuilderPlugin
|
||||||
it.rxBus = RxBusWrapper()
|
it.rxBus = RxBusWrapper(aapsSchedulers)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,7 +42,7 @@ open class TriggerTestBase : TestBaseWithProfile() {
|
||||||
AndroidInjector {
|
AndroidInjector {
|
||||||
if (it is Trigger) {
|
if (it is Trigger) {
|
||||||
it.aapsLogger = aapsLogger
|
it.aapsLogger = aapsLogger
|
||||||
it.rxBus = RxBusWrapper()
|
it.rxBus = RxBusWrapper(aapsSchedulers)
|
||||||
it.resourceHelper = resourceHelper
|
it.resourceHelper = resourceHelper
|
||||||
it.profileFunction = profileFunction
|
it.profileFunction = profileFunction
|
||||||
it.sp = sp
|
it.sp = sp
|
||||||
|
|
|
@ -33,7 +33,7 @@ class NsClientReceiverDelegateTest : TestBase() {
|
||||||
@Mock lateinit var resourceHelper: ResourceHelper
|
@Mock lateinit var resourceHelper: ResourceHelper
|
||||||
|
|
||||||
lateinit var receiverStatusStore: ReceiverStatusStore
|
lateinit var receiverStatusStore: ReceiverStatusStore
|
||||||
val rxBus: RxBusWrapper = RxBusWrapper()
|
val rxBus = RxBusWrapper(aapsSchedulers)
|
||||||
|
|
||||||
private var sut: NsClientReceiverDelegate? = null
|
private var sut: NsClientReceiverDelegate? = null
|
||||||
|
|
||||||
|
|
|
@ -114,7 +114,7 @@ class SmsCommunicatorPluginTest : TestBaseWithProfile() {
|
||||||
`when`(SmsManager.getDefault()).thenReturn(smsManager)
|
`when`(SmsManager.getDefault()).thenReturn(smsManager)
|
||||||
`when`(sp.getString(R.string.key_smscommunicator_allowednumbers, "")).thenReturn("1234;5678")
|
`when`(sp.getString(R.string.key_smscommunicator_allowednumbers, "")).thenReturn("1234;5678")
|
||||||
|
|
||||||
smsCommunicatorPlugin = SmsCommunicatorPlugin(injector, aapsLogger, resourceHelper, sp, constraintChecker, rxBus, profileFunction, fabricPrivacy, activePlugin, commandQueue, loopPlugin, iobCobCalculatorPlugin, xdripCalibrations, otp, Config(), DateUtil(context, resourceHelper))
|
smsCommunicatorPlugin = SmsCommunicatorPlugin(injector, aapsLogger, resourceHelper, aapsSchedulers, sp, constraintChecker, rxBus, profileFunction, fabricPrivacy, activePlugin, commandQueue, loopPlugin, iobCobCalculatorPlugin, xdripCalibrations, otp, Config(), DateUtil(context, resourceHelper))
|
||||||
smsCommunicatorPlugin.setPluginEnabled(PluginType.GENERAL, true)
|
smsCommunicatorPlugin.setPluginEnabled(PluginType.GENERAL, true)
|
||||||
Mockito.doAnswer { invocation: InvocationOnMock ->
|
Mockito.doAnswer { invocation: InvocationOnMock ->
|
||||||
val callback = invocation.getArgument<Callback>(1)
|
val callback = invocation.getArgument<Callback>(1)
|
||||||
|
|
|
@ -31,7 +31,7 @@ import java.util.*
|
||||||
class IobCobCalculatorPluginTest : TestBase() {
|
class IobCobCalculatorPluginTest : TestBase() {
|
||||||
|
|
||||||
@Mock lateinit var sp: SP
|
@Mock lateinit var sp: SP
|
||||||
private val rxBus: RxBusWrapper = RxBusWrapper()
|
private val rxBus = RxBusWrapper(aapsSchedulers)
|
||||||
@Mock lateinit var resourceHelper: ResourceHelper
|
@Mock lateinit var resourceHelper: ResourceHelper
|
||||||
@Mock lateinit var profileFunction: ProfileFunction
|
@Mock lateinit var profileFunction: ProfileFunction
|
||||||
@Mock lateinit var activePlugin: ActivePluginProvider
|
@Mock lateinit var activePlugin: ActivePluginProvider
|
||||||
|
@ -59,7 +59,7 @@ class IobCobCalculatorPluginTest : TestBase() {
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
fun mock() {
|
fun mock() {
|
||||||
iobCobCalculatorPlugin = IobCobCalculatorPlugin(injector, aapsLogger, rxBus, sp, resourceHelper, profileFunction, activePlugin, treatmentsPlugin, sensitivityOref1Plugin, sensitivityAAPSPlugin, sensitivityWeightedAveragePlugin, fabricPrivacy, dateUtil)
|
iobCobCalculatorPlugin = IobCobCalculatorPlugin(injector, aapsLogger, aapsSchedulers, rxBus, sp, resourceHelper, profileFunction, activePlugin, treatmentsPlugin, sensitivityOref1Plugin, sensitivityAAPSPlugin, sensitivityWeightedAveragePlugin, fabricPrivacy, dateUtil)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -51,7 +51,7 @@ class ComboPluginTest : TestBase() {
|
||||||
@Before
|
@Before
|
||||||
fun prepareMocks() {
|
fun prepareMocks() {
|
||||||
`when`(resourceHelper.gs(R.string.novalidbasalrate)).thenReturn("No valid basal rate read from pump")
|
`when`(resourceHelper.gs(R.string.novalidbasalrate)).thenReturn("No valid basal rate read from pump")
|
||||||
comboPlugin = ComboPlugin(injector, aapsLogger, RxBusWrapper(), resourceHelper, profileFunction, treatmentsPlugin, sp, commandQueue, context)
|
comboPlugin = ComboPlugin(injector, aapsLogger, RxBusWrapper(aapsSchedulers), resourceHelper, profileFunction, treatmentsPlugin, sp, commandQueue, context)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -46,7 +46,7 @@ class DanaRPluginTest : TestBaseWithProfile() {
|
||||||
`when`(resourceHelper.gs(R.string.limitingbasalratio)).thenReturn("Limiting max basal rate to %1\$.2f U/h because of %2\$s")
|
`when`(resourceHelper.gs(R.string.limitingbasalratio)).thenReturn("Limiting max basal rate to %1\$.2f U/h because of %2\$s")
|
||||||
`when`(resourceHelper.gs(R.string.limitingpercentrate)).thenReturn("Limiting max percent rate to %1\$d%% because of %2\$s")
|
`when`(resourceHelper.gs(R.string.limitingpercentrate)).thenReturn("Limiting max percent rate to %1\$d%% because of %2\$s")
|
||||||
danaPump = info.nightscout.androidaps.dana.DanaPump(aapsLogger, sp, injector)
|
danaPump = info.nightscout.androidaps.dana.DanaPump(aapsLogger, sp, injector)
|
||||||
danaRPlugin = DanaRPlugin(injector, aapsLogger, rxBus, context, resourceHelper, constraintChecker, activePluginProvider, sp, commandQueue, danaPump, dateUtil, fabricPrivacy)
|
danaRPlugin = DanaRPlugin(injector, aapsLogger, aapsSchedulers, rxBus, context, resourceHelper, constraintChecker, activePluginProvider, sp, commandQueue, danaPump, dateUtil, fabricPrivacy)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test @Throws(Exception::class)
|
@Test @Throws(Exception::class)
|
||||||
|
|
|
@ -55,7 +55,7 @@ open class DanaRTestBase : TestBase() {
|
||||||
it.danaRPlugin = danaRPlugin
|
it.danaRPlugin = danaRPlugin
|
||||||
it.danaRKoreanPlugin = danaRKoreanPlugin
|
it.danaRKoreanPlugin = danaRKoreanPlugin
|
||||||
it.danaRv2Plugin = danaRv2Plugin
|
it.danaRv2Plugin = danaRv2Plugin
|
||||||
it.rxBus = RxBusWrapper()
|
it.rxBus = RxBusWrapper(aapsSchedulers)
|
||||||
it.resourceHelper = resourceHelper
|
it.resourceHelper = resourceHelper
|
||||||
it.activePlugin = activePluginProvider
|
it.activePlugin = activePluginProvider
|
||||||
it.configBuilder = configBuilder
|
it.configBuilder = configBuilder
|
||||||
|
|
|
@ -46,7 +46,7 @@ class DanaRKoreanPluginTest : TestBaseWithProfile() {
|
||||||
`when`(resourceHelper.gs(R.string.limitingbasalratio)).thenReturn("Limiting max basal rate to %1\$.2f U/h because of %2\$s")
|
`when`(resourceHelper.gs(R.string.limitingbasalratio)).thenReturn("Limiting max basal rate to %1\$.2f U/h because of %2\$s")
|
||||||
`when`(resourceHelper.gs(R.string.limitingpercentrate)).thenReturn("Limiting max percent rate to %1\$d%% because of %2\$s")
|
`when`(resourceHelper.gs(R.string.limitingpercentrate)).thenReturn("Limiting max percent rate to %1\$d%% because of %2\$s")
|
||||||
danaPump = DanaPump(aapsLogger, sp, injector)
|
danaPump = DanaPump(aapsLogger, sp, injector)
|
||||||
danaRPlugin = DanaRKoreanPlugin(injector, aapsLogger, rxBus, danaPump, context, resourceHelper, constraintChecker, activePluginProvider, sp, commandQueue, dateUtil, fabricPrivacy)
|
danaRPlugin = DanaRKoreanPlugin(injector, aapsLogger, aapsSchedulers, rxBus, danaPump, context, resourceHelper, constraintChecker, activePluginProvider, sp, commandQueue, dateUtil, fabricPrivacy)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test @Throws(Exception::class)
|
@Test @Throws(Exception::class)
|
||||||
|
|
|
@ -65,6 +65,6 @@ class DanaRSPluginTest : DanaRSTestBase() {
|
||||||
Mockito.`when`(resourceHelper.gs(eq(R.string.limitingbasalratio), anyObject(), anyObject())).thenReturn("limitingbasalratio")
|
Mockito.`when`(resourceHelper.gs(eq(R.string.limitingbasalratio), anyObject(), anyObject())).thenReturn("limitingbasalratio")
|
||||||
Mockito.`when`(resourceHelper.gs(eq(R.string.limitingpercentrate), anyObject(), anyObject())).thenReturn("limitingpercentrate")
|
Mockito.`when`(resourceHelper.gs(eq(R.string.limitingpercentrate), anyObject(), anyObject())).thenReturn("limitingpercentrate")
|
||||||
|
|
||||||
danaRSPlugin = DanaRSPlugin(HasAndroidInjector { AndroidInjector { Unit } }, aapsLogger, rxBus, context, resourceHelper, constraintChecker, profileFunction, activePluginProvider, sp, commandQueue, danaPump, detailedBolusInfoStorage, fabricPrivacy, dateUtil)
|
danaRSPlugin = DanaRSPlugin(HasAndroidInjector { AndroidInjector { Unit } }, aapsLogger, aapsSchedulers, rxBus, context, resourceHelper, constraintChecker, profileFunction, activePluginProvider, sp, commandQueue, danaPump, detailedBolusInfoStorage, fabricPrivacy, dateUtil)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -46,7 +46,7 @@ class DanaRv2PluginTest : TestBaseWithProfile() {
|
||||||
`when`(resourceHelper.gs(R.string.limitingbasalratio)).thenReturn("Limiting max basal rate to %1\$.2f U/h because of %2\$s")
|
`when`(resourceHelper.gs(R.string.limitingbasalratio)).thenReturn("Limiting max basal rate to %1\$.2f U/h because of %2\$s")
|
||||||
`when`(resourceHelper.gs(R.string.limitingpercentrate)).thenReturn("Limiting max percent rate to %1\$d%% because of %2\$s")
|
`when`(resourceHelper.gs(R.string.limitingpercentrate)).thenReturn("Limiting max percent rate to %1\$d%% because of %2\$s")
|
||||||
danaPump = DanaPump(aapsLogger, sp, injector)
|
danaPump = DanaPump(aapsLogger, sp, injector)
|
||||||
danaRv2Plugin = DanaRv2Plugin(injector, aapsLogger, rxBus, context, danaPump, resourceHelper, constraintChecker, activePluginProvider, sp, commandQueue, detailedBolusInfoStorage, dateUtil, fabricPrivacy)
|
danaRv2Plugin = DanaRv2Plugin(injector, aapsLogger, aapsSchedulers, rxBus, context, danaPump, resourceHelper, constraintChecker, activePluginProvider, sp, commandQueue, detailedBolusInfoStorage, dateUtil, fabricPrivacy)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -1,13 +1,12 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.virtual
|
package info.nightscout.androidaps.plugins.pump.virtual
|
||||||
|
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
|
||||||
import info.nightscout.androidaps.Config
|
import info.nightscout.androidaps.Config
|
||||||
import info.nightscout.androidaps.R
|
import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.TestBase
|
import info.nightscout.androidaps.TestBase
|
||||||
import info.nightscout.androidaps.interfaces.CommandQueueProvider
|
import info.nightscout.androidaps.interfaces.CommandQueueProvider
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
|
||||||
import info.nightscout.androidaps.interfaces.ProfileFunction
|
import info.nightscout.androidaps.interfaces.ProfileFunction
|
||||||
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
import info.nightscout.androidaps.plugins.pump.common.defs.PumpType
|
import info.nightscout.androidaps.plugins.pump.common.defs.PumpType
|
||||||
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin
|
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin
|
||||||
import info.nightscout.androidaps.utils.DateUtil
|
import info.nightscout.androidaps.utils.DateUtil
|
||||||
|
@ -27,7 +26,7 @@ import org.powermock.modules.junit4.PowerMockRunner
|
||||||
@PrepareForTest(FabricPrivacy::class)
|
@PrepareForTest(FabricPrivacy::class)
|
||||||
class VirtualPumpPluginUTest : TestBase() {
|
class VirtualPumpPluginUTest : TestBase() {
|
||||||
|
|
||||||
val rxBus = RxBusWrapper()
|
private val rxBus = RxBusWrapper(aapsSchedulers)
|
||||||
@Mock lateinit var fabricPrivacy: FabricPrivacy
|
@Mock lateinit var fabricPrivacy: FabricPrivacy
|
||||||
@Mock lateinit var resourceHelper: ResourceHelper
|
@Mock lateinit var resourceHelper: ResourceHelper
|
||||||
@Mock lateinit var sp: SP
|
@Mock lateinit var sp: SP
|
||||||
|
@ -40,7 +39,7 @@ class VirtualPumpPluginUTest : TestBase() {
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
fun prepareMocks() {
|
fun prepareMocks() {
|
||||||
virtualPumpPlugin = VirtualPumpPlugin(HasAndroidInjector { AndroidInjector { } }, aapsLogger, rxBus, fabricPrivacy, resourceHelper, sp, profileFunction, treatmentsPlugin, commandQueue, Config(), dateUtil)
|
virtualPumpPlugin = VirtualPumpPlugin({ AndroidInjector { } }, aapsLogger, rxBus, fabricPrivacy, resourceHelper, aapsSchedulers, sp, profileFunction, treatmentsPlugin, commandQueue, Config(), dateUtil)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -1,10 +1,8 @@
|
||||||
package info.nightscout.androidaps.plugins.source
|
package info.nightscout.androidaps.plugins.source
|
||||||
|
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
|
||||||
import info.nightscout.androidaps.Config
|
import info.nightscout.androidaps.Config
|
||||||
import info.nightscout.androidaps.TestBase
|
import info.nightscout.androidaps.TestBase
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||||
import org.junit.Assert
|
import org.junit.Assert
|
||||||
|
@ -24,7 +22,7 @@ class NSClientPluginTest : TestBase() {
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
fun setup() {
|
fun setup() {
|
||||||
nsClientSourcePlugin = NSClientSourcePlugin(HasAndroidInjector { AndroidInjector { } }, resourceHelper, aapsLogger, sp, Config())
|
nsClientSourcePlugin = NSClientSourcePlugin({ AndroidInjector { } }, resourceHelper, aapsLogger, Config())
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun advancedFilteringSupported() {
|
@Test fun advancedFilteringSupported() {
|
||||||
|
|
|
@ -60,7 +60,7 @@ class TreatmentsPluginTest : TestBaseWithProfile() {
|
||||||
`when`(profileFunction.getProfile(ArgumentMatchers.anyLong())).thenReturn(validProfile)
|
`when`(profileFunction.getProfile(ArgumentMatchers.anyLong())).thenReturn(validProfile)
|
||||||
`when`(activePluginProvider.activeInsulin).thenReturn(insulinOrefRapidActingPlugin)
|
`when`(activePluginProvider.activeInsulin).thenReturn(insulinOrefRapidActingPlugin)
|
||||||
|
|
||||||
sot = TreatmentsPlugin(profileInjector, aapsLogger, rxBus, resourceHelper, context, sp, profileFunction, activePluginProvider, nsUpload, fabricPrivacy, dateUtil, uploadQueue)
|
sot = TreatmentsPlugin(profileInjector, aapsLogger, rxBus, aapsSchedulers, resourceHelper, context, sp, profileFunction, activePluginProvider, nsUpload, fabricPrivacy, dateUtil, uploadQueue)
|
||||||
sot.service = treatmentService
|
sot.service = treatmentService
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,10 +11,10 @@ import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
||||||
import info.nightscout.androidaps.interfaces.Constraint
|
import info.nightscout.androidaps.interfaces.Constraint
|
||||||
import info.nightscout.androidaps.interfaces.PumpDescription
|
import info.nightscout.androidaps.interfaces.PumpDescription
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker
|
import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker
|
||||||
import info.nightscout.androidaps.queue.commands.CustomCommand
|
|
||||||
import info.nightscout.androidaps.plugins.pump.virtual.VirtualPumpPlugin
|
import info.nightscout.androidaps.plugins.pump.virtual.VirtualPumpPlugin
|
||||||
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin
|
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin
|
||||||
import info.nightscout.androidaps.queue.commands.Command
|
import info.nightscout.androidaps.queue.commands.Command
|
||||||
|
import info.nightscout.androidaps.queue.commands.CustomCommand
|
||||||
import info.nightscout.androidaps.utils.FabricPrivacy
|
import info.nightscout.androidaps.utils.FabricPrivacy
|
||||||
import info.nightscout.androidaps.utils.ToastUtils
|
import info.nightscout.androidaps.utils.ToastUtils
|
||||||
import info.nightscout.androidaps.utils.buildHelper.BuildHelper
|
import info.nightscout.androidaps.utils.buildHelper.BuildHelper
|
||||||
|
@ -55,7 +55,7 @@ class CommandQueueTest : TestBaseWithProfile() {
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
fun prepare() {
|
fun prepare() {
|
||||||
commandQueue = CommandQueue(injector, aapsLogger, rxBus, resourceHelper, constraintChecker, profileFunction, lazyActivePlugin, context, sp, buildHelper, fabricPrivacy)
|
commandQueue = CommandQueue(injector, aapsLogger, rxBus, aapsSchedulers, resourceHelper, constraintChecker, profileFunction, lazyActivePlugin, context, sp, buildHelper, fabricPrivacy)
|
||||||
|
|
||||||
val pumpDescription = PumpDescription()
|
val pumpDescription = PumpDescription()
|
||||||
pumpDescription.basalMinimumRate = 0.1
|
pumpDescription.basalMinimumRate = 0.1
|
||||||
|
@ -268,16 +268,19 @@ class CommandQueueTest : TestBaseWithProfile() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private class CustomCommand1 : CustomCommand {
|
private class CustomCommand1 : CustomCommand {
|
||||||
|
|
||||||
override val statusDescription: String
|
override val statusDescription: String
|
||||||
get() = "CUSTOM COMMAND 1"
|
get() = "CUSTOM COMMAND 1"
|
||||||
}
|
}
|
||||||
|
|
||||||
private class CustomCommand2 : CustomCommand {
|
private class CustomCommand2 : CustomCommand {
|
||||||
|
|
||||||
override val statusDescription: String
|
override val statusDescription: String
|
||||||
get() = "CUSTOM COMMAND 2"
|
get() = "CUSTOM COMMAND 2"
|
||||||
}
|
}
|
||||||
|
|
||||||
private class CustomCommand3 : CustomCommand {
|
private class CustomCommand3 : CustomCommand {
|
||||||
|
|
||||||
override val statusDescription: String
|
override val statusDescription: String
|
||||||
get() = "CUSTOM COMMAND 3"
|
get() = "CUSTOM COMMAND 3"
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,7 +52,7 @@ class BolusWizardTest : TestBase() {
|
||||||
if (it is BolusWizard) {
|
if (it is BolusWizard) {
|
||||||
it.aapsLogger = aapsLogger
|
it.aapsLogger = aapsLogger
|
||||||
it.resourceHelper = resourceHelper
|
it.resourceHelper = resourceHelper
|
||||||
it.rxBus = RxBusWrapper()
|
it.rxBus = RxBusWrapper(aapsSchedulers)
|
||||||
it.profileFunction = profileFunction
|
it.profileFunction = profileFunction
|
||||||
it.constraintChecker = constraintChecker
|
it.constraintChecker = constraintChecker
|
||||||
it.activePlugin = activePlugin
|
it.activePlugin = activePlugin
|
||||||
|
|
|
@ -2,12 +2,12 @@
|
||||||
|
|
||||||
buildscript {
|
buildscript {
|
||||||
ext {
|
ext {
|
||||||
kotlin_version = '1.4.21'
|
kotlin_version = '1.4.30'
|
||||||
coreVersion = '1.3.2'
|
coreVersion = '1.3.2'
|
||||||
rxjava_version = '2.2.19'
|
rxjava_version = '2.2.20'
|
||||||
rxandroid_version = '2.1.1'
|
rxandroid_version = '2.1.1'
|
||||||
rxkotlin_version = '2.4.0'
|
rxkotlin_version = '2.4.0'
|
||||||
room_version = '2.2.5'
|
room_version = '2.2.6'
|
||||||
lifecycle_version = '2.2.0'
|
lifecycle_version = '2.2.0'
|
||||||
dagger_version = '2.31.2'
|
dagger_version = '2.31.2'
|
||||||
coroutinesVersion = '1.3.7'
|
coroutinesVersion = '1.3.7'
|
||||||
|
|
|
@ -45,6 +45,7 @@ import info.nightscout.androidaps.queue.Callback;
|
||||||
import info.nightscout.androidaps.utils.FabricPrivacy;
|
import info.nightscout.androidaps.utils.FabricPrivacy;
|
||||||
import info.nightscout.androidaps.utils.SafeParse;
|
import info.nightscout.androidaps.utils.SafeParse;
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper;
|
import info.nightscout.androidaps.utils.resources.ResourceHelper;
|
||||||
|
import info.nightscout.androidaps.utils.rx.AapsSchedulers;
|
||||||
import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||||
import io.reactivex.disposables.CompositeDisposable;
|
import io.reactivex.disposables.CompositeDisposable;
|
||||||
|
@ -59,6 +60,7 @@ public class TDDStatsActivity extends NoSplashAppCompatActivity {
|
||||||
@Inject CommandQueueProvider commandQueue;
|
@Inject CommandQueueProvider commandQueue;
|
||||||
@Inject DatabaseHelperInterface databaseHelper;
|
@Inject DatabaseHelperInterface databaseHelper;
|
||||||
@Inject FabricPrivacy fabricPrivacy;
|
@Inject FabricPrivacy fabricPrivacy;
|
||||||
|
@Inject AapsSchedulers aapsSchedulers;
|
||||||
|
|
||||||
private final CompositeDisposable disposable = new CompositeDisposable();
|
private final CompositeDisposable disposable = new CompositeDisposable();
|
||||||
|
|
||||||
|
@ -83,12 +85,12 @@ public class TDDStatsActivity extends NoSplashAppCompatActivity {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
disposable.add(rxBus
|
disposable.add(rxBus
|
||||||
.toObservable(EventPumpStatusChanged.class)
|
.toObservable(EventPumpStatusChanged.class)
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(aapsSchedulers.getMain())
|
||||||
.subscribe(event -> statusView.setText(event.getStatus(resourceHelper)), exception -> fabricPrivacy.logException(exception))
|
.subscribe(event -> statusView.setText(event.getStatus(resourceHelper)), exception -> fabricPrivacy.logException(exception))
|
||||||
);
|
);
|
||||||
disposable.add(rxBus
|
disposable.add(rxBus
|
||||||
.toObservable(EventDanaRSyncStatus.class)
|
.toObservable(EventDanaRSyncStatus.class)
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(aapsSchedulers.getMain())
|
||||||
.subscribe(event -> {
|
.subscribe(event -> {
|
||||||
aapsLogger.debug("EventDanaRSyncStatus: " + event.getMessage());
|
aapsLogger.debug("EventDanaRSyncStatus: " + event.getMessage());
|
||||||
statusView.setText(event.getMessage());
|
statusView.setText(event.getMessage());
|
||||||
|
|
|
@ -20,7 +20,7 @@ import info.nightscout.androidaps.plugins.general.overview.events.EventDismissBo
|
||||||
import info.nightscout.androidaps.plugins.general.overview.events.EventOverviewBolusProgress
|
import info.nightscout.androidaps.plugins.general.overview.events.EventOverviewBolusProgress
|
||||||
import info.nightscout.androidaps.utils.FabricPrivacy
|
import info.nightscout.androidaps.utils.FabricPrivacy
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
import info.nightscout.androidaps.utils.rx.AapsSchedulers
|
||||||
import io.reactivex.disposables.CompositeDisposable
|
import io.reactivex.disposables.CompositeDisposable
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
@ -31,6 +31,7 @@ class BolusProgressDialog : DaggerDialogFragment() {
|
||||||
@Inject lateinit var resourceHelper: ResourceHelper
|
@Inject lateinit var resourceHelper: ResourceHelper
|
||||||
@Inject lateinit var commandQueue: CommandQueueProvider
|
@Inject lateinit var commandQueue: CommandQueueProvider
|
||||||
@Inject lateinit var fabricPrivacy: FabricPrivacy
|
@Inject lateinit var fabricPrivacy: FabricPrivacy
|
||||||
|
@Inject lateinit var aapsSchedulers: AapsSchedulers
|
||||||
|
|
||||||
private val disposable = CompositeDisposable()
|
private val disposable = CompositeDisposable()
|
||||||
|
|
||||||
|
@ -111,17 +112,17 @@ class BolusProgressDialog : DaggerDialogFragment() {
|
||||||
|
|
||||||
disposable.add(rxBus
|
disposable.add(rxBus
|
||||||
.toObservable(EventPumpStatusChanged::class.java)
|
.toObservable(EventPumpStatusChanged::class.java)
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(aapsSchedulers.main)
|
||||||
.subscribe({ binding.status.text = it.getStatus(resourceHelper) }) { fabricPrivacy.logException(it) }
|
.subscribe({ binding.status.text = it.getStatus(resourceHelper) }, fabricPrivacy::logException)
|
||||||
)
|
)
|
||||||
disposable.add(rxBus
|
disposable.add(rxBus
|
||||||
.toObservable(EventDismissBolusProgressIfRunning::class.java)
|
.toObservable(EventDismissBolusProgressIfRunning::class.java)
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(aapsSchedulers.main)
|
||||||
.subscribe({ if (running) dismiss() }) { fabricPrivacy.logException(it) }
|
.subscribe({ if (running) dismiss() }, fabricPrivacy::logException)
|
||||||
)
|
)
|
||||||
disposable.add(rxBus
|
disposable.add(rxBus
|
||||||
.toObservable(EventOverviewBolusProgress::class.java)
|
.toObservable(EventOverviewBolusProgress::class.java)
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(aapsSchedulers.main)
|
||||||
.subscribe({
|
.subscribe({
|
||||||
aapsLogger.debug(LTag.UI, "Status: ${it.status} Percent: ${it.percent}")
|
aapsLogger.debug(LTag.UI, "Status: ${it.status} Percent: ${it.percent}")
|
||||||
binding.status.text = it.status
|
binding.status.text = it.status
|
||||||
|
@ -131,7 +132,7 @@ class BolusProgressDialog : DaggerDialogFragment() {
|
||||||
scheduleDismiss()
|
scheduleDismiss()
|
||||||
}
|
}
|
||||||
state = it.status
|
state = it.status
|
||||||
}) { fabricPrivacy.logException(it) }
|
}, fabricPrivacy::logException)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,7 @@ import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
import info.nightscout.androidaps.utils.FabricPrivacy
|
import info.nightscout.androidaps.utils.FabricPrivacy
|
||||||
import info.nightscout.androidaps.utils.extensions.plusAssign
|
import info.nightscout.androidaps.utils.extensions.plusAssign
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
|
import info.nightscout.androidaps.utils.rx.AapsSchedulers
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||||
import io.reactivex.disposables.CompositeDisposable
|
import io.reactivex.disposables.CompositeDisposable
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
@ -25,6 +26,7 @@ class NtpProgressDialog : DaggerDialogFragment() {
|
||||||
@Inject lateinit var aapsLogger: AAPSLogger
|
@Inject lateinit var aapsLogger: AAPSLogger
|
||||||
@Inject lateinit var resourceHelper: ResourceHelper
|
@Inject lateinit var resourceHelper: ResourceHelper
|
||||||
@Inject lateinit var fabricPrivacy: FabricPrivacy
|
@Inject lateinit var fabricPrivacy: FabricPrivacy
|
||||||
|
@Inject lateinit var aapsSchedulers: AapsSchedulers
|
||||||
|
|
||||||
private val disposable = CompositeDisposable()
|
private val disposable = CompositeDisposable()
|
||||||
|
|
||||||
|
@ -71,7 +73,7 @@ class NtpProgressDialog : DaggerDialogFragment() {
|
||||||
|
|
||||||
disposable += rxBus
|
disposable += rxBus
|
||||||
.toObservable(EventNtpStatus::class.java)
|
.toObservable(EventNtpStatus::class.java)
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(aapsSchedulers.main)
|
||||||
.subscribe({ event: EventNtpStatus ->
|
.subscribe({ event: EventNtpStatus ->
|
||||||
if (_binding != null) {
|
if (_binding != null) {
|
||||||
aapsLogger.debug(LTag.UI, "Status: " + event.status + " Percent: " + event.percent)
|
aapsLogger.debug(LTag.UI, "Status: " + event.status + " Percent: " + event.percent)
|
||||||
|
|
|
@ -1,14 +1,16 @@
|
||||||
package info.nightscout.androidaps.plugins.bus
|
package info.nightscout.androidaps.plugins.bus
|
||||||
|
|
||||||
import info.nightscout.androidaps.events.Event
|
import info.nightscout.androidaps.events.Event
|
||||||
|
import info.nightscout.androidaps.utils.rx.AapsSchedulers
|
||||||
import io.reactivex.Observable
|
import io.reactivex.Observable
|
||||||
import io.reactivex.schedulers.Schedulers
|
|
||||||
import io.reactivex.subjects.PublishSubject
|
import io.reactivex.subjects.PublishSubject
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
import javax.inject.Singleton
|
import javax.inject.Singleton
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
open class RxBusWrapper @Inject constructor() {
|
open class RxBusWrapper @Inject constructor(
|
||||||
|
val aapsSchedulers: AapsSchedulers
|
||||||
|
) {
|
||||||
|
|
||||||
private val publisher = PublishSubject.create<Event>()
|
private val publisher = PublishSubject.create<Event>()
|
||||||
|
|
||||||
|
@ -20,6 +22,6 @@ open class RxBusWrapper @Inject constructor() {
|
||||||
// Using ofType we filter only events that match that class type
|
// Using ofType we filter only events that match that class type
|
||||||
fun <T> toObservable(eventType: Class<T>): Observable<T> =
|
fun <T> toObservable(eventType: Class<T>): Observable<T> =
|
||||||
publisher
|
publisher
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(aapsSchedulers.io)
|
||||||
.ofType(eventType)
|
.ofType(eventType)
|
||||||
}
|
}
|
|
@ -41,6 +41,7 @@ import info.nightscout.androidaps.utils.DateUtil;
|
||||||
import info.nightscout.androidaps.utils.DecimalFormatter;
|
import info.nightscout.androidaps.utils.DecimalFormatter;
|
||||||
import info.nightscout.androidaps.utils.FabricPrivacy;
|
import info.nightscout.androidaps.utils.FabricPrivacy;
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper;
|
import info.nightscout.androidaps.utils.resources.ResourceHelper;
|
||||||
|
import info.nightscout.androidaps.utils.rx.AapsSchedulers;
|
||||||
import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
||||||
import io.reactivex.disposables.CompositeDisposable;
|
import io.reactivex.disposables.CompositeDisposable;
|
||||||
import io.reactivex.schedulers.Schedulers;
|
import io.reactivex.schedulers.Schedulers;
|
||||||
|
@ -70,6 +71,7 @@ public abstract class PumpPluginAbstract extends PumpPluginBase implements PumpI
|
||||||
protected PumpDriverState pumpState = PumpDriverState.NotInitialized;
|
protected PumpDriverState pumpState = PumpDriverState.NotInitialized;
|
||||||
protected boolean displayConnectionMessages = false;
|
protected boolean displayConnectionMessages = false;
|
||||||
protected PumpType pumpType;
|
protected PumpType pumpType;
|
||||||
|
protected AapsSchedulers aapsSchedulers;
|
||||||
|
|
||||||
|
|
||||||
protected PumpPluginAbstract(
|
protected PumpPluginAbstract(
|
||||||
|
@ -84,7 +86,8 @@ public abstract class PumpPluginAbstract extends PumpPluginBase implements PumpI
|
||||||
SP sp,
|
SP sp,
|
||||||
Context context,
|
Context context,
|
||||||
FabricPrivacy fabricPrivacy,
|
FabricPrivacy fabricPrivacy,
|
||||||
DateUtil dateUtil
|
DateUtil dateUtil,
|
||||||
|
AapsSchedulers aapsSchedulers
|
||||||
) {
|
) {
|
||||||
|
|
||||||
super(pluginDescription, injector, aapsLogger, resourceHelper, commandQueue);
|
super(pluginDescription, injector, aapsLogger, resourceHelper, commandQueue);
|
||||||
|
@ -100,6 +103,7 @@ public abstract class PumpPluginAbstract extends PumpPluginBase implements PumpI
|
||||||
pumpDescription.setPumpDescription(pumpType);
|
pumpDescription.setPumpDescription(pumpType);
|
||||||
this.pumpType = pumpType;
|
this.pumpType = pumpType;
|
||||||
this.dateUtil = dateUtil;
|
this.dateUtil = dateUtil;
|
||||||
|
this.aapsSchedulers = aapsSchedulers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -119,7 +123,7 @@ public abstract class PumpPluginAbstract extends PumpPluginBase implements PumpI
|
||||||
|
|
||||||
disposable.add(rxBus
|
disposable.add(rxBus
|
||||||
.toObservable(EventAppExit.class)
|
.toObservable(EventAppExit.class)
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(aapsSchedulers.getIo())
|
||||||
.subscribe(event -> context.unbindService(serviceConnection), fabricPrivacy::logException)
|
.subscribe(event -> context.unbindService(serviceConnection), fabricPrivacy::logException)
|
||||||
);
|
);
|
||||||
onStartCustomActions();
|
onStartCustomActions();
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
package info.nightscout.androidaps.utils.rx
|
||||||
|
|
||||||
|
import io.reactivex.Scheduler
|
||||||
|
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||||
|
import io.reactivex.schedulers.Schedulers
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by adrian on 12.04.20.
|
||||||
|
*/
|
||||||
|
|
||||||
|
interface AapsSchedulers {
|
||||||
|
val main: Scheduler
|
||||||
|
val io: Scheduler
|
||||||
|
val cpu: Scheduler
|
||||||
|
}
|
||||||
|
|
||||||
|
class DefaultAapsSchedulers : AapsSchedulers {
|
||||||
|
override val main: Scheduler = AndroidSchedulers.mainThread()
|
||||||
|
override val io: Scheduler = Schedulers.io()
|
||||||
|
override val cpu: Scheduler = Schedulers.computation()
|
||||||
|
}
|
||||||
|
|
||||||
|
class TestAapsSchedulers : AapsSchedulers {
|
||||||
|
override val main: Scheduler = Schedulers.trampoline()
|
||||||
|
override val io: Scheduler = Schedulers.trampoline()
|
||||||
|
override val cpu: Scheduler = Schedulers.trampoline()
|
||||||
|
}
|
|
@ -0,0 +1,43 @@
|
||||||
|
package info.nightscout.androidaps.utils.rx
|
||||||
|
|
||||||
|
import io.reactivex.Completable
|
||||||
|
import io.reactivex.Flowable
|
||||||
|
import io.reactivex.Single
|
||||||
|
import java.util.concurrent.TimeUnit
|
||||||
|
import kotlin.math.pow
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by adrian on 12.04.20.
|
||||||
|
*/
|
||||||
|
|
||||||
|
inline fun <reified T> Single<T>.retryExponentialBackoff(retries: Int, time: Long, timeUnit: TimeUnit): Single<T> =
|
||||||
|
this.retryWhen { throwables: Flowable<Throwable> ->
|
||||||
|
throwables.zipWith(
|
||||||
|
Flowable.range(0, retries),
|
||||||
|
{ throwable: Throwable, retryCount: Int ->
|
||||||
|
if (retryCount >= retries) {
|
||||||
|
throw throwable
|
||||||
|
} else {
|
||||||
|
retryCount
|
||||||
|
}
|
||||||
|
}
|
||||||
|
).flatMap { retryCount: Int ->
|
||||||
|
Flowable.timer(time * 2.toDouble().pow(retryCount.toDouble()).toLong(), timeUnit)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun Completable.retryExponentialBackoff(retries: Int, time: Long, timeUnit: TimeUnit): Completable =
|
||||||
|
this.retryWhen { throwables: Flowable<Throwable> ->
|
||||||
|
throwables.zipWith(
|
||||||
|
Flowable.range(0, retries),
|
||||||
|
{ throwable: Throwable, retryCount: Int ->
|
||||||
|
if (retryCount >= retries) {
|
||||||
|
throw throwable
|
||||||
|
} else {
|
||||||
|
retryCount
|
||||||
|
}
|
||||||
|
}
|
||||||
|
).flatMap { retryCount: Int ->
|
||||||
|
Flowable.timer(time * 2.toDouble().pow(retryCount.toDouble()).toLong(), timeUnit)
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,5 +1,6 @@
|
||||||
package info.nightscout.androidaps.dana
|
package info.nightscout.androidaps.dana
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.os.Handler
|
import android.os.Handler
|
||||||
|
@ -30,8 +31,8 @@ import info.nightscout.androidaps.utils.alertDialogs.OKDialog
|
||||||
import info.nightscout.androidaps.utils.extensions.plusAssign
|
import info.nightscout.androidaps.utils.extensions.plusAssign
|
||||||
import info.nightscout.androidaps.utils.extensions.toVisibility
|
import info.nightscout.androidaps.utils.extensions.toVisibility
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
|
import info.nightscout.androidaps.utils.rx.AapsSchedulers
|
||||||
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
|
||||||
import io.reactivex.disposables.CompositeDisposable
|
import io.reactivex.disposables.CompositeDisposable
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
@ -47,6 +48,7 @@ class DanaFragment : DaggerFragment() {
|
||||||
@Inject lateinit var sp: SP
|
@Inject lateinit var sp: SP
|
||||||
@Inject lateinit var warnColors: WarnColors
|
@Inject lateinit var warnColors: WarnColors
|
||||||
@Inject lateinit var dateUtil: DateUtil
|
@Inject lateinit var dateUtil: DateUtil
|
||||||
|
@Inject lateinit var aapsSchedulers: AapsSchedulers
|
||||||
|
|
||||||
private var disposable: CompositeDisposable = CompositeDisposable()
|
private var disposable: CompositeDisposable = CompositeDisposable()
|
||||||
|
|
||||||
|
@ -118,38 +120,39 @@ class DanaFragment : DaggerFragment() {
|
||||||
loopHandler.postDelayed(refreshLoop, T.mins(1).msecs())
|
loopHandler.postDelayed(refreshLoop, T.mins(1).msecs())
|
||||||
disposable += rxBus
|
disposable += rxBus
|
||||||
.toObservable(EventInitializationChanged::class.java)
|
.toObservable(EventInitializationChanged::class.java)
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(aapsSchedulers.main)
|
||||||
.subscribe({ updateGUI() }, fabricPrivacy::logException)
|
.subscribe({ updateGUI() }, fabricPrivacy::logException)
|
||||||
disposable += rxBus
|
disposable += rxBus
|
||||||
.toObservable(info.nightscout.androidaps.dana.events.EventDanaRNewStatus::class.java)
|
.toObservable(info.nightscout.androidaps.dana.events.EventDanaRNewStatus::class.java)
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(aapsSchedulers.main)
|
||||||
.subscribe({ updateGUI() }, fabricPrivacy::logException)
|
.subscribe({ updateGUI() }, fabricPrivacy::logException)
|
||||||
disposable += rxBus
|
disposable += rxBus
|
||||||
.toObservable(EventExtendedBolusChange::class.java)
|
.toObservable(EventExtendedBolusChange::class.java)
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(aapsSchedulers.main)
|
||||||
.subscribe({ updateGUI() }, fabricPrivacy::logException)
|
.subscribe({ updateGUI() }, fabricPrivacy::logException)
|
||||||
disposable += rxBus
|
disposable += rxBus
|
||||||
.toObservable(EventTempBasalChange::class.java)
|
.toObservable(EventTempBasalChange::class.java)
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(aapsSchedulers.main)
|
||||||
.subscribe({ updateGUI() }, fabricPrivacy::logException)
|
.subscribe({ updateGUI() }, fabricPrivacy::logException)
|
||||||
disposable += rxBus
|
disposable += rxBus
|
||||||
.toObservable(EventQueueChanged::class.java)
|
.toObservable(EventQueueChanged::class.java)
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(aapsSchedulers.main)
|
||||||
.subscribe({ updateGUI() }, fabricPrivacy::logException)
|
.subscribe({ updateGUI() }, fabricPrivacy::logException)
|
||||||
disposable += rxBus
|
disposable += rxBus
|
||||||
.toObservable(EventPumpStatusChanged::class.java)
|
.toObservable(EventPumpStatusChanged::class.java)
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(aapsSchedulers.main)
|
||||||
.subscribe({
|
.subscribe({
|
||||||
when {
|
when (it.status) {
|
||||||
it.status == EventPumpStatusChanged.Status.CONNECTING ->
|
EventPumpStatusChanged.Status.CONNECTING ->
|
||||||
@Suppress("SetTextI18n")
|
@Suppress("SetTextI18n")
|
||||||
binding.btconnection.text = "{fa-bluetooth-b spin} ${it.secondsElapsed}s"
|
binding.btconnection.text = "{fa-bluetooth-b spin} ${it.secondsElapsed}s"
|
||||||
it.status == EventPumpStatusChanged.Status.CONNECTED ->
|
EventPumpStatusChanged.Status.CONNECTED ->
|
||||||
@Suppress("SetTextI18n")
|
@Suppress("SetTextI18n")
|
||||||
binding.btconnection.text = "{fa-bluetooth}"
|
binding.btconnection.text = "{fa-bluetooth}"
|
||||||
it.status == EventPumpStatusChanged.Status.DISCONNECTED ->
|
EventPumpStatusChanged.Status.DISCONNECTED ->
|
||||||
@Suppress("SetTextI18n")
|
@Suppress("SetTextI18n")
|
||||||
binding.btconnection.text = "{fa-bluetooth-b}"
|
binding.btconnection.text = "{fa-bluetooth-b}"
|
||||||
|
else -> {}
|
||||||
}
|
}
|
||||||
if (it.getStatus(resourceHelper) != "") {
|
if (it.getStatus(resourceHelper) != "") {
|
||||||
binding.danaPumpstatus.text = it.getStatus(resourceHelper)
|
binding.danaPumpstatus.text = it.getStatus(resourceHelper)
|
||||||
|
@ -174,6 +177,7 @@ class DanaFragment : DaggerFragment() {
|
||||||
_binding = null
|
_binding = null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressLint("SetTextI18n")
|
||||||
@Synchronized
|
@Synchronized
|
||||||
fun updateGUI() {
|
fun updateGUI() {
|
||||||
if (_binding == null) return
|
if (_binding == null) return
|
||||||
|
@ -199,7 +203,7 @@ class DanaFragment : DaggerFragment() {
|
||||||
warnColors.setColor(binding.dailyunits, pump.dailyTotalUnits, pump.maxDailyTotalUnits * 0.75, pump.maxDailyTotalUnits * 0.9)
|
warnColors.setColor(binding.dailyunits, pump.dailyTotalUnits, pump.maxDailyTotalUnits * 0.75, pump.maxDailyTotalUnits * 0.9)
|
||||||
binding.basabasalrate.text = "( " + (pump.activeProfile + 1) + " ) " + resourceHelper.gs(R.string.pump_basebasalrate, plugin.baseBasalRate)
|
binding.basabasalrate.text = "( " + (pump.activeProfile + 1) + " ) " + resourceHelper.gs(R.string.pump_basebasalrate, plugin.baseBasalRate)
|
||||||
// DanaRPlugin, DanaRKoreanPlugin
|
// DanaRPlugin, DanaRKoreanPlugin
|
||||||
if (activePlugin.activePump.isFakingTempsByExtendedBoluses == true) {
|
if (activePlugin.activePump.isFakingTempsByExtendedBoluses) {
|
||||||
binding.tempbasal.text = activePlugin.activeTreatments.getRealTempBasalFromHistory(System.currentTimeMillis())?.toStringFull()
|
binding.tempbasal.text = activePlugin.activeTreatments.getRealTempBasalFromHistory(System.currentTimeMillis())?.toStringFull()
|
||||||
?: ""
|
?: ""
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -31,7 +31,7 @@ import info.nightscout.androidaps.utils.DateUtil
|
||||||
import info.nightscout.androidaps.utils.DecimalFormatter
|
import info.nightscout.androidaps.utils.DecimalFormatter
|
||||||
import info.nightscout.androidaps.utils.FabricPrivacy
|
import info.nightscout.androidaps.utils.FabricPrivacy
|
||||||
import info.nightscout.androidaps.utils.extensions.plusAssign
|
import info.nightscout.androidaps.utils.extensions.plusAssign
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
import info.nightscout.androidaps.utils.rx.AapsSchedulers
|
||||||
import io.reactivex.disposables.CompositeDisposable
|
import io.reactivex.disposables.CompositeDisposable
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
@ -46,6 +46,7 @@ class DanaHistoryActivity : NoSplashAppCompatActivity() {
|
||||||
@Inject lateinit var commandQueue: CommandQueueProvider
|
@Inject lateinit var commandQueue: CommandQueueProvider
|
||||||
@Inject lateinit var databaseHelper: DatabaseHelperInterface
|
@Inject lateinit var databaseHelper: DatabaseHelperInterface
|
||||||
@Inject lateinit var dateUtil: DateUtil
|
@Inject lateinit var dateUtil: DateUtil
|
||||||
|
@Inject lateinit var aapsSchedulers: AapsSchedulers
|
||||||
|
|
||||||
private val disposable = CompositeDisposable()
|
private val disposable = CompositeDisposable()
|
||||||
|
|
||||||
|
@ -63,15 +64,15 @@ class DanaHistoryActivity : NoSplashAppCompatActivity() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
disposable += rxBus
|
disposable += rxBus
|
||||||
.toObservable(EventPumpStatusChanged::class.java)
|
.toObservable(EventPumpStatusChanged::class.java)
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(aapsSchedulers.main)
|
||||||
.subscribe({ binding.status.text = it.getStatus(resourceHelper) }) { fabricPrivacy.logException(it) }
|
.subscribe({ binding.status.text = it.getStatus(resourceHelper) }, fabricPrivacy::logException)
|
||||||
disposable += rxBus
|
disposable += rxBus
|
||||||
.toObservable(EventDanaRSyncStatus::class.java)
|
.toObservable(EventDanaRSyncStatus::class.java)
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(aapsSchedulers.main)
|
||||||
.subscribe({
|
.subscribe({
|
||||||
aapsLogger.debug(LTag.PUMP, "EventDanaRSyncStatus: " + it.message)
|
aapsLogger.debug(LTag.PUMP, "EventDanaRSyncStatus: " + it.message)
|
||||||
binding.status.text = it.message
|
binding.status.text = it.message
|
||||||
}) { fabricPrivacy.logException(it) }
|
}, fabricPrivacy::logException)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onPause() {
|
override fun onPause() {
|
||||||
|
|
|
@ -19,7 +19,7 @@ import info.nightscout.androidaps.plugins.pump.common.defs.PumpType
|
||||||
import info.nightscout.androidaps.queue.Callback
|
import info.nightscout.androidaps.queue.Callback
|
||||||
import info.nightscout.androidaps.utils.FabricPrivacy
|
import info.nightscout.androidaps.utils.FabricPrivacy
|
||||||
import info.nightscout.androidaps.utils.extensions.plusAssign
|
import info.nightscout.androidaps.utils.extensions.plusAssign
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
import info.nightscout.androidaps.utils.rx.AapsSchedulers
|
||||||
import io.reactivex.disposables.CompositeDisposable
|
import io.reactivex.disposables.CompositeDisposable
|
||||||
import java.text.DecimalFormat
|
import java.text.DecimalFormat
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
@ -35,6 +35,7 @@ class DanaUserOptionsActivity : NoSplashAppCompatActivity() {
|
||||||
@Inject lateinit var danaPump: DanaPump
|
@Inject lateinit var danaPump: DanaPump
|
||||||
@Inject lateinit var activePlugin: ActivePluginProvider
|
@Inject lateinit var activePlugin: ActivePluginProvider
|
||||||
@Inject lateinit var commandQueue: CommandQueueProvider
|
@Inject lateinit var commandQueue: CommandQueueProvider
|
||||||
|
@Inject lateinit var aapsSchedulers: AapsSchedulers
|
||||||
|
|
||||||
private val disposable = CompositeDisposable()
|
private val disposable = CompositeDisposable()
|
||||||
|
|
||||||
|
@ -52,8 +53,8 @@ class DanaUserOptionsActivity : NoSplashAppCompatActivity() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
disposable += rxBus
|
disposable += rxBus
|
||||||
.toObservable(EventInitializationChanged::class.java)
|
.toObservable(EventInitializationChanged::class.java)
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(aapsSchedulers.main)
|
||||||
.subscribe({ setData() }) { fabricPrivacy.logException(it) }
|
.subscribe({ setData() }, fabricPrivacy::logException)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Synchronized
|
@Synchronized
|
||||||
|
|
|
@ -37,9 +37,9 @@ import info.nightscout.androidaps.utils.DateUtil;
|
||||||
import info.nightscout.androidaps.utils.FabricPrivacy;
|
import info.nightscout.androidaps.utils.FabricPrivacy;
|
||||||
import info.nightscout.androidaps.utils.Round;
|
import info.nightscout.androidaps.utils.Round;
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper;
|
import info.nightscout.androidaps.utils.resources.ResourceHelper;
|
||||||
|
import info.nightscout.androidaps.utils.rx.AapsSchedulers;
|
||||||
import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
||||||
import io.reactivex.disposables.CompositeDisposable;
|
import io.reactivex.disposables.CompositeDisposable;
|
||||||
import io.reactivex.schedulers.Schedulers;
|
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
public class DanaRKoreanPlugin extends AbstractDanaRPlugin {
|
public class DanaRKoreanPlugin extends AbstractDanaRPlugin {
|
||||||
|
@ -55,6 +55,7 @@ public class DanaRKoreanPlugin extends AbstractDanaRPlugin {
|
||||||
public DanaRKoreanPlugin(
|
public DanaRKoreanPlugin(
|
||||||
HasAndroidInjector injector,
|
HasAndroidInjector injector,
|
||||||
AAPSLogger aapsLogger,
|
AAPSLogger aapsLogger,
|
||||||
|
AapsSchedulers aapsSchedulers,
|
||||||
RxBusWrapper rxBus,
|
RxBusWrapper rxBus,
|
||||||
DanaPump danaPump,
|
DanaPump danaPump,
|
||||||
Context context,
|
Context context,
|
||||||
|
@ -66,7 +67,7 @@ public class DanaRKoreanPlugin extends AbstractDanaRPlugin {
|
||||||
DateUtil dateUtil,
|
DateUtil dateUtil,
|
||||||
FabricPrivacy fabricPrivacy
|
FabricPrivacy fabricPrivacy
|
||||||
) {
|
) {
|
||||||
super(injector, danaPump, resourceHelper, constraintChecker, aapsLogger, commandQueue, rxBus, activePlugin, sp, dateUtil);
|
super(injector, danaPump, resourceHelper, constraintChecker, aapsLogger, aapsSchedulers, commandQueue, rxBus, activePlugin, sp, dateUtil);
|
||||||
this.aapsLogger = aapsLogger;
|
this.aapsLogger = aapsLogger;
|
||||||
this.context = context;
|
this.context = context;
|
||||||
this.resourceHelper = resourceHelper;
|
this.resourceHelper = resourceHelper;
|
||||||
|
@ -84,7 +85,7 @@ public class DanaRKoreanPlugin extends AbstractDanaRPlugin {
|
||||||
context.bindService(intent, mConnection, Context.BIND_AUTO_CREATE);
|
context.bindService(intent, mConnection, Context.BIND_AUTO_CREATE);
|
||||||
disposable.add(rxBus
|
disposable.add(rxBus
|
||||||
.toObservable(EventPreferenceChange.class)
|
.toObservable(EventPreferenceChange.class)
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(aapsSchedulers.getIo())
|
||||||
.subscribe(event -> {
|
.subscribe(event -> {
|
||||||
if (isEnabled(PluginType.PUMP)) {
|
if (isEnabled(PluginType.PUMP)) {
|
||||||
boolean previousValue = useExtendedBoluses;
|
boolean previousValue = useExtendedBoluses;
|
||||||
|
@ -98,7 +99,7 @@ public class DanaRKoreanPlugin extends AbstractDanaRPlugin {
|
||||||
);
|
);
|
||||||
disposable.add(rxBus
|
disposable.add(rxBus
|
||||||
.toObservable(EventAppExit.class)
|
.toObservable(EventAppExit.class)
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(aapsSchedulers.getIo())
|
||||||
.subscribe(event -> context.unbindService(mConnection), fabricPrivacy::logException)
|
.subscribe(event -> context.unbindService(mConnection), fabricPrivacy::logException)
|
||||||
);
|
);
|
||||||
super.onStart();
|
super.onStart();
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue