修改sos报警问题

main
chengbin 4 months ago
parent ae7bacc912
commit 795c836f0c

@ -63,15 +63,6 @@ abstract class BaseActivity : AppCompatActivity() {
super.onCreate(null)
setContentView(baseBinding.root)
// 测试按钮
baseBinding.tvExit.setOnClickListener{
val intent = Intent(Intent.ACTION_MAIN)
intent.addCategory(Intent.CATEGORY_HOME)
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK
startActivityForResult(intent, 1111)
// finish()
}
initSound()
setChildContent()
initView()
@ -261,6 +252,10 @@ abstract class BaseActivity : AppCompatActivity() {
}
private fun dealActionUp(event: KeyEvent): Boolean {
if(baseBinding.sosArea.visibility == View.VISIBLE){
return true
}
val repeatCount = event.repeatCount
val keyCode = event.keyCode
/*if (KeyEvent.KEYCODE_DPAD_LEFT == keyCode || KeyEvent.KEYCODE_DPAD_RIGHT == keyCode) {
@ -271,14 +266,17 @@ abstract class BaseActivity : AppCompatActivity() {
} else */
if (keyCode == KeyEvent.KEYCODE_F1) {
LogUtils.w("BaseActivity F1 up")
onSosHelp(false)
SoundUtils.stopSoundIo()
if(System.currentTimeMillis() - sosDownTime > 5000){
onSosHelp(false)
SoundUtils.stopSoundIo()
}
return true
}
return super.dispatchKeyEvent(event)
}
private var centerDownTime = 0L
private var sosDownTime = 0L
private fun dealActionDown(event: KeyEvent): Boolean {
val repeatCount = event.repeatCount
@ -303,6 +301,10 @@ abstract class BaseActivity : AppCompatActivity() {
}
}
} else if (keyCode == KeyEvent.KEYCODE_F1) {
sosDownTime == System.currentTimeMillis();
if(baseBinding.sosArea.visibility == View.VISIBLE){
return true
}
LogUtils.w("BaseActivity F1 pressed")
onSosHelp()
SoundUtils.playSoundIo()
@ -320,6 +322,15 @@ abstract class BaseActivity : AppCompatActivity() {
return
}
LztekUtil.setSosStatus(sos)
if (sos) {
if (baseBinding.sosArea.visibility == View.GONE) {
baseBinding.sosArea.visibility = View.VISIBLE
}
} else {
if (baseBinding.sosArea.visibility == View.VISIBLE) {
baseBinding.sosArea.visibility = View.GONE
}
}
GlobalScope.launch(Dispatchers.IO) {
devicesApi.sendSosAlarm()
}
@ -336,6 +347,7 @@ abstract class BaseActivity : AppCompatActivity() {
}
private fun hideVoiceArea() {
lastFocusView?.requestFocus()
baseBinding.areaSound.visibility = View.GONE

@ -310,18 +310,7 @@ class HomeActivity : NoOptionsActivity() {
Process.killProcess(Process.myPid())
}
override fun onSosHelp(sos: Boolean) {
super.onSosHelp(sos)
if (sos) {
if (mBinding.tvSos.visibility == View.GONE) {
mBinding.tvSos.visibility = View.VISIBLE
}
} else {
if (mBinding.tvSos.visibility == View.VISIBLE) {
mBinding.tvSos.visibility = View.GONE
}
}
}
override fun onBackPressed() {
// super.onBackPressed()

@ -1,108 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/_303852"
android:orientation="vertical">
<com.yinuo.safetywatcher.watcher.ui.view.CommonTopBar
android:id="@+id/topBar"
android:layout_width="match_parent"
android:layout_height="@dimen/_120dp" />
<RelativeLayout
android:id="@+id/area_sound"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:background="@drawable/warn_setting_btn_bg"
android:padding="@dimen/_20dp"
android:visibility="gone">
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.yinuo.safetywatcher.watcher.ui.view.CommonTopBar
android:id="@+id/topBar"
android:layout_width="match_parent"
android:layout_height="@dimen/_120dp" />
<TextView
android:id="@+id/tv"
<RelativeLayout
android:id="@+id/area_sound"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:text="音量"
android:textColor="@color/white"
android:textSize="@dimen/_40dp" />
android:layout_centerInParent="true"
android:background="@drawable/warn_setting_btn_bg"
android:padding="@dimen/_20dp"
android:visibility="gone">
<TextView
android:id="@+id/tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:text="音量"
android:textColor="@color/white"
android:textSize="@dimen/_40dp" />
<SeekBar
android:id="@+id/sb_sound"
style="@style/LightSeekbarStyle"
android:layout_width="@dimen/_630dp"
android:layout_height="@dimen/_100dp"
android:layout_below="@+id/tv"
android:layout_marginTop="@dimen/_20dp"
android:focusable="true"
android:nextFocusRight="@id/sb_sound"
android:nextFocusLeft="@id/sb_sound"
android:min="0"
android:padding="0dp" />
<SeekBar
android:id="@+id/sb_sound"
style="@style/LightSeekbarStyle"
android:layout_width="@dimen/_630dp"
android:layout_height="@dimen/_100dp"
android:layout_below="@+id/tv"
android:layout_marginTop="@dimen/_20dp"
android:focusable="true"
android:nextFocusRight="@id/sb_sound"
android:nextFocusLeft="@id/sb_sound"
android:min="0"
android:padding="0dp" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/layout_shutdown"
android:layout_width="@dimen/_960dp"
android:layout_height="200px"
android:layout_centerInParent="true"
android:background="@drawable/warn_setting_btn_bg"
android:visibility="gone">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="@dimen/_32dp"
android:layout_marginBottom="@dimen/_32dp"
android:text="您的设备将会关机!"
android:textColor="@color/white"
android:textSize="@dimen/_36dp" />
<TextView
android:id="@+id/tv_cancel"
android:layout_width="@dimen/_480dp"
android:layout_height="@dimen/_81dp"
android:layout_alignParentBottom="true"
android:background="@drawable/cancel_btn_bg"
android:focusable="true"
android:gravity="center"
android:text="@string/cancel"
android:nextFocusLeft="@id/tv_cancel"
android:textColor="@color/white_30"
android:textSize="@dimen/_36dp" />
<TextView
android:id="@+id/tv_confirm"
android:layout_width="@dimen/_480dp"
android:layout_height="@dimen/_81dp"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:background="@drawable/confirm_btn_bg"
android:focusable="true"
android:gravity="center"
android:text="@string/confirm"
android:nextFocusRight="@id/tv_confirm"
android:textColor="@color/white"
android:textSize="@dimen/_36dp" />
</RelativeLayout>
</RelativeLayout>
<RelativeLayout
android:id="@+id/layout_shutdown"
android:layout_width="@dimen/_960dp"
android:layout_height="200px"
android:layout_centerInParent="true"
android:background="@drawable/warn_setting_btn_bg"
android:visibility="gone">
<RelativeLayout
android:id="@+id/sos_area"
android:visibility="gone"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<TextView
android:id="@+id/tv_sos"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="@dimen/_32dp"
android:layout_marginBottom="@dimen/_32dp"
android:text="您的设备将会关机!"
android:textColor="@color/white"
android:textSize="@dimen/_36dp" />
<TextView
android:id="@+id/tv_cancel"
android:layout_width="@dimen/_480dp"
android:layout_height="@dimen/_81dp"
android:layout_alignParentBottom="true"
android:background="@drawable/cancel_btn_bg"
android:focusable="true"
android:background="@drawable/sensor_init_btn_bg"
android:gravity="center"
android:text="@string/cancel"
android:nextFocusLeft="@id/tv_cancel"
android:textColor="@color/white_30"
android:textSize="@dimen/_36dp" />
<TextView
android:id="@+id/tv_confirm"
android:layout_width="@dimen/_480dp"
android:layout_height="@dimen/_81dp"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:background="@drawable/confirm_btn_bg"
android:focusable="true"
android:gravity="center"
android:text="@string/confirm"
android:nextFocusRight="@id/tv_confirm"
android:layout_centerInParent="true"
android:text="@string/text_sos"
android:minHeight="@dimen/_100dp"
android:layout_centerHorizontal="true"
android:padding="@dimen/_12dp"
android:textColor="@color/white"
android:textSize="@dimen/_36dp" />
android:textSize="@dimen/_132dp"
/>
</RelativeLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/white"
android:text="exit"
android:visibility="gone"
android:id="@+id/tv_exit"
android:layout_marginBottom="@dimen/_20dp"
android:padding="@dimen/_20dp"
android:layout_alignParentBottom="true"
android:background="@color/red"
android:layout_alignParentEnd="true"/>
</RelativeLayout>
Loading…
Cancel
Save