From ca4d809f41e0b9c5b1c467f3060080a6c10ca8bb Mon Sep 17 00:00:00 2001 From: Bart Sopers Date: Sat, 26 Sep 2020 19:29:28 +0200 Subject: [PATCH] WIP on adding navigation between Omnipod fragments in replace Pod wizard --- app/build.gradle | 6 ++ build.gradle | 3 +- omnipod/build.gradle | 9 ++- .../omnipod/dagger/OmnipodWizardModule.kt | 4 +- .../pump/omnipod/ui/PodManagementActivity.kt | 6 ++ .../pump/omnipod/ui/wizard2/WizardActivity.kt | 2 +- .../wizard2/{ => fragment}/WizardFragment1.kt | 13 ++-- .../fragment/action/ActionFragmentBase.kt | 25 +++++++ .../action/DeactivatePodActionFragment.kt | 5 ++ .../action/InsertCannulaActionFragment.kt | 5 ++ .../action/PairAndPrimePodActionFragment.kt | 5 ++ .../fragment/info/AttachPodInfoFragment.kt | 5 ++ .../info/DeactivatePodInfoFragment.kt | 5 ++ .../fragment/info/FillPodInfoFragment.kt | 5 ++ .../wizard2/fragment/info/InfoFragmentBase.kt | 26 ++++++++ .../info/PodDeactivatedInfoFragment.kt | 5 ++ .../fragment/info/PodReplacedInfoFragment.kt | 5 ++ .../{ => viewmodel}/WizardViewModel1.kt | 2 +- .../src/main/res/layout/omnipod_pod_mgmt.xml | 24 +++++-- ...eplace_pod_wizard_action_page_fragment.xml | 17 +++++ .../omnipod_replace_pod_wizard_activity.xml | 21 ++++++ ..._replace_pod_wizard_info_page_fragment.xml | 16 +++++ .../res/layout/omnipod_wizard_activity.xml | 14 ---- .../res/layout/omnipod_wizard_fragment1.xml | 14 ---- ...od_replace_pod_wizard_navigation_graph.xml | 66 +++++++++++++++++++ omnipod/src/main/res/values/strings.xml | 1 + 26 files changed, 263 insertions(+), 46 deletions(-) rename omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard2/{ => fragment}/WizardFragment1.kt (77%) create mode 100644 omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard2/fragment/action/ActionFragmentBase.kt create mode 100644 omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard2/fragment/action/DeactivatePodActionFragment.kt create mode 100644 omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard2/fragment/action/InsertCannulaActionFragment.kt create mode 100644 omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard2/fragment/action/PairAndPrimePodActionFragment.kt create mode 100644 omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard2/fragment/info/AttachPodInfoFragment.kt create mode 100644 omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard2/fragment/info/DeactivatePodInfoFragment.kt create mode 100644 omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard2/fragment/info/FillPodInfoFragment.kt create mode 100644 omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard2/fragment/info/InfoFragmentBase.kt create mode 100644 omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard2/fragment/info/PodDeactivatedInfoFragment.kt create mode 100644 omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard2/fragment/info/PodReplacedInfoFragment.kt rename omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard2/{ => viewmodel}/WizardViewModel1.kt (98%) create mode 100644 omnipod/src/main/res/layout/omnipod_replace_pod_wizard_action_page_fragment.xml create mode 100644 omnipod/src/main/res/layout/omnipod_replace_pod_wizard_activity.xml create mode 100644 omnipod/src/main/res/layout/omnipod_replace_pod_wizard_info_page_fragment.xml delete mode 100644 omnipod/src/main/res/layout/omnipod_wizard_activity.xml delete mode 100644 omnipod/src/main/res/layout/omnipod_wizard_fragment1.xml create mode 100644 omnipod/src/main/res/navigation/omnipod_replace_pod_wizard_navigation_graph.xml diff --git a/app/build.gradle b/app/build.gradle index 1b2b39485a..be67687bda 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -354,6 +354,12 @@ dependencies { androidTestImplementation 'androidx.test.uiautomator:uiautomator:2.2.0' + // Navigation + implementation "androidx.navigation:navigation-fragment:$nav_version" + implementation "androidx.navigation:navigation-ui:$nav_version" + implementation "androidx.navigation:navigation-fragment-ktx:$nav_version" + implementation "androidx.navigation:navigation-ui-ktx:$nav_version" + //WorkManager implementation 'androidx.work:work-runtime:2.3.4' implementation 'androidx.work:work-runtime-ktx:2.3.4' diff --git a/build.gradle b/build.gradle index aeeb75768d..185f3010ee 100644 --- a/build.gradle +++ b/build.gradle @@ -13,7 +13,8 @@ buildscript { coroutinesVersion = '1.3.7' activityVersion = '1.2.0-alpha06' fragmentVersion = '1.3.0-alpha07' - ormLiteVersion = "4.46" + ormLiteVersion = '4.46' + nav_version = '2.3.0' } repositories { google() diff --git a/omnipod/build.gradle b/omnipod/build.gradle index c3b3a84f35..ab5129a293 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' @@ -86,12 +87,10 @@ dependencies { implementation "com.joanzapata.iconify:android-iconify-fontawesome:2.2.2" - // Omnipod - start implementation 'org.apache.commons:commons-lang3:3.10' implementation 'net.danlew:android.joda:2.10.6' implementation "com.google.code.gson:gson:2.8.6" implementation(name: "com.atech-software.android.library.wizardpager-1.1.4", ext: "aar") - // Omnipod - end implementation "com.google.dagger:dagger-android:$dagger_version" implementation "com.google.dagger:dagger-android-support:$dagger_version" @@ -100,6 +99,12 @@ dependencies { kapt "com.google.dagger:dagger-android-processor:$dagger_version" kapt "com.google.dagger:dagger-compiler:$dagger_version" + // Navigation + implementation "androidx.navigation:navigation-fragment:$nav_version" + implementation "androidx.navigation:navigation-ui:$nav_version" + implementation "androidx.navigation:navigation-fragment-ktx:$nav_version" + implementation "androidx.navigation:navigation-ui-ktx:$nav_version" + testImplementation 'junit:junit:4.13' testImplementation "org.mockito:mockito-core:2.8.47" testImplementation "org.powermock:powermock-api-mockito2:$powermockVersion" 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 e5795b0b90..95103a4003 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,8 +7,8 @@ import dagger.Module import dagger.Provides import dagger.android.ContributesAndroidInjector import dagger.multibindings.IntoMap -import info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard2.WizardFragment1 -import info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard2.WizardViewModel1 +import info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard2.fragment.WizardFragment1 +import info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard2.viewmodel.WizardViewModel1 import javax.inject.Provider @Module 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 ed90d287ae..ab4132e940 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,6 +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.utils.FabricPrivacy import info.nightscout.androidaps.utils.alertDialogs.OKDialog import info.nightscout.androidaps.utils.extensions.plusAssign @@ -56,6 +57,11 @@ class PodManagementActivity : NoSplashAppCompatActivity() { initPodAction() } + initpod_init_pod_new.setOnClickListener { + val myIntent = Intent(this@PodManagementActivity, WizardActivity::class.java) + this@PodManagementActivity.startActivity(myIntent) + } + initpod_remove_pod.setOnClickListener { deactivatePodAction() } 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 index da6611dbb1..48986c0c02 100644 --- 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 @@ -8,6 +8,6 @@ class WizardActivity : NoSplashAppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - setContentView(R.layout.omnipod_wizard_activity) // TODO: replace with DataBindingUtil.setContentView + 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/WizardFragment1.kt b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard2/fragment/WizardFragment1.kt similarity index 77% rename from omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard2/WizardFragment1.kt rename to omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard2/fragment/WizardFragment1.kt index c272740a5a..0422ca30a4 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard2/WizardFragment1.kt +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/wizard2/fragment/WizardFragment1.kt @@ -1,16 +1,15 @@ -package info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard2 +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 androidx.fragment.app.viewModels -import androidx.lifecycle.ViewModel import androidx.lifecycle.ViewModelProvider import dagger.android.support.DaggerFragment 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.wizard2.viewmodel.WizardViewModel1 import javax.inject.Inject class WizardFragment1 : DaggerFragment() { @@ -33,13 +32,13 @@ class WizardFragment1 : DaggerFragment() { inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? - ): View? = inflater.inflate(R.layout.omnipod_wizard_fragment1, container, false) + ): View? = inflater.inflate(R.layout.omnipod_replace_pod_wizard_info_page_fragment, container, false) override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) - view.findViewById