react-native-mytatva-rn-sdk 1.2.92 → 1.2.94
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 +20 -7
- package/android/src/main/java/com/mytatvarnsdk/CgmTrackyLibModule.kt +594 -232
- package/android/src/main/java/com/mytatvarnsdk/activity/PermissionActivity.kt +276 -87
- package/android/src/main/java/com/mytatvarnsdk/activity/PlaceTransmitterActivity.kt +4 -0
- package/android/src/main/res/layout/activity_permission.xml +0 -1
- package/android/src/main/res/layout/layout_green_solid_button.xml +43 -0
- package/android/src/main/res/layout/permission_disclosure_bottomsheet.xml +70 -0
- package/android/src/main/res/values/strings.xml +12 -0
- package/ios/MyReactNativeBridge.m +13 -1
- package/ios/Support/Converter/DataConverter.swift +62 -29
- package/ios/ViewControllers/AttachTransmitterViewController.swift +9 -0
- package/package.json +1 -1
|
@@ -2,7 +2,6 @@ package com.mytatvarnsdk.activity
|
|
|
2
2
|
|
|
3
3
|
import android.Manifest
|
|
4
4
|
import android.annotation.SuppressLint
|
|
5
|
-
import android.app.AlertDialog
|
|
6
5
|
import android.app.Dialog
|
|
7
6
|
import android.bluetooth.BluetoothAdapter
|
|
8
7
|
import android.content.Context
|
|
@@ -18,6 +17,7 @@ import android.view.Gravity
|
|
|
18
17
|
import android.view.View
|
|
19
18
|
import android.view.ViewGroup
|
|
20
19
|
import android.view.Window
|
|
20
|
+
import android.widget.TextView
|
|
21
21
|
import android.widget.Toast
|
|
22
22
|
import androidx.activity.OnBackPressedCallback
|
|
23
23
|
import androidx.activity.enableEdgeToEdge
|
|
@@ -34,6 +34,7 @@ import com.facebook.react.bridge.CatalystInstance
|
|
|
34
34
|
import com.facebook.react.bridge.WritableMap
|
|
35
35
|
import com.facebook.react.modules.core.DeviceEventManagerModule
|
|
36
36
|
import com.mytatvarnsdk.CgmTrackyLibModule
|
|
37
|
+
import com.mytatvarnsdk.R
|
|
37
38
|
import com.mytatvarnsdk.base.BasePermissionActivity
|
|
38
39
|
import com.mytatvarnsdk.databinding.ActivityPermissionBinding
|
|
39
40
|
import com.mytatvarnsdk.databinding.BluetoothDialogBottomsheetBinding
|
|
@@ -46,12 +47,18 @@ class PermissionActivity : BasePermissionActivity() {
|
|
|
46
47
|
private val BLUETOOTH_REQUEST_CODE = 102
|
|
47
48
|
|
|
48
49
|
private val REQUEST_ENABLE_BT = 1
|
|
50
|
+
|
|
51
|
+
companion object {
|
|
52
|
+
private const val CGM_PERMISSION_PREFS = "cgm_permission_prefs"
|
|
53
|
+
private const val REQUESTED_PREFIX = "requested_"
|
|
54
|
+
}
|
|
49
55
|
private val bluetoothAdapter: BluetoothAdapter? by lazy {
|
|
50
56
|
BluetoothAdapter.getDefaultAdapter()
|
|
51
57
|
}
|
|
52
58
|
private val reactContext = CgmTrackyLibModule.mReactContext
|
|
53
59
|
|
|
54
60
|
private var isForReconnect: Boolean = false
|
|
61
|
+
private var pendingBluetoothAfterLocation = false
|
|
55
62
|
|
|
56
63
|
override fun onCreate(savedInstanceState: Bundle?) {
|
|
57
64
|
super.onCreate(savedInstanceState)
|
|
@@ -71,11 +78,6 @@ class PermissionActivity : BasePermissionActivity() {
|
|
|
71
78
|
override fun getPermission(): Array<out Array<out String?>?>? {
|
|
72
79
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
|
73
80
|
return arrayOf<Array<String?>?>(ConstantsLibrary.BLUETOOTH_S)
|
|
74
|
-
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
|
75
|
-
return arrayOf<Array<String?>?>(
|
|
76
|
-
ConstantsLibrary.LOCAL_PERMISSION,
|
|
77
|
-
ConstantsLibrary.BACKGROUND_LOCATION_Q
|
|
78
|
-
)
|
|
79
81
|
} else {
|
|
80
82
|
return arrayOf<Array<String?>?>(ConstantsLibrary.LOCAL_PERMISSION)
|
|
81
83
|
}
|
|
@@ -136,20 +138,18 @@ class PermissionActivity : BasePermissionActivity() {
|
|
|
136
138
|
|
|
137
139
|
sendDataToRN("", "cgm_permissions_page_landing")
|
|
138
140
|
|
|
139
|
-
|
|
140
|
-
binding.switchBluetooth.isChecked = isBluetoothPermissionGranted(this) && it.isEnabled
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
binding.switchLocation.isChecked = isLocationPermissionGranted(this)
|
|
141
|
+
refreshPermissionSwitchStates()
|
|
144
142
|
|
|
145
143
|
binding.switchBluetooth.setOnCheckedChangeListener { _, isChecked ->
|
|
146
144
|
if (isChecked) {
|
|
145
|
+
setSwitchChecked(binding.switchBluetooth, false)
|
|
147
146
|
requestBluetoothPermission()
|
|
148
147
|
}
|
|
149
148
|
}
|
|
150
149
|
|
|
151
150
|
binding.switchLocation.setOnCheckedChangeListener { _, isChecked ->
|
|
152
151
|
if (isChecked) {
|
|
152
|
+
setSwitchChecked(binding.switchLocation, false)
|
|
153
153
|
requestLocationPermission()
|
|
154
154
|
}
|
|
155
155
|
}
|
|
@@ -294,50 +294,224 @@ class PermissionActivity : BasePermissionActivity() {
|
|
|
294
294
|
}
|
|
295
295
|
|
|
296
296
|
|
|
297
|
-
private fun
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
if (
|
|
301
|
-
|
|
297
|
+
private fun setSwitchChecked(switch: androidx.appcompat.widget.SwitchCompat, checked: Boolean) {
|
|
298
|
+
switch.setOnCheckedChangeListener(null)
|
|
299
|
+
switch.isChecked = checked
|
|
300
|
+
if (switch.id == binding.switchBluetooth.id) {
|
|
301
|
+
switch.setOnCheckedChangeListener { _, isChecked ->
|
|
302
|
+
if (isChecked) {
|
|
303
|
+
setSwitchChecked(binding.switchBluetooth, false)
|
|
304
|
+
requestBluetoothPermission()
|
|
305
|
+
}
|
|
306
|
+
}
|
|
302
307
|
} else {
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
+
switch.setOnCheckedChangeListener { _, isChecked ->
|
|
309
|
+
if (isChecked) {
|
|
310
|
+
setSwitchChecked(binding.switchLocation, false)
|
|
311
|
+
requestLocationPermission()
|
|
312
|
+
}
|
|
313
|
+
}
|
|
308
314
|
}
|
|
309
315
|
}
|
|
310
316
|
|
|
311
|
-
private fun
|
|
312
|
-
|
|
317
|
+
private fun showPermissionDisclosure(
|
|
318
|
+
title: String,
|
|
319
|
+
message: String,
|
|
320
|
+
onContinue: () -> Unit,
|
|
321
|
+
onCancel: () -> Unit,
|
|
322
|
+
) {
|
|
323
|
+
showActionBottomSheet(
|
|
324
|
+
title = title,
|
|
325
|
+
message = message,
|
|
326
|
+
continueText = getString(R.string.cgm_disclosure_continue),
|
|
327
|
+
onContinue = onContinue,
|
|
328
|
+
onCancel = onCancel,
|
|
329
|
+
)
|
|
330
|
+
}
|
|
313
331
|
|
|
314
|
-
|
|
332
|
+
private fun showPermissionSettingsPrompt(
|
|
333
|
+
title: String,
|
|
334
|
+
message: String,
|
|
335
|
+
onCancel: () -> Unit,
|
|
336
|
+
) {
|
|
337
|
+
showActionBottomSheet(
|
|
338
|
+
title = title,
|
|
339
|
+
message = message,
|
|
340
|
+
continueText = getString(R.string.cgm_open_settings),
|
|
341
|
+
onContinue = { openAppPermissionSettings() },
|
|
342
|
+
onCancel = onCancel,
|
|
343
|
+
)
|
|
344
|
+
}
|
|
315
345
|
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
346
|
+
private fun showActionBottomSheet(
|
|
347
|
+
title: String,
|
|
348
|
+
message: String,
|
|
349
|
+
continueText: String,
|
|
350
|
+
onContinue: () -> Unit,
|
|
351
|
+
onCancel: () -> Unit,
|
|
352
|
+
) {
|
|
353
|
+
val sheetView =
|
|
354
|
+
layoutInflater.inflate(R.layout.permission_disclosure_bottomsheet, null)
|
|
355
|
+
|
|
356
|
+
sheetView.findViewById<TextView>(R.id.disclosure_title).text = title
|
|
357
|
+
sheetView.findViewById<TextView>(R.id.disclosure_message).text = message
|
|
358
|
+
|
|
359
|
+
val dialog = Dialog(this)
|
|
360
|
+
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE)
|
|
361
|
+
dialog.setContentView(sheetView)
|
|
362
|
+
dialog.setCancelable(false)
|
|
363
|
+
dialog.setCanceledOnTouchOutside(false)
|
|
364
|
+
|
|
365
|
+
val window = dialog.window
|
|
366
|
+
window?.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)
|
|
367
|
+
window?.setGravity(Gravity.BOTTOM)
|
|
368
|
+
window?.setBackgroundDrawable(Color.TRANSPARENT.toDrawable())
|
|
369
|
+
|
|
370
|
+
var pendingAction: (() -> Unit)? = null
|
|
371
|
+
dialog.setOnDismissListener {
|
|
372
|
+
val action = pendingAction
|
|
373
|
+
pendingAction = null
|
|
374
|
+
if (action != null) {
|
|
375
|
+
binding.root.post { action() }
|
|
321
376
|
}
|
|
377
|
+
}
|
|
322
378
|
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
379
|
+
val notNowButton = sheetView.findViewById<View>(R.id.btn_not_now)
|
|
380
|
+
notNowButton.findViewById<TextView>(R.id.tvProceed).text =
|
|
381
|
+
getString(R.string.cgm_disclosure_not_now)
|
|
382
|
+
notNowButton.findViewById<View>(R.id.btnProceed).setOnClickListener {
|
|
383
|
+
pendingAction = onCancel
|
|
384
|
+
dialog.dismiss()
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
val continueButton = sheetView.findViewById<View>(R.id.btn_continue)
|
|
388
|
+
continueButton.findViewById<TextView>(R.id.tvProceed).text = continueText
|
|
389
|
+
continueButton.findViewById<View>(R.id.btnProceed).setOnClickListener {
|
|
390
|
+
pendingAction = onContinue
|
|
391
|
+
dialog.dismiss()
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
dialog.show()
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
private fun getMissingPermissions(permissions: Array<String>): Array<String> {
|
|
398
|
+
return permissions.filter {
|
|
399
|
+
ContextCompat.checkSelfPermission(this, it) != PackageManager.PERMISSION_GRANTED
|
|
400
|
+
}.toTypedArray()
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
private fun hasRequestedPermissionBefore(permission: String): Boolean {
|
|
404
|
+
return permissionPrefs().getBoolean("$REQUESTED_PREFIX$permission", false)
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
private fun markPermissionsRequested(permissions: Array<String>) {
|
|
408
|
+
val editor = permissionPrefs().edit()
|
|
409
|
+
permissions.forEach { editor.putBoolean("$REQUESTED_PREFIX$it", true) }
|
|
410
|
+
editor.apply()
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
private fun permissionPrefs() =
|
|
414
|
+
getSharedPreferences(CGM_PERMISSION_PREFS, Context.MODE_PRIVATE)
|
|
415
|
+
|
|
416
|
+
private fun isPermissionBlocked(permission: String): Boolean {
|
|
417
|
+
if (ContextCompat.checkSelfPermission(this, permission) ==
|
|
418
|
+
PackageManager.PERMISSION_GRANTED
|
|
419
|
+
) {
|
|
420
|
+
return false
|
|
421
|
+
}
|
|
422
|
+
if (ActivityCompat.shouldShowRequestPermissionRationale(this, permission)) {
|
|
423
|
+
return false
|
|
424
|
+
}
|
|
425
|
+
return hasRequestedPermissionBefore(permission)
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
private fun canRequestSystemPermission(permissions: Array<String>): Boolean {
|
|
429
|
+
val missing = getMissingPermissions(permissions)
|
|
430
|
+
if (missing.isEmpty()) {
|
|
431
|
+
return false
|
|
432
|
+
}
|
|
433
|
+
return missing.none { isPermissionBlocked(it) }
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
private fun openAppPermissionSettings() {
|
|
437
|
+
startActivity(
|
|
438
|
+
Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS).apply {
|
|
439
|
+
data = Uri.fromParts("package", packageName, null)
|
|
440
|
+
},
|
|
441
|
+
)
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
private fun requestMissingPermissionsAfterDisclosure(
|
|
445
|
+
permissions: Array<String>,
|
|
446
|
+
requestCode: Int,
|
|
447
|
+
settingsTitle: String,
|
|
448
|
+
settingsMessage: String,
|
|
449
|
+
onBlockedCancel: () -> Unit,
|
|
450
|
+
) {
|
|
451
|
+
val missing = getMissingPermissions(permissions)
|
|
452
|
+
if (missing.isEmpty()) {
|
|
453
|
+
completePermissionRequest(requestCode)
|
|
454
|
+
return
|
|
455
|
+
}
|
|
456
|
+
if (canRequestSystemPermission(missing)) {
|
|
457
|
+
markPermissionsRequested(missing)
|
|
458
|
+
ActivityCompat.requestPermissions(this, missing, requestCode)
|
|
459
|
+
return
|
|
460
|
+
}
|
|
461
|
+
showPermissionSettingsPrompt(
|
|
462
|
+
title = settingsTitle,
|
|
463
|
+
message = settingsMessage,
|
|
464
|
+
onCancel = onBlockedCancel,
|
|
465
|
+
)
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
private fun completePermissionRequest(requestCode: Int) {
|
|
469
|
+
when (requestCode) {
|
|
470
|
+
LOCATION_REQUEST_CODE -> {
|
|
471
|
+
if (pendingBluetoothAfterLocation) {
|
|
472
|
+
pendingBluetoothAfterLocation = false
|
|
473
|
+
onBluetoothPermissionGranted()
|
|
474
|
+
} else {
|
|
475
|
+
onLocationPermissionGranted()
|
|
476
|
+
}
|
|
337
477
|
}
|
|
478
|
+
BLUETOOTH_REQUEST_CODE -> onBluetoothPermissionGranted()
|
|
338
479
|
}
|
|
339
480
|
}
|
|
340
481
|
|
|
482
|
+
private fun refreshPermissionSwitchStates() {
|
|
483
|
+
setSwitchChecked(binding.switchLocation, isLocationPermissionGranted(this))
|
|
484
|
+
val isBluetoothReady = isBluetoothPermissionGranted(this) &&
|
|
485
|
+
bluetoothAdapter?.isEnabled == true
|
|
486
|
+
setSwitchChecked(binding.switchBluetooth, isBluetoothReady)
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
private fun requestLocationPermission() {
|
|
490
|
+
val permissionArray = PermissionUtils.LOCAL_PERMISSION
|
|
491
|
+
|
|
492
|
+
if (hasPermissions(permissionArray)) {
|
|
493
|
+
onLocationPermissionGranted()
|
|
494
|
+
return
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
showPermissionDisclosure(
|
|
498
|
+
title = getString(R.string.cgm_location_disclosure_title),
|
|
499
|
+
message = getString(R.string.cgm_location_disclosure_message),
|
|
500
|
+
onContinue = {
|
|
501
|
+
requestMissingPermissionsAfterDisclosure(
|
|
502
|
+
permissions = permissionArray,
|
|
503
|
+
requestCode = LOCATION_REQUEST_CODE,
|
|
504
|
+
settingsTitle = getString(R.string.cgm_location_settings_title),
|
|
505
|
+
settingsMessage = getString(R.string.cgm_location_settings_message),
|
|
506
|
+
onBlockedCancel = { setSwitchChecked(binding.switchLocation, false) },
|
|
507
|
+
)
|
|
508
|
+
},
|
|
509
|
+
onCancel = {
|
|
510
|
+
setSwitchChecked(binding.switchLocation, false)
|
|
511
|
+
},
|
|
512
|
+
)
|
|
513
|
+
}
|
|
514
|
+
|
|
341
515
|
@RequiresPermission(Manifest.permission.BLUETOOTH_CONNECT)
|
|
342
516
|
private fun requestBluetoothPermission() {
|
|
343
517
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
|
@@ -345,42 +519,53 @@ class PermissionActivity : BasePermissionActivity() {
|
|
|
345
519
|
|
|
346
520
|
if (hasPermissions(permissions)) {
|
|
347
521
|
onBluetoothPermissionGranted()
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
ActivityCompat.shouldShowRequestPermissionRationale(this, it)
|
|
351
|
-
}
|
|
522
|
+
return
|
|
523
|
+
}
|
|
352
524
|
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
}
|
|
525
|
+
showPermissionDisclosure(
|
|
526
|
+
title = getString(R.string.cgm_bluetooth_disclosure_title),
|
|
527
|
+
message = getString(R.string.cgm_bluetooth_disclosure_message),
|
|
528
|
+
onContinue = {
|
|
529
|
+
requestMissingPermissionsAfterDisclosure(
|
|
530
|
+
permissions = permissions,
|
|
531
|
+
requestCode = BLUETOOTH_REQUEST_CODE,
|
|
532
|
+
settingsTitle = getString(R.string.cgm_bluetooth_settings_title),
|
|
533
|
+
settingsMessage = getString(R.string.cgm_bluetooth_settings_message),
|
|
534
|
+
onBlockedCancel = { setSwitchChecked(binding.switchBluetooth, false) },
|
|
364
535
|
)
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
536
|
+
},
|
|
537
|
+
onCancel = {
|
|
538
|
+
setSwitchChecked(binding.switchBluetooth, false)
|
|
539
|
+
},
|
|
540
|
+
)
|
|
369
541
|
} else {
|
|
370
|
-
|
|
542
|
+
if (!hasPermissions(PermissionUtils.LOCAL_PERMISSION)) {
|
|
543
|
+
showPermissionDisclosure(
|
|
544
|
+
title = getString(R.string.cgm_bluetooth_disclosure_title),
|
|
545
|
+
message = getString(R.string.cgm_bluetooth_disclosure_message),
|
|
546
|
+
onContinue = {
|
|
547
|
+
pendingBluetoothAfterLocation = true
|
|
548
|
+
requestMissingPermissionsAfterDisclosure(
|
|
549
|
+
permissions = PermissionUtils.LOCAL_PERMISSION,
|
|
550
|
+
requestCode = LOCATION_REQUEST_CODE,
|
|
551
|
+
settingsTitle = getString(R.string.cgm_location_settings_title),
|
|
552
|
+
settingsMessage = getString(R.string.cgm_location_settings_message),
|
|
553
|
+
onBlockedCancel = {
|
|
554
|
+
pendingBluetoothAfterLocation = false
|
|
555
|
+
setSwitchChecked(binding.switchBluetooth, false)
|
|
556
|
+
},
|
|
557
|
+
)
|
|
558
|
+
},
|
|
559
|
+
onCancel = {
|
|
560
|
+
setSwitchChecked(binding.switchBluetooth, false)
|
|
561
|
+
},
|
|
562
|
+
)
|
|
563
|
+
} else {
|
|
564
|
+
onBluetoothPermissionGranted()
|
|
565
|
+
}
|
|
371
566
|
}
|
|
372
567
|
}
|
|
373
568
|
|
|
374
|
-
private fun showPermissionRationale(title: String, message: String, onProceed: () -> Unit) {
|
|
375
|
-
AlertDialog.Builder(this)
|
|
376
|
-
.setTitle(title)
|
|
377
|
-
.setMessage(message)
|
|
378
|
-
.setPositiveButton("OK") { _, _ -> onProceed() }
|
|
379
|
-
.setNegativeButton("Cancel", null)
|
|
380
|
-
.show()
|
|
381
|
-
}
|
|
382
|
-
|
|
383
|
-
|
|
384
569
|
private fun hasPermissions(permissions: Array<String>): Boolean {
|
|
385
570
|
return permissions.all {
|
|
386
571
|
ContextCompat.checkSelfPermission(this, it) == PackageManager.PERMISSION_GRANTED
|
|
@@ -413,17 +598,6 @@ class PermissionActivity : BasePermissionActivity() {
|
|
|
413
598
|
}
|
|
414
599
|
}
|
|
415
600
|
|
|
416
|
-
private fun onForegroundLocationGranted() {
|
|
417
|
-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q &&
|
|
418
|
-
ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_BACKGROUND_LOCATION)
|
|
419
|
-
!= PackageManager.PERMISSION_GRANTED
|
|
420
|
-
) {
|
|
421
|
-
onLocationPermissionGranted()
|
|
422
|
-
} else {
|
|
423
|
-
Log.d("Permission", "All location permissions granted")
|
|
424
|
-
}
|
|
425
|
-
}
|
|
426
|
-
|
|
427
601
|
@RequiresPermission(Manifest.permission.BLUETOOTH_CONNECT)
|
|
428
602
|
override fun onRequestPermissionsResult(
|
|
429
603
|
requestCode: Int,
|
|
@@ -444,13 +618,24 @@ class PermissionActivity : BasePermissionActivity() {
|
|
|
444
618
|
|
|
445
619
|
LOCATION_REQUEST_CODE -> {
|
|
446
620
|
if (allGranted) {
|
|
447
|
-
|
|
621
|
+
if (pendingBluetoothAfterLocation) {
|
|
622
|
+
pendingBluetoothAfterLocation = false
|
|
623
|
+
onBluetoothPermissionGranted()
|
|
624
|
+
} else {
|
|
625
|
+
onLocationPermissionGranted()
|
|
626
|
+
}
|
|
627
|
+
} else {
|
|
628
|
+
pendingBluetoothAfterLocation = false
|
|
629
|
+
setSwitchChecked(binding.switchLocation, false)
|
|
630
|
+
setSwitchChecked(binding.switchBluetooth, false)
|
|
448
631
|
}
|
|
449
632
|
}
|
|
450
633
|
|
|
451
634
|
BLUETOOTH_REQUEST_CODE -> {
|
|
452
635
|
if (allGranted) {
|
|
453
636
|
onBluetoothPermissionGranted()
|
|
637
|
+
} else {
|
|
638
|
+
setSwitchChecked(binding.switchBluetooth, false)
|
|
454
639
|
}
|
|
455
640
|
}
|
|
456
641
|
}
|
|
@@ -458,8 +643,8 @@ class PermissionActivity : BasePermissionActivity() {
|
|
|
458
643
|
}
|
|
459
644
|
|
|
460
645
|
private fun onLocationPermissionGranted() {
|
|
646
|
+
setSwitchChecked(binding.switchLocation, true)
|
|
461
647
|
updateProceedButtonState()
|
|
462
|
-
// Start location-based action
|
|
463
648
|
}
|
|
464
649
|
|
|
465
650
|
@RequiresPermission(Manifest.permission.BLUETOOTH_CONNECT)
|
|
@@ -473,12 +658,13 @@ class PermissionActivity : BasePermissionActivity() {
|
|
|
473
658
|
}
|
|
474
659
|
}
|
|
475
660
|
|
|
661
|
+
setSwitchChecked(binding.switchBluetooth, true)
|
|
476
662
|
updateProceedButtonState()
|
|
477
|
-
// Start Bluetooth device scan or connect
|
|
478
663
|
}
|
|
479
664
|
|
|
480
665
|
override fun onResume() {
|
|
481
666
|
super.onResume()
|
|
667
|
+
refreshPermissionSwitchStates()
|
|
482
668
|
updateProceedButtonState()
|
|
483
669
|
}
|
|
484
670
|
|
|
@@ -486,7 +672,10 @@ class PermissionActivity : BasePermissionActivity() {
|
|
|
486
672
|
super.onActivityResult(requestCode, resultCode, data)
|
|
487
673
|
if (requestCode == REQUEST_ENABLE_BT) {
|
|
488
674
|
if (resultCode == RESULT_OK) {
|
|
675
|
+
setSwitchChecked(binding.switchBluetooth, true)
|
|
489
676
|
updateProceedButtonState()
|
|
677
|
+
} else {
|
|
678
|
+
setSwitchChecked(binding.switchBluetooth, false)
|
|
490
679
|
}
|
|
491
680
|
}
|
|
492
681
|
}
|
|
@@ -62,6 +62,10 @@ class PlaceTransmitterActivity : AppCompatActivity() {
|
|
|
62
62
|
binding.commonButton.tvProceed.text = "Complete"
|
|
63
63
|
|
|
64
64
|
binding.commonButton.btnProceed.setOnClickListener {
|
|
65
|
+
sendDataToRN(
|
|
66
|
+
"{\"screen\":\"PlaceTransmitter\",\"step\":5}",
|
|
67
|
+
"CGM_PLACE_TRANSMITTER_COMPLETE_CLICKED"
|
|
68
|
+
)
|
|
65
69
|
sendDataToRN("", "cgm_connection_complete_clicked")
|
|
66
70
|
sendDataToRN("", "WARM_PERIOD_STARTED")
|
|
67
71
|
finish()
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
3
|
+
xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
4
|
+
android:layout_width="match_parent"
|
|
5
|
+
android:layout_height="wrap_content"
|
|
6
|
+
android:background="@color/white">
|
|
7
|
+
|
|
8
|
+
<androidx.cardview.widget.CardView
|
|
9
|
+
android:id="@+id/btnProceed"
|
|
10
|
+
android:layout_width="match_parent"
|
|
11
|
+
android:layout_height="60dp"
|
|
12
|
+
android:layout_marginTop="10dp"
|
|
13
|
+
android:layout_marginBottom="10dp"
|
|
14
|
+
app:cardBackgroundColor="#2A805A"
|
|
15
|
+
app:cardCornerRadius="12dp"
|
|
16
|
+
app:cardElevation="0dp"
|
|
17
|
+
app:layout_constraintBottom_toBottomOf="parent"
|
|
18
|
+
app:layout_constraintEnd_toEndOf="parent"
|
|
19
|
+
app:layout_constraintStart_toStartOf="parent"
|
|
20
|
+
app:layout_constraintTop_toTopOf="parent">
|
|
21
|
+
|
|
22
|
+
<androidx.constraintlayout.widget.ConstraintLayout
|
|
23
|
+
android:layout_width="match_parent"
|
|
24
|
+
android:layout_height="50dp"
|
|
25
|
+
android:background="@drawable/bg_green_border_20">
|
|
26
|
+
|
|
27
|
+
<TextView
|
|
28
|
+
android:id="@+id/tvProceed"
|
|
29
|
+
android:layout_width="wrap_content"
|
|
30
|
+
android:layout_height="wrap_content"
|
|
31
|
+
android:fontFamily="@font/roboto_semibold"
|
|
32
|
+
android:text="Continue"
|
|
33
|
+
android:textColor="#ffffff"
|
|
34
|
+
android:textSize="16sp"
|
|
35
|
+
app:layout_constraintBottom_toBottomOf="parent"
|
|
36
|
+
app:layout_constraintEnd_toEndOf="parent"
|
|
37
|
+
app:layout_constraintStart_toStartOf="parent"
|
|
38
|
+
app:layout_constraintTop_toTopOf="parent" />
|
|
39
|
+
|
|
40
|
+
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
41
|
+
</androidx.cardview.widget.CardView>
|
|
42
|
+
|
|
43
|
+
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
3
|
+
android:layout_width="match_parent"
|
|
4
|
+
android:layout_height="wrap_content"
|
|
5
|
+
android:background="@drawable/bottom_sheet_background"
|
|
6
|
+
android:gravity="center_horizontal"
|
|
7
|
+
android:orientation="vertical"
|
|
8
|
+
android:paddingHorizontal="16dp"
|
|
9
|
+
android:paddingTop="12dp"
|
|
10
|
+
android:paddingBottom="8dp">
|
|
11
|
+
|
|
12
|
+
<View
|
|
13
|
+
android:layout_width="40dp"
|
|
14
|
+
android:layout_height="4dp"
|
|
15
|
+
android:layout_marginBottom="20dp"
|
|
16
|
+
android:background="@drawable/bg_grey" />
|
|
17
|
+
|
|
18
|
+
<ImageView
|
|
19
|
+
android:id="@+id/disclosure_icon"
|
|
20
|
+
android:layout_width="56dp"
|
|
21
|
+
android:layout_height="56dp"
|
|
22
|
+
android:contentDescription="@null"
|
|
23
|
+
android:src="@drawable/poput_request_permission_icon" />
|
|
24
|
+
|
|
25
|
+
<TextView
|
|
26
|
+
android:id="@+id/disclosure_title"
|
|
27
|
+
android:layout_width="match_parent"
|
|
28
|
+
android:layout_height="wrap_content"
|
|
29
|
+
android:layout_marginTop="12dp"
|
|
30
|
+
android:fontFamily="@font/roboto_bold"
|
|
31
|
+
android:gravity="center"
|
|
32
|
+
android:textColor="#212121"
|
|
33
|
+
android:textSize="20sp" />
|
|
34
|
+
|
|
35
|
+
<TextView
|
|
36
|
+
android:id="@+id/disclosure_message"
|
|
37
|
+
android:layout_width="match_parent"
|
|
38
|
+
android:layout_height="wrap_content"
|
|
39
|
+
android:layout_marginTop="12dp"
|
|
40
|
+
android:fontFamily="@font/roboto_regular"
|
|
41
|
+
android:gravity="center"
|
|
42
|
+
android:lineSpacingExtra="4dp"
|
|
43
|
+
android:paddingHorizontal="8dp"
|
|
44
|
+
android:textColor="#212121"
|
|
45
|
+
android:textSize="14sp" />
|
|
46
|
+
|
|
47
|
+
<LinearLayout
|
|
48
|
+
android:layout_width="match_parent"
|
|
49
|
+
android:layout_height="wrap_content"
|
|
50
|
+
android:layout_marginTop="16dp"
|
|
51
|
+
android:orientation="horizontal"
|
|
52
|
+
android:weightSum="2">
|
|
53
|
+
|
|
54
|
+
<include
|
|
55
|
+
android:id="@+id/btn_not_now"
|
|
56
|
+
layout="@layout/layout_green_border_button"
|
|
57
|
+
android:layout_width="0dp"
|
|
58
|
+
android:layout_height="wrap_content"
|
|
59
|
+
android:layout_marginEnd="6dp"
|
|
60
|
+
android:layout_weight="1" />
|
|
61
|
+
|
|
62
|
+
<include
|
|
63
|
+
android:id="@+id/btn_continue"
|
|
64
|
+
layout="@layout/layout_green_solid_button"
|
|
65
|
+
android:layout_width="0dp"
|
|
66
|
+
android:layout_height="wrap_content"
|
|
67
|
+
android:layout_marginStart="6dp"
|
|
68
|
+
android:layout_weight="1" />
|
|
69
|
+
</LinearLayout>
|
|
70
|
+
</LinearLayout>
|
|
@@ -201,4 +201,16 @@
|
|
|
201
201
|
<string name="txt_know_more"><u>Know More</u></string>
|
|
202
202
|
<string name="txt_open_setting"><u>Open System Settings</u></string>
|
|
203
203
|
|
|
204
|
+
<string name="cgm_disclosure_not_now">Not now</string>
|
|
205
|
+
<string name="cgm_disclosure_continue">Continue</string>
|
|
206
|
+
<string name="cgm_location_disclosure_title">Location data</string>
|
|
207
|
+
<string name="cgm_location_disclosure_message">GoodFlip uses location data to discover and connect to your CGM device when you set up or sync readings. Location is used only while you use this feature and is not used for advertising.</string>
|
|
208
|
+
<string name="cgm_bluetooth_disclosure_title">Bluetooth and location</string>
|
|
209
|
+
<string name="cgm_bluetooth_disclosure_message">GoodFlip uses Bluetooth and location data to discover and connect to your CGM device when you set up or sync readings. Location is used only while you use this feature and is not used for advertising.</string>
|
|
210
|
+
<string name="cgm_open_settings">Open Settings</string>
|
|
211
|
+
<string name="cgm_bluetooth_settings_title">Enable Bluetooth permission</string>
|
|
212
|
+
<string name="cgm_bluetooth_settings_message">Bluetooth access was denied. Open Settings, go to Permissions, and allow Bluetooth so GoodFlip can connect your CGM device.</string>
|
|
213
|
+
<string name="cgm_location_settings_title">Enable Location permission</string>
|
|
214
|
+
<string name="cgm_location_settings_message">Location access was denied. Open Settings, go to Permissions, and allow Location so GoodFlip can discover your CGM device.</string>
|
|
215
|
+
|
|
204
216
|
</resources>
|
|
@@ -365,7 +365,19 @@ RCT_EXPORT_MODULE();
|
|
|
365
365
|
NSString *name = notification.name;
|
|
366
366
|
|
|
367
367
|
if ([name isEqualToString:@"cgmDeviceEvent"]) {
|
|
368
|
-
|
|
368
|
+
NSDictionary *userInfo = notification.userInfo;
|
|
369
|
+
NSString *status = userInfo[@"status"];
|
|
370
|
+
NSString *data = userInfo[@"data"];
|
|
371
|
+
|
|
372
|
+
if (status != nil) {
|
|
373
|
+
NSMutableDictionary *body = [NSMutableDictionary dictionaryWithObject:status forKey:@"status"];
|
|
374
|
+
if (data != nil) {
|
|
375
|
+
body[@"data"] = data;
|
|
376
|
+
}
|
|
377
|
+
[self sendEventWithName:@"cgmDeviceEvent" body:body];
|
|
378
|
+
} else {
|
|
379
|
+
[self sendEventWithName:@"cgmDeviceEvent" body:@{@"status": @"WARM_PERIOD_STARTED"}];
|
|
380
|
+
}
|
|
369
381
|
}
|
|
370
382
|
else if ([name isEqualToString:@"cgmwatchdemoclicked"]) {
|
|
371
383
|
[self sendEventWithName:@"cgmwatchdemoclicked" body:@{@"status": @"cgm_watch_demo_clicked"}];
|