diff --git a/pump/omnipod-common/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/common/ui/wizard/activation/PodActivationWizardActivity.kt b/pump/omnipod-common/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/common/ui/wizard/activation/PodActivationWizardActivity.kt index b069fb2437..c314840347 100644 --- a/pump/omnipod-common/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/common/ui/wizard/activation/PodActivationWizardActivity.kt +++ b/pump/omnipod-common/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/common/ui/wizard/activation/PodActivationWizardActivity.kt @@ -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 diff --git a/pump/omnipod-common/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/common/ui/wizard/common/activity/OmnipodWizardActivityBase.kt b/pump/omnipod-common/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/common/ui/wizard/common/activity/OmnipodWizardActivityBase.kt index 1399ad58a8..0a2b90971e 100644 --- a/pump/omnipod-common/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/common/ui/wizard/common/activity/OmnipodWizardActivityBase.kt +++ b/pump/omnipod-common/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/common/ui/wizard/common/activity/OmnipodWizardActivityBase.kt @@ -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() { diff --git a/pump/omnipod-common/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/common/ui/wizard/common/fragment/ActionFragmentBase.kt b/pump/omnipod-common/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/common/ui/wizard/common/fragment/ActionFragmentBase.kt index 7f2d426fff..bad933b22f 100644 --- a/pump/omnipod-common/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/common/ui/wizard/common/fragment/ActionFragmentBase.kt +++ b/pump/omnipod-common/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/common/ui/wizard/common/fragment/ActionFragmentBase.kt @@ -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