react-native-mytatva-rn-sdk 1.2.44 → 1.2.46
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/CgmTrackyLibModule.kt +21 -4
- package/android/src/main/java/com/mytatvarnsdk/activity/ConnectSensorActivity.kt +18 -3
- package/android/src/main/java/com/mytatvarnsdk/activity/HelpActivity.kt +118 -59
- package/android/src/main/java/com/mytatvarnsdk/activity/PermissionActivity.kt +370 -351
- package/android/src/main/java/com/mytatvarnsdk/activity/PlaceSensorActivity.kt +7 -2
- package/android/src/main/java/com/mytatvarnsdk/activity/PlaceTransmitterActivity.kt +10 -4
- package/android/src/main/java/com/mytatvarnsdk/activity/SearchTransmitterActivity.kt +30 -53
- package/android/src/main/java/com/mytatvarnsdk/activity/SensorConnectSuccessActivity.kt +9 -2
- package/android/src/main/java/com/mytatvarnsdk/activity/StartCGMActivity.kt +11 -3
- package/android/src/main/java/com/mytatvarnsdk/model/BaseViewModel.java +1 -1
- package/ios/MyReactNativeBridge.m +60 -55
- package/ios/Support/API.swift +1 -1
- package/ios/ViewControllers/AttachTransmitterViewController.swift +1 -0
- package/ios/ViewControllers/ChatWithExpertViewController.swift +4 -0
- package/ios/ViewControllers/ConnectToSensorViewController.swift +1 -0
- package/ios/ViewControllers/ConnectToTransmitterViewController.swift +19 -6
- package/ios/ViewControllers/ProvidePermissionViewController.swift +3 -0
- package/ios/ViewControllers/PutOnTheSensorViewController.swift +1 -0
- package/ios/ViewControllers/StartConnectionViewController.swift +4 -2
- package/ios/ViewModel/FinalViewModel.swift +15 -22
- package/package.json +1 -1
|
@@ -262,7 +262,7 @@ class CgmTrackyLibModule(reactContext: ReactApplicationContext) :
|
|
|
262
262
|
put("transmitterName", device?.name ?: "")
|
|
263
263
|
put("SensorId", sensorId ?: "")
|
|
264
264
|
put("Sensor", sensorId ?: "")
|
|
265
|
-
put("timeInMillis",
|
|
265
|
+
put("timeInMillis", System.currentTimeMillis())
|
|
266
266
|
}
|
|
267
267
|
|
|
268
268
|
val obj = JSONObject().apply {
|
|
@@ -368,10 +368,22 @@ class CgmTrackyLibModule(reactContext: ReactApplicationContext) :
|
|
|
368
368
|
Handler(Looper.getMainLooper()).postDelayed({
|
|
369
369
|
// Create new observer with explicit nullable parameter type
|
|
370
370
|
glucoseObserver = Observer<PocGlucose?> { pocGlucose ->
|
|
371
|
-
|
|
371
|
+
val currentTime = System.currentTimeMillis()
|
|
372
|
+
var dataAge = System.currentTimeMillis()
|
|
373
|
+
|
|
374
|
+
if (prefsHelper.lastSyncData != null) {
|
|
375
|
+
dataAge = currentTime - prefsHelper.lastSyncData.timeInMillis
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
if ((pocGlucose != null && prefsHelper.lastSyncData == null) || (pocGlucose != null && prefsHelper.lastSyncData != null && dataAge <= 4 * 60 * 1000L)) {
|
|
372
379
|
handleGlucoseData(pocGlucose)
|
|
380
|
+
Log.d(
|
|
381
|
+
"observeGlucoseData",
|
|
382
|
+
"Received glucose data - processing"
|
|
383
|
+
)
|
|
373
384
|
} else {
|
|
374
|
-
|
|
385
|
+
observeAllGlucoseData(userToken)
|
|
386
|
+
Log.d(
|
|
375
387
|
"observeGlucoseData",
|
|
376
388
|
"Received null glucose data - skipping processing"
|
|
377
389
|
)
|
|
@@ -517,6 +529,11 @@ class CgmTrackyLibModule(reactContext: ReactApplicationContext) :
|
|
|
517
529
|
if (lastSyncData != null) {
|
|
518
530
|
CoroutineScope(Dispatchers.IO).launch {
|
|
519
531
|
val glucoseData = mModel.getGlucoseBetweenTime(lastSyncData.lastSyncTime)
|
|
532
|
+
|
|
533
|
+
Log.d("observeAllGlucoseData: ", glucoseData.toString())
|
|
534
|
+
Log.d("Last sync time: ", lastSyncData.lastSyncTime.toString())
|
|
535
|
+
Log.d("current time: ", System.currentTimeMillis().toString())
|
|
536
|
+
|
|
520
537
|
if (glucoseData != null && glucoseData.isNotEmpty()) {
|
|
521
538
|
processBatchDataAndStartObserver(glucoseData)
|
|
522
539
|
} else {
|
|
@@ -778,7 +795,7 @@ class CgmTrackyLibModule(reactContext: ReactApplicationContext) :
|
|
|
778
795
|
lastRecord?.let {
|
|
779
796
|
try {
|
|
780
797
|
val syncData = SyncMeta(
|
|
781
|
-
|
|
798
|
+
System.currentTimeMillis(),
|
|
782
799
|
it.timeInMillis,
|
|
783
800
|
it.deviceId,
|
|
784
801
|
it.glucoseId
|
|
@@ -36,6 +36,7 @@ import com.mytatvarnsdk.databinding.ActivityConnectSensorBinding
|
|
|
36
36
|
import com.mytatvarnsdk.databinding.ExitDialogBottomsheetBinding
|
|
37
37
|
import com.mytatvarnsdk.myView.progress.ProgressManagement
|
|
38
38
|
import com.mytatvarnsdk.myView.progress.ProgressType
|
|
39
|
+
import org.json.JSONObject
|
|
39
40
|
|
|
40
41
|
|
|
41
42
|
class ConnectSensorActivity : BaseBleActivity() {
|
|
@@ -75,6 +76,8 @@ class ConnectSensorActivity : BaseBleActivity() {
|
|
|
75
76
|
intent.getSerializableExtra("transmitterDeviceInfo") as PocDeviceAndRssi?
|
|
76
77
|
isForReconnect = intent.getBooleanExtra("IsForReconnect", false)
|
|
77
78
|
|
|
79
|
+
sendDataToRN("", "cgm_connect_sensor_scan_landing")
|
|
80
|
+
|
|
78
81
|
binding.commonButton.btnProceed.setOnClickListener {
|
|
79
82
|
transmitterDeviceInfo?.let {
|
|
80
83
|
QRActivity.startQR(
|
|
@@ -89,7 +92,10 @@ class ConnectSensorActivity : BaseBleActivity() {
|
|
|
89
92
|
}
|
|
90
93
|
|
|
91
94
|
binding.toolbar.btnWhatsapp.setOnClickListener {
|
|
92
|
-
startActivity(
|
|
95
|
+
startActivity(
|
|
96
|
+
Intent(this, HelpActivity::class.java)
|
|
97
|
+
.putExtra("ScreenName", "Sensor Screen")
|
|
98
|
+
)
|
|
93
99
|
}
|
|
94
100
|
|
|
95
101
|
binding.toolbar.btnWatchDemo.setOnClickListener {
|
|
@@ -148,10 +154,15 @@ class ConnectSensorActivity : BaseBleActivity() {
|
|
|
148
154
|
}
|
|
149
155
|
|
|
150
156
|
binding.btnSupport.btnProceed.setOnClickListener {
|
|
151
|
-
startActivity(
|
|
157
|
+
startActivity(
|
|
158
|
+
Intent(this, HelpActivity::class.java)
|
|
159
|
+
.putExtra("ScreenName", "Sensor Screen")
|
|
160
|
+
)
|
|
152
161
|
}
|
|
153
162
|
|
|
154
163
|
binding.btnRetry.btnProceed.setOnClickListener {
|
|
164
|
+
sendDataToRN("", "cgm_retry_connect_sensor_clicked")
|
|
165
|
+
|
|
155
166
|
transmitterDeviceInfo?.let {
|
|
156
167
|
QRActivity.startQR(
|
|
157
168
|
this,
|
|
@@ -161,6 +172,10 @@ class ConnectSensorActivity : BaseBleActivity() {
|
|
|
161
172
|
}
|
|
162
173
|
|
|
163
174
|
if (errorStatus.isNotEmpty()) {
|
|
175
|
+
val jsonObject = JSONObject()
|
|
176
|
+
jsonObject.put("error_description", errorStatus)
|
|
177
|
+
sendDataToRN(jsonObject.toString(), "cgm_sensor_connection_failed")
|
|
178
|
+
|
|
164
179
|
binding.tvReason.visibility = View.VISIBLE
|
|
165
180
|
binding.tvReason.text = "Reason - ${errorStatus}"
|
|
166
181
|
} else {
|
|
@@ -340,7 +355,7 @@ class ConnectSensorActivity : BaseBleActivity() {
|
|
|
340
355
|
val module = catalystInstance.getNativeModule(CgmTrackyLibModule::class.java)
|
|
341
356
|
|
|
342
357
|
if (module == null) {
|
|
343
|
-
sendDataToRNDirectly(
|
|
358
|
+
sendDataToRNDirectly(data, status)
|
|
344
359
|
Log.d("sendDataToRN: ", "Module null")
|
|
345
360
|
} else {
|
|
346
361
|
module.sendDataToReact(data, status, "cgmDeviceEvent")
|
|
@@ -3,96 +3,155 @@ package com.mytatvarnsdk.activity
|
|
|
3
3
|
import android.content.Intent
|
|
4
4
|
import android.net.Uri
|
|
5
5
|
import android.os.Bundle
|
|
6
|
+
import android.util.Log
|
|
7
|
+
import android.widget.RadioButton
|
|
6
8
|
import android.widget.Toast
|
|
7
9
|
import androidx.activity.OnBackPressedCallback
|
|
8
10
|
import androidx.activity.enableEdgeToEdge
|
|
9
11
|
import androidx.appcompat.app.AppCompatActivity
|
|
10
12
|
import androidx.core.view.ViewCompat
|
|
11
13
|
import androidx.core.view.WindowInsetsCompat
|
|
14
|
+
import com.facebook.react.bridge.Arguments
|
|
15
|
+
import com.facebook.react.bridge.CatalystInstance
|
|
16
|
+
import com.facebook.react.bridge.WritableMap
|
|
17
|
+
import com.facebook.react.modules.core.DeviceEventManagerModule
|
|
18
|
+
import com.mytatvarnsdk.CgmTrackyLibModule
|
|
12
19
|
import com.mytatvarnsdk.R
|
|
13
20
|
import com.mytatvarnsdk.databinding.ActivityHelpBinding
|
|
21
|
+
import org.json.JSONObject
|
|
14
22
|
|
|
15
23
|
class HelpActivity : AppCompatActivity() {
|
|
16
|
-
|
|
24
|
+
private lateinit var binding: ActivityHelpBinding
|
|
25
|
+
private val reactContext = CgmTrackyLibModule.mReactContext
|
|
17
26
|
|
|
18
|
-
override fun onCreate(savedInstanceState: Bundle?) {
|
|
19
|
-
super.onCreate(savedInstanceState)
|
|
20
|
-
binding = ActivityHelpBinding.inflate(layoutInflater)
|
|
21
|
-
setContentView(binding.root)
|
|
22
27
|
|
|
23
|
-
|
|
28
|
+
override fun onCreate(savedInstanceState: Bundle?) {
|
|
29
|
+
super.onCreate(savedInstanceState)
|
|
30
|
+
binding = ActivityHelpBinding.inflate(layoutInflater)
|
|
31
|
+
setContentView(binding.root)
|
|
24
32
|
|
|
25
|
-
|
|
26
|
-
val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
|
|
27
|
-
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
|
|
28
|
-
insets
|
|
29
|
-
}
|
|
33
|
+
enableEdgeToEdge()
|
|
30
34
|
|
|
31
|
-
|
|
32
|
-
|
|
35
|
+
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { v, insets ->
|
|
36
|
+
val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
|
|
37
|
+
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
|
|
38
|
+
insets
|
|
39
|
+
}
|
|
33
40
|
|
|
34
|
-
|
|
35
|
-
binding.btnProceed.setOnClickListener {
|
|
36
|
-
openWhatsApp()
|
|
41
|
+
init()
|
|
37
42
|
}
|
|
38
43
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
44
|
+
private fun init() {
|
|
45
|
+
val jsonObject = JSONObject()
|
|
46
|
+
jsonObject.put("screen_name", intent.getStringExtra("ScreenName"))
|
|
47
|
+
sendDataToRN(jsonObject.toString(), "cgm_WA_support_clicked")
|
|
42
48
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
49
|
+
binding.btnProceed.setOnClickListener {
|
|
50
|
+
val selectedRadioButtonId = binding.helpOptionsGroup.checkedRadioButtonId
|
|
51
|
+
|
|
52
|
+
if (selectedRadioButtonId != -1) {
|
|
53
|
+
val selectedRadioButton = findViewById<RadioButton>(selectedRadioButtonId)
|
|
54
|
+
val selectedText = selectedRadioButton.text.toString()
|
|
46
55
|
|
|
47
|
-
|
|
56
|
+
val jsonObject = JSONObject()
|
|
57
|
+
jsonObject.put("help", selectedText)
|
|
58
|
+
sendDataToRN(jsonObject.toString(), "cgm_WA_support_proceed_clicked")
|
|
59
|
+
}
|
|
48
60
|
|
|
49
|
-
|
|
50
|
-
when (checkedId) {
|
|
51
|
-
R.id.radio_purchase -> {
|
|
52
|
-
enableDisableBtn(true)
|
|
61
|
+
openWhatsApp()
|
|
53
62
|
}
|
|
54
63
|
|
|
55
|
-
|
|
56
|
-
|
|
64
|
+
binding.ivBack.setOnClickListener {
|
|
65
|
+
finish()
|
|
57
66
|
}
|
|
58
67
|
|
|
59
|
-
|
|
60
|
-
|
|
68
|
+
binding.tvBack.setOnClickListener {
|
|
69
|
+
finish()
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
enableDisableBtn(false)
|
|
73
|
+
|
|
74
|
+
binding.helpOptionsGroup.setOnCheckedChangeListener { group, checkedId ->
|
|
75
|
+
when (checkedId) {
|
|
76
|
+
R.id.radio_purchase -> {
|
|
77
|
+
enableDisableBtn(true)
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
R.id.radio_connect -> {
|
|
81
|
+
enableDisableBtn(true)
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
R.id.radio_troubles -> {
|
|
85
|
+
enableDisableBtn(true)
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
else -> {
|
|
89
|
+
enableDisableBtn(false)
|
|
90
|
+
}
|
|
91
|
+
}
|
|
61
92
|
}
|
|
62
93
|
|
|
63
|
-
|
|
64
|
-
|
|
94
|
+
val callback: OnBackPressedCallback = object : OnBackPressedCallback(true) {
|
|
95
|
+
override fun handleOnBackPressed() {
|
|
96
|
+
finish()
|
|
97
|
+
}
|
|
65
98
|
}
|
|
66
|
-
|
|
99
|
+
onBackPressedDispatcher.addCallback(this, callback)
|
|
67
100
|
}
|
|
68
101
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
102
|
+
fun enableDisableBtn(isEnable: Boolean) {
|
|
103
|
+
binding.btnProceed.isEnabled = isEnable
|
|
104
|
+
if (isEnable) {
|
|
105
|
+
binding.btnProceed.alpha = 1f
|
|
106
|
+
} else {
|
|
107
|
+
binding.btnProceed.alpha = 0.5f
|
|
108
|
+
}
|
|
73
109
|
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
110
|
+
|
|
111
|
+
private fun openWhatsApp() {
|
|
112
|
+
val waBotUrl = "https://wa.aisensy.com/aaa1qv"
|
|
113
|
+
val intent = Intent(Intent.ACTION_VIEW, Uri.parse(waBotUrl))
|
|
114
|
+
try {
|
|
115
|
+
// You don't need to set the package for browser-based WhatsApp bots
|
|
116
|
+
startActivity(intent)
|
|
117
|
+
} catch (e: Exception) {
|
|
118
|
+
e.printStackTrace()
|
|
119
|
+
Toast.makeText(this, "Error opening WhatsApp Bot", Toast.LENGTH_SHORT).show()
|
|
120
|
+
}
|
|
83
121
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
122
|
+
|
|
123
|
+
private fun sendDataToRN(data: String, status: String) {
|
|
124
|
+
if (reactContext != null) {
|
|
125
|
+
try {
|
|
126
|
+
val catalystInstance: CatalystInstance = reactContext.catalystInstance
|
|
127
|
+
val module = catalystInstance.getNativeModule(CgmTrackyLibModule::class.java)
|
|
128
|
+
|
|
129
|
+
if (module == null) {
|
|
130
|
+
sendDataToRNDirectly(data, status)
|
|
131
|
+
Log.d("sendDataToRN: ", "Module null")
|
|
132
|
+
} else {
|
|
133
|
+
module.sendDataToReact(data, status, "cgmDeviceEvent")
|
|
134
|
+
Log.d("sendDataToRN: ", "Module is not null")
|
|
135
|
+
}
|
|
136
|
+
} catch (e: Exception) {
|
|
137
|
+
Log.e("sendDataToRN: Error ", e.message.toString())
|
|
138
|
+
}
|
|
139
|
+
} else {
|
|
140
|
+
Log.e("TrackyActivity", "ReactApplicationContext is null")
|
|
141
|
+
}
|
|
95
142
|
}
|
|
96
|
-
}
|
|
97
143
|
|
|
144
|
+
private fun sendDataToRNDirectly(data: String, status: String) {
|
|
145
|
+
try {
|
|
146
|
+
val map: WritableMap = Arguments.createMap().apply {
|
|
147
|
+
putString("data", data)
|
|
148
|
+
putString("status", status)
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
reactContext?.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
|
|
152
|
+
?.emit("cgmDeviceEvent", map)
|
|
153
|
+
} catch (e: Exception) {
|
|
154
|
+
Log.e("sendDataToRNDirectly", "Error sending data to React", e)
|
|
155
|
+
}
|
|
156
|
+
}
|
|
98
157
|
}
|