Skip to content

Commit

Permalink
Release-v2.8.2 package
Browse files Browse the repository at this point in the history
  • Loading branch information
SaravanKumarMS committed May 3, 2024
1 parent bf4a552 commit 1023f4f
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 14 deletions.
4 changes: 2 additions & 2 deletions mobile/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@ 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 {
CONNECTING, READING_DEVICE_STATE
}

private var connectionStatusModalDialog: ProgressDialogWithSpinner? = null
private var isDialogVisible = false // Custom flag for dialog visibility

@JvmOverloads
fun showModalDialog(
Expand All @@ -39,6 +41,7 @@ abstract class BaseActivity : AppCompatActivity() {

if (!this@BaseActivity.isFinishing) {
connectionStatusModalDialog?.show(supportFragmentManager, null)
isDialogVisible = true
}
}
}
Expand All @@ -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")
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
@@ -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?) :
Expand Down Expand Up @@ -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
}
}
3 changes: 2 additions & 1 deletion mobile/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1148,7 +1148,7 @@
<string name="matter_validation_manual_qrcode">Enter valid QR Code</string>
<string name="matter_occupancy_sensor_action">Press and Hold to detect the occupancy” and release the button to undetect the occupancy</string>
<string name="ssid_and_password_required">SSID and password required.</string>
<string name="password_must_be_between_8_to_12_characters">Password must be between 8 to 12 characters.</string>
<string name="password_must_be_min_8_characters">Password must be minimum 8 characters.</string>
<string name="add_device_subtitle">Add the device name. This is the name that will be used to reference this device.</string>
<string name="add_device_name">Add Device Name</string>
<string name="matter_scanner_info">Manual QR code payload ID:</string>
Expand All @@ -1159,4 +1159,5 @@
<string name="please_enter_valid_device_name">Please enter valid device name</string>
<string name="start_commissioning">Start Commissioning</string>
<string name="qr_code_info">QR Code info</string>
<string name="failed_to_discover_services">Failed to discover services</string>
</resources>

0 comments on commit 1023f4f

Please sign in to comment.