@rentlydev/rently-tuya 0.1.0
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/LICENSE +20 -0
- package/README.md +281 -0
- package/android/build.gradle +182 -0
- package/android/gradle.properties +7 -0
- package/android/libs/airbrake-android-1.4.0.jar +0 -0
- package/android/src/main/AndroidManifest.xml +1 -0
- package/android/src/main/AndroidManifestNew.xml +25 -0
- package/android/src/main/java/com/rentlytuya/RentlyTuyaModule.kt +503 -0
- package/android/src/main/java/com/rentlytuya/RentlyTuyaPackage.kt +18 -0
- package/android/src/main/java/com/rentlytuya/TuyaActivity.kt +45 -0
- package/android/src/main/java/com/rentlytuya/alerts/FormatSDCardAlert.kt +83 -0
- package/android/src/main/java/com/rentlytuya/alerts/PermissionAlert.kt +91 -0
- package/android/src/main/java/com/rentlytuya/alerts/RemoveDoorbellAlert.kt +83 -0
- package/android/src/main/java/com/rentlytuya/alerts/RemoveDoorbellFailureAlert.kt +71 -0
- package/android/src/main/java/com/rentlytuya/alerts/ResetWifiAlert.kt +83 -0
- package/android/src/main/java/com/rentlytuya/alerts/SuccessAlert.kt +74 -0
- package/android/src/main/java/com/rentlytuya/components/Alert.kt +47 -0
- package/android/src/main/java/com/rentlytuya/components/AnchorButton.kt +125 -0
- package/android/src/main/java/com/rentlytuya/components/Button.kt +147 -0
- package/android/src/main/java/com/rentlytuya/components/CustomDatePicker.kt +275 -0
- package/android/src/main/java/com/rentlytuya/components/Divider.kt +53 -0
- package/android/src/main/java/com/rentlytuya/components/EncryptedImageView.kt +59 -0
- package/android/src/main/java/com/rentlytuya/components/Label.kt +155 -0
- package/android/src/main/java/com/rentlytuya/components/LoadingIndicator.kt +75 -0
- package/android/src/main/java/com/rentlytuya/components/Slider.kt +66 -0
- package/android/src/main/java/com/rentlytuya/components/Switch.kt +51 -0
- package/android/src/main/java/com/rentlytuya/components/VideoView.kt +45 -0
- package/android/src/main/java/com/rentlytuya/dashboard/AdvancedSettings.kt +259 -0
- package/android/src/main/java/com/rentlytuya/dashboard/Dashboard.kt +551 -0
- package/android/src/main/java/com/rentlytuya/dashboard/DoorbellSettings.kt +874 -0
- package/android/src/main/java/com/rentlytuya/dashboard/Messages.kt +463 -0
- package/android/src/main/java/com/rentlytuya/dashboard/NavController.kt +358 -0
- package/android/src/main/java/com/rentlytuya/dashboard/OfflineScreen.kt +160 -0
- package/android/src/main/java/com/rentlytuya/dashboard/Playback.kt +685 -0
- package/android/src/main/java/com/rentlytuya/tuya/Messages.kt +234 -0
- package/android/src/main/java/com/rentlytuya/tuya/Playback.kt +385 -0
- package/android/src/main/java/com/rentlytuya/tuya/ScreenCapture.kt +244 -0
- package/android/src/main/java/com/rentlytuya/tuya/Settings.kt +809 -0
- package/android/src/main/java/com/rentlytuya/tuya/Tuya.kt +497 -0
- package/android/src/main/java/com/rentlytuya/ui/theme/LocalColor.kt +80 -0
- package/android/src/main/java/com/rentlytuya/ui/theme/LocalFont.kt +35 -0
- package/android/src/main/java/com/rentlytuya/ui/theme/Theme.kt +34 -0
- package/android/src/main/java/com/rentlytuya/ui/theme/Type.kt +34 -0
- package/android/src/main/java/com/rentlytuya/util/Airbrake.kt +40 -0
- package/android/src/main/java/com/rentlytuya/util/DpConstants.kt +53 -0
- package/android/src/main/java/com/rentlytuya/util/FrescoManager.kt +86 -0
- package/android/src/main/java/com/rentlytuya/util/HeapAnalytics.kt +16 -0
- package/android/src/main/java/com/rentlytuya/util/KeylessModule.kt +81 -0
- package/android/src/main/java/com/rentlytuya/util/PermissionHandler.kt +75 -0
- package/android/src/main/java/com/rentlytuya/util/ReactParamsCheck.kt +152 -0
- package/android/src/main/java/com/rentlytuya/util/Util.kt +128 -0
- package/android/src/main/res/drawable/ic_close.xml +12 -0
- package/android/src/main/res/drawable/ic_launcher_background.xml +170 -0
- package/android/src/main/res/drawable/ic_launcher_foreground.xml +30 -0
- package/android/src/main/res/drawable/img_place_holder.png +0 -0
- package/android/src/main/res/drawable-hdpi/ic_action_arrow_backward.png +0 -0
- package/android/src/main/res/drawable-hdpi/ic_arrow_backward_white.png +0 -0
- package/android/src/main/res/drawable-hdpi/ic_arrow_blue_right.png +0 -0
- package/android/src/main/res/drawable-hdpi/ic_calendar.png +0 -0
- package/android/src/main/res/drawable-hdpi/ic_camera.png +0 -0
- package/android/src/main/res/drawable-hdpi/ic_message.png +0 -0
- package/android/src/main/res/drawable-hdpi/ic_pause.png +0 -0
- package/android/src/main/res/drawable-hdpi/ic_play.png +0 -0
- package/android/src/main/res/drawable-hdpi/ic_play_back.png +0 -0
- package/android/src/main/res/drawable-hdpi/ic_record.png +0 -0
- package/android/src/main/res/drawable-hdpi/ic_retry.png +0 -0
- package/android/src/main/res/drawable-hdpi/ic_setting.png +0 -0
- package/android/src/main/res/drawable-hdpi/ic_sound_off.png +0 -0
- package/android/src/main/res/drawable-hdpi/ic_sound_on.png +0 -0
- package/android/src/main/res/drawable-mdpi/ic_action_arrow_backward.png +0 -0
- package/android/src/main/res/drawable-mdpi/ic_arrow_backward_white.png +0 -0
- package/android/src/main/res/drawable-mdpi/ic_arrow_blue_right.png +0 -0
- package/android/src/main/res/drawable-mdpi/ic_battery_average.png +0 -0
- package/android/src/main/res/drawable-mdpi/ic_battery_charging.png +0 -0
- package/android/src/main/res/drawable-mdpi/ic_battery_full.png +0 -0
- package/android/src/main/res/drawable-mdpi/ic_battery_good.png +0 -0
- package/android/src/main/res/drawable-mdpi/ic_battery_low.png +0 -0
- package/android/src/main/res/drawable-mdpi/ic_calendar.png +0 -0
- package/android/src/main/res/drawable-mdpi/ic_camera.png +0 -0
- package/android/src/main/res/drawable-mdpi/ic_message.png +0 -0
- package/android/src/main/res/drawable-mdpi/ic_pause.png +0 -0
- package/android/src/main/res/drawable-mdpi/ic_play.png +0 -0
- package/android/src/main/res/drawable-mdpi/ic_play_back.png +0 -0
- package/android/src/main/res/drawable-mdpi/ic_record.png +0 -0
- package/android/src/main/res/drawable-mdpi/ic_retry.png +0 -0
- package/android/src/main/res/drawable-mdpi/ic_setting.png +0 -0
- package/android/src/main/res/drawable-mdpi/ic_sound_off.png +0 -0
- package/android/src/main/res/drawable-mdpi/ic_sound_on.png +0 -0
- package/android/src/main/res/drawable-xhdpi/ic_action_arrow_backward.png +0 -0
- package/android/src/main/res/drawable-xhdpi/ic_arrow_backward_white.png +0 -0
- package/android/src/main/res/drawable-xhdpi/ic_arrow_blue_right.png +0 -0
- package/android/src/main/res/drawable-xhdpi/ic_battery_average.png +0 -0
- package/android/src/main/res/drawable-xhdpi/ic_battery_charging.png +0 -0
- package/android/src/main/res/drawable-xhdpi/ic_battery_full.png +0 -0
- package/android/src/main/res/drawable-xhdpi/ic_battery_good.png +0 -0
- package/android/src/main/res/drawable-xhdpi/ic_battery_low.png +0 -0
- package/android/src/main/res/drawable-xhdpi/ic_calendar.png +0 -0
- package/android/src/main/res/drawable-xhdpi/ic_camera.png +0 -0
- package/android/src/main/res/drawable-xhdpi/ic_message.png +0 -0
- package/android/src/main/res/drawable-xhdpi/ic_pause.png +0 -0
- package/android/src/main/res/drawable-xhdpi/ic_play.png +0 -0
- package/android/src/main/res/drawable-xhdpi/ic_play_back.png +0 -0
- package/android/src/main/res/drawable-xhdpi/ic_record.png +0 -0
- package/android/src/main/res/drawable-xhdpi/ic_retry.png +0 -0
- package/android/src/main/res/drawable-xhdpi/ic_setting.png +0 -0
- package/android/src/main/res/drawable-xhdpi/ic_sound_off.png +0 -0
- package/android/src/main/res/drawable-xhdpi/ic_sound_on.png +0 -0
- package/android/src/main/res/drawable-xxhdpi/ic_action_arrow_backward.png +0 -0
- package/android/src/main/res/drawable-xxhdpi/ic_arrow_backward_white.png +0 -0
- package/android/src/main/res/drawable-xxhdpi/ic_arrow_blue_right.png +0 -0
- package/android/src/main/res/drawable-xxhdpi/ic_battery_average.png +0 -0
- package/android/src/main/res/drawable-xxhdpi/ic_battery_charging.png +0 -0
- package/android/src/main/res/drawable-xxhdpi/ic_battery_full.png +0 -0
- package/android/src/main/res/drawable-xxhdpi/ic_battery_good.png +0 -0
- package/android/src/main/res/drawable-xxhdpi/ic_battery_low.png +0 -0
- package/android/src/main/res/drawable-xxhdpi/ic_calendar.png +0 -0
- package/android/src/main/res/drawable-xxhdpi/ic_camera.png +0 -0
- package/android/src/main/res/drawable-xxhdpi/ic_message.png +0 -0
- package/android/src/main/res/drawable-xxhdpi/ic_pause.png +0 -0
- package/android/src/main/res/drawable-xxhdpi/ic_play.png +0 -0
- package/android/src/main/res/drawable-xxhdpi/ic_play_back.png +0 -0
- package/android/src/main/res/drawable-xxhdpi/ic_record.png +0 -0
- package/android/src/main/res/drawable-xxhdpi/ic_retry.png +0 -0
- package/android/src/main/res/drawable-xxhdpi/ic_setting.png +0 -0
- package/android/src/main/res/drawable-xxhdpi/ic_sound_off.png +0 -0
- package/android/src/main/res/drawable-xxhdpi/ic_sound_on.png +0 -0
- package/android/src/main/res/drawable-xxxhdpi/ic_action_arrow_backward.png +0 -0
- package/android/src/main/res/drawable-xxxhdpi/ic_arrow_backward_white.png +0 -0
- package/android/src/main/res/drawable-xxxhdpi/ic_arrow_blue_right.png +0 -0
- package/android/src/main/res/drawable-xxxhdpi/ic_calendar.png +0 -0
- package/android/src/main/res/drawable-xxxhdpi/ic_camera.png +0 -0
- package/android/src/main/res/drawable-xxxhdpi/ic_message.png +0 -0
- package/android/src/main/res/drawable-xxxhdpi/ic_pause.png +0 -0
- package/android/src/main/res/drawable-xxxhdpi/ic_play.png +0 -0
- package/android/src/main/res/drawable-xxxhdpi/ic_play_back.png +0 -0
- package/android/src/main/res/drawable-xxxhdpi/ic_record.png +0 -0
- package/android/src/main/res/drawable-xxxhdpi/ic_retry.png +0 -0
- package/android/src/main/res/drawable-xxxhdpi/ic_setting.png +0 -0
- package/android/src/main/res/drawable-xxxhdpi/ic_sound_off.png +0 -0
- package/android/src/main/res/drawable-xxxhdpi/ic_sound_on.png +0 -0
- package/android/src/main/res/font/quicksand_bold.ttf +0 -0
- package/android/src/main/res/font/quicksand_light.ttf +0 -0
- package/android/src/main/res/font/quicksand_medium.ttf +0 -0
- package/android/src/main/res/font/quicksand_regular.ttf +0 -0
- package/android/src/main/res/font/quicksand_semi_bold.ttf +0 -0
- package/android/src/main/res/values/strings.xml +121 -0
- package/android/thingMapping.gradle +200 -0
- package/android/thingMapping.json +2014 -0
- package/ios/components/Alert.swift +54 -0
- package/ios/components/AnchorButton.swift +100 -0
- package/ios/components/Button.swift +118 -0
- package/ios/components/CustomDatePicker.swift +275 -0
- package/ios/components/Divider.swift +28 -0
- package/ios/components/Image.swift +72 -0
- package/ios/components/Label.swift +105 -0
- package/ios/components/Switch.swift +61 -0
- package/ios/dashboard/AdvanceSettings.swift +127 -0
- package/ios/dashboard/Dashboard.swift +354 -0
- package/ios/dashboard/Messages.swift +361 -0
- package/ios/dashboard/NavigationController.swift +173 -0
- package/ios/dashboard/OfflineScreen.swift +109 -0
- package/ios/dashboard/Playback.swift +543 -0
- package/ios/dashboard/PreviewManager.swift +117 -0
- package/ios/dashboard/Settings.swift +672 -0
- package/ios/icons/Charging.png +0 -0
- package/ios/icons/Charging@2x.png +0 -0
- package/ios/icons/Charging@3x.png +0 -0
- package/ios/icons/back_arraow.png +0 -0
- package/ios/icons/back_arraow@2x.png +0 -0
- package/ios/icons/back_arraow@3x.png +0 -0
- package/ios/icons/battery_average.png +0 -0
- package/ios/icons/battery_average@2x.png +0 -0
- package/ios/icons/battery_average@3x.png +0 -0
- package/ios/icons/battery_full.png +0 -0
- package/ios/icons/battery_full@2x.png +0 -0
- package/ios/icons/battery_full@3x.png +0 -0
- package/ios/icons/battery_good.png +0 -0
- package/ios/icons/battery_good@2x.png +0 -0
- package/ios/icons/battery_good@3x.png +0 -0
- package/ios/icons/battery_low.png +0 -0
- package/ios/icons/battery_low@2x.png +0 -0
- package/ios/icons/battery_low@3x.png +0 -0
- package/ios/icons/calendar.png +0 -0
- package/ios/icons/calendar@2x.png +0 -0
- package/ios/icons/calendar@3x.png +0 -0
- package/ios/icons/cloud.png +0 -0
- package/ios/icons/cloud@2x.png +0 -0
- package/ios/icons/cloud@3x.png +0 -0
- package/ios/icons/down_update.png +0 -0
- package/ios/icons/down_update@2x.png +0 -0
- package/ios/icons/down_update@3x.png +0 -0
- package/ios/icons/exit_fullscreen.png +0 -0
- package/ios/icons/exit_fullscreen@2x.png +0 -0
- package/ios/icons/exit_fullscreen@3x.png +0 -0
- package/ios/icons/expand.png +0 -0
- package/ios/icons/fullscreen.png +0 -0
- package/ios/icons/fullscreen@2x.png +0 -0
- package/ios/icons/fullscreen@3x.png +0 -0
- package/ios/icons/image_placeholder.png +0 -0
- package/ios/icons/information.png +0 -0
- package/ios/icons/information@2x.png +0 -0
- package/ios/icons/information@3x.png +0 -0
- package/ios/icons/keyless_Setting.png +0 -0
- package/ios/icons/keyless_Setting@2x.png +0 -0
- package/ios/icons/keyless_Setting@3x.png +0 -0
- package/ios/icons/keyless_back@1x.png +0 -0
- package/ios/icons/keyless_back@2x.png +0 -0
- package/ios/icons/keyless_back@3x.png +0 -0
- package/ios/icons/keyless_filter.png +0 -0
- package/ios/icons/keyless_filter@2x.png +0 -0
- package/ios/icons/keyless_filter@3x.png +0 -0
- package/ios/icons/keyless_message.png +0 -0
- package/ios/icons/keyless_message@2x.png +0 -0
- package/ios/icons/keyless_message@3x.png +0 -0
- package/ios/icons/keyless_pause.png +0 -0
- package/ios/icons/keyless_pause@2x.png +0 -0
- package/ios/icons/keyless_pause@3x.png +0 -0
- package/ios/icons/keyless_photo.png +0 -0
- package/ios/icons/keyless_photo@2x.png +0 -0
- package/ios/icons/keyless_photo@3x.png +0 -0
- package/ios/icons/keyless_play.png +0 -0
- package/ios/icons/keyless_play@2x.png +0 -0
- package/ios/icons/keyless_play@3x.png +0 -0
- package/ios/icons/keyless_play_list.png +0 -0
- package/ios/icons/keyless_play_list@2x.png +0 -0
- package/ios/icons/keyless_play_list@3x.png +0 -0
- package/ios/icons/keyless_play_playback.png +0 -0
- package/ios/icons/keyless_play_playback@2x.png +0 -0
- package/ios/icons/keyless_play_playback@3x.png +0 -0
- package/ios/icons/keyless_record.png +0 -0
- package/ios/icons/keyless_record@2x.png +0 -0
- package/ios/icons/keyless_record@3x.png +0 -0
- package/ios/icons/keyless_record_on.png +0 -0
- package/ios/icons/keyless_record_on@2x.png +0 -0
- package/ios/icons/keyless_record_on@3x.png +0 -0
- package/ios/icons/keyless_sound_off.png +0 -0
- package/ios/icons/keyless_sound_off@2x.png +0 -0
- package/ios/icons/keyless_sound_off@3x.png +0 -0
- package/ios/icons/keyless_sound_on.png +0 -0
- package/ios/icons/keyless_sound_on@2x.png +0 -0
- package/ios/icons/keyless_sound_on@3x.png +0 -0
- package/ios/icons/keyless_speak_off.png +0 -0
- package/ios/icons/keyless_speak_off@2x.png +0 -0
- package/ios/icons/keyless_speak_on.png +0 -0
- package/ios/icons/keyless_speak_on@2x.png +0 -0
- package/ios/icons/keyless_speak_on@3x.png +0 -0
- package/ios/icons/refresh.png +0 -0
- package/ios/icons/refresh@2x.png +0 -0
- package/ios/icons/refresh@3x.png +0 -0
- package/ios/icons/ty_camera_control_hd_normal@2x.png +0 -0
- package/ios/icons/ty_camera_control_hd_normal@3x.png +0 -0
- package/ios/icons/ty_camera_control_sd_normal@2x.png +0 -0
- package/ios/icons/ty_camera_control_sd_normal@3x.png +0 -0
- package/ios/icons/upgrade_success.png +0 -0
- package/ios/icons/upgrade_success@2x.png +0 -0
- package/ios/icons/upgrade_success@3x.png +0 -0
- package/ios/listener/KeylessListener.m +8 -0
- package/ios/listener/KeylessListener.swift +56 -0
- package/ios/listener/RentlyTuya-Bridging-Header.h +5 -0
- package/ios/listener/RentlyTuya.mm +56 -0
- package/ios/listener/RentlyTuya.swift +544 -0
- package/ios/theme/LocalColor.swift +33 -0
- package/ios/theme/LocalFont.swift +32 -0
- package/ios/theme/Theme.swift +71 -0
- package/ios/tuya/CameraManager.swift +296 -0
- package/ios/tuya/SettingsManager.swift +475 -0
- package/ios/tuya/Tuya.swift +570 -0
- package/ios/tuya/TuyaMessages.swift +98 -0
- package/ios/utils/Airbrake.swift +31 -0
- package/ios/utils/AppUtility.swift +76 -0
- package/ios/utils/HeapAnalytics.swift +8 -0
- package/ios/utils/OrientationManager.swift +60 -0
- package/ios/utils/PromiseHandler.swift +36 -0
- package/lib/commonjs/index.js +90 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/package.json +1 -0
- package/lib/module/index.js +83 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/typescript/commonjs/package.json +1 -0
- package/lib/typescript/commonjs/src/index.d.ts +75 -0
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -0
- package/lib/typescript/module/package.json +1 -0
- package/lib/typescript/module/src/index.d.ts +75 -0
- package/lib/typescript/module/src/index.d.ts.map +1 -0
- package/package.json +188 -0
- package/rently-tuya.podspec +52 -0
- package/src/index.tsx +158 -0
@@ -0,0 +1,874 @@
|
|
1
|
+
package com.rentlytuya.dashboard
|
2
|
+
|
3
|
+
import android.app.Activity
|
4
|
+
import android.util.Log
|
5
|
+
import androidx.activity.compose.BackHandler
|
6
|
+
import androidx.compose.foundation.Image
|
7
|
+
import androidx.compose.foundation.background
|
8
|
+
import androidx.compose.foundation.clickable
|
9
|
+
import androidx.compose.foundation.interaction.MutableInteractionSource
|
10
|
+
import androidx.compose.foundation.layout.Arrangement
|
11
|
+
import androidx.compose.foundation.layout.Column
|
12
|
+
import androidx.compose.foundation.layout.Row
|
13
|
+
import androidx.compose.foundation.layout.fillMaxHeight
|
14
|
+
import androidx.compose.foundation.layout.fillMaxSize
|
15
|
+
import androidx.compose.foundation.layout.fillMaxWidth
|
16
|
+
import androidx.compose.foundation.layout.height
|
17
|
+
import androidx.compose.foundation.layout.padding
|
18
|
+
import androidx.compose.foundation.layout.size
|
19
|
+
import androidx.compose.foundation.layout.width
|
20
|
+
import androidx.compose.foundation.lazy.LazyColumn
|
21
|
+
import androidx.compose.material3.ripple
|
22
|
+
import androidx.compose.runtime.Composable
|
23
|
+
import androidx.compose.runtime.MutableIntState
|
24
|
+
import androidx.compose.runtime.MutableState
|
25
|
+
import androidx.compose.runtime.mutableStateOf
|
26
|
+
import androidx.compose.runtime.remember
|
27
|
+
import androidx.compose.ui.Alignment
|
28
|
+
import androidx.compose.ui.Modifier
|
29
|
+
import androidx.compose.ui.platform.LocalConfiguration
|
30
|
+
import androidx.compose.ui.platform.LocalContext
|
31
|
+
import androidx.compose.ui.res.painterResource
|
32
|
+
import androidx.compose.ui.unit.dp
|
33
|
+
import androidx.compose.ui.unit.sp
|
34
|
+
import androidx.compose.ui.window.Dialog
|
35
|
+
import androidx.compose.ui.window.DialogProperties
|
36
|
+
import androidx.navigation.NavController
|
37
|
+
import com.facebook.react.ReactApplication
|
38
|
+
import com.rentlytuya.R
|
39
|
+
import com.rentlytuya.alerts.RemoveDoorbellAlert
|
40
|
+
import com.rentlytuya.alerts.RemoveDoorbellFailureAlert
|
41
|
+
import com.rentlytuya.alerts.ResetWifiAlert
|
42
|
+
import com.rentlytuya.components.Button
|
43
|
+
import com.rentlytuya.components.Divider
|
44
|
+
import com.rentlytuya.components.Label
|
45
|
+
import com.rentlytuya.components.LoadingIndicator
|
46
|
+
import com.rentlytuya.components.Switch
|
47
|
+
import com.rentlytuya.tuya.Settings
|
48
|
+
import com.rentlytuya.tuya.Tuya
|
49
|
+
import com.rentlytuya.tuya.Tuya.TAG
|
50
|
+
import com.rentlytuya.ui.theme.LocalColor
|
51
|
+
import com.rentlytuya.util.DateUtil.isNotNull
|
52
|
+
import com.rentlytuya.util.KeylessModule
|
53
|
+
import com.rentlytuya.util.Util.isLandscape
|
54
|
+
import com.rentlytuya.util.Util.strings
|
55
|
+
|
56
|
+
enum class MotionSensitivityLevel(val level: String) {
|
57
|
+
HIGH("High"),
|
58
|
+
MEDIUM("Medium"),
|
59
|
+
LOW("Low")
|
60
|
+
}
|
61
|
+
|
62
|
+
enum class NightVision(val mode: String) {
|
63
|
+
AUTO("Auto"),
|
64
|
+
ON("On"),
|
65
|
+
OFF("Off")
|
66
|
+
}
|
67
|
+
|
68
|
+
enum class SDCardRecordType(val type: String) {
|
69
|
+
EVENT_RECORDING("Event Recording"),
|
70
|
+
NON_STOP("Non-Stop")
|
71
|
+
}
|
72
|
+
|
73
|
+
enum class ChimeType(val type: String) {
|
74
|
+
NONE("Not Selected"),
|
75
|
+
MECHANICAL("Mechanical"),
|
76
|
+
DIGITAL("Digital"),
|
77
|
+
NoBELLS("No Bells")
|
78
|
+
}
|
79
|
+
|
80
|
+
@Composable
|
81
|
+
fun DoorbellSettings(
|
82
|
+
isSettings: MutableState<Boolean>,
|
83
|
+
isAdvancedSettings: MutableState<Boolean>,
|
84
|
+
isStorageSettings: MutableState<Boolean>,
|
85
|
+
navController: NavController,
|
86
|
+
isWaterMarkEnabled: MutableState<Boolean>,
|
87
|
+
isFlipEnabled: MutableState<Boolean>,
|
88
|
+
isAntiDismantlingAlarmEnabled: MutableState<Boolean>,
|
89
|
+
nightVisionLevel: MutableState<String>,
|
90
|
+
isMotionDetectionEnabled: MutableState<Boolean>,
|
91
|
+
motionSensitivityLevel: MutableState<String>,
|
92
|
+
aosuMotionSensitivityLevel: MutableState<String>,
|
93
|
+
isPIRDetectionEnabled: MutableState<Boolean>,
|
94
|
+
pirSensitivityLevel: MutableIntState,
|
95
|
+
storageFunctionType: MutableIntState,
|
96
|
+
isSDCardRecordingEnabled: MutableState<Boolean>,
|
97
|
+
sdCardRecordingType: MutableState<String>,
|
98
|
+
chimeType: MutableState<String>,
|
99
|
+
powerSource: MutableState<String>,
|
100
|
+
batteryPercentage: MutableIntState,
|
101
|
+
totalStorageCapacity: MutableState<String>,
|
102
|
+
usedStorage: MutableState<String>,
|
103
|
+
remainingStorageCapacity: MutableState<String>
|
104
|
+
) {
|
105
|
+
|
106
|
+
val activity = LocalContext.current as Activity
|
107
|
+
val reactContext = (LocalContext.current.applicationContext as ReactApplication)
|
108
|
+
.reactNativeHost.reactInstanceManager.currentReactContext
|
109
|
+
|
110
|
+
val isLoading = remember { mutableStateOf(false) }
|
111
|
+
|
112
|
+
BackHandler {
|
113
|
+
if (isAdvancedSettings.value || isStorageSettings.value) {
|
114
|
+
isAdvancedSettings.value = false
|
115
|
+
isStorageSettings.value = false
|
116
|
+
navController.navigate("Settings")
|
117
|
+
} else {
|
118
|
+
isSettings.value = false
|
119
|
+
navController.navigate("Dashboard")
|
120
|
+
}
|
121
|
+
}
|
122
|
+
|
123
|
+
val isResetWifiAlertVisible = remember { mutableStateOf(false) }
|
124
|
+
val isRemoveDoorbellAlertVisible = remember { mutableStateOf(false) }
|
125
|
+
val isRemoveDoorbellFailureAlertVisible = remember { mutableStateOf(false) }
|
126
|
+
|
127
|
+
if (isLoading.value) {
|
128
|
+
LoadingIndicator()
|
129
|
+
}
|
130
|
+
|
131
|
+
ResetWifiAlert(
|
132
|
+
isResetWifiAlertVisible = isResetWifiAlertVisible.value,
|
133
|
+
onDismiss = { isResetWifiAlertVisible.value = false },
|
134
|
+
onReset = {
|
135
|
+
reactContext?.let { context ->
|
136
|
+
val keylessModule = context.getNativeModule(KeylessModule::class.java)
|
137
|
+
Tuya.deviceId?.let {
|
138
|
+
keylessModule?.sendDataToJS(
|
139
|
+
eventName = "navigateToAddDoorbell",
|
140
|
+
deviceId = it,
|
141
|
+
onSuccess = {
|
142
|
+
Log.i(TAG, "Navigate to Add Doorbell Success")
|
143
|
+
isResetWifiAlertVisible.value = false
|
144
|
+
activity.finish()
|
145
|
+
},
|
146
|
+
onFailure = {
|
147
|
+
Log.i(TAG, "Navigate to Add Doorbell Failed")
|
148
|
+
isResetWifiAlertVisible.value = false
|
149
|
+
}
|
150
|
+
)
|
151
|
+
} ?: Log.i(TAG, "Device ID is null")
|
152
|
+
}
|
153
|
+
}
|
154
|
+
)
|
155
|
+
|
156
|
+
RemoveDoorbellAlert(
|
157
|
+
isRemoveDoorbellAlertVisible = isRemoveDoorbellAlertVisible.value,
|
158
|
+
onDismiss = { isRemoveDoorbellAlertVisible.value = false },
|
159
|
+
onRemove = {
|
160
|
+
isRemoveDoorbellAlertVisible.value = false
|
161
|
+
isLoading.value = true
|
162
|
+
reactContext?.let { context ->
|
163
|
+
val keylessModule = context.getNativeModule(KeylessModule::class.java)
|
164
|
+
Tuya.deviceId?.let {
|
165
|
+
keylessModule?.sendDataToJS(
|
166
|
+
eventName = "removeCamera",
|
167
|
+
deviceId = it,
|
168
|
+
onSuccess = {
|
169
|
+
Log.i(TAG, "Remove Doorbell Success")
|
170
|
+
isLoading.value = false
|
171
|
+
activity.finish()
|
172
|
+
},
|
173
|
+
onFailure = {
|
174
|
+
Log.i(TAG, "Remove Doorbell Failed")
|
175
|
+
isLoading.value = false
|
176
|
+
isRemoveDoorbellFailureAlertVisible.value = true
|
177
|
+
}
|
178
|
+
)
|
179
|
+
} ?: Log.i(TAG, "Device ID is null")
|
180
|
+
}
|
181
|
+
}
|
182
|
+
)
|
183
|
+
|
184
|
+
RemoveDoorbellFailureAlert(
|
185
|
+
isRemoveDoorbellFailureAlertVisible = isRemoveDoorbellFailureAlertVisible.value,
|
186
|
+
onDismiss = {
|
187
|
+
isRemoveDoorbellFailureAlertVisible.value = false
|
188
|
+
},
|
189
|
+
onOK = {
|
190
|
+
isRemoveDoorbellFailureAlertVisible.value = false
|
191
|
+
}
|
192
|
+
)
|
193
|
+
|
194
|
+
when {
|
195
|
+
isAdvancedSettings.value -> AdvancedSettings()
|
196
|
+
isStorageSettings.value -> StorageSettings(
|
197
|
+
totalStorageCapacity = totalStorageCapacity,
|
198
|
+
usedStorage = usedStorage,
|
199
|
+
remainingStorageCapacity = remainingStorageCapacity,
|
200
|
+
storageFunctionType = storageFunctionType
|
201
|
+
)
|
202
|
+
|
203
|
+
else -> {
|
204
|
+
LazyColumn(
|
205
|
+
modifier = Modifier.fillMaxSize()
|
206
|
+
) {
|
207
|
+
item {
|
208
|
+
Heading(title = strings(id = R.string.basicSettings))
|
209
|
+
}
|
210
|
+
if (!Settings.isAOSU()) {
|
211
|
+
item {
|
212
|
+
SettingsItem(
|
213
|
+
title = strings(id = R.string.flipScreen),
|
214
|
+
description = strings(id = R.string.flipScreenDescription),
|
215
|
+
withSwitch = true,
|
216
|
+
checked = isFlipEnabled.value,
|
217
|
+
onToggle = {
|
218
|
+
Settings.setFlip(
|
219
|
+
enable = it,
|
220
|
+
isLoading = isLoading,
|
221
|
+
isFlipEnabled = isFlipEnabled
|
222
|
+
)
|
223
|
+
}
|
224
|
+
)
|
225
|
+
}
|
226
|
+
}
|
227
|
+
item {
|
228
|
+
SettingsItem(
|
229
|
+
title = strings(id = R.string.timeWaterMark),
|
230
|
+
description = strings(id = R.string.waterMarkDescription),
|
231
|
+
withSwitch = true,
|
232
|
+
checked = isWaterMarkEnabled.value,
|
233
|
+
onToggle = {
|
234
|
+
Settings.setWatermark(
|
235
|
+
enable = it,
|
236
|
+
isLoading = isLoading,
|
237
|
+
isWaterMarkEnabled = isWaterMarkEnabled
|
238
|
+
)
|
239
|
+
}
|
240
|
+
)
|
241
|
+
}
|
242
|
+
if (Settings.isAOSU()) {
|
243
|
+
item {
|
244
|
+
SettingsItem(
|
245
|
+
title = strings(id = R.string.antiDismantlingAlarm),
|
246
|
+
description = strings(id = R.string.antiDismantlingAlarmDescription),
|
247
|
+
withSwitch = true,
|
248
|
+
checked = isAntiDismantlingAlarmEnabled.value,
|
249
|
+
onToggle = {
|
250
|
+
Settings.setAntiDismantlingAlarm(
|
251
|
+
enable = it,
|
252
|
+
isLoading = isLoading,
|
253
|
+
isAntiDismantlingAlarmEnabled = isAntiDismantlingAlarmEnabled
|
254
|
+
)
|
255
|
+
}
|
256
|
+
)
|
257
|
+
}
|
258
|
+
}
|
259
|
+
item {
|
260
|
+
SettingsItem(
|
261
|
+
title = strings(id = R.string.irNightVision),
|
262
|
+
description = strings(id = R.string.nightVisionDescription),
|
263
|
+
withDropDown = true,
|
264
|
+
dropDownTitle = strings(id = R.string.nightVision),
|
265
|
+
dropDownList = enumValues<NightVision>().map { it.mode },
|
266
|
+
selectedOption = when (nightVisionLevel.value) {
|
267
|
+
"0" -> NightVision.AUTO.mode
|
268
|
+
|
269
|
+
"1" -> NightVision.OFF.mode
|
270
|
+
|
271
|
+
"2" -> NightVision.ON.mode
|
272
|
+
|
273
|
+
else -> ""
|
274
|
+
},
|
275
|
+
onDropDownItemSelected = {
|
276
|
+
val newMode = when (it) {
|
277
|
+
NightVision.AUTO.mode -> "0"
|
278
|
+
|
279
|
+
NightVision.OFF.mode -> "1"
|
280
|
+
|
281
|
+
NightVision.ON.mode -> "2"
|
282
|
+
|
283
|
+
else -> null
|
284
|
+
}
|
285
|
+
|
286
|
+
if (newMode.isNotNull()) {
|
287
|
+
Settings.setNightVision(
|
288
|
+
mode = nightVisionLevel,
|
289
|
+
newMode = newMode,
|
290
|
+
isLoading = isLoading
|
291
|
+
)
|
292
|
+
}
|
293
|
+
}
|
294
|
+
)
|
295
|
+
}
|
296
|
+
|
297
|
+
item {
|
298
|
+
Heading(title = strings(id = R.string.motionDetection))
|
299
|
+
}
|
300
|
+
item {
|
301
|
+
SettingsItem(
|
302
|
+
title = strings(id = R.string.motionDetection),
|
303
|
+
description = strings(id = R.string.motionDetectionDescription),
|
304
|
+
withSwitch = true,
|
305
|
+
checked = if (Settings.is8s() || Settings.isAOSU()) {
|
306
|
+
isMotionDetectionEnabled.value
|
307
|
+
} else {
|
308
|
+
isPIRDetectionEnabled.value
|
309
|
+
},
|
310
|
+
onToggle = {
|
311
|
+
Settings.setMotionDetection(
|
312
|
+
is8s = Settings.is8s() || Settings.isAOSU(),
|
313
|
+
enable = it,
|
314
|
+
isLoading = isLoading,
|
315
|
+
isMotionDetectionEnabled = if (Settings.is8s() || Settings.isAOSU()) {
|
316
|
+
isMotionDetectionEnabled
|
317
|
+
} else {
|
318
|
+
isPIRDetectionEnabled
|
319
|
+
}
|
320
|
+
)
|
321
|
+
}
|
322
|
+
)
|
323
|
+
}
|
324
|
+
if (Settings.isAOSU() && isMotionDetectionEnabled.value){
|
325
|
+
item {
|
326
|
+
SettingsItem(
|
327
|
+
title = strings(id = R.string.motionSensitivityLevel),
|
328
|
+
withDropDown = true,
|
329
|
+
dropDownTitle = strings(id = R.string.motionSensitivityLevel),
|
330
|
+
dropDownList = enumValues<MotionSensitivityLevel>().map { it.level },
|
331
|
+
selectedOption = when (aosuMotionSensitivityLevel.value) {
|
332
|
+
"1" -> MotionSensitivityLevel.LOW.level
|
333
|
+
|
334
|
+
"2" -> MotionSensitivityLevel.MEDIUM.level
|
335
|
+
|
336
|
+
"3" -> MotionSensitivityLevel.HIGH.level
|
337
|
+
|
338
|
+
else -> ""
|
339
|
+
},
|
340
|
+
onDropDownItemSelected = {
|
341
|
+
val newMode = when (it) {
|
342
|
+
MotionSensitivityLevel.LOW.level -> "1"
|
343
|
+
|
344
|
+
MotionSensitivityLevel.MEDIUM.level -> "2"
|
345
|
+
|
346
|
+
MotionSensitivityLevel.HIGH.level -> "3"
|
347
|
+
|
348
|
+
else -> null
|
349
|
+
}
|
350
|
+
|
351
|
+
if (newMode.isNotNull()) {
|
352
|
+
Settings.setMotionSensitivity(
|
353
|
+
mode = aosuMotionSensitivityLevel,
|
354
|
+
newMode = newMode,
|
355
|
+
isAOSU = true,
|
356
|
+
isLoading = isLoading
|
357
|
+
)
|
358
|
+
}
|
359
|
+
}
|
360
|
+
)
|
361
|
+
}
|
362
|
+
} else if (Settings.is8s() && isMotionDetectionEnabled.value) {
|
363
|
+
item {
|
364
|
+
SettingsItem(
|
365
|
+
title = strings(id = R.string.motionSensitivityLevel),
|
366
|
+
withDropDown = true,
|
367
|
+
dropDownTitle = strings(id = R.string.motionSensitivityLevel),
|
368
|
+
dropDownList = enumValues<MotionSensitivityLevel>().map { it.level },
|
369
|
+
selectedOption = when (motionSensitivityLevel.value) {
|
370
|
+
"0" -> MotionSensitivityLevel.LOW.level
|
371
|
+
|
372
|
+
"1" -> MotionSensitivityLevel.MEDIUM.level
|
373
|
+
|
374
|
+
"2" -> MotionSensitivityLevel.HIGH.level
|
375
|
+
|
376
|
+
else -> ""
|
377
|
+
},
|
378
|
+
onDropDownItemSelected = {
|
379
|
+
val newMode = when (it) {
|
380
|
+
MotionSensitivityLevel.LOW.level -> "0"
|
381
|
+
|
382
|
+
MotionSensitivityLevel.MEDIUM.level -> "1"
|
383
|
+
|
384
|
+
MotionSensitivityLevel.HIGH.level -> "2"
|
385
|
+
|
386
|
+
else -> null
|
387
|
+
}
|
388
|
+
|
389
|
+
if (newMode.isNotNull()) {
|
390
|
+
Settings.setMotionSensitivity(
|
391
|
+
mode = motionSensitivityLevel,
|
392
|
+
newMode = newMode,
|
393
|
+
isLoading = isLoading
|
394
|
+
)
|
395
|
+
}
|
396
|
+
}
|
397
|
+
)
|
398
|
+
}
|
399
|
+
} else if (!Settings.is8s() && isPIRDetectionEnabled.value) {
|
400
|
+
item {
|
401
|
+
SettingsItem(
|
402
|
+
title = strings(id = R.string.motionSensitivityLevel),
|
403
|
+
withDropDown = true,
|
404
|
+
dropDownTitle = strings(id = R.string.motionSensitivityLevel),
|
405
|
+
dropDownList = enumValues<MotionSensitivityLevel>().map { it.level },
|
406
|
+
selectedOption = when (pirSensitivityLevel.intValue) {
|
407
|
+
1 -> MotionSensitivityLevel.LOW.level
|
408
|
+
|
409
|
+
3 -> MotionSensitivityLevel.MEDIUM.level
|
410
|
+
|
411
|
+
5 -> MotionSensitivityLevel.HIGH.level
|
412
|
+
|
413
|
+
else -> ""
|
414
|
+
},
|
415
|
+
onDropDownItemSelected = {
|
416
|
+
val newMode = when (it) {
|
417
|
+
MotionSensitivityLevel.LOW.level -> 1
|
418
|
+
|
419
|
+
MotionSensitivityLevel.MEDIUM.level -> 3
|
420
|
+
|
421
|
+
MotionSensitivityLevel.HIGH.level -> 5
|
422
|
+
|
423
|
+
else -> null
|
424
|
+
}
|
425
|
+
|
426
|
+
if (newMode.isNotNull()) {
|
427
|
+
Settings.setPIRSensitivity(
|
428
|
+
mode = pirSensitivityLevel,
|
429
|
+
newMode = newMode,
|
430
|
+
isLoading = isLoading
|
431
|
+
)
|
432
|
+
}
|
433
|
+
}
|
434
|
+
)
|
435
|
+
}
|
436
|
+
}
|
437
|
+
|
438
|
+
item {
|
439
|
+
Heading(title = strings(id = R.string.storageSettings))
|
440
|
+
}
|
441
|
+
item {
|
442
|
+
SettingsItem(
|
443
|
+
title = strings(id = R.string.storageSetting),
|
444
|
+
description = when (storageFunctionType.intValue) {
|
445
|
+
1 -> strings(id = R.string.functioningAsExpected)
|
446
|
+
2 -> strings(id = R.string.notFunctioningAsExpected)
|
447
|
+
3 -> ""
|
448
|
+
4 -> ""
|
449
|
+
5 -> strings(id = R.string.checkSDCardIsInserted)
|
450
|
+
else -> ""
|
451
|
+
},
|
452
|
+
additionalInfo = when (storageFunctionType.intValue) {
|
453
|
+
1 -> strings(id = R.string.normal)
|
454
|
+
2 -> strings(id = R.string.abnormal)
|
455
|
+
3 -> strings(id = R.string.insufficientCapacity)
|
456
|
+
4 -> strings(id = R.string.formatting)
|
457
|
+
5 -> strings(id = R.string.noStorage)
|
458
|
+
else -> ""
|
459
|
+
},
|
460
|
+
onClick = {
|
461
|
+
isStorageSettings.value = true
|
462
|
+
}
|
463
|
+
)
|
464
|
+
}
|
465
|
+
|
466
|
+
if (Settings.is8s()) {
|
467
|
+
item {
|
468
|
+
SettingsItem(
|
469
|
+
title = strings(id = R.string.sdCardRecording),
|
470
|
+
withSwitch = true,
|
471
|
+
checked = isSDCardRecordingEnabled.value,
|
472
|
+
onToggle = {
|
473
|
+
Settings.setSDCardRecording(
|
474
|
+
enable = it,
|
475
|
+
isLoading = isLoading,
|
476
|
+
isSDCardRecordingEnabled = isSDCardRecordingEnabled
|
477
|
+
)
|
478
|
+
}
|
479
|
+
)
|
480
|
+
}
|
481
|
+
|
482
|
+
if (isSDCardRecordingEnabled.value) {
|
483
|
+
item {
|
484
|
+
SettingsItem(
|
485
|
+
title = strings(id = R.string.recordingMode),
|
486
|
+
description = if (sdCardRecordingType.value == "1") {
|
487
|
+
strings(id = R.string.eventWillBeRecordedWhenMotionIsDetected)
|
488
|
+
} else {
|
489
|
+
strings(id = R.string.eventWillBeRecordedContinuously)
|
490
|
+
},
|
491
|
+
withDropDown = true,
|
492
|
+
dropDownTitle = strings(id = R.string.recordingMode),
|
493
|
+
dropDownList = enumValues<SDCardRecordType>().map { it.type },
|
494
|
+
selectedOption = when (sdCardRecordingType.value) {
|
495
|
+
"1" -> SDCardRecordType.EVENT_RECORDING.type
|
496
|
+
|
497
|
+
"2" -> SDCardRecordType.NON_STOP.type
|
498
|
+
|
499
|
+
else -> ""
|
500
|
+
},
|
501
|
+
onDropDownItemSelected = {
|
502
|
+
val newMode = when (it) {
|
503
|
+
SDCardRecordType.EVENT_RECORDING.type -> "1"
|
504
|
+
|
505
|
+
SDCardRecordType.NON_STOP.type -> "2"
|
506
|
+
|
507
|
+
else -> null
|
508
|
+
}
|
509
|
+
|
510
|
+
if (newMode.isNotNull()) {
|
511
|
+
Settings.setSDCardRecordingMode(
|
512
|
+
newMode = newMode,
|
513
|
+
mode = sdCardRecordingType,
|
514
|
+
isLoading = isLoading
|
515
|
+
)
|
516
|
+
}
|
517
|
+
}
|
518
|
+
)
|
519
|
+
}
|
520
|
+
}
|
521
|
+
}
|
522
|
+
|
523
|
+
item {
|
524
|
+
SettingsItem(
|
525
|
+
title = strings(id = R.string.resetWiFi),
|
526
|
+
onClick = {
|
527
|
+
isResetWifiAlertVisible.value = true
|
528
|
+
}
|
529
|
+
)
|
530
|
+
}
|
531
|
+
|
532
|
+
if (!Settings.is8s()) {
|
533
|
+
item {
|
534
|
+
Heading(title = strings(id = R.string.powerInformation))
|
535
|
+
}
|
536
|
+
|
537
|
+
item {
|
538
|
+
SettingsItem(
|
539
|
+
title = strings(id = R.string.powerSource),
|
540
|
+
rightArrow = false,
|
541
|
+
additionalInfo = if (powerSource.value == "0") {
|
542
|
+
"Battery (${batteryPercentage.intValue}%)"
|
543
|
+
} else {
|
544
|
+
strings(id = R.string.charging)
|
545
|
+
}
|
546
|
+
)
|
547
|
+
}
|
548
|
+
}
|
549
|
+
|
550
|
+
if (!Settings.isAOSU()) {
|
551
|
+
item {
|
552
|
+
Heading(title = strings(id = R.string.chimeConnectionSettings))
|
553
|
+
}
|
554
|
+
|
555
|
+
item {
|
556
|
+
SettingsItem(
|
557
|
+
title = strings(id = R.string.chimeType),
|
558
|
+
description = if (Settings.is8s()) strings(id = R.string.chimeDescription8s) else strings(id = R.string.chimeDescription15s),
|
559
|
+
withDropDown = true,
|
560
|
+
dropDownTitle = strings(id = R.string.chimeType),
|
561
|
+
dropDownList = enumValues<ChimeType>() // Digital chime type is not available for 8s model.
|
562
|
+
.filter {
|
563
|
+
if (Settings.is8s()) it != ChimeType.NONE && it != ChimeType.DIGITAL
|
564
|
+
else it != ChimeType.NONE
|
565
|
+
}
|
566
|
+
.map { it.type },
|
567
|
+
selectedOption = when ((chimeType.value)) {
|
568
|
+
"0" -> ChimeType.NONE.type
|
569
|
+
|
570
|
+
"1" -> ChimeType.MECHANICAL.type
|
571
|
+
|
572
|
+
"2" -> ChimeType.DIGITAL.type
|
573
|
+
|
574
|
+
"3" -> ChimeType.NoBELLS.type
|
575
|
+
|
576
|
+
else -> ""
|
577
|
+
},
|
578
|
+
onDropDownItemSelected = {
|
579
|
+
val newMode = when (it) {
|
580
|
+
ChimeType.NONE.type -> "0"
|
581
|
+
|
582
|
+
ChimeType.MECHANICAL.type -> "1"
|
583
|
+
|
584
|
+
ChimeType.DIGITAL.type -> "2"
|
585
|
+
|
586
|
+
ChimeType.NoBELLS.type -> "3"
|
587
|
+
|
588
|
+
else -> null
|
589
|
+
}
|
590
|
+
|
591
|
+
if (newMode.isNotNull()) {
|
592
|
+
Settings.setChime(
|
593
|
+
newMode = newMode,
|
594
|
+
isLoading = isLoading,
|
595
|
+
mode = chimeType
|
596
|
+
)
|
597
|
+
}
|
598
|
+
}
|
599
|
+
)
|
600
|
+
}
|
601
|
+
}
|
602
|
+
|
603
|
+
item {
|
604
|
+
Heading(title = strings(id = R.string.advancedSettings))
|
605
|
+
}
|
606
|
+
item {
|
607
|
+
SettingsItem(
|
608
|
+
title = strings(id = R.string.deviceInfo),
|
609
|
+
onClick = {
|
610
|
+
isAdvancedSettings.value = true
|
611
|
+
}
|
612
|
+
)
|
613
|
+
}
|
614
|
+
|
615
|
+
if (!Tuya.isResident || (Tuya.displayRemoveDoorbellButton ?: false)) {
|
616
|
+
item {
|
617
|
+
Row(
|
618
|
+
modifier = Modifier
|
619
|
+
.fillMaxWidth()
|
620
|
+
.padding(top = 15.dp, bottom = 30.dp),
|
621
|
+
horizontalArrangement = Arrangement.Center
|
622
|
+
) {
|
623
|
+
Button(
|
624
|
+
modifier = Modifier
|
625
|
+
.width(190.dp)
|
626
|
+
.height(50.dp),
|
627
|
+
id = "RemoveDoorbell",
|
628
|
+
title = strings(id = R.string.removeDoorbell),
|
629
|
+
textColor = LocalColor.Monochrome.White,
|
630
|
+
secondary = true,
|
631
|
+
m = true,
|
632
|
+
semiBold = true
|
633
|
+
) {
|
634
|
+
isRemoveDoorbellAlertVisible.value = true
|
635
|
+
}
|
636
|
+
}
|
637
|
+
}
|
638
|
+
}
|
639
|
+
}
|
640
|
+
}
|
641
|
+
}
|
642
|
+
}
|
643
|
+
|
644
|
+
@Composable
|
645
|
+
fun Heading(title: String) {
|
646
|
+
Row(
|
647
|
+
modifier = Modifier
|
648
|
+
.fillMaxWidth()
|
649
|
+
.height(40.dp)
|
650
|
+
.background(LocalColor.Monochrome.White),
|
651
|
+
verticalAlignment = Alignment.CenterVertically
|
652
|
+
) {
|
653
|
+
Label(
|
654
|
+
modifier = Modifier
|
655
|
+
.padding(start = 20.dp),
|
656
|
+
title = title,
|
657
|
+
black = true,
|
658
|
+
bold = true,
|
659
|
+
l = true
|
660
|
+
)
|
661
|
+
}
|
662
|
+
}
|
663
|
+
|
664
|
+
@Composable
|
665
|
+
fun SettingsItem(
|
666
|
+
title: String,
|
667
|
+
description: String = "",
|
668
|
+
additionalInfo: String = "",
|
669
|
+
withSwitch: Boolean = false,
|
670
|
+
withDropDown: Boolean = false,
|
671
|
+
checked: Boolean = false,
|
672
|
+
rightArrow: Boolean = true,
|
673
|
+
dropDownTitle: String = "",
|
674
|
+
dropDownList: List<String> = listOf(),
|
675
|
+
selectedOption: String = "",
|
676
|
+
onDropDownItemSelected: (item: String) -> Unit = {},
|
677
|
+
onToggle: (state: Boolean) -> Unit = {},
|
678
|
+
onClick: (() -> Unit)? = null
|
679
|
+
) {
|
680
|
+
|
681
|
+
val isDropDownVisible = remember {
|
682
|
+
mutableStateOf(false)
|
683
|
+
}
|
684
|
+
|
685
|
+
Column(modifier = Modifier.background(LocalColor.Main.Light)) {
|
686
|
+
Row(
|
687
|
+
modifier = Modifier
|
688
|
+
.fillMaxWidth()
|
689
|
+
.clickable(
|
690
|
+
interactionSource = remember { MutableInteractionSource() },
|
691
|
+
indication = if (withDropDown || onClick.isNotNull()) ripple() else null
|
692
|
+
) {
|
693
|
+
if (withDropDown) isDropDownVisible.value = true else onClick?.invoke()
|
694
|
+
}
|
695
|
+
.padding(horizontal = 20.dp),
|
696
|
+
horizontalArrangement = Arrangement.SpaceBetween,
|
697
|
+
verticalAlignment = Alignment.CenterVertically
|
698
|
+
) {
|
699
|
+
Column(
|
700
|
+
modifier = Modifier
|
701
|
+
.fillMaxWidth(0.6f)
|
702
|
+
.padding(vertical = 10.dp)
|
703
|
+
) {
|
704
|
+
Label(
|
705
|
+
modifier = Modifier,
|
706
|
+
id = title.lowercase(),
|
707
|
+
title = title,
|
708
|
+
m = true,
|
709
|
+
grey = true,
|
710
|
+
semiBold = true,
|
711
|
+
)
|
712
|
+
|
713
|
+
if (description.isNotBlank()) {
|
714
|
+
Label(
|
715
|
+
modifier = Modifier
|
716
|
+
.padding(top = 5.dp),
|
717
|
+
id = title.lowercase() + "Description",
|
718
|
+
title = description,
|
719
|
+
maxLines = 6,
|
720
|
+
s = true,
|
721
|
+
lightGrey = true,
|
722
|
+
medium = true,
|
723
|
+
lineHeight = 15.sp
|
724
|
+
)
|
725
|
+
}
|
726
|
+
}
|
727
|
+
|
728
|
+
Row(
|
729
|
+
modifier = Modifier
|
730
|
+
.fillMaxWidth(),
|
731
|
+
horizontalArrangement = Arrangement.End
|
732
|
+
) {
|
733
|
+
when {
|
734
|
+
withSwitch -> {
|
735
|
+
Switch(
|
736
|
+
id = title + "Switch",
|
737
|
+
checked = checked,
|
738
|
+
onChange = onToggle
|
739
|
+
)
|
740
|
+
}
|
741
|
+
|
742
|
+
withDropDown -> {
|
743
|
+
PopUp(
|
744
|
+
isVisible = isDropDownVisible,
|
745
|
+
dropDownTitle = dropDownTitle,
|
746
|
+
dropDownList = dropDownList,
|
747
|
+
selectedOption = selectedOption,
|
748
|
+
onDropDownItemSelected = onDropDownItemSelected,
|
749
|
+
)
|
750
|
+
}
|
751
|
+
|
752
|
+
else -> {
|
753
|
+
if (additionalInfo != "") {
|
754
|
+
Label(
|
755
|
+
modifier = Modifier
|
756
|
+
.padding(end = 5.dp),
|
757
|
+
id = title.lowercase(),
|
758
|
+
title = additionalInfo,
|
759
|
+
maxLines = 1,
|
760
|
+
s = true,
|
761
|
+
black = true,
|
762
|
+
semiBold = true,
|
763
|
+
lineHeight = 15.sp
|
764
|
+
)
|
765
|
+
}
|
766
|
+
|
767
|
+
if (rightArrow) {
|
768
|
+
Image(
|
769
|
+
modifier = Modifier
|
770
|
+
.size(12.dp),
|
771
|
+
painter = painterResource(id = R.drawable.ic_arrow_blue_right),
|
772
|
+
contentDescription = "rightArrow",
|
773
|
+
)
|
774
|
+
}
|
775
|
+
}
|
776
|
+
}
|
777
|
+
}
|
778
|
+
}
|
779
|
+
|
780
|
+
Divider(
|
781
|
+
modifier = Modifier
|
782
|
+
.padding(horizontal = 10.dp),
|
783
|
+
thickness = 1.dp
|
784
|
+
)
|
785
|
+
}
|
786
|
+
}
|
787
|
+
|
788
|
+
@Composable
|
789
|
+
fun PopUp(
|
790
|
+
isVisible: MutableState<Boolean>,
|
791
|
+
dropDownTitle: String = "",
|
792
|
+
dropDownList: List<String> = listOf(),
|
793
|
+
selectedOption: String = "",
|
794
|
+
onDropDownItemSelected: (item: String) -> Unit = {},
|
795
|
+
) {
|
796
|
+
|
797
|
+
val configuration = LocalConfiguration.current
|
798
|
+
|
799
|
+
Row(
|
800
|
+
modifier = Modifier
|
801
|
+
.fillMaxHeight()
|
802
|
+
.clickable(
|
803
|
+
interactionSource = remember { MutableInteractionSource() },
|
804
|
+
indication = null
|
805
|
+
) {
|
806
|
+
isVisible.value = true
|
807
|
+
},
|
808
|
+
horizontalArrangement = Arrangement.End,
|
809
|
+
verticalAlignment = Alignment.CenterVertically
|
810
|
+
) {
|
811
|
+
Label(
|
812
|
+
modifier = Modifier
|
813
|
+
.padding(end = 5.dp),
|
814
|
+
title = selectedOption,
|
815
|
+
black = true,
|
816
|
+
semiBold = true,
|
817
|
+
m = true
|
818
|
+
)
|
819
|
+
Image(
|
820
|
+
modifier = Modifier
|
821
|
+
.size(12.dp),
|
822
|
+
painter = painterResource(id = R.drawable.ic_arrow_blue_right),
|
823
|
+
contentDescription = "rightArrow",
|
824
|
+
)
|
825
|
+
}
|
826
|
+
|
827
|
+
if (isVisible.value) {
|
828
|
+
Dialog(
|
829
|
+
onDismissRequest = {
|
830
|
+
isVisible.value = false
|
831
|
+
},
|
832
|
+
properties = DialogProperties(
|
833
|
+
usePlatformDefaultWidth = false
|
834
|
+
)
|
835
|
+
) {
|
836
|
+
Column(
|
837
|
+
modifier = Modifier
|
838
|
+
.fillMaxWidth(
|
839
|
+
if (!isLandscape(configuration)) 0.9f else 0.5f
|
840
|
+
)
|
841
|
+
.background(LocalColor.Monochrome.White)
|
842
|
+
.padding(vertical = 10.dp)
|
843
|
+
) {
|
844
|
+
Label(
|
845
|
+
modifier = Modifier
|
846
|
+
.padding(vertical = 10.dp, horizontal = 20.dp),
|
847
|
+
title = dropDownTitle,
|
848
|
+
bold = true,
|
849
|
+
xl20 = true,
|
850
|
+
black = true
|
851
|
+
)
|
852
|
+
dropDownList.forEach {
|
853
|
+
Row(
|
854
|
+
modifier = Modifier
|
855
|
+
.fillMaxWidth()
|
856
|
+
.clickable {
|
857
|
+
onDropDownItemSelected(it)
|
858
|
+
isVisible.value = false
|
859
|
+
}
|
860
|
+
) {
|
861
|
+
Label(
|
862
|
+
modifier = Modifier
|
863
|
+
.padding(vertical = 10.dp, horizontal = 20.dp),
|
864
|
+
title = it,
|
865
|
+
black = true,
|
866
|
+
semiBold = true,
|
867
|
+
l = true
|
868
|
+
)
|
869
|
+
}
|
870
|
+
}
|
871
|
+
}
|
872
|
+
}
|
873
|
+
}
|
874
|
+
}
|