diff --git a/mobile/build.gradle.kts b/mobile/build.gradle.kts
index 672fd9e5..5ddba351 100644
--- a/mobile/build.gradle.kts
+++ b/mobile/build.gradle.kts
@@ -57,8 +57,8 @@ android {
create("blueGecko") {
dimension = versionDim
applicationId = "com.siliconlabs.bledemo"
- versionCode = 47
- versionName = "2.8.1"
+ versionCode = 48
+ versionName = "2.8.2"
}
}
diff --git a/mobile/src/main/java/com/siliconlabs/bledemo/Base/activities/BaseActivity.kt b/mobile/src/main/java/com/siliconlabs/bledemo/Base/activities/BaseActivity.kt
index c87d09eb..087d3335 100644
--- a/mobile/src/main/java/com/siliconlabs/bledemo/Base/activities/BaseActivity.kt
+++ b/mobile/src/main/java/com/siliconlabs/bledemo/Base/activities/BaseActivity.kt
@@ -8,6 +8,7 @@ import androidx.annotation.StringRes
import androidx.appcompat.app.AppCompatActivity
import com.siliconlabs.bledemo.R
import com.siliconlabs.bledemo.base.dialogs.ProgressDialogWithSpinner
+import timber.log.Timber
abstract class BaseActivity : AppCompatActivity() {
enum class ConnectionStatus {
@@ -15,6 +16,7 @@ abstract class BaseActivity : AppCompatActivity() {
}
private var connectionStatusModalDialog: ProgressDialogWithSpinner? = null
+ private var isDialogVisible = false // Custom flag for dialog visibility
@JvmOverloads
fun showModalDialog(
@@ -39,6 +41,7 @@ abstract class BaseActivity : AppCompatActivity() {
if (!this@BaseActivity.isFinishing) {
connectionStatusModalDialog?.show(supportFragmentManager, null)
+ isDialogVisible = true
}
}
}
@@ -49,9 +52,13 @@ abstract class BaseActivity : AppCompatActivity() {
fun dismissModalDialog() {
runOnUiThread {
- if (connectionStatusModalDialog != null && connectionStatusModalDialog?.isVisible!!) {
+ if (isDialogVisible) {
+ Timber.e("Attempting to dismiss the dialog")
connectionStatusModalDialog?.dismiss()
connectionStatusModalDialog = null
+ isDialogVisible = false // Update the visibility flag after dismissing
+ } else {
+ Timber.e("Dialog is not visible, cannot dismiss")
}
}
}
diff --git a/mobile/src/main/java/com/siliconlabs/bledemo/features/demo/matter_demo/fragments/MatterWifiInputDialogFragment.kt b/mobile/src/main/java/com/siliconlabs/bledemo/features/demo/matter_demo/fragments/MatterWifiInputDialogFragment.kt
index 3f5f5cde..46f6ce5f 100644
--- a/mobile/src/main/java/com/siliconlabs/bledemo/features/demo/matter_demo/fragments/MatterWifiInputDialogFragment.kt
+++ b/mobile/src/main/java/com/siliconlabs/bledemo/features/demo/matter_demo/fragments/MatterWifiInputDialogFragment.kt
@@ -73,7 +73,7 @@ class MatterWifiInputDialogFragment : DialogFragment() {
}
if (!FragmentUtils.isPasswordValid(wifiPassword)) {
Toast.makeText(requireContext(),
- getString(R.string.password_must_be_between_8_to_12_characters), Toast.LENGTH_SHORT)
+ getString(R.string.password_must_be_min_8_characters), Toast.LENGTH_SHORT)
.show()
return@setOnClickListener
}
diff --git a/mobile/src/main/java/com/siliconlabs/bledemo/features/demo/matter_demo/utils/FragmentUtils.kt b/mobile/src/main/java/com/siliconlabs/bledemo/features/demo/matter_demo/utils/FragmentUtils.kt
index 77196261..edec7178 100644
--- a/mobile/src/main/java/com/siliconlabs/bledemo/features/demo/matter_demo/utils/FragmentUtils.kt
+++ b/mobile/src/main/java/com/siliconlabs/bledemo/features/demo/matter_demo/utils/FragmentUtils.kt
@@ -28,7 +28,7 @@ object FragmentUtils {
}
fun isPasswordValid(password: String?): Boolean {
val minLength = 8
- val maxLength = 12
+ val maxLength = 100
return password != null && password.length >= minLength && password.length <= maxLength
}
diff --git a/mobile/src/main/java/com/siliconlabs/bledemo/home_screen/dialogs/SelectDeviceDialog.kt b/mobile/src/main/java/com/siliconlabs/bledemo/home_screen/dialogs/SelectDeviceDialog.kt
index fcb9af63..e44bb917 100644
--- a/mobile/src/main/java/com/siliconlabs/bledemo/home_screen/dialogs/SelectDeviceDialog.kt
+++ b/mobile/src/main/java/com/siliconlabs/bledemo/home_screen/dialogs/SelectDeviceDialog.kt
@@ -166,7 +166,12 @@ class SelectDeviceDialog(
private fun setReadingDialogMsgAndDiscoverServices(gatt: BluetoothGatt) {
(activity as MainActivity).setModalDialogMessage(R.string.reading_board_type)
- gatt.discoverServices()
+ val success = gatt.discoverServices()
+ if (!success) {
+ // Handle unsuccessful service discovery
+ showMessage(R.string.failed_to_discover_services)
+ (activity as MainActivity).dismissModalDialog()
+ }
}
private fun launchDemo(boardType: String? = null, powerSource: Int? = null) {
diff --git a/mobile/src/main/java/com/siliconlabs/bledemo/home_screen/views/BluetoothEnableBar.kt b/mobile/src/main/java/com/siliconlabs/bledemo/home_screen/views/BluetoothEnableBar.kt
index 6f1f738d..d6ea833f 100644
--- a/mobile/src/main/java/com/siliconlabs/bledemo/home_screen/views/BluetoothEnableBar.kt
+++ b/mobile/src/main/java/com/siliconlabs/bledemo/home_screen/views/BluetoothEnableBar.kt
@@ -1,15 +1,13 @@
package com.siliconlabs.bledemo.home_screen.views
import android.annotation.SuppressLint
-import android.app.Activity
import android.bluetooth.BluetoothAdapter
import android.content.Context
import android.content.Intent
-import android.provider.Settings
+import android.os.Handler
+import android.os.Looper
import android.util.AttributeSet
import android.view.View
-import androidx.activity.result.ActivityResultLauncher
-import androidx.activity.result.contract.ActivityResultContracts
import com.siliconlabs.bledemo.R
class BluetoothEnableBar(context: Context, attrs: AttributeSet?) :
@@ -44,10 +42,32 @@ class BluetoothEnableBar(context: Context, attrs: AttributeSet?) :
BluetoothAdapter.getDefaultAdapter().enable()
_binding.apply {
context.startActivity(Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE))
- warningBarMessage.text = context.getString(R.string.bluetooth_adapter_bar_turning_on)
- warningBarActionButton.visibility = View.GONE
+ val bluetoothAdapter = BluetoothAdapter.getDefaultAdapter()
+ // Add a delay to check if Bluetooth is on after enabling
+ Handler(Looper.getMainLooper()).postDelayed({
+ warningBarMessage.text =
+ context.getString(R.string.bluetooth_adapter_bar_turning_on)
+ if (bluetoothAdapter.isEnabled) {
+ // Bluetooth is on
+ // Display message or perform actions here
+ _binding.apply {
+ warningBarMessage.text = context.getString(R.string.toast_bluetooth_enabled)
+ warningBarActionButton.visibility = View.GONE
+ }
+ } else {
+ // Bluetooth is still off
+ // Display message or perform actions here
+ _binding.apply {
+ warningBarMessage.text =
+ context.getString(R.string.bluetooth_adapter_bar_disabled)
+ warningBarActionButton.visibility = View.VISIBLE
+ }
+ }
+ }, DELAY_CHECK_BLUETOOTH)
}
}
-
+ companion object {
+ private const val DELAY_CHECK_BLUETOOTH = 5000L
+ }
}
\ No newline at end of file
diff --git a/mobile/src/main/res/values/strings.xml b/mobile/src/main/res/values/strings.xml
index 36ffa850..a8a4e784 100644
--- a/mobile/src/main/res/values/strings.xml
+++ b/mobile/src/main/res/values/strings.xml
@@ -1148,7 +1148,7 @@
Enter valid QR Code
Press and Hold to detect the occupancyā€¯ and release the button to undetect the occupancy
SSID and password required.
- Password must be between 8 to 12 characters.
+ Password must be minimum 8 characters.
Add the device name. This is the name that will be used to reference this device.
Add Device Name
Manual QR code payload ID:
@@ -1159,4 +1159,5 @@
Please enter valid device name
Start Commissioning
QR Code info
+ Failed to discover services