react-native-mytatva-rn-sdk 1.2.19 → 1.2.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/build.gradle +4 -2
- package/android/src/main/java/com/mytatvarnsdk/activity/ConnectSensorActivity.kt +300 -247
- package/android/src/main/java/com/mytatvarnsdk/activity/SearchTransmitterActivity.kt +371 -427
- package/ios/ViewControllers/AttachTransmitterViewController.swift +1 -1
- package/ios/ViewModel/FinalViewModel.swift +1 -1
- package/lib/commonjs/CGMConnect.js +9 -4
- package/lib/commonjs/CGMConnect.js.map +1 -1
- package/lib/module/CGMConnect.js +9 -4
- package/lib/module/CGMConnect.js.map +1 -1
- package/package.json +1 -1
- package/src/CGMConnect.ts +18 -12
package/android/build.gradle
CHANGED
|
@@ -179,8 +179,10 @@ dependencies {
|
|
|
179
179
|
implementation "io.ktor:ktor-client-serialization:$ktor_version"
|
|
180
180
|
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.3.1")
|
|
181
181
|
|
|
182
|
-
implementation
|
|
183
|
-
implementation
|
|
182
|
+
implementation(name: 'library_zxing-release', ext: 'aar')
|
|
183
|
+
implementation(name: 'algorithm-release', ext: 'aar')
|
|
184
|
+
// implementation files('libs/library_zxing-release.aar')
|
|
185
|
+
// implementation files('libs/algorithm-release.aar')
|
|
184
186
|
}
|
|
185
187
|
|
|
186
188
|
if (isNewArchitectureEnabled()) {
|
|
@@ -25,6 +25,11 @@ import cgmblelib.ble.scancallback.ManageScanCallback
|
|
|
25
25
|
import cgmblelib.custom.livedata.scan.PocDeviceAndRssi
|
|
26
26
|
import cgmblelib.database.entity.PocDevice
|
|
27
27
|
import com.bumptech.glide.Glide
|
|
28
|
+
import com.facebook.react.bridge.Arguments
|
|
29
|
+
import com.facebook.react.bridge.CatalystInstance
|
|
30
|
+
import com.facebook.react.bridge.WritableMap
|
|
31
|
+
import com.facebook.react.modules.core.DeviceEventManagerModule
|
|
32
|
+
import com.mytatvarnsdk.CgmTrackyLibModule
|
|
28
33
|
import com.mytatvarnsdk.R
|
|
29
34
|
import com.mytatvarnsdk.base.BaseBleActivity
|
|
30
35
|
import com.mytatvarnsdk.databinding.ActivityConnectSensorBinding
|
|
@@ -34,309 +39,357 @@ import com.mytatvarnsdk.myView.progress.ProgressType
|
|
|
34
39
|
|
|
35
40
|
|
|
36
41
|
class ConnectSensorActivity : BaseBleActivity() {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
override fun setView(): Int {
|
|
57
|
-
return R.layout.activity_connect_sensor
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
override fun onPermissionRequestSuccess() {
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
override fun initViews() {
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
private fun initialize() {
|
|
67
|
-
transmitterDeviceInfo =
|
|
68
|
-
intent.getSerializableExtra("transmitterDeviceInfo") as PocDeviceAndRssi?
|
|
69
|
-
|
|
70
|
-
binding.commonButton.btnProceed.setOnClickListener {
|
|
71
|
-
transmitterDeviceInfo?.let {
|
|
72
|
-
QRActivity.startQR(
|
|
73
|
-
this,
|
|
74
|
-
it.pocDevice
|
|
75
|
-
)
|
|
76
|
-
}
|
|
42
|
+
private lateinit var binding: ActivityConnectSensorBinding
|
|
43
|
+
public val REQUEST_QR: Int = 115
|
|
44
|
+
private val CAMERA_REQUEST_CODE = 100
|
|
45
|
+
var transmitterDeviceInfo: PocDeviceAndRssi? = null
|
|
46
|
+
private var isForReconnect: Boolean = false
|
|
47
|
+
private val reactContext = CgmTrackyLibModule.mReactContext
|
|
48
|
+
|
|
49
|
+
override fun onCreate(savedInstanceState: Bundle?) {
|
|
50
|
+
super.onCreate(savedInstanceState)
|
|
51
|
+
binding = ActivityConnectSensorBinding.inflate(layoutInflater)
|
|
52
|
+
setContentView(binding.root)
|
|
53
|
+
|
|
54
|
+
enableEdgeToEdge()
|
|
55
|
+
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { v, insets ->
|
|
56
|
+
val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
|
|
57
|
+
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
|
|
58
|
+
insets
|
|
59
|
+
}
|
|
60
|
+
initialize()
|
|
77
61
|
}
|
|
78
62
|
|
|
79
|
-
|
|
80
|
-
|
|
63
|
+
override fun setView(): Int {
|
|
64
|
+
return R.layout.activity_connect_sensor
|
|
81
65
|
}
|
|
82
66
|
|
|
83
|
-
|
|
84
|
-
startActivity(Intent(this, HelpActivity::class.java))
|
|
67
|
+
override fun onPermissionRequestSuccess() {
|
|
85
68
|
}
|
|
86
69
|
|
|
87
|
-
|
|
88
|
-
override fun handleOnBackPressed() {
|
|
89
|
-
openExitDialog()
|
|
90
|
-
}
|
|
70
|
+
override fun initViews() {
|
|
91
71
|
}
|
|
92
|
-
onBackPressedDispatcher.addCallback(this, callback)
|
|
93
72
|
|
|
73
|
+
private fun initialize() {
|
|
74
|
+
transmitterDeviceInfo =
|
|
75
|
+
intent.getSerializableExtra("transmitterDeviceInfo") as PocDeviceAndRssi?
|
|
76
|
+
isForReconnect = intent.getBooleanExtra("IsForReconnect", false)
|
|
77
|
+
|
|
78
|
+
binding.commonButton.btnProceed.setOnClickListener {
|
|
79
|
+
transmitterDeviceInfo?.let {
|
|
80
|
+
QRActivity.startQR(
|
|
81
|
+
this,
|
|
82
|
+
it.pocDevice
|
|
83
|
+
)
|
|
84
|
+
}
|
|
85
|
+
}
|
|
94
86
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
87
|
+
binding.toolbar.btnClose.setOnClickListener {
|
|
88
|
+
openExitDialog()
|
|
89
|
+
}
|
|
98
90
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
binding.tvPermission.text = "Press on Proceed button below to scan QR"
|
|
103
|
-
} else {
|
|
104
|
-
binding.commonButton.btnProceed.isEnabled = false
|
|
105
|
-
binding.commonButton.btnProceed.alpha = 0.5f
|
|
106
|
-
binding.clPermission.visibility = View.VISIBLE
|
|
107
|
-
}
|
|
108
|
-
}
|
|
91
|
+
binding.toolbar.btnWhatsapp.setOnClickListener {
|
|
92
|
+
startActivity(Intent(this, HelpActivity::class.java))
|
|
93
|
+
}
|
|
109
94
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
95
|
+
val callback: OnBackPressedCallback = object : OnBackPressedCallback(true) {
|
|
96
|
+
override fun handleOnBackPressed() {
|
|
97
|
+
openExitDialog()
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
onBackPressedDispatcher.addCallback(this, callback)
|
|
116
101
|
|
|
117
|
-
Glide.with(this)
|
|
118
|
-
.asGif()
|
|
119
|
-
.load(R.drawable.warning)
|
|
120
|
-
.into(binding.ivGif)
|
|
121
102
|
|
|
122
|
-
|
|
123
|
-
|
|
103
|
+
binding.tvPermission.setOnClickListener(View.OnClickListener { v: View? ->
|
|
104
|
+
requestCameraPermission()
|
|
105
|
+
})
|
|
124
106
|
|
|
125
|
-
|
|
107
|
+
if (isCameraPermissionGranted(this)) {
|
|
108
|
+
binding.commonButton.btnProceed.isEnabled = true
|
|
109
|
+
binding.commonButton.btnProceed.alpha = 1f
|
|
110
|
+
binding.tvPermission.text = "Press on Proceed button below to scan QR"
|
|
111
|
+
} else {
|
|
112
|
+
binding.commonButton.btnProceed.isEnabled = false
|
|
113
|
+
binding.commonButton.btnProceed.alpha = 0.5f
|
|
114
|
+
binding.clPermission.visibility = View.VISIBLE
|
|
115
|
+
}
|
|
116
|
+
}
|
|
126
117
|
|
|
127
|
-
|
|
118
|
+
fun manageErrorState(showError: Boolean, errorStatus: String) {
|
|
119
|
+
ProgressManagement.getInstance().dismissWait(this)
|
|
120
|
+
if (showError) {
|
|
121
|
+
binding.clFail.visibility = View.VISIBLE
|
|
122
|
+
binding.clMain.visibility = View.GONE
|
|
123
|
+
binding.commonButton.root.visibility = View.GONE
|
|
124
|
+
|
|
125
|
+
Glide.with(this)
|
|
126
|
+
.asGif()
|
|
127
|
+
.load(R.drawable.warning)
|
|
128
|
+
.into(binding.ivGif)
|
|
129
|
+
|
|
130
|
+
binding.btnSupport.tvProceed.text = "Contact Support"
|
|
131
|
+
binding.btnRetry.tvProceed.text = "Retry"
|
|
132
|
+
|
|
133
|
+
binding.btnWatchDemo.setOnClickListener {
|
|
134
|
+
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
binding.btnSupport.btnProceed.setOnClickListener {
|
|
138
|
+
startActivity(Intent(this, HelpActivity::class.java))
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
binding.btnRetry.btnProceed.setOnClickListener {
|
|
142
|
+
transmitterDeviceInfo?.let {
|
|
143
|
+
QRActivity.startQR(
|
|
144
|
+
this,
|
|
145
|
+
it.pocDevice
|
|
146
|
+
)
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
if (errorStatus.isNotEmpty()) {
|
|
151
|
+
binding.tvReason.visibility = View.VISIBLE
|
|
152
|
+
binding.tvReason.text = "Reason - ${errorStatus}"
|
|
153
|
+
} else {
|
|
154
|
+
binding.tvReason.visibility = View.GONE
|
|
155
|
+
}
|
|
156
|
+
} else {
|
|
157
|
+
binding.commonButton.root.visibility = View.VISIBLE
|
|
158
|
+
binding.clFail.visibility = View.GONE
|
|
159
|
+
binding.clMain.visibility = View.VISIBLE
|
|
160
|
+
}
|
|
161
|
+
}
|
|
128
162
|
|
|
129
|
-
binding.btnSupport.btnProceed.setOnClickListener {
|
|
130
|
-
startActivity(Intent(this, HelpActivity::class.java))
|
|
131
|
-
}
|
|
132
163
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
164
|
+
private fun requestCameraPermission() {
|
|
165
|
+
if (hasPermissions(PermissionUtils.CAMERA_PERMISSION)) {
|
|
166
|
+
onCameraPermissionGranted()
|
|
167
|
+
} else {
|
|
168
|
+
if (ActivityCompat.shouldShowRequestPermissionRationale(
|
|
169
|
+
this,
|
|
170
|
+
Manifest.permission.CAMERA
|
|
171
|
+
)
|
|
172
|
+
) {
|
|
173
|
+
showPermissionRationale(
|
|
174
|
+
title = "Camera Permission Needed",
|
|
175
|
+
message = "We need access to your camera to proceed.",
|
|
176
|
+
onProceed = {
|
|
177
|
+
ActivityCompat.requestPermissions(
|
|
178
|
+
this,
|
|
179
|
+
PermissionUtils.CAMERA_PERMISSION,
|
|
180
|
+
CAMERA_REQUEST_CODE
|
|
181
|
+
)
|
|
182
|
+
}
|
|
183
|
+
)
|
|
184
|
+
} else {
|
|
185
|
+
ActivityCompat.requestPermissions(
|
|
186
|
+
this,
|
|
187
|
+
PermissionUtils.CAMERA_PERMISSION,
|
|
188
|
+
CAMERA_REQUEST_CODE
|
|
189
|
+
)
|
|
190
|
+
}
|
|
139
191
|
}
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
if (errorStatus.isNotEmpty()) {
|
|
143
|
-
binding.tvReason.visibility = View.VISIBLE
|
|
144
|
-
binding.tvReason.text = "Reason - ${errorStatus}"
|
|
145
|
-
} else {
|
|
146
|
-
binding.tvReason.visibility = View.GONE
|
|
147
|
-
}
|
|
148
|
-
} else {
|
|
149
|
-
binding.commonButton.root.visibility = View.VISIBLE
|
|
150
|
-
binding.clFail.visibility = View.GONE
|
|
151
|
-
binding.clMain.visibility = View.VISIBLE
|
|
152
192
|
}
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
onCameraPermissionGranted()
|
|
159
|
-
} else {
|
|
160
|
-
if (ActivityCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.CAMERA)) {
|
|
161
|
-
showPermissionRationale(
|
|
162
|
-
title = "Camera Permission Needed",
|
|
163
|
-
message = "We need access to your camera to proceed.",
|
|
164
|
-
onProceed = {
|
|
165
|
-
ActivityCompat.requestPermissions(
|
|
166
|
-
this,
|
|
167
|
-
PermissionUtils.CAMERA_PERMISSION,
|
|
168
|
-
CAMERA_REQUEST_CODE
|
|
169
|
-
)
|
|
170
|
-
}
|
|
171
|
-
)
|
|
172
|
-
} else {
|
|
173
|
-
ActivityCompat.requestPermissions(
|
|
174
|
-
this,
|
|
175
|
-
PermissionUtils.CAMERA_PERMISSION,
|
|
176
|
-
CAMERA_REQUEST_CODE
|
|
177
|
-
)
|
|
178
|
-
}
|
|
193
|
+
|
|
194
|
+
private fun onCameraPermissionGranted() {
|
|
195
|
+
binding.commonButton.btnProceed.isEnabled = true
|
|
196
|
+
binding.commonButton.btnProceed.alpha = 1f
|
|
197
|
+
binding.commonButton.btnProceed.performClick()
|
|
179
198
|
}
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
private fun showPermissionRationale(title: String, message: String, onProceed: () -> Unit) {
|
|
189
|
-
AlertDialog.Builder(this)
|
|
190
|
-
.setTitle(title)
|
|
191
|
-
.setMessage(message)
|
|
192
|
-
.setPositiveButton("OK") { _, _ -> onProceed() }
|
|
193
|
-
.setNegativeButton("Cancel", null)
|
|
194
|
-
.show()
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
private fun hasPermissions(permissions: Array<String>): Boolean {
|
|
198
|
-
return permissions.all {
|
|
199
|
-
ContextCompat.checkSelfPermission(this, it) == PackageManager.PERMISSION_GRANTED
|
|
199
|
+
|
|
200
|
+
private fun showPermissionRationale(title: String, message: String, onProceed: () -> Unit) {
|
|
201
|
+
AlertDialog.Builder(this)
|
|
202
|
+
.setTitle(title)
|
|
203
|
+
.setMessage(message)
|
|
204
|
+
.setPositiveButton("OK") { _, _ -> onProceed() }
|
|
205
|
+
.setNegativeButton("Cancel", null)
|
|
206
|
+
.show()
|
|
200
207
|
}
|
|
201
|
-
}
|
|
202
208
|
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
}
|
|
209
|
+
private fun hasPermissions(permissions: Array<String>): Boolean {
|
|
210
|
+
return permissions.all {
|
|
211
|
+
ContextCompat.checkSelfPermission(this, it) == PackageManager.PERMISSION_GRANTED
|
|
212
|
+
}
|
|
213
|
+
}
|
|
209
214
|
|
|
215
|
+
fun isCameraPermissionGranted(context: Context): Boolean {
|
|
216
|
+
return ContextCompat.checkSelfPermission(
|
|
217
|
+
context,
|
|
218
|
+
Manifest.permission.CAMERA
|
|
219
|
+
) == PackageManager.PERMISSION_GRANTED
|
|
220
|
+
}
|
|
210
221
|
|
|
211
|
-
private fun openExitDialog() {
|
|
212
|
-
val binding = ExitDialogBottomsheetBinding.inflate(layoutInflater)
|
|
213
222
|
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
dialog.setContentView(binding.root)
|
|
223
|
+
private fun openExitDialog() {
|
|
224
|
+
val binding = ExitDialogBottomsheetBinding.inflate(layoutInflater)
|
|
217
225
|
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
window?.setBackgroundDrawable(Color.TRANSPARENT.toDrawable())
|
|
226
|
+
val dialog = Dialog(this)
|
|
227
|
+
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE)
|
|
228
|
+
dialog.setContentView(binding.root)
|
|
222
229
|
|
|
223
|
-
|
|
230
|
+
val window = dialog.window
|
|
231
|
+
window?.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)
|
|
232
|
+
window?.setGravity(Gravity.BOTTOM)
|
|
233
|
+
window?.setBackgroundDrawable(Color.TRANSPARENT.toDrawable())
|
|
224
234
|
|
|
225
|
-
|
|
226
|
-
finish()
|
|
227
|
-
dialog.dismiss()
|
|
228
|
-
})
|
|
235
|
+
binding.btnExit.tvProceed.text = "Exit"
|
|
229
236
|
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
237
|
+
binding.btnExit.root.setOnClickListener(View.OnClickListener { v: View? ->
|
|
238
|
+
finish()
|
|
239
|
+
dialog.dismiss()
|
|
240
|
+
})
|
|
233
241
|
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
242
|
+
binding.btnCancel.root.setOnClickListener(View.OnClickListener { v: View? ->
|
|
243
|
+
dialog.dismiss()
|
|
244
|
+
})
|
|
237
245
|
|
|
246
|
+
binding.closeButton.setOnClickListener(View.OnClickListener { v: View? ->
|
|
247
|
+
dialog.dismiss()
|
|
248
|
+
})
|
|
238
249
|
|
|
239
|
-
dialog.show()
|
|
240
|
-
}
|
|
241
250
|
|
|
242
|
-
|
|
243
|
-
|
|
251
|
+
dialog.show()
|
|
252
|
+
}
|
|
244
253
|
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
permissions: Array<out String>,
|
|
248
|
-
grantResults: IntArray
|
|
249
|
-
) {
|
|
250
|
-
super.onRequestPermissionsResult(requestCode, permissions, grantResults)
|
|
251
|
-
val allGranted = grantResults.all { it == PackageManager.PERMISSION_GRANTED }
|
|
254
|
+
override fun init() {
|
|
255
|
+
}
|
|
252
256
|
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
+
override fun onRequestPermissionsResult(
|
|
258
|
+
requestCode: Int,
|
|
259
|
+
permissions: Array<out String>,
|
|
260
|
+
grantResults: IntArray
|
|
261
|
+
) {
|
|
262
|
+
super.onRequestPermissionsResult(requestCode, permissions, grantResults)
|
|
263
|
+
val allGranted = grantResults.all { it == PackageManager.PERMISSION_GRANTED }
|
|
264
|
+
|
|
265
|
+
when (requestCode) {
|
|
266
|
+
CAMERA_REQUEST_CODE -> {
|
|
267
|
+
if (allGranted) {
|
|
268
|
+
onCameraPermissionGranted()
|
|
269
|
+
}
|
|
270
|
+
}
|
|
257
271
|
}
|
|
258
|
-
}
|
|
259
272
|
}
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
273
|
+
|
|
274
|
+
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
|
275
|
+
super.onActivityResult(requestCode, resultCode, data)
|
|
276
|
+
if (requestCode == REQUEST_QR && resultCode == RESULT_OK && data != null) {
|
|
277
|
+
val device: PocDevice? = data.getParcelableExtra("device")
|
|
278
|
+
if (device != null) {
|
|
279
|
+
bind(device)
|
|
280
|
+
}
|
|
281
|
+
}
|
|
269
282
|
}
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
283
|
+
|
|
284
|
+
private fun bind(device: PocDevice) {
|
|
285
|
+
try {
|
|
286
|
+
if (device.address != null) {
|
|
287
|
+
ManageGattCallback.getInstance().ConnectViaAddress(device.address)
|
|
288
|
+
ManageScanCallback.getInstance().stopLeScan()
|
|
289
|
+
ProgressManagement.getInstance()
|
|
290
|
+
.showWait(this, ProgressType.PROGRESSDIALOG_CONNECT, null)
|
|
291
|
+
}
|
|
292
|
+
} catch (e: Exception) {
|
|
293
|
+
Log.d("bind::-> ", "bind: ${e.message}")
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
override fun onClick(p0: View?) {
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
override fun bindFail() {
|
|
301
|
+
super.bindFail()
|
|
302
|
+
manageErrorState(true, "Bind Fail")
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
override fun bindSuccess() {
|
|
306
|
+
super.bindSuccess()
|
|
307
|
+
ProgressManagement.getInstance().dismissWait(this)
|
|
308
|
+
if (isForReconnect) {
|
|
309
|
+
sendDataToRN("")
|
|
310
|
+
} else {
|
|
311
|
+
startActivity(Intent(this, SensorConnectSuccessActivity::class.java))
|
|
312
|
+
}
|
|
313
|
+
finish()
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
private fun sendDataToRN(data: String) {
|
|
317
|
+
if (reactContext != null) {
|
|
318
|
+
try {
|
|
319
|
+
val catalystInstance: CatalystInstance = reactContext.catalystInstance
|
|
320
|
+
val module = catalystInstance.getNativeModule(CgmTrackyLibModule::class.java)
|
|
321
|
+
|
|
322
|
+
if (module == null) {
|
|
323
|
+
sendDataToRNDirectly("", "WARM_PERIOD_STARTED")
|
|
324
|
+
Log.d("sendDataToRN: ", "Module null")
|
|
325
|
+
} else {
|
|
326
|
+
module.sendDataToReact(data, "WARM_PERIOD_STARTED", "cgmDeviceEvent")
|
|
327
|
+
Log.d("sendDataToRN: ", "Module is not null")
|
|
328
|
+
}
|
|
329
|
+
} catch (e: Exception) {
|
|
330
|
+
Log.e("sendDataToRN: Error ", e.message.toString())
|
|
331
|
+
}
|
|
332
|
+
} else {
|
|
333
|
+
Log.e("TrackyActivity", "ReactApplicationContext is null")
|
|
334
|
+
}
|
|
281
335
|
}
|
|
282
|
-
}
|
|
283
336
|
|
|
284
|
-
override fun onClick(p0: View?) {
|
|
285
|
-
}
|
|
286
337
|
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
338
|
+
private fun sendDataToRNDirectly(data: String, status: String) {
|
|
339
|
+
try {
|
|
340
|
+
val map: WritableMap = Arguments.createMap().apply {
|
|
341
|
+
putString("data", data)
|
|
342
|
+
putString("status", status)
|
|
343
|
+
}
|
|
291
344
|
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
345
|
+
reactContext?.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
|
|
346
|
+
?.emit("cgmDeviceEvent", map)
|
|
347
|
+
} catch (e: Exception) {
|
|
348
|
+
Log.e("sendDataToRNDirectly", "Error sending data to React", e)
|
|
349
|
+
}
|
|
350
|
+
}
|
|
298
351
|
|
|
299
352
|
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
353
|
+
override fun bluetoothStateOFF() {
|
|
354
|
+
super.bluetoothStateOFF()
|
|
355
|
+
manageErrorState(true, "Bluetooth Off")
|
|
303
356
|
|
|
304
|
-
|
|
357
|
+
}
|
|
305
358
|
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
359
|
+
override fun disconnect() {
|
|
360
|
+
super.disconnect()
|
|
361
|
+
manageErrorState(true, "Disconnected")
|
|
309
362
|
|
|
310
|
-
|
|
363
|
+
}
|
|
311
364
|
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
365
|
+
override fun disconnectForTimeout() {
|
|
366
|
+
super.disconnectForTimeout()
|
|
367
|
+
manageErrorState(true, "Disconnected")
|
|
315
368
|
|
|
316
|
-
|
|
369
|
+
}
|
|
317
370
|
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
371
|
+
override fun checkFailForLowPower() {
|
|
372
|
+
super.checkFailForLowPower()
|
|
373
|
+
manageErrorState(true, "Low Power")
|
|
321
374
|
|
|
322
|
-
|
|
375
|
+
}
|
|
323
376
|
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
377
|
+
override fun checkFailErrorTemperature() {
|
|
378
|
+
super.checkFailErrorTemperature()
|
|
379
|
+
manageErrorState(true, "Temperature Error")
|
|
327
380
|
|
|
328
|
-
|
|
381
|
+
}
|
|
329
382
|
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
383
|
+
override fun unbindReset() {
|
|
384
|
+
super.unbindReset()
|
|
385
|
+
manageErrorState(true, "Unbinded")
|
|
333
386
|
|
|
334
|
-
|
|
387
|
+
}
|
|
335
388
|
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
389
|
+
override fun unbindCommand() {
|
|
390
|
+
super.unbindCommand()
|
|
391
|
+
manageErrorState(true, "Unbinded")
|
|
339
392
|
|
|
340
|
-
|
|
393
|
+
}
|
|
341
394
|
|
|
342
395
|
}
|