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)
|
||||
|
||||
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)
|
||||
?: if (intent.safeGetSerializableExtra(KEY_TYPE, Type::class.java) == Type.LONG) {
|
||||
R.id.startPodActivationFragment
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
package info.nightscout.androidaps.plugins.pump.omnipod.common.ui.wizard.common.activity
|
||||
|
||||
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.appcompat.app.AlertDialog
|
||||
import androidx.core.view.MenuProvider
|
||||
import androidx.navigation.NavController
|
||||
import androidx.navigation.fragment.NavHostFragment
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.common.R
|
||||
|
@ -11,13 +14,27 @@ import info.nightscout.core.ui.activities.TranslatedDaggerAppCompatActivity
|
|||
|
||||
abstract class OmnipodWizardActivityBase : TranslatedDaggerAppCompatActivity() {
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?, persistentState: PersistableBundle?) {
|
||||
super.onCreate(savedInstanceState, persistentState)
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
onBackPressedDispatcher.addCallback(this, object : OnBackPressedCallback(true) {
|
||||
override fun handleOnBackPressed() {
|
||||
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() {
|
||||
|
|
|
@ -14,7 +14,7 @@ import info.nightscout.shared.extensions.toVisibility
|
|||
|
||||
abstract class ActionFragmentBase : WizardFragmentBase() {
|
||||
|
||||
val actionViewModel: ActionViewModelBase
|
||||
private val actionViewModel: ActionViewModelBase
|
||||
get() = viewModel as ActionViewModelBase
|
||||
|
||||
@SuppressLint("CutPasteId")
|
||||
|
@ -27,7 +27,7 @@ abstract class ActionFragmentBase : WizardFragmentBase() {
|
|||
view.findViewById<Button>(R.id.omnipod_wizard_button_retry)
|
||||
.setOnClickListener { actionViewModel.executeAction() }
|
||||
|
||||
actionViewModel.isActionExecutingLiveData.observe(viewLifecycleOwner, { isExecuting ->
|
||||
actionViewModel.isActionExecutingLiveData.observe(viewLifecycleOwner) { isExecuting ->
|
||||
if (isExecuting) {
|
||||
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
|
||||
|
@ -37,9 +37,9 @@ abstract class ActionFragmentBase : WizardFragmentBase() {
|
|||
view.findViewById<ProgressBar>(R.id.omnipod_wizard_action_progress_indication).visibility =
|
||||
isExecuting.toVisibility()
|
||||
view.findViewById<Button>(R.id.button_cancel).isEnabled = !isExecuting
|
||||
})
|
||||
}
|
||||
|
||||
actionViewModel.actionResultLiveData.observe(viewLifecycleOwner, { result ->
|
||||
actionViewModel.actionResultLiveData.observe(viewLifecycleOwner) { result ->
|
||||
result?.let {
|
||||
val isExecuting = isActionExecuting()
|
||||
|
||||
|
@ -56,7 +56,7 @@ abstract class ActionFragmentBase : WizardFragmentBase() {
|
|||
onFailure()
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
if (savedInstanceState == null && !isActionExecuting()) {
|
||||
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() {
|
||||
super.onDestroyView()
|
||||
|
|
|
@ -10,6 +10,11 @@ abstract class PodDeactivationWizardActivity : OmnipodWizardActivityBase() {
|
|||
super.onCreate(savedInstanceState)
|
||||
|
||||
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
|
||||
|
|
|
@ -11,11 +11,11 @@
|
|||
<activity
|
||||
android:name=".ui.wizard.activation.DashPodActivationWizardActivity"
|
||||
android:exported="false"
|
||||
android:theme="@style/AppTheme.NoActionBar" />
|
||||
android:theme="@style/AppTheme" />
|
||||
<activity
|
||||
android:name=".ui.wizard.deactivation.DashPodDeactivationWizardActivity"
|
||||
android:exported="false"
|
||||
android:theme="@style/AppTheme.NoActionBar" />
|
||||
android:theme="@style/AppTheme" />
|
||||
<activity
|
||||
android:name=".ui.DashPodManagementActivity"
|
||||
android:exported="false"
|
||||
|
|
|
@ -9,11 +9,11 @@
|
|||
<activity
|
||||
android:name=".ui.wizard.activation.ErosPodActivationWizardActivity"
|
||||
android:exported="false"
|
||||
android:theme="@style/AppTheme.NoActionBar" />
|
||||
android:theme="@style/AppTheme" />
|
||||
<activity
|
||||
android:name=".ui.wizard.deactivation.ErosPodDeactivationWizardActivity"
|
||||
android:exported="false"
|
||||
android:theme="@style/AppTheme.NoActionBar" />
|
||||
android:theme="@style/AppTheme" />
|
||||
<activity
|
||||
android:name=".ui.ErosPodManagementActivity"
|
||||
android:exported="false"
|
||||
|
|
Loading…
Reference in a new issue