Prechádzať zdrojové kódy

a133主板西班牙项目增加通话界面音量调节功能

weizhengliang 1 rok pred
rodič
commit
6360a8b7bb

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

@@ -7,6 +7,7 @@ import android.os.SystemClock
 import android.util.Log
 import android.view.View
 import android.view.ViewGroup
+import android.widget.SeekBar
 import com.alibaba.fastjson.JSONObject
 import com.google.gson.Gson
 import com.wdkl.app.ncs.callingdoor.R
@@ -60,17 +61,15 @@ class SkyCallFragment: BaseCallFragment(), CallSessionCallback {
     private val handler = Handler(Looper.getMainLooper())
 
     private var audioCall: Boolean = true
-
     private var callEnded: Boolean = false
-
     private var outGoing: Boolean = false
 
+    private var speakerMute = false
+    private var micMute: Boolean = false // 是否关闭麦克风
+    private var volume = 60
+
     override fun getLayId(): Int {
-        if ("rk3288".equals(Build.MODEL)) {
-            return R.layout.sky_voice_call_layout_rk3288
-        } else {
-            return R.layout.sky_voice_call_layout
-        }
+        return R.layout.sky_voice_call_layout
     }
 
     override fun init() {
@@ -79,6 +78,16 @@ class SkyCallFragment: BaseCallFragment(), CallSessionCallback {
 
         //初始化计时器
         initCountDownTimer(sky_voice_call_timeout)
+
+        volume = SettingConfig.getExtensionCallVolume(activity)
+        if (volume < 0 || volume > 100) {
+            volume = 60
+        }
+        call_volume_bar.progress = volume/10
+        tv_volume.text = "" + volume/10
+
+        VoiceManagerUtil.setCallVoice(activity, volume)
+
         //tcp参数
         if (tcpModel != null) {
             fromId = tcpModel!!.fromId
@@ -94,9 +103,6 @@ class SkyCallFragment: BaseCallFragment(), CallSessionCallback {
             WebRTCEngine.getInstance().init(true, this.context)
         }
 
-        VoiceManagerUtil.setCallVoice(activity, SettingConfig.getExtensionCallVolume(activity))
-        //WebRTCEngine.getInstance().toggleSpeaker(true)
-
         //初始化 janusClient
         janusClient = JanusClient(JanusConstant.JANUS_URL, Constant.SIP_ID.toBigInteger())
 
@@ -203,6 +209,45 @@ class SkyCallFragment: BaseCallFragment(), CallSessionCallback {
             voiceAccept()
             janusClient!!.connect()
         }
+
+        sky_voice_call_speaker.setOnClickListener {
+            speakerMute = !speakerMute
+            Log.d(TAG,"Speaker enable: $speakerMute")
+
+            WebRTCEngine.getInstance().setVolumeMute(speakerMute)
+            sky_voice_call_speaker.isSelected = speakerMute
+        }
+
+        sky_voice_call_mute.setOnClickListener {
+            micMute = !micMute
+            Log.d(TAG,"静音切换: $micMute")
+
+            WebRTCEngine.getInstance().muteAudio(micMute)
+            sky_voice_call_mute.isSelected = micMute
+        }
+
+        call_volume_bar.setOnSeekBarChangeListener(object : SeekBar.OnSeekBarChangeListener{
+            override fun onProgressChanged(seekBar: SeekBar?, progress: Int, fromUser: Boolean) {
+                tv_volume.text = "" + progress
+                if (seekBar!!.progress <= 1) {
+                    tv_volume.text = "1"
+                } else {
+                    tv_volume.text = "" + progress
+                }
+            }
+
+            override fun onStartTrackingTouch(seekBar: SeekBar?) {
+                //
+            }
+
+            override fun onStopTrackingTouch(seekBar: SeekBar?) {
+                if (seekBar!!.progress <= 2) {
+                    VoiceManagerUtil.setCallVoice(activity, 20)
+                } else {
+                    VoiceManagerUtil.setCallVoice(activity, seekBar.progress*10)
+                }
+            }
+        })
     }
 
     override fun destroy() {
@@ -399,6 +444,9 @@ class SkyCallFragment: BaseCallFragment(), CallSessionCallback {
         sky_voice_call_timer.visibility = View.VISIBLE
         sky_voice_call_timer.base = SystemClock.elapsedRealtime()
         sky_voice_call_timer.start()
+        sky_voice_call_speaker.visibility = View.VISIBLE
+        sky_voice_call_mute.visibility = View.VISIBLE
+        ll_voice_volume_bar.visibility = View.VISIBLE
     }
 
     //通话结束

+ 66 - 7
android_door/src/main/h10_a133_chile/res/layout/sky_voice_call_layout.xml

@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="utf-8"?>
-<layout>
+<layout xmlns:app="http://schemas.android.com/apk/res-auto">
     <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
         android:layout_width="match_parent"
         android:layout_height="match_parent"
@@ -83,12 +83,34 @@
                     android:textColor="@color/white"
                     android:textSize="24sp" />
 
-                <ImageView
-                    android:id="@+id/sky_voice_call_hangup"
-                    android:layout_width="80dp"
-                    android:layout_height="80dp"
-                    android:layout_marginTop="20dp"
-                    android:src="@drawable/selector_call_hangup" />
+                <LinearLayout
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:layout_marginTop="32dp">
+
+                    <ImageView
+                        android:id="@+id/sky_voice_call_mute"
+                        android:layout_width="80dp"
+                        android:layout_height="80dp"
+                        android:layout_marginRight="40dp"
+                        android:src="@drawable/av_mute_selector"
+                        android:visibility="gone"/>
+
+                    <ImageView
+                        android:id="@+id/sky_voice_call_hangup"
+                        android:layout_width="80dp"
+                        android:layout_height="80dp"
+                        android:src="@drawable/selector_call_hangup" />
+
+                    <ImageView
+                        android:id="@+id/sky_voice_call_speaker"
+                        android:layout_width="80dp"
+                        android:layout_height="80dp"
+                        android:layout_marginLeft="40dp"
+                        android:src="@drawable/av_speaker_selector"
+                        android:visibility="gone"/>
+
+                </LinearLayout>
             </LinearLayout>
 
             <!--来电-->
@@ -130,6 +152,43 @@
                     android:layout_height="1dp"
                     android:layout_weight="2" />
             </LinearLayout>
+
+            <LinearLayout
+                android:id="@+id/ll_voice_volume_bar"
+                android:layout_width="60dp"
+                android:layout_height="match_parent"
+                android:layout_alignParentRight="true"
+                android:layout_marginRight="120dp"
+                android:layout_marginTop="100dp"
+                android:layout_marginBottom="100dp"
+                android:clipChildren="true"
+                android:orientation="vertical"
+                android:gravity="center"
+                android:visibility="gone">
+                <TextView
+                    android:id="@+id/tv_volume"
+                    android:layout_width="match_parent"
+                    android:layout_height="wrap_content"
+                    android:gravity="center"
+                    android:textSize="24sp"
+                    android:textColor="@color/title_text"/>
+
+                <com.wdkl.ncs.android.lib.widget.VerticalSeekBarWrapper
+                    android:layout_width="32dp"
+                    android:layout_height="match_parent">
+                    <com.wdkl.ncs.android.lib.widget.VerticalSeekBar
+                        android:id="@+id/call_volume_bar"
+                        android:layout_width="0dp"
+                        android:layout_height="0dp"
+                        android:padding="8dp"
+                        android:max="10"
+                        android:progress="6"
+                        android:splitTrack="false"
+                        android:progressDrawable="@drawable/seek_bar_bg"
+                        android:thumb="@drawable/seek_bar_thumb"
+                        app:seekBarRotation="CW270" /> <!-- Rotation: CW90 or CW270 -->
+                </com.wdkl.ncs.android.lib.widget.VerticalSeekBarWrapper>
+            </LinearLayout>
         </RelativeLayout>
     </FrameLayout>
 </layout>

+ 0 - 136
android_door/src/main/h10_a133_chile/res/layout/sky_voice_call_layout_rk3288.xml

@@ -1,136 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<layout>
-    <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
-        android:layout_width="match_parent"
-        android:layout_height="match_parent"
-        android:background="@color/gray_deep">
-        <!--全屏视频画面-->
-        <FrameLayout
-            android:id="@+id/fullscreen_video_frame"
-            android:layout_width="match_parent"
-            android:layout_height="match_parent"
-            android:layout_gravity="center"
-            android:visibility="gone"/>
-
-        <!--小窗视频画面-->
-        <FrameLayout
-            android:id="@+id/pip_video_frame"
-            android:layout_width="280dp"
-            android:layout_height="400dp"
-            android:layout_gravity="top|end"
-            android:layout_marginHorizontal="10dp"
-            android:layout_marginTop="10dp"
-            android:visibility="gone"/>
-
-        <RelativeLayout
-            android:layout_width="match_parent"
-            android:layout_height="match_parent">
-
-            <!--语音呼叫layout-->
-            <LinearLayout
-                android:id="@+id/ll_voice_call"
-                android:layout_width="match_parent"
-                android:layout_height="wrap_content"
-                android:layout_marginTop="400dp"
-                android:gravity="center_horizontal"
-                android:orientation="vertical">
-
-                <ImageView
-                    android:id="@+id/sky_voice_call_head_img"
-                    android:layout_width="200dp"
-                    android:layout_height="200dp"
-                    android:layout_marginTop="80dp"
-                    android:scaleType="centerInside"
-                    android:src="@drawable/ic_nurse" />
-
-                <TextView
-                    android:id="@+id/sky_voice_call_calling_text"
-                    android:layout_width="wrap_content"
-                    android:layout_height="wrap_content"
-                    android:layout_marginTop="24dp"
-                    android:gravity="center"
-                    android:text="@string/call_in_calling"
-                    android:textColor="@color/white"
-                    android:textSize="48sp" />
-
-                <TextView
-                    android:id="@+id/sky_voice_call_timeout"
-                    android:layout_width="wrap_content"
-                    android:layout_height="wrap_content"
-                    android:layout_marginTop="24dp"
-                    android:gravity="center"
-                    android:textColor="@color/white"
-                    android:textSize="36sp" />
-            </LinearLayout>
-
-            <!--呼出-->
-            <LinearLayout
-                android:id="@+id/sky_voice_call_outgoing"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:layout_alignParentBottom="true"
-                android:layout_centerHorizontal="true"
-                android:layout_marginBottom="120dp"
-                android:gravity="center_horizontal"
-                android:orientation="vertical"
-                android:visibility="visible">
-
-                <Chronometer
-                    android:id="@+id/sky_voice_call_timer"
-                    android:layout_width="match_parent"
-                    android:layout_height="wrap_content"
-                    android:gravity="center"
-                    android:text="00:00"
-                    android:textColor="@color/white"
-                    android:textSize="32sp" />
-
-                <ImageView
-                    android:id="@+id/sky_voice_call_hangup"
-                    android:layout_width="120dp"
-                    android:layout_height="120dp"
-                    android:layout_marginTop="20dp"
-                    android:src="@drawable/selector_call_hangup" />
-            </LinearLayout>
-
-            <!--来电-->
-            <LinearLayout
-                android:id="@+id/sky_voice_call_incoming"
-                android:layout_width="match_parent"
-                android:layout_height="140dp"
-                android:layout_alignParentBottom="true"
-                android:layout_centerHorizontal="true"
-                android:layout_marginBottom="120dp"
-                android:gravity="bottom"
-                android:orientation="horizontal"
-                android:visibility="gone">
-
-                <View
-                    android:layout_width="0dp"
-                    android:layout_height="1dp"
-                    android:layout_weight="2" />
-
-                <ImageView
-                    android:id="@+id/sky_voice_call_ring_reject"
-                    android:layout_width="100dp"
-                    android:layout_height="100dp"
-                    android:src="@drawable/selector_call_hangup" />
-
-                <View
-                    android:layout_width="0dp"
-                    android:layout_height="1dp"
-                    android:layout_weight="1" />
-
-                <ImageView
-                    android:id="@+id/sky_voice_call_ring_pickup_audio"
-                    android:layout_width="100dp"
-                    android:layout_height="100dp"
-                    android:src="@drawable/selector_call_answer" />
-
-                <View
-                    android:layout_width="0dp"
-                    android:layout_height="1dp"
-                    android:layout_weight="2" />
-            </LinearLayout>
-        </RelativeLayout>
-    </FrameLayout>
-</layout>