react-native-mytatva-rn-sdk 1.2.43 → 1.2.45
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/src/main/java/com/mytatvarnsdk/activity/ConnectSensorActivity.kt +23 -6
- package/android/src/main/java/com/mytatvarnsdk/activity/HelpActivity.kt +118 -59
- package/android/src/main/java/com/mytatvarnsdk/activity/PermissionActivity.kt +384 -321
- package/android/src/main/java/com/mytatvarnsdk/activity/PlaceSensorActivity.kt +50 -1
- package/android/src/main/java/com/mytatvarnsdk/activity/PlaceTransmitterActivity.kt +13 -5
- package/android/src/main/java/com/mytatvarnsdk/activity/SearchTransmitterActivity.kt +72 -52
- package/android/src/main/java/com/mytatvarnsdk/activity/SensorConnectSuccessActivity.kt +52 -1
- package/android/src/main/java/com/mytatvarnsdk/activity/StartCGMActivity.kt +53 -1
- package/package.json +1 -1
|
@@ -4,6 +4,7 @@ import android.app.Dialog
|
|
|
4
4
|
import android.content.Intent
|
|
5
5
|
import android.graphics.Color
|
|
6
6
|
import android.os.Bundle
|
|
7
|
+
import android.util.Log
|
|
7
8
|
import android.view.Gravity
|
|
8
9
|
import android.view.View
|
|
9
10
|
import android.view.ViewGroup
|
|
@@ -16,6 +17,11 @@ import androidx.core.view.ViewCompat
|
|
|
16
17
|
import androidx.core.view.WindowInsetsCompat
|
|
17
18
|
import com.bumptech.glide.Glide
|
|
18
19
|
import com.bumptech.glide.load.resource.bitmap.RoundedCorners
|
|
20
|
+
import com.facebook.react.bridge.Arguments
|
|
21
|
+
import com.facebook.react.bridge.CatalystInstance
|
|
22
|
+
import com.facebook.react.bridge.WritableMap
|
|
23
|
+
import com.facebook.react.modules.core.DeviceEventManagerModule
|
|
24
|
+
import com.mytatvarnsdk.CgmTrackyLibModule
|
|
19
25
|
import com.mytatvarnsdk.R
|
|
20
26
|
import com.mytatvarnsdk.databinding.ActivityPlaceSensorBinding
|
|
21
27
|
import com.mytatvarnsdk.databinding.ExitDialogBottomsheetBinding
|
|
@@ -26,6 +32,7 @@ import com.pierfrancescosoffritti.androidyoutubeplayer.core.player.options.IFram
|
|
|
26
32
|
|
|
27
33
|
class PlaceSensorActivity : AppCompatActivity() {
|
|
28
34
|
private lateinit var binding: ActivityPlaceSensorBinding
|
|
35
|
+
private val reactContext = CgmTrackyLibModule.mReactContext
|
|
29
36
|
|
|
30
37
|
override fun onCreate(savedInstanceState: Bundle?) {
|
|
31
38
|
super.onCreate(savedInstanceState)
|
|
@@ -41,6 +48,8 @@ class PlaceSensorActivity : AppCompatActivity() {
|
|
|
41
48
|
}
|
|
42
49
|
|
|
43
50
|
private fun init() {
|
|
51
|
+
sendDataToRN("", "cgm_place_sensor_landing")
|
|
52
|
+
|
|
44
53
|
Glide.with(this)
|
|
45
54
|
.load(R.drawable.img_male)
|
|
46
55
|
.transform(RoundedCorners(50))
|
|
@@ -52,10 +61,15 @@ class PlaceSensorActivity : AppCompatActivity() {
|
|
|
52
61
|
.into(binding.ivPlay)
|
|
53
62
|
|
|
54
63
|
binding.toolbar.btnWhatsapp.setOnClickListener {
|
|
55
|
-
startActivity(
|
|
64
|
+
startActivity(
|
|
65
|
+
Intent(this, HelpActivity::class.java)
|
|
66
|
+
.putExtra("ScreenName", "Attach Sensor Screen")
|
|
67
|
+
)
|
|
56
68
|
}
|
|
57
69
|
|
|
58
70
|
binding.toolbar.btnWatchDemo.setOnClickListener {
|
|
71
|
+
sendDataToRN("", "cgm_watch_demo_clicked")
|
|
72
|
+
|
|
59
73
|
startActivity(
|
|
60
74
|
Intent(this, VideoActivity::class.java).putExtra("VideoId", "r5Zemc4R044")
|
|
61
75
|
)
|
|
@@ -85,6 +99,41 @@ class PlaceSensorActivity : AppCompatActivity() {
|
|
|
85
99
|
onBackPressedDispatcher.addCallback(this, callback)
|
|
86
100
|
}
|
|
87
101
|
|
|
102
|
+
private fun sendDataToRN(data: String, status: String) {
|
|
103
|
+
if (reactContext != null) {
|
|
104
|
+
try {
|
|
105
|
+
val catalystInstance: CatalystInstance = reactContext.catalystInstance
|
|
106
|
+
val module = catalystInstance.getNativeModule(CgmTrackyLibModule::class.java)
|
|
107
|
+
|
|
108
|
+
if (module == null) {
|
|
109
|
+
sendDataToRNDirectly(data, status)
|
|
110
|
+
Log.d("sendDataToRN: ", "Module null")
|
|
111
|
+
} else {
|
|
112
|
+
module.sendDataToReact(data, status, "cgmDeviceEvent")
|
|
113
|
+
Log.d("sendDataToRN: ", "Module is not null")
|
|
114
|
+
}
|
|
115
|
+
} catch (e: Exception) {
|
|
116
|
+
Log.e("sendDataToRN: Error ", e.message.toString())
|
|
117
|
+
}
|
|
118
|
+
} else {
|
|
119
|
+
Log.e("TrackyActivity", "ReactApplicationContext is null")
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
private fun sendDataToRNDirectly(data: String, status: String) {
|
|
125
|
+
try {
|
|
126
|
+
val map: WritableMap = Arguments.createMap().apply {
|
|
127
|
+
putString("data", data)
|
|
128
|
+
putString("status", status)
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
reactContext?.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
|
|
132
|
+
?.emit("cgmDeviceEvent", map)
|
|
133
|
+
} catch (e: Exception) {
|
|
134
|
+
Log.e("sendDataToRNDirectly", "Error sending data to React", e)
|
|
135
|
+
}
|
|
136
|
+
}
|
|
88
137
|
|
|
89
138
|
private fun openExitDialog() {
|
|
90
139
|
val binding = ExitDialogBottomsheetBinding.inflate(layoutInflater)
|
|
@@ -48,6 +48,8 @@ class PlaceTransmitterActivity : AppCompatActivity() {
|
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
private fun init() {
|
|
51
|
+
sendDataToRN("", "cgm_place_transmitter_landing")
|
|
52
|
+
|
|
51
53
|
Glide.with(this)
|
|
52
54
|
.load(R.drawable.img_female)
|
|
53
55
|
.transform(RoundedCorners(50))
|
|
@@ -61,15 +63,21 @@ class PlaceTransmitterActivity : AppCompatActivity() {
|
|
|
61
63
|
binding.commonButton.tvProceed.text = "Complete"
|
|
62
64
|
|
|
63
65
|
binding.commonButton.btnProceed.setOnClickListener {
|
|
64
|
-
sendDataToRN("")
|
|
66
|
+
sendDataToRN("", "cgm_connection_complete_clicked")
|
|
67
|
+
sendDataToRN("", "WARM_PERIOD_STARTED")
|
|
65
68
|
finish()
|
|
66
69
|
}
|
|
67
70
|
|
|
68
71
|
binding.toolbar.btnWhatsapp.setOnClickListener {
|
|
69
|
-
startActivity(
|
|
72
|
+
startActivity(
|
|
73
|
+
Intent(this, HelpActivity::class.java)
|
|
74
|
+
.putExtra("ScreenName", "Attach Transmitter Screen")
|
|
75
|
+
)
|
|
70
76
|
}
|
|
71
77
|
|
|
72
78
|
binding.toolbar.btnWatchDemo.setOnClickListener {
|
|
79
|
+
sendDataToRN("", "cgm_watch_demo_clicked")
|
|
80
|
+
|
|
73
81
|
startActivity(
|
|
74
82
|
Intent(this, VideoActivity::class.java).putExtra("VideoId", "r5Zemc4R044")
|
|
75
83
|
)
|
|
@@ -124,17 +132,17 @@ class PlaceTransmitterActivity : AppCompatActivity() {
|
|
|
124
132
|
dialog.show()
|
|
125
133
|
}
|
|
126
134
|
|
|
127
|
-
private fun sendDataToRN(data: String) {
|
|
135
|
+
private fun sendDataToRN(data: String, status: String) {
|
|
128
136
|
if (reactContext != null) {
|
|
129
137
|
try {
|
|
130
138
|
val catalystInstance: CatalystInstance = reactContext.catalystInstance
|
|
131
139
|
val module = catalystInstance.getNativeModule(CgmTrackyLibModule::class.java)
|
|
132
140
|
|
|
133
141
|
if (module == null) {
|
|
134
|
-
sendDataToRNDirectly(
|
|
142
|
+
sendDataToRNDirectly(data, status)
|
|
135
143
|
Log.d("sendDataToRN: ", "Module null")
|
|
136
144
|
} else {
|
|
137
|
-
module.sendDataToReact(data,
|
|
145
|
+
module.sendDataToReact(data, status, "cgmDeviceEvent")
|
|
138
146
|
Log.d("sendDataToRN: ", "Module is not null")
|
|
139
147
|
}
|
|
140
148
|
} catch (e: Exception) {
|
|
@@ -33,6 +33,11 @@ import cgmblelib.custom.livedata.scan.PocDeviceAndRssi
|
|
|
33
33
|
import cgmblelib.database.entity.PocDevice
|
|
34
34
|
import cgmblelib.database.entity.PocGlucose
|
|
35
35
|
import com.bumptech.glide.Glide
|
|
36
|
+
import com.facebook.react.bridge.Arguments
|
|
37
|
+
import com.facebook.react.bridge.CatalystInstance
|
|
38
|
+
import com.facebook.react.bridge.WritableMap
|
|
39
|
+
import com.facebook.react.modules.core.DeviceEventManagerModule
|
|
40
|
+
import com.mytatvarnsdk.CgmTrackyLibModule
|
|
36
41
|
import com.mytatvarnsdk.R
|
|
37
42
|
import com.mytatvarnsdk.base.BaseBleActivity
|
|
38
43
|
import com.mytatvarnsdk.databinding.ActivitySearchTransmitterBinding
|
|
@@ -50,6 +55,7 @@ import com.mytatvarnsdk.network.AuthenticateSDKService
|
|
|
50
55
|
import kotlinx.coroutines.CoroutineScope
|
|
51
56
|
import kotlinx.coroutines.Dispatchers
|
|
52
57
|
import kotlinx.coroutines.Job
|
|
58
|
+
import org.json.JSONObject
|
|
53
59
|
import java.text.SimpleDateFormat
|
|
54
60
|
import java.util.Date
|
|
55
61
|
import java.util.Locale
|
|
@@ -65,6 +71,7 @@ class SearchTransmitterActivity : BaseBleActivity() {
|
|
|
65
71
|
private val job = Job()
|
|
66
72
|
private val scope = CoroutineScope(Dispatchers.IO + job)
|
|
67
73
|
private var isForReconnect: Boolean = false
|
|
74
|
+
private val reactContext = CgmTrackyLibModule.mReactContext
|
|
68
75
|
|
|
69
76
|
override fun init() {
|
|
70
77
|
|
|
@@ -101,6 +108,8 @@ class SearchTransmitterActivity : BaseBleActivity() {
|
|
|
101
108
|
}
|
|
102
109
|
|
|
103
110
|
private fun setupInitialState() {
|
|
111
|
+
sendDataToRN("", "cgm_connect_transmitter_landing")
|
|
112
|
+
|
|
104
113
|
isForReconnect = intent.getBooleanExtra("IsForReconnect", false)
|
|
105
114
|
|
|
106
115
|
// Set initial states
|
|
@@ -140,16 +149,27 @@ class SearchTransmitterActivity : BaseBleActivity() {
|
|
|
140
149
|
}
|
|
141
150
|
|
|
142
151
|
binding.btnSupport.btnProceed.setOnClickListener {
|
|
143
|
-
startActivity(
|
|
152
|
+
startActivity(
|
|
153
|
+
Intent(this, HelpActivity::class.java)
|
|
154
|
+
.putExtra("ScreenName", "Transmitter Screen")
|
|
155
|
+
)
|
|
144
156
|
}
|
|
145
157
|
|
|
146
158
|
binding.btnRetry.btnProceed.setOnClickListener {
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
159
|
+
sendDataToRN("", "cgm_retry_connect_transmitter_clicked")
|
|
160
|
+
|
|
161
|
+
Handler().postDelayed({
|
|
162
|
+
val intent = intent
|
|
163
|
+
finish()
|
|
164
|
+
startActivity(intent)
|
|
165
|
+
}, 500)
|
|
150
166
|
}
|
|
151
167
|
|
|
152
168
|
if (errorStatus.isNotEmpty()) {
|
|
169
|
+
val jsonObject = JSONObject()
|
|
170
|
+
jsonObject.put("error_description", errorStatus)
|
|
171
|
+
sendDataToRN(jsonObject.toString(), "cgm_transmitter_connection_failed")
|
|
172
|
+
|
|
153
173
|
binding.tvReason.visibility = View.VISIBLE
|
|
154
174
|
binding.tvReason.text = "Reason - ${errorStatus}"
|
|
155
175
|
} else {
|
|
@@ -213,6 +233,8 @@ class SearchTransmitterActivity : BaseBleActivity() {
|
|
|
213
233
|
if (transmitterDeviceInfo != null && !binding.tvReason.isVisible) {
|
|
214
234
|
manageErrorState(false, "")
|
|
215
235
|
} else {
|
|
236
|
+
sendDataToRN("", "cgm_transmitter_detection_failed")
|
|
237
|
+
|
|
216
238
|
manageErrorState(true, "")
|
|
217
239
|
}
|
|
218
240
|
Log.d("Search Transmitter Error--> ", "Search Transmitter Error--> scanEnd")
|
|
@@ -220,6 +242,7 @@ class SearchTransmitterActivity : BaseBleActivity() {
|
|
|
220
242
|
|
|
221
243
|
override fun bluetoothStateOFF() {
|
|
222
244
|
super.bluetoothStateOFF()
|
|
245
|
+
|
|
223
246
|
manageErrorState(true, "Bluetooth Off")
|
|
224
247
|
Log.d("Search Transmitter Error--> ", "Search Transmitter Error--> bluetoothStateOFF")
|
|
225
248
|
}
|
|
@@ -240,6 +263,7 @@ class SearchTransmitterActivity : BaseBleActivity() {
|
|
|
240
263
|
ProgressManagement.getInstance().dismissWait(this)
|
|
241
264
|
manageErrorState(true, "Bind Failure")
|
|
242
265
|
Log.d("Search Transmitter Error--> ", "Search Transmitter Error--> bindFail")
|
|
266
|
+
sendDataToRN("", "cgm_transmitter_connection_failed")
|
|
243
267
|
}
|
|
244
268
|
|
|
245
269
|
public override fun bindSuccess() {
|
|
@@ -254,54 +278,8 @@ class SearchTransmitterActivity : BaseBleActivity() {
|
|
|
254
278
|
binding.commonButton.btnProceed.alpha = 1.0f
|
|
255
279
|
binding.view2.background = ContextCompat.getDrawable(this, R.drawable.bg_green_progress)
|
|
256
280
|
binding.tvDivide2.setTextColor("#299D6B".toColorInt())
|
|
257
|
-
}
|
|
258
281
|
|
|
259
|
-
|
|
260
|
-
val dto: GlucoseLog = GlucoseLog()
|
|
261
|
-
dto.timeInMillis = glucose.getTimeInMillis()
|
|
262
|
-
dto.countdownMinutes = glucose.getCountdownMinutes()
|
|
263
|
-
dto.countdownHours = glucose.getCountdownHours()
|
|
264
|
-
dto.countdownDays = glucose.getCountdownDays()
|
|
265
|
-
dto.hypoglycemiaEarlyWarnMinutes = glucose.getHypoglycemiaEarlyWarnMinutes()
|
|
266
|
-
dto.showGlucoseMG = glucose.getShowGlucoseMG()
|
|
267
|
-
dto.glucoseId = glucose.getGlucoseId()
|
|
268
|
-
dto.name = glucose.getName()
|
|
269
|
-
dto.showGlucose = glucose.getShowGlucose()
|
|
270
|
-
dto.Ib = glucose.getIb()
|
|
271
|
-
dto.Iw = glucose.getIw()
|
|
272
|
-
dto.T = glucose.getT()
|
|
273
|
-
dto.year = glucose.getYear()
|
|
274
|
-
dto.month = glucose.getMonth()
|
|
275
|
-
dto.day = glucose.getDay()
|
|
276
|
-
dto.hour = glucose.getHour()
|
|
277
|
-
dto.minute = glucose.getMinute()
|
|
278
|
-
|
|
279
|
-
// Convert byte[] to List<Integer>
|
|
280
|
-
dto.bytes = ArrayList()
|
|
281
|
-
for (b in glucose.getBytes()) {
|
|
282
|
-
dto.bytes?.add(b.toInt() and 0xFF) // Prevent negative values
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
// Trend
|
|
286
|
-
val trendObj: TrendObject = TrendObject()
|
|
287
|
-
trendObj.trendId = glucose.getTrend().getTrendId()
|
|
288
|
-
trendObj.drawableId = glucose.getTrend().getDrawableId()
|
|
289
|
-
trendObj.widgetImg = glucose.getTrend().getWidgetImg()
|
|
290
|
-
trendObj.apsChangeRate = glucose.getTrend().getApsChangeRate()
|
|
291
|
-
dto.trendObject = trendObj
|
|
292
|
-
|
|
293
|
-
// Status
|
|
294
|
-
val statusObj: GlucoseStatusObject = GlucoseStatusObject()
|
|
295
|
-
statusObj.statusId = glucose.getGlucoseStatus().getStatusId()
|
|
296
|
-
dto.glucoseStatusObject = statusObj
|
|
297
|
-
|
|
298
|
-
// Error
|
|
299
|
-
val errorObj: ErrorObject = ErrorObject()
|
|
300
|
-
errorObj.errorId = glucose.getErrorCode().getErrorId()
|
|
301
|
-
errorObj.sound = glucose.getErrorCode().getSound().toString()
|
|
302
|
-
dto.errorObject = errorObj
|
|
303
|
-
|
|
304
|
-
return dto
|
|
282
|
+
sendDataToRN("", "cgm_transmitter_connection_successful")
|
|
305
283
|
}
|
|
306
284
|
|
|
307
285
|
|
|
@@ -346,10 +324,15 @@ class SearchTransmitterActivity : BaseBleActivity() {
|
|
|
346
324
|
|
|
347
325
|
private fun setupClickListeners() {
|
|
348
326
|
binding.toolbar.btnWhatsapp.setOnClickListener {
|
|
349
|
-
startActivity(
|
|
327
|
+
startActivity(
|
|
328
|
+
Intent(this, HelpActivity::class.java)
|
|
329
|
+
.putExtra("ScreenName", "Transmitter Screen")
|
|
330
|
+
)
|
|
350
331
|
}
|
|
351
332
|
|
|
352
333
|
binding.toolbar.btnWatchDemo.setOnClickListener {
|
|
334
|
+
sendDataToRN("", "cgm_watch_demo_clicked")
|
|
335
|
+
|
|
353
336
|
startActivity(
|
|
354
337
|
Intent(this, VideoActivity::class.java).putExtra("VideoId", "r5Zemc4R044")
|
|
355
338
|
)
|
|
@@ -457,6 +440,41 @@ class SearchTransmitterActivity : BaseBleActivity() {
|
|
|
457
440
|
}
|
|
458
441
|
}
|
|
459
442
|
|
|
443
|
+
private fun sendDataToRN(data: String, status: String) {
|
|
444
|
+
if (reactContext != null) {
|
|
445
|
+
try {
|
|
446
|
+
val catalystInstance: CatalystInstance = reactContext.catalystInstance
|
|
447
|
+
val module = catalystInstance.getNativeModule(CgmTrackyLibModule::class.java)
|
|
448
|
+
|
|
449
|
+
if (module == null) {
|
|
450
|
+
sendDataToRNDirectly(data, status)
|
|
451
|
+
Log.d("sendDataToRN: ", "Module null")
|
|
452
|
+
} else {
|
|
453
|
+
module.sendDataToReact(data, status, "cgmDeviceEvent")
|
|
454
|
+
Log.d("sendDataToRN: ", "Module is not null")
|
|
455
|
+
}
|
|
456
|
+
} catch (e: Exception) {
|
|
457
|
+
Log.e("sendDataToRN: Error ", e.message.toString())
|
|
458
|
+
}
|
|
459
|
+
} else {
|
|
460
|
+
Log.e("TrackyActivity", "ReactApplicationContext is null")
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
|
|
465
|
+
private fun sendDataToRNDirectly(data: String, status: String) {
|
|
466
|
+
try {
|
|
467
|
+
val map: WritableMap = Arguments.createMap().apply {
|
|
468
|
+
putString("data", data)
|
|
469
|
+
putString("status", status)
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
reactContext?.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
|
|
473
|
+
?.emit("cgmDeviceEvent", map)
|
|
474
|
+
} catch (e: Exception) {
|
|
475
|
+
Log.e("sendDataToRNDirectly", "Error sending data to React", e)
|
|
476
|
+
}
|
|
477
|
+
}
|
|
460
478
|
|
|
461
479
|
fun logLongJson(tag: String, message: String) {
|
|
462
480
|
val maxLogSize = 4000
|
|
@@ -519,6 +537,8 @@ class SearchTransmitterActivity : BaseBleActivity() {
|
|
|
519
537
|
})
|
|
520
538
|
|
|
521
539
|
binding.searchingLayout.startAnimation(fadeOut)
|
|
540
|
+
|
|
541
|
+
sendDataToRN("", "cgm_transmitter_detected")
|
|
522
542
|
}
|
|
523
543
|
|
|
524
544
|
private fun connectToTransmitter() {
|
|
@@ -4,6 +4,7 @@ import android.app.Dialog
|
|
|
4
4
|
import android.content.Intent
|
|
5
5
|
import android.graphics.Color
|
|
6
6
|
import android.os.Bundle
|
|
7
|
+
import android.util.Log
|
|
7
8
|
import android.view.Gravity
|
|
8
9
|
import android.view.View
|
|
9
10
|
import android.view.ViewGroup
|
|
@@ -16,6 +17,10 @@ import androidx.core.view.ViewCompat
|
|
|
16
17
|
import androidx.core.view.WindowInsetsCompat
|
|
17
18
|
import cgmblelib.utils.SharedPreferencesLibraryUtil
|
|
18
19
|
import com.bumptech.glide.Glide
|
|
20
|
+
import com.facebook.react.bridge.Arguments
|
|
21
|
+
import com.facebook.react.bridge.CatalystInstance
|
|
22
|
+
import com.facebook.react.bridge.WritableMap
|
|
23
|
+
import com.facebook.react.modules.core.DeviceEventManagerModule
|
|
19
24
|
import com.mytatvarnsdk.R
|
|
20
25
|
import com.mytatvarnsdk.databinding.ActivitySensorConnectSuccessBinding
|
|
21
26
|
import com.mytatvarnsdk.databinding.ExitDialogBottomsheetBinding
|
|
@@ -41,6 +46,7 @@ class SensorConnectSuccessActivity : AppCompatActivity() {
|
|
|
41
46
|
private val job = Job()
|
|
42
47
|
private val scope = CoroutineScope(Dispatchers.IO + job)
|
|
43
48
|
private var isForReconnect: Boolean = false
|
|
49
|
+
private val reactContext = CgmTrackyLibModule.mReactContext
|
|
44
50
|
|
|
45
51
|
override fun onCreate(savedInstanceState: Bundle?) {
|
|
46
52
|
super.onCreate(savedInstanceState)
|
|
@@ -59,6 +65,8 @@ class SensorConnectSuccessActivity : AppCompatActivity() {
|
|
|
59
65
|
private fun init() {
|
|
60
66
|
isForReconnect = intent.getBooleanExtra("IsForReconnect", false)
|
|
61
67
|
|
|
68
|
+
sendDataToRN("", "cgm_sensor_connection_successful")
|
|
69
|
+
|
|
62
70
|
val formatter = SimpleDateFormat("hh:mm a", Locale.getDefault())
|
|
63
71
|
binding.tvDateTime.text = "Connected on ${formatter.format(Date()).uppercase()}"
|
|
64
72
|
|
|
@@ -70,16 +78,23 @@ class SensorConnectSuccessActivity : AppCompatActivity() {
|
|
|
70
78
|
authenticateSDKService = AuthenticateSDKService(scope = scope)
|
|
71
79
|
|
|
72
80
|
binding.toolbar.btnWhatsapp.setOnClickListener {
|
|
73
|
-
startActivity(
|
|
81
|
+
startActivity(
|
|
82
|
+
Intent(this, HelpActivity::class.java)
|
|
83
|
+
.putExtra("ScreenName", "Sensor Screen")
|
|
84
|
+
)
|
|
74
85
|
}
|
|
75
86
|
|
|
76
87
|
binding.toolbar.btnWatchDemo.setOnClickListener {
|
|
88
|
+
sendDataToRN("","cgm_watch_demo_clicked")
|
|
89
|
+
|
|
77
90
|
startActivity(
|
|
78
91
|
Intent(this, VideoActivity::class.java).putExtra("VideoId", "r5Zemc4R044")
|
|
79
92
|
)
|
|
80
93
|
}
|
|
81
94
|
|
|
82
95
|
binding.commonButton.btnProceed.setOnClickListener {
|
|
96
|
+
sendDataToRN("", "cgm_connect_sensor_proceed_clicked")
|
|
97
|
+
|
|
83
98
|
if (isForReconnect) {
|
|
84
99
|
startActivity(Intent(this, PlaceTransmitterActivity::class.java))
|
|
85
100
|
} else {
|
|
@@ -102,6 +117,42 @@ class SensorConnectSuccessActivity : AppCompatActivity() {
|
|
|
102
117
|
postEventDataToAPI()
|
|
103
118
|
}
|
|
104
119
|
|
|
120
|
+
private fun sendDataToRN(data: String, status: String) {
|
|
121
|
+
if (reactContext != null) {
|
|
122
|
+
try {
|
|
123
|
+
val catalystInstance: CatalystInstance = reactContext.catalystInstance
|
|
124
|
+
val module = catalystInstance.getNativeModule(CgmTrackyLibModule::class.java)
|
|
125
|
+
|
|
126
|
+
if (module == null) {
|
|
127
|
+
sendDataToRNDirectly(data, status)
|
|
128
|
+
Log.d("sendDataToRN: ", "Module null")
|
|
129
|
+
} else {
|
|
130
|
+
module.sendDataToReact(data, status, "cgmDeviceEvent")
|
|
131
|
+
Log.d("sendDataToRN: ", "Module is not null")
|
|
132
|
+
}
|
|
133
|
+
} catch (e: Exception) {
|
|
134
|
+
Log.e("sendDataToRN: Error ", e.message.toString())
|
|
135
|
+
}
|
|
136
|
+
} else {
|
|
137
|
+
Log.e("TrackyActivity", "ReactApplicationContext is null")
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
private fun sendDataToRNDirectly(data: String, status: String) {
|
|
143
|
+
try {
|
|
144
|
+
val map: WritableMap = Arguments.createMap().apply {
|
|
145
|
+
putString("data", data)
|
|
146
|
+
putString("status", status)
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
reactContext?.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
|
|
150
|
+
?.emit("cgmDeviceEvent", map)
|
|
151
|
+
} catch (e: Exception) {
|
|
152
|
+
Log.e("sendDataToRNDirectly", "Error sending data to React", e)
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
105
156
|
private fun postEventDataToAPI() {
|
|
106
157
|
val sharedPreferencesLibraryUtil = SharedPreferencesLibraryUtil(this)
|
|
107
158
|
val information = sharedPreferencesLibraryUtil.qrInformation
|
|
@@ -6,6 +6,7 @@ import android.content.pm.PackageManager
|
|
|
6
6
|
import android.graphics.Color
|
|
7
7
|
import android.os.Build
|
|
8
8
|
import android.os.Bundle
|
|
9
|
+
import android.util.Log
|
|
9
10
|
import android.view.Gravity
|
|
10
11
|
import android.view.View
|
|
11
12
|
import android.view.ViewGroup
|
|
@@ -17,15 +18,22 @@ import androidx.core.content.ContextCompat
|
|
|
17
18
|
import androidx.core.graphics.drawable.toDrawable
|
|
18
19
|
import androidx.core.view.ViewCompat
|
|
19
20
|
import androidx.core.view.WindowInsetsCompat
|
|
21
|
+
import com.facebook.react.bridge.Arguments
|
|
22
|
+
import com.facebook.react.bridge.CatalystInstance
|
|
23
|
+
import com.facebook.react.bridge.WritableMap
|
|
24
|
+
import com.facebook.react.modules.core.DeviceEventManagerModule
|
|
25
|
+
import com.mytatvarnsdk.CgmTrackyLibModule
|
|
20
26
|
import com.mytatvarnsdk.CgmTrackyLibModule.Companion.mReactContext
|
|
21
27
|
import com.mytatvarnsdk.R
|
|
22
28
|
import com.mytatvarnsdk.databinding.ActivityStartCgmactivityBinding
|
|
23
29
|
import com.mytatvarnsdk.databinding.ExitDialogBottomsheetBinding
|
|
30
|
+
import org.json.JSONObject
|
|
24
31
|
|
|
25
32
|
|
|
26
33
|
class StartCGMActivity : AppCompatActivity() {
|
|
27
34
|
private lateinit var binding: ActivityStartCgmactivityBinding
|
|
28
35
|
private var isForReconnect: Boolean = false
|
|
36
|
+
private val reactContext = CgmTrackyLibModule.mReactContext
|
|
29
37
|
|
|
30
38
|
override fun onCreate(savedInstanceState: Bundle?) {
|
|
31
39
|
super.onCreate(savedInstanceState)
|
|
@@ -44,6 +52,8 @@ class StartCGMActivity : AppCompatActivity() {
|
|
|
44
52
|
private fun init() {
|
|
45
53
|
isForReconnect = intent.getBooleanExtra("IsForReconnect", false)
|
|
46
54
|
|
|
55
|
+
sendDataToRN("", "cgm_start_connection_landing")
|
|
56
|
+
|
|
47
57
|
if (isForReconnect) {
|
|
48
58
|
binding.commonButton.tvProceed.text = "Start Reconnection Journey"
|
|
49
59
|
} else {
|
|
@@ -51,6 +61,8 @@ class StartCGMActivity : AppCompatActivity() {
|
|
|
51
61
|
}
|
|
52
62
|
|
|
53
63
|
binding.commonButton.btnProceed.setOnClickListener {
|
|
64
|
+
sendDataToRN("", "cgm_start_connection_journey_clicked")
|
|
65
|
+
|
|
54
66
|
if (isForReconnect) {
|
|
55
67
|
val intent = if (areAllPermissionsGranted()) {
|
|
56
68
|
Intent(this, SearchTransmitterActivity::class.java).putExtra(
|
|
@@ -75,10 +87,14 @@ class StartCGMActivity : AppCompatActivity() {
|
|
|
75
87
|
}
|
|
76
88
|
|
|
77
89
|
binding.toolbar.btnWhatsapp.setOnClickListener {
|
|
78
|
-
startActivity(
|
|
90
|
+
startActivity(
|
|
91
|
+
Intent(this, HelpActivity::class.java)
|
|
92
|
+
.putExtra("ScreenName", "Start CGM Screen")
|
|
93
|
+
)
|
|
79
94
|
}
|
|
80
95
|
|
|
81
96
|
binding.toolbar.btnWatchDemo.setOnClickListener {
|
|
97
|
+
sendDataToRN("", "cgm_watch_demo_clicked")
|
|
82
98
|
startActivity(
|
|
83
99
|
Intent(this, VideoActivity::class.java).putExtra("VideoId", "r5Zemc4R044")
|
|
84
100
|
)
|
|
@@ -142,4 +158,40 @@ class StartCGMActivity : AppCompatActivity() {
|
|
|
142
158
|
dialog.show()
|
|
143
159
|
}
|
|
144
160
|
|
|
161
|
+
private fun sendDataToRN(data: String, status: String) {
|
|
162
|
+
if (reactContext != null) {
|
|
163
|
+
try {
|
|
164
|
+
val catalystInstance: CatalystInstance = reactContext.catalystInstance
|
|
165
|
+
val module = catalystInstance.getNativeModule(CgmTrackyLibModule::class.java)
|
|
166
|
+
|
|
167
|
+
if (module == null) {
|
|
168
|
+
sendDataToRNDirectly(data, status)
|
|
169
|
+
Log.d("sendDataToRN: ", "Module null")
|
|
170
|
+
} else {
|
|
171
|
+
module.sendDataToReact(data, status, "cgmDeviceEvent")
|
|
172
|
+
Log.d("sendDataToRN: ", "Module is not null")
|
|
173
|
+
}
|
|
174
|
+
} catch (e: Exception) {
|
|
175
|
+
Log.e("sendDataToRN: Error ", e.message.toString())
|
|
176
|
+
}
|
|
177
|
+
} else {
|
|
178
|
+
Log.e("TrackyActivity", "ReactApplicationContext is null")
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
private fun sendDataToRNDirectly(data: String, status: String) {
|
|
184
|
+
try {
|
|
185
|
+
val map: WritableMap = Arguments.createMap().apply {
|
|
186
|
+
putString("data", data)
|
|
187
|
+
putString("status", status)
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
reactContext?.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
|
|
191
|
+
?.emit("cgmDeviceEvent", map)
|
|
192
|
+
} catch (e: Exception) {
|
|
193
|
+
Log.e("sendDataToRNDirectly", "Error sending data to React", e)
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
145
197
|
}
|