Browse Source

提交修改代码

wangjk 4 years ago
parent
commit
0ba01ed961

+ 1 - 1
.gitignore

@@ -9,7 +9,7 @@
 .externalNativeBuild
 ### Android template
 # Built application files
-*.apk
+app/*.apk
 *.ap_
 
 # Files for the ART/Dalvik VM

+ 116 - 0
.idea/codeStyles/Project.xml

@@ -0,0 +1,116 @@
+<component name="ProjectCodeStyleConfiguration">
+  <code_scheme name="Project" version="173">
+    <codeStyleSettings language="XML">
+      <indentOptions>
+        <option name="CONTINUATION_INDENT_SIZE" value="4" />
+      </indentOptions>
+      <arrangement>
+        <rules>
+          <section>
+            <rule>
+              <match>
+                <AND>
+                  <NAME>xmlns:android</NAME>
+                  <XML_ATTRIBUTE />
+                  <XML_NAMESPACE>^$</XML_NAMESPACE>
+                </AND>
+              </match>
+            </rule>
+          </section>
+          <section>
+            <rule>
+              <match>
+                <AND>
+                  <NAME>xmlns:.*</NAME>
+                  <XML_ATTRIBUTE />
+                  <XML_NAMESPACE>^$</XML_NAMESPACE>
+                </AND>
+              </match>
+              <order>BY_NAME</order>
+            </rule>
+          </section>
+          <section>
+            <rule>
+              <match>
+                <AND>
+                  <NAME>.*:id</NAME>
+                  <XML_ATTRIBUTE />
+                  <XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
+                </AND>
+              </match>
+            </rule>
+          </section>
+          <section>
+            <rule>
+              <match>
+                <AND>
+                  <NAME>.*:name</NAME>
+                  <XML_ATTRIBUTE />
+                  <XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
+                </AND>
+              </match>
+            </rule>
+          </section>
+          <section>
+            <rule>
+              <match>
+                <AND>
+                  <NAME>name</NAME>
+                  <XML_ATTRIBUTE />
+                  <XML_NAMESPACE>^$</XML_NAMESPACE>
+                </AND>
+              </match>
+            </rule>
+          </section>
+          <section>
+            <rule>
+              <match>
+                <AND>
+                  <NAME>style</NAME>
+                  <XML_ATTRIBUTE />
+                  <XML_NAMESPACE>^$</XML_NAMESPACE>
+                </AND>
+              </match>
+            </rule>
+          </section>
+          <section>
+            <rule>
+              <match>
+                <AND>
+                  <NAME>.*</NAME>
+                  <XML_ATTRIBUTE />
+                  <XML_NAMESPACE>^$</XML_NAMESPACE>
+                </AND>
+              </match>
+              <order>BY_NAME</order>
+            </rule>
+          </section>
+          <section>
+            <rule>
+              <match>
+                <AND>
+                  <NAME>.*</NAME>
+                  <XML_ATTRIBUTE />
+                  <XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
+                </AND>
+              </match>
+              <order>ANDROID_ATTRIBUTE_ORDER</order>
+            </rule>
+          </section>
+          <section>
+            <rule>
+              <match>
+                <AND>
+                  <NAME>.*</NAME>
+                  <XML_ATTRIBUTE />
+                  <XML_NAMESPACE>.*</XML_NAMESPACE>
+                </AND>
+              </match>
+              <order>BY_NAME</order>
+            </rule>
+          </section>
+        </rules>
+      </arrangement>
+    </codeStyleSettings>
+  </code_scheme>
+</component>

+ 4 - 0
app/build.gradle

@@ -24,7 +24,11 @@ android {
         minSdkVersion 15
         targetSdkVersion 26
         versionCode 1
+<<<<<<< HEAD
         versionName "1.47"
+=======
+        versionName "1.43"
+>>>>>>> 101e0c9955aaa42a57f45b21f4f890bb1540b288
         testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
         multiDexEnabled true
 

+ 3 - 0
app/src/main/java/com/wdkl/callingmainnurse/MyApplication.java

@@ -12,6 +12,7 @@ import com.wdkl.callingmainnurse.entity.AllDoctorHostEntity;
 import com.wdkl.callingmainnurse.entity.UdpEntity;
 import com.wdkl.callingmainnurse.service.APPService;
 import com.wdkl.callingmainnurse.util.ScreenExtinguishUtil;
+import com.wdkl.callingmainnurse.util.SpeechUtil;
 import com.wdkl.callingmainnurse.util.UdpHelper;
 import com.wdkl.callingmainnurse.util.anrfcutil.AnrFcExceptionUtil;
 import com.zhy.http.okhttp.OkHttpUtils;
@@ -117,6 +118,7 @@ public class MyApplication extends Application {
         Intent bindIntent = new Intent(this, APPService.class);
         bindService(bindIntent, connection, BIND_AUTO_CREATE);
 
+        SpeechUtil.getInstance().init(getApplicationContext());
 
     }
 
@@ -155,5 +157,6 @@ public class MyApplication extends Application {
     public void onTerminate() { // 程序终止 (Waderson 20180123)
         super.onTerminate();
         //unbindService(connection);
+        SpeechUtil.getInstance().release();
     }
 }

+ 11 - 1
app/src/main/java/com/wdkl/callingmainnurse/ui/activity/InitActivity.java

@@ -114,6 +114,10 @@ public class InitActivity extends BaseActivity implements SerialPortUtil.IForBro
         serialPortUtil.setOnBroadcastClickListener(this);
         serialPortUtil.setOnDataReceiveStringListener(this);
 
+        if (-100 == SharedPreferencesUtil.getIntSp(MyApplication.getAppContext(), Constants.MSG_SP, SharedPreferencesUtil.CallingMode)) {
+            SharedPreferencesUtil.putIntSp(MyApplication.getAppContext(), Constants.MSG_SP, SharedPreferencesUtil.CallingMode, 0);
+        }
+
         if (-100 == SharedPreferencesUtil.getIntSp(MyApplication.getAppContext(), Constants.MSG_SP, SharedPreferencesUtil.SbCallingVoice)) {
             SharedPreferencesUtil.putIntSp(MyApplication.getAppContext(), Constants.MSG_SP, SharedPreferencesUtil.SbCallingVoice, 70);
         }
@@ -465,9 +469,15 @@ public class InitActivity extends BaseActivity implements SerialPortUtil.IForBro
             AutoRebootUtil.rebootContinueCounts(InitActivity.this, 0);//重启标识复位
 
             //有线mac地址,设备出场信息,无线mac地址
-            String str = "MGR_REG_A" + Constants.DELIMITER + Constants.MAC_ADDRESS + Constants.DELIMITER + "1" + Constants.DELIMITER + android.os.Build.DISPLAY +"_"+Constants.MCU_VERSION_NUMBER +
+            final String str = "MGR_REG_A" + Constants.DELIMITER + Constants.MAC_ADDRESS + Constants.DELIMITER + "1" + Constants.DELIMITER + android.os.Build.DISPLAY +"_"+Constants.MCU_VERSION_NUMBER +
                     Constants.DELIMITER + Constants.MAC_ADDRESS + Constants.DELIMITER + "FF:FF:FF:FF:FF:FF" + Constants.DELIMITER + SerialPortUtil.KEY_ID;
             UdpSendUtil.sendManualReboot(str);
+            runOnUiThread(new Runnable() {
+                @Override
+                public void run() {
+                    ToastUtil.showToast("收到按键消息,发送注册信息:" + str);
+                }
+            });
         }
     }
 

+ 36 - 0
app/src/main/java/com/wdkl/callingmainnurse/ui/activity/SysCallingVolSetActivity.java

@@ -3,6 +3,8 @@ package com.wdkl.callingmainnurse.ui.activity;
 import android.support.v7.widget.Toolbar;
 import android.util.Log;
 import android.view.View;
+import android.widget.RadioButton;
+import android.widget.RadioGroup;
 import android.widget.TextView;
 
 import com.google.gson.Gson;
@@ -16,6 +18,7 @@ import com.wdkl.callingmainnurse.util.LogUtil;
 import com.wdkl.callingmainnurse.util.SharedPreferencesUtil;
 import com.wdkl.callingmainnurse.util.SipUtil.SipHelperUtil;
 import com.wdkl.callingmainnurse.util.StringUtils;
+import com.wdkl.callingmainnurse.util.UdpSendUtil;
 import com.wdkl.callingmainnurse.util.VoiceManagerUtil;
 import com.zhy.http.okhttp.OkHttpUtils;
 import com.zhy.http.okhttp.callback.StringCallback;
@@ -37,6 +40,14 @@ import static com.wdkl.callingmainnurse.util.VoiceManagerUtil.getCallMax;
 
 public class SysCallingVolSetActivity extends BaseActivity {
 
+    //通话模式选择: 双工模式-0, 单工模式-1
+    @Bind(R.id.group_calling_mode)
+    RadioGroup groupCallingMode;
+    @Bind(R.id.rb_calling_mode_dual)
+    RadioButton rbDualMode;
+    @Bind(R.id.rb_calling_mode_single)
+    RadioButton rbSingleMode;
+
     //显示主机通话声音的TextView
     @Bind(R.id.activity_sb_calling_voice_set)
     TextView tvMainCallingVoice;
@@ -359,6 +370,7 @@ public class SysCallingVolSetActivity extends BaseActivity {
             VoiceManagerUtil.setCallVoice(MyApplication.getAppContext(), 100);
         }
 
+        int mode = SharedPreferencesUtil.getIntSp(SysCallingVolSetActivity.this, Constants.MSG_SP, SharedPreferencesUtil.CallingMode);
         int sb = SharedPreferencesUtil.getIntSp(SysCallingVolSetActivity.this, Constants.MSG_SP, SharedPreferencesUtil.SbCallingVoice);
         int sbing = SharedPreferencesUtil.getIntSp(SysCallingVolSetActivity.this, Constants.MSG_SP, SharedPreferencesUtil.SbingCallingVoice);
         int sip = SharedPreferencesUtil.getIntSp(SysCallingVolSetActivity.this, Constants.MSG_SP, SharedPreferencesUtil.SipCallingVoice);
@@ -366,6 +378,30 @@ public class SysCallingVolSetActivity extends BaseActivity {
         int sip_f = SharedPreferencesUtil.getIntSp(SysCallingVolSetActivity.this, Constants.MSG_SP, SharedPreferencesUtil.SipCallingVoice_f);
         int sip1_f = SharedPreferencesUtil.getIntSp(SysCallingVolSetActivity.this, Constants.MSG_SP, SharedPreferencesUtil.SipCallingVoice1_f);
 
+        if (mode == 1) {
+            rbSingleMode.setChecked(true);
+            UdpSendUtil.callModeChangeTradition("1");
+        } else {
+            rbDualMode.setChecked(true);
+            UdpSendUtil.callModeChangeTradition("0");
+        }
+
+        groupCallingMode.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
+            @Override
+            public void onCheckedChanged(RadioGroup group, int checkedId) {
+                switch (checkedId) {
+                    case R.id.rb_calling_mode_dual:
+                        SharedPreferencesUtil.putIntSp(SysCallingVolSetActivity.this, Constants.MSG_SP, SharedPreferencesUtil.CallingMode, 0);
+                        UdpSendUtil.callModeChangeTradition("0");
+                        break;
+                    case R.id.rb_calling_mode_single:
+                        SharedPreferencesUtil.putIntSp(SysCallingVolSetActivity.this, Constants.MSG_SP, SharedPreferencesUtil.CallingMode, 1);
+                        UdpSendUtil.callModeChangeTradition("1");
+                        break;
+                }
+            }
+        });
+
         if (sb < 0) {
             tvMainCallingVoice.setText("主机免提通话音量: " + 70);
             sbMainCallingVoiceSet.setProgress(70);

+ 130 - 10
app/src/main/java/com/wdkl/callingmainnurse/ui/fragment/CallingBedFragment.java

@@ -49,6 +49,7 @@ import com.wdkl.callingmainnurse.util.LogUtil;
 import com.wdkl.callingmainnurse.util.PalyPhonetics;
 import com.wdkl.callingmainnurse.util.SharedPreferencesUtil;
 import com.wdkl.callingmainnurse.util.SipUtil.SipHelperUtil;
+import com.wdkl.callingmainnurse.util.SpeechUtil;
 import com.wdkl.callingmainnurse.util.StringUtils;
 import com.wdkl.callingmainnurse.util.ToastUtil;
 import com.wdkl.callingmainnurse.util.UIUtils;
@@ -425,6 +426,8 @@ public class CallingBedFragment extends BaseFragment implements SicknessBedAdapt
 
     public static CallingBedFragment mCallingBedFragment;
 
+    private boolean enableTTS = false;
+
     private CallATimeoutThread callATimeoutThread;
     private List<CallListEntity> callListEntityList;
     private boolean threadBool = true;//30秒无人接听线程
@@ -517,7 +520,9 @@ public class CallingBedFragment extends BaseFragment implements SicknessBedAdapt
         serialPortUtil.setOnDataReceiveListener(this, this);
         setVolumePA(false);
         setPowerLed("1");
-        startPalyPhonetics();
+        if (!enableTTS) {
+            startPalyPhonetics();
+        }
     }
 
     @Override
@@ -669,6 +674,9 @@ public class CallingBedFragment extends BaseFragment implements SicknessBedAdapt
             if (null != loopVoice) {
                 loopVoice.setPalyDismiss(true);
             }
+            if (enableTTS) {
+                SpeechUtil.getInstance().stopSpeak();
+            }
         } else {
             for (int i=0; i<PalyPhonetics.speakEntityList.size(); i++) {//将播报列表也删除该元素 两种实体格式不一样,所以要用循环
                 if(PalyPhonetics.speakEntityList.get(i).equals(deleteEntity)) {
@@ -716,6 +724,9 @@ public class CallingBedFragment extends BaseFragment implements SicknessBedAdapt
             if (null != loopVoice) {
                 loopVoice.setPalyDismiss(true);
             }
+            if (enableTTS) {
+                SpeechUtil.getInstance().stopSpeak();
+            }
         } else {
             for (int i=0; i<PalyPhonetics.speakEntityList.size(); i++) {//将播报列表也删除该元素 两种实体格式不一样,所以要用循环
                 if(PalyPhonetics.speakEntityList.get(i).equals(deleteEntity)) {
@@ -1011,6 +1022,9 @@ public class CallingBedFragment extends BaseFragment implements SicknessBedAdapt
                 if (null != loopVoice) {
                     loopVoice.setPalyDismiss(true);
                 }
+                if (enableTTS) {
+                    SpeechUtil.getInstance().stopSpeak();
+                }
                 //String sipAddress = callingEntity.getSipAddress();
                 String sipAddress = callingEntity.getSipAddress();
                 if (StringUtils.notEmpty(sipAddress)) {
@@ -1026,7 +1040,12 @@ public class CallingBedFragment extends BaseFragment implements SicknessBedAdapt
                 }
             } else {
                 if (null != loopingUdpentity && loopingUdpentity.equals(callingEntity)) {
-                    loopVoice.setPalyDismiss(true);
+                    if (null != loopVoice) {
+                        loopVoice.setPalyDismiss(true);
+                    }
+                }
+                if (enableTTS) {
+                    SpeechUtil.getInstance().stopSpeak();
                 }
                 endCall();
                 Constants.DoctorMachineCallStatus = Constants.STANDBY;
@@ -1055,6 +1074,9 @@ public class CallingBedFragment extends BaseFragment implements SicknessBedAdapt
                     if (null != loopVoice) {
                         loopVoice.setPalyDismiss(true);
                     }
+                    if (enableTTS) {
+                        SpeechUtil.getInstance().stopSpeak();
+                    }
                     if (StringUtils.notEmpty(sipAddress)) {
                         LogUtil.d("sipAddress", "Call==sipAddress==" + sipAddress);
                         LogUtil.d("sipAddress", "Call==deviceMAC==" + sickBedInfo.getDeviceMAC());
@@ -1167,6 +1189,9 @@ public class CallingBedFragment extends BaseFragment implements SicknessBedAdapt
         if (vRightCallInfo.getVisibility() == View.VISIBLE && sickBedInfo.equals(sickbedInformationList.get(position))) {
             if (null == sickBedInfo || !StringUtils.listNotEmpty(sickbedInformationList)) return;
             if (filterSipToast()) {
+                if (enableTTS) {
+                    SpeechUtil.getInstance().stopSpeak();
+                }
                 if (Constants.CALL_STATE.equals(Constants.STANDBY)) {
                     String sipAddress = sickBedInfo.getSipID();
                     if (StringUtils.notEmpty(sipAddress)) {
@@ -1254,6 +1279,9 @@ public class CallingBedFragment extends BaseFragment implements SicknessBedAdapt
         if (vRightCallListInfo.getVisibility() == View.VISIBLE && callItemChooseEntity.equals(MyApplication.callEntityList.get(position))) {
             if (null == callItemChooseEntity) return;
             if (filterSipToast() && !MyApplication.callEntityList.get(position).getType().equals(Constants.WSHROOM_CALL) && !MyApplication.callEntityList.get(position).getType().equals(Constants.ROOMHELP_CALL)) {
+                if (enableTTS) {
+                    SpeechUtil.getInstance().stopSpeak();
+                }
                 if (Constants.CALL_STATE.equals(Constants.STANDBY)) {
                     String sipAddress = callItemChooseEntity.getSipAddress();
                     if (StringUtils.notEmpty(sipAddress)) {
@@ -1336,6 +1364,9 @@ public class CallingBedFragment extends BaseFragment implements SicknessBedAdapt
                                         if (null != loopVoice) {
                                             loopVoice.setPalyDismiss(true);
                                         }
+                                        if (enableTTS) {
+                                            SpeechUtil.getInstance().stopSpeak();
+                                        }
                                     } else {
                                         if (PalyPhonetics.speakEntityList.contains(callingEntity)) {//将播报列表也删除该元素
                                             PalyPhonetics.speakEntityList.remove(callingEntity);
@@ -1405,6 +1436,10 @@ public class CallingBedFragment extends BaseFragment implements SicknessBedAdapt
                     //正在呼叫;将播报音量为0
                     if (null != loopVoice) {
                         loopVoice.setVolumes(0f);
+                        loopVoice.setPalyDismiss(true);
+                    }
+                    if (enableTTS) {
+                        SpeechUtil.getInstance().stopSpeak();
                     }
                     //安卓端接通电话,通知点阵屏,但要排除固定列表
                     if (!callBed) {
@@ -1454,8 +1489,15 @@ public class CallingBedFragment extends BaseFragment implements SicknessBedAdapt
                     case "call_4"://增援呼叫护士主机
                     case "call_6": //门口机呼叫护士主机
                         if (isMySelfMachine(nurseHostID)) {//只有属于自己管的机器才能加进列表
-                            if (!PalyPhonetics.speakEntityList.contains(udpEntity) && Constants.CALL_STATE.equals(Constants.STANDBY)) {
-                                addPhonetics(udpEntity); //在此加入列表队列 Waderson  20171101
+                            if (enableTTS) {
+                                //使用TTS播报
+                                if (Constants.CALL_STATE.equals(Constants.STANDBY)) {
+                                    startSpeak(udpEntity);
+                                }
+                            } else {
+                                if (!PalyPhonetics.speakEntityList.contains(udpEntity) && Constants.CALL_STATE.equals(Constants.STANDBY)) {
+                                    addPhonetics(udpEntity); //在此加入列表队列 Waderson  20171101
+                                }
                             }
                             if (!MyApplication.callEntityList.contains(udpEntity)) {
                                 if (isHaveThisWSHtype(udpEntity)) return;
@@ -1472,8 +1514,15 @@ public class CallingBedFragment extends BaseFragment implements SicknessBedAdapt
                         break;
                     case "call_12": //总控制室呼叫护士主机
                         if (isMySelfMachine(nurseHostID)) {
-                            if (!PalyPhonetics.speakEntityList.contains(udpEntity) && Constants.CALL_STATE.equals(Constants.STANDBY)) {
-                                addPhonetics(udpEntity);
+                            if (enableTTS) {
+                                //使用TTS播报
+                                if (Constants.CALL_STATE.equals(Constants.STANDBY)) {
+                                    startSpeak(udpEntity);
+                                }
+                            } else {
+                                if (!PalyPhonetics.speakEntityList.contains(udpEntity) && Constants.CALL_STATE.equals(Constants.STANDBY)) {
+                                    addPhonetics(udpEntity);
+                                }
                             }
                             if (!MyApplication.callEntityList.contains(udpEntity)) {
                                 MyApplication.callEntityList.add(udpEntity);
@@ -1491,8 +1540,15 @@ public class CallingBedFragment extends BaseFragment implements SicknessBedAdapt
                     case "call_14": //医生主机呼叫护士主机
                         Log.e("qqqq","nurseHostID "+nurseHostID);
                         if (isMySelfMachine(nurseHostID)) {
-                            if (!PalyPhonetics.speakEntityList.contains(udpEntity) && Constants.CALL_STATE.equals(Constants.STANDBY)) {
-                                addPhonetics(udpEntity);
+                            if (enableTTS) {
+                                //使用TTS播报
+                                if (Constants.CALL_STATE.equals(Constants.STANDBY)) {
+                                    startSpeak(udpEntity);
+                                }
+                            } else {
+                                if (!PalyPhonetics.speakEntityList.contains(udpEntity) && Constants.CALL_STATE.equals(Constants.STANDBY)) {
+                                    addPhonetics(udpEntity);
+                                }
                             }
                             if (!MyApplication.callEntityList.contains(udpEntity)) {
                                 MyApplication.callEntityList.add(udpEntity);
@@ -1664,6 +1720,12 @@ public class CallingBedFragment extends BaseFragment implements SicknessBedAdapt
         if (null != deleteUdpEntity) {
             String roomNumber = deleteUdpEntity.getRoomNumber();
             if (StringUtils.notEmpty(roomNumber)) {
+                //if (null != loopVoice) {
+                //    loopVoice.setPalyDismiss(true);
+                //}
+                if (enableTTS) {
+                    SpeechUtil.getInstance().stopSpeak();
+                }
                 for (int i = 0; i < PalyPhonetics.speakEntityList.size(); i++) {
                     if (roomNumber.equals(PalyPhonetics.speakEntityList.get(i).getRoomNumber())) {
                         if (null != loopingUdpentity && loopingUdpentity.equals(PalyPhonetics.speakEntityList.get(i))) {
@@ -1732,6 +1794,48 @@ public class CallingBedFragment extends BaseFragment implements SicknessBedAdapt
 //                VoiceManagerUtil.setCallVoice(getActivity(), StringUtils.parseInt(systemInfoEntity.getNightSipVol()) );
             }
         }
+        SpeechUtil.getInstance().setSpeechLoopCount(speakLooping);
+    }
+
+    //语音播报
+    private void startSpeak(UdpEntity entity) {
+        loopingUdpentity = entity;
+        showUrgentWindow(entity);
+        String type = entity.getType();
+        String rnb = entity.getRoomNumber();
+        String bnb = entity.getBedNumber();
+        String text = "";
+        switch (type) {
+            case DOOR_CALL: //门口机
+                text = rnb + "房门口机呼叫";
+                SpeechUtil.getInstance().newSpeech(text);
+                break;
+            case Constants.MAIN_CALL://主机
+                text = rnb + "号主机呼叫";
+                SpeechUtil.getInstance().newSpeech(text);
+                break;
+            case Constants.SON_CALL://床位
+            case Constants.TRADITION_CALL://传统床位
+                text = rnb + "房" + bnb + "床呼叫";
+                SpeechUtil.getInstance().newSpeech(text);
+                break;
+            case Constants.ROOMHELP_CALL://请求增援
+                text = rnb + "房" + bnb + "床请求增援";
+                SpeechUtil.getInstance().newSpeech(text);
+                break;
+            case Constants.WSHROOM_CALL://卫生间
+                text = rnb + "房卫生间请求增援";
+                SpeechUtil.getInstance().newSpeech(text);
+                break;
+            case Constants.MANAGER_CALL://总控机
+                text = "总控制室呼叫";
+                SpeechUtil.getInstance().newSpeech(text);
+                break;
+            case Constants.DOCTOR_CALL://医生主机
+                text = "医生主机呼叫";
+                SpeechUtil.getInstance().newSpeech(text);
+                break;
+        }
     }
 
     /**
@@ -1771,6 +1875,9 @@ public class CallingBedFragment extends BaseFragment implements SicknessBedAdapt
                         if (null != loopVoice) {
                             loopVoice.setPalyDismiss(true);
                         }
+                        if (enableTTS) {
+                            SpeechUtil.getInstance().stopSpeak();
+                        }
                     } else {
                         if (PalyPhonetics.speakEntityList.contains(udpEntity)) {//将播报列表也删除该元素
                             LogUtil.d("sendTransferForSon", "-----2222----");
@@ -1805,6 +1912,9 @@ public class CallingBedFragment extends BaseFragment implements SicknessBedAdapt
                         if (null != loopVoice) {
                             loopVoice.setPalyDismiss(true);
                         }
+                        if (enableTTS) {
+                            SpeechUtil.getInstance().stopSpeak();
+                        }
                     } else {
                         if (PalyPhonetics.speakEntityList.contains(callEntityList.get(i))) {//将播报列表也删除该元素
                             PalyPhonetics.speakEntityList.remove(udpEntity);
@@ -2191,7 +2301,12 @@ public class CallingBedFragment extends BaseFragment implements SicknessBedAdapt
                                 } else {
                                     //结束通话将当前呼叫对象语音关闭; 减少由于SIP结束回调的延时而出现重叠(之前是写在SIP结束回调的;在连续狂打电话的情况下效果重叠不行)
                                     if (null != loopingUdpentity && loopingUdpentity.equals(callingEntity)) {
-                                        loopVoice.setPalyDismiss(true);
+                                        if (null != loopVoice) {
+                                            loopVoice.setPalyDismiss(true);
+                                        }
+                                    }
+                                    if (enableTTS) {
+                                        SpeechUtil.getInstance().stopSpeak();
                                     }
                                     endCall(); //否则就挂断电话!
                                 }
@@ -2212,7 +2327,12 @@ public class CallingBedFragment extends BaseFragment implements SicknessBedAdapt
                         setCallVoice(0);//0为外喇叭 1为 手柄
                         if (handTelephone) {
                             if (null != loopingUdpentity && loopingUdpentity.equals(callingEntity)) {
-                                loopVoice.setPalyDismiss(true);
+                                if (null != loopVoice) {
+                                    loopVoice.setPalyDismiss(true);
+                                }
+                            }
+                            if (enableTTS) {
+                                SpeechUtil.getInstance().stopSpeak();
                             }
                             endCall(); //挂断电话!
                         }

+ 1 - 0
app/src/main/java/com/wdkl/callingmainnurse/util/SharedPreferencesUtil.java

@@ -10,6 +10,7 @@ import android.content.SharedPreferences;
 
 public class SharedPreferencesUtil {
 
+    public static final String CallingMode = "CallingMode";
     public static final String SbCallingVoice = "SbCallingVoice";
     public static final String SbingCallingVoice = "SbingCallingVoice";
     public static final String SipCallingVoice = "SipCallingVoice";

+ 105 - 0
app/src/main/java/com/wdkl/callingmainnurse/util/SpeechUtil.java

@@ -0,0 +1,105 @@
+package com.wdkl.callingmainnurse.util;
+
+import android.content.Context;
+import android.speech.tts.TextToSpeech;
+import android.speech.tts.UtteranceProgressListener;
+
+import java.util.Locale;
+
+public class SpeechUtil {
+    private static final String TAG = "SpeechUtil";
+
+    private TextToSpeech textToSpeech;
+    private static SpeechUtil speech;
+    private int speakIndex = 0;
+    private int loopCount = 2;
+    private String speechText;
+    private boolean isStop = true;
+
+    public static SpeechUtil getInstance() {
+        if (speech == null) {
+            synchronized (SpeechUtil.class) {
+                if (speech == null) {
+                    speech = new SpeechUtil();
+                }
+            }
+        }
+        return speech;
+    }
+
+    public void init(Context context) {
+        textToSpeech = new TextToSpeech(context, new TextToSpeech.OnInitListener() {
+            @Override
+            public void onInit(int status) {
+                if (status == TextToSpeech.SUCCESS) {
+                    int supported = textToSpeech.setLanguage(Locale.CHINESE);
+                    if ((supported != TextToSpeech.LANG_AVAILABLE) && (supported != TextToSpeech.LANG_COUNTRY_AVAILABLE)) {
+                        ToastUtil.showToast("当前不支持中文!");
+                    } else {
+                        LogUtil.d(TAG, "onInit: 支持中文");
+                    }
+                    LogUtil.d(TAG, "onInit: TTS引擎初始化成功");
+                } else {
+                    LogUtil.d(TAG, "onInit: TTS引擎初始化失败");
+                }
+            }
+        }, "com.iflytek.speechcloud");
+        textToSpeech.setSpeechRate(0.5f);
+    }
+
+    public void newSpeech(String text) {
+        LogUtil.d(TAG, "start speech: " + text);
+        if (loopCount > 0) {
+            stopSpeak();
+            speechText = text;
+            speakIndex = 0;
+            speak();
+            isStop = false;
+        }
+    }
+
+    public void speak() {
+        textToSpeech.speak(speechText, TextToSpeech.QUEUE_FLUSH, null, "uniqueId");
+        textToSpeech.setOnUtteranceProgressListener(new UtteranceProgressListener() {
+            @Override
+            public void onStart(String utteranceId) {
+                //LogUtil.d(TAG, "speak onStart..." + utteranceId);
+            }
+
+            @Override
+            public void onDone(String utteranceId) {
+                speakIndex++;
+                //LogUtil.d(TAG, "speak onDone...index: " + speakIndex + ", loop: " + loopCount);
+                if (speakIndex < loopCount && !isStop) {
+                    speak();
+                }
+            }
+
+            @Override
+            public void onError(String utteranceId) {
+                //LogUtil.d(TAG, "speak onError..." + utteranceId);
+            }
+        });
+    }
+
+    public void stopSpeak() {
+        if (textToSpeech.isSpeaking()) {
+            isStop = true;
+            textToSpeech.stop();
+            LogUtil.d(TAG, "stop speak");
+        }
+    }
+
+    public void setSpeechLoopCount(int count) {
+        loopCount = count;
+    }
+
+    public void release() {
+        if (textToSpeech != null) {
+            textToSpeech.stop();
+            textToSpeech.shutdown();
+            textToSpeech = null;
+        }
+    }
+
+}

+ 8 - 1
app/src/main/java/com/wdkl/callingmainnurse/util/StringUtils.java

@@ -10,6 +10,7 @@ import android.os.Bundle;
 import com.wdkl.callingmainnurse.BuildConfig;
 import com.wdkl.callingmainnurse.MyApplication;
 import com.wdkl.callingmainnurse.R;
+import com.wdkl.callingmainnurse.common.Constants;
 
 import java.io.BufferedReader;
 import java.io.IOException;
@@ -28,6 +29,8 @@ import java.util.List;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
+import serialporttest.utils.SerialPortUtil;
+
 /**
  * 类描述:字符串操作工具包
  * 创建人:Waderson Shll (TEL:15675117662)<br>
@@ -74,7 +77,11 @@ public class StringUtils {
 
     public static String getAllVersionName() {
         String str = "\r\nApp名称: " + MyApplication.getAppContext().getString(R.string.app_name)
-                + "\r\nAPP版本号:V" + BuildConfig.VERSION_NAME + "     中央服务器系列\r\n发布日期:" + BuildConfig.BUILD_TIME;
+                + "\r\nAPP版本号: V" + BuildConfig.VERSION_NAME
+                + "\r\nMCU版本号: " + Constants.MCU_VERSION_NUMBER
+                + "\r\n设备ID: " + SerialPortUtil.KEY_ID
+                + "\r\n中央服务器系列"
+                + "\r\n发布日期:" + BuildConfig.BUILD_TIME;
         if (android.os.Build.VERSION.SDK_INT >= 26) { //android8.0 = 26
             str = str + "    android8.1 , rk3368";// rk3368 android8.1
         } else if (android.os.Build.VERSION.SDK_INT >= 24) { //android7.0 = 24

+ 9 - 0
app/src/main/java/com/wdkl/callingmainnurse/util/UdpSendUtil.java

@@ -37,6 +37,15 @@ public class UdpSendUtil {
     }
 
     /**
+     * 护士主机改变传统转接盒的通话模式
+     */
+    public static void callModeChangeTradition(String mode) {
+        AnalysisUdpUtil.sendUdpData("call_mode_change_tradition_system"
+                , Constants.MYSELF_ID
+                , "0", "0", Constants.SIP_IP, "0", "0", mode, "0", "0", Constants.MAC_ADDRESS);
+    }
+
+    /**
      * 请求托管
      *
      * @param sendId(发送主机一id)

+ 39 - 1
app/src/main/res/layout/activity_calling_voice_set_layout.xml

@@ -23,7 +23,8 @@
             android:layout_width="match_parent"
             android:layout_height="0dp"
             android:layout_weight="1"
-            android:orientation="vertical">
+            android:orientation="vertical"
+            android:visibility="gone">
 
             <TextView
                 android:id="@+id/activity_sb_calling_voice_set"
@@ -52,6 +53,43 @@
             android:layout_width="match_parent"
             android:layout_height="0dp"
             android:layout_weight="1"
+            android:gravity="center_vertical">
+
+            <TextView
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:text="通话模式选择:"
+                android:textColor="@color/white"
+                android:textSize="28sp"/>
+
+            <RadioGroup
+                android:id="@+id/group_calling_mode"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_marginLeft="30dp"
+                android:orientation="horizontal">
+                <RadioButton
+                    android:id="@+id/rb_calling_mode_dual"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:text="双工模式"
+                    android:textColor="@color/white"
+                    android:textSize="28sp"/>
+                <RadioButton
+                    android:id="@+id/rb_calling_mode_single"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:layout_marginLeft="30dp"
+                    android:text="单工模式"
+                    android:textColor="@color/white"
+                    android:textSize="28sp"/>
+            </RadioGroup>
+        </LinearLayout>
+
+        <LinearLayout
+            android:layout_width="match_parent"
+            android:layout_height="0dp"
+            android:layout_weight="1"
             android:orientation="vertical">
 
             <TextView

BIN
tts/iFlytek.apk