Skip to content

Commit

Permalink
Release-v2.8.1 package
Browse files Browse the repository at this point in the history
  • Loading branch information
SaravanKumarMS committed Apr 10, 2024
1 parent e53e39b commit bf4a552
Show file tree
Hide file tree
Showing 11 changed files with 317 additions and 31 deletions.
21 changes: 18 additions & 3 deletions mobile/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ android {
compileSdk = 33
namespace = "com.siliconlabs.bledemo"


defaultConfig {
minSdk = 29
targetSdk = 33
Expand All @@ -28,6 +29,11 @@ android {
isMinifyEnabled = false
proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro")
signingConfig = signingConfigs.getByName("debug")

ndk {
abiFilters.add("armeabi-v7a")
abiFilters.add("arm64-v8a")
}
}
debug {
isDebuggable = true
Expand All @@ -51,8 +57,8 @@ android {
create("blueGecko") {
dimension = versionDim
applicationId = "com.siliconlabs.bledemo"
versionCode = 46
versionName = "2.8.0"
versionCode = 47
versionName = "2.8.1"
}
}

Expand All @@ -67,7 +73,14 @@ android {

buildFeatures {
viewBinding = true

}

// packagingOptions {
// jniLibs {
// useLegacyPackaging = true
// }
// }
}

dependencies {
Expand Down Expand Up @@ -95,7 +108,7 @@ dependencies {
implementation("io.github.g00fy2.quickie:quickie-bundled:1.7.0")

implementation("com.google.android.flexbox:flexbox:3.0.0")
implementation("com.github.PhilJay:MPAndroidChart:v3.0.3")
// implementation("com.github.PhilJay:MPAndroidChart:v3.0.3")

// Navigation
implementation("androidx.navigation:navigation-fragment-ktx:2.5.3")
Expand All @@ -104,6 +117,7 @@ dependencies {

// Dependency injection
implementation("com.google.dagger:hilt-android:2.45")
implementation(files("libs/MPAndroidChart-v3.0.1.jar"))
kapt("com.google.dagger:hilt-android-compiler:2.45")

// View binding
Expand All @@ -115,6 +129,7 @@ dependencies {
// Parsing
implementation("com.google.code.gson:gson:2.10.1")
implementation("com.opencsv:opencsv:5.6")
implementation ("androidx.activity:activity:1.6.0-alpha05")

// Only used for Int.pow() method in a couple of places
implementation("com.google.guava:guava:29.0-android")
Expand Down
Binary file added mobile/libs/MPAndroidChart-v3.0.1.jar
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -432,14 +432,14 @@ class MatterConnectFragment : Fragment() {

override fun onStatusUpdate(status: Int) {
super.onStatusUpdate(status)
Timber.tag(TAG).e("onStatusUpdate :" + status.toString())
Timber.tag(TAG).e("onStatusUpdate : $status.toString()")
}


@SuppressLint("MissingPermission")
override fun onCommissioningComplete(nodeId: Long, errorCode: Int) {
super.onCommissioningComplete(nodeId, errorCode)
Timber.tag(TAG).e("onCommissioningComplete : NodeID: " + nodeId.toString())
Timber.tag(TAG).e("onCommissioningComplete : NodeID: $nodeId.toString()")
Timber.tag(TAG).e("onCommissioningComplete : errorCode: " + errorCode.toString())
removeAlert()
if (errorCode == STATUS_PAIRING_SUCCESS) {
Expand All @@ -455,7 +455,7 @@ class MatterConnectFragment : Fragment() {
override fun onSuccess(valueList: MutableList<ChipStructs.DescriptorClusterDeviceTypeStruct>?) {

Timber.tag(TAG)
.e("deviceType " + valueList?.get(0)?.deviceType?.toInt()!!)
.e("deviceType $ valueList?.get(0)?.deviceType?.toInt()!!")
val deviceType = valueList?.get(0)?.deviceType?.toInt()!!
println("device Type: $deviceType}")
println("device Info: ${matterScanDevice.name} DeviceId: ${deviceId}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import com.siliconlabs.bledemo.features.demo.matter_demo.model.CHIPDeviceInfo
import com.siliconlabs.bledemo.features.demo.matter_demo.model.ProvisionNetworkType
import com.siliconlabs.bledemo.features.demo.matter_demo.utils.FragmentUtils
import com.siliconlabs.bledemo.features.demo.matter_demo.utils.MessageDialogFragment
import com.siliconlabs.bledemo.features.iop_test.utils.DialogDeviceInfoFragment
import timber.log.Timber
import java.util.concurrent.Executors
import kotlin.math.abs
Expand All @@ -55,6 +56,8 @@ class MatterScannerFragment : Fragment() {
private lateinit var payload: SetupPayload
private var isShortDiscriminator = false
private lateinit var qrCodeManualInput: String
private var deviceDialog: DialogDeviceInfoFragment? = null
private var deviceInfodialogShown = false

@RequiresApi(Build.VERSION_CODES.S)
override fun onCreate(savedInstanceState: Bundle?) {
Expand Down Expand Up @@ -173,13 +176,27 @@ class MatterScannerFragment : Fragment() {
ALERT_NTW_MODE_DIALOG_TAG
)
if (prev == null) {
networkSelectionDialog = MatterNetworkSelectionInputDialogFragment.newInstance()
val chipDeviceInfo = """
Version: ${payload.version ?: "N/A"}
Vendor ID: ${payload.vendorId ?: "N/A"}
Product ID: ${payload.productId ?: "N/A"}
Discriminator: ${payload.discriminator ?: "N/A"}
Setup PIN Code: ${payload.setupPinCode ?: "N/A"}
Discovery Capabilities: ${
payload.discoveryCapabilities?.joinToString(", ") ?: "N/A"
}
Commissioning Flow: ${payload.commissioningFlow ?: "N/A"}
""".trimIndent()
showDeviceInfoDialog(chipDeviceInfo)



networkSelectionDialog!!.setTargetFragment(this, DIALOG_NTW_MODE_FRAGMENT)
networkSelectionDialog!!.show(
requireActivity().supportFragmentManager,
ALERT_NTW_MODE_DIALOG_TAG
)
}
}

Expand Down Expand Up @@ -217,14 +234,26 @@ class MatterScannerFragment : Fragment() {
ALERT_NTW_MODE_DIALOG_TAG
)
if (prev == null) {
networkSelectionDialog =
MatterNetworkSelectionInputDialogFragment.newInstance()
val chipDeviceInfo = """
Version: ${payload.version ?: "N/A"}
Vendor ID: ${payload.vendorId ?: "N/A"}
Product ID: ${payload.productId ?: "N/A"}
Discriminator: ${payload.discriminator ?: "N/A"}
Setup PIN Code: ${payload.setupPinCode ?: "N/A"}
Discovery Capabilities: ${
payload.discoveryCapabilities?.joinToString(", ") ?: "N/A"
}
Commissioning Flow: ${payload.commissioningFlow ?: "N/A"}
""".trimIndent()
showDeviceInfoDialog(chipDeviceInfo)


networkSelectionDialog!!.setTargetFragment(this, DIALOG_NTW_MODE_FRAGMENT)
networkSelectionDialog!!.show(
requireActivity().supportFragmentManager,
ALERT_NTW_MODE_DIALOG_TAG
)
}
}

Expand Down Expand Up @@ -427,6 +456,45 @@ class MatterScannerFragment : Fragment() {
}
}

private fun showDeviceInfoDialog(message: String) {
try {
if (isAdded && requireActivity() != null && !requireActivity().isFinishing) {
requireActivity().runOnUiThread {
if (!deviceInfodialogShown && (deviceDialog == null || !deviceDialog!!.isShowing())) {
deviceInfodialogShown=true
deviceDialog = DialogDeviceInfoFragment.Builder()
.setTitle(getString(R.string.qr_code_info))
.setMessage(message)
.setPositiveButton(getString(R.string.start_commissioning)) { dialog, which ->
// Positive button click logic
networkSelectionDialog =
MatterNetworkSelectionInputDialogFragment.newInstance()

networkSelectionDialog!!.setTargetFragment(this, DIALOG_NTW_MODE_FRAGMENT)
networkSelectionDialog!!.show(
requireActivity().supportFragmentManager, ALERT_NTW_MODE_DIALOG_TAG
)
deviceDialog?.isShowing()==false
deviceInfodialogShown=false
}
.setNegativeButton("Cancel") { dialog, which ->
deviceDialog?.dismiss()
deviceDialog?.isShowing()==false
deviceInfodialogShown=false
}
.build()

deviceDialog?.show(parentFragmentManager, "DialogDeviceInfoFragment")
}
}
} else {
Timber.e("Fail to read device detail")
}
} catch (e: Exception) {
Timber.e("Fail to read device detail $e")
}
}

interface CallBack {
fun onChipDeviceInfoReceived(deviceInfo: CHIPDeviceInfo, ntwInputType: String)

Expand All @@ -437,10 +505,10 @@ class MatterScannerFragment : Fragment() {
companion object {
private val TAG = MatterScannerFragment::class.java.classes.toString()
private const val REQUEST_CODE_LOCATION_PERMISSION = 101
private const val REQUEST_CODE_CAMERA_PERMISSION = 100;
private const val REQUEST_CODE_CAMERA_PERMISSION = 100
private const val RATIO_4_3_VALUE = 4.0 / 3.0
private const val RATIO_16_9_VALUE = 16.0 / 9.0
private const val DIALOG_NTW_MODE_FRAGMENT = 998;
private const val DIALOG_NTW_MODE_FRAGMENT = 998
const val CANCEL_REQ_CODE = 5000
const val WIFI_REQ_CODE = 5001
const val THREAD_REQ_CODE = 5002
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,9 @@ object ChipClient {
}

private fun showMessage(msg: String, context: Context) {

Toast.makeText(context, msg, Toast.LENGTH_SHORT).show()

Toast.makeText(context, msg, Toast.LENGTH_SHORT).show()
}

suspend fun getConnectedDevicePointer(context: Context, nodeId: Long): Long {
// TODO (#21539) This is a memory leak because we currently never call releaseConnectedDevicePointer
// once we are done with the returned device pointer. Memory leak was introduced since the refactor
Expand All @@ -79,7 +78,7 @@ object ChipClient {
}

override fun onConnectionFailure(nodeId: Long, error: Exception) {
// showMessage("Device is offline",context)
// showMessage("Device is offline",context)
val errorMessage = "Unable to get connected device with nodeId $nodeId"
Log.e(TAG, errorMessage, error)
continuation.resumeWithException(IllegalStateException(errorMessage))
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
package com.siliconlabs.bledemo.features.iop_test.utils

import android.app.AlertDialog
import android.app.Dialog
import android.content.DialogInterface
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.DialogFragment
import com.siliconlabs.bledemo.R
import com.siliconlabs.bledemo.databinding.DialogDeviceInfoLayoutBinding

class DialogDeviceInfoFragment : DialogFragment() {
var title: String? = null
var message: String? = null
var positiveButtonText: String? = null
var negativeButtonText: String? = null
var positiveClickListener: DialogInterface.OnClickListener? = null
var negativeClickListener: DialogInterface.OnClickListener? = null
lateinit var binding: DialogDeviceInfoLayoutBinding

private var dialogShowing = false

override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
binding = DialogDeviceInfoLayoutBinding.inflate(inflater, container, false)
return binding.root
}

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)


// Set title and message
binding.dialogTitle.text = title
binding.dialogMessage.text = message

// Set positive button click listener
binding.btnPositive.setOnClickListener {
positiveClickListener?.onClick(dialog, DialogInterface.BUTTON_POSITIVE)
dismiss()
}

// Set negative button click listener
binding.btnNegative.setOnClickListener {
negativeClickListener?.onClick(dialog, DialogInterface.BUTTON_NEGATIVE)
dismiss()
}

// Set button texts
binding.btnPositive.text = positiveButtonText
binding.btnNegative.text = negativeButtonText

}
/*override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
val builder = AlertDialog.Builder(requireActivity())
builder.setTitle(title)
builder.setMessage(message)
if (positiveButtonText != null) {
builder.setPositiveButton(positiveButtonText, positiveClickListener)
}
if (negativeButtonText != null) {
builder.setNegativeButton(negativeButtonText, negativeClickListener)
}
val dialog = builder.create()
dialog.setOnShowListener {
dialogShowing = true
}
dialog.setOnDismissListener {
dialogShowing = false
}
return dialog
}*/

// Builder pattern for setting dialog properties
class Builder {
private val fragment = DialogDeviceInfoFragment()

fun setTitle(title: String?): Builder {
fragment.title = title
return this
}

fun setMessage(message: String?): Builder {
fragment.message = message
return this
}

fun setPositiveButton(text: String?, listener: DialogInterface.OnClickListener?): Builder {
fragment.positiveButtonText = text
fragment.positiveClickListener = listener
return this
}

fun setNegativeButton(text: String?, listener: DialogInterface.OnClickListener?): Builder {
fragment.negativeButtonText = text
fragment.negativeClickListener = listener
return this
}

fun build(): DialogDeviceInfoFragment {
return fragment
}
}

fun isShowing(): Boolean {
return dialogShowing
}
}
6 changes: 6 additions & 0 deletions mobile/src/main/res/drawable/rounded_dialog_background.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<!-- rounded_dialog_background.xml -->
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="@dimen/matter_10dp" /> <!-- Adjust radius as needed -->
<solid android:color="@android:color/white" /> <!-- Background color -->
</shape>

0 comments on commit bf4a552

Please sign in to comment.