瀏覽代碼

修改设置参数更新机制,优化通话

weizhengliang 3 年之前
父節點
當前提交
5987335831

+ 27 - 19
callingdoor/src/main/java/com/wdkl/app/ncs/callingdoor/activity/CallingdoorActivity.kt

@@ -375,7 +375,7 @@ class CallingdoorActivity :BaseActivity<CallingdoorActivityPresenter, Callingdoo
         SettingConfig.setSipOverTime(this, partSetting.sipOvertime)
         SettingConfig.setSleepTime(this, partSetting.sleepSecondsDoor)
 
-        updateSettings()
+        updateSettings(true)
     }
 
     override fun setTcpServerHost(tcpSeverDTO: TcpSeverDTO) {
@@ -566,6 +566,8 @@ class CallingdoorActivity :BaseActivity<CallingdoorActivityPresenter, Callingdoo
                         if (tcpModel.getAction() == TcpAction.DeviceAction.APP_UPDATE) {
                             Constant.silentUpdate = true
                             checkAppVersion()
+                        } else if (tcpModel.action == TcpAction.DeviceAction.SYSTEM_SETTING) {
+                            presenter.loadPartSettings(Constant.PART_ID)
                         }
                     } else if (tcpModel.action == TcpAction.DataAction.REFRESH) {
                         //重新加载数据
@@ -659,7 +661,7 @@ class CallingdoorActivity :BaseActivity<CallingdoorActivityPresenter, Callingdoo
         }
     }
 
-    private fun updateSettings() {
+    private fun updateSettings(forceSet: Boolean) {
         val  currentTimestamp = System.currentTimeMillis()
 
         //白天起始时间戳
@@ -668,23 +670,29 @@ class CallingdoorActivity :BaseActivity<CallingdoorActivityPresenter, Callingdoo
         //白天结束时间戳
         var endOfDayTimeStamp = TimeHandle.dateToStamp(date+" "+SettingConfig.getEndOfDay(this)+":00", "yyyy-MM-dd HH:mm:ss")
 
-        //白天
-        if (dayStartTimeStamp < currentTimestamp && currentTimestamp < endOfDayTimeStamp) {
-            //设置白天亮度
-            ScreenManagerUtil().setScreenBrightness(this, Math.ceil(2.54 * SettingConfig.getDaytimeBrightness(this)).toInt())
-            //设置白天系统音量和响铃音
-            VoiceManagerUtil.setSystemVoice(this, SettingConfig.getDoorDaytimeSystemVolume(this))
-            VoiceManagerUtil.setMusicVoice(this, SettingConfig.getDoorDaytimeSystemVolume(this))
-            view_title_layout_iv_day_night.setImageResource(R.mipmap.ic_daylight)
-            Constant.inday = true
+        val curInday = dayStartTimeStamp < currentTimestamp && currentTimestamp < endOfDayTimeStamp
+        if (curInday) {
+            //当前是白天并且原来不是白天
+            if (Constant.day_state != 0 || forceSet) {
+                //设置白天亮度
+                ScreenManagerUtil().setScreenBrightness(this, Math.ceil(2.54 * SettingConfig.getDaytimeBrightness(this)).toInt())
+                //设置白天系统音量和响铃音
+                VoiceManagerUtil.setSystemVoice(this, SettingConfig.getDoorDaytimeSystemVolume(this))
+                VoiceManagerUtil.setMusicVoice(this, SettingConfig.getDoorDaytimeSystemVolume(this))
+                view_title_layout_iv_day_night.setImageResource(R.mipmap.ic_daylight)
+            }
+            Constant.day_state = 0
         } else {
-            //设置晚上亮度
-            ScreenManagerUtil().setScreenBrightness(this, Math.ceil(2.54 * SettingConfig.getNightBrightness(this)).toInt())
-            //设置晚上系统音量和响铃音
-            VoiceManagerUtil.setSystemVoice(this, SettingConfig.getDoorNightSystemVolume(this))
-            VoiceManagerUtil.setMusicVoice(this, SettingConfig.getDoorNightSystemVolume(this))
-            view_title_layout_iv_day_night.setImageResource(R.mipmap.ic_night)
-            Constant.inday = false
+            //当前是夜晚并且原来不是夜晚
+            if (Constant.day_state != 1 || forceSet) {
+                //设置晚上亮度
+                ScreenManagerUtil().setScreenBrightness(this, Math.ceil(2.54 * SettingConfig.getNightBrightness(this)).toInt())
+                //设置晚上系统音量和响铃音
+                VoiceManagerUtil.setSystemVoice(this, SettingConfig.getDoorNightSystemVolume(this))
+                VoiceManagerUtil.setMusicVoice(this, SettingConfig.getDoorNightSystemVolume(this))
+                view_title_layout_iv_day_night.setImageResource(R.mipmap.ic_night)
+            }
+            Constant.day_state = 1
         }
     }
 
@@ -694,7 +702,7 @@ class CallingdoorActivity :BaseActivity<CallingdoorActivityPresenter, Callingdoo
                     || intent.action == Intent.ACTION_TIME_CHANGED
                     || intent.action == Intent.ACTION_TIMEZONE_CHANGED) {
                 updateNetState()
-                updateSettings()
+                updateSettings(false)
 
                 if (SocketManager.getInstance().userState == 1) {
                     view_title_layout_tv_point.setBackgroundResource(R.color.green)

+ 10 - 8
callingdoor/src/main/java/com/wdkl/app/ncs/callingdoor/fragment/SkyCallFragment.kt

@@ -3,6 +3,7 @@ package com.wdkl.app.ncs.callingbed2.fragment
 import android.os.Handler
 import android.os.Looper
 import android.os.SystemClock
+import android.text.TextUtils
 import android.util.Log
 import android.view.View
 import android.view.ViewGroup
@@ -194,12 +195,12 @@ class SkyCallFragment: BaseCallFragment(), CallSession.CallSessionCallback {
 
             Handler().postDelayed({
                 if (session.state == EnumType.CallState.Connected){
-                    showCalling(audioCall)
+                    //showCalling(audioCall)
                 } else {
                     gEngineKit?.endCall()
                     callEnd()
                 }
-            }, 1500)
+            }, 2000)
         }
     }
 
@@ -225,7 +226,7 @@ class SkyCallFragment: BaseCallFragment(), CallSession.CallSessionCallback {
 
             Handler().postDelayed({
                 if (session.state == EnumType.CallState.Connected){
-                    showCalling(audioCall)
+                    //showCalling(audioCall)
                 } else {
                     gEngineKit?.endCall()
                     callEnd()
@@ -273,7 +274,7 @@ class SkyCallFragment: BaseCallFragment(), CallSession.CallSessionCallback {
                 //3s还未连接上则判定为通话失败
                 Handler().postDelayed({
                     if (session.state == EnumType.CallState.Connected){
-                        showCalling(audioCall)
+                        //showCalling(audioCall)
                     } else {
                         showMessage("当前网络状态不佳,通话结束")
                         gEngineKit?.endCall()
@@ -310,12 +311,12 @@ class SkyCallFragment: BaseCallFragment(), CallSession.CallSessionCallback {
      *******************************************************/
     override fun didChangeState(state: EnumType.CallState?) {
         Log.e("dds", "didChangeState: " + state)
-        /*handler.post {
+        handler.post {
             if (state == EnumType.CallState.Connected) {
                 //更新界面显示
                 showCalling(audioCall)
             }
-        }*/
+        }
     }
 
     override fun didDisconnected(userId: String?) {
@@ -452,7 +453,7 @@ class SkyCallFragment: BaseCallFragment(), CallSession.CallSessionCallback {
                         audioCall = true
                         Handler().postDelayed({
                             joinAudioCall()
-                        }, 500)
+                        }, 300)
                     }
                 }
             }
@@ -468,8 +469,9 @@ class SkyCallFragment: BaseCallFragment(), CallSession.CallSessionCallback {
                             Constant.interactionId = curInteractionVO.id
                             fromId = curTcpModel.fromId
                             acceptCall()
-                            if (!startCall(curInteractionVO.toSipId, Constant.CALL_TYPE == Constant.VOICE_CALL)) {
+                            if (TextUtils.isEmpty(curInteractionVO.toSipId) || !startCall(curInteractionVO.toSipId, Constant.CALL_TYPE == Constant.VOICE_CALL)) {
                                 //通话失败,重置并返回主界面
+                                showMessage("通话失败,targetId为空或通话服务异常!")
                                 Constant.CALL_STATE = Constant.CALL_STANDBY
                                 VoiceUtil.handoffAudioCall(Constant.DEVICE_ID, fromId, Constant.interactionId)
                                 if (sky_voice_call_timer != null) {

+ 2 - 1
middleware/src/main/code/com/wdkl/ncs/android/middleware/common/Constant.java

@@ -22,7 +22,8 @@ public class Constant {
     //语音留言上传地址
     public static final String UPLOAD_VOICE_MSG_URL = "/ncs/upload/File";
 
-    public static boolean inday = true;
+    //0--白天,1--夜晚
+    public static int day_state = -1;
 
     //待机
     public final static int CALL_STANDBY = 0;