|
|
|
@ -18,7 +18,6 @@ import com.yinuo.safetywatcher.watcher.port.UNIT_PPM
|
|
|
|
|
import com.yinuo.safetywatcher.watcher.port.cmd.CH4_H2
|
|
|
|
|
import com.yinuo.safetywatcher.watcher.port.cmd.O2
|
|
|
|
|
import com.yinuo.safetywatcher.watcher.port.cmd.VOCS
|
|
|
|
|
import com.yinuo.safetywatcher.watcher.port.getGasRange
|
|
|
|
|
import com.yinuo.safetywatcher.watcher.port.getLocalGasUnit
|
|
|
|
|
import com.yinuo.safetywatcher.watcher.port.saveGasUnit
|
|
|
|
|
import com.yinuo.safetywatcher.watcher.utils.hideIme
|
|
|
|
@ -43,6 +42,7 @@ class SensorSettingActivity : NoOptionsActivity() {
|
|
|
|
|
|
|
|
|
|
var gasName = ""
|
|
|
|
|
var sensorIndex = -1
|
|
|
|
|
var showRbView: View? = null
|
|
|
|
|
|
|
|
|
|
override fun initView() {
|
|
|
|
|
gasName = intent.getStringExtra("GasType")!!
|
|
|
|
@ -53,10 +53,12 @@ class SensorSettingActivity : NoOptionsActivity() {
|
|
|
|
|
mBinding.rgUnit.visibility = View.GONE
|
|
|
|
|
mBinding.rbLel.visibility = View.GONE
|
|
|
|
|
mBinding.rbVol.visibility = View.VISIBLE
|
|
|
|
|
showRbView = mBinding.rbVol
|
|
|
|
|
} else if (gasName == CH4_H2) {
|
|
|
|
|
mBinding.rgUnit.visibility = View.GONE
|
|
|
|
|
mBinding.rbVol.visibility = View.GONE
|
|
|
|
|
mBinding.rbLel.visibility = View.VISIBLE
|
|
|
|
|
showRbView = mBinding.rbLel
|
|
|
|
|
} else {
|
|
|
|
|
mBinding.rgUnit.visibility = View.VISIBLE
|
|
|
|
|
mBinding.rbVol.visibility = View.GONE
|
|
|
|
@ -66,8 +68,10 @@ class SensorSettingActivity : NoOptionsActivity() {
|
|
|
|
|
}
|
|
|
|
|
if (localGasUnit == UNIT_PPM) {
|
|
|
|
|
mBinding.rbPpm.isChecked = true
|
|
|
|
|
showRbView = mBinding.rbPpm
|
|
|
|
|
} else {
|
|
|
|
|
mBinding.rbMgm3.isChecked = true
|
|
|
|
|
showRbView = mBinding.rbMgm3
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -82,9 +86,10 @@ class SensorSettingActivity : NoOptionsActivity() {
|
|
|
|
|
} else {
|
|
|
|
|
mBinding.etName.setText("${gasName}传感器")
|
|
|
|
|
}
|
|
|
|
|
val gasRange = getGasRange(gasName)
|
|
|
|
|
mBinding.etStep.text = getString(R.string.sensor_step_txt).plus(": $gasRange")
|
|
|
|
|
mBinding.etGasName.setText(gasNickName ?: "")
|
|
|
|
|
val gasRange = ParseHelper.getGasRangeMax(gasName)
|
|
|
|
|
// mBinding.etStep.text = getString(R.string.sensor_step_txt).plus(": $gasRange")
|
|
|
|
|
mBinding.etStep.hint = "最大量程:$gasRange $localGasUnit"
|
|
|
|
|
mBinding.etGasName.hint = "气体名称:$gasNickName"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -171,7 +176,7 @@ class SensorSettingActivity : NoOptionsActivity() {
|
|
|
|
|
}
|
|
|
|
|
} else if (keyCode == KeyEvent.KEYCODE_DPAD_DOWN) {
|
|
|
|
|
if (event.action == KeyEvent.ACTION_DOWN) {
|
|
|
|
|
mBinding.tvWarnSetting.requestFocus()
|
|
|
|
|
mBinding.etStep.requestFocus()
|
|
|
|
|
return@setOnKeyListener true
|
|
|
|
|
}
|
|
|
|
|
} else if (keyCode == KeyEvent.KEYCODE_DPAD_CENTER || keyCode == KeyEvent.KEYCODE_ENTER) {
|
|
|
|
@ -183,6 +188,27 @@ class SensorSettingActivity : NoOptionsActivity() {
|
|
|
|
|
return@setOnKeyListener false
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
mBinding.etStep.setOnKeyListener { v, keyCode, event ->
|
|
|
|
|
if (keyCode == KeyEvent.KEYCODE_DPAD_UP) {
|
|
|
|
|
if (event.action == KeyEvent.ACTION_DOWN) {
|
|
|
|
|
mBinding.etGasName.requestFocus()
|
|
|
|
|
return@setOnKeyListener true
|
|
|
|
|
}
|
|
|
|
|
} else if (keyCode == KeyEvent.KEYCODE_DPAD_DOWN) {
|
|
|
|
|
if (event.action == KeyEvent.ACTION_DOWN) {
|
|
|
|
|
// mBinding.tvWarnSetting.requestFocus()
|
|
|
|
|
showRbView?.requestFocus() ?: mBinding.tvWarnSetting.requestFocus()
|
|
|
|
|
return@setOnKeyListener true
|
|
|
|
|
}
|
|
|
|
|
} else if (keyCode == KeyEvent.KEYCODE_DPAD_CENTER || keyCode == KeyEvent.KEYCODE_ENTER) {
|
|
|
|
|
if (event.action == KeyEvent.ACTION_DOWN) {
|
|
|
|
|
mBinding.etStep.showIme()
|
|
|
|
|
return@setOnKeyListener true
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return@setOnKeyListener false
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
mBinding.etName.setOnFocusChangeListener { _, hasFocus ->
|
|
|
|
|
if (!hasFocus) {
|
|
|
|
|
mBinding.etName.hideIme()
|
|
|
|
@ -227,6 +253,8 @@ class SensorSettingActivity : NoOptionsActivity() {
|
|
|
|
|
val gasNickName = mBinding.etGasName.text.toString()
|
|
|
|
|
saveGasNickName(gasName, gasNickName)
|
|
|
|
|
|
|
|
|
|
// TODO 量程
|
|
|
|
|
|
|
|
|
|
val checkedRadioButtonId = mBinding.rgUnit.checkedRadioButtonId
|
|
|
|
|
var selectedUnit = UNIT_PPM
|
|
|
|
|
if (checkedRadioButtonId == R.id.rb_mgm3) {
|
|
|
|
|