优化设置页面到操作密码传值
This commit is contained in:
@@ -74,14 +74,8 @@ dependencies {
|
|||||||
// Kotlin 协程
|
// Kotlin 协程
|
||||||
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.3")
|
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.3")
|
||||||
|
|
||||||
// CameraX 用于相机预览
|
|
||||||
implementation("androidx.camera:camera-camera2:1.3.0")
|
|
||||||
implementation("androidx.camera:camera-lifecycle:1.3.0")
|
|
||||||
implementation("androidx.camera:camera-view:1.3.0")
|
|
||||||
// Google ML Kit 人脸检测
|
// Google ML Kit 人脸检测
|
||||||
implementation("com.google.mlkit:face-detection:16.1.5")
|
implementation("com.google.mlkit:face-detection:16.1.5")
|
||||||
// 图形绘制库(绘制人脸框)
|
|
||||||
implementation("com.github.bumptech.glide:glide:4.15.1")
|
|
||||||
//Glide 依赖
|
//Glide 依赖
|
||||||
implementation("com.github.bumptech.glide:glide:4.16.0")
|
implementation("com.github.bumptech.glide:glide:4.16.0")
|
||||||
// ZXing 二维码扫描库
|
// ZXing 二维码扫描库
|
||||||
@@ -92,8 +86,6 @@ dependencies {
|
|||||||
implementation("com.geyifeng.immersionbar:immersionbar-ktx:3.2.2")
|
implementation("com.geyifeng.immersionbar:immersionbar-ktx:3.2.2")
|
||||||
implementation("com.wdullaer:materialdatetimepicker:4.2.3") // 经典稳定
|
implementation("com.wdullaer:materialdatetimepicker:4.2.3") // 经典稳定
|
||||||
implementation("androidx.core:core-ktx:1.12.0")
|
implementation("androidx.core:core-ktx:1.12.0")
|
||||||
// Android-PickerView 时间选择器
|
|
||||||
implementation("com.contrarywind:Android-PickerView:4.1.9")
|
|
||||||
//二维码三方库
|
//二维码三方库
|
||||||
implementation("com.github.maning0303:MNMLKitScanner:V1.0.4")
|
implementation("com.github.maning0303:MNMLKitScanner:V1.0.4")
|
||||||
implementation("com.google.mlkit:barcode-scanning:17.0.2")
|
implementation("com.google.mlkit:barcode-scanning:17.0.2")
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ class AutoModeActivity : AppCompatActivity() {
|
|||||||
private var selectedStartMinute = 0
|
private var selectedStartMinute = 0
|
||||||
private var selectedEndHour = 10
|
private var selectedEndHour = 10
|
||||||
private var selectedEndMinute = 0
|
private var selectedEndMinute = 0
|
||||||
|
private var optionPassword: String? = null
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
@@ -42,6 +43,8 @@ class AutoModeActivity : AppCompatActivity() {
|
|||||||
.titleBar(binding.topBar)
|
.titleBar(binding.topBar)
|
||||||
.init()
|
.init()
|
||||||
|
|
||||||
|
optionPassword = intent.getStringExtra("optionPassword")
|
||||||
|
|
||||||
initListener()
|
initListener()
|
||||||
|
|
||||||
loadCurrentSettings()
|
loadCurrentSettings()
|
||||||
@@ -177,7 +180,8 @@ class AutoModeActivity : AppCompatActivity() {
|
|||||||
id = deviceId,
|
id = deviceId,
|
||||||
workMode = selectedMode,
|
workMode = selectedMode,
|
||||||
startTime = startTime,
|
startTime = startTime,
|
||||||
endTime = endTime
|
endTime = endTime,
|
||||||
|
optionPassword = optionPassword
|
||||||
)
|
)
|
||||||
val response = RetrofitNetwork.getNetworkService().updateDeviceInfo(deviceBean)
|
val response = RetrofitNetwork.getNetworkService().updateDeviceInfo(deviceBean)
|
||||||
withContext(Dispatchers.Main) {
|
withContext(Dispatchers.Main) {
|
||||||
|
|||||||
@@ -56,15 +56,15 @@ class SettingsActivity : BaseActivity() {
|
|||||||
if (isPasswordVerified) {
|
if (isPasswordVerified) {
|
||||||
val dialog = RecognitionModeDialog(this)
|
val dialog = RecognitionModeDialog(this)
|
||||||
dialog.setOnConfirmListener { mode ->
|
dialog.setOnConfirmListener { mode ->
|
||||||
updateRecognitionMode(mode)
|
updateRecognitionMode(mode, verifiedPassword)
|
||||||
}
|
}
|
||||||
dialog.show()
|
dialog.show()
|
||||||
} else {
|
} else {
|
||||||
showPasswordDialog { _ ->
|
showPasswordDialog { inputPassword ->
|
||||||
isPasswordVerified = true
|
isPasswordVerified = true
|
||||||
val dialog = RecognitionModeDialog(this)
|
val dialog = RecognitionModeDialog(this)
|
||||||
dialog.setOnConfirmListener { mode ->
|
dialog.setOnConfirmListener { mode ->
|
||||||
updateRecognitionMode(mode)
|
updateRecognitionMode(mode, inputPassword)
|
||||||
}
|
}
|
||||||
dialog.show()
|
dialog.show()
|
||||||
}
|
}
|
||||||
@@ -106,11 +106,13 @@ class SettingsActivity : BaseActivity() {
|
|||||||
binding.itemAutoMode.setOnClickListener {
|
binding.itemAutoMode.setOnClickListener {
|
||||||
if (isPasswordVerified) {
|
if (isPasswordVerified) {
|
||||||
val intent = Intent(this, AutoModeActivity::class.java)
|
val intent = Intent(this, AutoModeActivity::class.java)
|
||||||
|
intent.putExtra("optionPassword", verifiedPassword)
|
||||||
startActivity(intent)
|
startActivity(intent)
|
||||||
} else {
|
} else {
|
||||||
showPasswordDialog { _ ->
|
showPasswordDialog { inputPassword ->
|
||||||
isPasswordVerified = true
|
isPasswordVerified = true
|
||||||
val intent = Intent(this, AutoModeActivity::class.java)
|
val intent = Intent(this, AutoModeActivity::class.java)
|
||||||
|
intent.putExtra("optionPassword", inputPassword)
|
||||||
startActivity(intent)
|
startActivity(intent)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -259,7 +261,7 @@ class SettingsActivity : BaseActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateRecognitionMode(mode: String) {
|
private fun updateRecognitionMode(mode: String, optionPassword: String?) {
|
||||||
val deviceId = DeviceIdEvent.getDeviceId()
|
val deviceId = DeviceIdEvent.getDeviceId()
|
||||||
if (deviceId.isNullOrEmpty()) {
|
if (deviceId.isNullOrEmpty()) {
|
||||||
Toast.makeText(this, "设备ID为空", Toast.LENGTH_SHORT).show()
|
Toast.makeText(this, "设备ID为空", Toast.LENGTH_SHORT).show()
|
||||||
@@ -277,6 +279,7 @@ class SettingsActivity : BaseActivity() {
|
|||||||
val deviceBean = com.ckkj.defense_device.bean.DeviceBean(
|
val deviceBean = com.ckkj.defense_device.bean.DeviceBean(
|
||||||
id = deviceId,
|
id = deviceId,
|
||||||
patternPerception = patternPerception,
|
patternPerception = patternPerception,
|
||||||
|
optionPassword = optionPassword
|
||||||
)
|
)
|
||||||
val response = RetrofitNetwork.getNetworkService().updateDeviceInfo(deviceBean)
|
val response = RetrofitNetwork.getNetworkService().updateDeviceInfo(deviceBean)
|
||||||
withContext(Dispatchers.Main) {
|
withContext(Dispatchers.Main) {
|
||||||
|
|||||||
@@ -77,6 +77,7 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/save"
|
android:text="@string/save"
|
||||||
|
android:textColor="@color/white"
|
||||||
android:layout_marginEnd="20dp"
|
android:layout_marginEnd="20dp"
|
||||||
android:layout_marginStart="20dp"
|
android:layout_marginStart="20dp"
|
||||||
android:layout_marginBottom="90dp"
|
android:layout_marginBottom="90dp"
|
||||||
|
|||||||
Reference in New Issue
Block a user