From 31215ea4884de3b29c6adee8b216b64d54f431b7 Mon Sep 17 00:00:00 2001 From: Bart Sopers Date: Thu, 1 Oct 2020 19:32:56 +0200 Subject: [PATCH] Split Change Pod wizard into Activate Pod wizard and Deactivate Pod wizard --- .../androidaps/setupwizard/SWDefinition.kt | 53 +++++----- app/src/main/res/values/strings.xml | 2 - omnipod/src/main/AndroidManifest.xml | 3 +- .../pump/omnipod/OmnipodPumpPlugin.java | 6 -- .../pump/omnipod/dagger/OmnipodModule.kt | 9 +- .../omnipod/dagger/OmnipodWizardModule.kt | 27 +++--- .../definition/OmnipodCommandType.java | 4 +- .../definition/PodHistoryEntryType.java | 4 +- .../omnipod/manager/AapsOmnipodManager.java | 8 +- .../pump/omnipod/ui/PodHistoryActivity.java | 4 +- .../pump/omnipod/ui/PodManagementActivity.kt | 58 +++++------ .../ui/wizard/ChangePodWizardActivity.kt | 79 --------------- .../activation/PodActivationWizardActivity.kt | 60 ++++++++++++ .../fragment}/AttachPodInfoFragment.kt | 9 +- .../fragment/FillPodInfoFragment.kt | 19 ++++ .../fragment/InitializePodActionFragment.kt | 35 +++++++ .../fragment/InsertCannulaActionFragment.kt | 35 +++++++ .../fragment/PodActivatedInfoFragment.kt | 19 ++++ .../PodActivationActionFragmentBase.kt | 36 +++++++ .../InitializePodActionViewModel.kt} | 7 +- .../viewmodel/InsertCannulaActionViewModel.kt | 3 +- .../activity/OmnipodWizardActivityBase.kt | 34 +++++++ .../fragment}/ActionFragmentBase.kt | 41 ++++---- .../fragment}/InfoFragmentBase.kt | 11 +-- .../common/fragment/WizardFragmentBase.kt | 84 ++++++++++++++++ .../viewmodel/ActionViewModelBase.kt | 2 +- .../PodDeactivationWizardActivity.kt | 18 ++++ .../fragment}/DeactivatePodActionFragment.kt | 19 ++-- .../fragment}/DeactivatePodInfoFragment.kt | 7 +- .../fragment/PodDeactivatedInfoFragment.kt | 19 ++++ .../fragment/PodDiscardedInfoFragment.kt | 19 ++++ .../viewmodel/DeactivatePodActionViewModel.kt | 3 +- .../fragment/ChangePodWizardFragmentBase.kt | 97 ------------------- .../action/InsertCannulaActionFragment.kt | 61 ------------ .../action/PairAndPrimePodActionFragment.kt | 61 ------------ .../fragment/info/FillPodInfoFragment.kt | 18 ---- .../fragment/info/PodChangedInfoFragment.kt | 18 ---- .../info/PodDeactivatedInfoFragment.kt | 18 ---- .../fragment/info/PodDiscardedInfoFragment.kt | 18 ---- ...mnipod_pod_activation_wizard_activity.xml} | 0 ...nipod_pod_deactivation_wizard_activity.xml | 15 +++ .../res/layout/omnipod_pod_management.xml | 43 ++++---- ...> omnipod_wizard_action_page_fragment.xml} | 38 ++++---- ...t.xml => omnipod_wizard_base_fragment.xml} | 12 +-- ... => omnipod_wizard_info_page_fragment.xml} | 4 +- ...ons.xml => omnipod_wizard_nav_buttons.xml} | 8 +- ...=> omnipod_wizard_progress_indication.xml} | 4 +- ...pod_change_pod_wizard_navigation_graph.xml | 82 ---------------- ...pod_activation_wizard_navigation_graph.xml | 41 ++++++++ ...d_deactivation_wizard_navigation_graph.xml | 32 ++++++ .../src/main/res/values-bg-rBG/strings.xml | 34 +++---- .../src/main/res/values-cs-rCZ/strings.xml | 28 +++--- .../src/main/res/values-de-rDE/strings.xml | 24 ++--- .../src/main/res/values-es-rES/strings.xml | 20 ++-- .../src/main/res/values-fr-rFR/strings.xml | 34 +++---- .../src/main/res/values-it-rIT/strings.xml | 34 +++---- .../src/main/res/values-lt-rLT/strings.xml | 20 ++-- .../src/main/res/values-nl-rNL/strings.xml | 20 ++-- .../src/main/res/values-pl-rPL/strings.xml | 20 ++-- .../src/main/res/values-pt-rPT/strings.xml | 26 ++--- .../src/main/res/values-ro-rRO/strings.xml | 36 +++---- .../src/main/res/values-ru-rRU/strings.xml | 34 +++---- .../src/main/res/values-sk-rSK/strings.xml | 34 +++---- .../src/main/res/values-sv-rSE/strings.xml | 20 ++-- omnipod/src/main/res/values/colors.xml | 2 +- omnipod/src/main/res/values/dimens.xml | 2 +- omnipod/src/main/res/values/strings.xml | 71 +++++++------- omnipod/src/main/res/values/styles.xml | 6 +- 68 files changed, 895 insertions(+), 877 deletions(-) delete mode 100644 omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/ChangePodWizardActivity.kt create mode 100644 omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/activation/PodActivationWizardActivity.kt rename omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/{fragment/info => activation/fragment}/AttachPodInfoFragment.kt (53%) create mode 100644 omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/activation/fragment/FillPodInfoFragment.kt create mode 100644 omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/activation/fragment/InitializePodActionFragment.kt create mode 100644 omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/activation/fragment/InsertCannulaActionFragment.kt create mode 100644 omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/activation/fragment/PodActivatedInfoFragment.kt create mode 100644 omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/activation/fragment/PodActivationActionFragmentBase.kt rename omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/{viewmodel/PairAndPrimePodActionViewModel.kt => activation/viewmodel/InitializePodActionViewModel.kt} (51%) rename omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/{ => activation}/viewmodel/InsertCannulaActionViewModel.kt (82%) create mode 100644 omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/common/activity/OmnipodWizardActivityBase.kt rename omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/{fragment/action => common/fragment}/ActionFragmentBase.kt (50%) rename omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/{fragment/info => common/fragment}/InfoFragmentBase.kt (54%) create mode 100644 omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/common/fragment/WizardFragmentBase.kt rename omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/{ => common}/viewmodel/ActionViewModelBase.kt (98%) create mode 100644 omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/deactivation/PodDeactivationWizardActivity.kt rename omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/{fragment/action => deactivation/fragment}/DeactivatePodActionFragment.kt (71%) rename omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/{fragment/info => deactivation/fragment}/DeactivatePodInfoFragment.kt (58%) create mode 100644 omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/deactivation/fragment/PodDeactivatedInfoFragment.kt create mode 100644 omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/deactivation/fragment/PodDiscardedInfoFragment.kt rename omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/{ => deactivation}/viewmodel/DeactivatePodActionViewModel.kt (89%) delete mode 100644 omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/fragment/ChangePodWizardFragmentBase.kt delete mode 100644 omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/fragment/action/InsertCannulaActionFragment.kt delete mode 100644 omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/fragment/action/PairAndPrimePodActionFragment.kt delete mode 100644 omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/fragment/info/FillPodInfoFragment.kt delete mode 100644 omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/fragment/info/PodChangedInfoFragment.kt delete mode 100644 omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/fragment/info/PodDeactivatedInfoFragment.kt delete mode 100644 omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/fragment/info/PodDiscardedInfoFragment.kt rename omnipod/src/main/res/layout/{omnipod_change_pod_wizard_activity.xml => omnipod_pod_activation_wizard_activity.xml} (100%) create mode 100644 omnipod/src/main/res/layout/omnipod_pod_deactivation_wizard_activity.xml rename omnipod/src/main/res/layout/{omnipod_change_pod_wizard_action_page_fragment.xml => omnipod_wizard_action_page_fragment.xml} (56%) rename omnipod/src/main/res/layout/{omnipod_change_pod_wizard_base_fragment.xml => omnipod_wizard_base_fragment.xml} (59%) rename omnipod/src/main/res/layout/{omnipod_change_pod_wizard_info_page_fragment.xml => omnipod_wizard_info_page_fragment.xml} (72%) rename omnipod/src/main/res/layout/{omnipod_change_pod_wizard_nav_buttons.xml => omnipod_wizard_nav_buttons.xml} (64%) rename omnipod/src/main/res/layout/{omnipod_change_pod_wizard_progress_indication.xml => omnipod_wizard_progress_indication.xml} (78%) delete mode 100644 omnipod/src/main/res/navigation/omnipod_change_pod_wizard_navigation_graph.xml create mode 100644 omnipod/src/main/res/navigation/omnipod_pod_activation_wizard_navigation_graph.xml create mode 100644 omnipod/src/main/res/navigation/omnipod_pod_deactivation_wizard_navigation_graph.xml diff --git a/app/src/main/java/info/nightscout/androidaps/setupwizard/SWDefinition.kt b/app/src/main/java/info/nightscout/androidaps/setupwizard/SWDefinition.kt index 76e5057654..1d7c37929f 100644 --- a/app/src/main/java/info/nightscout/androidaps/setupwizard/SWDefinition.kt +++ b/app/src/main/java/info/nightscout/androidaps/setupwizard/SWDefinition.kt @@ -31,7 +31,6 @@ import info.nightscout.androidaps.plugins.profile.local.LocalProfilePlugin import info.nightscout.androidaps.plugins.profile.ns.NSProfileFragment import info.nightscout.androidaps.plugins.profile.ns.NSProfilePlugin import info.nightscout.androidaps.plugins.pump.omnipod.OmnipodPumpPlugin -import info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.ChangePodWizardActivity import info.nightscout.androidaps.setupwizard.elements.* import info.nightscout.androidaps.setupwizard.events.EventSWUpdate import info.nightscout.androidaps.utils.AndroidPermission @@ -317,43 +316,35 @@ class SWDefinition @Inject constructor( .visibility(SWValidator { (activePlugin.activePump as PluginBase).preferencesId > 0 })) .add(SWInfotext(injector) .label(R.string.setupwizard_pump_pump_not_initialized) - .visibility(SWValidator { !activePlugin.activePump.isInitialized })) - // BEGIN OMNIPOD - .add(SWInfotext(injector) - .label(R.string.setupwizard_pump_waiting_for_riley_link_connection) - .visibility(SWValidator { - val activePump = activePlugin.activePump - activePump is OmnipodPumpPlugin && !activePump.isRileyLinkReady - })) - .add(SWInfotext(injector) - .label(R.string.setupwizard_pump_waiting_for_pod_change) - .visibility(SWValidator { - val activePump = activePlugin.activePump - activePump is OmnipodPumpPlugin && activePump.isRileyLinkReady && !activePump.isInitialized - })) - .add(SWButton(injector) - .text(R.string.setupwizard_pump_omnipod_change_pod) - .action(Runnable { - protectionCheck.queryProtection(activity, ProtectionCheck.Protection.PREFERENCES, Runnable { - val i = Intent(activity, ChangePodWizardActivity::class.java) - activity.startActivity(i) - }, null) - }) - .visibility(SWValidator { - val activePump = activePlugin.activePump - activePump is OmnipodPumpPlugin && activePump.isRileyLinkReady && !activePump.isInitialized - })) - // END OMNIPOD + .visibility(SWValidator { !isPumpInitialized() })) + .add( // Omnipod only + SWInfotext(injector) + .label(R.string.setupwizard_pump_waiting_for_riley_link_connection) + .visibility(SWValidator { + val activePump = activePlugin.activePump + activePump is OmnipodPumpPlugin && !activePump.isRileyLinkReady + })) .add(SWButton(injector) .text(R.string.readstatus) .action(Runnable { commandQueue.readStatus("Clicked connect to pump", null) }) - .visibility(SWValidator { activePlugin.activePump !is OmnipodPumpPlugin })) + .visibility(SWValidator { + // Hide for Omnipod, because as we don't require a Pod to be paired in the setup wizard, + // Getting the status might not be possible + activePlugin.activePump !is OmnipodPumpPlugin + })) .add(SWEventListener(injector, EventPumpStatusChanged::class.java)) .validator(SWValidator { - val activePump = activePlugin.activePump - activePump.isInitialized + isPumpInitialized() }) + private fun isPumpInitialized(): Boolean { + val activePump = activePlugin.activePump + + // For Omnipod, consider the pump initialized when a RL has been configured successfully + // Users will be prompted to activate a Pod after completing the setup wizard. + return activePump.isInitialized || (activePump is OmnipodPumpPlugin && activePump.isRileyLinkReady) + } + private val screenAps = SWScreen(injector, R.string.configbuilder_aps) .skippable(false) .add(SWInfotext(injector) diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index b76e703166..2b6e4788aa 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -950,9 +950,7 @@ Please select source of profile. If patient is a child you should use NS profile. If there is nobody following you on Nightscout you will probably prefer Local profile. Please remember that you are only selecting the profile source. To use it you must activate it by executing \"Profile switch\" Select one from availables algorithms. They are sorted from oldest to newest. Newer algorithm is usually more powerful and more aggressive. Thus if you are new looper you may probably start with AMA and not with latest one. Do not forget to read the OpenAPS documentation and configure it before use. Waiting for RileyLink connection…\n - Waiting for Pod change…\n Note: You can continue setup once the pump has been initialized.\n - Change Pod Start your first objective Permission Ask for permission diff --git a/omnipod/src/main/AndroidManifest.xml b/omnipod/src/main/AndroidManifest.xml index 7da09f6d06..4c8d3b5305 100644 --- a/omnipod/src/main/AndroidManifest.xml +++ b/omnipod/src/main/AndroidManifest.xml @@ -9,6 +9,7 @@ - + + \ No newline at end of file diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/OmnipodPumpPlugin.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/OmnipodPumpPlugin.java index 1201412345..6e1c85314b 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/OmnipodPumpPlugin.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/OmnipodPumpPlugin.java @@ -319,12 +319,6 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface, return rileyLinkServiceData.rileyLinkServiceState.isReady(); } - public boolean needsPodActivation() { - // don't use PodStateManager.isActivationCompleted() because that returns false for PodProgressStatus.ACTIVATION_TIME_EXCEEDED - // which indicates that the pod should be deactivated rather then activated - return !podStateManager.isPodInitialized() || podStateManager.getPodProgressStatus().isBefore(PodProgressStatus.ABOVE_FIFTY_UNITS); - } - private void updateAapsTbr() { // As per the characteristics of the Omnipod, we only know whether or not a TBR is currently active // But it doesn't tell us the duration or amount, so we can only update TBR status in AAPS if diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dagger/OmnipodModule.kt b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dagger/OmnipodModule.kt index a61a9425bf..fd2b49ae1c 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dagger/OmnipodModule.kt +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dagger/OmnipodModule.kt @@ -9,7 +9,8 @@ import info.nightscout.androidaps.plugins.pump.omnipod.manager.AapsPodStateManag import info.nightscout.androidaps.plugins.pump.omnipod.rileylink.manager.OmnipodRileyLinkCommunicationManager import info.nightscout.androidaps.plugins.pump.omnipod.ui.PodHistoryActivity import info.nightscout.androidaps.plugins.pump.omnipod.ui.PodManagementActivity -import info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.ChangePodWizardActivity +import info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.activation.PodActivationWizardActivity +import info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.deactivation.PodDeactivationWizardActivity @Module @Suppress("unused") @@ -22,7 +23,11 @@ abstract class OmnipodModule { @ActivityScope @ContributesAndroidInjector(modules = [OmnipodWizardModule::class]) - abstract fun contributesWizardActivity(): ChangePodWizardActivity + abstract fun contributesActivationWizardActivity(): PodActivationWizardActivity + + @ActivityScope + @ContributesAndroidInjector(modules = [OmnipodWizardModule::class]) + abstract fun contributesDeactivationWizardActivity(): PodDeactivationWizardActivity // Service @ContributesAndroidInjector diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dagger/OmnipodWizardModule.kt b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dagger/OmnipodWizardModule.kt index 3fe8250a58..4421900b15 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dagger/OmnipodWizardModule.kt +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dagger/OmnipodWizardModule.kt @@ -7,13 +7,18 @@ import dagger.Module import dagger.Provides import dagger.android.ContributesAndroidInjector import dagger.multibindings.IntoMap -import info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.fragment.action.DeactivatePodActionFragment -import info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.fragment.action.InsertCannulaActionFragment -import info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.fragment.action.PairAndPrimePodActionFragment -import info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.fragment.info.* -import info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.viewmodel.DeactivatePodActionViewModel -import info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.viewmodel.InsertCannulaActionViewModel -import info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.viewmodel.PairAndPrimePodActionViewModel +import info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.activation.fragment.AttachPodInfoFragment +import info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.activation.fragment.FillPodInfoFragment +import info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.activation.fragment.InitializePodActionFragment +import info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.activation.fragment.InsertCannulaActionFragment +import info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.activation.fragment.PodActivatedInfoFragment +import info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.activation.viewmodel.InitializePodActionViewModel +import info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.activation.viewmodel.InsertCannulaActionViewModel +import info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.deactivation.fragment.DeactivatePodActionFragment +import info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.deactivation.fragment.DeactivatePodInfoFragment +import info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.deactivation.fragment.PodDeactivatedInfoFragment +import info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.deactivation.fragment.PodDiscardedInfoFragment +import info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.deactivation.viewmodel.DeactivatePodActionViewModel import javax.inject.Provider @Module @@ -31,8 +36,8 @@ abstract class OmnipodWizardModule { @Binds @IntoMap @OmnipodPluginQualifier - @ViewModelKey(PairAndPrimePodActionViewModel::class) - internal abstract fun pairAndPrimePodActionViewModel(viewModel: PairAndPrimePodActionViewModel): ViewModel + @ViewModelKey(InitializePodActionViewModel::class) + internal abstract fun initializePodActionViewModel(viewModel: InitializePodActionViewModel): ViewModel @Binds @IntoMap @@ -57,7 +62,7 @@ abstract class OmnipodWizardModule { @FragmentScope @ContributesAndroidInjector - internal abstract fun contributesPairAndPrimePodActionFragment(): PairAndPrimePodActionFragment + internal abstract fun contributesInitializePodActionFragment(): InitializePodActionFragment @FragmentScope @ContributesAndroidInjector @@ -81,7 +86,7 @@ abstract class OmnipodWizardModule { @FragmentScope @ContributesAndroidInjector - internal abstract fun contributesPodChangedInfoFragment(): PodChangedInfoFragment + internal abstract fun contributesPodActivatedInfoFragment(): PodActivatedInfoFragment } diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/definition/OmnipodCommandType.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/definition/OmnipodCommandType.java index 4f196cda3d..8d9b250ac4 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/definition/OmnipodCommandType.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/definition/OmnipodCommandType.java @@ -6,8 +6,8 @@ import info.nightscout.androidaps.plugins.pump.omnipod.R; * Created by andy on 4.8.2019 */ public enum OmnipodCommandType { - ACTIVATE_POD(R.string.omnipod_cmd_activate_pod), // First step of Pod change - INSERT_CANNULA(R.string.omnipod_cmd_insert_cannula), // Second step of Pod change + INITIALIZE_POD(R.string.omnipod_cmd_initialize_pod), // First step of Pod activation + INSERT_CANNULA(R.string.omnipod_cmd_insert_cannula), // Second step of Pod activation DEACTIVATE_POD(R.string.omnipod_cmd_deactivate_pod), // SET_BASAL_PROFILE(R.string.omnipod_cmd_set_basal_schedule), // SET_BOLUS(R.string.omnipod_cmd_set_bolus), // diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/definition/PodHistoryEntryType.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/definition/PodHistoryEntryType.java index 207a7814fc..89560786e0 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/definition/PodHistoryEntryType.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/definition/PodHistoryEntryType.java @@ -13,10 +13,10 @@ import info.nightscout.androidaps.plugins.pump.omnipod.R; */ public enum PodHistoryEntryType { - ACTIVATE_POD(1, R.string.omnipod_cmd_activate_pod, PumpHistoryEntryGroup.Prime), + INITIALIZE_POD(1, R.string.omnipod_cmd_initialize_pod, PumpHistoryEntryGroup.Prime), INSERT_CANNULA(2, R.string.omnipod_cmd_insert_cannula, PumpHistoryEntryGroup.Prime), DEACTIVATE_POD(3, R.string.omnipod_cmd_deactivate_pod, PumpHistoryEntryGroup.Prime), - DISCARD_POD_STATE(4, R.string.omnipod_cmd_discard_pod, PumpHistoryEntryGroup.Prime), + DISCARD_POD(4, R.string.omnipod_cmd_discard_pod, PumpHistoryEntryGroup.Prime), SET_TEMPORARY_BASAL(10, R.string.omnipod_cmd_set_tbr, PumpHistoryEntryGroup.Basal), CANCEL_TEMPORARY_BASAL_BY_DRIVER(11, R.string.omnipod_cmd_cancel_tbr_by_driver, PumpHistoryEntryGroup.Basal), diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/manager/AapsOmnipodManager.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/manager/AapsOmnipodManager.java index 3d21de9c14..cddf3b2692 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/manager/AapsOmnipodManager.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/manager/AapsOmnipodManager.java @@ -153,7 +153,7 @@ public class AapsOmnipodManager { timeChangeEventEnabled = sp.getBoolean(OmnipodStorageKeys.Preferences.TIME_CHANGE_EVENT_ENABLED, true); } - public PumpEnactResult activateNewPod() { + public PumpEnactResult initializePod() { PumpEnactResult result = new PumpEnactResult(injector); try { Boolean res = executeCommand(delegate::pairAndPrime) @@ -162,13 +162,13 @@ public class AapsOmnipodManager { result.success(res).enacted(res); if (!res) { - result.comment(R.string.omnipod_error_failed_to_activate_pod); + result.comment(R.string.omnipod_error_failed_to_initialize_pod); } } catch (Exception ex) { result.success(false).enacted(false).comment(translateException(ex)); } - addToHistory(System.currentTimeMillis(), PodHistoryEntryType.ACTIVATE_POD, result.comment, result.success); + addToHistory(System.currentTimeMillis(), PodHistoryEntryType.INITIALIZE_POD, result.comment, result.success); return result; } @@ -313,7 +313,7 @@ public class AapsOmnipodManager { public PumpEnactResult discardPodState() { podStateManager.discardState(); - addSuccessToHistory(System.currentTimeMillis(), PodHistoryEntryType.DISCARD_POD_STATE, null); + addSuccessToHistory(System.currentTimeMillis(), PodHistoryEntryType.DISCARD_POD, null); createSuspendedFakeTbrIfNotExists(); diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/PodHistoryActivity.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/PodHistoryActivity.java index ad81185d5c..ff8319a557 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/PodHistoryActivity.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/PodHistoryActivity.java @@ -275,13 +275,13 @@ public class PodHistoryActivity extends NoSplashAppCompatActivity { case GET_POD_STATUS: case GET_POD_INFO: case SET_TIME: - case ACTIVATE_POD: + case INITIALIZE_POD: case CANCEL_TEMPORARY_BASAL_BY_DRIVER: case CANCEL_TEMPORARY_BASAL: case CONFIGURE_ALERTS: case CANCEL_BOLUS: case DEACTIVATE_POD: - case DISCARD_POD_STATE: + case DISCARD_POD: case ACKNOWLEDGE_ALERTS: case SUSPEND_DELIVERY: case RESUME_DELIVERY: diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/PodManagementActivity.kt b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/PodManagementActivity.kt index 27f730ef0d..03ee8035ae 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/PodManagementActivity.kt +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/PodManagementActivity.kt @@ -2,8 +2,6 @@ package info.nightscout.androidaps.plugins.pump.omnipod.ui import android.content.Intent import android.os.Bundle -import android.view.View -import android.widget.LinearLayout import dagger.android.HasAndroidInjector import info.nightscout.androidaps.activities.NoSplashAppCompatActivity import info.nightscout.androidaps.interfaces.CommandQueueProvider @@ -14,10 +12,12 @@ import info.nightscout.androidaps.plugins.pump.omnipod.R import info.nightscout.androidaps.plugins.pump.omnipod.driver.manager.PodStateManager import info.nightscout.androidaps.plugins.pump.omnipod.event.EventOmnipodPumpValuesChanged import info.nightscout.androidaps.plugins.pump.omnipod.manager.AapsOmnipodManager -import info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.ChangePodWizardActivity +import info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.activation.PodActivationWizardActivity +import info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.deactivation.PodDeactivationWizardActivity import info.nightscout.androidaps.utils.FabricPrivacy import info.nightscout.androidaps.utils.alertDialogs.OKDialog import info.nightscout.androidaps.utils.extensions.plusAssign +import info.nightscout.androidaps.utils.extensions.toVisibility import info.nightscout.androidaps.utils.resources.ResourceHelper import io.reactivex.android.schedulers.AndroidSchedulers import io.reactivex.disposables.CompositeDisposable @@ -44,17 +44,23 @@ class PodManagementActivity : NoSplashAppCompatActivity() { super.onCreate(savedInstanceState) setContentView(R.layout.omnipod_pod_management) - omnipod_pod_management_button_change_pod.setOnClickListener { - val myIntent = Intent(this@PodManagementActivity, ChangePodWizardActivity::class.java) - this@PodManagementActivity.startActivity(myIntent) + omnipod_pod_management_button_activate_pod.setOnClickListener { + startActivity(Intent(this, PodActivationWizardActivity::class.java)) + } + + omnipod_pod_management_button_deactivate_pod.setOnClickListener { + startActivity(Intent(this, PodDeactivationWizardActivity::class.java)) } omnipod_pod_management_button_discard_pod.setOnClickListener { - discardPodAction() + OKDialog.showConfirmation(this, + resourceHelper.gs(R.string.omnipod_pod_management_discard_pod_state_confirmation), Thread { + aapsOmnipodManager.discardPodState() + }) } omnipod_pod_management_button_pod_history.setOnClickListener { - showPodHistory() + startActivity(Intent(this, PodHistoryActivity::class.java)) } } @@ -77,29 +83,27 @@ class PodManagementActivity : NoSplashAppCompatActivity() { disposables.clear() } - private fun discardPodAction() { - OKDialog.showConfirmation(this, - resourceHelper.gs(R.string.omnipod_pod_management_discard_pod_state_confirmation), Thread { - aapsOmnipodManager.discardPodState() - }) - } - - private fun showPodHistory() { - startActivity(Intent(applicationContext, PodHistoryActivity::class.java)) - } - private fun refreshButtons() { - omnipod_pod_management_button_change_pod.isEnabled = true - omnipod_pod_management_button_discard_pod.isEnabled = podStateManager.hasPodState() - - val waitingForRlLayout = findViewById(R.id.omnipod_pod_management_waiting_for_rl_layout) + // Only show the discard button to reset a cached Pod address before the Pod has actually been initialized + // Otherwise, users should use the Deactivate Pod Wizard. In case proper deactivation fails, + // they will get an option to discard the Pod state there + // TODO maybe rename this button and the confirmation dialog text (see onCreate) + val discardButtonEnabled = podStateManager.hasPodState() && !podStateManager.isPodInitialized + omnipod_pod_management_button_discard_pod.visibility = discardButtonEnabled.toVisibility() + omnipod_pod_management_waiting_for_rl_layout.visibility = (!rileyLinkServiceData.rileyLinkServiceState.isReady).toVisibility() if (rileyLinkServiceData.rileyLinkServiceState.isReady) { - waitingForRlLayout.visibility = View.GONE + omnipod_pod_management_button_activate_pod.isEnabled = !podStateManager.isPodActivationCompleted + omnipod_pod_management_button_deactivate_pod.isEnabled = podStateManager.isPodInitialized + if (discardButtonEnabled) { + omnipod_pod_management_button_discard_pod.isEnabled = true + } } else { - waitingForRlLayout.visibility = View.VISIBLE - omnipod_pod_management_button_change_pod.isEnabled = false - omnipod_pod_management_button_discard_pod.isEnabled = false + omnipod_pod_management_button_activate_pod.isEnabled = false + omnipod_pod_management_button_deactivate_pod.isEnabled = false + if (discardButtonEnabled) { + omnipod_pod_management_button_discard_pod.isEnabled = false + } } } diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/ChangePodWizardActivity.kt b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/ChangePodWizardActivity.kt deleted file mode 100644 index bfdc60932a..0000000000 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/ChangePodWizardActivity.kt +++ /dev/null @@ -1,79 +0,0 @@ -package info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard - -import android.app.AlertDialog -import android.os.Bundle -import androidx.annotation.IdRes -import androidx.navigation.NavController -import androidx.navigation.fragment.NavHostFragment -import info.nightscout.androidaps.activities.NoSplashAppCompatActivity -import info.nightscout.androidaps.plugins.pump.omnipod.R -import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.PodProgressStatus -import info.nightscout.androidaps.plugins.pump.omnipod.driver.manager.PodStateManager -import javax.inject.Inject - -class ChangePodWizardActivity : NoSplashAppCompatActivity() { - companion object { - const val KEY_START_DESTINATION = "startDestination" - } - - @Inject - lateinit var podStateManager: PodStateManager - - @IdRes - private var startDestination: Int = R.id.deactivatePodInfoFragment - - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - - setContentView(R.layout.omnipod_change_pod_wizard_activity) - - startDestination = savedInstanceState?.getInt(KEY_START_DESTINATION, R.id.deactivatePodInfoFragment) - ?: if (!podStateManager.isPodActivationCompleted) { - if (!podStateManager.isPodInitialized || podStateManager.podProgressStatus.isBefore(PodProgressStatus.PRIMING_COMPLETED)) { - R.id.fillPodInfoFragment - } else { - R.id.attachPodInfoFragment - } - } else { - R.id.deactivatePodInfoFragment - } - - setStartDestination(startDestination) - } - - fun setStartDestination(@IdRes startDestination: Int) { - this.startDestination = startDestination - val navController = getNavController() - val navInflater = navController.navInflater - val graph = navInflater.inflate(R.navigation.omnipod_change_pod_wizard_navigation_graph) - graph.startDestination = startDestination - navController.graph = graph - } - - override fun onBackPressed() { - exitActivityAfterConfirmation() - } - - fun exitActivityAfterConfirmation() { - if (getNavController().previousBackStackEntry == null) { - finish() - } else { - AlertDialog.Builder(this) - .setIcon(android.R.drawable.ic_dialog_alert) - .setTitle(getString(R.string.omnipod_change_pod_wizard_change_pod)) - .setMessage(getString(R.string.omnipod_change_pod_wizard_exit_confirmation)) - .setPositiveButton(getString(R.string.omnipod_yes)) { _, _ -> finish() } - .setNegativeButton(getString(R.string.omnipod_no), null) - .show() - } - } - - override fun onSaveInstanceState(outState: Bundle) { - super.onSaveInstanceState(outState) - outState.putInt(KEY_START_DESTINATION, startDestination) - } - - private fun getNavController(): NavController = - (supportFragmentManager.findFragmentById(R.id.nav_host_fragment) as NavHostFragment).navController - -} \ No newline at end of file diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/activation/PodActivationWizardActivity.kt b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/activation/PodActivationWizardActivity.kt new file mode 100644 index 0000000000..183c3c239c --- /dev/null +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/activation/PodActivationWizardActivity.kt @@ -0,0 +1,60 @@ +package info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.activation + +import android.os.Bundle +import androidx.annotation.IdRes +import info.nightscout.androidaps.plugins.pump.omnipod.R +import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.PodProgressStatus +import info.nightscout.androidaps.plugins.pump.omnipod.driver.manager.PodStateManager +import info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.common.activity.OmnipodWizardActivityBase +import javax.inject.Inject + +class PodActivationWizardActivity : OmnipodWizardActivityBase() { + companion object { + const val KEY_START_DESTINATION = "startDestination" + } + + @Inject + lateinit var podStateManager: PodStateManager + + @IdRes + private var startDestination: Int = R.id.fillPodInfoFragment + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + + setContentView(R.layout.omnipod_pod_activation_wizard_activity) + + startDestination = savedInstanceState?.getInt(KEY_START_DESTINATION, R.id.fillPodInfoFragment) + ?: if (!podStateManager.isPodInitialized || podStateManager.podProgressStatus.isBefore(PodProgressStatus.PRIMING_COMPLETED)) { + R.id.fillPodInfoFragment + } else { + R.id.attachPodInfoFragment + } + + setStartDestination(startDestination) + } + + private fun setStartDestination(@IdRes startDestination: Int) { + this.startDestination = startDestination + val navController = getNavController() + val navInflater = navController.navInflater + val graph = navInflater.inflate(R.navigation.omnipod_pod_activation_wizard_navigation_graph) + graph.startDestination = startDestination + navController.graph = graph + } + + override fun onSaveInstanceState(outState: Bundle) { + super.onSaveInstanceState(outState) + outState.putInt(KEY_START_DESTINATION, startDestination) + } + + override fun getTotalDefinedNumberOfSteps(): Int = 5 + + override fun getActualNumberOfSteps(): Int { + if (startDestination == R.id.attachPodInfoFragment) { + return 3 + } + return 5 + } + +} \ No newline at end of file diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/fragment/info/AttachPodInfoFragment.kt b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/activation/fragment/AttachPodInfoFragment.kt similarity index 53% rename from omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/fragment/info/AttachPodInfoFragment.kt rename to omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/activation/fragment/AttachPodInfoFragment.kt index 53eb8c4806..032f71d335 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/fragment/info/AttachPodInfoFragment.kt +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/activation/fragment/AttachPodInfoFragment.kt @@ -1,18 +1,19 @@ -package info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.fragment.info +package info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.activation.fragment import androidx.annotation.IdRes import androidx.annotation.StringRes import info.nightscout.androidaps.plugins.pump.omnipod.R +import info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.common.fragment.InfoFragmentBase class AttachPodInfoFragment : InfoFragmentBase() { @StringRes - override fun getTitleId(): Int = R.string.omnipod_change_pod_wizard_attach_pod_title + override fun getTitleId(): Int = R.string.omnipod_pod_activation_wizard_attach_pod_title @StringRes - override fun getTextId(): Int = R.string.omnipod_change_pod_wizard_attach_pod_text + override fun getTextId(): Int = R.string.omnipod_pod_activation_wizard_attach_pod_text @IdRes override fun getNextPageActionId(): Int = R.id.action_attachPodInfoFragment_to_insertCannulaActionFragment - override fun getIndex(): Int = 6 + override fun getIndex(): Int = 3 } \ No newline at end of file diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/activation/fragment/FillPodInfoFragment.kt b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/activation/fragment/FillPodInfoFragment.kt new file mode 100644 index 0000000000..425ff1e7ea --- /dev/null +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/activation/fragment/FillPodInfoFragment.kt @@ -0,0 +1,19 @@ +package info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.activation.fragment + +import androidx.annotation.IdRes +import androidx.annotation.StringRes +import info.nightscout.androidaps.plugins.pump.omnipod.R +import info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.common.fragment.InfoFragmentBase + +class FillPodInfoFragment : InfoFragmentBase() { + @StringRes + override fun getTitleId(): Int = R.string.omnipod_pod_activation_wizard_fill_pod_title + + @StringRes + override fun getTextId(): Int = R.string.omnipod_pod_activation_wizard_fill_pod_text + + @IdRes + override fun getNextPageActionId(): Int = R.id.action_fillPodInfoFragment_to_initializePodActionFragment + + override fun getIndex(): Int = 1 +} \ No newline at end of file diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/activation/fragment/InitializePodActionFragment.kt b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/activation/fragment/InitializePodActionFragment.kt new file mode 100644 index 0000000000..bc10c3daf1 --- /dev/null +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/activation/fragment/InitializePodActionFragment.kt @@ -0,0 +1,35 @@ +package info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.activation.fragment + +import android.os.Bundle +import androidx.annotation.IdRes +import androidx.annotation.StringRes +import androidx.fragment.app.viewModels +import androidx.lifecycle.ViewModelProvider +import info.nightscout.androidaps.plugins.pump.omnipod.R +import info.nightscout.androidaps.plugins.pump.omnipod.dagger.OmnipodPluginQualifier +import info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.activation.viewmodel.InitializePodActionViewModel +import javax.inject.Inject + +class InitializePodActionFragment : PodActivationActionFragmentBase() { + @Inject + @OmnipodPluginQualifier + lateinit var viewModelFactory: ViewModelProvider.Factory + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + + val vm: InitializePodActionViewModel by viewModels { viewModelFactory } + this.viewModel = vm + } + + @StringRes + override fun getTitleId(): Int = R.string.omnipod_pod_activation_wizard_initialize_pod_title + + @StringRes + override fun getTextId(): Int = R.string.omnipod_pod_activation_wizard_initialize_pod_text + + @IdRes + override fun getNextPageActionId(): Int = R.id.action_initializePodActionFragment_to_attachPodInfoFragment + + override fun getIndex(): Int = 2 +} \ No newline at end of file diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/activation/fragment/InsertCannulaActionFragment.kt b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/activation/fragment/InsertCannulaActionFragment.kt new file mode 100644 index 0000000000..009318c60d --- /dev/null +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/activation/fragment/InsertCannulaActionFragment.kt @@ -0,0 +1,35 @@ +package info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.activation.fragment + +import android.os.Bundle +import androidx.annotation.IdRes +import androidx.annotation.StringRes +import androidx.fragment.app.viewModels +import androidx.lifecycle.ViewModelProvider +import info.nightscout.androidaps.plugins.pump.omnipod.R +import info.nightscout.androidaps.plugins.pump.omnipod.dagger.OmnipodPluginQualifier +import info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.activation.viewmodel.InsertCannulaActionViewModel +import javax.inject.Inject + +class InsertCannulaActionFragment : PodActivationActionFragmentBase() { + @Inject + @OmnipodPluginQualifier + lateinit var viewModelFactory: ViewModelProvider.Factory + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + + val vm: InsertCannulaActionViewModel by viewModels { viewModelFactory } + this.viewModel = vm + } + + @StringRes + override fun getTitleId(): Int = R.string.omnipod_pod_activation_wizard_insert_cannula_title + + @StringRes + override fun getTextId(): Int = R.string.omnipod_pod_activation_wizard_insert_cannula_text + + @IdRes + override fun getNextPageActionId(): Int = R.id.action_insertCannulaActionFragment_to_PodActivatedInfoFragment + + override fun getIndex(): Int = 4 +} \ No newline at end of file diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/activation/fragment/PodActivatedInfoFragment.kt b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/activation/fragment/PodActivatedInfoFragment.kt new file mode 100644 index 0000000000..455a8063a3 --- /dev/null +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/activation/fragment/PodActivatedInfoFragment.kt @@ -0,0 +1,19 @@ +package info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.activation.fragment + +import androidx.annotation.IdRes +import androidx.annotation.StringRes +import info.nightscout.androidaps.plugins.pump.omnipod.R +import info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.common.fragment.InfoFragmentBase + +class PodActivatedInfoFragment : InfoFragmentBase() { + @StringRes + override fun getTitleId(): Int = R.string.omnipod_pod_activation_wizard_pod_activated_title + + @StringRes + override fun getTextId(): Int = R.string.omnipod_pod_activation_wizard_pod_activated_text + + @IdRes + override fun getNextPageActionId(): Int? = null + + override fun getIndex(): Int = 5 +} \ No newline at end of file diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/activation/fragment/PodActivationActionFragmentBase.kt b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/activation/fragment/PodActivationActionFragmentBase.kt new file mode 100644 index 0000000000..2055d895e0 --- /dev/null +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/activation/fragment/PodActivationActionFragmentBase.kt @@ -0,0 +1,36 @@ +package info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.activation.fragment + +import android.content.Intent +import android.os.Bundle +import android.view.View +import info.nightscout.androidaps.plugins.pump.omnipod.R +import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.PodProgressStatus +import info.nightscout.androidaps.plugins.pump.omnipod.driver.manager.PodStateManager +import info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.common.fragment.ActionFragmentBase +import info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.deactivation.PodDeactivationWizardActivity +import kotlinx.android.synthetic.main.omnipod_wizard_action_page_fragment.* +import javax.inject.Inject + +abstract class PodActivationActionFragmentBase : ActionFragmentBase() { + @Inject + protected lateinit var podStateManager: PodStateManager + + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) + + omnipod_wizard_button_deactivate_pod.setOnClickListener { + activity?.let { + startActivity(Intent(it, PodDeactivationWizardActivity::class.java)) + it.finish() + } + } + } + + override fun onActionFailure() { + if (podStateManager.isPodInitialized && podStateManager.podProgressStatus == PodProgressStatus.ACTIVATION_TIME_EXCEEDED) { + omnipod_wizard_action_error.setText(R.string.omnipod_error_pod_fault_activation_time_exceeded) + omnipod_wizard_button_retry.visibility = View.GONE + omnipod_wizard_button_deactivate_pod.visibility = View.VISIBLE + } + } +} \ No newline at end of file diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/viewmodel/PairAndPrimePodActionViewModel.kt b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/activation/viewmodel/InitializePodActionViewModel.kt similarity index 51% rename from omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/viewmodel/PairAndPrimePodActionViewModel.kt rename to omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/activation/viewmodel/InitializePodActionViewModel.kt index 45c9a39f36..429b1170d2 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/viewmodel/PairAndPrimePodActionViewModel.kt +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/activation/viewmodel/InitializePodActionViewModel.kt @@ -1,9 +1,10 @@ -package info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.viewmodel +package info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.activation.viewmodel import info.nightscout.androidaps.data.PumpEnactResult import info.nightscout.androidaps.plugins.pump.omnipod.manager.AapsOmnipodManager +import info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.common.viewmodel.ActionViewModelBase import javax.inject.Inject -class PairAndPrimePodActionViewModel @Inject constructor(private val aapsOmnipodManager: AapsOmnipodManager) : ActionViewModelBase() { - override fun doExecuteAction(): PumpEnactResult = aapsOmnipodManager.activateNewPod() +class InitializePodActionViewModel @Inject constructor(private val aapsOmnipodManager: AapsOmnipodManager) : ActionViewModelBase() { + override fun doExecuteAction(): PumpEnactResult = aapsOmnipodManager.initializePod() } \ No newline at end of file diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/viewmodel/InsertCannulaActionViewModel.kt b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/activation/viewmodel/InsertCannulaActionViewModel.kt similarity index 82% rename from omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/viewmodel/InsertCannulaActionViewModel.kt rename to omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/activation/viewmodel/InsertCannulaActionViewModel.kt index 25c3bd9a34..fe042a4a03 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/viewmodel/InsertCannulaActionViewModel.kt +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/activation/viewmodel/InsertCannulaActionViewModel.kt @@ -1,8 +1,9 @@ -package info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.viewmodel +package info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.activation.viewmodel import info.nightscout.androidaps.data.PumpEnactResult import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.plugins.pump.omnipod.manager.AapsOmnipodManager +import info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.common.viewmodel.ActionViewModelBase import javax.inject.Inject class InsertCannulaActionViewModel @Inject constructor(private val aapsOmnipodManager: AapsOmnipodManager, private val profileFunction: ProfileFunction) : ActionViewModelBase() { diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/common/activity/OmnipodWizardActivityBase.kt b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/common/activity/OmnipodWizardActivityBase.kt new file mode 100644 index 0000000000..b15e1a8012 --- /dev/null +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/common/activity/OmnipodWizardActivityBase.kt @@ -0,0 +1,34 @@ +package info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.common.activity + +import android.app.AlertDialog +import androidx.navigation.NavController +import androidx.navigation.fragment.NavHostFragment +import info.nightscout.androidaps.activities.NoSplashAppCompatActivity +import info.nightscout.androidaps.plugins.pump.omnipod.R + +abstract class OmnipodWizardActivityBase : NoSplashAppCompatActivity() { + override fun onBackPressed() { + exitActivityAfterConfirmation() + } + + fun exitActivityAfterConfirmation() { + if (getNavController().previousBackStackEntry == null) { + finish() + } else { + AlertDialog.Builder(this) + .setIcon(android.R.drawable.ic_dialog_alert) + .setTitle(getString(R.string.omnipod_wizard_exit_confirmation_title)) + .setMessage(getString(R.string.omnipod_wizard_exit_confirmation_text)) + .setPositiveButton(getString(R.string.omnipod_yes)) { _, _ -> finish() } + .setNegativeButton(getString(R.string.omnipod_no), null) + .show() + } + } + + protected fun getNavController(): NavController = + (supportFragmentManager.findFragmentById(R.id.nav_host_fragment) as NavHostFragment).navController + + abstract fun getTotalDefinedNumberOfSteps(): Int + + abstract fun getActualNumberOfSteps(): Int +} \ No newline at end of file diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/fragment/action/ActionFragmentBase.kt b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/common/fragment/ActionFragmentBase.kt similarity index 50% rename from omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/fragment/action/ActionFragmentBase.kt rename to omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/common/fragment/ActionFragmentBase.kt index d640cfedbd..1b0d8e41f6 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/fragment/action/ActionFragmentBase.kt +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/common/fragment/ActionFragmentBase.kt @@ -1,4 +1,4 @@ -package info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.fragment.action +package info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.common.fragment import android.os.Bundle import android.view.View @@ -6,47 +6,46 @@ import androidx.annotation.LayoutRes import androidx.annotation.StringRes import androidx.lifecycle.Observer import info.nightscout.androidaps.plugins.pump.omnipod.R -import info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.fragment.ChangePodWizardFragmentBase -import info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.viewmodel.ActionViewModelBase +import info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.common.viewmodel.ActionViewModelBase import info.nightscout.androidaps.utils.extensions.toVisibility -import kotlinx.android.synthetic.main.omnipod_change_pod_wizard_action_page_fragment.* -import kotlinx.android.synthetic.main.omnipod_change_pod_wizard_nav_buttons.* +import kotlinx.android.synthetic.main.omnipod_wizard_action_page_fragment.* +import kotlinx.android.synthetic.main.omnipod_wizard_nav_buttons.* -abstract class ActionFragmentBase : ChangePodWizardFragmentBase() { +abstract class ActionFragmentBase : WizardFragmentBase() { protected lateinit var viewModel: ActionViewModelBase override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) - omnipod_change_pod_wizard_button_next.isEnabled = false - omnipod_change_pod_wizard_action_page_text.setText(getTextId()) + omnipod_wizard_button_next.isEnabled = false + omnipod_wizard_action_page_text.setText(getTextId()) - omnipod_change_pod_wizard_button_retry.setOnClickListener { viewModel.executeAction() } + omnipod_wizard_button_retry.setOnClickListener { viewModel.executeAction() } viewModel.isActionExecutingLiveData.observe(viewLifecycleOwner, Observer { isExecuting -> if (isExecuting) { - omnipod_change_pod_wizard_action_error.visibility = View.GONE - omnipod_change_pod_wizard_button_deactivate_pod.visibility = View.GONE - omnipod_change_pod_wizard_button_discard_pod.visibility = View.GONE - omnipod_change_pod_wizard_button_retry.visibility = View.GONE + omnipod_wizard_action_error.visibility = View.GONE + omnipod_wizard_button_deactivate_pod.visibility = View.GONE + omnipod_wizard_button_discard_pod.visibility = View.GONE + omnipod_wizard_button_retry.visibility = View.GONE } - omnipod_change_pod_wizard_action_progress_indication.visibility = isExecuting.toVisibility() - omnipod_change_pod_wizard_button_cancel.isEnabled = !isExecuting + omnipod_wizard_action_progress_indication.visibility = isExecuting.toVisibility() + omnipod_wizard_button_cancel.isEnabled = !isExecuting }) viewModel.actionResultLiveData.observe(viewLifecycleOwner, Observer { result -> result?.let { val isExecuting = isActionExecuting() - omnipod_change_pod_wizard_button_next.isEnabled = result.success - omnipod_change_pod_wizard_action_success.visibility = result.success.toVisibility() - omnipod_change_pod_wizard_action_error.visibility = (!isExecuting && !result.success).toVisibility() - omnipod_change_pod_wizard_button_retry.visibility = (!isExecuting && !result.success).toVisibility() + omnipod_wizard_button_next.isEnabled = result.success + omnipod_wizard_action_success.visibility = result.success.toVisibility() + omnipod_wizard_action_error.visibility = (!isExecuting && !result.success).toVisibility() + omnipod_wizard_button_retry.visibility = (!isExecuting && !result.success).toVisibility() if (result.success) { onActionSuccess() } else { - omnipod_change_pod_wizard_action_error.text = result.comment + omnipod_wizard_action_error.text = result.comment onActionFailure() } } @@ -75,6 +74,6 @@ abstract class ActionFragmentBase : ChangePodWizardFragmentBase() { @LayoutRes override fun getLayoutId(): Int { - return R.layout.omnipod_change_pod_wizard_action_page_fragment + return R.layout.omnipod_wizard_action_page_fragment } } \ No newline at end of file diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/fragment/info/InfoFragmentBase.kt b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/common/fragment/InfoFragmentBase.kt similarity index 54% rename from omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/fragment/info/InfoFragmentBase.kt rename to omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/common/fragment/InfoFragmentBase.kt index 1a69cbd701..d1008a1bea 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/fragment/info/InfoFragmentBase.kt +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/common/fragment/InfoFragmentBase.kt @@ -1,19 +1,18 @@ -package info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.fragment.info +package info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.common.fragment import android.os.Bundle import android.view.View import androidx.annotation.LayoutRes import androidx.annotation.StringRes import info.nightscout.androidaps.plugins.pump.omnipod.R -import info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.fragment.ChangePodWizardFragmentBase -import kotlinx.android.synthetic.main.omnipod_change_pod_wizard_info_page_fragment.* +import kotlinx.android.synthetic.main.omnipod_wizard_info_page_fragment.* -abstract class InfoFragmentBase : ChangePodWizardFragmentBase() { +abstract class InfoFragmentBase : WizardFragmentBase() { override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) - omnipod_change_pod_wizard_info_page_text.setText(getTextId()) + omnipod_wizard_info_page_text.setText(getTextId()) } @StringRes @@ -21,7 +20,7 @@ abstract class InfoFragmentBase : ChangePodWizardFragmentBase() { @LayoutRes override fun getLayoutId(): Int { - return R.layout.omnipod_change_pod_wizard_info_page_fragment + return R.layout.omnipod_wizard_info_page_fragment } } \ No newline at end of file diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/common/fragment/WizardFragmentBase.kt b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/common/fragment/WizardFragmentBase.kt new file mode 100644 index 0000000000..cd6f135f08 --- /dev/null +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/common/fragment/WizardFragmentBase.kt @@ -0,0 +1,84 @@ +package info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.common.fragment + +import android.content.res.ColorStateList +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.view.ViewStub +import androidx.annotation.IdRes +import androidx.annotation.LayoutRes +import androidx.annotation.StringRes +import androidx.navigation.fragment.findNavController +import dagger.android.support.DaggerFragment +import info.nightscout.androidaps.plugins.pump.omnipod.R +import info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.common.activity.OmnipodWizardActivityBase +import kotlinx.android.synthetic.main.omnipod_wizard_base_fragment.* +import kotlinx.android.synthetic.main.omnipod_wizard_nav_buttons.* +import kotlinx.android.synthetic.main.omnipod_wizard_progress_indication.* +import kotlin.math.roundToInt + +abstract class WizardFragmentBase : DaggerFragment() { + override fun onCreateView( + inflater: LayoutInflater, + container: ViewGroup?, + savedInstanceState: Bundle? + ): View { + val baseView = inflater.inflate(R.layout.omnipod_wizard_base_fragment, container, false) + val contentView = baseView.findViewById(R.id.omnipod_wizard_base_fragment_content) + contentView?.let { + it.layoutResource = getLayoutId() + it.inflate() + } + return baseView + } + + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) + + omnipod_wizard_base_fragment_title.setText(getTitleId()) + + val nextPage = getNextPageActionId() + + if (nextPage == null) { + omnipod_wizard_button_next.text = getString(R.string.omnipod_wizard_button_finish) + omnipod_wizard_button_next.backgroundTintList = ColorStateList.valueOf(resources.getColor(R.color.review_green, context?.theme)) + } + + updateProgressIndication() + + omnipod_wizard_button_next.setOnClickListener { + if (nextPage == null) { + activity?.finish() + } else { + findNavController().navigate(nextPage) + } + } + + omnipod_wizard_button_cancel.setOnClickListener { + (activity as? OmnipodWizardActivityBase)?.exitActivityAfterConfirmation() + } + } + + private fun updateProgressIndication() { + (activity as? OmnipodWizardActivityBase)?.let { + val numberOfSteps = it.getActualNumberOfSteps() + + val currentFragment = getIndex() - (it.getTotalDefinedNumberOfSteps() - numberOfSteps) + val progressPercentage = (currentFragment / numberOfSteps.toDouble() * 100).roundToInt() + + omnipod_wizard_progress_indication.progress = progressPercentage + } + } + + @LayoutRes + protected abstract fun getLayoutId(): Int + + @IdRes + protected abstract fun getNextPageActionId(): Int? + + @StringRes + protected abstract fun getTitleId(): Int + + protected abstract fun getIndex(): Int +} \ No newline at end of file diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/viewmodel/ActionViewModelBase.kt b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/common/viewmodel/ActionViewModelBase.kt similarity index 98% rename from omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/viewmodel/ActionViewModelBase.kt rename to omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/common/viewmodel/ActionViewModelBase.kt index f6212758eb..1590f752e2 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/viewmodel/ActionViewModelBase.kt +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/common/viewmodel/ActionViewModelBase.kt @@ -1,4 +1,4 @@ -package info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.viewmodel +package info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.common.viewmodel import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/deactivation/PodDeactivationWizardActivity.kt b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/deactivation/PodDeactivationWizardActivity.kt new file mode 100644 index 0000000000..892d85a97e --- /dev/null +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/deactivation/PodDeactivationWizardActivity.kt @@ -0,0 +1,18 @@ +package info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.deactivation + +import android.os.Bundle +import info.nightscout.androidaps.plugins.pump.omnipod.R +import info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.common.activity.OmnipodWizardActivityBase + +class PodDeactivationWizardActivity : OmnipodWizardActivityBase() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + + setContentView(R.layout.omnipod_pod_deactivation_wizard_activity) + } + + override fun getTotalDefinedNumberOfSteps(): Int = 3 + + override fun getActualNumberOfSteps(): Int = 3 + +} \ No newline at end of file diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/fragment/action/DeactivatePodActionFragment.kt b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/deactivation/fragment/DeactivatePodActionFragment.kt similarity index 71% rename from omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/fragment/action/DeactivatePodActionFragment.kt rename to omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/deactivation/fragment/DeactivatePodActionFragment.kt index 202889fdc0..a88b5866be 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/fragment/action/DeactivatePodActionFragment.kt +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/deactivation/fragment/DeactivatePodActionFragment.kt @@ -1,4 +1,4 @@ -package info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.fragment.action +package info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.deactivation.fragment import android.app.AlertDialog import android.os.Bundle @@ -11,9 +11,10 @@ import androidx.navigation.fragment.findNavController import info.nightscout.androidaps.plugins.pump.omnipod.R import info.nightscout.androidaps.plugins.pump.omnipod.dagger.OmnipodPluginQualifier import info.nightscout.androidaps.plugins.pump.omnipod.manager.AapsOmnipodManager -import info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.viewmodel.DeactivatePodActionViewModel +import info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.common.fragment.ActionFragmentBase +import info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.deactivation.viewmodel.DeactivatePodActionViewModel import info.nightscout.androidaps.utils.extensions.toVisibility -import kotlinx.android.synthetic.main.omnipod_change_pod_wizard_action_page_fragment.* +import kotlinx.android.synthetic.main.omnipod_wizard_action_page_fragment.* import javax.inject.Inject class DeactivatePodActionFragment : ActionFragmentBase() { @@ -33,11 +34,11 @@ class DeactivatePodActionFragment : ActionFragmentBase() { override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) - omnipod_change_pod_wizard_button_discard_pod.setOnClickListener { + omnipod_wizard_button_discard_pod.setOnClickListener { AlertDialog.Builder(context) .setIcon(android.R.drawable.ic_dialog_alert) - .setTitle(getString(R.string.omnipod_change_pod_wizard_discard_pod)) - .setMessage(getString(R.string.omnipod_change_pod_wizard_discard_pod_confirmation)) + .setTitle(getString(R.string.omnipod_pod_deactivation_wizard_discard_pod)) + .setMessage(getString(R.string.omnipod_pod_deactivation_wizard_discard_pod_confirmation)) .setPositiveButton(getString(R.string.omnipod_yes)) { _, _ -> aapsOmnipodManager.discardPodState() findNavController().navigate(R.id.action_deactivatePodActionFragment_to_podDiscardedInfoFragment) @@ -48,14 +49,14 @@ class DeactivatePodActionFragment : ActionFragmentBase() { } override fun onActionFailure() { - omnipod_change_pod_wizard_button_discard_pod.visibility = (!isActionExecuting()).toVisibility() + omnipod_wizard_button_discard_pod.visibility = (!isActionExecuting()).toVisibility() } @StringRes - override fun getTitleId(): Int = R.string.omnipod_change_pod_wizard_deactivating_pod_title + override fun getTitleId(): Int = R.string.omnipod_pod_deactivation_wizard_deactivating_pod_title @StringRes - override fun getTextId(): Int = R.string.omnipod_change_pod_wizard_deactivating_pod_text + override fun getTextId(): Int = R.string.omnipod_pod_deactivation_wizard_deactivating_pod_text @IdRes override fun getNextPageActionId(): Int = R.id.action_deactivatePodActionFragment_to_podDeactivatedInfoFragment diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/fragment/info/DeactivatePodInfoFragment.kt b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/deactivation/fragment/DeactivatePodInfoFragment.kt similarity index 58% rename from omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/fragment/info/DeactivatePodInfoFragment.kt rename to omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/deactivation/fragment/DeactivatePodInfoFragment.kt index 824a2e44b2..5fefcfc549 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/fragment/info/DeactivatePodInfoFragment.kt +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/deactivation/fragment/DeactivatePodInfoFragment.kt @@ -1,15 +1,16 @@ -package info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.fragment.info +package info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.deactivation.fragment import androidx.annotation.IdRes import androidx.annotation.StringRes import info.nightscout.androidaps.plugins.pump.omnipod.R +import info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.common.fragment.InfoFragmentBase class DeactivatePodInfoFragment : InfoFragmentBase() { @StringRes - override fun getTitleId(): Int = R.string.omnipod_change_pod_wizard_deactivate_pod_title + override fun getTitleId(): Int = R.string.omnipod_pod_deactivation_wizard_deactivate_pod_title @StringRes - override fun getTextId(): Int = R.string.omnipod_change_pod_wizard_deactivate_pod_text + override fun getTextId(): Int = R.string.omnipod_pod_deactivation_wizard_deactivate_pod_text @IdRes override fun getNextPageActionId(): Int = R.id.action_deactivatePodInfoFragment_to_deactivatePodActionFragment diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/deactivation/fragment/PodDeactivatedInfoFragment.kt b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/deactivation/fragment/PodDeactivatedInfoFragment.kt new file mode 100644 index 0000000000..3b1c80cbb1 --- /dev/null +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/deactivation/fragment/PodDeactivatedInfoFragment.kt @@ -0,0 +1,19 @@ +package info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.deactivation.fragment + +import androidx.annotation.IdRes +import androidx.annotation.StringRes +import info.nightscout.androidaps.plugins.pump.omnipod.R +import info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.common.fragment.InfoFragmentBase + +class PodDeactivatedInfoFragment : InfoFragmentBase() { + @StringRes + override fun getTitleId(): Int = R.string.omnipod_pod_deactivation_wizard_pod_deactivated_title + + @StringRes + override fun getTextId(): Int = R.string.omnipod_pod_deactivation_wizard_pod_deactivated_text + + @IdRes + override fun getNextPageActionId(): Int? = null + + override fun getIndex(): Int = 3 +} \ No newline at end of file diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/deactivation/fragment/PodDiscardedInfoFragment.kt b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/deactivation/fragment/PodDiscardedInfoFragment.kt new file mode 100644 index 0000000000..7b53f4abc4 --- /dev/null +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/deactivation/fragment/PodDiscardedInfoFragment.kt @@ -0,0 +1,19 @@ +package info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.deactivation.fragment + +import androidx.annotation.IdRes +import androidx.annotation.StringRes +import info.nightscout.androidaps.plugins.pump.omnipod.R +import info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.common.fragment.InfoFragmentBase + +class PodDiscardedInfoFragment : InfoFragmentBase() { + @StringRes + override fun getTitleId(): Int = R.string.omnipod_pod_deactivation_wizard_pod_discarded_title + + @StringRes + override fun getTextId(): Int = R.string.omnipod_pod_deactivation_wizard_pod_discarded_text + + @IdRes + override fun getNextPageActionId(): Int? = null + + override fun getIndex(): Int = 3 +} \ No newline at end of file diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/viewmodel/DeactivatePodActionViewModel.kt b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/deactivation/viewmodel/DeactivatePodActionViewModel.kt similarity index 89% rename from omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/viewmodel/DeactivatePodActionViewModel.kt rename to omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/deactivation/viewmodel/DeactivatePodActionViewModel.kt index 49d0f2ed19..80296603f2 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/viewmodel/DeactivatePodActionViewModel.kt +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/deactivation/viewmodel/DeactivatePodActionViewModel.kt @@ -1,9 +1,10 @@ -package info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.viewmodel +package info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.deactivation.viewmodel import info.nightscout.androidaps.data.PumpEnactResult import info.nightscout.androidaps.interfaces.CommandQueueProvider import info.nightscout.androidaps.plugins.pump.omnipod.manager.AapsOmnipodManager import info.nightscout.androidaps.plugins.pump.omnipod.queue.command.CommandDeactivatePod +import info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.common.viewmodel.ActionViewModelBase import info.nightscout.androidaps.queue.Callback import io.reactivex.subjects.SingleSubject import javax.inject.Inject diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/fragment/ChangePodWizardFragmentBase.kt b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/fragment/ChangePodWizardFragmentBase.kt deleted file mode 100644 index 5c5c1befef..0000000000 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/fragment/ChangePodWizardFragmentBase.kt +++ /dev/null @@ -1,97 +0,0 @@ -package info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.fragment - -import android.content.res.ColorStateList -import android.os.Bundle -import android.view.LayoutInflater -import android.view.View -import android.view.ViewGroup -import android.view.ViewStub -import androidx.annotation.IdRes -import androidx.annotation.LayoutRes -import androidx.annotation.StringRes -import androidx.navigation.fragment.findNavController -import dagger.android.support.DaggerFragment -import info.nightscout.androidaps.plugins.pump.omnipod.R -import info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.ChangePodWizardActivity -import kotlinx.android.synthetic.main.omnipod_change_pod_wizard_base_fragment.* -import kotlinx.android.synthetic.main.omnipod_change_pod_wizard_nav_buttons.* -import kotlinx.android.synthetic.main.omnipod_change_pod_wizard_progress_indication.* -import kotlin.math.roundToInt - -abstract class ChangePodWizardFragmentBase : DaggerFragment() { - override fun onCreateView( - inflater: LayoutInflater, - container: ViewGroup?, - savedInstanceState: Bundle? - ): View { - val baseView = inflater.inflate(R.layout.omnipod_change_pod_wizard_base_fragment, container, false) - val contentView = baseView.findViewById(R.id.omnipod_change_pod_wizard_base_fragment_content) - contentView?.let { - it.layoutResource = getLayoutId() - it.inflate() - } - return baseView - } - - override fun onViewCreated(view: View, savedInstanceState: Bundle?) { - super.onViewCreated(view, savedInstanceState) - - omnipod_change_pod_wizard_base_fragment_title.setText(getTitleId()) - - val nextPage = getNextPageActionId() - - if (nextPage == null) { - omnipod_change_pod_wizard_button_next.text = getString(R.string.omnipod_change_pod_wizard_button_finish) - omnipod_change_pod_wizard_button_next.backgroundTintList = ColorStateList.valueOf(resources.getColor(R.color.review_green, context?.theme)) - } - - updateProgressIndication() - - omnipod_change_pod_wizard_button_next.setOnClickListener { - if (nextPage == null) { - activity?.finish() - } else { - findNavController().navigate(nextPage) - } - } - - omnipod_change_pod_wizard_button_cancel.setOnClickListener { - (activity as? ChangePodWizardActivity)?.exitActivityAfterConfirmation() - } - } - - private fun updateProgressIndication() { - val findNavController = findNavController() - val graph = findNavController.graph - val totalFragments = - when (graph.startDestination) { - R.id.fillPodInfoFragment -> { - 8 - 3 - } - - R.id.attachPodInfoFragment -> { - 8 - 5 - } - - else -> { - 8 - } - } - - val currentFragment = getIndex() - (8 - totalFragments) - val progressPercentage = (currentFragment / totalFragments.toDouble() * 100).roundToInt() - - omnipod_change_pod_wizard_progress_indication.progress = progressPercentage - } - - @LayoutRes - protected abstract fun getLayoutId(): Int - - @IdRes - protected abstract fun getNextPageActionId(): Int? - - @StringRes - protected abstract fun getTitleId(): Int - - protected abstract fun getIndex(): Int -} \ No newline at end of file diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/fragment/action/InsertCannulaActionFragment.kt b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/fragment/action/InsertCannulaActionFragment.kt deleted file mode 100644 index ef9d2e5d39..0000000000 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/fragment/action/InsertCannulaActionFragment.kt +++ /dev/null @@ -1,61 +0,0 @@ -package info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.fragment.action - -import android.os.Bundle -import android.view.View -import androidx.annotation.IdRes -import androidx.annotation.StringRes -import androidx.fragment.app.viewModels -import androidx.lifecycle.ViewModelProvider -import androidx.navigation.fragment.findNavController -import info.nightscout.androidaps.plugins.pump.omnipod.R -import info.nightscout.androidaps.plugins.pump.omnipod.dagger.OmnipodPluginQualifier -import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.PodProgressStatus -import info.nightscout.androidaps.plugins.pump.omnipod.driver.manager.PodStateManager -import info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.ChangePodWizardActivity -import info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.viewmodel.InsertCannulaActionViewModel -import kotlinx.android.synthetic.main.omnipod_change_pod_wizard_action_page_fragment.* -import javax.inject.Inject - -class InsertCannulaActionFragment : ActionFragmentBase() { - @Inject - @OmnipodPluginQualifier - lateinit var viewModelFactory: ViewModelProvider.Factory - - @Inject - lateinit var podStateManager: PodStateManager - - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - - val vm: InsertCannulaActionViewModel by viewModels { viewModelFactory } - this.viewModel = vm - } - - override fun onViewCreated(view: View, savedInstanceState: Bundle?) { - super.onViewCreated(view, savedInstanceState) - - omnipod_change_pod_wizard_button_deactivate_pod.setOnClickListener { - (activity as? ChangePodWizardActivity)?.setStartDestination(R.id.deactivatePodInfoFragment) - findNavController().navigate(R.id.deactivatePodInfoFragment) - } - } - - override fun onActionFailure() { - if (podStateManager.isPodInitialized && podStateManager.podProgressStatus == PodProgressStatus.ACTIVATION_TIME_EXCEEDED) { - omnipod_change_pod_wizard_action_error.setText(R.string.omnipod_error_pod_fault_activation_time_exceeded) - omnipod_change_pod_wizard_button_retry.visibility = View.GONE - omnipod_change_pod_wizard_button_deactivate_pod.visibility = View.VISIBLE - } - } - - @StringRes - override fun getTitleId(): Int = R.string.omnipod_change_pod_wizard_insert_cannula_title - - @StringRes - override fun getTextId(): Int = R.string.omnipod_change_pod_wizard_insert_cannula_text - - @IdRes - override fun getNextPageActionId(): Int = R.id.action_insertCannulaActionFragment_to_PodChangedInfoFragment - - override fun getIndex(): Int = 7 -} \ No newline at end of file diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/fragment/action/PairAndPrimePodActionFragment.kt b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/fragment/action/PairAndPrimePodActionFragment.kt deleted file mode 100644 index f2054bc7ee..0000000000 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/fragment/action/PairAndPrimePodActionFragment.kt +++ /dev/null @@ -1,61 +0,0 @@ -package info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.fragment.action - -import android.os.Bundle -import android.view.View -import androidx.annotation.IdRes -import androidx.annotation.StringRes -import androidx.fragment.app.viewModels -import androidx.lifecycle.ViewModelProvider -import androidx.navigation.fragment.findNavController -import info.nightscout.androidaps.plugins.pump.omnipod.R -import info.nightscout.androidaps.plugins.pump.omnipod.dagger.OmnipodPluginQualifier -import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.PodProgressStatus -import info.nightscout.androidaps.plugins.pump.omnipod.driver.manager.PodStateManager -import info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.ChangePodWizardActivity -import info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.viewmodel.PairAndPrimePodActionViewModel -import kotlinx.android.synthetic.main.omnipod_change_pod_wizard_action_page_fragment.* -import javax.inject.Inject - -class PairAndPrimePodActionFragment : ActionFragmentBase() { - @Inject - @OmnipodPluginQualifier - lateinit var viewModelFactory: ViewModelProvider.Factory - - @Inject - lateinit var podStateManager: PodStateManager - - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - - val vm: PairAndPrimePodActionViewModel by viewModels { viewModelFactory } - this.viewModel = vm - } - - override fun onViewCreated(view: View, savedInstanceState: Bundle?) { - super.onViewCreated(view, savedInstanceState) - - omnipod_change_pod_wizard_button_deactivate_pod.setOnClickListener { - (activity as? ChangePodWizardActivity)?.setStartDestination(R.id.deactivatePodInfoFragment) - findNavController().navigate(R.id.deactivatePodInfoFragment) - } - } - - override fun onActionFailure() { - if (podStateManager.isPodInitialized && podStateManager.podProgressStatus == PodProgressStatus.ACTIVATION_TIME_EXCEEDED) { - omnipod_change_pod_wizard_action_error.setText(R.string.omnipod_error_pod_fault_activation_time_exceeded) - omnipod_change_pod_wizard_button_retry.visibility = View.GONE - omnipod_change_pod_wizard_button_deactivate_pod.visibility = View.VISIBLE - } - } - - @StringRes - override fun getTitleId(): Int = R.string.omnipod_change_pod_wizard_activate_pod_title - - @StringRes - override fun getTextId(): Int = R.string.omnipod_change_pod_wizard_activate_pod_text - - @IdRes - override fun getNextPageActionId(): Int = R.id.action_pairAndPrimePodActionFragment_to_attachPodInfoFragment - - override fun getIndex(): Int = 5 -} \ No newline at end of file diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/fragment/info/FillPodInfoFragment.kt b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/fragment/info/FillPodInfoFragment.kt deleted file mode 100644 index 1c7e2f24d8..0000000000 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/fragment/info/FillPodInfoFragment.kt +++ /dev/null @@ -1,18 +0,0 @@ -package info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.fragment.info - -import androidx.annotation.IdRes -import androidx.annotation.StringRes -import info.nightscout.androidaps.plugins.pump.omnipod.R - -class FillPodInfoFragment : InfoFragmentBase() { - @StringRes - override fun getTitleId(): Int = R.string.omnipod_change_pod_wizard_fill_pod_title - - @StringRes - override fun getTextId(): Int = R.string.omnipod_change_pod_wizard_fill_pod_text - - @IdRes - override fun getNextPageActionId(): Int = R.id.action_fillPodInfoFragment_to_pairAndPrimePodActionFragment - - override fun getIndex(): Int = 4 -} \ No newline at end of file diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/fragment/info/PodChangedInfoFragment.kt b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/fragment/info/PodChangedInfoFragment.kt deleted file mode 100644 index d0f6cf0561..0000000000 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/fragment/info/PodChangedInfoFragment.kt +++ /dev/null @@ -1,18 +0,0 @@ -package info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.fragment.info - -import androidx.annotation.IdRes -import androidx.annotation.StringRes -import info.nightscout.androidaps.plugins.pump.omnipod.R - -class PodChangedInfoFragment : InfoFragmentBase() { - @StringRes - override fun getTitleId(): Int = R.string.omnipod_change_pod_wizard_pod_changed_title - - @StringRes - override fun getTextId(): Int = R.string.omnipod_change_pod_wizard_pod_changed_text - - @IdRes - override fun getNextPageActionId(): Int? = null - - override fun getIndex(): Int = 8 -} \ No newline at end of file diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/fragment/info/PodDeactivatedInfoFragment.kt b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/fragment/info/PodDeactivatedInfoFragment.kt deleted file mode 100644 index 5b3aef7870..0000000000 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/fragment/info/PodDeactivatedInfoFragment.kt +++ /dev/null @@ -1,18 +0,0 @@ -package info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.fragment.info - -import androidx.annotation.IdRes -import androidx.annotation.StringRes -import info.nightscout.androidaps.plugins.pump.omnipod.R - -class PodDeactivatedInfoFragment : InfoFragmentBase() { - @StringRes - override fun getTitleId(): Int = R.string.omnipod_change_pod_wizard_pod_deactivated_title - - @StringRes - override fun getTextId(): Int = R.string.omnipod_change_pod_wizard_pod_deactivated_text - - @IdRes - override fun getNextPageActionId(): Int = R.id.action_podDeactivatedInfoFragment_to_fillPodInfoFragment - - override fun getIndex(): Int = 3 -} \ No newline at end of file diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/fragment/info/PodDiscardedInfoFragment.kt b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/fragment/info/PodDiscardedInfoFragment.kt deleted file mode 100644 index 1e295f5331..0000000000 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard/fragment/info/PodDiscardedInfoFragment.kt +++ /dev/null @@ -1,18 +0,0 @@ -package info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.fragment.info - -import androidx.annotation.IdRes -import androidx.annotation.StringRes -import info.nightscout.androidaps.plugins.pump.omnipod.R - -class PodDiscardedInfoFragment : InfoFragmentBase() { - @StringRes - override fun getTitleId(): Int = R.string.omnipod_change_pod_wizard_pod_discarded_title - - @StringRes - override fun getTextId(): Int = R.string.omnipod_change_pod_wizard_pod_discarded_text - - @IdRes - override fun getNextPageActionId(): Int = R.id.action_podDiscardedInfoFragment_to_fillPodInfoFragment - - override fun getIndex(): Int = 3 -} \ No newline at end of file diff --git a/omnipod/src/main/res/layout/omnipod_change_pod_wizard_activity.xml b/omnipod/src/main/res/layout/omnipod_pod_activation_wizard_activity.xml similarity index 100% rename from omnipod/src/main/res/layout/omnipod_change_pod_wizard_activity.xml rename to omnipod/src/main/res/layout/omnipod_pod_activation_wizard_activity.xml diff --git a/omnipod/src/main/res/layout/omnipod_pod_deactivation_wizard_activity.xml b/omnipod/src/main/res/layout/omnipod_pod_deactivation_wizard_activity.xml new file mode 100644 index 0000000000..8104ed2ec4 --- /dev/null +++ b/omnipod/src/main/res/layout/omnipod_pod_deactivation_wizard_activity.xml @@ -0,0 +1,15 @@ + + + + + \ No newline at end of file diff --git a/omnipod/src/main/res/layout/omnipod_pod_management.xml b/omnipod/src/main/res/layout/omnipod_pod_management.xml index f76b7ed544..bc088db71f 100644 --- a/omnipod/src/main/res/layout/omnipod_pod_management.xml +++ b/omnipod/src/main/res/layout/omnipod_pod_management.xml @@ -15,11 +15,10 @@ - + android:drawableTop="@drawable/ic_actions_temptarget" + android:text="@string/omnipod_pod_management_button_deactivate_pod" + android:textAllCaps="false" /> - - + android:layout_marginBottom="@dimen/omnipod_wizard_vertical_spacing" + android:textAppearance="@style/OmnipodWizardText" />