WIP on adding navigation between Omnipod fragments in replace Pod wizard

This commit is contained in:
Bart Sopers 2020-09-26 19:29:28 +02:00
parent ee9079fdcf
commit ca4d809f41
26 changed files with 263 additions and 46 deletions

View file

@ -354,6 +354,12 @@ dependencies {
androidTestImplementation 'androidx.test.uiautomator:uiautomator:2.2.0' 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 //WorkManager
implementation 'androidx.work:work-runtime:2.3.4' implementation 'androidx.work:work-runtime:2.3.4'
implementation 'androidx.work:work-runtime-ktx:2.3.4' implementation 'androidx.work:work-runtime-ktx:2.3.4'

View file

@ -13,7 +13,8 @@ buildscript {
coroutinesVersion = '1.3.7' coroutinesVersion = '1.3.7'
activityVersion = '1.2.0-alpha06' activityVersion = '1.2.0-alpha06'
fragmentVersion = '1.3.0-alpha07' fragmentVersion = '1.3.0-alpha07'
ormLiteVersion = "4.46" ormLiteVersion = '4.46'
nav_version = '2.3.0'
} }
repositories { repositories {
google() google()

View file

@ -75,6 +75,7 @@ dependencies {
implementation 'androidx.core:core-ktx:1.2.0' implementation 'androidx.core:core-ktx:1.2.0'
implementation "androidx.preference:preference-ktx:1.1.1" implementation "androidx.preference:preference-ktx:1.1.1"
implementation "androidx.activity:activity-ktx:${activityVersion}" implementation "androidx.activity:activity-ktx:${activityVersion}"
implementation "androidx.fragment:fragment:${fragmentVersion}"
implementation 'com.google.android.material:material:1.1.0' implementation 'com.google.android.material:material:1.1.0'
implementation 'com.google.firebase:firebase-analytics-ktx:17.4.3' 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" implementation "com.joanzapata.iconify:android-iconify-fontawesome:2.2.2"
// Omnipod - start
implementation 'org.apache.commons:commons-lang3:3.10' implementation 'org.apache.commons:commons-lang3:3.10'
implementation 'net.danlew:android.joda:2.10.6' implementation 'net.danlew:android.joda:2.10.6'
implementation "com.google.code.gson:gson:2.8.6" implementation "com.google.code.gson:gson:2.8.6"
implementation(name: "com.atech-software.android.library.wizardpager-1.1.4", ext: "aar") 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:$dagger_version"
implementation "com.google.dagger:dagger-android-support:$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-android-processor:$dagger_version"
kapt "com.google.dagger:dagger-compiler:$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 'junit:junit:4.13'
testImplementation "org.mockito:mockito-core:2.8.47" testImplementation "org.mockito:mockito-core:2.8.47"
testImplementation "org.powermock:powermock-api-mockito2:$powermockVersion" testImplementation "org.powermock:powermock-api-mockito2:$powermockVersion"

View file

@ -7,8 +7,8 @@ import dagger.Module
import dagger.Provides import dagger.Provides
import dagger.android.ContributesAndroidInjector import dagger.android.ContributesAndroidInjector
import dagger.multibindings.IntoMap import dagger.multibindings.IntoMap
import info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard2.WizardFragment1 import info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard2.fragment.WizardFragment1
import info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard2.WizardViewModel1 import info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard2.viewmodel.WizardViewModel1
import javax.inject.Provider import javax.inject.Provider
@Module @Module

View file

@ -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.FullInitPodWizardModel
import info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.model.RemovePodWizardModel 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.wizard.model.ShortInitPodWizardModel
import info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard2.WizardActivity
import info.nightscout.androidaps.utils.FabricPrivacy import info.nightscout.androidaps.utils.FabricPrivacy
import info.nightscout.androidaps.utils.alertDialogs.OKDialog import info.nightscout.androidaps.utils.alertDialogs.OKDialog
import info.nightscout.androidaps.utils.extensions.plusAssign import info.nightscout.androidaps.utils.extensions.plusAssign
@ -56,6 +57,11 @@ class PodManagementActivity : NoSplashAppCompatActivity() {
initPodAction() initPodAction()
} }
initpod_init_pod_new.setOnClickListener {
val myIntent = Intent(this@PodManagementActivity, WizardActivity::class.java)
this@PodManagementActivity.startActivity(myIntent)
}
initpod_remove_pod.setOnClickListener { initpod_remove_pod.setOnClickListener {
deactivatePodAction() deactivatePodAction()
} }

View file

@ -8,6 +8,6 @@ class WizardActivity : NoSplashAppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) 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
} }
} }

View file

@ -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.os.Bundle
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.Button
import androidx.fragment.app.viewModels import androidx.fragment.app.viewModels
import androidx.lifecycle.ViewModel
import androidx.lifecycle.ViewModelProvider import androidx.lifecycle.ViewModelProvider
import dagger.android.support.DaggerFragment import dagger.android.support.DaggerFragment
import info.nightscout.androidaps.plugins.pump.omnipod.R import info.nightscout.androidaps.plugins.pump.omnipod.R
import info.nightscout.androidaps.plugins.pump.omnipod.dagger.OmnipodPluginQualifier import info.nightscout.androidaps.plugins.pump.omnipod.dagger.OmnipodPluginQualifier
import info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard2.viewmodel.WizardViewModel1
import javax.inject.Inject import javax.inject.Inject
class WizardFragment1 : DaggerFragment() { class WizardFragment1 : DaggerFragment() {
@ -33,13 +32,13 @@ class WizardFragment1 : DaggerFragment() {
inflater: LayoutInflater, inflater: LayoutInflater,
container: ViewGroup?, container: ViewGroup?,
savedInstanceState: Bundle? 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?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
view.findViewById<Button>(R.id.test_button)?.setOnClickListener { //view.findViewById<Button>(R.id.test_button)?.setOnClickListener {
viewModel.onButtonPressedForTesting() // viewModel.onButtonPressedForTesting()
} //}
} }
} }

View file

@ -0,0 +1,25 @@
package info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard2.fragment.action
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import dagger.android.support.DaggerFragment
import info.nightscout.androidaps.plugins.pump.omnipod.R
abstract class ActionFragmentBase : DaggerFragment() {
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? = inflater.inflate(R.layout.omnipod_replace_pod_wizard_action_page_fragment, container, false)
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
view.findViewById<TextView>(R.id.omnipod_wizard_action_page_text)?.text = getText()
}
abstract fun getText(): String
}

View file

@ -0,0 +1,5 @@
package info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard2.fragment.action
class DeactivatePodActionFragment : ActionFragmentBase() {
override fun getText(): String = "[deactivate Pod]"
}

View file

@ -0,0 +1,5 @@
package info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard2.fragment.action
class InsertCannulaActionFragment : ActionFragmentBase() {
override fun getText(): String = "[insert cannula]"
}

View file

@ -0,0 +1,5 @@
package info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard2.fragment.action
class PairAndPrimePodActionFragment : ActionFragmentBase() {
override fun getText(): String = "[pair and prime Pod]"
}

View file

@ -0,0 +1,5 @@
package info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard2.fragment.info
class AttachPodInfoFragment : InfoFragmentBase() {
override fun getText(): String = "Attach the Pod"
}

View file

@ -0,0 +1,5 @@
package info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard2.fragment.info
class DeactivatePodInfoFragment : InfoFragmentBase() {
override fun getText(): String = "Deactivate the Pod"
}

View file

@ -0,0 +1,5 @@
package info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard2.fragment.info
class FillPodInfoFragment : InfoFragmentBase() {
override fun getText(): String = "Fill the Pod"
}

View file

@ -0,0 +1,26 @@
package info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard2.fragment.info;
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import dagger.android.support.DaggerFragment
import info.nightscout.androidaps.plugins.pump.omnipod.R
abstract class InfoFragmentBase : DaggerFragment() {
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): 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<TextView>(R.id.omnipod_wizard_info_page_text)?.text = getText();
}
abstract fun getText(): String
}

View file

@ -0,0 +1,5 @@
package info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard2.fragment.info
class PodDeactivatedInfoFragment : InfoFragmentBase() {
override fun getText(): String = "Pod has been deactivated"
}

View file

@ -0,0 +1,5 @@
package info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard2.fragment.info
class PodReplacedInfoFragment : InfoFragmentBase() {
override fun getText(): String = "the Pod has been replaced"
}

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard2 package info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard2.viewmodel
import androidx.lifecycle.ViewModel import androidx.lifecycle.ViewModel
import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.AAPSLogger

View file

@ -15,7 +15,6 @@
android:orientation="vertical"> android:orientation="vertical">
<TextView <TextView
android:id="@+id/initpod_space0"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="120dp" android:layout_height="120dp"
android:layout_marginLeft="10dp" android:layout_marginLeft="10dp"
@ -73,7 +72,26 @@
android:textAllCaps="false" /> android:textAllCaps="false" />
<TextView <TextView
android:id="@+id/initpod_space1" android:layout_width="match_parent"
android:layout_height="20dp"
android:layout_weight="0.5"
android:text="" />
<info.nightscout.androidaps.utils.ui.SingleClickButton
android:id="@+id/initpod_init_pod_new"
style="?android:attr/buttonStyle"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="40dp"
android:layout_marginTop="3dp"
android:layout_marginRight="40dp"
android:layout_marginBottom="3dp"
android:layout_weight="0.5"
android:drawableTop="@drawable/ic_cp_pump_canula"
android:text="@string/omnipod_button_replace_pod"
android:textAllCaps="false" />
<TextView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="20dp" android:layout_height="20dp"
android:layout_weight="0.5" android:layout_weight="0.5"
@ -94,7 +112,6 @@
android:textAllCaps="false" /> android:textAllCaps="false" />
<TextView <TextView
android:id="@+id/initpod_space2"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="20dp" android:layout_height="20dp"
android:layout_weight="0.5" android:layout_weight="0.5"
@ -115,7 +132,6 @@
android:textAllCaps="false" /> android:textAllCaps="false" />
<TextView <TextView
android:id="@+id/initpod_space3"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="20dp" android:layout_height="20dp"
android:layout_weight="0.5" android:layout_weight="0.5"

View file

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ScrollView
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:id="@+id/omnipod_wizard_action_page_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</ScrollView>
</LinearLayout>

View file

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<FragmentContainerView
android:id="@+id/nav_host_fragment"
android:name="androidx.navigation.fragment.NavHostFragment"
android:layout_width="0dp"
android:layout_height="0dp"
app:defaultNavHost="true"
app:navGraph="@navigation/omnipod_replace_pod_wizard_navigation_graph"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</LinearLayout>

View file

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ScrollView
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:id="@+id/omnipod_wizard_info_page_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</ScrollView>
</LinearLayout>

View file

@ -1,14 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<!-- TODO: replace with nav host fragment (or FragmentContainerView) -->
<fragment
android:id="@+id/test_fragment"
android:name="info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard2.WizardFragment1"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>

View file

@ -1,14 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<!-- TODO: replace with something useful -->
<Button
android:id="@+id/test_button"
android:text="Test test"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>

View file

@ -0,0 +1,66 @@
<?xml version="1.0" encoding="utf-8"?>
<navigation xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/omnipod_replace_pod_navigation_graph"
app:startDestination="@id/deactivatePodInfoFragment">
<fragment
android:id="@+id/deactivatePodInfoFragment"
android:name="info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard2.fragment.info.DeactivatePodInfoFragment"
android:label="DeactivatePodInfoFragment" >
<action
android:id="@+id/action_deactivatePodInfoFragment_to_deactivatePodActionFragment"
app:destination="@id/deactivatePodActionFragment" />
</fragment>
<fragment
android:id="@+id/deactivatePodActionFragment"
android:name="info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard2.fragment.action.DeactivatePodActionFragment"
android:label="DeactivatePodActionFragment" >
<action
android:id="@+id/action_deactivatePodActionFragment_to_podDeactivatedInfoFragment"
app:destination="@id/podDeactivatedInfoFragment" />
</fragment>
<fragment
android:id="@+id/podDeactivatedInfoFragment"
android:name="info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard2.fragment.info.PodDeactivatedInfoFragment"
android:label="PodDeactivatedInfoFragment" >
<action
android:id="@+id/action_podDeactivatedInfoFragment_to_fillPodInfoFragment"
app:destination="@id/fillPodInfoFragment" />
</fragment>
<fragment
android:id="@+id/fillPodInfoFragment"
android:name="info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard2.fragment.info.FillPodInfoFragment"
android:label="FillPodInfoFragment" >
<action
android:id="@+id/action_fillPodInfoFragment_to_pairAndPrimePodActionFragment"
app:destination="@id/pairAndPrimePodActionFragment" />
</fragment>
<fragment
android:id="@+id/pairAndPrimePodActionFragment"
android:name="info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard2.fragment.action.PairAndPrimePodActionFragment"
android:label="PairAndPrimePodActionFragment" >
<action
android:id="@+id/action_pairAndPrimePodActionFragment_to_attachPodInfoFragment"
app:destination="@id/attachPodInfoFragment" />
</fragment>
<fragment
android:id="@+id/attachPodInfoFragment"
android:name="info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard2.fragment.info.AttachPodInfoFragment"
android:label="AttachPodInfoFragment" >
<action
android:id="@+id/action_attachPodInfoFragment_to_insertCannulaActionFragment"
app:destination="@id/insertCannulaActionFragment" />
</fragment>
<fragment
android:id="@+id/insertCannulaActionFragment"
android:name="info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard2.fragment.action.InsertCannulaActionFragment"
android:label="InsertCannulaActionFragment" >
<action
android:id="@+id/action_insertCannulaActionFragment_to_podReplacedInfoFragment"
app:destination="@id/podReplacedInfoFragment" />
</fragment>
<fragment
android:id="@+id/podReplacedInfoFragment"
android:name="info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard2.fragment.info.PodReplacedInfoFragment"
android:label="PodReplacedInfoFragment" />
</navigation>

View file

@ -189,6 +189,7 @@
<!-- Omnipod - Buttons --> <!-- Omnipod - Buttons -->
<string name="omnipod_button_init_pod">Init Pod</string> <string name="omnipod_button_init_pod">Init Pod</string>
<string name="omnipod_button_replace_pod">Replace Pod (NEW)</string>
<string name="omnipod_button_deactivate_pod">Deactivate Pod</string> <string name="omnipod_button_deactivate_pod">Deactivate Pod</string>
<string name="omnipod_button_discard_pod">Discard Pod</string> <string name="omnipod_button_discard_pod">Discard Pod</string>
<string name="omnipod_button_set_time">Set time</string> <string name="omnipod_button_set_time">Set time</string>