Omnipod activation, deactivation: toolbar
This commit is contained in:
parent
5746f4fe0d
commit
ac3015bc86
6 changed files with 39 additions and 13 deletions
|
@ -26,6 +26,10 @@ abstract class PodActivationWizardActivity : OmnipodWizardActivityBase() {
|
||||||
|
|
||||||
setContentView(R.layout.omnipod_common_pod_activation_wizard_activity)
|
setContentView(R.layout.omnipod_common_pod_activation_wizard_activity)
|
||||||
|
|
||||||
|
title = getString(R.string.omnipod_common_pod_management_button_activate_pod)
|
||||||
|
supportActionBar?.setDisplayHomeAsUpEnabled(true)
|
||||||
|
supportActionBar?.setDisplayShowHomeEnabled(true)
|
||||||
|
|
||||||
startDestination = savedInstanceState?.getInt(KEY_START_DESTINATION, R.id.startPodActivationFragment)
|
startDestination = savedInstanceState?.getInt(KEY_START_DESTINATION, R.id.startPodActivationFragment)
|
||||||
?: if (intent.safeGetSerializableExtra(KEY_TYPE, Type::class.java) == Type.LONG) {
|
?: if (intent.safeGetSerializableExtra(KEY_TYPE, Type::class.java) == Type.LONG) {
|
||||||
R.id.startPodActivationFragment
|
R.id.startPodActivationFragment
|
||||||
|
|
|
@ -1,9 +1,12 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.omnipod.common.ui.wizard.common.activity
|
package info.nightscout.androidaps.plugins.pump.omnipod.common.ui.wizard.common.activity
|
||||||
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.os.PersistableBundle
|
import android.view.Menu
|
||||||
|
import android.view.MenuInflater
|
||||||
|
import android.view.MenuItem
|
||||||
import androidx.activity.OnBackPressedCallback
|
import androidx.activity.OnBackPressedCallback
|
||||||
import androidx.appcompat.app.AlertDialog
|
import androidx.appcompat.app.AlertDialog
|
||||||
|
import androidx.core.view.MenuProvider
|
||||||
import androidx.navigation.NavController
|
import androidx.navigation.NavController
|
||||||
import androidx.navigation.fragment.NavHostFragment
|
import androidx.navigation.fragment.NavHostFragment
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.common.R
|
import info.nightscout.androidaps.plugins.pump.omnipod.common.R
|
||||||
|
@ -11,13 +14,27 @@ import info.nightscout.core.ui.activities.TranslatedDaggerAppCompatActivity
|
||||||
|
|
||||||
abstract class OmnipodWizardActivityBase : TranslatedDaggerAppCompatActivity() {
|
abstract class OmnipodWizardActivityBase : TranslatedDaggerAppCompatActivity() {
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?, persistentState: PersistableBundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState, persistentState)
|
super.onCreate(savedInstanceState)
|
||||||
onBackPressedDispatcher.addCallback(this, object : OnBackPressedCallback(true) {
|
onBackPressedDispatcher.addCallback(this, object : OnBackPressedCallback(true) {
|
||||||
override fun handleOnBackPressed() {
|
override fun handleOnBackPressed() {
|
||||||
exitActivityAfterConfirmation()
|
exitActivityAfterConfirmation()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
// Add menu items without overriding methods in the Activity
|
||||||
|
addMenuProvider(object : MenuProvider {
|
||||||
|
override fun onCreateMenu(menu: Menu, menuInflater: MenuInflater) {}
|
||||||
|
|
||||||
|
override fun onMenuItemSelected(menuItem: MenuItem): Boolean =
|
||||||
|
when (menuItem.itemId) {
|
||||||
|
android.R.id.home -> {
|
||||||
|
onBackPressedDispatcher.onBackPressed()
|
||||||
|
true
|
||||||
|
}
|
||||||
|
|
||||||
|
else -> false
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fun exitActivityAfterConfirmation() {
|
fun exitActivityAfterConfirmation() {
|
||||||
|
|
|
@ -14,7 +14,7 @@ import info.nightscout.shared.extensions.toVisibility
|
||||||
|
|
||||||
abstract class ActionFragmentBase : WizardFragmentBase() {
|
abstract class ActionFragmentBase : WizardFragmentBase() {
|
||||||
|
|
||||||
val actionViewModel: ActionViewModelBase
|
private val actionViewModel: ActionViewModelBase
|
||||||
get() = viewModel as ActionViewModelBase
|
get() = viewModel as ActionViewModelBase
|
||||||
|
|
||||||
@SuppressLint("CutPasteId")
|
@SuppressLint("CutPasteId")
|
||||||
|
@ -27,7 +27,7 @@ abstract class ActionFragmentBase : WizardFragmentBase() {
|
||||||
view.findViewById<Button>(R.id.omnipod_wizard_button_retry)
|
view.findViewById<Button>(R.id.omnipod_wizard_button_retry)
|
||||||
.setOnClickListener { actionViewModel.executeAction() }
|
.setOnClickListener { actionViewModel.executeAction() }
|
||||||
|
|
||||||
actionViewModel.isActionExecutingLiveData.observe(viewLifecycleOwner, { isExecuting ->
|
actionViewModel.isActionExecutingLiveData.observe(viewLifecycleOwner) { isExecuting ->
|
||||||
if (isExecuting) {
|
if (isExecuting) {
|
||||||
view.findViewById<TextView>(R.id.omnipod_wizard_action_error).visibility = View.GONE
|
view.findViewById<TextView>(R.id.omnipod_wizard_action_error).visibility = View.GONE
|
||||||
view.findViewById<Button>(R.id.omnipod_wizard_button_deactivate_pod).visibility = View.GONE
|
view.findViewById<Button>(R.id.omnipod_wizard_button_deactivate_pod).visibility = View.GONE
|
||||||
|
@ -37,9 +37,9 @@ abstract class ActionFragmentBase : WizardFragmentBase() {
|
||||||
view.findViewById<ProgressBar>(R.id.omnipod_wizard_action_progress_indication).visibility =
|
view.findViewById<ProgressBar>(R.id.omnipod_wizard_action_progress_indication).visibility =
|
||||||
isExecuting.toVisibility()
|
isExecuting.toVisibility()
|
||||||
view.findViewById<Button>(R.id.button_cancel).isEnabled = !isExecuting
|
view.findViewById<Button>(R.id.button_cancel).isEnabled = !isExecuting
|
||||||
})
|
}
|
||||||
|
|
||||||
actionViewModel.actionResultLiveData.observe(viewLifecycleOwner, { result ->
|
actionViewModel.actionResultLiveData.observe(viewLifecycleOwner) { result ->
|
||||||
result?.let {
|
result?.let {
|
||||||
val isExecuting = isActionExecuting()
|
val isExecuting = isActionExecuting()
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ abstract class ActionFragmentBase : WizardFragmentBase() {
|
||||||
onFailure()
|
onFailure()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
|
|
||||||
if (savedInstanceState == null && !isActionExecuting()) {
|
if (savedInstanceState == null && !isActionExecuting()) {
|
||||||
actionViewModel.executeAction()
|
actionViewModel.executeAction()
|
||||||
|
@ -64,7 +64,7 @@ abstract class ActionFragmentBase : WizardFragmentBase() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected fun isActionExecuting() = actionViewModel.isActionExecutingLiveData.value!!
|
private fun isActionExecuting() = actionViewModel.isActionExecutingLiveData.value!!
|
||||||
|
|
||||||
override fun onDestroyView() {
|
override fun onDestroyView() {
|
||||||
super.onDestroyView()
|
super.onDestroyView()
|
||||||
|
|
|
@ -10,6 +10,11 @@ abstract class PodDeactivationWizardActivity : OmnipodWizardActivityBase() {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
|
|
||||||
setContentView(R.layout.omnipod_common_pod_deactivation_wizard_activity)
|
setContentView(R.layout.omnipod_common_pod_deactivation_wizard_activity)
|
||||||
|
|
||||||
|
title = getString(R.string.omnipod_common_pod_management_button_deactivate_pod)
|
||||||
|
supportActionBar?.setDisplayHomeAsUpEnabled(true)
|
||||||
|
supportActionBar?.setDisplayShowHomeEnabled(true)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getTotalDefinedNumberOfSteps(): Int = 3
|
override fun getTotalDefinedNumberOfSteps(): Int = 3
|
||||||
|
|
|
@ -11,11 +11,11 @@
|
||||||
<activity
|
<activity
|
||||||
android:name=".ui.wizard.activation.DashPodActivationWizardActivity"
|
android:name=".ui.wizard.activation.DashPodActivationWizardActivity"
|
||||||
android:exported="false"
|
android:exported="false"
|
||||||
android:theme="@style/AppTheme.NoActionBar" />
|
android:theme="@style/AppTheme" />
|
||||||
<activity
|
<activity
|
||||||
android:name=".ui.wizard.deactivation.DashPodDeactivationWizardActivity"
|
android:name=".ui.wizard.deactivation.DashPodDeactivationWizardActivity"
|
||||||
android:exported="false"
|
android:exported="false"
|
||||||
android:theme="@style/AppTheme.NoActionBar" />
|
android:theme="@style/AppTheme" />
|
||||||
<activity
|
<activity
|
||||||
android:name=".ui.DashPodManagementActivity"
|
android:name=".ui.DashPodManagementActivity"
|
||||||
android:exported="false"
|
android:exported="false"
|
||||||
|
|
|
@ -9,11 +9,11 @@
|
||||||
<activity
|
<activity
|
||||||
android:name=".ui.wizard.activation.ErosPodActivationWizardActivity"
|
android:name=".ui.wizard.activation.ErosPodActivationWizardActivity"
|
||||||
android:exported="false"
|
android:exported="false"
|
||||||
android:theme="@style/AppTheme.NoActionBar" />
|
android:theme="@style/AppTheme" />
|
||||||
<activity
|
<activity
|
||||||
android:name=".ui.wizard.deactivation.ErosPodDeactivationWizardActivity"
|
android:name=".ui.wizard.deactivation.ErosPodDeactivationWizardActivity"
|
||||||
android:exported="false"
|
android:exported="false"
|
||||||
android:theme="@style/AppTheme.NoActionBar" />
|
android:theme="@style/AppTheme" />
|
||||||
<activity
|
<activity
|
||||||
android:name=".ui.ErosPodManagementActivity"
|
android:name=".ui.ErosPodManagementActivity"
|
||||||
android:exported="false"
|
android:exported="false"
|
||||||
|
|
Loading…
Reference in a new issue