|
@@ -6,6 +6,7 @@ import android.content.Intent
|
|
|
import android.content.pm.PackageManager
|
|
|
import android.media.AudioAttributes
|
|
|
import android.media.SoundPool
|
|
|
+import android.os.Build
|
|
|
import android.os.CountDownTimer
|
|
|
import android.os.Handler
|
|
|
import android.os.Looper
|
|
@@ -13,6 +14,7 @@ import android.util.Log
|
|
|
import android.view.View
|
|
|
import android.widget.ImageView
|
|
|
import android.widget.TextView
|
|
|
+import androidx.annotation.RequiresApi
|
|
|
import com.alibaba.fastjson.JSON
|
|
|
import com.google.common.base.Strings
|
|
|
import com.szeasco.facesdk.helper.GpioHelper
|
|
@@ -100,6 +102,7 @@ class MainActivity : BaseActivity<MainActivityPresenter, ActivityMainBinding>(),
|
|
|
DaggerApplicationComponent.builder().frameWorkComponent(DaggerFrameWorkComponent.builder().apiProviders(ApiProviders()).build()).build().inject(this)
|
|
|
}
|
|
|
|
|
|
+ @RequiresApi(Build.VERSION_CODES.N)
|
|
|
override fun init() {
|
|
|
|
|
|
if(!NetHelper.getInstance().netAvailable){
|
|
@@ -232,17 +235,20 @@ class MainActivity : BaseActivity<MainActivityPresenter, ActivityMainBinding>(),
|
|
|
// 通过,亮起绿色灯光,并开门
|
|
|
gpioHelper!!.setPassStatus(true)
|
|
|
gpioHelper!!.setWhiteLedStatus(true)
|
|
|
- if (Locale.CHINESE.getLanguage().equals(language)) {
|
|
|
- play(passSoundID!!)
|
|
|
- }
|
|
|
-
|
|
|
- showTipView(R.drawable.allow_in,R.string.door_opened)
|
|
|
//结束通话
|
|
|
janusClient!!.destroyRoom(janusClient!!.currentHandleId, null)
|
|
|
janusClient!!.disConnect()
|
|
|
- //处理界面
|
|
|
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ //处理界面
|
|
|
+
|
|
|
+ showTipView(R.drawable.allow_in,R.string.door_opened)
|
|
|
+// if (Locale.CHINESE.getLanguage().equals(language)) {
|
|
|
+ play(passSoundID!!)
|
|
|
+// }
|
|
|
//10秒后退出程序,调起门禁默认应用
|
|
|
exitApp(10000)
|
|
|
|
|
@@ -251,9 +257,9 @@ class MainActivity : BaseActivity<MainActivityPresenter, ActivityMainBinding>(),
|
|
|
TcpAction.EntraceGuardAction.REJECT ->{
|
|
|
//停止等待音乐,停止倒计时
|
|
|
cancelCountDownTimer()
|
|
|
- if (Locale.CHINESE.getLanguage().equals(language)) {
|
|
|
+// if (Locale.CHINESE.getLanguage().equals(language)) {
|
|
|
play(strangerSoundID!!)
|
|
|
- }
|
|
|
+// }
|
|
|
showTipView(R.drawable.busyline,R.string.call_busy)
|
|
|
|
|
|
janusClient!!.destroyRoom(janusClient!!.currentHandleId, null)
|
|
@@ -265,9 +271,9 @@ class MainActivity : BaseActivity<MainActivityPresenter, ActivityMainBinding>(),
|
|
|
TcpAction.EntraceGuardAction.LOCKDOOR -> {
|
|
|
// 陌生人,亮起红外灯光
|
|
|
gpioHelper!!.setPassStatus(false)
|
|
|
- if (Locale.CHINESE.getLanguage().equals(language)) {
|
|
|
+// if (Locale.CHINESE.getLanguage().equals(language)) {
|
|
|
play(strangerSoundID!!)
|
|
|
- }
|
|
|
+// }
|
|
|
}
|
|
|
|
|
|
TcpAction.EntraceGuardAction.OPENSPEAKER -> { //打开音频
|
|
@@ -299,9 +305,9 @@ class MainActivity : BaseActivity<MainActivityPresenter, ActivityMainBinding>(),
|
|
|
TcpAction.EntraceGuardAction.HANGUP -> { //主机直接挂断,不开门显示
|
|
|
//停止等待音乐,停止倒计时
|
|
|
cancelCountDownTimer()
|
|
|
- if (Locale.CHINESE.getLanguage().equals(language)) {
|
|
|
+// if (Locale.CHINESE.getLanguage().equals(language)) {
|
|
|
play(strangerSoundID!!)
|
|
|
- }
|
|
|
+// }
|
|
|
showTipView(R.drawable.not_allow,R.string.not_allowed)
|
|
|
janusClient!!.destroyRoom(janusClient!!.currentHandleId, null)
|
|
|
janusClient!!.disConnect()
|
|
@@ -325,12 +331,32 @@ class MainActivity : BaseActivity<MainActivityPresenter, ActivityMainBinding>(),
|
|
|
Constants.TIME->{
|
|
|
var tcpModel = messageEvent.tcpModel as TcpModel
|
|
|
if(tcpModel.type.equals(TcpType.TIME)&&tcpModel.action.equals(TcpAction.TimeAction.SYNC)){
|
|
|
- (this.getSystemService(Context.ALARM_SERVICE) as AlarmManager).setTime(tcpModel.data.toString().toLong()*1000+200)
|
|
|
+ var time = 0L
|
|
|
+ var timeZone = "Asia/shanghai"
|
|
|
+ if(canPaseJson(tcpModel.data.toString())){
|
|
|
+ var json = JSON.parseObject(tcpModel.data.toString())
|
|
|
+ time=json.getLong("time")*1000+200
|
|
|
+ timeZone=json.getString("time_zone")
|
|
|
+ }else {
|
|
|
+ time = tcpModel.data.toString().toLong()*1000+200
|
|
|
+ }
|
|
|
+ (this.getSystemService(Context.ALARM_SERVICE) as AlarmManager).setTime(time)
|
|
|
+ (this.getSystemService(Context.ALARM_SERVICE) as AlarmManager).setTimeZone(timeZone)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ fun canPaseJson(str: String?): Boolean {
|
|
|
+ var result = false
|
|
|
+ result = try {
|
|
|
+ val obj: Any = JSON.parseObject(str)
|
|
|
+ true
|
|
|
+ } catch (e: Exception) {
|
|
|
+ false
|
|
|
+ }
|
|
|
+ return result
|
|
|
+ }
|
|
|
|
|
|
// override fun userLogout() {
|
|
|
// Log.i("webrtc", "用户退出登录")
|