diff --git a/omnipod/build.gradle b/omnipod/build.gradle
index 948b9f17dc..cf19262acc 100644
--- a/omnipod/build.gradle
+++ b/omnipod/build.gradle
@@ -75,6 +75,7 @@ dependencies {
implementation 'androidx.core:core-ktx:1.2.0'
implementation "androidx.preference:preference-ktx:1.1.1"
implementation "androidx.activity:activity-ktx:${activityVersion}"
+ implementation "androidx.fragment:fragment:${fragmentVersion}"
implementation 'com.google.android.material:material:1.1.0'
implementation 'com.google.firebase:firebase-analytics-ktx:17.4.3'
diff --git a/omnipod/src/main/AndroidManifest.xml b/omnipod/src/main/AndroidManifest.xml
index 9171091799..924fee176f 100644
--- a/omnipod/src/main/AndroidManifest.xml
+++ b/omnipod/src/main/AndroidManifest.xml
@@ -9,7 +9,7 @@
-
+
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 e0ab2a651c..2bf3095cd4 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
@@ -13,7 +13,7 @@ import info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.initpod.InitAct
import info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.initpod.InitPodTask
import info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.pages.PodInfoFragment
import info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.removepod.RemoveActionFragment
-import info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard2.WizardActivity
+import info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard2.ReplacePodWizardActivity
@Module
@Suppress("unused")
@@ -26,7 +26,7 @@ abstract class OmnipodModule {
@ActivityScope
@ContributesAndroidInjector(modules = [OmnipodWizardModule::class])
- abstract fun contributesWizardActivity(): WizardActivity
+ abstract fun contributesWizardActivity(): ReplacePodWizardActivity
// Fragments
@ContributesAndroidInjector abstract fun initActionFragment(): InitActionFragment
diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/OmnipodFragment.kt b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/OmnipodFragment.kt
index ebea1f9703..5ffe10db0b 100644
--- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/OmnipodFragment.kt
+++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/OmnipodFragment.kt
@@ -29,7 +29,7 @@ import info.nightscout.androidaps.plugins.pump.omnipod.driver.manager.PodStateMa
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.queue.command.*
-import info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard2.WizardActivity
+import info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard2.ReplacePodWizardActivity
import info.nightscout.androidaps.plugins.pump.omnipod.util.AapsOmnipodUtil
import info.nightscout.androidaps.queue.Callback
import info.nightscout.androidaps.queue.events.EventQueueChanged
@@ -94,7 +94,7 @@ class OmnipodFragment : DaggerFragment() {
super.onViewCreated(view, savedInstanceState)
omnipod_button_replace_pod.setOnClickListener {
- startActivity(Intent(context, WizardActivity::class.java))
+ startActivity(Intent(context, ReplacePodWizardActivity::class.java))
}
omnipod_button_pod_mgmt.setOnClickListener {
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 181a0af528..47567445bb 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
@@ -23,7 +23,7 @@ import info.nightscout.androidaps.plugins.pump.omnipod.manager.AapsOmnipodManage
import info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.model.FullInitPodWizardModel
import info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.model.RemovePodWizardModel
import info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.model.ShortInitPodWizardModel
-import info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard2.WizardActivity
+import info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard2.ReplacePodWizardActivity
import info.nightscout.androidaps.utils.FabricPrivacy
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
import info.nightscout.androidaps.utils.extensions.plusAssign
@@ -58,7 +58,7 @@ class PodManagementActivity : NoSplashAppCompatActivity() {
}
initpod_replace_pod.setOnClickListener {
- val myIntent = Intent(this@PodManagementActivity, WizardActivity::class.java)
+ val myIntent = Intent(this@PodManagementActivity, ReplacePodWizardActivity::class.java)
this@PodManagementActivity.startActivity(myIntent)
}
diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard2/ReplacePodWizardActivity.kt b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard2/ReplacePodWizardActivity.kt
new file mode 100644
index 0000000000..0dacf911e8
--- /dev/null
+++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard2/ReplacePodWizardActivity.kt
@@ -0,0 +1,53 @@
+package info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard2
+
+import android.os.Bundle
+import android.os.PersistableBundle
+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 ReplacePodWizardActivity : NoSplashAppCompatActivity() {
+ companion object {
+ const val KEY_START_DESTINATION = "startDestination"
+ }
+
+ @Inject
+ lateinit var podStateManager: PodStateManager
+
+ var startDestination: Int = R.id.deactivatePodInfoFragment
+ get() = field
+
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+
+ if (savedInstanceState == null) {
+ setContentView(R.layout.omnipod_replace_pod_wizard_activity)
+
+ val navHostFragment = supportFragmentManager.findFragmentById(R.id.nav_host_fragment) as NavHostFragment
+ val navController = navHostFragment.navController
+ val navInflater = navController.navInflater
+ val graph = navInflater.inflate(R.navigation.omnipod_replace_pod_wizard_navigation_graph)
+
+ if (!podStateManager.isPodActivationCompleted) {
+ if (!podStateManager.isPodInitialized || podStateManager.podProgressStatus.isBefore(PodProgressStatus.PRIMING_COMPLETED)) {
+ startDestination = R.id.fillPodInfoFragment
+ } else {
+ startDestination = R.id.attachPodInfoFragment
+ }
+ }
+
+ graph.startDestination = startDestination;
+ navController.graph = graph
+ } else {
+ startDestination = savedInstanceState.getInt(KEY_START_DESTINATION, R.id.deactivatePodInfoFragment)
+ }
+ }
+
+ override fun onSaveInstanceState(outState: Bundle?, outPersistentState: PersistableBundle?) {
+ super.onSaveInstanceState(outState, outPersistentState)
+ outState?.putInt(KEY_START_DESTINATION, startDestination)
+ }
+}
\ No newline at end of file
diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard2/WizardActivity.kt b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard2/WizardActivity.kt
deleted file mode 100644
index 48986c0c02..0000000000
--- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard2/WizardActivity.kt
+++ /dev/null
@@ -1,13 +0,0 @@
-package info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard2
-
-import android.os.Bundle
-import info.nightscout.androidaps.activities.NoSplashAppCompatActivity
-import info.nightscout.androidaps.plugins.pump.omnipod.R
-
-class WizardActivity : NoSplashAppCompatActivity() {
-
- override fun onCreate(savedInstanceState: Bundle?) {
- super.onCreate(savedInstanceState)
- setContentView(R.layout.omnipod_replace_pod_wizard_activity) // TODO: replace with DataBindingUtil.setContentView
- }
-}
\ No newline at end of file
diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard2/fragment/FragmentBase.kt b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard2/fragment/FragmentBase.kt
new file mode 100644
index 0000000000..62218df708
--- /dev/null
+++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard2/fragment/FragmentBase.kt
@@ -0,0 +1,73 @@
+package info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard2.fragment
+
+import android.os.Bundle
+import android.view.LayoutInflater
+import android.view.View
+import android.view.ViewGroup
+import android.widget.Button
+import android.widget.TextView
+import androidx.annotation.IdRes
+import androidx.annotation.LayoutRes
+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.wizard2.ReplacePodWizardActivity
+
+abstract class FragmentBase : DaggerFragment() {
+ override fun onCreateView(
+ inflater: LayoutInflater,
+ container: ViewGroup?,
+ savedInstanceState: Bundle?
+ ): View? = inflater.inflate(getLayout(), container, false)
+
+ override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
+ super.onViewCreated(view, savedInstanceState)
+
+ view.findViewById