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
|
@@ -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,10 +92,15 @@ 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 {
|
|
102
|
+
sendDataToRN("", "cgm_watch_demo_clicked")
|
|
103
|
+
|
|
96
104
|
startActivity(
|
|
97
105
|
Intent(this, VideoActivity::class.java).putExtra("VideoId", "r5Zemc4R044")
|
|
98
106
|
)
|
|
@@ -146,10 +154,15 @@ class ConnectSensorActivity : BaseBleActivity() {
|
|
|
146
154
|
}
|
|
147
155
|
|
|
148
156
|
binding.btnSupport.btnProceed.setOnClickListener {
|
|
149
|
-
startActivity(
|
|
157
|
+
startActivity(
|
|
158
|
+
Intent(this, HelpActivity::class.java)
|
|
159
|
+
.putExtra("ScreenName", "Sensor Screen")
|
|
160
|
+
)
|
|
150
161
|
}
|
|
151
162
|
|
|
152
163
|
binding.btnRetry.btnProceed.setOnClickListener {
|
|
164
|
+
sendDataToRN("", "cgm_retry_connect_sensor_clicked")
|
|
165
|
+
|
|
153
166
|
transmitterDeviceInfo?.let {
|
|
154
167
|
QRActivity.startQR(
|
|
155
168
|
this,
|
|
@@ -159,6 +172,10 @@ class ConnectSensorActivity : BaseBleActivity() {
|
|
|
159
172
|
}
|
|
160
173
|
|
|
161
174
|
if (errorStatus.isNotEmpty()) {
|
|
175
|
+
val jsonObject = JSONObject()
|
|
176
|
+
jsonObject.put("error_description", errorStatus)
|
|
177
|
+
sendDataToRN(jsonObject.toString(), "cgm_sensor_connection_failed")
|
|
178
|
+
|
|
162
179
|
binding.tvReason.visibility = View.VISIBLE
|
|
163
180
|
binding.tvReason.text = "Reason - ${errorStatus}"
|
|
164
181
|
} else {
|
|
@@ -317,7 +334,7 @@ class ConnectSensorActivity : BaseBleActivity() {
|
|
|
317
334
|
super.bindSuccess()
|
|
318
335
|
ProgressManagement.getInstance().dismissWait(this)
|
|
319
336
|
if (isForReconnect) {
|
|
320
|
-
sendDataToRN("")
|
|
337
|
+
sendDataToRN("", "WARM_PERIOD_STARTED")
|
|
321
338
|
startActivity(
|
|
322
339
|
Intent(this, SensorConnectSuccessActivity::class.java)
|
|
323
340
|
.putExtra(
|
|
@@ -331,17 +348,17 @@ class ConnectSensorActivity : BaseBleActivity() {
|
|
|
331
348
|
finish()
|
|
332
349
|
}
|
|
333
350
|
|
|
334
|
-
private fun sendDataToRN(data: String) {
|
|
351
|
+
private fun sendDataToRN(data: String, status: String) {
|
|
335
352
|
if (reactContext != null) {
|
|
336
353
|
try {
|
|
337
354
|
val catalystInstance: CatalystInstance = reactContext.catalystInstance
|
|
338
355
|
val module = catalystInstance.getNativeModule(CgmTrackyLibModule::class.java)
|
|
339
356
|
|
|
340
357
|
if (module == null) {
|
|
341
|
-
sendDataToRNDirectly(
|
|
358
|
+
sendDataToRNDirectly(data, status)
|
|
342
359
|
Log.d("sendDataToRN: ", "Module null")
|
|
343
360
|
} else {
|
|
344
|
-
module.sendDataToReact(data,
|
|
361
|
+
module.sendDataToReact(data, status, "cgmDeviceEvent")
|
|
345
362
|
Log.d("sendDataToRN: ", "Module is not null")
|
|
346
363
|
}
|
|
347
364
|
} catch (e: Exception) {
|
|
@@ -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
|
}
|