|
@@ -148,6 +148,39 @@ class CallingbedActivity :BaseActivity<CallingbedActivityPresenter, CallingbedMa
|
|
|
private val uninstallApk = false
|
|
|
private var copyDone = false
|
|
|
|
|
|
+ private var sleepCountdown = false
|
|
|
+ private val updateHandler: Handler = object : Handler(Looper.getMainLooper()) {
|
|
|
+ override fun handleMessage(msg: Message) {
|
|
|
+ //熄屏时间到,当前是夜晚且亮度为0则切换到黑屏界面
|
|
|
+ if (black_view != null && Constant.NIGHT_BRIGHTNESS == 0
|
|
|
+ && Constant.day_state == 1 && !Constant.IS_RECORDING && skyCallFragment == null) {
|
|
|
+ black_view.visibility = View.VISIBLE
|
|
|
+ Log.e(TAG, "进入夜晚黑屏模式111...")
|
|
|
+ }
|
|
|
+ sleepCountdown = false
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ override fun startCountDownSleep() {
|
|
|
+ updateHandler.sendEmptyMessageDelayed(1, Constant.SLEEP_MINUTE * 60 * 1000L)
|
|
|
+ sleepCountdown = true
|
|
|
+ }
|
|
|
+
|
|
|
+ override fun cancelSleep() {
|
|
|
+ updateHandler.removeMessages(1)
|
|
|
+ sleepCountdown = false
|
|
|
+ }
|
|
|
+
|
|
|
+ override fun resetSleepTime() {
|
|
|
+ updateHandler.removeMessages(1)
|
|
|
+ updateHandler.sendEmptyMessageDelayed(1, Constant.SLEEP_MINUTE * 60 * 1000L)
|
|
|
+ sleepCountdown = true
|
|
|
+ }
|
|
|
+
|
|
|
+ fun turnScreenOff() {
|
|
|
+ black_view.visibility = View.VISIBLE
|
|
|
+ }
|
|
|
+
|
|
|
companion object {
|
|
|
private const val TIME_WHAT = 1000
|
|
|
}
|
|
@@ -448,6 +481,12 @@ class CallingbedActivity :BaseActivity<CallingbedActivityPresenter, CallingbedMa
|
|
|
override fun bindEvent() {
|
|
|
}
|
|
|
|
|
|
+ override fun onResume() {
|
|
|
+ super.onResume()
|
|
|
+ //重置黑屏时间
|
|
|
+ resetSleepTime()
|
|
|
+ }
|
|
|
+
|
|
|
override fun destory() {
|
|
|
SerialPortUtil.getInstance().closeHeart()
|
|
|
SerialPortUtil.getInstance().closeSerialPort()
|
|
@@ -460,6 +499,7 @@ class CallingbedActivity :BaseActivity<CallingbedActivityPresenter, CallingbedMa
|
|
|
SoundPoolManager.getInstance().release()
|
|
|
isTimeWorking = false
|
|
|
stopBroadcast(false)
|
|
|
+ cancelSleep()
|
|
|
}
|
|
|
|
|
|
fun initDevice() {
|
|
@@ -705,6 +745,12 @@ class CallingbedActivity :BaseActivity<CallingbedActivityPresenter, CallingbedMa
|
|
|
SettingConfig.setAutoAnswer(activity, false)
|
|
|
}
|
|
|
|
|
|
+ Constant.SLEEP_MINUTE = partSetting.sleepSecondsBed
|
|
|
+ Constant.NIGHT_BRIGHTNESS = partSetting.nightLight
|
|
|
+ if (sleepCountdown) {
|
|
|
+ resetSleepTime()
|
|
|
+ }
|
|
|
+
|
|
|
VoiceManagerUtil.setCallVoice(activity, partSetting.dayBedVol)
|
|
|
} catch (ex: Exception) {
|
|
|
showMessage(StringUtil.getResString(R.string.setting_params_error) + ex.message)
|
|
@@ -737,6 +783,9 @@ class CallingbedActivity :BaseActivity<CallingbedActivityPresenter, CallingbedMa
|
|
|
}
|
|
|
|
|
|
fun addCallFragment(fragment: Fragment) {
|
|
|
+ cancelSleep()
|
|
|
+ black_view.visibility = View.GONE
|
|
|
+
|
|
|
//先切换到首页
|
|
|
if (!mainFragment.equals(curFragment)) {
|
|
|
switchToMainFragment()
|
|
@@ -746,7 +795,7 @@ class CallingbedActivity :BaseActivity<CallingbedActivityPresenter, CallingbedMa
|
|
|
supportFragmentManager.beginTransaction()
|
|
|
.setCustomAnimations(R.anim.slide_down_in, R.anim.slide_up_out)
|
|
|
.add(R.id.call_frame, fragment)
|
|
|
- .commit()
|
|
|
+ .commitAllowingStateLoss()
|
|
|
}
|
|
|
|
|
|
fun removeCallFragment() {
|
|
@@ -754,7 +803,7 @@ class CallingbedActivity :BaseActivity<CallingbedActivityPresenter, CallingbedMa
|
|
|
supportFragmentManager.beginTransaction()
|
|
|
//.setCustomAnimations(R.anim.slide_down_in, R.anim.slide_down_out)
|
|
|
.remove(skyCallFragment)
|
|
|
- .commit()
|
|
|
+ .commitAllowingStateLoss()
|
|
|
skyCallFragment = null
|
|
|
}
|
|
|
}
|
|
@@ -768,10 +817,13 @@ class CallingbedActivity :BaseActivity<CallingbedActivityPresenter, CallingbedMa
|
|
|
|
|
|
//切换fragment
|
|
|
private fun switchToFragment(layId: Int, fragment: Fragment, tag: String) {
|
|
|
+ //重置黑屏时间
|
|
|
+ resetSleepTime()
|
|
|
+
|
|
|
supportFragmentManager.beginTransaction()
|
|
|
.setCustomAnimations(R.anim.push_left_in, R.anim.push_left_out)
|
|
|
.replace(layId, fragment, tag)
|
|
|
- .commit()
|
|
|
+ .commitAllowingStateLoss()
|
|
|
curFragment = tag
|
|
|
}
|
|
|
|
|
@@ -871,6 +923,19 @@ class CallingbedActivity :BaseActivity<CallingbedActivityPresenter, CallingbedMa
|
|
|
}
|
|
|
Constant.day_state = 1
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ if (Constant.day_state == 1 && Constant.NIGHT_BRIGHTNESS == 0) {
|
|
|
+ //夜晚
|
|
|
+ if (!Constant.IS_RECORDING && !sleepCountdown && skyCallFragment == null && black_view.visibility == View.GONE) {
|
|
|
+ black_view.visibility = View.VISIBLE
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ //白天
|
|
|
+ if (black_view.visibility == View.VISIBLE) {
|
|
|
+ black_view.visibility = View.GONE
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
override fun loadAppVersion(appInfo: AppVersionDO) {
|
|
@@ -879,6 +944,9 @@ class CallingbedActivity :BaseActivity<CallingbedActivityPresenter, CallingbedMa
|
|
|
showMessage("current version: " + BuildConfig.VERSION_NAME + "_" + BuildConfig.VERSION_CODE + ", new version: " + newAppVersion + "_" + appInfo.versionNo)
|
|
|
|
|
|
if (BuildConfig.VERSION_CODE < appInfo.versionNo) {
|
|
|
+ cancelSleep()
|
|
|
+ black_view.visibility = View.GONE
|
|
|
+
|
|
|
if (!updating) {
|
|
|
//showMessage("即将升级...")
|
|
|
Constant.APP_PATH = appInfo.appPath
|
|
@@ -913,6 +981,30 @@ class CallingbedActivity :BaseActivity<CallingbedActivityPresenter, CallingbedMa
|
|
|
Log.d("serialPortBedOnclick", "buffer[0]:" + buffer[0] + ", buffer[1]:" + buffer[1] + ", buffer[2]:" + buffer[2]
|
|
|
+ ", buffer[3]:" + buffer[3] + ", buffer[4]:" + buffer[4] + ", buffer[5]:" + buffer[5] + ", buffer[6]:" + buffer[6]
|
|
|
+ ", buffer[7]:" + buffer[7] + ", buffer[8]:" + buffer[8])
|
|
|
+
|
|
|
+ if (black_view.visibility == View.VISIBLE) {
|
|
|
+ if (buffer[5].toInt() == 1 || buffer[5].toInt() == 2
|
|
|
+ || buffer[6].toInt() == 1 || buffer[6].toInt() == 2) {
|
|
|
+ //手柄按键,先亮屏然后直接呼叫
|
|
|
+ runOnUiThread {
|
|
|
+ cancelSleep()
|
|
|
+ black_view.visibility = View.GONE
|
|
|
+ }
|
|
|
+ } else if (buffer[0].toInt() == 1 || buffer[0].toInt() == 2
|
|
|
+ || buffer[1].toInt() == 1 || buffer[1].toInt() == 2
|
|
|
+ || buffer[2].toInt() == 1 || buffer[2].toInt() == 2
|
|
|
+ || buffer[3].toInt() == 1 || buffer[3].toInt() == 2
|
|
|
+ || buffer[4].toInt() == 1 || buffer[4].toInt() == 2) {
|
|
|
+ //其他按键则先亮屏
|
|
|
+ runOnUiThread {
|
|
|
+ cancelSleep()
|
|
|
+ black_view.visibility = View.GONE
|
|
|
+ }
|
|
|
+
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
//测试模式
|
|
|
if (testFragment == curFragment) {
|
|
|
if (buffer[0].toInt() == 1 || buffer[0].toInt() == 2) {
|
|
@@ -1217,6 +1309,11 @@ class CallingbedActivity :BaseActivity<CallingbedActivityPresenter, CallingbedMa
|
|
|
|
|
|
//开始呼叫
|
|
|
fun startCall(type: Int) {
|
|
|
+ if (Constant.DEVICE_STATUS == 0) {
|
|
|
+ showMessage(R.string.device_disable)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
if (Constant.CUSTOM_ID != -1) {
|
|
|
if (playing) {
|
|
|
stopBroadcast(false)
|
|
@@ -1307,8 +1404,12 @@ class CallingbedActivity :BaseActivity<CallingbedActivityPresenter, CallingbedMa
|
|
|
Log.d("TCP", "received tcp action: " + tcpModel.action + ", type: " + tcpModel.type)
|
|
|
if (tcpModel.getType() == TcpType.VOICE) {
|
|
|
if (tcpModel.data != null) {
|
|
|
- val interactionVO = Gson().fromJson(tcpModel.data.toString(), InteractionVO::class.java)
|
|
|
if (tcpModel.action == TcpAction.VoiceAction.CALL) {
|
|
|
+ if (black_view.visibility == View.VISIBLE) {
|
|
|
+ black_view.visibility = View.GONE
|
|
|
+ }
|
|
|
+
|
|
|
+ val interactionVO = Gson().fromJson(tcpModel.data.toString(), InteractionVO::class.java)
|
|
|
Constant.fromId = tcpModel.fromId
|
|
|
Constant.interactionId = interactionVO.id
|
|
|
Constant.TARGET_SIP = interactionVO.fromSipId
|