From ca9cbefaa79d1b118799b549486734737ef1c09a Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Sat, 19 Aug 2023 14:29:26 +0200 Subject: [PATCH] DiaconnG8BLEScanActivity: toolbar --- pump/diaconn/src/main/AndroidManifest.xml | 2 +- .../activities/DiaconnG8BLEScanActivity.kt | 23 ++++++++++++++++ .../layout/diaconn_g8_blescanner_activity.xml | 27 ------------------- 3 files changed, 24 insertions(+), 28 deletions(-) diff --git a/pump/diaconn/src/main/AndroidManifest.xml b/pump/diaconn/src/main/AndroidManifest.xml index 78ca45b4ba..da8b4faa60 100644 --- a/pump/diaconn/src/main/AndroidManifest.xml +++ b/pump/diaconn/src/main/AndroidManifest.xml @@ -18,7 +18,7 @@ + android:theme="@style/AppTheme"> diff --git a/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/activities/DiaconnG8BLEScanActivity.kt b/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/activities/DiaconnG8BLEScanActivity.kt index 4e9b63f519..f3f3a65eae 100644 --- a/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/activities/DiaconnG8BLEScanActivity.kt +++ b/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/activities/DiaconnG8BLEScanActivity.kt @@ -18,11 +18,15 @@ import android.os.Bundle import android.os.Handler import android.os.Looper import android.os.ParcelUuid +import android.view.Menu +import android.view.MenuInflater +import android.view.MenuItem import android.view.View import android.view.ViewGroup import android.widget.BaseAdapter import android.widget.TextView import androidx.core.app.ActivityCompat +import androidx.core.view.MenuProvider import info.nightscout.core.ui.activities.TranslatedDaggerAppCompatActivity import info.nightscout.core.ui.toast.ToastUtils import info.nightscout.core.utils.extensions.safeEnable @@ -57,12 +61,31 @@ class DiaconnG8BLEScanActivity : TranslatedDaggerAppCompatActivity() { setContentView(binding.root) requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT + title = getString(R.string.diaconn_pairing) + supportActionBar?.setDisplayHomeAsUpEnabled(true) + supportActionBar?.setDisplayShowHomeEnabled(true) + blePreCheck.prerequisitesCheck(this) listAdapter = ListAdapter() binding.bleScannerListview.emptyView = binding.bleScannerNoDevice binding.bleScannerListview.adapter = listAdapter listAdapter?.notifyDataSetChanged() + + // 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 onResume() { diff --git a/pump/diaconn/src/main/res/layout/diaconn_g8_blescanner_activity.xml b/pump/diaconn/src/main/res/layout/diaconn_g8_blescanner_activity.xml index cdf85f5450..26bee39daf 100644 --- a/pump/diaconn/src/main/res/layout/diaconn_g8_blescanner_activity.xml +++ b/pump/diaconn/src/main/res/layout/diaconn_g8_blescanner_activity.xml @@ -7,33 +7,6 @@ android:orientation="vertical" tools:context=".activities.DiaconnG8BLEScanActivity"> - - - - - - - -