react-native-mytatva-rn-sdk 1.2.8 → 1.2.10
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 +16 -9
- package/android/src/main/java/com/mytatvarnsdk/activity/PermissionActivity.kt +37 -3
- package/android/src/main/java/com/mytatvarnsdk/activity/SearchTransmitterActivity.kt +416 -408
- package/android/src/main/res/layout/activity_connect_sensor.xml +18 -1
- package/android/src/main/res/layout/activity_search_transmitter.xml +19 -1
- package/ios/MyReactNativeBridge.h +2 -2
- package/ios/MyReactNativeBridge.m +14 -14
- package/ios/Support/Global.swift +1 -1
- package/ios/VisitRnSdk.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
- package/ios/VisitRnSdk.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
- package/ios/VisitRnSdk.xcodeproj/xcuserdata/sonusharma.xcuserdatad/xcschemes/xcschememanagement.plist +14 -0
- package/lib/commonjs/CGMConnect.js +10 -14
- package/lib/commonjs/CGMConnect.js.map +1 -1
- package/lib/module/CGMConnect.js +10 -14
- package/lib/module/CGMConnect.js.map +1 -1
- package/package.json +1 -1
- package/src/CGMConnect.ts +22 -19
- /package/ios/Storyboard/Base.lproj/{Main.storyboard → MainCGM.storyboard} +0 -0
|
@@ -20,6 +20,7 @@ import androidx.core.graphics.drawable.toDrawable
|
|
|
20
20
|
import androidx.core.graphics.toColorInt
|
|
21
21
|
import androidx.core.view.ViewCompat
|
|
22
22
|
import androidx.core.view.WindowInsetsCompat
|
|
23
|
+
import androidx.core.view.isVisible
|
|
23
24
|
import androidx.lifecycle.ViewModelProviders
|
|
24
25
|
import cgmblelib.Enum.enumDevice
|
|
25
26
|
import cgmblelib.ble.BleService
|
|
@@ -57,299 +58,306 @@ import java.util.Date
|
|
|
57
58
|
import java.util.Locale
|
|
58
59
|
|
|
59
60
|
class SearchTransmitterActivity : BaseBleActivity() {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
61
|
+
private lateinit var binding: ActivitySearchTransmitterBinding
|
|
62
|
+
private val handler = Handler(Looper.getMainLooper())
|
|
63
|
+
private var isSearching = true
|
|
64
|
+
private var isTransmitterConnected = false
|
|
65
|
+
private var transmitterDeviceInfo: PocDeviceAndRssi? = null
|
|
66
|
+
private lateinit var mModel: MainActivityModel
|
|
67
|
+
lateinit var authenticateSDKService: AuthenticateSDKService
|
|
68
|
+
private val job = Job()
|
|
69
|
+
private val scope = CoroutineScope(Dispatchers.IO + job)
|
|
70
|
+
private var isForReconnect: Boolean = false
|
|
71
|
+
private val reactContext = CgmTrackyLibModule.mReactContext
|
|
72
|
+
|
|
73
|
+
override fun init() {
|
|
74
|
+
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
override fun onCreate(savedInstanceState: Bundle?) {
|
|
79
|
+
super.onCreate(savedInstanceState)
|
|
80
|
+
binding = ActivitySearchTransmitterBinding.inflate(layoutInflater)
|
|
81
|
+
enableEdgeToEdge()
|
|
82
|
+
setContentView(binding.root)
|
|
83
|
+
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { v, insets ->
|
|
84
|
+
val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
|
|
85
|
+
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
|
|
86
|
+
insets
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
setupClickListeners()
|
|
90
|
+
setupInitialState()
|
|
91
|
+
startDeviceSearch()
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
override fun getPermission(): Array<out Array<out String?>?>? {
|
|
95
|
+
return arrayOfNulls<Array<String?>>(0)
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
override fun onPermissionRequestSuccess() {
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
override fun onPermissionRequestFail(vararg permission: String?) {
|
|
102
|
+
}
|
|
73
103
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
override fun onCreate(savedInstanceState: Bundle?) {
|
|
78
|
-
super.onCreate(savedInstanceState)
|
|
79
|
-
binding = ActivitySearchTransmitterBinding.inflate(layoutInflater)
|
|
80
|
-
enableEdgeToEdge()
|
|
81
|
-
setContentView(binding.root)
|
|
82
|
-
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { v, insets ->
|
|
83
|
-
val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
|
|
84
|
-
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
|
|
85
|
-
insets
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
setupClickListeners()
|
|
89
|
-
setupInitialState()
|
|
90
|
-
startDeviceSearch()
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
override fun getPermission(): Array<out Array<out String?>?>? {
|
|
94
|
-
return arrayOfNulls<Array<String?>>(0)
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
override fun onPermissionRequestSuccess() {
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
override fun onPermissionRequestFail(vararg permission: String?) {
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
override fun onPermissionRequestFailForever(vararg permission: String?) {
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
private fun setupInitialState() {
|
|
107
|
-
isForReconnect = intent.getBooleanExtra("IsForReconnect", false)
|
|
108
|
-
|
|
109
|
-
// Set initial states
|
|
110
|
-
binding.searchingLayout.visibility = View.VISIBLE
|
|
111
|
-
binding.connectedLayout.visibility = View.GONE
|
|
112
|
-
|
|
113
|
-
binding.commonButton.btnProceed.isEnabled = false
|
|
114
|
-
binding.commonButton.btnProceed.alpha = 0.5f
|
|
115
|
-
|
|
116
|
-
Glide.with(this)
|
|
117
|
-
.asGif()
|
|
118
|
-
.load(R.drawable.success_anim)
|
|
119
|
-
.into(binding.ivSuccess)
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
fun manageErrorState(showError: Boolean) {
|
|
123
|
-
if (showError) {
|
|
124
|
-
binding.clFail.visibility = View.VISIBLE
|
|
125
|
-
binding.clMain.visibility = View.GONE
|
|
126
|
-
binding.commonButton.root.visibility = View.GONE
|
|
127
|
-
|
|
128
|
-
Glide.with(this)
|
|
129
|
-
.asGif()
|
|
130
|
-
.load(R.drawable.warning)
|
|
131
|
-
.into(binding.ivGif)
|
|
132
|
-
|
|
133
|
-
binding.btnSupport.tvProceed.text = "Contact Support"
|
|
134
|
-
binding.btnRetry.tvProceed.text = "Retry"
|
|
135
|
-
|
|
136
|
-
binding.btnWatchDemo.setOnClickListener {
|
|
137
|
-
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
binding.btnSupport.btnProceed.setOnClickListener {
|
|
141
|
-
startActivity(Intent(this, HelpActivity::class.java))
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
binding.btnRetry.btnProceed.setOnClickListener {
|
|
145
|
-
val intent = intent
|
|
146
|
-
finish()
|
|
147
|
-
startActivity(intent)
|
|
148
|
-
}
|
|
149
|
-
} else {
|
|
150
|
-
binding.commonButton.root.visibility = View.VISIBLE
|
|
151
|
-
binding.clFail.visibility = View.GONE
|
|
152
|
-
binding.clMain.visibility = View.VISIBLE
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
private fun openExitDialog() {
|
|
157
|
-
val binding = ExitDialogBottomsheetBinding.inflate(layoutInflater)
|
|
158
|
-
|
|
159
|
-
val dialog = Dialog(this)
|
|
160
|
-
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE)
|
|
161
|
-
dialog.setContentView(binding.root)
|
|
162
|
-
|
|
163
|
-
val window = dialog.window
|
|
164
|
-
window?.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)
|
|
165
|
-
window?.setGravity(Gravity.BOTTOM)
|
|
166
|
-
window?.setBackgroundDrawable(Color.TRANSPARENT.toDrawable())
|
|
167
|
-
|
|
168
|
-
binding.btnExit.tvProceed.text = "Exit"
|
|
169
|
-
|
|
170
|
-
binding.btnExit.root.setOnClickListener(View.OnClickListener { v: View? ->
|
|
171
|
-
finish()
|
|
172
|
-
dialog.dismiss()
|
|
173
|
-
})
|
|
174
|
-
|
|
175
|
-
binding.btnCancel.root.setOnClickListener(View.OnClickListener { v: View? ->
|
|
176
|
-
dialog.dismiss()
|
|
177
|
-
})
|
|
178
|
-
|
|
179
|
-
binding.closeButton.setOnClickListener(View.OnClickListener { v: View? ->
|
|
180
|
-
dialog.dismiss()
|
|
181
|
-
})
|
|
182
|
-
|
|
183
|
-
dialog.show()
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
public override fun scanStart() {
|
|
188
|
-
if (mPocDevice != null && mPocDevice.isBound) {
|
|
189
|
-
ProgressManagement.getInstance().showWait(this, ProgressType.PROGRESSDIALOG_SCAN, null)
|
|
190
|
-
}
|
|
191
|
-
manageErrorState(false)
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
public override fun scanIn(device: PocDeviceAndRssi) {
|
|
196
|
-
transmitterDeviceInfo = device
|
|
197
|
-
if (isSearching) {
|
|
198
|
-
deviceDetected(device)
|
|
199
|
-
}
|
|
200
|
-
manageErrorState(false)
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
public override fun scanEnd() {
|
|
204
|
-
if (transmitterDeviceInfo == null) {
|
|
205
|
-
manageErrorState(true)
|
|
206
|
-
}
|
|
207
|
-
Log.d("Search Transmitter Error--> ", "Search Transmitter Error--> scanEnd")
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
override fun bluetoothStateOFF() {
|
|
211
|
-
super.bluetoothStateOFF()
|
|
212
|
-
manageErrorState(true)
|
|
213
|
-
Log.d("Search Transmitter Error--> ", "Search Transmitter Error--> bluetoothStateOFF")
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
override fun failGPS() {
|
|
217
|
-
super.failGPS()
|
|
218
|
-
manageErrorState(true)
|
|
219
|
-
Log.d("Search Transmitter Error--> ", "Search Transmitter Error--> failGPS")
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
override fun failLocal() {
|
|
223
|
-
super.failLocal()
|
|
224
|
-
manageErrorState(true)
|
|
225
|
-
Log.d("Search Transmitter Error--> ", "Search Transmitter Error--> failLocal")
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
public override fun bindFail() {
|
|
229
|
-
ProgressManagement.getInstance().dismissWait(this)
|
|
230
|
-
manageErrorState(true)
|
|
231
|
-
Log.d("Search Transmitter Error--> ", "Search Transmitter Error--> bindFail")
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
public override fun bindSuccess() {
|
|
235
|
-
ProgressManagement.getInstance().dismissWait(this)
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
fun mapToDto(glucose: PocGlucose): GlucoseLog {
|
|
239
|
-
val dto: GlucoseLog = GlucoseLog()
|
|
240
|
-
dto.timeInMillis = glucose.getTimeInMillis()
|
|
241
|
-
dto.countdownMinutes = glucose.getCountdownMinutes()
|
|
242
|
-
dto.countdownHours = glucose.getCountdownHours()
|
|
243
|
-
dto.countdownDays = glucose.getCountdownDays()
|
|
244
|
-
dto.hypoglycemiaEarlyWarnMinutes = glucose.getHypoglycemiaEarlyWarnMinutes()
|
|
245
|
-
dto.showGlucoseMG = glucose.getShowGlucoseMG()
|
|
246
|
-
dto.glucoseId = glucose.getGlucoseId()
|
|
247
|
-
dto.name = glucose.getName()
|
|
248
|
-
dto.showGlucose = glucose.getShowGlucose()
|
|
249
|
-
dto.Ib = glucose.getIb()
|
|
250
|
-
dto.Iw = glucose.getIw()
|
|
251
|
-
dto.T = glucose.getT()
|
|
252
|
-
dto.year = glucose.getYear()
|
|
253
|
-
dto.month = glucose.getMonth()
|
|
254
|
-
dto.day = glucose.getDay()
|
|
255
|
-
dto.hour = glucose.getHour()
|
|
256
|
-
dto.minute = glucose.getMinute()
|
|
257
|
-
|
|
258
|
-
// Convert byte[] to List<Integer>
|
|
259
|
-
dto.bytes = ArrayList()
|
|
260
|
-
for (b in glucose.getBytes()) {
|
|
261
|
-
dto.bytes?.add(b.toInt() and 0xFF) // Prevent negative values
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
// Trend
|
|
265
|
-
val trendObj: TrendObject = TrendObject()
|
|
266
|
-
trendObj.trendId = glucose.getTrend().getTrendId()
|
|
267
|
-
trendObj.drawableId = glucose.getTrend().getDrawableId()
|
|
268
|
-
trendObj.widgetImg = glucose.getTrend().getWidgetImg()
|
|
269
|
-
trendObj.apsChangeRate = glucose.getTrend().getApsChangeRate()
|
|
270
|
-
dto.trendObject = trendObj
|
|
271
|
-
|
|
272
|
-
// Status
|
|
273
|
-
val statusObj: GlucoseStatusObject = GlucoseStatusObject()
|
|
274
|
-
statusObj.statusId = glucose.getGlucoseStatus().getStatusId()
|
|
275
|
-
dto.glucoseStatusObject = statusObj
|
|
276
|
-
|
|
277
|
-
// Error
|
|
278
|
-
val errorObj: ErrorObject = ErrorObject()
|
|
279
|
-
errorObj.errorId = glucose.getErrorCode().getErrorId()
|
|
280
|
-
errorObj.sound = glucose.getErrorCode().getSound().toString()
|
|
281
|
-
dto.errorObject = errorObj
|
|
282
|
-
|
|
283
|
-
return dto
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
public override fun disconnect() {
|
|
288
|
-
ProgressManagement.getInstance().dismissWait(this)
|
|
289
|
-
showShortToast(R.string.bt_connect_fail)
|
|
290
|
-
manageErrorState(true)
|
|
291
|
-
}
|
|
104
|
+
override fun onPermissionRequestFailForever(vararg permission: String?) {
|
|
105
|
+
}
|
|
292
106
|
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
manageErrorState(true)
|
|
296
|
-
Log.d("Search Transmitter Error--> ", "Search Transmitter Error--> disconnectForTimeout")
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
public override fun checkFailForLowPower() {
|
|
300
|
-
ProgressManagement.getInstance().dismissWait(this)
|
|
301
|
-
WarnDialogUtils.getInstance().showWarnDialog(this, DialogType.TYPE_LOW_POWER)
|
|
302
|
-
}
|
|
107
|
+
private fun setupInitialState() {
|
|
108
|
+
isForReconnect = intent.getBooleanExtra("IsForReconnect", false)
|
|
303
109
|
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
110
|
+
// Set initial states
|
|
111
|
+
binding.searchingLayout.visibility = View.VISIBLE
|
|
112
|
+
binding.connectedLayout.visibility = View.GONE
|
|
307
113
|
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
}
|
|
114
|
+
binding.commonButton.btnProceed.isEnabled = false
|
|
115
|
+
binding.commonButton.btnProceed.alpha = 0.5f
|
|
311
116
|
|
|
117
|
+
Glide.with(this)
|
|
118
|
+
.asGif()
|
|
119
|
+
.load(R.drawable.success_anim)
|
|
120
|
+
.into(binding.ivSuccess)
|
|
121
|
+
}
|
|
312
122
|
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
123
|
+
fun manageErrorState(showError: Boolean, errorStatus: String) {
|
|
124
|
+
if (showError) {
|
|
125
|
+
binding.clFail.visibility = View.VISIBLE
|
|
126
|
+
binding.clMain.visibility = View.GONE
|
|
127
|
+
binding.commonButton.root.visibility = View.GONE
|
|
128
|
+
|
|
129
|
+
Glide.with(this)
|
|
130
|
+
.asGif()
|
|
131
|
+
.load(R.drawable.warning)
|
|
132
|
+
.into(binding.ivGif)
|
|
133
|
+
|
|
134
|
+
binding.btnSupport.tvProceed.text = "Contact Support"
|
|
135
|
+
binding.btnRetry.tvProceed.text = "Retry"
|
|
136
|
+
|
|
137
|
+
binding.btnWatchDemo.setOnClickListener {
|
|
138
|
+
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
binding.btnSupport.btnProceed.setOnClickListener {
|
|
142
|
+
startActivity(Intent(this, HelpActivity::class.java))
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
binding.btnRetry.btnProceed.setOnClickListener {
|
|
146
|
+
val intent = intent
|
|
147
|
+
finish()
|
|
148
|
+
startActivity(intent)
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
if (errorStatus.isNotEmpty()) {
|
|
152
|
+
binding.tvReason.visibility = View.VISIBLE
|
|
153
|
+
binding.tvReason.text = "Reason - ${errorStatus}"
|
|
154
|
+
} else {
|
|
155
|
+
binding.tvReason.visibility = View.GONE
|
|
156
|
+
}
|
|
157
|
+
} else {
|
|
158
|
+
binding.commonButton.root.visibility = View.VISIBLE
|
|
159
|
+
binding.clFail.visibility = View.GONE
|
|
160
|
+
binding.clMain.visibility = View.VISIBLE
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
private fun openExitDialog() {
|
|
165
|
+
val binding = ExitDialogBottomsheetBinding.inflate(layoutInflater)
|
|
166
|
+
|
|
167
|
+
val dialog = Dialog(this)
|
|
168
|
+
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE)
|
|
169
|
+
dialog.setContentView(binding.root)
|
|
170
|
+
|
|
171
|
+
val window = dialog.window
|
|
172
|
+
window?.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)
|
|
173
|
+
window?.setGravity(Gravity.BOTTOM)
|
|
174
|
+
window?.setBackgroundDrawable(Color.TRANSPARENT.toDrawable())
|
|
175
|
+
|
|
176
|
+
binding.btnExit.tvProceed.text = "Exit"
|
|
177
|
+
|
|
178
|
+
binding.btnExit.root.setOnClickListener(View.OnClickListener { v: View? ->
|
|
179
|
+
finish()
|
|
180
|
+
dialog.dismiss()
|
|
181
|
+
})
|
|
182
|
+
|
|
183
|
+
binding.btnCancel.root.setOnClickListener(View.OnClickListener { v: View? ->
|
|
184
|
+
dialog.dismiss()
|
|
185
|
+
})
|
|
186
|
+
|
|
187
|
+
binding.closeButton.setOnClickListener(View.OnClickListener { v: View? ->
|
|
188
|
+
dialog.dismiss()
|
|
189
|
+
})
|
|
190
|
+
|
|
191
|
+
dialog.show()
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
public override fun scanStart() {
|
|
196
|
+
if (mPocDevice != null && mPocDevice.isBound) {
|
|
197
|
+
ProgressManagement.getInstance().showWait(this, ProgressType.PROGRESSDIALOG_SCAN, null)
|
|
198
|
+
}
|
|
199
|
+
manageErrorState(false, "")
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
public override fun scanIn(device: PocDeviceAndRssi) {
|
|
204
|
+
transmitterDeviceInfo = device
|
|
205
|
+
if (isSearching) {
|
|
206
|
+
deviceDetected(device)
|
|
207
|
+
}
|
|
208
|
+
manageErrorState(false, "")
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
public override fun scanEnd() {
|
|
212
|
+
if (transmitterDeviceInfo == null && !binding.tvReason.isVisible) {
|
|
213
|
+
manageErrorState(false, "")
|
|
214
|
+
}
|
|
215
|
+
Log.d("Search Transmitter Error--> ", "Search Transmitter Error--> scanEnd")
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
override fun bluetoothStateOFF() {
|
|
219
|
+
super.bluetoothStateOFF()
|
|
220
|
+
manageErrorState(true, "Bluetooth Off")
|
|
221
|
+
Log.d("Search Transmitter Error--> ", "Search Transmitter Error--> bluetoothStateOFF")
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
override fun failGPS() {
|
|
225
|
+
super.failGPS()
|
|
226
|
+
manageErrorState(true, "GPS Off")
|
|
227
|
+
Log.d("Search Transmitter Error--> ", "Search Transmitter Error--> failGPS")
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
override fun failLocal() {
|
|
231
|
+
super.failLocal()
|
|
232
|
+
manageErrorState(true, "Something went wrong")
|
|
233
|
+
Log.d("Search Transmitter Error--> ", "Search Transmitter Error--> failLocal")
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
public override fun bindFail() {
|
|
237
|
+
ProgressManagement.getInstance().dismissWait(this)
|
|
238
|
+
manageErrorState(true, "Bind Failure")
|
|
239
|
+
Log.d("Search Transmitter Error--> ", "Search Transmitter Error--> bindFail")
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
public override fun bindSuccess() {
|
|
243
|
+
ProgressManagement.getInstance().dismissWait(this)
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
fun mapToDto(glucose: PocGlucose): GlucoseLog {
|
|
247
|
+
val dto: GlucoseLog = GlucoseLog()
|
|
248
|
+
dto.timeInMillis = glucose.getTimeInMillis()
|
|
249
|
+
dto.countdownMinutes = glucose.getCountdownMinutes()
|
|
250
|
+
dto.countdownHours = glucose.getCountdownHours()
|
|
251
|
+
dto.countdownDays = glucose.getCountdownDays()
|
|
252
|
+
dto.hypoglycemiaEarlyWarnMinutes = glucose.getHypoglycemiaEarlyWarnMinutes()
|
|
253
|
+
dto.showGlucoseMG = glucose.getShowGlucoseMG()
|
|
254
|
+
dto.glucoseId = glucose.getGlucoseId()
|
|
255
|
+
dto.name = glucose.getName()
|
|
256
|
+
dto.showGlucose = glucose.getShowGlucose()
|
|
257
|
+
dto.Ib = glucose.getIb()
|
|
258
|
+
dto.Iw = glucose.getIw()
|
|
259
|
+
dto.T = glucose.getT()
|
|
260
|
+
dto.year = glucose.getYear()
|
|
261
|
+
dto.month = glucose.getMonth()
|
|
262
|
+
dto.day = glucose.getDay()
|
|
263
|
+
dto.hour = glucose.getHour()
|
|
264
|
+
dto.minute = glucose.getMinute()
|
|
265
|
+
|
|
266
|
+
// Convert byte[] to List<Integer>
|
|
267
|
+
dto.bytes = ArrayList()
|
|
268
|
+
for (b in glucose.getBytes()) {
|
|
269
|
+
dto.bytes?.add(b.toInt() and 0xFF) // Prevent negative values
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
// Trend
|
|
273
|
+
val trendObj: TrendObject = TrendObject()
|
|
274
|
+
trendObj.trendId = glucose.getTrend().getTrendId()
|
|
275
|
+
trendObj.drawableId = glucose.getTrend().getDrawableId()
|
|
276
|
+
trendObj.widgetImg = glucose.getTrend().getWidgetImg()
|
|
277
|
+
trendObj.apsChangeRate = glucose.getTrend().getApsChangeRate()
|
|
278
|
+
dto.trendObject = trendObj
|
|
279
|
+
|
|
280
|
+
// Status
|
|
281
|
+
val statusObj: GlucoseStatusObject = GlucoseStatusObject()
|
|
282
|
+
statusObj.statusId = glucose.getGlucoseStatus().getStatusId()
|
|
283
|
+
dto.glucoseStatusObject = statusObj
|
|
284
|
+
|
|
285
|
+
// Error
|
|
286
|
+
val errorObj: ErrorObject = ErrorObject()
|
|
287
|
+
errorObj.errorId = glucose.getErrorCode().getErrorId()
|
|
288
|
+
errorObj.sound = glucose.getErrorCode().getSound().toString()
|
|
289
|
+
dto.errorObject = errorObj
|
|
290
|
+
|
|
291
|
+
return dto
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
|
|
295
|
+
public override fun disconnect() {
|
|
296
|
+
ProgressManagement.getInstance().dismissWait(this)
|
|
297
|
+
showShortToast(R.string.bt_connect_fail)
|
|
298
|
+
manageErrorState(true, "Disconnected")
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
public override fun disconnectForTimeout() {
|
|
302
|
+
ProgressManagement.getInstance().dismissWait(this)
|
|
303
|
+
manageErrorState(true, "Disconnected")
|
|
304
|
+
Log.d("Search Transmitter Error--> ", "Search Transmitter Error--> disconnectForTimeout")
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
public override fun checkFailForLowPower() {
|
|
308
|
+
ProgressManagement.getInstance().dismissWait(this)
|
|
309
|
+
WarnDialogUtils.getInstance().showWarnDialog(this, DialogType.TYPE_LOW_POWER)
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
public override fun checkFailErrorTemperature() {
|
|
313
|
+
ProgressManagement.getInstance().dismissWait(this)
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
public override fun onlineLost() {
|
|
317
|
+
showShortToast(R.string.online_lost)
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
|
|
321
|
+
private fun bind(device: PocDevice) {
|
|
322
|
+
try {
|
|
323
|
+
if (device.address != null) {
|
|
324
|
+
ManageGattCallback.getInstance().ConnectViaAddress(device.address)
|
|
325
|
+
ManageScanCallback.getInstance().stopLeScan()
|
|
326
|
+
ProgressManagement.getInstance()
|
|
327
|
+
.showWait(this, ProgressType.PROGRESSDIALOG_CONNECT, null)
|
|
328
|
+
}
|
|
329
|
+
} catch (e: Exception) {
|
|
330
|
+
Log.d("bind::-> ", "bind: ${e.message}")
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
private fun setupClickListeners() {
|
|
335
|
+
binding.toolbar.btnWhatsapp.setOnClickListener {
|
|
336
|
+
startActivity(Intent(this, HelpActivity::class.java))
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
binding.toolbar.btnClose.setOnClickListener {
|
|
340
|
+
openExitDialog()
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
// Watch Demo button
|
|
344
|
+
binding.toolbar.btnWatchDemo.setOnClickListener {
|
|
345
|
+
// Implement demo video functionality
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
// Connect button (visible when device is detected)
|
|
349
|
+
binding.btnConnect.setOnClickListener {
|
|
350
|
+
connectToTransmitter()
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
val callback: OnBackPressedCallback = object : OnBackPressedCallback(true) {
|
|
354
|
+
override fun handleOnBackPressed() {
|
|
355
|
+
openExitDialog()
|
|
356
|
+
}
|
|
324
357
|
}
|
|
358
|
+
onBackPressedDispatcher.addCallback(this, callback)
|
|
325
359
|
|
|
326
|
-
|
|
327
|
-
binding.toolbar.btnWhatsapp.setOnClickListener {
|
|
328
|
-
startActivity(Intent(this, HelpActivity::class.java))
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
binding.toolbar.btnClose.setOnClickListener {
|
|
332
|
-
openExitDialog()
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
// Watch Demo button
|
|
336
|
-
binding.toolbar.btnWatchDemo.setOnClickListener {
|
|
337
|
-
// Implement demo video functionality
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
// Connect button (visible when device is detected)
|
|
341
|
-
binding.btnConnect.setOnClickListener {
|
|
342
|
-
connectToTransmitter()
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
val callback: OnBackPressedCallback = object : OnBackPressedCallback(true) {
|
|
346
|
-
override fun handleOnBackPressed() {
|
|
347
|
-
openExitDialog()
|
|
348
|
-
}
|
|
349
|
-
}
|
|
350
|
-
onBackPressedDispatcher.addCallback(this, callback)
|
|
351
|
-
|
|
352
|
-
binding.commonButton.btnProceed.setOnClickListener {
|
|
360
|
+
binding.commonButton.btnProceed.setOnClickListener {
|
|
353
361
|
// CoroutineScope(Dispatchers.IO).launch {
|
|
354
362
|
// // This block runs in IO thread
|
|
355
363
|
// val result = mModel.glucoseByTime
|
|
@@ -429,175 +437,175 @@ class SearchTransmitterActivity : BaseBleActivity() {
|
|
|
429
437
|
// }
|
|
430
438
|
// }
|
|
431
439
|
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
}
|
|
440
|
+
if (isTransmitterConnected) {
|
|
441
|
+
proceedToNextStep()
|
|
442
|
+
}
|
|
436
443
|
}
|
|
444
|
+
}
|
|
437
445
|
|
|
438
446
|
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
}
|
|
447
|
+
fun logLongJson(tag: String, message: String) {
|
|
448
|
+
val maxLogSize = 4000
|
|
449
|
+
for (i in 0..message.length / maxLogSize) {
|
|
450
|
+
val start = i * maxLogSize
|
|
451
|
+
val end = (i + 1) * maxLogSize
|
|
452
|
+
if (start < message.length) {
|
|
453
|
+
Log.d(tag, message.substring(start, minOf(end, message.length)))
|
|
454
|
+
}
|
|
448
455
|
}
|
|
456
|
+
}
|
|
449
457
|
|
|
450
|
-
|
|
451
|
-
|
|
458
|
+
private fun startDeviceSearch() {
|
|
459
|
+
mModel = ViewModelProviders.of(this)[MainActivityModel::class.java]
|
|
452
460
|
|
|
453
|
-
|
|
454
|
-
|
|
461
|
+
ReconnectManagement.getInstance()
|
|
462
|
+
.reconnect(ReconnectManagement.ReconnectState.STATE_SCAN_AGAIN)
|
|
455
463
|
|
|
456
|
-
|
|
464
|
+
authenticateSDKService = AuthenticateSDKService(scope = scope)
|
|
457
465
|
|
|
458
|
-
|
|
459
|
-
|
|
466
|
+
isSearching = true
|
|
467
|
+
isTransmitterConnected = false
|
|
460
468
|
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
469
|
+
// Show searching state
|
|
470
|
+
binding.searchingLayout.visibility = View.VISIBLE
|
|
471
|
+
binding.connectedLayout.visibility = View.GONE
|
|
464
472
|
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
473
|
+
Glide.with(this)
|
|
474
|
+
.asGif()
|
|
475
|
+
.load(R.drawable.searching)
|
|
476
|
+
.into(binding.progressSearch)
|
|
469
477
|
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
478
|
+
binding.commonButton.btnProceed.isEnabled = false
|
|
479
|
+
binding.commonButton.btnProceed.alpha = 0.5f
|
|
480
|
+
}
|
|
473
481
|
|
|
474
|
-
|
|
475
|
-
|
|
482
|
+
private fun deviceDetected(device: PocDeviceAndRssi) {
|
|
483
|
+
isSearching = false
|
|
476
484
|
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
485
|
+
// Animate the transition
|
|
486
|
+
val fadeOut = AlphaAnimation(1.0f, 0.0f)
|
|
487
|
+
fadeOut.duration = 300
|
|
488
|
+
fadeOut.setAnimationListener(object : Animation.AnimationListener {
|
|
489
|
+
override fun onAnimationStart(animation: Animation?) {}
|
|
482
490
|
|
|
483
|
-
|
|
484
|
-
|
|
491
|
+
override fun onAnimationEnd(animation: Animation?) {
|
|
492
|
+
binding.searchingLayout.visibility = View.GONE
|
|
485
493
|
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
494
|
+
// Show the connected layout
|
|
495
|
+
binding.connectedLayout.visibility = View.VISIBLE
|
|
496
|
+
binding.tvSerialNumber.text = device.pocDevice.name
|
|
489
497
|
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
498
|
+
// Fade in the connected layout
|
|
499
|
+
val fadeIn = AlphaAnimation(0.0f, 1.0f)
|
|
500
|
+
fadeIn.duration = 300
|
|
501
|
+
binding.connectedLayout.startAnimation(fadeIn)
|
|
502
|
+
}
|
|
495
503
|
|
|
496
|
-
|
|
497
|
-
|
|
504
|
+
override fun onAnimationRepeat(animation: Animation?) {}
|
|
505
|
+
})
|
|
498
506
|
|
|
499
|
-
|
|
500
|
-
|
|
507
|
+
binding.searchingLayout.startAnimation(fadeOut)
|
|
508
|
+
}
|
|
501
509
|
|
|
502
|
-
|
|
503
|
-
|
|
510
|
+
private fun connectToTransmitter() {
|
|
511
|
+
isTransmitterConnected = true
|
|
504
512
|
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
513
|
+
if (transmitterDeviceInfo != null) {
|
|
514
|
+
Log.d("onDeviceConnect--->", "onDeviceConnect: " + transmitterDeviceInfo.toString())
|
|
515
|
+
if (enumDevice.getEnumDevice(transmitterDeviceInfo!!.pocDevice.name).isAbleScanQRCode) {
|
|
516
|
+
Log.d("onDeviceConnect--->", "isAbleScanQRCode")
|
|
517
|
+
} else {
|
|
518
|
+
bind(transmitterDeviceInfo!!.pocDevice)
|
|
519
|
+
}
|
|
512
520
|
|
|
513
|
-
|
|
521
|
+
binding.tvTransName.text = "Sno: ${transmitterDeviceInfo!!.pocDevice.name}"
|
|
514
522
|
|
|
515
|
-
|
|
523
|
+
val formatter = SimpleDateFormat("hh:mm a", Locale.getDefault())
|
|
516
524
|
|
|
517
|
-
|
|
525
|
+
binding.tvDateTime.text = "Connected on ${formatter.format(Date()).uppercase()}"
|
|
518
526
|
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
}
|
|
527
|
+
binding.clSuccess.visibility = View.VISIBLE
|
|
528
|
+
binding.clMain.visibility = View.GONE
|
|
529
|
+
binding.commonButton.btnProceed.isEnabled = true
|
|
530
|
+
binding.commonButton.btnProceed.alpha = 1.0f
|
|
531
|
+
binding.view2.background = ContextCompat.getDrawable(this, R.drawable.bg_green_progress)
|
|
532
|
+
binding.tvDivide2.setTextColor("#299D6B".toColorInt())
|
|
526
533
|
}
|
|
534
|
+
}
|
|
527
535
|
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
536
|
+
private fun proceedToNextStep() {
|
|
537
|
+
if (isForReconnect) {
|
|
538
|
+
sendDataToRN("")
|
|
539
|
+
finish()
|
|
540
|
+
} else {
|
|
541
|
+
val intent = Intent(this, ConnectSensorActivity::class.java)
|
|
542
|
+
intent.putExtra("transmitterDeviceInfo", transmitterDeviceInfo) // Serializable
|
|
543
|
+
startActivity(intent)
|
|
544
|
+
finish()
|
|
537
545
|
// transmitterDeviceInfo?.let {
|
|
538
546
|
// QRActivity.startQR(
|
|
539
547
|
// this@SearchTransmitterActivity,
|
|
540
548
|
// it.pocDevice
|
|
541
549
|
// )
|
|
542
550
|
// }
|
|
543
|
-
}
|
|
544
551
|
}
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
private fun sendDataToRN(data: String) {
|
|
555
|
+
if (reactContext != null) {
|
|
556
|
+
try {
|
|
557
|
+
val catalystInstance: CatalystInstance = reactContext.catalystInstance
|
|
558
|
+
val module = catalystInstance.getNativeModule(CgmTrackyLibModule::class.java)
|
|
545
559
|
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
val catalystInstance: CatalystInstance = reactContext.catalystInstance
|
|
550
|
-
val module = catalystInstance.getNativeModule(CgmTrackyLibModule::class.java)
|
|
551
|
-
|
|
552
|
-
if (module == null) {
|
|
553
|
-
sendDataToRNDirectly("", "WARM_PERIOD_STARTED")
|
|
554
|
-
Log.d("sendDataToRN: ", "Module null")
|
|
555
|
-
} else {
|
|
556
|
-
module.sendDataToReact(data, "WARM_PERIOD_STARTED", "cgmDeviceEvent")
|
|
557
|
-
Log.d("sendDataToRN: ", "Module is not null")
|
|
558
|
-
}
|
|
559
|
-
} catch (e: Exception) {
|
|
560
|
-
Log.e("sendDataToRN: Error ", e.message.toString())
|
|
561
|
-
}
|
|
560
|
+
if (module == null) {
|
|
561
|
+
sendDataToRNDirectly("", "WARM_PERIOD_STARTED")
|
|
562
|
+
Log.d("sendDataToRN: ", "Module null")
|
|
562
563
|
} else {
|
|
563
|
-
|
|
564
|
+
module.sendDataToReact(data, "WARM_PERIOD_STARTED", "cgmDeviceEvent")
|
|
565
|
+
Log.d("sendDataToRN: ", "Module is not null")
|
|
564
566
|
}
|
|
567
|
+
} catch (e: Exception) {
|
|
568
|
+
Log.e("sendDataToRN: Error ", e.message.toString())
|
|
569
|
+
}
|
|
570
|
+
} else {
|
|
571
|
+
Log.e("TrackyActivity", "ReactApplicationContext is null")
|
|
565
572
|
}
|
|
573
|
+
}
|
|
566
574
|
|
|
567
575
|
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
576
|
+
private fun sendDataToRNDirectly(data: String, status: String) {
|
|
577
|
+
try {
|
|
578
|
+
val map: WritableMap = Arguments.createMap().apply {
|
|
579
|
+
putString("data", data)
|
|
580
|
+
putString("status", status)
|
|
581
|
+
}
|
|
574
582
|
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
}
|
|
583
|
+
reactContext?.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
|
|
584
|
+
?.emit("cgmDeviceEvent", map)
|
|
585
|
+
} catch (e: Exception) {
|
|
586
|
+
Log.e("sendDataToRNDirectly", "Error sending data to React", e)
|
|
580
587
|
}
|
|
588
|
+
}
|
|
581
589
|
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
590
|
+
override fun onDestroy() {
|
|
591
|
+
super.onDestroy()
|
|
592
|
+
handler.removeCallbacksAndMessages(null)
|
|
593
|
+
}
|
|
586
594
|
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
595
|
+
override fun onResume() {
|
|
596
|
+
super.onResume()
|
|
597
|
+
BleService.startService(this)
|
|
598
|
+
}
|
|
591
599
|
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
600
|
+
override fun setView(): Int {
|
|
601
|
+
return R.layout.activity_search_transmitter
|
|
602
|
+
}
|
|
595
603
|
|
|
596
|
-
|
|
597
|
-
|
|
604
|
+
override fun initViews() {
|
|
605
|
+
}
|
|
598
606
|
|
|
599
|
-
|
|
600
|
-
|
|
607
|
+
override fun onClick(p0: View?) {
|
|
608
|
+
}
|
|
601
609
|
|
|
602
610
|
|
|
603
611
|
}
|