优化设置页面到水枪设置的操作密码传值,关闭lint这个检查
This commit is contained in:
@@ -27,6 +27,7 @@ class SettingsActivity : BaseActivity() {
|
||||
private var alertAudio: String? = null
|
||||
private var audioContent: String? = null
|
||||
private var isPasswordVerified = false
|
||||
private var verifiedPassword: String? = null
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
@@ -59,7 +60,7 @@ class SettingsActivity : BaseActivity() {
|
||||
}
|
||||
dialog.show()
|
||||
} else {
|
||||
showPasswordDialog {
|
||||
showPasswordDialog { _ ->
|
||||
isPasswordVerified = true
|
||||
val dialog = RecognitionModeDialog(this)
|
||||
dialog.setOnConfirmListener { mode ->
|
||||
@@ -94,11 +95,11 @@ class SettingsActivity : BaseActivity() {
|
||||
}
|
||||
binding.itemWaterGunSetting.setOnClickListener {
|
||||
if (isPasswordVerified) {
|
||||
navigateToWaterGunSettings()
|
||||
navigateToWaterGunSettings(verifiedPassword)
|
||||
} else {
|
||||
showPasswordDialog {
|
||||
showPasswordDialog { inputPassword ->
|
||||
isPasswordVerified = true
|
||||
navigateToWaterGunSettings()
|
||||
navigateToWaterGunSettings(inputPassword)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -107,7 +108,7 @@ class SettingsActivity : BaseActivity() {
|
||||
val intent = Intent(this, AutoModeActivity::class.java)
|
||||
startActivity(intent)
|
||||
} else {
|
||||
showPasswordDialog {
|
||||
showPasswordDialog { _ ->
|
||||
isPasswordVerified = true
|
||||
val intent = Intent(this, AutoModeActivity::class.java)
|
||||
startActivity(intent)
|
||||
@@ -328,7 +329,7 @@ class SettingsActivity : BaseActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
private fun showPasswordDialog(onVerified: () -> Unit) {
|
||||
private fun showPasswordDialog(onVerified: (String) -> Unit) {
|
||||
passwordDialog = PasswordInputDialog(this).apply {
|
||||
setOnConfirmListener { inputPassword ->
|
||||
CoroutineScope(Dispatchers.IO).launch {
|
||||
@@ -338,7 +339,8 @@ class SettingsActivity : BaseActivity() {
|
||||
withContext(Dispatchers.Main) {
|
||||
if (response.code == 200) {
|
||||
dismiss()
|
||||
onVerified()
|
||||
verifiedPassword = inputPassword
|
||||
onVerified(inputPassword)
|
||||
} else {
|
||||
Toast.makeText(
|
||||
this@SettingsActivity,
|
||||
@@ -365,8 +367,9 @@ class SettingsActivity : BaseActivity() {
|
||||
passwordDialog.show()
|
||||
}
|
||||
|
||||
private fun navigateToWaterGunSettings() {
|
||||
private fun navigateToWaterGunSettings(optionPassword: String? = null) {
|
||||
val intent = Intent(this, WaterGunSettingsActivity::class.java)
|
||||
intent.putExtra("optionPassword", optionPassword)
|
||||
val deviceId = DeviceIdEvent.getDeviceId()
|
||||
if (!deviceId.isNullOrEmpty()) {
|
||||
CoroutineScope(Dispatchers.IO).launch {
|
||||
|
||||
@@ -24,6 +24,7 @@ class WaterGunSettingsActivity : BaseActivity() {
|
||||
private var currentStrikeRange: String = "7"
|
||||
private var currentStrikeInterval: String = "3"
|
||||
private var currentContainer: String = "容器4"
|
||||
private var optionPassword: String? = null
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
@@ -41,6 +42,7 @@ class WaterGunSettingsActivity : BaseActivity() {
|
||||
currentStrikeRange = intent.getStringExtra("strikeRange") ?: "7"
|
||||
currentStrikeInterval = intent.getStringExtra("strikeInterval") ?: "3"
|
||||
currentContainer = intent.getStringExtra("container") ?: "容器4"
|
||||
optionPassword = intent.getStringExtra("optionPassword")
|
||||
|
||||
// 显示初始值
|
||||
binding.tvDistance.text = "${currentStrikeRange}m"
|
||||
@@ -100,7 +102,8 @@ class WaterGunSettingsActivity : BaseActivity() {
|
||||
try {
|
||||
val deviceBean = DeviceBean(
|
||||
id = deviceId,
|
||||
strikeRange = distance
|
||||
strikeRange = distance,
|
||||
optionPassword = optionPassword
|
||||
)
|
||||
val response = RetrofitNetwork.getNetworkService().updateDeviceInfo(deviceBean)
|
||||
withContext(Dispatchers.Main) {
|
||||
@@ -131,7 +134,8 @@ class WaterGunSettingsActivity : BaseActivity() {
|
||||
try {
|
||||
val deviceBean = DeviceBean(
|
||||
id = deviceId,
|
||||
strikeInterval = interval
|
||||
strikeInterval = interval,
|
||||
optionPassword = optionPassword
|
||||
)
|
||||
val response = RetrofitNetwork.getNetworkService().updateDeviceInfo(deviceBean)
|
||||
withContext(Dispatchers.Main) {
|
||||
@@ -162,7 +166,8 @@ class WaterGunSettingsActivity : BaseActivity() {
|
||||
try {
|
||||
val deviceBean = DeviceBean(
|
||||
id = deviceId,
|
||||
container = container
|
||||
container = container,
|
||||
optionPassword = optionPassword
|
||||
)
|
||||
val response = RetrofitNetwork.getNetworkService().updateDeviceInfo(deviceBean)
|
||||
withContext(Dispatchers.Main) {
|
||||
|
||||
Reference in New Issue
Block a user