Add scan retry button on timeout
This commit is contained in:
parent
954264fe37
commit
7c054a7021
2 changed files with 10 additions and 0 deletions
|
|
@ -234,6 +234,8 @@ class MainActivity : AppCompatActivity() {
|
|||
}
|
||||
|
||||
private fun setupRelayButton() {
|
||||
relayButton.setOnClickListener(null)
|
||||
relayButton.text = getString(R.string.button_hold)
|
||||
relayButton.setOnTouchListener { _, event ->
|
||||
when (event.action) {
|
||||
MotionEvent.ACTION_DOWN -> {
|
||||
|
|
@ -293,6 +295,13 @@ class MainActivity : AppCompatActivity() {
|
|||
adapter?.bluetoothLeScanner?.stopScan(scanCallback)
|
||||
if (scanTimedOut) {
|
||||
statusText.text = getString(R.string.status_device_not_found)
|
||||
relayButton.setOnTouchListener(null)
|
||||
relayButton.text = getString(R.string.button_retry_scan)
|
||||
relayButton.isEnabled = true
|
||||
relayButton.setOnClickListener {
|
||||
setupRelayButton()
|
||||
startScan()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@
|
|||
<string name="status_bluetooth_disabled">Bluetooth not enabled</string>
|
||||
<string name="status_scanning">Scanning…</string>
|
||||
<string name="status_device_not_found">Device not found</string>
|
||||
<string name="button_retry_scan">Opnieuw scannen</string>
|
||||
|
||||
<!-- MainActivity UI -->
|
||||
<string name="button_on">ON</string>
|
||||
|
|
|
|||
Loading…
Reference in a new issue