|
|
@ -17,7 +17,6 @@ import android.widget.SeekBar
|
|
|
|
import android.widget.TextView
|
|
|
|
import android.widget.TextView
|
|
|
|
import androidx.appcompat.app.AppCompatActivity
|
|
|
|
import androidx.appcompat.app.AppCompatActivity
|
|
|
|
import androidx.appcompat.widget.AppCompatRadioButton
|
|
|
|
import androidx.appcompat.widget.AppCompatRadioButton
|
|
|
|
import androidx.core.view.postDelayed
|
|
|
|
|
|
|
|
import androidx.lifecycle.lifecycleScope
|
|
|
|
import androidx.lifecycle.lifecycleScope
|
|
|
|
import com.common.commonlib.utils.LogUtils
|
|
|
|
import com.common.commonlib.utils.LogUtils
|
|
|
|
import com.common.commonlib.utils.MMKVUtils
|
|
|
|
import com.common.commonlib.utils.MMKVUtils
|
|
|
@ -25,9 +24,9 @@ import com.loper7.date_time_picker.number_picker.NumberPicker
|
|
|
|
import com.yinuo.safetywatcher.R
|
|
|
|
import com.yinuo.safetywatcher.R
|
|
|
|
import com.yinuo.safetywatcher.databinding.ActivityBaseBinding
|
|
|
|
import com.yinuo.safetywatcher.databinding.ActivityBaseBinding
|
|
|
|
import com.yinuo.safetywatcher.watcher.constant.NAMESPACE_ANDROID
|
|
|
|
import com.yinuo.safetywatcher.watcher.constant.NAMESPACE_ANDROID
|
|
|
|
import com.yinuo.safetywatcher.watcher.port.GasPortUtils
|
|
|
|
|
|
|
|
import com.yinuo.safetywatcher.watcher.ui.view.CommonDialog
|
|
|
|
import com.yinuo.safetywatcher.watcher.ui.view.CommonDialog
|
|
|
|
import com.yinuo.safetywatcher.watcher.ui.view.CommonTopBar
|
|
|
|
import com.yinuo.safetywatcher.watcher.ui.view.CommonTopBar
|
|
|
|
|
|
|
|
import com.yinuo.safetywatcher.watcher.utils.GPIOUtils
|
|
|
|
import com.yinuo.safetywatcher.watcher.utils.PlatformUtils
|
|
|
|
import com.yinuo.safetywatcher.watcher.utils.PlatformUtils
|
|
|
|
import com.yinuo.safetywatcher.watcher.utils.RecordHelper
|
|
|
|
import com.yinuo.safetywatcher.watcher.utils.RecordHelper
|
|
|
|
import com.yinuo.safetywatcher.watcher.utils.SoundUtils
|
|
|
|
import com.yinuo.safetywatcher.watcher.utils.SoundUtils
|
|
|
@ -72,22 +71,11 @@ abstract class BaseActivity : AppCompatActivity() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private val shoutDownListener: (ByteArray) -> Unit = {
|
|
|
|
|
|
|
|
if (it[0] == 0x01.toByte() && it[1] == 0x06.toByte() && it[2] == 0x05.toByte() && it[5] == 0x00.toByte()) {
|
|
|
|
|
|
|
|
if (shoutDowning) {
|
|
|
|
|
|
|
|
shoutDowning = false
|
|
|
|
|
|
|
|
PlatformUtils.shutDown()
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var shoutDowning = false
|
|
|
|
|
|
|
|
open fun onShutDown() {
|
|
|
|
open fun onShutDown() {
|
|
|
|
GasPortUtils.addListener(shoutDownListener)
|
|
|
|
|
|
|
|
shoutDowning = true
|
|
|
|
|
|
|
|
GasPortUtils.setSpeed(0)
|
|
|
|
|
|
|
|
// 暂停录制编码
|
|
|
|
// 暂停录制编码
|
|
|
|
RecordHelper.stopRecording()
|
|
|
|
RecordHelper.stopRecording()
|
|
|
|
|
|
|
|
GPIOUtils.shoutDownMotor()
|
|
|
|
|
|
|
|
PlatformUtils.shutDown()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private val setVoiceAreaRunnable = Runnable {
|
|
|
|
private val setVoiceAreaRunnable = Runnable {
|
|
|
@ -237,13 +225,11 @@ abstract class BaseActivity : AppCompatActivity() {
|
|
|
|
override fun onDestroy() {
|
|
|
|
override fun onDestroy() {
|
|
|
|
super.onDestroy()
|
|
|
|
super.onDestroy()
|
|
|
|
closeLoadingDialog()
|
|
|
|
closeLoadingDialog()
|
|
|
|
GasPortUtils.removeListener(shoutDownListener)
|
|
|
|
|
|
|
|
GlobalScope.launch(Dispatchers.IO) {
|
|
|
|
GlobalScope.launch(Dispatchers.IO) {
|
|
|
|
MMKVUtils.sync()
|
|
|
|
MMKVUtils.sync()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var isHomeLongPress = false
|
|
|
|
|
|
|
|
var isLeftRightLongPress = false
|
|
|
|
var isLeftRightLongPress = false
|
|
|
|
override fun dispatchKeyEvent(event: KeyEvent): Boolean {
|
|
|
|
override fun dispatchKeyEvent(event: KeyEvent): Boolean {
|
|
|
|
LogUtils.w("cyy dispatchKeyEvent keyCode = ${event?.keyCode} count = ${event?.repeatCount} acton = ${event?.action}")
|
|
|
|
LogUtils.w("cyy dispatchKeyEvent keyCode = ${event?.keyCode} count = ${event?.repeatCount} acton = ${event?.action}")
|
|
|
@ -264,13 +250,6 @@ abstract class BaseActivity : AppCompatActivity() {
|
|
|
|
baseBinding.areaSound.postDelayed(hideVoiceAreaRunnable, 1500)
|
|
|
|
baseBinding.areaSound.postDelayed(hideVoiceAreaRunnable, 1500)
|
|
|
|
return true
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (keyCode == KeyEvent.KEYCODE_ENTER) {
|
|
|
|
|
|
|
|
if (isHomeLongPress) {
|
|
|
|
|
|
|
|
lastFocusView = currentFocus
|
|
|
|
|
|
|
|
baseBinding.layoutShutdown.visibility = View.VISIBLE
|
|
|
|
|
|
|
|
baseBinding.tvCancel.requestFocus()
|
|
|
|
|
|
|
|
return true
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else if (keyCode == KeyEvent.KEYCODE_F1) {
|
|
|
|
} else if (keyCode == KeyEvent.KEYCODE_F1) {
|
|
|
|
LogUtils.w("BaseActivity F1 up")
|
|
|
|
LogUtils.w("BaseActivity F1 up")
|
|
|
|
SoundUtils.stopSoundIo()
|
|
|
|
SoundUtils.stopSoundIo()
|
|
|
@ -279,6 +258,8 @@ abstract class BaseActivity : AppCompatActivity() {
|
|
|
|
return super.dispatchKeyEvent(event)
|
|
|
|
return super.dispatchKeyEvent(event)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private var centerDownTime = 0L
|
|
|
|
|
|
|
|
|
|
|
|
private fun dealActionDown(event: KeyEvent): Boolean {
|
|
|
|
private fun dealActionDown(event: KeyEvent): Boolean {
|
|
|
|
val repeatCount = event.repeatCount
|
|
|
|
val repeatCount = event.repeatCount
|
|
|
|
val keyCode = event.keyCode
|
|
|
|
val keyCode = event.keyCode
|
|
|
@ -289,10 +270,17 @@ abstract class BaseActivity : AppCompatActivity() {
|
|
|
|
var mediaVolume = baseBinding.sbSound.progress
|
|
|
|
var mediaVolume = baseBinding.sbSound.progress
|
|
|
|
if (KeyEvent.KEYCODE_DPAD_LEFT == keyCode) mediaVolume-- else mediaVolume++
|
|
|
|
if (KeyEvent.KEYCODE_DPAD_LEFT == keyCode) mediaVolume-- else mediaVolume++
|
|
|
|
baseBinding.sbSound.progress = mediaVolume
|
|
|
|
baseBinding.sbSound.progress = mediaVolume
|
|
|
|
return super.dispatchKeyEvent(event)
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (keyCode == KeyEvent.KEYCODE_ENTER) {
|
|
|
|
} else if (keyCode == KeyEvent.KEYCODE_ENTER) {
|
|
|
|
isHomeLongPress = repeatCount > 8
|
|
|
|
if (repeatCount == 0) {
|
|
|
|
|
|
|
|
centerDownTime = System.currentTimeMillis()
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
if (System.currentTimeMillis() - centerDownTime > 2000 && baseBinding.layoutShutdown.visibility == View.GONE) {
|
|
|
|
|
|
|
|
lastFocusView = currentFocus
|
|
|
|
|
|
|
|
baseBinding.layoutShutdown.visibility = View.VISIBLE
|
|
|
|
|
|
|
|
baseBinding.tvCancel.requestFocus()
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
} else if (keyCode == KeyEvent.KEYCODE_F1) {
|
|
|
|
} else if (keyCode == KeyEvent.KEYCODE_F1) {
|
|
|
|
LogUtils.w("BaseActivity F1 pressed")
|
|
|
|
LogUtils.w("BaseActivity F1 pressed")
|
|
|
|
SoundUtils.playSoundIo()
|
|
|
|
SoundUtils.playSoundIo()
|
|
|
|