Procházet zdrojové kódy

<增加倒计时60s>

weizhengliang před 4 roky
rodič
revize
a934b32b2d

+ 36 - 3
nursehome/src/main/java/com/wdkl/ncs/android/component/nursehome/activity/NurseHomeActivity.kt

@@ -9,6 +9,7 @@ import android.content.IntentFilter
 import android.graphics.Color
 import android.net.Uri
 import android.os.Build
+import android.os.CountDownTimer
 import android.provider.Settings
 import android.support.v4.app.Fragment
 import android.support.v4.app.FragmentManager
@@ -83,6 +84,11 @@ class NurseHomeActivity  : BaseActivity<NurseHomeActivityPresenter, ActivityNurs
 
     var receiver :TimeReceiver? = null
 
+    lateinit var countDownTimer: CountDownTimer
+
+    //呼叫对方设备id
+    var callTargetId: Int? = -1
+
     //来电设备id
     //private var fromId: Int = -1
     //Interaction ID
@@ -151,6 +157,8 @@ class NurseHomeActivity  : BaseActivity<NurseHomeActivityPresenter, ActivityNurs
 
         //设置设置配置
         setSettingConfiguration()
+
+        initCountDownTimer()
     }
 
     /**
@@ -248,7 +256,7 @@ class NurseHomeActivity  : BaseActivity<NurseHomeActivityPresenter, ActivityNurs
      *页面销毁回调
      */
     override fun destory() {
-
+        countDownTimer.cancel()
     }
     /**
      *处理错误信息
@@ -532,6 +540,21 @@ fun call(tyte:Int){
 
     }
 
+    fun initCountDownTimer() {
+        countDownTimer = object: CountDownTimer(60*1000L, 1000) {
+            override fun onTick(millisUntilFinished: Long) {
+                //
+            }
+
+            override fun onFinish() {
+                //呼叫超时,退出呼叫界面
+                showMessage("无人应答...")
+                VoiceUtil.cancelAudioCall(Integer.parseInt(Constants.ids), callTargetId)
+                CallDialogHelper.dismissCallDialog()
+            }
+        }
+    }
+
 
     @Subscribe(threadMode = ThreadMode.MAIN)
     fun onMoonEvent(messageEvent: MessageEvent) {
@@ -546,7 +569,7 @@ fun call(tyte:Int){
                         Constants.interactionId = interactionVO.id
 
                         CallDialogHelper.dismissCallDialog()
-                        CallDialogHelper.showCallDialog(this@NurseHomeActivity, 1, View.OnClickListener {
+                        CallDialogHelper.showCallDialog(this@NurseHomeActivity, 1, interactionVO.fromFrameFullName, View.OnClickListener {
                             //呼出取消
                         }, View.OnClickListener {
                             //来电接听
@@ -564,6 +587,7 @@ fun call(tyte:Int){
                         Constants.interactionId = interactionVO.id
                         Constants.fromId = tcpModel.fromId
                         CallDialogHelper.dismissCallDialog()
+                        countDownTimer.cancel()
 
                         DeviceChannel.calling = true
                         if (Constants.call_type == 1) {
@@ -574,27 +598,36 @@ fun call(tyte:Int){
                     } else if (tcpModel.getAction() == TcpAction.VoiceAction.REJECT) {//对方拒绝
                         DeviceChannel.calling = false
                         CallDialogHelper.dismissCallDialog()
+                        countDownTimer.cancel()
                     } else if (tcpModel.getAction() == TcpAction.VoiceAction.CANCEL) {//对方取消
                         DeviceChannel.calling = false
                         CallDialogHelper.dismissCallDialog()
+                        countDownTimer.cancel()
                     } else if (tcpModel.getAction() == TcpAction.VoiceAction.CALLING) {//对方通话中
                         showMessage("对方忙线中")
                         DeviceChannel.calling = false
                         CallDialogHelper.dismissCallDialog()
+                        countDownTimer.cancel()
                     } else if (tcpModel.getAction() == TcpAction.VoiceAction.FAILED) {//对方不在线 呼叫失败
                         showMessage("对方离线或不存在,呼叫失败")
                         DeviceChannel.calling = false
                         CallDialogHelper.dismissCallDialog()
+                        countDownTimer.cancel()
                     } else if (tcpModel.getAction() == TcpAction.VoiceAction.HANDOFF) {//对方挂断
                         DeviceChannel.calling = false
                         CallDialogHelper.dismissCallDialog()
+                        countDownTimer.cancel()
                     } else if (tcpModel.getAction() == TcpAction.VoiceAction.SUCCESS) {//服务器返回的呼叫成功tcp
+                        callTargetId = interactionVO.toDeviceId
+                        countDownTimer.start()
+
                         CallDialogHelper.dismissCallDialog()
-                        CallDialogHelper.showCallDialog(this@NurseHomeActivity, 0, View.OnClickListener {
+                        CallDialogHelper.showCallDialog(this@NurseHomeActivity, 0, "", View.OnClickListener {
                             //呼出取消
                             DeviceChannel.calling = false
                             VoiceUtil.cancelAudioCall(Integer.parseInt(Constants.ids), interactionVO.toDeviceId)
                             CallDialogHelper.dismissCallDialog()
+                            countDownTimer.cancel()
                         }, View.OnClickListener {
                             //来电接听
                         }, View.OnClickListener {

+ 1 - 1
nursehome/src/main/java/com/wdkl/ncs/android/component/nursehome/activity/RegisterActivity.kt

@@ -147,7 +147,7 @@ class RegisterActivity : BaseActivity<DevicePresenter, ActivityRegisterBinding>(
         //这里的是视频通话有关的
 
 //        initSDK("000100")
-        initSDK(data.sipId)
+        //initSDK(data.sipId)
         AppTool.Time.delay(800) {
             push("/nursehome/main")
             finish()

+ 3 - 3
nursehome/src/main/java/com/wdkl/ncs/android/component/nursehome/settingconfig/SettingConfig.java

@@ -36,10 +36,10 @@ public class SettingConfig {
 
     //主机白天系统音量
     private static final String KEY_SP_HOST_DAYTIME_VOLUME = "KEY_SP_HOST_DAYTIME_VOLUME";
-    private static final int host_daytime_volume = 70;
+    private static final int host_daytime_volume = 100;
     //主机晚上系统音量
     private static final String KEY_SP_HOST_NIGHT_VOLUME = "KEY_SP_HOST_NIGHT_VOLUME";
-    private static final int host_night_volume = 50;
+    private static final int host_night_volume = 80;
 
     //主机免提录入音量
     private static final String KEY_SP_HANDS_FREE_INPUT_VOLUME_OF_HOST_MACHINE = "KEY_SP_HANDS_FREE_INPUT_VOLUME_OF_HOST_MACHINE";
@@ -50,7 +50,7 @@ public class SettingConfig {
 
     //主机免提播放音量
     private static final String KEY_SP_HOST_HANDS_FREE_PLAY_VOLUME = "KEY_SP_HOST_HANDS_FREE_PLAY_VOLUME";
-    private static final int host_hands_free_play_volume = 70;
+    private static final int host_hands_free_play_volume = 90;
     //主机手柄播放音量
     private static final String KEY_SP_HOST_GAMEPAD_PLAY_VOLUME = "KEY_SP_HOST_GAMEPAD_PLAY_VOLUME";
     private static final int host_gamepad_play_volume = 40;

+ 4 - 1
nursehome/src/main/java/com/wdkl/ncs/android/component/nursehome/util/CallDialogHelper.java

@@ -11,6 +11,7 @@ import android.view.WindowManager;
 import android.widget.ImageView;
 import android.widget.LinearLayout;
 import android.widget.RelativeLayout;
+import android.widget.TextView;
 
 import com.wdkl.core.voip.AsyncPlayer;
 import com.wdkl.ncs.android.component.nursehome.R;
@@ -22,7 +23,7 @@ public class CallDialogHelper {
 
     private static AsyncPlayer ringPlayer;
 
-    public static void showCallDialog(Activity activity, int callType, View.OnClickListener hangupCall, View.OnClickListener acceptCall, View.OnClickListener rejectCall) {
+    public static void showCallDialog(Activity activity, int callType, String name, View.OnClickListener hangupCall, View.OnClickListener acceptCall, View.OnClickListener rejectCall) {
         if (ringPlayer == null) {
             ringPlayer = new AsyncPlayer(null);
         }
@@ -37,6 +38,7 @@ public class CallDialogHelper {
         RelativeLayout inCall = contentView.findViewById(R.id.rl_call_incoming);
         ImageView accept = contentView.findViewById(R.id.iv_accept_call);
         ImageView reject = contentView.findViewById(R.id.iv_reject_call);
+        TextView textName = contentView.findViewById(R.id.tv_incoming_call_text);
 
         if (callType == 0) {
             //去电
@@ -47,6 +49,7 @@ public class CallDialogHelper {
             //来电
             outCall.setVisibility(View.GONE);
             inCall.setVisibility(View.VISIBLE);
+            textName.setText("有新的通话请求: " + name);
             ringPlayer.play(activity, R.raw.incoming_call, true, AudioManager.STREAM_MUSIC);
         }
 

+ 26 - 5
nursehome/src/main/res/layout/call_dialog_lay.xml

@@ -8,12 +8,21 @@
         android:id="@+id/ll_call_outgoing"
         android:layout_width="match_parent"
         android:layout_height="match_parent"
-        android:gravity="center">
+        android:gravity="center"
+        android:orientation="vertical">
+
+        <TextView
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:gravity="center"
+            android:text="正在呼叫,等待接听中..."
+            android:textSize="28sp"/>
 
         <ImageView
             android:id="@+id/iv_hangup_call"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
+            android:layout_marginTop="60dp"
             android:src="@drawable/selector_call_hangup" />
     </LinearLayout>
 
@@ -26,21 +35,33 @@
         android:gravity="center"
         android:visibility="gone">
 
+        <TextView
+            android:id="@+id/tv_incoming_call_text"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:gravity="center"
+            android:text="有新的来电..."
+            android:textSize="28sp"/>
+
         <ImageView
             android:id="@+id/iv_accept_call"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
-            android:src="@drawable/selector_call_answer"
+            android:layout_below="@id/tv_incoming_call_text"
             android:layout_alignParentLeft="true"
-            android:layout_marginLeft="120dp"/>
+            android:layout_marginLeft="160dp"
+            android:layout_marginTop="60dp"
+            android:src="@drawable/selector_call_answer"/>
 
         <ImageView
             android:id="@+id/iv_reject_call"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
-            android:src="@drawable/selector_call_end"
+            android:layout_below="@id/tv_incoming_call_text"
             android:layout_alignParentRight="true"
-            android:layout_marginRight="120dp"/>
+            android:layout_marginRight="160dp"
+            android:layout_marginTop="60dp"
+            android:src="@drawable/selector_call_end"/>
     </RelativeLayout>
 
 </RelativeLayout>