BLEScanActivity: toolbar
This commit is contained in:
parent
f65c7bb517
commit
f56b25da97
3 changed files with 26 additions and 28 deletions
|
@ -9,7 +9,7 @@
|
||||||
<activity
|
<activity
|
||||||
android:name=".activities.BLEScanActivity"
|
android:name=".activities.BLEScanActivity"
|
||||||
android:exported="false"
|
android:exported="false"
|
||||||
android:theme="@style/AppTheme.NoActionBar">
|
android:theme="@style/AppTheme">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="info.nightscout.pump.danars.activities.BLEScanActivity" />
|
<action android:name="info.nightscout.pump.danars.activities.BLEScanActivity" />
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
|
|
|
@ -15,11 +15,15 @@ import android.os.Build
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.os.Handler
|
import android.os.Handler
|
||||||
import android.os.Looper
|
import android.os.Looper
|
||||||
|
import android.view.Menu
|
||||||
|
import android.view.MenuInflater
|
||||||
|
import android.view.MenuItem
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.widget.BaseAdapter
|
import android.widget.BaseAdapter
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import androidx.core.app.ActivityCompat
|
import androidx.core.app.ActivityCompat
|
||||||
|
import androidx.core.view.MenuProvider
|
||||||
import info.nightscout.core.ui.activities.TranslatedDaggerAppCompatActivity
|
import info.nightscout.core.ui.activities.TranslatedDaggerAppCompatActivity
|
||||||
import info.nightscout.core.ui.toast.ToastUtils
|
import info.nightscout.core.ui.toast.ToastUtils
|
||||||
import info.nightscout.core.utils.extensions.safeEnable
|
import info.nightscout.core.utils.extensions.safeEnable
|
||||||
|
@ -28,6 +32,7 @@ import info.nightscout.pump.danars.R
|
||||||
import info.nightscout.pump.danars.databinding.DanarsBlescannerActivityBinding
|
import info.nightscout.pump.danars.databinding.DanarsBlescannerActivityBinding
|
||||||
import info.nightscout.pump.danars.events.EventDanaRSDeviceChange
|
import info.nightscout.pump.danars.events.EventDanaRSDeviceChange
|
||||||
import info.nightscout.rx.bus.RxBus
|
import info.nightscout.rx.bus.RxBus
|
||||||
|
import info.nightscout.shared.interfaces.ResourceHelper
|
||||||
import info.nightscout.shared.sharedPreferences.SP
|
import info.nightscout.shared.sharedPreferences.SP
|
||||||
import java.util.regex.Pattern
|
import java.util.regex.Pattern
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
@ -38,6 +43,7 @@ class BLEScanActivity : TranslatedDaggerAppCompatActivity() {
|
||||||
@Inject lateinit var blePreCheck: BlePreCheck
|
@Inject lateinit var blePreCheck: BlePreCheck
|
||||||
@Inject lateinit var context: Context
|
@Inject lateinit var context: Context
|
||||||
@Inject lateinit var rxBus: RxBus
|
@Inject lateinit var rxBus: RxBus
|
||||||
|
@Inject lateinit var rh: ResourceHelper
|
||||||
|
|
||||||
private var listAdapter: ListAdapter? = null
|
private var listAdapter: ListAdapter? = null
|
||||||
private val devices = ArrayList<BluetoothDeviceItem>()
|
private val devices = ArrayList<BluetoothDeviceItem>()
|
||||||
|
@ -53,12 +59,31 @@ class BLEScanActivity : TranslatedDaggerAppCompatActivity() {
|
||||||
setContentView(binding.root)
|
setContentView(binding.root)
|
||||||
requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
|
requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
|
||||||
|
|
||||||
|
title = rh.gs(info.nightscout.pump.dana.R.string.danars_pairing)
|
||||||
|
supportActionBar?.setDisplayHomeAsUpEnabled(true)
|
||||||
|
supportActionBar?.setDisplayShowHomeEnabled(true)
|
||||||
|
|
||||||
blePreCheck.prerequisitesCheck(this)
|
blePreCheck.prerequisitesCheck(this)
|
||||||
|
|
||||||
listAdapter = ListAdapter()
|
listAdapter = ListAdapter()
|
||||||
binding.bleScannerListview.emptyView = binding.bleScannerNoDevice
|
binding.bleScannerListview.emptyView = binding.bleScannerNoDevice
|
||||||
binding.bleScannerListview.adapter = listAdapter
|
binding.bleScannerListview.adapter = listAdapter
|
||||||
listAdapter?.notifyDataSetChanged()
|
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() {
|
override fun onResume() {
|
||||||
|
|
|
@ -7,33 +7,6 @@
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
tools:context=".activities.BLEScanActivity">
|
tools:context=".activities.BLEScanActivity">
|
||||||
|
|
||||||
<RelativeLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="center"
|
|
||||||
android:background="?attr/activity_title_backgroundColor"
|
|
||||||
android:orientation="horizontal"
|
|
||||||
android:padding="5dp">
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:importantForAccessibility="no"
|
|
||||||
app:srcCompat="@drawable/ic_bluetooth_white_48dp" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_centerInParent="true"
|
|
||||||
android:layout_gravity="center"
|
|
||||||
android:layout_marginStart="10dp"
|
|
||||||
android:layout_marginEnd="10dp"
|
|
||||||
android:text="@string/danars_pairing"
|
|
||||||
android:textAlignment="center"
|
|
||||||
android:textAppearance="?android:attr/textAppearanceLarge" />
|
|
||||||
|
|
||||||
</RelativeLayout>
|
|
||||||
|
|
||||||
<ListView
|
<ListView
|
||||||
android:id="@+id/ble_scanner_listview"
|
android:id="@+id/ble_scanner_listview"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
|
Loading…
Reference in a new issue