diff --git a/app/src/main/java/info/nightscout/androidaps/dependencyInjection/ActivitiesModule.kt b/app/src/main/java/info/nightscout/androidaps/dependencyInjection/ActivitiesModule.kt index 3c4add198a..34e365aa9b 100644 --- a/app/src/main/java/info/nightscout/androidaps/dependencyInjection/ActivitiesModule.kt +++ b/app/src/main/java/info/nightscout/androidaps/dependencyInjection/ActivitiesModule.kt @@ -18,8 +18,6 @@ import info.nightscout.androidaps.plugins.pump.insight.activities.InsightAlertAc import info.nightscout.androidaps.plugins.pump.insight.activities.InsightPairingActivity import info.nightscout.androidaps.plugins.pump.insight.activities.InsightPairingInformationActivity import info.nightscout.androidaps.plugins.pump.medtronic.dialog.MedtronicHistoryActivity -import info.nightscout.androidaps.plugins.pump.omnipod.dialogs.PodHistoryActivity -import info.nightscout.androidaps.plugins.pump.omnipod.dialogs.PodManagementActivity import info.nightscout.androidaps.setupwizard.SetupWizardActivity @Module @@ -50,7 +48,6 @@ abstract class ActivitiesModule { @ContributesAndroidInjector abstract fun contributesStatsActivity(): StatsActivity @ContributesAndroidInjector abstract fun contributesSurveyActivity(): SurveyActivity @ContributesAndroidInjector abstract fun contributesTDDStatsActivity(): TDDStatsActivity - @ContributesAndroidInjector abstract fun contributesPodManagementActivity(): PodManagementActivity - @ContributesAndroidInjector abstract fun contributesPodHistoryActivity(): PodHistoryActivity + } \ No newline at end of file diff --git a/app/src/main/java/info/nightscout/androidaps/dependencyInjection/OmnipodModule.kt b/app/src/main/java/info/nightscout/androidaps/dependencyInjection/OmnipodModule.kt index cf406ec220..c19443146f 100644 --- a/app/src/main/java/info/nightscout/androidaps/dependencyInjection/OmnipodModule.kt +++ b/app/src/main/java/info/nightscout/androidaps/dependencyInjection/OmnipodModule.kt @@ -3,6 +3,9 @@ package info.nightscout.androidaps.dependencyInjection import dagger.Module import dagger.android.ContributesAndroidInjector import info.nightscout.androidaps.plugins.pump.omnipod.comm.OmnipodCommunicationManager +import info.nightscout.androidaps.plugins.pump.omnipod.defs.state.PodSessionState +import info.nightscout.androidaps.plugins.pump.omnipod.dialogs.PodHistoryActivity +import info.nightscout.androidaps.plugins.pump.omnipod.dialogs.PodManagementActivity import info.nightscout.androidaps.plugins.pump.omnipod.dialogs.wizard.pages.InitPodRefreshAction import info.nightscout.androidaps.plugins.pump.omnipod.driver.comm.AapsOmnipodManager import info.nightscout.androidaps.plugins.pump.omnipod.driver.ui.OmnipodUITask @@ -11,9 +14,15 @@ import info.nightscout.androidaps.plugins.pump.omnipod.driver.ui.OmnipodUITask @Suppress("unused") abstract class OmnipodModule { + // Activities + @ContributesAndroidInjector abstract fun contributesPodManagementActivity(): PodManagementActivity + @ContributesAndroidInjector abstract fun contributesPodHistoryActivity(): PodHistoryActivity + @ContributesAndroidInjector abstract fun omnipodCommunicationManagerProvider(): OmnipodCommunicationManager @ContributesAndroidInjector abstract fun omnipodUITaskProvider(): OmnipodUITask @ContributesAndroidInjector abstract fun aapsOmnipodManagerProvider(): AapsOmnipodManager @ContributesAndroidInjector abstract fun initPodRefreshAction(): InitPodRefreshAction + @ContributesAndroidInjector abstract fun podSessionState(): PodSessionState + } \ No newline at end of file diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/OmnipodPumpPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/OmnipodPumpPlugin.java index dd6d7295b7..466a6be10f 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/OmnipodPumpPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/OmnipodPumpPlugin.java @@ -619,15 +619,7 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump if (omnipodUtil.getPodSessionState() != null) { podSessionState = omnipodUtil.getPodSessionState(); } else { - String podState = sp.getString(OmnipodConst.Prefs.PodState, ""); - - aapsLogger.info(LTag.PUMP, "PodSessionState-SP: loaded from SharedPreferences: " + podState); - - if (StringUtils.isNotEmpty(podState)) { - podSessionState = omnipodUtil.getGsonInstance().fromJson(podState, PodSessionState.class); - podSessionState.injectDaggerClass(injector); - omnipodUtil.setPodSessionState(podSessionState); - } + podSessionState = omnipodUtil.loadSessionState(); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/util/OmnipodUtil.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/util/OmnipodUtil.java index 6d4261042f..435c08c8a5 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/util/OmnipodUtil.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/util/OmnipodUtil.java @@ -8,6 +8,7 @@ import com.google.gson.JsonDeserializer; import com.google.gson.JsonPrimitive; import com.google.gson.JsonSerializer; +import org.apache.commons.lang3.StringUtils; import org.joda.time.DateTime; import org.joda.time.DateTimeZone; import org.joda.time.format.ISODateTimeFormat; @@ -15,10 +16,12 @@ import org.joda.time.format.ISODateTimeFormat; import javax.inject.Inject; import javax.inject.Singleton; +import dagger.android.HasAndroidInjector; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; import info.nightscout.androidaps.interfaces.ActivePluginProvider; import info.nightscout.androidaps.logging.AAPSLogger; +import info.nightscout.androidaps.logging.LTag; import info.nightscout.androidaps.plugins.bus.RxBusWrapper; import info.nightscout.androidaps.plugins.pump.common.defs.PumpType; import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkUtil; @@ -46,6 +49,7 @@ public class OmnipodUtil { private final OmnipodPumpStatus omnipodPumpStatus; private final ActivePluginProvider activePlugins; private final SP sp; + private final HasAndroidInjector injector; private boolean lowLevelDebug = true; private OmnipodCommandType currentCommand; @@ -63,7 +67,8 @@ public class OmnipodUtil { RileyLinkUtil rileyLinkUtil, OmnipodPumpStatus omnipodPumpStatus, SP sp, - ActivePluginProvider activePlugins + ActivePluginProvider activePlugins, + HasAndroidInjector injector ) { this.aapsLogger = aapsLogger; this.rxBus = rxBus; @@ -71,6 +76,7 @@ public class OmnipodUtil { this.omnipodPumpStatus = omnipodPumpStatus; this.sp = sp; this.activePlugins = activePlugins; + this.injector = injector; } @@ -223,4 +229,20 @@ public class OmnipodUtil { public SP getSp() { return this.sp; } + + public PodSessionState loadSessionState() { + String podState = sp.getString(OmnipodConst.Prefs.PodState, ""); + + aapsLogger.info(LTag.PUMP, "PodSessionState-SP: loaded from SharedPreferences: " + podState); + + if (StringUtils.isNotEmpty(podState)) { + PodSessionState podSessionState = gsonInstance.fromJson(podState, PodSessionState.class); + podSessionState.injectDaggerClass(injector); + setPodSessionState(podSessionState); + + return podSessionState; + } + + return null; + } }