diff --git a/pump/omnipod-common/src/main/res/drawable/ic_pod_management_activate_pod.xml b/core/ui/src/main/res/drawable/ic_pod_activate_pod.xml similarity index 100% rename from pump/omnipod-common/src/main/res/drawable/ic_pod_management_activate_pod.xml rename to core/ui/src/main/res/drawable/ic_pod_activate_pod.xml diff --git a/pump/omnipod-common/src/main/res/drawable/ic_pod_management_deactivate_pod.xml b/core/ui/src/main/res/drawable/ic_pod_deactivate_pod.xml similarity index 100% rename from pump/omnipod-common/src/main/res/drawable/ic_pod_management_deactivate_pod.xml rename to core/ui/src/main/res/drawable/ic_pod_deactivate_pod.xml diff --git a/pump/omnipod-common/src/main/res/drawable/ic_omnipod_overview_resume_delivery.xml b/core/ui/src/main/res/drawable/ic_pod_resume_delivery.xml similarity index 100% rename from pump/omnipod-common/src/main/res/drawable/ic_omnipod_overview_resume_delivery.xml rename to core/ui/src/main/res/drawable/ic_pod_resume_delivery.xml diff --git a/pump/eopatch/src/main/AndroidManifest.xml b/pump/eopatch/src/main/AndroidManifest.xml index 9a804daffe..d5ac92560f 100644 --- a/pump/eopatch/src/main/AndroidManifest.xml +++ b/pump/eopatch/src/main/AndroidManifest.xml @@ -4,7 +4,8 @@ + android:configChanges="orientation|layoutDirection|screenLayout|density|screenSize|smallestScreenSize" + android:theme="@style/AppTheme" /> diff --git a/pump/eopatch/src/main/java/info/nightscout/androidaps/plugins/pump/eopatch/ui/EoBaseActivity.kt b/pump/eopatch/src/main/java/info/nightscout/androidaps/plugins/pump/eopatch/ui/EoBaseActivity.kt index 8602ef800e..06879a9cf7 100644 --- a/pump/eopatch/src/main/java/info/nightscout/androidaps/plugins/pump/eopatch/ui/EoBaseActivity.kt +++ b/pump/eopatch/src/main/java/info/nightscout/androidaps/plugins/pump/eopatch/ui/EoBaseActivity.kt @@ -8,7 +8,6 @@ import androidx.databinding.DataBindingUtil import androidx.databinding.ViewDataBinding import androidx.lifecycle.ViewModelProvider import info.nightscout.androidaps.plugins.pump.eopatch.dagger.EopatchPluginQualifier -import info.nightscout.core.ui.R import info.nightscout.core.ui.activities.TranslatedDaggerAppCompatActivity import info.nightscout.rx.AapsSchedulers import io.reactivex.rxjava3.disposables.CompositeDisposable @@ -16,10 +15,8 @@ import javax.inject.Inject abstract class EoBaseActivity : TranslatedDaggerAppCompatActivity(), EoBaseNavigator { - @Inject @EopatchPluginQualifier - lateinit var viewModelFactory: ViewModelProvider.Factory - + @Inject lateinit var viewModelFactory: ViewModelProvider.Factory @Inject lateinit var aapsSchedulers: AapsSchedulers protected lateinit var binding: B @@ -28,16 +25,13 @@ abstract class EoBaseActivity : TranslatedDaggerAppCompatAc protected lateinit var getResult: ActivityResultLauncher - @LayoutRes - abstract fun getLayoutId(): Int + @LayoutRes abstract fun getLayoutId(): Int override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - setTheme(R.style.AppTheme_NoActionBar) binding = DataBindingUtil.setContentView(this, getLayoutId()) binding.lifecycleOwner = this - } override fun back() { diff --git a/pump/eopatch/src/main/java/info/nightscout/androidaps/plugins/pump/eopatch/ui/EopatchActivity.kt b/pump/eopatch/src/main/java/info/nightscout/androidaps/plugins/pump/eopatch/ui/EopatchActivity.kt index f30e06a5ff..d6f1625645 100644 --- a/pump/eopatch/src/main/java/info/nightscout/androidaps/plugins/pump/eopatch/ui/EopatchActivity.kt +++ b/pump/eopatch/src/main/java/info/nightscout/androidaps/plugins/pump/eopatch/ui/EopatchActivity.kt @@ -5,9 +5,13 @@ import android.content.Context import android.content.Intent import android.content.pm.ActivityInfo import android.os.Bundle +import android.view.Menu +import android.view.MenuInflater +import android.view.MenuItem import android.view.MotionEvent import androidx.activity.OnBackPressedCallback import androidx.appcompat.app.AlertDialog +import androidx.core.view.MenuProvider import androidx.lifecycle.ViewModelProvider import info.nightscout.androidaps.plugins.pump.eopatch.R import info.nightscout.androidaps.plugins.pump.eopatch.code.EventType @@ -38,6 +42,10 @@ class EopatchActivity : EoBaseActivity() { super.onCreate(savedInstanceState) requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_LOCKED + title = getString(R.string.string_activate_patch) + supportActionBar?.setDisplayHomeAsUpEnabled(true) + supportActionBar?.setDisplayShowHomeEnabled(true) + binding.apply { viewModel = ViewModelProvider(this@EopatchActivity, viewModelFactory)[EopatchViewModel::class.java] viewModel?.apply { @@ -108,12 +116,27 @@ class EopatchActivity : EoBaseActivity() { override fun handleOnBackPressed() { binding.viewModel?.apply { when (patchStep.value) { + PatchStep.WAKE_UP, PatchStep.SAFE_DEACTIVATION -> this@EopatchActivity.finish() else -> Unit } } } }) + // 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 + } + }) } override fun onNewIntent(intent: Intent?) { diff --git a/pump/eopatch/src/main/res/layout/activity_eopatch.xml b/pump/eopatch/src/main/res/layout/activity_eopatch.xml index 178ff6982d..7011f99e76 100644 --- a/pump/eopatch/src/main/res/layout/activity_eopatch.xml +++ b/pump/eopatch/src/main/res/layout/activity_eopatch.xml @@ -17,26 +17,6 @@ android:orientation="vertical" tools:context=".ui.EopatchActivity"> - - - - - - -