自动模式

This commit is contained in:
2026-05-19 16:15:14 +08:00
parent 066334932f
commit 157ac8be13
4 changed files with 61 additions and 100 deletions

View File

@@ -20,7 +20,7 @@ import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
//设置页面
class SettingsActivity : BaseActivity() {
class SettingsActivity : BaseActivity(), DeviceUpdateEvent.DeviceUpdateListener {
private lateinit var binding: SettingsActivityBinding
private val SP_NAME = "DeviceSettings"
@@ -96,6 +96,16 @@ class SettingsActivity : BaseActivity() {
startActivity(intent)
}
fetchDeviceInfo()
DeviceUpdateEvent.addListener(this)
}
override fun onDestroy() {
super.onDestroy()
DeviceUpdateEvent.removeListener(this)
}
override fun onDeviceUpdated(deviceId: String) {
fetchDeviceInfo()
}
private fun fetchDeviceInfo() {
@@ -144,6 +154,14 @@ class SettingsActivity : BaseActivity() {
!cacheMode.isNullOrEmpty() -> cacheMode
else -> getString(R.string.bluetooth_recognition)
}
device.workMode?.let { workMode ->
binding.tvAutoMode.text = when (workMode) {
"0" -> getString(R.string.full_auto_mode)
"1" -> getString(R.string.semi_auto_mode)
else -> getString(R.string.full_auto_mode)
}
}
}
private fun getCachedRecognitionMode(): String? {