|
@@ -27,6 +27,7 @@ import com.wdkl.ncs.entraceguard.tcp.channel.EntraceGuardUtil
|
|
import com.wdkl.ncs.entraceguard.tcp.dto.TcpModel
|
|
import com.wdkl.ncs.entraceguard.tcp.dto.TcpModel
|
|
import com.wdkl.ncs.entraceguard.tcp.enums.TcpAction
|
|
import com.wdkl.ncs.entraceguard.tcp.enums.TcpAction
|
|
import com.wdkl.ncs.entraceguard.tcp.enums.TcpType
|
|
import com.wdkl.ncs.entraceguard.tcp.enums.TcpType
|
|
|
|
+import com.wdkl.ncs.entraceguard.utils.LocaleMangerUtils
|
|
import com.wdkl.ncs.framework.base.BaseActivity
|
|
import com.wdkl.ncs.framework.base.BaseActivity
|
|
import com.wdkl.ncs.framework.common.Constants
|
|
import com.wdkl.ncs.framework.common.Constants
|
|
import com.wdkl.ncs.framework.di.ApiProviders
|
|
import com.wdkl.ncs.framework.di.ApiProviders
|
|
@@ -86,6 +87,8 @@ class MainActivity : BaseActivity<MainActivityPresenter, ActivityMainBinding>(),
|
|
|
|
|
|
var room: Room? = null
|
|
var room: Room? = null
|
|
|
|
|
|
|
|
+ private var language = "zh"
|
|
|
|
+
|
|
override fun getLayId(): Int {
|
|
override fun getLayId(): Int {
|
|
return R.layout.activity_main
|
|
return R.layout.activity_main
|
|
}
|
|
}
|
|
@@ -100,7 +103,7 @@ class MainActivity : BaseActivity<MainActivityPresenter, ActivityMainBinding>(),
|
|
override fun init() {
|
|
override fun init() {
|
|
|
|
|
|
if(!NetHelper.getInstance().netAvailable){
|
|
if(!NetHelper.getInstance().netAvailable){
|
|
- showTipView(R.drawable.net_inavailable,"没有网络,无法通讯")
|
|
|
|
|
|
+ showTipView(R.drawable.net_inavailable,R.string.no_network)
|
|
exitApp(5000)
|
|
exitApp(5000)
|
|
}else {
|
|
}else {
|
|
|
|
|
|
@@ -130,6 +133,8 @@ class MainActivity : BaseActivity<MainActivityPresenter, ActivityMainBinding>(),
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ language = LocaleMangerUtils.getApplicationLocale().language
|
|
}
|
|
}
|
|
|
|
|
|
override fun bindEvent() {
|
|
override fun bindEvent() {
|
|
@@ -170,7 +175,7 @@ class MainActivity : BaseActivity<MainActivityPresenter, ActivityMainBinding>(),
|
|
// SocketManager.getInstance().connect(Urls.WS, Constants.sipId, 0)
|
|
// SocketManager.getInstance().connect(Urls.WS, Constants.sipId, 0)
|
|
TcpClient.getInstance().sendMsg(EntraceGuardUtil.startVisit(Constants.deviceId).toJson())
|
|
TcpClient.getInstance().sendMsg(EntraceGuardUtil.startVisit(Constants.deviceId).toJson())
|
|
}else{
|
|
}else{
|
|
- showTipView(R.drawable.unregister,"设备未注册或未启用")
|
|
|
|
|
|
+ showTipView(R.drawable.unregister,R.string.device_unregister)
|
|
exitApp(3000)
|
|
exitApp(3000)
|
|
}
|
|
}
|
|
|
|
|
|
@@ -216,7 +221,7 @@ class MainActivity : BaseActivity<MainActivityPresenter, ActivityMainBinding>(),
|
|
TcpAction.EntraceGuardAction.FAILED ->{ //护士主机不在线
|
|
TcpAction.EntraceGuardAction.FAILED ->{ //护士主机不在线
|
|
//取消响应计时
|
|
//取消响应计时
|
|
responseCountDownTimer?.cancel()
|
|
responseCountDownTimer?.cancel()
|
|
- showTipView(R.drawable.host_offline,"对方不在线,无法连接")
|
|
|
|
|
|
+ showTipView(R.drawable.host_offline,R.string.call_failed)
|
|
exitApp(3000)
|
|
exitApp(3000)
|
|
}
|
|
}
|
|
|
|
|
|
@@ -226,10 +231,12 @@ class MainActivity : BaseActivity<MainActivityPresenter, ActivityMainBinding>(),
|
|
cancelCountDownTimer()
|
|
cancelCountDownTimer()
|
|
// 通过,亮起绿色灯光,并开门
|
|
// 通过,亮起绿色灯光,并开门
|
|
gpioHelper!!.setPassStatus(true)
|
|
gpioHelper!!.setPassStatus(true)
|
|
- gpioHelper!!.setWhiteLedStatus(true);
|
|
|
|
- play(passSoundID!!)
|
|
|
|
|
|
+ gpioHelper!!.setWhiteLedStatus(true)
|
|
|
|
+ if (Locale.CHINESE.getLanguage().equals(language)) {
|
|
|
|
+ play(passSoundID!!)
|
|
|
|
+ }
|
|
|
|
|
|
- showTipView(R.drawable.allow_in,"欢迎光临,正在为您开门")
|
|
|
|
|
|
+ showTipView(R.drawable.allow_in,R.string.door_opened)
|
|
//结束通话
|
|
//结束通话
|
|
janusClient!!.destroyRoom(janusClient!!.currentHandleId, null)
|
|
janusClient!!.destroyRoom(janusClient!!.currentHandleId, null)
|
|
janusClient!!.disConnect()
|
|
janusClient!!.disConnect()
|
|
@@ -244,8 +251,10 @@ class MainActivity : BaseActivity<MainActivityPresenter, ActivityMainBinding>(),
|
|
TcpAction.EntraceGuardAction.REJECT ->{
|
|
TcpAction.EntraceGuardAction.REJECT ->{
|
|
//停止等待音乐,停止倒计时
|
|
//停止等待音乐,停止倒计时
|
|
cancelCountDownTimer()
|
|
cancelCountDownTimer()
|
|
- play(strangerSoundID!!)
|
|
|
|
- showTipView(R.drawable.busyline,"对方正忙,请稍候在试")
|
|
|
|
|
|
+ if (Locale.CHINESE.getLanguage().equals(language)) {
|
|
|
|
+ play(strangerSoundID!!)
|
|
|
|
+ }
|
|
|
|
+ showTipView(R.drawable.busyline,R.string.call_busy)
|
|
|
|
|
|
janusClient!!.destroyRoom(janusClient!!.currentHandleId, null)
|
|
janusClient!!.destroyRoom(janusClient!!.currentHandleId, null)
|
|
janusClient!!.disConnect()
|
|
janusClient!!.disConnect()
|
|
@@ -256,7 +265,9 @@ class MainActivity : BaseActivity<MainActivityPresenter, ActivityMainBinding>(),
|
|
TcpAction.EntraceGuardAction.LOCKDOOR -> {
|
|
TcpAction.EntraceGuardAction.LOCKDOOR -> {
|
|
// 陌生人,亮起红外灯光
|
|
// 陌生人,亮起红外灯光
|
|
gpioHelper!!.setPassStatus(false)
|
|
gpioHelper!!.setPassStatus(false)
|
|
- play(strangerSoundID!!)
|
|
|
|
|
|
+ if (Locale.CHINESE.getLanguage().equals(language)) {
|
|
|
|
+ play(strangerSoundID!!)
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
TcpAction.EntraceGuardAction.OPENSPEAKER -> { //打开音频
|
|
TcpAction.EntraceGuardAction.OPENSPEAKER -> { //打开音频
|
|
@@ -288,8 +299,10 @@ class MainActivity : BaseActivity<MainActivityPresenter, ActivityMainBinding>(),
|
|
TcpAction.EntraceGuardAction.HANGUP -> { //主机直接挂断,不开门显示
|
|
TcpAction.EntraceGuardAction.HANGUP -> { //主机直接挂断,不开门显示
|
|
//停止等待音乐,停止倒计时
|
|
//停止等待音乐,停止倒计时
|
|
cancelCountDownTimer()
|
|
cancelCountDownTimer()
|
|
- play(strangerSoundID!!)
|
|
|
|
- showTipView(R.drawable.not_allow,"未授权通行")
|
|
|
|
|
|
+ if (Locale.CHINESE.getLanguage().equals(language)) {
|
|
|
|
+ play(strangerSoundID!!)
|
|
|
|
+ }
|
|
|
|
+ showTipView(R.drawable.not_allow,R.string.not_allowed)
|
|
janusClient!!.destroyRoom(janusClient!!.currentHandleId, null)
|
|
janusClient!!.destroyRoom(janusClient!!.currentHandleId, null)
|
|
janusClient!!.disConnect()
|
|
janusClient!!.disConnect()
|
|
// SkyEngineKit.Instance().endCall()
|
|
// SkyEngineKit.Instance().endCall()
|
|
@@ -433,7 +446,8 @@ class MainActivity : BaseActivity<MainActivityPresenter, ActivityMainBinding>(),
|
|
countDownTimer = object : CountDownTimer(100 * 1000L, 1000) {
|
|
countDownTimer = object : CountDownTimer(100 * 1000L, 1000) {
|
|
override fun onTick(millisUntilFinished: Long) {
|
|
override fun onTick(millisUntilFinished: Long) {
|
|
val time = millisUntilFinished / 1000
|
|
val time = millisUntilFinished / 1000
|
|
- counter_down.setText("等待响应倒计时: " + time + " 秒")
|
|
|
|
|
|
+ val text = getString(R.string.call_timeout, time)
|
|
|
|
+ counter_down.setText(text)
|
|
}
|
|
}
|
|
override fun onFinish() {
|
|
override fun onFinish() {
|
|
//呼叫超时,返回到主界面
|
|
//呼叫超时,返回到主界面
|
|
@@ -442,7 +456,7 @@ class MainActivity : BaseActivity<MainActivityPresenter, ActivityMainBinding>(),
|
|
janusClient!!.disConnect()
|
|
janusClient!!.disConnect()
|
|
RingPlayHelper.stopRingTone()
|
|
RingPlayHelper.stopRingTone()
|
|
TcpClient.getInstance().sendMsg(EntraceGuardUtil.timeOut(interactionVO).toJson())
|
|
TcpClient.getInstance().sendMsg(EntraceGuardUtil.timeOut(interactionVO).toJson())
|
|
- showTipView(R.drawable.no_reponse,"无人应答,请稍候再试")
|
|
|
|
|
|
+ showTipView(R.drawable.no_reponse,R.string.call_no_response)
|
|
exitApp(3000)
|
|
exitApp(3000)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -460,12 +474,15 @@ class MainActivity : BaseActivity<MainActivityPresenter, ActivityMainBinding>(),
|
|
|
|
|
|
}
|
|
}
|
|
override fun onFinish() {
|
|
override fun onFinish() {
|
|
- showTipView(R.drawable.no_reponse,"对方无响应,请稍候再试")
|
|
|
|
|
|
+ showTipView(R.drawable.no_reponse,R.string.call_no_response)
|
|
exitApp(3000)
|
|
exitApp(3000)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ fun showTipView(imageId: Int, resId: Int) {
|
|
|
|
+ showTipView(imageId, getString(resId))
|
|
|
|
+ }
|
|
|
|
|
|
fun showTipView(imageId :Int, message:String){
|
|
fun showTipView(imageId :Int, message:String){
|
|
counter_down_wrap.visibility=View.GONE
|
|
counter_down_wrap.visibility=View.GONE
|