|
@@ -1,12 +1,15 @@
|
|
|
package com.wdkl.app.ncs.callingdoor.activity
|
|
|
|
|
|
import android.content.*
|
|
|
+import android.graphics.Color
|
|
|
import android.net.ConnectivityManager
|
|
|
import android.os.*
|
|
|
import android.support.v4.app.Fragment
|
|
|
import android.text.TextUtils
|
|
|
import android.util.Log
|
|
|
+import android.view.Gravity
|
|
|
import android.view.View
|
|
|
+import android.widget.TextView
|
|
|
import com.enation.javashop.android.jrouter.external.annotation.Router
|
|
|
import com.enation.javashop.net.engine.model.NetState
|
|
|
import com.example.yf_rk3288_api.YF_RK3288_API_Manager
|
|
@@ -47,6 +50,7 @@ import com.wdkl.ncs.android.middleware.tcp.enums.TcpType
|
|
|
import com.wdkl.ncs.android.middleware.udp.ServerInfoUtil
|
|
|
import com.wdkl.ncs.android.middleware.utils.AppUtil
|
|
|
import com.wdkl.ncs.android.middleware.utils.CommonUtils
|
|
|
+import com.wdkl.ncs.android.middleware.utils.Util
|
|
|
import kotlinx.android.synthetic.main.callingdoor_main_lay.*
|
|
|
import kotlinx.android.synthetic.main.callingdoor_main_lay.app_version
|
|
|
import kotlinx.android.synthetic.main.callingdoor_main_lay.room_action_call
|
|
@@ -55,6 +59,7 @@ import kotlinx.android.synthetic.main.callingdoor_main_lay.room_action_nurse
|
|
|
import kotlinx.android.synthetic.main.callingdoor_main_lay.room_action_support
|
|
|
import kotlinx.android.synthetic.main.callingdoor_main_lay.room_cancel_call
|
|
|
import kotlinx.android.synthetic.main.callingdoor_main_lay.tv_room_name
|
|
|
+import kotlinx.android.synthetic.main.callingdoor_main_lay.view_flipper
|
|
|
import kotlinx.android.synthetic.main.callingdoor_main_lay_rk3288.*
|
|
|
import kotlinx.android.synthetic.main.view_bed_name.*
|
|
|
import kotlinx.android.synthetic.main.view_title_layout.*
|
|
@@ -112,6 +117,8 @@ class CallingdoorActivity :BaseActivity<CallingdoorActivityPresenter, Callingdoo
|
|
|
private var cancelRestart = false
|
|
|
private var copyDone = false
|
|
|
|
|
|
+ private var bedCalls = ArrayList<String>()
|
|
|
+
|
|
|
private val handler by lazy { Handler(Looper.getMainLooper()) }
|
|
|
|
|
|
//网络异常计数
|
|
@@ -184,6 +191,15 @@ class CallingdoorActivity :BaseActivity<CallingdoorActivityPresenter, Callingdoo
|
|
|
//alarmManager.setTimeZone("Asia/Shanghai")
|
|
|
}
|
|
|
|
|
|
+ //tts初始化
|
|
|
+ SpeechUtil.getInstance().init(activity) {
|
|
|
+ //如果tts启用失败或者不支持中文则将语音播报切换到音乐模式
|
|
|
+ if (!it) {
|
|
|
+ Log.e(TAG, "tts init failed...")
|
|
|
+ }
|
|
|
+ }
|
|
|
+ SpeechUtil.getInstance().setSpeechLoopCount(3)
|
|
|
+
|
|
|
app_version.text = "V" + BuildConfig.VERSION_NAME
|
|
|
|
|
|
//显示二维码界面
|
|
@@ -454,9 +470,9 @@ class CallingdoorActivity :BaseActivity<CallingdoorActivityPresenter, Callingdoo
|
|
|
room_action_nurse.setBackgroundResource(R.mipmap.bg_bottom_btn)
|
|
|
tv_room_name.text = Constant.ROOM_NAME
|
|
|
tv_room_name.setTextColor(resources.getColor(R.color.main_color))
|
|
|
- if (Constant.DEVICE_ID != -1 && nursingInteId != null) {
|
|
|
+ /*if (Constant.DEVICE_ID != -1 && nursingInteId != null) {
|
|
|
OtherUtil.sendNursingEnd(Constant.DEVICE_ID, nursingInteId)
|
|
|
- }
|
|
|
+ }*/
|
|
|
} else {
|
|
|
Constant.inNursing = true
|
|
|
if ("rk3128".equals(Build.MODEL) || "rk3368".equals(Build.MODEL) || "WDMK_I".equals(Build.MODEL) || "WDMKI".equals(Build.MODEL)) {
|
|
@@ -470,9 +486,9 @@ class CallingdoorActivity :BaseActivity<CallingdoorActivityPresenter, Callingdoo
|
|
|
tv_room_name.text = Constant.ROOM_NAME + " " + Constant.NursingTitle + "..."
|
|
|
}
|
|
|
tv_room_name.setTextColor(resources.getColor(R.color.nursing_color))
|
|
|
- if (Constant.DEVICE_ID != -1) {
|
|
|
+ /*if (Constant.DEVICE_ID != -1) {
|
|
|
OtherUtil.sendNursing(Constant.DEVICE_ID)
|
|
|
- }
|
|
|
+ }*/
|
|
|
}
|
|
|
|
|
|
return@setOnLongClickListener true
|
|
@@ -554,7 +570,19 @@ class CallingdoorActivity :BaseActivity<CallingdoorActivityPresenter, Callingdoo
|
|
|
|
|
|
//门口机取消分机呼叫
|
|
|
room_cancel_call.setOnClickListener {
|
|
|
- VoiceUtil.cancelCallByDoor(Constant.DEVICE_ID)
|
|
|
+ if (Constant.TCP_CONNECTED) {
|
|
|
+ if (Constant.DEVICE_ID != -1) {
|
|
|
+ VoiceUtil.cancelCallByDoor(Constant.DEVICE_ID)
|
|
|
+ } else {
|
|
|
+ showMessage("没有设备id!")
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ showMessage("网络异常!")
|
|
|
+ }
|
|
|
+
|
|
|
+ SpeechUtil.getInstance().stopSpeak()
|
|
|
+ bedCalls.clear()
|
|
|
+ view_flipper.removeAllViews()
|
|
|
}
|
|
|
|
|
|
app_version.setOnLongClickListener {
|
|
@@ -1095,9 +1123,12 @@ class CallingdoorActivity :BaseActivity<CallingdoorActivityPresenter, Callingdoo
|
|
|
val interactionVO = Gson().fromJson(tcpModel.data.toString(), InteractionVO::class.java)
|
|
|
nursingInteId = interactionVO.id
|
|
|
} else {
|
|
|
- if ("rk3128".equals(Build.MODEL) || "rk3368".equals(Build.MODEL) || "WDMK_I".equals(Build.MODEL) || "WDMKI".equals(Build.MODEL)) {
|
|
|
+ /*if ("rk3128".equals(Build.MODEL) || "rk3368".equals(Build.MODEL) || "WDMK_I".equals(Build.MODEL) || "WDMKI".equals(Build.MODEL)) {
|
|
|
DoorLightHelper.handleDoorLight(tcpModel)
|
|
|
- }
|
|
|
+ }*/
|
|
|
+
|
|
|
+ DoorLightHelper.handleDoorLight(tcpModel)
|
|
|
+ callControl(tcpModel)
|
|
|
}
|
|
|
} else if(tcpModel.action == TcpAction.TimeAction.SYNC && tcpModel.type==TcpType.TIME){
|
|
|
val time = tcpModel.data.toString().toLong()*1000
|
|
@@ -1128,6 +1159,55 @@ class CallingdoorActivity :BaseActivity<CallingdoorActivityPresenter, Callingdoo
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private fun callControl(tcpModel: TcpModel) {
|
|
|
+ if (tcpModel.action == TcpAction.SideAction.CALL) {
|
|
|
+ //显示分机呼叫信息
|
|
|
+ val interactionVO = Gson().fromJson(tcpModel.data.toString(), InteractionVO::class.java)
|
|
|
+ updateBedCall(interactionVO, true)
|
|
|
+ } else if (tcpModel.action == TcpAction.SideAction.ACCEPT || tcpModel.action == TcpAction.SideAction.CANCEL) {
|
|
|
+ val interactionVO = Gson().fromJson(tcpModel.data.toString(), InteractionVO::class.java)
|
|
|
+ updateBedCall(interactionVO, false)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //更新呼叫信息显示
|
|
|
+ private fun updateBedCall(interactionVO: InteractionVO, add: Boolean) {
|
|
|
+ val name = CommonUtils.subStringAfter(interactionVO.fromFrameFullName, "-")
|
|
|
+ val frameName = Util.appendSpace(interactionVO.fromFrameFullName.replace("-", ","))
|
|
|
+ if (add) {
|
|
|
+ bedCalls.add(name)
|
|
|
+ if (Constant.TTS_STATUS == 2) {
|
|
|
+ SpeechUtil.getInstance().addSpeech(frameName + "呼叫", false)
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ bedCalls.remove(name)
|
|
|
+ if (Constant.TTS_STATUS == 2) {
|
|
|
+ SpeechUtil.getInstance().removeSpeak(frameName + "呼叫")
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (bedCalls.size > 0) {
|
|
|
+ view_flipper.removeAllViews()
|
|
|
+ for ((index, e) in bedCalls.withIndex()) {
|
|
|
+ val textView = TextView(activity)
|
|
|
+ textView.text = e + " 呼叫"
|
|
|
+ textView.setSingleLine(true)
|
|
|
+ textView.setEllipsize(TextUtils.TruncateAt.END)
|
|
|
+ textView.setTextColor(Color.RED)
|
|
|
+ if ("rk3288".equals(Build.MODEL) || "rk3368".equals(Build.MODEL) || "WDMK_I".equals(Build.MODEL) || "WDMKI".equals(Build.MODEL)) {
|
|
|
+ textView.textSize = 48f
|
|
|
+ } else {
|
|
|
+ textView.textSize = 32f
|
|
|
+ }
|
|
|
+ textView.gravity = (Gravity.END or Gravity.CENTER)
|
|
|
+
|
|
|
+ view_flipper.addView(textView, index)
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ view_flipper.removeAllViews()
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private fun updateStatus(state: String) {
|
|
|
this.runOnUiThread {
|
|
|
when (state) {
|