@rentlydev/rently-tuya 0.2.1 → 0.2.3

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.
Files changed (68) hide show
  1. package/android/src/main/java/com/rentlytuya/RentlyTuyaModule.kt +10 -0
  2. package/android/src/main/java/com/rentlytuya/alerts/PermissionAlert.kt +2 -2
  3. package/android/src/main/java/com/rentlytuya/components/AnchorButton.kt +4 -2
  4. package/android/src/main/java/com/rentlytuya/components/Button.kt +5 -4
  5. package/android/src/main/java/com/rentlytuya/components/CustomDatePicker.kt +9 -7
  6. package/android/src/main/java/com/rentlytuya/components/Divider.kt +1 -5
  7. package/android/src/main/java/com/rentlytuya/components/Label.kt +1 -1
  8. package/android/src/main/java/com/rentlytuya/dashboard/AdvancedSettings.kt +11 -9
  9. package/android/src/main/java/com/rentlytuya/dashboard/Dashboard.kt +4 -4
  10. package/android/src/main/java/com/rentlytuya/dashboard/DoorbellSettings.kt +125 -103
  11. package/android/src/main/java/com/rentlytuya/dashboard/FirmwareUpdate.kt +5 -8
  12. package/android/src/main/java/com/rentlytuya/dashboard/Messages.kt +3 -4
  13. package/android/src/main/java/com/rentlytuya/dashboard/NavController.kt +28 -13
  14. package/android/src/main/java/com/rentlytuya/dashboard/OfflineScreen.kt +12 -12
  15. package/android/src/main/java/com/rentlytuya/dashboard/Playback.kt +3 -3
  16. package/android/src/main/java/com/rentlytuya/tuya/Settings.kt +28 -1
  17. package/android/src/main/java/com/rentlytuya/tuya/Tuya.kt +6 -1
  18. package/android/src/main/java/com/rentlytuya/ui/theme/LocalColor.kt +34 -21
  19. package/android/src/main/java/com/rentlytuya/ui/theme/Theme.kt +13 -1
  20. package/android/src/main/java/com/rentlytuya/util/KeylessModule.kt +16 -4
  21. package/android/src/main/res/drawable/update_complete.png +0 -0
  22. package/android/src/main/res/values/strings.xml +4 -2
  23. package/ios/components/Alert.swift +5 -7
  24. package/ios/components/AnchorButton.swift +2 -0
  25. package/ios/components/Button.swift +17 -2
  26. package/ios/components/CustomDatePicker.swift +5 -5
  27. package/ios/components/Label.swift +6 -1
  28. package/ios/dashboard/AdvanceSettings.swift +5 -5
  29. package/ios/dashboard/Dashboard.swift +43 -6
  30. package/ios/dashboard/FirmwareSettings.swift +11 -9
  31. package/ios/dashboard/Messages.swift +5 -3
  32. package/ios/dashboard/NavigationController.swift +51 -8
  33. package/ios/dashboard/OfflineScreen.swift +5 -7
  34. package/ios/dashboard/Playback.swift +7 -5
  35. package/ios/dashboard/PreviewManager.swift +20 -4
  36. package/ios/dashboard/Settings.swift +39 -21
  37. package/ios/generated/RNRentlyTuyaSpec/RNRentlyTuyaSpec.h +30 -0
  38. package/ios/icons/cloud.png +0 -0
  39. package/ios/icons/cloud@2x.png +0 -0
  40. package/ios/icons/cloud@3x.png +0 -0
  41. package/ios/icons/down_update.png +0 -0
  42. package/ios/icons/down_update@2x.png +0 -0
  43. package/ios/icons/down_update@3x.png +0 -0
  44. package/ios/listener/KeylessListener.swift +11 -5
  45. package/ios/listener/RentlyTuya.mm +6 -1
  46. package/ios/listener/RentlyTuyaImpl.swift +11 -1
  47. package/ios/theme/LocalColor.swift +66 -20
  48. package/ios/theme/Theme.swift +162 -25
  49. package/ios/tuya/CameraManager.swift +1 -1
  50. package/ios/tuya/Tuya.swift +8 -0
  51. package/ios/utils/PermissionManager.swift +41 -0
  52. package/lib/commonjs/NativeRentlyTuya.js.map +1 -1
  53. package/lib/commonjs/index.js.map +1 -1
  54. package/lib/module/NativeRentlyTuya.js.map +1 -1
  55. package/lib/module/index.js.map +1 -1
  56. package/lib/typescript/commonjs/src/NativeRentlyTuya.d.ts +5 -0
  57. package/lib/typescript/commonjs/src/NativeRentlyTuya.d.ts.map +1 -1
  58. package/lib/typescript/commonjs/src/index.d.ts +5 -0
  59. package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
  60. package/lib/typescript/module/src/NativeRentlyTuya.d.ts +5 -0
  61. package/lib/typescript/module/src/NativeRentlyTuya.d.ts.map +1 -1
  62. package/lib/typescript/module/src/index.d.ts +5 -0
  63. package/lib/typescript/module/src/index.d.ts.map +1 -1
  64. package/package.json +1 -1
  65. package/src/NativeRentlyTuya.ts +5 -0
  66. package/src/index.tsx +5 -0
  67. package/android/src/main/res/drawable/green_complete.png +0 -0
  68. package/android/src/main/res/drawable/white_complete.png +0 -0
@@ -194,8 +194,10 @@ fun FirmwareUpdate(
194
194
  title = strings(id = R.string.updateFirmware),
195
195
  semiBold = true,
196
196
  textModifier = Modifier,
197
+ primary = isNewVersionAvailable.value,
198
+ grey = !isNewVersionAvailable.value,
197
199
  xl18 = true,
198
- textColor = LocalColor.Monochrome.White,
200
+ textColor = LocalColor.Monochrome.StaticWhite,
199
201
  disabled = !isNewVersionAvailable.value || isLoading.value,
200
202
  onClick = {
201
203
  Heap.trackEvent(eventName = "clickUpdateFirmwareButton")
@@ -285,15 +287,10 @@ fun FirmwareUpdatingScreen(
285
287
  ) {
286
288
  Box(contentAlignment = Alignment.Center) {
287
289
  Image(
288
- painter = painterResource(id = R.drawable.green_complete),
290
+ painter = painterResource(id = R.drawable.update_complete),
289
291
  contentDescription = null,
290
292
  modifier = Modifier.size(150.dp)
291
293
  )
292
- Image(
293
- painter = painterResource(id = R.drawable.white_complete),
294
- contentDescription = null,
295
- modifier = Modifier.size(50.dp)
296
- )
297
294
  }
298
295
 
299
296
  Spacer(modifier = Modifier.height(36.dp))
@@ -339,7 +336,7 @@ fun FirmwareUpdatingScreen(
339
336
  "${(progress * 100).toInt()}%"
340
337
  },
341
338
  xl18 = true,
342
- white = true,
339
+ customColor = LocalColor.Monochrome.StaticWhite,
343
340
  modifier = Modifier.padding(top = 8.dp)
344
341
  )
345
342
  }
@@ -326,7 +326,7 @@ fun MessageItem(
326
326
  title = formatMessageDate(message.dateTime),
327
327
  bold = true,
328
328
  m = true,
329
- black = true,
329
+ secondary = true,
330
330
  medium = true
331
331
  )
332
332
 
@@ -340,7 +340,7 @@ fun MessageItem(
340
340
  strings(id = R.string.unableToCaptureDetectedEvents)
341
341
  },
342
342
  l = true,
343
- primary = true,
343
+ black = true,
344
344
  semiBold = true,
345
345
  maxLines = 6
346
346
  )
@@ -357,7 +357,6 @@ fun MessageItem(
357
357
  }
358
358
  }
359
359
 
360
- Divider(thickness = 1.dp)
361
360
  }
362
361
  }
363
362
  }
@@ -468,7 +467,7 @@ private suspend fun fetchMoreMessages(
468
467
  private fun formatMessageDate(dateTime: String): String {
469
468
  return try {
470
469
  val formatter = SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.getDefault())
471
- val date = formatter.parse(dateTime)
470
+ val date = formatter.parse(dateTime)!!
472
471
  val outputFormatter = SimpleDateFormat("MM/dd/yyyy hh:mm a", Locale.getDefault())
473
472
  outputFormatter.format(date)
474
473
  } catch (e: Exception) {
@@ -4,6 +4,7 @@ import android.app.Activity
4
4
  import android.content.res.Configuration
5
5
  import android.os.Build
6
6
  import android.util.Log
7
+ import androidx.activity.compose.BackHandler
7
8
  import androidx.compose.animation.EnterTransition
8
9
  import androidx.compose.animation.ExitTransition
9
10
  import androidx.compose.foundation.Image
@@ -46,6 +47,7 @@ import com.rentlytuya.tuya.Tuya
46
47
  import com.rentlytuya.tuya.Tuya.TAG
47
48
  import com.rentlytuya.tuya.Tuya.isDefaultSettingsUpdated
48
49
  import com.rentlytuya.tuya.Tuya.isResident
50
+ import com.rentlytuya.tuya.Tuya.doorbellSetting
49
51
  import com.rentlytuya.ui.theme.LocalColor
50
52
  import com.rentlytuya.util.DPConstants
51
53
  import com.rentlytuya.util.DateUtil.isNotNull
@@ -88,6 +90,7 @@ fun NavController(
88
90
  val isWaterMarkEnabled = remember { mutableStateOf(false) }
89
91
  val isFlipEnabled = remember { mutableStateOf(false) }
90
92
  val isAntiDismantlingAlarmEnabled = remember { mutableStateOf(false) }
93
+ val isDoorbellCallEnabled = remember { mutableStateOf(false) }
91
94
  val nightVisionLevel = remember { mutableStateOf("0") }
92
95
  val isMotionDetectionEnabled = remember { mutableStateOf(false) }
93
96
  val motionSensitivityLevel = remember { mutableStateOf("0") }
@@ -137,8 +140,15 @@ fun NavController(
137
140
  }
138
141
  }
139
142
 
140
- Column(modifier = Modifier.fillMaxSize()) {
143
+ LaunchedEffect(Unit) {
144
+ if (doorbellSetting) {
145
+ //navigate to settings screen
146
+ isSettings.value = true
147
+ navController.navigate(ScreenRoutes.SETTINGS)
148
+ }
149
+ }
141
150
 
151
+ Column(modifier = Modifier.fillMaxSize()) {
142
152
  if (configuration.orientation == Configuration.ORIENTATION_PORTRAIT ||
143
153
  (configuration.orientation == Configuration.ORIENTATION_LANDSCAPE &&
144
154
  currentDestination.value != ScreenRoutes.DASHBOARD && currentDestination.value != ScreenRoutes.PLAYBACK && currentDestination.value != ScreenRoutes.ACTIVITY_HISTORY)
@@ -147,11 +157,12 @@ fun NavController(
147
157
  title = when {
148
158
  isFirmwareUpdate.value -> strings(id = R.string.firmwareVersion)
149
159
  isFirmwareUpdate.value && isUpdateInProgress.value -> strings(id = R.string.updateFirmware)
150
- isAdvancedSettings.value -> strings(id = R.string.advancedSettings)
160
+ isAdvancedSettings.value -> strings(id = R.string.deviceInformation)
151
161
  isStorageSettings.value -> strings(id = R.string.activityStorage)
152
162
  currentDestination.value == ScreenRoutes.DASHBOARD -> deviceName.value
153
163
  else -> currentDestination.value
154
164
  },
165
+ currentRoute = currentDestination.value,
155
166
  onTrailingIconClick = {
156
167
  when (currentDestination.value) {
157
168
  ScreenRoutes.PLAYBACK -> isDatePickerVisible.value = true
@@ -191,6 +202,7 @@ fun NavController(
191
202
  isWaterMarkEnabled = isWaterMarkEnabled,
192
203
  isFlipEnabled = isFlipEnabled,
193
204
  isAntiDismantlingAlarmEnabled = isAntiDismantlingAlarmEnabled,
205
+ isDoorbellCallEnabled = isDoorbellCallEnabled,
194
206
  nightVisionLevel = nightVisionLevel,
195
207
  isMotionDetectionEnabled = isMotionDetectionEnabled,
196
208
  motionSensitivityLevel = motionSensitivityLevel,
@@ -295,6 +307,7 @@ fun NavController(
295
307
  isWaterMarkEnabled = isWaterMarkEnabled,
296
308
  isFlipEnabled = isFlipEnabled,
297
309
  isAntiDismantlingAlarmEnabled = isAntiDismantlingAlarmEnabled,
310
+ isDoorbellCallEnabled = isDoorbellCallEnabled,
298
311
  nightVisionLevel = nightVisionLevel,
299
312
  isMotionDetectionEnabled = isMotionDetectionEnabled,
300
313
  motionSensitivityLevel = motionSensitivityLevel,
@@ -321,17 +334,19 @@ fun NavController(
321
334
  @Composable
322
335
  fun TopBar(
323
336
  title: String,
337
+ currentRoute: String = "",
324
338
  onBack: () -> Unit = {},
325
339
  onTrailingIconClick: () -> Unit = {}
326
340
  ) {
327
341
 
328
- val isSpecialTitle = title in listOf(ScreenRoutes.SETTINGS, ScreenRoutes.ACTIVITY_HISTORY, strings(id = R.string.advancedSettings), strings(id = R.string.activityStorage), strings(id = R.string.firmwareVersion), strings(id = R.string.updateFirmware))
342
+ val isSpecialTitle = title in listOf(ScreenRoutes.SETTINGS, ScreenRoutes.ACTIVITY_HISTORY, strings(id = R.string.deviceInformation), strings(id = R.string.activityStorage), strings(id = R.string.firmwareVersion), strings(id = R.string.updateFirmware))
343
+ val isDashboard = currentRoute == ScreenRoutes.DASHBOARD
329
344
 
330
345
  Box(
331
346
  modifier = Modifier
332
347
  .fillMaxWidth()
333
348
  .fillMaxHeight(0.075f)
334
- .background(if (isSpecialTitle) LocalColor.Main.Light else LocalColor.Monochrome.Grey)
349
+ .background(if (isDashboard) LocalColor.Monochrome.DarkGrey else LocalColor.Main.Light)
335
350
  ) {
336
351
  IconButton(
337
352
  modifier = Modifier
@@ -347,9 +362,10 @@ fun TopBar(
347
362
  Image(
348
363
  modifier = Modifier.size(35.dp),
349
364
  painter = painterResource(
350
- id = if (isSpecialTitle) R.drawable.ic_action_arrow_backward else R.drawable.ic_arrow_backward_white
365
+ id = if (isDashboard) R.drawable.ic_arrow_backward_white else R.drawable.ic_action_arrow_backward
351
366
  ),
352
- contentDescription = "back"
367
+ contentDescription = "back",
368
+ colorFilter = if (isDashboard) null else ColorFilter.tint(color = LocalColor.Monochrome.BlackColor)
353
369
  )
354
370
  }
355
371
 
@@ -364,8 +380,7 @@ fun TopBar(
364
380
  title = title,
365
381
  semiBold = true,
366
382
  xl20 = true,
367
- white = !isSpecialTitle,
368
- black = isSpecialTitle
383
+ customColor = if (isDashboard) LocalColor.Monochrome.StaticWhite else LocalColor.Monochrome.BlackColor
369
384
  )
370
385
  }
371
386
  if (!isSpecialTitle || title == ScreenRoutes.PLAYBACK || title == ScreenRoutes.ACTIVITY_HISTORY) {
@@ -381,11 +396,7 @@ fun TopBar(
381
396
  id = if (title == ScreenRoutes.PLAYBACK || title == ScreenRoutes.ACTIVITY_HISTORY) R.drawable.ic_calendar else R.drawable.ic_setting
382
397
  ),
383
398
  contentDescription = "trailingIcon",
384
- colorFilter = if (title == ScreenRoutes.ACTIVITY_HISTORY) {
385
- ColorFilter.tint(color = LocalColor.Monochrome.Grey)
386
- } else {
387
- null
388
- }
399
+ colorFilter = if (isDashboard) null else ColorFilter.tint(color = LocalColor.Monochrome.BlackColor)
389
400
  )
390
401
  }
391
402
  }
@@ -410,6 +421,10 @@ private fun handleBackNavigation(
410
421
  isAdvancedSettings.value = false
411
422
  isStorageSettings.value = false
412
423
  navController.navigate(ScreenRoutes.SETTINGS)
424
+ } else if (doorbellSetting && isSettings.value) {
425
+ // If doorbellSetting is true and we're in settings, finish the activity
426
+ isSettings.value = false
427
+ activity.finish()
413
428
  } else if (currentDestination.value == ScreenRoutes.DASHBOARD) {
414
429
  scope.launch {
415
430
  val success = Tuya.disconnect { value -> isLoading.value = value }
@@ -17,6 +17,7 @@ import androidx.compose.runtime.Composable
17
17
  import androidx.compose.runtime.DisposableEffect
18
18
  import androidx.compose.ui.Alignment
19
19
  import androidx.compose.ui.Modifier
20
+ import androidx.compose.ui.graphics.Color
20
21
  import androidx.compose.ui.platform.LocalContext
21
22
  import androidx.compose.ui.unit.dp
22
23
  import com.facebook.react.ReactApplication
@@ -63,7 +64,7 @@ fun OfflineScreen(
63
64
  modifier = Modifier
64
65
  .padding(bottom = 15.dp),
65
66
  title = strings(id = R.string.connectionFailed),
66
- white = true,
67
+ customColor = LocalColor.Monochrome.StaticWhite,
67
68
  xl20 = true,
68
69
  bold = true,
69
70
  center = true
@@ -73,7 +74,7 @@ fun OfflineScreen(
73
74
  modifier = Modifier
74
75
  .padding(bottom = 10.dp),
75
76
  title = strings(id = R.string.pleaseCheckTheFollowing),
76
- white = true,
77
+ customColor = LocalColor.Monochrome.StaticWhite,
77
78
  maxLines = 2
78
79
  )
79
80
 
@@ -81,7 +82,7 @@ fun OfflineScreen(
81
82
  modifier = Modifier
82
83
  .padding(start = 10.dp, bottom = 10.dp),
83
84
  title = strings(id = R.string.moveYourWiFi),
84
- white = true,
85
+ customColor = LocalColor.Monochrome.StaticWhite,
85
86
  maxLines = 2
86
87
  )
87
88
 
@@ -93,7 +94,7 @@ fun OfflineScreen(
93
94
  } else {
94
95
  strings(id = R.string.pressTheDoorbellButtonFor15s)
95
96
  },
96
- white = true,
97
+ customColor = LocalColor.Monochrome.StaticWhite,
97
98
  maxLines = 6
98
99
  )
99
100
 
@@ -102,7 +103,7 @@ fun OfflineScreen(
102
103
  modifier = Modifier
103
104
  .padding(start = 10.dp, top = 10.dp),
104
105
  title = strings(id = R.string.ensureTheHomeBaseIsPlugged),
105
- white = true,
106
+ customColor = LocalColor.Monochrome.StaticWhite,
106
107
  maxLines = 4
107
108
  )
108
109
  }
@@ -111,7 +112,7 @@ fun OfflineScreen(
111
112
  modifier = Modifier
112
113
  .padding(top = 25.dp),
113
114
  title = strings(id = R.string.firstTimeUsingDoorbell),
114
- white = true
115
+ customColor = LocalColor.Monochrome.StaticWhite
115
116
  )
116
117
 
117
118
  AnchorButton(
@@ -119,13 +120,12 @@ fun OfflineScreen(
119
120
  .padding(bottom = 20.dp),
120
121
  id = "Connect_Doorbell_To_WiFi",
121
122
  title = strings(id = R.string.connectDoorbellToWiFi),
122
- primary = true,
123
+ customColor = LocalColor.Primary.Light,
123
124
  underLine = true,
124
125
  onClick = {
125
- Tuya.deviceId?.let {
126
126
  KeylessModule.instance?.sendDataToJS(
127
127
  eventName = "RESET_WIFI",
128
- deviceId = it,
128
+ value = Tuya.tuyaProductName ?: "",
129
129
  onSuccess = {
130
130
  Log.i(TAG, "Navigate to Add Doorbell Success")
131
131
  activity.finish()
@@ -134,7 +134,6 @@ fun OfflineScreen(
134
134
  Log.i(TAG, "Navigate to Add Doorbell Failed")
135
135
  }
136
136
  )
137
- } ?: Log.i(TAG, "Device ID is null")
138
137
  }
139
138
  )
140
139
 
@@ -148,7 +147,8 @@ fun OfflineScreen(
148
147
  xl20 = true,
149
148
  black = true,
150
149
  iconId = R.drawable.ic_retry,
151
- textColor = LocalColor.Primary.Light,
150
+ textColor = LocalColor.Monochrome.StaticWhite,
151
+ backgroundColor = LocalColor.Monochrome.Black,
152
152
  borderColor = LocalColor.Primary.Light
153
153
  ) {
154
154
  onReConnect()
@@ -158,7 +158,7 @@ fun OfflineScreen(
158
158
  modifier = Modifier
159
159
  .padding(bottom = 5.dp),
160
160
  title = strings(id = R.string.contactSupport),
161
- white = true,
161
+ customColor = LocalColor.Monochrome.StaticWhite,
162
162
  center = true,
163
163
  maxLines = 2
164
164
  )
@@ -485,7 +485,7 @@ fun VideoItem(
485
485
  .height(78.dp)
486
486
  .padding(top = 10.dp)
487
487
  .shadow(1.dp)
488
- .background(if (selectedItem.value == video) LocalColor.Secondary.Light else LocalColor.Monochrome.White)
488
+ .background(if (selectedItem.value == video) LocalColor.Main.Dark else LocalColor.Monochrome.White)
489
489
  .clickable {
490
490
  if (selectedItem.value == video) {
491
491
  currentSliderValue.intValue = 0
@@ -508,7 +508,7 @@ fun VideoItem(
508
508
  ) {
509
509
  Label(
510
510
  title = DateUtil.convertTimestampToTime(video.startTime).uppercase(),
511
- primary = true,
511
+ customColor = if (selectedItem.value == video) LocalColor.Monochrome.StaticWhite else LocalColor.Monochrome.BlackColor,
512
512
  l = true,
513
513
  center = true,
514
514
  semiBold = true
@@ -520,7 +520,7 @@ fun VideoItem(
520
520
  endTime = video.endTime
521
521
  )
522
522
  }",
523
- secondary = true,
523
+ customColor = if (selectedItem.value == video) LocalColor.Monochrome.StaticWhite else LocalColor.Primary.Secondary,
524
524
  semiBold = true,
525
525
  center = true,
526
526
  s = true,
@@ -88,6 +88,7 @@ object Settings {
88
88
  isWaterMarkEnabled: MutableState<Boolean>,
89
89
  isFlipEnabled: MutableState<Boolean>,
90
90
  isAntiDismantlingAlarmEnabled: MutableState<Boolean>,
91
+ isDoorbellCallEnabled: MutableState<Boolean>,
91
92
  nightVisionLevel: MutableState<String>,
92
93
  isMotionDetectionEnabled: MutableState<Boolean>,
93
94
  motionSensitivityLevel: MutableState<String>,
@@ -104,6 +105,7 @@ object Settings {
104
105
  usedStorage: MutableState<String>,
105
106
  remainingStorageCapacity: MutableState<String>
106
107
  ) {
108
+ isDoorbellCallEnabled.value = Tuya.isDoorbellCallEnabled
107
109
  val deviceBean = ThingHomeSdk.getDataInstance().getDeviceBean(deviceId)
108
110
  if (deviceBean.isNotNull()) {
109
111
  for ((key, value) in deviceBean.getDps()) {
@@ -319,6 +321,31 @@ object Settings {
319
321
  )
320
322
  }
321
323
 
324
+ fun setEnableDoorbellCall(
325
+ enable: Boolean,
326
+ isLoading: MutableState<Boolean>,
327
+ isDoorbellCallEnabled: MutableState<Boolean>
328
+ ) {
329
+ isLoading.value = true
330
+ Tuya.id?.let {
331
+ KeylessModule.instance?.sendDataToJS(
332
+ eventName = "ENABLE_DOORBELL_CALL",
333
+ value = it,
334
+ enableValue = enable,
335
+ onSuccess = {
336
+ isLoading.value = false
337
+ isDoorbellCallEnabled.value = enable
338
+ Log.i(TAG, "Doorbell Call Update Success")
339
+ },
340
+ onFailure = {
341
+ isLoading.value = false
342
+ isDoorbellCallEnabled.value = !enable
343
+ Log.i(TAG,"Doorbell Call Update Failed")
344
+ }
345
+ )
346
+ } ?: Log.i(TAG, "ID is null")
347
+ }
348
+
322
349
  fun setNightVision(
323
350
  newMode: String,
324
351
  mode: MutableState<String>,
@@ -1038,7 +1065,7 @@ object DefaultSettings {
1038
1065
  Tuya.id?.let {
1039
1066
  KeylessModule.instance?.sendDataToJS(
1040
1067
  eventName = "RESET_DEFAULT_SETTINGS_FLAG",
1041
- deviceId = it,
1068
+ value = it,
1042
1069
  onSuccess = {
1043
1070
  Log.i(TAG, "Reset Default Settings Success")
1044
1071
  },
@@ -44,6 +44,7 @@ object Tuya {
44
44
  var tuyaProductName: String? = null
45
45
  var tuyaProductID: String? = null
46
46
  var lastMoveOutDate: String? = null
47
+ var isDoorbellCallEnabled: Boolean = false
47
48
  var resetRequired: Boolean? = null
48
49
  var isResident: Boolean = true
49
50
  var displayRemoveDoorbellButton: Boolean? = null
@@ -54,9 +55,13 @@ object Tuya {
54
55
  var continuousRecording: Boolean = false
55
56
  var eventRecording: Boolean = false
56
57
  var setSensitivityLow: Boolean = false
58
+ var darkThemeEnabled: Boolean = false
59
+ var useSystemSetting: Boolean = false
57
60
 
58
- val scope = CoroutineScope(Dispatchers.IO + SupervisorJob())
61
+ // For navigation handling for AOSU charging
62
+ var doorbellSetting: Boolean = false
59
63
 
64
+ val scope = CoroutineScope(Dispatchers.IO + SupervisorJob())
60
65
  suspend fun login(
61
66
  uid: String,
62
67
  password: String,
@@ -1,46 +1,53 @@
1
1
  package com.rentlytuya.ui.theme
2
2
 
3
3
  import android.util.Log
4
+ import androidx.compose.runtime.getValue
5
+ import androidx.compose.runtime.mutableStateOf
6
+ import androidx.compose.runtime.setValue
4
7
  import androidx.compose.ui.graphics.Color
5
8
  import com.rentlytuya.tuya.Tuya.TAG
6
9
 
7
10
  object LocalColor {
8
11
 
9
12
  object Main {
10
- var Light = Color(0xFFf3faff)
11
- var Dark = Color(0xFF329ddc)
13
+ var Light by mutableStateOf(Color(0xFFf3faff))
14
+ var Dark by mutableStateOf(Color(0xFF329ddc))
12
15
  }
13
16
 
14
17
  object Primary {
15
- var Light = Color(0xFF39a1e8)
16
- var Secondary = Color(0xFF6a97b5)
17
- var Dark = Color(0xFF329ddc)
18
- var Medium = Color(0xFF008adc)
18
+ var Light by mutableStateOf(Color(0xFF39a1e8))
19
+ var Secondary by mutableStateOf(Color(0xFF6a97b5))
20
+ var Dark by mutableStateOf(Color(0xFF329ddc))
21
+ var Medium by mutableStateOf(Color(0xFF008adc))
19
22
  }
20
23
 
21
24
  object Secondary {
22
- var White = Color(0xFFf3faff)
23
- var Light = Color(0xFFd9edfb)
25
+ var Light by mutableStateOf(Color(0xFFd9edfb))
24
26
  }
25
27
 
26
28
  object Danger {
27
- var Primary = Color(0xFFcb0000)
29
+ var Primary by mutableStateOf(Color(0xFFcb0000))
30
+ var Secondary by mutableStateOf(Color(0xFFEF4343))
28
31
  }
29
32
 
30
33
  object Monochrome {
31
- var White = Color(0xFFFFFFFF)
32
- var LightGrey = Color(0xFF80FFFFFF)
33
- var Regular = Color(0xFF86858C)
34
- var Medium = Color(0xFF3f4d59)
35
- var Grey = Color(0xFF373737)
36
- var Black = Color(0xFF000000)
37
- var Brown = Color(0xFFB45309)
34
+ var White by mutableStateOf(Color(0xFFFFFFFF))
35
+ var BlackColor by mutableStateOf(Color(0xFF000000))
36
+ var LightGrey by mutableStateOf(Color(0xFF1A1A1A))
37
+ var DarkGrey by mutableStateOf(Color(0xFF1A1A1A))
38
+ var Regular by mutableStateOf(Color(0xFF86858C))
39
+ var Medium by mutableStateOf(Color(0xFF3f4d59))
40
+ var Grey by mutableStateOf(Color(0xFF373737))
41
+ var Black by mutableStateOf(Color(0xFF000000))
42
+ var Brown by mutableStateOf(Color(0xFFB45309))
43
+ var DatePickerBackground by mutableStateOf(Color(0xFF177BB5))
44
+ val StaticWhite = Color(0xFFFFFFFF)
38
45
  }
39
46
 
40
- fun setTheme(flavour: String) {
47
+ fun setTheme(flavour: String, darkThemeEnabled: Boolean = false) {
41
48
  when (flavour.lowercase()) {
42
49
  "keyless" -> {
43
- setSmartHomeTheme()
50
+ setSmartHomeTheme(darkThemeEnabled)
44
51
  }
45
52
 
46
53
  "progress" -> {
@@ -60,9 +67,15 @@ object LocalColor {
60
67
  }
61
68
  }
62
69
 
63
- private fun setSmartHomeTheme() {
64
- LocalColor.Main.Light = Color(0xFFf3faff)
65
- LocalColor.Main.Dark = Color(0xFF329ddc)
70
+ private fun setSmartHomeTheme(darkThemeEnabled: Boolean = false) {
71
+ LocalColor.Main.Light = if (darkThemeEnabled) Color(0xFF1A1A1A) else Color(0xFFF9FAFB)
72
+ LocalColor.Main.Dark = Color(0xFF177BB5)
73
+ LocalColor.Primary.Secondary = if (darkThemeEnabled) Color(0xFFF9FAFB) else Color(0xFF374151)
74
+ LocalColor.Monochrome.White = if (darkThemeEnabled) Color(0xFF242526) else Color(0xFFFFFFFF)
75
+ LocalColor.Monochrome.Medium = if (darkThemeEnabled) Color(0xFFF9FAFB) else Color(0xFF3f4d59)
76
+ LocalColor.Monochrome.Regular = if (darkThemeEnabled) Color(0xFFD1D5DB) else Color(0xFF6B7280)
77
+ LocalColor.Monochrome.BlackColor = if (darkThemeEnabled) Color(0xFFF9FAFB) else Color(0xFF000000)
78
+ LocalColor.Monochrome.DatePickerBackground = if (darkThemeEnabled) Color(0xFF373737) else Color(0xFF177BB5)
66
79
  }
67
80
 
68
81
  private fun setProgressTheme() {
@@ -8,6 +8,7 @@ import androidx.compose.runtime.SideEffect
8
8
  import androidx.compose.ui.graphics.toArgb
9
9
  import androidx.compose.ui.platform.LocalView
10
10
  import androidx.core.view.WindowCompat
11
+ import com.rentlytuya.tuya.Tuya
11
12
 
12
13
  @Composable
13
14
  fun TuyaTheme(
@@ -16,6 +17,17 @@ fun TuyaTheme(
16
17
  dynamicColor: Boolean = true,
17
18
  content: @Composable () -> Unit
18
19
  ) {
20
+
21
+ val effectiveDark = if (Tuya.useSystemSetting) {
22
+ darkTheme
23
+ } else {
24
+ Tuya.darkThemeEnabled
25
+ }
26
+
27
+ // Modify this if other flavors needs to support dark theme
28
+ SideEffect {
29
+ LocalColor.setTheme("keyless", effectiveDark)
30
+ }
19
31
 
20
32
  val view = LocalView.current
21
33
  if (!view.isInEditMode) {
@@ -23,7 +35,7 @@ fun TuyaTheme(
23
35
  val window = (view.context as Activity).window
24
36
  // window.statusBarColor = LocalColor.Monochrome.Grey.toArgb()
25
37
  window.navigationBarColor = LocalColor.Monochrome.Grey.toArgb()
26
- WindowCompat.getInsetsController(window, view).isAppearanceLightStatusBars = darkTheme
38
+ WindowCompat.getInsetsController(window, view).isAppearanceLightStatusBars = effectiveDark
27
39
  }
28
40
  }
29
41
 
@@ -23,15 +23,27 @@ class KeylessModule(reactContext: ReactApplicationContext) :
23
23
 
24
24
  fun sendDataToJS(
25
25
  eventName: String,
26
- deviceId: String,
26
+ value: String,
27
+ enableValue: Boolean? = null, // only used for ENABLE_DOORBELL_CALL
27
28
  onSuccess: (String) -> Unit,
28
29
  onFailure: (String) -> Unit
29
30
  ) {
30
31
  try {
31
32
  val params = WritableNativeMap()
32
- // For Update Default Settings value, id is passed
33
- val key = if (eventName == "RESET_DEFAULT_SETTINGS_FLAG") "id" else "device_id"
34
- params.putString(key, deviceId)
33
+ //For reset default settings value , id is passed
34
+ //For reset wifi, tuyaProductName is passed
35
+ val key = when (eventName) {
36
+ "RESET_DEFAULT_SETTINGS_FLAG" -> "id"
37
+ "RESET_WIFI" -> "doorbellType"
38
+ "REMOVE_CAMERA" -> "device_id"
39
+ "ENABLE_DOORBELL_CALL" -> "id"
40
+ else -> "device_id"
41
+ }
42
+ params.putString(key, value)
43
+
44
+ if (eventName == "ENABLE_DOORBELL_CALL" && enableValue != null) {
45
+ params.putBoolean("doorbell_calling_enabled", enableValue)
46
+ }
35
47
 
36
48
  onSuccessListener = onSuccess
37
49
  onFailureListener = onFailure
@@ -19,7 +19,7 @@
19
19
  <string name="tapToSpeak">Tap to Speak</string>
20
20
 
21
21
  <!-- Title -->
22
- <string name="advancedSettings">Advanced Settings</string>
22
+ <string name="deviceInformation">Device Information</string>
23
23
  <string name="activityStorage">Activity Storage</string>
24
24
  <string name="firmwareVersion">Firmware Version</string>
25
25
 
@@ -46,12 +46,14 @@
46
46
  <string name="flipScreenDescription">Flip the doorbell camera preview screen.</string>
47
47
  <string name="antiDismantlingAlarm">Anti-Dismantling Alarm</string>
48
48
  <string name="antiDismantlingAlarmDescription">Enabling this will trigger an alarm sound if the doorbell is forcibly removed from its mounting case.</string>
49
+ <string name="doorbellCall">Doorbell Call</string>
50
+ <string name="doorbellCallDescription">Enabling this will initiate doorbell call when someone press doorbell ring button.</string>
49
51
  <string name="irNightVision">IR Night Vision</string>
50
52
  <string name="nightVision">Night Vision</string>
51
53
  <string name="nightVisionDescription">Doorbell camera\'s night vision settings.</string>
52
54
  <string name="motionDetection">Motion Detection</string>
53
55
  <string name="motionDetectionDescription8s">Triggered motion will send push notifications.</string>
54
- <string name="motionDetectionDescription">If motion detection is enabled and motion is detected, the system will record the event and send a push notification.</string>
56
+ <string name="motionDetectionDescription">If motion detection is enabled and motion is detected, the app will record the event and send a push notification.</string>
55
57
  <string name="motionSensitivityLevel">Motion Sensitivity Level</string>
56
58
  <string name="storageSettings">Storage Settings</string>
57
59
  <string name="storageSetting">Storage Setting</string>
@@ -10,8 +10,8 @@ func getAlert(
10
10
  primaryAction: @escaping () -> Void,
11
11
  secondaryAction: @escaping () -> Void = {}
12
12
  ) -> Alert {
13
-
14
- updateAlertBackgroundColor()
13
+ // This is commented out for supporting dark mode for system alerts and pickers.
14
+ // updateAlertBackgroundColor()
15
15
 
16
16
  return Alert(
17
17
  title: Text(title),
@@ -30,8 +30,7 @@ func getAlert(
30
30
  }
31
31
 
32
32
  func getAlertwithSingleButton(title: String, message: String) -> Alert {
33
-
34
- updateAlertBackgroundColor()
33
+ // updateAlertBackgroundColor()
35
34
 
36
35
  return Alert(
37
36
  title: Text(title),
@@ -44,7 +43,7 @@ func getAlertwithSingleButton(title: String, message: String) -> Alert {
44
43
 
45
44
  func getSuccessAlert(title: String, action: (() -> Void)? = nil) -> Alert {
46
45
 
47
- updateAlertBackgroundColor()
46
+ // updateAlertBackgroundColor()
48
47
 
49
48
  if let action = action {
50
49
  return Alert(
@@ -62,8 +61,7 @@ func getSuccessAlert(title: String, action: (() -> Void)? = nil) -> Alert {
62
61
  }
63
62
 
64
63
  func getFailureAlert(title: String, action: (() -> Void)? = nil) -> Alert {
65
-
66
- updateAlertBackgroundColor()
64
+ // updateAlertBackgroundColor()
67
65
 
68
66
  if let action = action {
69
67
  return Alert(
@@ -19,6 +19,7 @@ struct AnchorButton: View {
19
19
  var primary: Bool = false
20
20
  var secondary: Bool = false
21
21
  var black: Bool = false
22
+ var paleWhite: Bool = false
22
23
 
23
24
  // Font Weight
24
25
  var light: Bool = false
@@ -58,6 +59,7 @@ struct AnchorButton: View {
58
59
  if primary { return LocalColor.Primary.light }
59
60
  if secondary { return LocalColor.Main.dark }
60
61
  if black { return LocalColor.Monochrome.black }
62
+ if paleWhite { return LocalColor.Monochrome.paleWhite }
61
63
  return LocalColor.Primary.light
62
64
  }
63
65