Browse Source

门口机增加显示分机呼叫信息,增加分机呼叫语音播报

weizhengliang 2 năm trước cách đây
mục cha
commit
bafadd077e

+ 87 - 7
callingdoor/src/main/java/com/wdkl/app/ncs/callingdoor/activity/CallingdoorActivity.kt

@@ -1,12 +1,15 @@
 package com.wdkl.app.ncs.callingdoor.activity
 
 import android.content.*
+import android.graphics.Color
 import android.net.ConnectivityManager
 import android.os.*
 import android.support.v4.app.Fragment
 import android.text.TextUtils
 import android.util.Log
+import android.view.Gravity
 import android.view.View
+import android.widget.TextView
 import com.enation.javashop.android.jrouter.external.annotation.Router
 import com.enation.javashop.net.engine.model.NetState
 import com.example.yf_rk3288_api.YF_RK3288_API_Manager
@@ -47,6 +50,7 @@ import com.wdkl.ncs.android.middleware.tcp.enums.TcpType
 import com.wdkl.ncs.android.middleware.udp.ServerInfoUtil
 import com.wdkl.ncs.android.middleware.utils.AppUtil
 import com.wdkl.ncs.android.middleware.utils.CommonUtils
+import com.wdkl.ncs.android.middleware.utils.Util
 import kotlinx.android.synthetic.main.callingdoor_main_lay.*
 import kotlinx.android.synthetic.main.callingdoor_main_lay.app_version
 import kotlinx.android.synthetic.main.callingdoor_main_lay.room_action_call
@@ -55,6 +59,7 @@ import kotlinx.android.synthetic.main.callingdoor_main_lay.room_action_nurse
 import kotlinx.android.synthetic.main.callingdoor_main_lay.room_action_support
 import kotlinx.android.synthetic.main.callingdoor_main_lay.room_cancel_call
 import kotlinx.android.synthetic.main.callingdoor_main_lay.tv_room_name
+import kotlinx.android.synthetic.main.callingdoor_main_lay.view_flipper
 import kotlinx.android.synthetic.main.callingdoor_main_lay_rk3288.*
 import kotlinx.android.synthetic.main.view_bed_name.*
 import kotlinx.android.synthetic.main.view_title_layout.*
@@ -112,6 +117,8 @@ class CallingdoorActivity :BaseActivity<CallingdoorActivityPresenter, Callingdoo
     private var cancelRestart = false
     private var copyDone = false
 
+    private var bedCalls = ArrayList<String>()
+
     private val handler by lazy { Handler(Looper.getMainLooper()) }
 
     //网络异常计数
@@ -184,6 +191,15 @@ class CallingdoorActivity :BaseActivity<CallingdoorActivityPresenter, Callingdoo
             //alarmManager.setTimeZone("Asia/Shanghai")
         }
 
+        //tts初始化
+        SpeechUtil.getInstance().init(activity) {
+            //如果tts启用失败或者不支持中文则将语音播报切换到音乐模式
+            if (!it) {
+                Log.e(TAG, "tts init failed...")
+            }
+        }
+        SpeechUtil.getInstance().setSpeechLoopCount(3)
+
         app_version.text = "V" + BuildConfig.VERSION_NAME
 
         //显示二维码界面
@@ -454,9 +470,9 @@ class CallingdoorActivity :BaseActivity<CallingdoorActivityPresenter, Callingdoo
                 room_action_nurse.setBackgroundResource(R.mipmap.bg_bottom_btn)
                 tv_room_name.text = Constant.ROOM_NAME
                 tv_room_name.setTextColor(resources.getColor(R.color.main_color))
-                if (Constant.DEVICE_ID != -1 && nursingInteId != null) {
+                /*if (Constant.DEVICE_ID != -1 && nursingInteId != null) {
                     OtherUtil.sendNursingEnd(Constant.DEVICE_ID, nursingInteId)
-                }
+                }*/
             } else {
                 Constant.inNursing = true
                 if ("rk3128".equals(Build.MODEL) || "rk3368".equals(Build.MODEL) || "WDMK_I".equals(Build.MODEL) || "WDMKI".equals(Build.MODEL)) {
@@ -470,9 +486,9 @@ class CallingdoorActivity :BaseActivity<CallingdoorActivityPresenter, Callingdoo
                     tv_room_name.text = Constant.ROOM_NAME + " " + Constant.NursingTitle + "..."
                 }
                 tv_room_name.setTextColor(resources.getColor(R.color.nursing_color))
-                if (Constant.DEVICE_ID != -1) {
+                /*if (Constant.DEVICE_ID != -1) {
                     OtherUtil.sendNursing(Constant.DEVICE_ID)
-                }
+                }*/
             }
 
             return@setOnLongClickListener true
@@ -554,7 +570,19 @@ class CallingdoorActivity :BaseActivity<CallingdoorActivityPresenter, Callingdoo
 
         //门口机取消分机呼叫
         room_cancel_call.setOnClickListener {
-            VoiceUtil.cancelCallByDoor(Constant.DEVICE_ID)
+            if (Constant.TCP_CONNECTED) {
+                if (Constant.DEVICE_ID != -1) {
+                    VoiceUtil.cancelCallByDoor(Constant.DEVICE_ID)
+                } else {
+                    showMessage("没有设备id!")
+                }
+            } else {
+                showMessage("网络异常!")
+            }
+
+            SpeechUtil.getInstance().stopSpeak()
+            bedCalls.clear()
+            view_flipper.removeAllViews()
         }
 
         app_version.setOnLongClickListener {
@@ -1095,9 +1123,12 @@ class CallingdoorActivity :BaseActivity<CallingdoorActivityPresenter, Callingdoo
                             val interactionVO = Gson().fromJson(tcpModel.data.toString(), InteractionVO::class.java)
                             nursingInteId = interactionVO.id
                         } else {
-                            if ("rk3128".equals(Build.MODEL) || "rk3368".equals(Build.MODEL) || "WDMK_I".equals(Build.MODEL) || "WDMKI".equals(Build.MODEL)) {
+                            /*if ("rk3128".equals(Build.MODEL) || "rk3368".equals(Build.MODEL) || "WDMK_I".equals(Build.MODEL) || "WDMKI".equals(Build.MODEL)) {
                                 DoorLightHelper.handleDoorLight(tcpModel)
-                            }
+                            }*/
+
+                            DoorLightHelper.handleDoorLight(tcpModel)
+                            callControl(tcpModel)
                         }
                     } else if(tcpModel.action == TcpAction.TimeAction.SYNC && tcpModel.type==TcpType.TIME){
                         val time =  tcpModel.data.toString().toLong()*1000
@@ -1128,6 +1159,55 @@ class CallingdoorActivity :BaseActivity<CallingdoorActivityPresenter, Callingdoo
         }
     }
 
+    private fun callControl(tcpModel: TcpModel) {
+        if (tcpModel.action == TcpAction.SideAction.CALL) {
+            //显示分机呼叫信息
+            val interactionVO = Gson().fromJson(tcpModel.data.toString(), InteractionVO::class.java)
+            updateBedCall(interactionVO, true)
+        } else if (tcpModel.action == TcpAction.SideAction.ACCEPT || tcpModel.action == TcpAction.SideAction.CANCEL) {
+            val interactionVO = Gson().fromJson(tcpModel.data.toString(), InteractionVO::class.java)
+            updateBedCall(interactionVO, false)
+        }
+    }
+
+    //更新呼叫信息显示
+    private fun updateBedCall(interactionVO: InteractionVO, add: Boolean) {
+        val name = CommonUtils.subStringAfter(interactionVO.fromFrameFullName, "-")
+        val frameName = Util.appendSpace(interactionVO.fromFrameFullName.replace("-", ","))
+        if (add) {
+            bedCalls.add(name)
+            if (Constant.TTS_STATUS == 2) {
+                SpeechUtil.getInstance().addSpeech(frameName + "呼叫", false)
+            }
+        } else {
+            bedCalls.remove(name)
+            if (Constant.TTS_STATUS == 2) {
+                SpeechUtil.getInstance().removeSpeak(frameName + "呼叫")
+            }
+        }
+
+        if (bedCalls.size > 0) {
+            view_flipper.removeAllViews()
+            for ((index, e) in bedCalls.withIndex()) {
+                val textView = TextView(activity)
+                textView.text = e + " 呼叫"
+                textView.setSingleLine(true)
+                textView.setEllipsize(TextUtils.TruncateAt.END)
+                textView.setTextColor(Color.RED)
+                if ("rk3288".equals(Build.MODEL) || "rk3368".equals(Build.MODEL) || "WDMK_I".equals(Build.MODEL) || "WDMKI".equals(Build.MODEL)) {
+                    textView.textSize = 48f
+                } else {
+                    textView.textSize = 32f
+                }
+                textView.gravity = (Gravity.END or Gravity.CENTER)
+
+                view_flipper.addView(textView, index)
+            }
+        } else {
+            view_flipper.removeAllViews()
+        }
+    }
+
     private fun updateStatus(state: String) {
         this.runOnUiThread {
             when (state) {

+ 3 - 1
callingdoor/src/main/java/com/wdkl/app/ncs/callingdoor/adapter/BedItemAdapter.java

@@ -11,6 +11,7 @@ import android.widget.TextView;
 import com.wdkl.app.ncs.callingdoor.R;
 import com.wdkl.ncs.android.middleware.common.Constant;
 import com.wdkl.ncs.android.middleware.model.vo.FrameBedVO;
+import com.wdkl.ncs.android.middleware.utils.CommonUtils;
 
 import java.util.ArrayList;
 
@@ -35,7 +36,8 @@ public class BedItemAdapter extends RecyclerView.Adapter<BedItemAdapter.BedViewH
 
     @Override
     public void onBindViewHolder(BedViewHolder bedViewHolder, int i) {
-        bedViewHolder.bedName.setText(data.get(i).getFrameBed().getFullName());
+        String name = CommonUtils.subStringAfter(data.get(i).getFrameBed().getFullName(), "-");
+        bedViewHolder.bedName.setText(name);
         bedViewHolder.name.setText(data.get(i).getCustomerName());
         if (Constant.supportCamera) {
             bedViewHolder.videoCall.setVisibility(View.VISIBLE);

+ 3 - 2
callingdoor/src/main/java/com/wdkl/app/ncs/callingdoor/adapter/FrameRoomAdapter.kt

@@ -17,6 +17,7 @@ import com.wdkl.app.ncs.callingdoor.R
 import com.wdkl.ncs.android.middleware.common.Constant
 import com.wdkl.ncs.android.middleware.model.dto.NurseConfigDto
 import com.wdkl.ncs.android.middleware.model.vo.FrameBedVO
+import com.wdkl.ncs.android.middleware.utils.CommonUtils
 
 class FrameRoomAdapter : RecyclerView.Adapter<FrameRoomAdapter.BedViewHolder> {
 
@@ -110,7 +111,7 @@ class FrameRoomAdapter : RecyclerView.Adapter<FrameRoomAdapter.BedViewHolder> {
     }
 
     private fun showBedInfo(holder: BedViewHolder, bedVO: FrameBedVO) {
-        holder.bedName.text = bedVO.frameBed.fullName
+        holder.bedName.text = CommonUtils.subStringAfter(bedVO.frameBed.fullName, "-")
         if (TextUtils.isEmpty(bedVO.customerName)) {
             //空床位
             holder.customName.text = "暂无"
@@ -199,7 +200,7 @@ class FrameRoomAdapter : RecyclerView.Adapter<FrameRoomAdapter.BedViewHolder> {
     }
 
     private fun showBedInfoRk3288(holder: BedViewHolder, bedVO: FrameBedVO) {
-        holder.bedName.text = bedVO.frameBed.fullName
+        holder.bedName.text = CommonUtils.subStringAfter(bedVO.frameBed.fullName, "-")
         if (TextUtils.isEmpty(bedVO.customerName)) {
             //空床位
             holder.customName.text = "暂无"

+ 4 - 0
callingdoor/src/main/java/com/wdkl/app/ncs/callingdoor/helper/AsyncPlayer.java

@@ -140,6 +140,10 @@ public class AsyncPlayer {
         }
     }
 
+    public boolean isPlay() {
+        return mState == PLAY;
+    }
+
     private void enqueueLocked(Command cmd) {
         mCmdQueue.add(cmd);
         if (mThread == null) {

+ 18 - 1
callingdoor/src/main/java/com/wdkl/app/ncs/callingdoor/helper/RingPlayHelper.java

@@ -2,19 +2,36 @@ package com.wdkl.app.ncs.callingdoor.helper;
 
 import android.content.Context;
 import android.media.AudioManager;
+import android.os.Handler;
+import android.os.Looper;
+import android.os.Message;
 
 public class RingPlayHelper {
 
     private static AsyncPlayer ringPlayer;
+    private final static Handler handler = new Handler(Looper.getMainLooper()) {
+        @Override
+        public void handleMessage(Message msg) {
+            if (ringPlayer != null) {
+                ringPlayer.stop();
+            }
+        }
+    };
 
     public static void playRingTone(Context context, int res, boolean loop) {
         if (ringPlayer == null) {
             ringPlayer = new AsyncPlayer(null);
         }
-        ringPlayer.play(context, res, loop, AudioManager.STREAM_MUSIC);
+
+        if (!ringPlayer.isPlay()) {
+            ringPlayer.play(context, res, loop, AudioManager.STREAM_MUSIC);
+            handler.removeCallbacksAndMessages(null);
+            handler.sendEmptyMessageDelayed(10, 30000);
+        }
     }
 
     public static void stopRingTone() {
+        handler.removeCallbacksAndMessages(null);
         if (ringPlayer != null) {
             ringPlayer.stop();
         }

+ 208 - 0
callingdoor/src/main/java/com/wdkl/app/ncs/callingdoor/helper/SpeechUtil.java

@@ -0,0 +1,208 @@
+package com.wdkl.app.ncs.callingdoor.helper;
+
+import android.content.Context;
+import android.os.Build;
+import android.speech.tts.TextToSpeech;
+import android.speech.tts.UtteranceProgressListener;
+import android.text.TextUtils;
+import android.util.Log;
+
+import com.wdkl.ncs.android.middleware.common.Constant;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+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 boolean isStop = true;
+    public volatile static ArrayList<String> speechTextList = new ArrayList<>();
+    private Thread speechThread;
+    private boolean isSpeechLoop = true;
+    private String speakSpeech;
+    private final Object lockObject = new Object();
+    HashMap<String, String> map = new HashMap<>();
+
+    public static SpeechUtil getInstance() {
+        if (speech == null) {
+            synchronized (SpeechUtil.class) {
+                if (speech == null) {
+                    speech = new SpeechUtil();
+                }
+            }
+        }
+        return speech;
+    }
+
+    public void init(Context context, final TtsCallback callback) {
+        map.put(TextToSpeech.Engine.KEY_PARAM_UTTERANCE_ID, "unigueId");
+        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)) {
+                        Constant.TTS_STATUS = 1;
+                        Log.d(TAG, "onInit: 当前不支持中文");
+                        if (callback != null) {
+                            callback.onInit(false);
+                        }
+                    } else {
+                        Constant.TTS_STATUS = 2;
+                        Log.d(TAG, "onInit: 支持中文");
+                        if (callback != null) {
+                            callback.onInit(true);
+                        }
+                    }
+                    Log.d(TAG, "onInit: TTS引擎初始化成功");
+                } else {
+                    Constant.TTS_STATUS = 0;
+                    Log.d(TAG, "onInit: TTS引擎初始化失败");
+                    if (callback != null) {
+                        callback.onInit(false);
+                    }
+                }
+            }
+        }, "com.iflytek.speechcloud");
+        textToSpeech.setSpeechRate(0.5f);
+    }
+
+    public void addSpeech(String text, boolean emergency) {
+        synchronized (lockObject) {
+            Log.d(TAG, "start add text speech: " + text);
+
+            if (speechTextList.contains(text)) {
+                return;
+            }
+            Log.d(TAG, "truely add text speech: " + text);
+
+            if (emergency) {
+                stopSpeak();
+                speechTextList.add(0, text);
+            } else {
+                speechTextList.add(text);
+            }
+            startSpeechThread();
+        }
+    }
+
+    public synchronized void speak(final String text) {
+        Log.d(TAG, "tts speak: " + text);
+
+        isStop = false;
+        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
+            textToSpeech.speak(text, TextToSpeech.QUEUE_FLUSH, null, "uniqueId");
+        } else {
+            textToSpeech.speak(text, TextToSpeech.QUEUE_FLUSH, map);
+        }
+        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(text);
+                } else {
+                    //语音播报完毕
+                    speakIndex = 0;
+                    isStop = true;
+                }
+            }
+
+            @Override
+            public void onError(String utteranceId) {
+                isStop = true;
+                Log.d(TAG, "speak onError..." + utteranceId);
+            }
+        });
+    }
+
+    public void stopSpeak() {
+        speechTextList.clear();
+        if (textToSpeech != null && textToSpeech.isSpeaking()) {
+            textToSpeech.stop();
+            isStop = true;
+            speakIndex = 0;
+
+            Log.d(TAG, "stop speak");
+        }
+    }
+
+    public void removeSpeak(String text) {
+        synchronized (lockObject) {
+            if (!TextUtils.isEmpty(text) && !TextUtils.isEmpty(speakSpeech)) {
+                Log.d(TAG, "remove speak: " + text);
+
+                if (text.equals(speakSpeech) && textToSpeech.isSpeaking()) {
+                    textToSpeech.stop();
+                    speechTextList.remove(text);
+                    isStop = true;
+                    speakIndex = 0;
+                } else {
+                    speechTextList.remove(text);
+                }
+            }
+        }
+    }
+
+    public void setSpeechLoopCount(int count) {
+        loopCount = count;
+    }
+
+    public void release() {
+        speechTextList.clear();
+        isStop = true;
+        speakIndex = 0;
+        if (textToSpeech != null) {
+            textToSpeech.stop();
+            textToSpeech.shutdown();
+            textToSpeech = null;
+        }
+    }
+
+    public void startSpeechThread() {
+        if (null == speechThread) {
+            speechThread = new Thread(new SpeechRunnable());
+            speechThread.start();
+        } else if (!speechThread.isAlive()) {
+            speechThread.start();
+        }
+    }
+
+    public class SpeechRunnable implements Runnable {
+        public void run() {
+            while (isSpeechLoop) {
+                if (speechTextList.size() > 0 && isStop) {
+                    speakSpeech = speechTextList.get(0);
+                    Log.d(TAG, "speakSpeech: " + speakSpeech);
+
+                    speak(speakSpeech);
+
+                    speechTextList.remove(speakSpeech);
+                }
+
+                try {
+                    Thread.sleep(50);
+                } catch (Exception e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+    }
+
+
+    public interface TtsCallback {
+        void onInit(boolean success);
+    }
+}

+ 42 - 15
callingdoor/src/main/res/layout/callingdoor_main_lay.xml

@@ -9,20 +9,47 @@
             android:id="@+id/activity_calling_door_layout_title"
             layout="@layout/view_title_layout"/>
 
-        <com.wdkl.ncs.android.lib.widget.MarqueeTextView
-            android:id="@+id/tv_room_name"
+        <LinearLayout
+            android:id="@+id/ll_room_name"
             android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:layout_below="@id/activity_calling_door_layout_title"
-            android:paddingLeft="20dp"
-            android:paddingRight="20dp"
-            android:text="--房"
-            android:textColor="@color/main_color"
-            android:textSize="68sp"
-            android:singleLine="true"
-            android:ellipsize="marquee"
-            android:focusable="true"
-            android:focusableInTouchMode="true" />
+            android:layout_height="100dp"
+            android:layout_below="@id/activity_calling_door_layout_title">
+            <com.wdkl.ncs.android.lib.widget.MarqueeTextView
+                android:id="@+id/tv_room_name"
+                android:layout_width="0dp"
+                android:layout_height="match_parent"
+                android:layout_weight="3"
+                android:paddingLeft="20dp"
+                android:paddingRight="20dp"
+                android:text="--房"
+                android:textColor="#EAF2F9"
+                android:textSize="68sp"
+                android:singleLine="true"
+                android:ellipsize="marquee"
+                android:focusable="true"
+                android:focusableInTouchMode="true" />
+
+            <ViewFlipper
+                android:id="@+id/view_flipper"
+                android:layout_width="0dp"
+                android:layout_height="match_parent"
+                android:layout_weight="1"
+                android:paddingRight="10dp"
+                android:paddingLeft="10dp"
+                android:autoStart="true"
+                android:flipInterval="5000"
+                android:inAnimation="@anim/slide_down_in"
+                android:outAnimation="@anim/slide_up_out">
+                <!--<TextView
+                    android:id="@+id/call_name"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:layout_gravity="center|right"
+                    android:text="09床 呼叫"
+                    android:textColor="@color/color_red"
+                    android:textSize="32sp" />-->
+            </ViewFlipper>
+        </LinearLayout>
 
         <!--右侧按钮区域-->
         <RelativeLayout
@@ -32,7 +59,7 @@
             android:layout_alignParentRight="true"
             android:layout_marginTop="10dp"
             android:layout_marginRight="10dp"
-            android:layout_below="@id/tv_room_name">
+            android:layout_below="@id/ll_room_name">
             <TextView
                 android:id="@+id/app_version"
                 android:layout_width="match_parent"
@@ -125,7 +152,7 @@
             android:layout_width="match_parent"
             android:layout_height="match_parent"
             android:layout_margin="10dp"
-            android:layout_below="@id/tv_room_name"
+            android:layout_below="@id/ll_room_name"
             android:layout_toLeftOf="@id/rl_room_actions"/>
 
         <!--通话界面-->

+ 43 - 15
callingdoor/src/main/res/layout/callingdoor_main_lay_rk3288.xml

@@ -9,21 +9,49 @@
             android:id="@+id/activity_calling_door_layout_title"
             layout="@layout/view_title_layout_rk3288"/>
 
-        <com.wdkl.ncs.android.lib.widget.MarqueeTextView
-            android:id="@+id/tv_room_name"
+        <LinearLayout
+            android:id="@+id/ll_room_name"
             android:layout_width="match_parent"
             android:layout_height="180dp"
-            android:layout_below="@id/activity_calling_door_layout_title"
-            android:paddingLeft="10dp"
-            android:paddingRight="10dp"
-            android:gravity="center_vertical"
-            android:singleLine="true"
-            android:ellipsize="marquee"
-            android:focusable="true"
-            android:focusableInTouchMode="true"
-            android:text="--房"
-            android:textColor="@color/main_color"
-            android:textSize="140sp" />
+            android:layout_below="@id/activity_calling_door_layout_title">
+
+            <com.wdkl.ncs.android.lib.widget.MarqueeTextView
+                android:id="@+id/tv_room_name"
+                android:layout_width="0dp"
+                android:layout_height="match_parent"
+                android:layout_weight="3"
+                android:paddingLeft="10dp"
+                android:paddingRight="10dp"
+                android:gravity="center_vertical"
+                android:singleLine="true"
+                android:ellipsize="marquee"
+                android:focusable="true"
+                android:focusableInTouchMode="true"
+                android:text="--房"
+                android:textColor="@color/main_color"
+                android:textSize="140sp" />
+
+            <ViewFlipper
+                android:id="@+id/view_flipper"
+                android:layout_width="0dp"
+                android:layout_height="match_parent"
+                android:layout_weight="1"
+                android:paddingRight="10dp"
+                android:paddingLeft="10dp"
+                android:autoStart="true"
+                android:flipInterval="5000"
+                android:inAnimation="@anim/slide_down_in"
+                android:outAnimation="@anim/slide_up_out">
+                <!--<TextView
+                    android:id="@+id/call_name"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:layout_gravity="center|right"
+                    android:text="09床 呼叫"
+                    android:textColor="@color/color_red"
+                    android:textSize="32sp" />-->
+            </ViewFlipper>
+        </LinearLayout>
 
         <!--右侧按钮区域-->
         <RelativeLayout
@@ -35,7 +63,7 @@
             android:layout_marginRight="10dp"
             android:paddingLeft="10dp"
             android:paddingRight="10dp"
-            android:layout_below="@id/tv_room_name">
+            android:layout_below="@id/ll_room_name">
             <TextView
                 android:id="@+id/app_version"
                 android:layout_width="match_parent"
@@ -127,7 +155,7 @@
             android:layout_width="match_parent"
             android:layout_height="match_parent"
             android:layout_margin="20dp"
-            android:layout_below="@id/tv_room_name"
+            android:layout_below="@id/ll_room_name"
             android:layout_toLeftOf="@id/rl_room_actions"/>
 
         <!--通话界面-->

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

@@ -75,6 +75,8 @@ public class Constant {
 
     public static String SIP_ROOM_ID = "";
 
+    public static int TTS_STATUS = 0;
+
     //科室id
     public static Integer PART_ID;
 

+ 28 - 0
middleware/src/main/code/com/wdkl/ncs/android/middleware/utils/CommonUtils.java

@@ -22,6 +22,34 @@ public class CommonUtils {
     private static final String DEFAULT_SIP_PORT = "8188";
 
 
+    public static String subStringBefore(String origin, String delimiter) {
+        if (!TextUtils.isEmpty(origin) && !TextUtils.isEmpty(delimiter) && origin.length() > 0) {
+            int index = origin.indexOf(delimiter);
+            if (index > 0) {
+                return origin.substring(0, index);
+            } else {
+                return origin;
+            }
+        } else {
+            return origin;
+        }
+    }
+
+    public static String subStringAfter(String origin, String delimiter) {
+        if (!TextUtils.isEmpty(origin) && !TextUtils.isEmpty(delimiter) && origin.length() > 0) {
+            int index = origin.indexOf(delimiter)+1;
+            int len = origin.length();
+            if (index > 0 && index < len) {
+                return origin.substring(index);
+            } else {
+                return origin;
+            }
+        } else {
+            return origin;
+        }
+    }
+
+
     public static String getUrl(Context context) {
         if (TextUtils.isEmpty(getSP(context).getString(KEY_SP_URL, DEFAULT_URL))) {
             return DEFAULT_URL;

+ 68 - 0
middleware/src/main/code/com/wdkl/ncs/android/middleware/utils/Util.kt

@@ -0,0 +1,68 @@
+package com.wdkl.ncs.android.middleware.utils
+
+import android.annotation.SuppressLint
+import android.app.KeyguardManager
+import android.content.Context
+import android.content.Context.KEYGUARD_SERVICE
+import android.os.PowerManager
+import android.util.DisplayMetrics
+import android.view.WindowManager
+import com.wdkl.ncs.android.lib.base.BaseApplication
+
+
+object Util {
+
+    /**
+     * 亮屏并解锁
+     */
+    @SuppressLint("InvalidWakeLockTag")
+    fun wakeUpAndUnlock(): PowerManager.WakeLock? {
+        val pm = BaseApplication.appContext.getSystemService(Context.POWER_SERVICE) as PowerManager
+        var wakeLock: PowerManager.WakeLock? = null
+
+        val screenOn = pm.isInteractive
+        if (!screenOn) { //如果是熄灭状态
+            wakeLock = pm.newWakeLock(PowerManager.ACQUIRE_CAUSES_WAKEUP or PowerManager.SCREEN_DIM_WAKE_LOCK, "TAG")
+            wakeLock.acquire(10000)//亮屏
+        }
+
+        // 屏幕解锁
+        val keyguardManager = BaseApplication.appContext.getSystemService(KEYGUARD_SERVICE) as KeyguardManager
+        val keyguardLock = keyguardManager.newKeyguardLock("unLock")
+        // 屏幕锁定
+        keyguardLock.reenableKeyguard()
+        keyguardLock.disableKeyguard() // 解锁
+        return wakeLock
+    }
+
+    @SuppressLint("InvalidWakeLockTag")
+    fun getCpuWakeLock(context: Context): PowerManager.WakeLock? {
+        val pm = context.getSystemService(Context.POWER_SERVICE) as PowerManager
+        val cpuWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,
+                context.javaClass.canonicalName)
+        return cpuWakeLock
+    }
+
+    fun appendSpace(para: String): String {
+        val length = para.length
+        val value = CharArray(length shl 1)
+        var i = 0
+        var j = 0
+        while (i < length) {
+            value[j] = para[i]
+            value[1 + j] = ' '
+            ++i
+            j = i shl 1
+        }
+        return String(value)
+    }
+
+
+
+    fun getPixelsFromDp(context: Context, size: Int): Int {
+        val metrics = DisplayMetrics()
+        val wm = context.getSystemService(Context.WINDOW_SERVICE) as WindowManager
+        wm.getDefaultDisplay().getMetrics(metrics)
+        return size * metrics.densityDpi / DisplayMetrics.DENSITY_DEFAULT
+    }
+}