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