Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
YDL-Component-Medical
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
杨凯
YDL-Component-Medical
Commits
b5761291
Commit
b5761291
authored
Jun 15, 2022
by
刘鹏
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 倾诉2.0通话界面功能完成
parent
e7145ce2
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
101 additions
and
63 deletions
+101
-63
AudioHomeActivity.kt
m-audioim/src/main/java/com/ydl/audioim/AudioHomeActivity.kt
+99
-62
audiohome_hands_free_enable.png
m-audioim/src/main/res/drawable-xhdpi/audiohome_hands_free_enable.png
+0
-0
audioim_home_muteon_enable.png
m-audioim/src/main/res/drawable-xhdpi/audioim_home_muteon_enable.png
+0
-0
audioimhome_hang_up_enable.png
m-audioim/src/main/res/drawable-xhdpi/audioimhome_hang_up_enable.png
+0
-0
audioim_activity_audio_home.xml
m-audioim/src/main/res/layout/audioim_activity_audio_home.xml
+2
-1
audioim_audio_out_channel.mp3
m-audioim/src/main/res/raw/audioim_audio_out_channel.mp3
+0
-0
No files found.
m-audioim/src/main/java/com/ydl/audioim/AudioHomeActivity.kt
View file @
b5761291
...
...
@@ -395,9 +395,9 @@ class AudioHomeActivity :
YDLavManager
.
instances
.
callEndStatusUpdate
(
channelId
!!
,
4
,
"对方离开频道"
)
if
(
totalDisposable
!=
null
)
{
totalDisposable
!!
.
dispose
()
totalDisposable
?
.
dispose
()
}
handler
!!
.
postDelayed
({
handler
?
.
postDelayed
({
//另一方离开频道
updateExpertStatus
(
false
,
1
)
},
500
)
...
...
@@ -509,21 +509,21 @@ class AudioHomeActivity :
sensorManager
=
getSystemService
(
Context
.
SENSOR_SERVICE
)
as
SensorManager
?
localPowerManager
=
getSystemService
(
POWER_SERVICE
)
as
PowerManager
?
localWakeLock
=
localPowerManager
!!
.
newWakeLock
(
localWakeLock
=
localPowerManager
?
.
newWakeLock
(
PowerManager
.
PROXIMITY_SCREEN_OFF_WAKE_LOCK
,
"yidianling"
)
// 获取电源管理器对象
val
screenOn
=
localPowerManager
!!
.
isScreenOn
if
(
!
screenOn
)
{
val
screenOn
=
localPowerManager
?
.
isScreenOn
if
(
screenOn
==
false
)
{
// 获取PowerManager.WakeLock对象,后面的参数|表示同时传入两个值,最后的是LogCat里用的Tag
val
wl
=
localPowerManager
!!
.
newWakeLock
(
val
wl
=
localPowerManager
?
.
newWakeLock
(
PowerManager
.
ACQUIRE_CAUSES_WAKEUP
or
PowerManager
.
SCREEN_BRIGHT_WAKE_LOCK
,
"bright"
)
wl
.
acquire
(
10000
)
// 点亮屏幕
wl
.
release
()
// 释放
wl
?
.
acquire
(
10000
)
// 点亮屏幕
wl
?
.
release
()
// 释放
}
}
...
...
@@ -617,7 +617,8 @@ class AudioHomeActivity :
// tv_tips.text = expertTips
var
time
=
totalDuration
?.
minus
(
remainTime
!!
.
toInt
())
tv_remain_time
.
text
=
DateUtils
.
formatTime
((
time
).
toString
())
val
timeTotal
=
totalDuration
?.
div
(
60
);
tv_totalDuration
.
text
=
"(满${timeTotal}分钟自动挂断,限24小时内拨打)"
if
(!
TextUtils
.
isEmpty
(
expertHeadUrl
))
{
var
option
=
SimpleImageOpConfiger
()
option
.
errorPic
=
R
.
drawable
.
audioim_head_place_hold_pic
...
...
@@ -646,10 +647,14 @@ class AudioHomeActivity :
iv_mute_on_off
.
setImageResource
(
R
.
drawable
.
audiohome_muteoff
)
audio_mute_text
.
text
=
"麦克风已关"
voiceManage
?.
getVoiceApi
()
?.
enableLocalAudio
(
false
)
AliYunRichLogsHelper
.
getInstance
()
.
sendRichLog
(
AliYunLogConfig
.
AGORA
,
"用户端点击:麦克风已关"
)
}
else
{
iv_mute_on_off
.
isSelected
=
true
iv_mute_on_off
.
setImageResource
(
R
.
drawable
.
audiohome_muteon
)
audio_mute_text
.
text
=
"麦克风已开"
AliYunRichLogsHelper
.
getInstance
()
.
sendRichLog
(
AliYunLogConfig
.
AGORA
,
"用户端点击:麦克风已开"
)
voiceManage
?.
getVoiceApi
()
?.
enableLocalAudio
(
true
)
}
}
...
...
@@ -660,6 +665,8 @@ class AudioHomeActivity :
showHangUpTimeTraditionalDialog
()
return
@setOnClickListener
}
AliYunRichLogsHelper
.
getInstance
()
.
sendRichLog
(
AliYunLogConfig
.
AGORA
,
"用户端点击:切换线路"
)
ActionCountUtils
.
record
(
"call_phone_page"
,
"call_phone_icon_click"
,
"0"
,
"4"
)
showChooseDialog
(
1
)
...
...
@@ -667,6 +674,8 @@ class AudioHomeActivity :
//挂断
iv_hang_up
.
setOnClickListener
{
if
(!
canHangUp
)
{
AliYunRichLogsHelper
.
getInstance
()
.
sendRichLog
(
AliYunLogConfig
.
AGORA
,
"用户端点击:挂断,展示提示弹窗"
)
showHangUpTimeOnlineDialog
()
return
@setOnClickListener
}
...
...
@@ -702,20 +711,24 @@ class AudioHomeActivity :
iv_hands_free
.
isSelected
=
false
iv_hands_free
.
setImageResource
(
R
.
drawable
.
audioim_img_hands_free_unuse
)
hands_free_text
.
text
=
"扬声器已关"
AliYunRichLogsHelper
.
getInstance
()
.
sendRichLog
(
AliYunLogConfig
.
AGORA
,
"用户端点击:免提,扬声器已关"
)
}
else
{
iv_hands_free
.
isSelected
=
true
iv_hands_free
.
setImageResource
(
R
.
drawable
.
audioim_img_hands_free
)
hands_free_text
.
text
=
"扬声器已开"
AliYunRichLogsHelper
.
getInstance
()
.
sendRichLog
(
AliYunLogConfig
.
AGORA
,
"用户端点击:免提,扬声器已开"
)
}
//已经接通
if
(
isConnectSuccess
)
{
//是否开启外放
voiceManage
!!
.
getVoiceApi
()
.
setEnableSpeakerphone
(
iv_hands_free
.
isSelected
)
voiceManage
?.
getVoiceApi
()
?
.
setEnableSpeakerphone
(
iv_hands_free
.
isSelected
)
}
else
{
//未接通
if
(
mPlayer
!=
null
)
{
mPlayer
!!
.
switchPlayType
(
iv_hands_free
.
isSelected
)
mPlayer
?
.
switchPlayType
(
iv_hands_free
.
isSelected
)
}
}
}
...
...
@@ -815,15 +828,15 @@ class AudioHomeActivity :
}
private
fun
dismissHangUpTimeTraditionalDialog
()
{
if
(
mHangUpTimeTraditionalDialog
!=
null
&&
mHangUpTimeTraditionalDialog
!!
.
isShowing
)
{
mHangUpTimeTraditionalDialog
!!
.
dismiss
()
if
(
mHangUpTimeTraditionalDialog
!=
null
&&
mHangUpTimeTraditionalDialog
?.
isShowing
==
true
)
{
mHangUpTimeTraditionalDialog
?
.
dismiss
()
mHangUpTimeTraditionalDialog
=
null
}
}
private
fun
dismissHangUpTimeOnlineDialog
()
{
if
(
mHangUpTimeOnlineDialog
!=
null
&&
mHangUpTimeOnlineDialog
!!
.
isShowing
)
{
mHangUpTimeOnlineDialog
!!
.
dismiss
()
if
(
mHangUpTimeOnlineDialog
!=
null
&&
mHangUpTimeOnlineDialog
?.
isShowing
==
true
)
{
mHangUpTimeOnlineDialog
?
.
dismiss
()
mHangUpTimeOnlineDialog
=
null
}
}
...
...
@@ -888,12 +901,12 @@ class AudioHomeActivity :
waittingStatus
()
}
else
{
tv_change_time_counter
.
text
=
"转传统电话(${remainTime}s)"
if
(
mHangUpTimeTraditionalDialog
!=
null
&&
mHangUpTimeTraditionalDialog
!!
.
isShowing
)
{
if
(
mHangUpTimeTraditionalDialog
!=
null
&&
mHangUpTimeTraditionalDialog
?.
isShowing
==
true
)
{
val
callTime
=
String
.
format
(
getString
(
R
.
string
.
audioim_audio_time_alarm_msg_tradition_dialog
),
traditionCallTime
)
(
mHangUpTimeTraditionalDialog
!!
.
findDialogView
(
R
.
id
.
third_title
)
as
TextView
).
text
=
(
mHangUpTimeTraditionalDialog
?
.
findDialogView
(
R
.
id
.
third_title
)
as
TextView
).
text
=
callTime
}
}
...
...
@@ -904,12 +917,12 @@ class AudioHomeActivity :
dismissHangUpTimeOnlineDialog
()
}
else
{
audio_hangup_text
.
text
=
"挂断(${remainTime - 20}s)"
if
(
mHangUpTimeOnlineDialog
!=
null
&&
mHangUpTimeOnlineDialog
!!
.
isShowing
)
{
if
(
mHangUpTimeOnlineDialog
!=
null
&&
mHangUpTimeOnlineDialog
?.
isShowing
==
true
)
{
val
callTime
=
String
.
format
(
getString
(
R
.
string
.
audioim_audio_time_alarm_msg_online_dialog
),
onlineCallTime
)
(
mHangUpTimeOnlineDialog
!!
.
findDialogView
(
R
.
id
.
third_title
)
as
TextView
).
text
=
(
mHangUpTimeOnlineDialog
?
.
findDialogView
(
R
.
id
.
third_title
)
as
TextView
).
text
=
callTime
}
}
...
...
@@ -991,7 +1004,7 @@ class AudioHomeActivity :
* param mRtcEventHandler 事件回调(SDK 通过指定的事件通知应用程序 SDK 的运行事件,如: 加入或离开频道,新用户加入频道等)
*/
voiceManage
=
YDLVoiceManager
(
this
,
BuildConfig
.
AGORA_APPID
,
mRtcEventHandler
)
voiceManage
!!
.
init
()
voiceManage
?
.
init
()
}
/**
...
...
@@ -1003,7 +1016,7 @@ class AudioHomeActivity :
writeAgoraLog
(
"对方(专家)接受了通话邀请,主叫(用户)开始加入频道:$channelId"
)
AliYunRichLogsHelper
.
getInstance
()
.
sendRichLog
(
AliYunLogConfig
.
AGORA
,
"对方(专家)接受了通话邀请,主叫(用户)开始加入频道:$channelId"
)
voiceManage
!!
.
getVoiceApi
()
.
joinChannel
(
voiceManage
?.
getVoiceApi
()
?
.
joinChannel
(
token
!!
,
channelId
!!
,
"Extra Optional Data"
,
...
...
@@ -1037,7 +1050,7 @@ class AudioHomeActivity :
}
//通话结束或挂断时,上传日志文件
uploadLog
()
handler
!!
.
postDelayed
({
handler
?
.
postDelayed
({
LogUtil
.
e
(
"离开频道"
)
leaveChannel
()
},
100
)
...
...
@@ -1180,9 +1193,9 @@ class AudioHomeActivity :
mPlayer
=
AudioPlayer
(
this
)
}
if
((
Math
.
random
()
*
10
+
1
).
toInt
()
>=
5
)
{
mPlayer
!!
.
setTwoDataAndStart
(
R
.
raw
.
audioim_audio_music_1
,
R
.
raw
.
audioim_loop_music
)
mPlayer
?
.
setTwoDataAndStart
(
R
.
raw
.
audioim_audio_music_1
,
R
.
raw
.
audioim_loop_music
)
}
else
{
mPlayer
!!
.
setTwoDataAndStart
(
R
.
raw
.
audioim_audio_music_2
,
R
.
raw
.
audioim_loop_music
)
mPlayer
?
.
setTwoDataAndStart
(
R
.
raw
.
audioim_audio_music_2
,
R
.
raw
.
audioim_loop_music
)
}
}
...
...
@@ -1193,12 +1206,12 @@ class AudioHomeActivity :
if
(
mPlayer
==
null
)
{
mPlayer
=
AudioPlayer
(
this
)
}
mPlayer
!!
.
setDataSource
(
R
.
raw
.
audioim_hand_down_music
)
mPlayer
!!
.
switchPlayType
(
iv_hands_free
.
isSelected
)
mPlayer
!!
.
setCompletionListener
(
MediaPlayer
.
OnCompletionListener
{
mPlayer
?
.
setDataSource
(
R
.
raw
.
audioim_hand_down_music
)
mPlayer
?
.
switchPlayType
(
iv_hands_free
.
isSelected
)
mPlayer
?
.
setCompletionListener
(
MediaPlayer
.
OnCompletionListener
{
LogUtil
.
e
(
"播放结束"
)
//通话剩余时间不足60s时,默认
if
(
localRemainTime
!!
>
(
totalDuration
?:
1500
).
minus
(
60
)
&&
!
TextUtils
.
isEmpty
(
if
(
localRemainTime
!!
<=
60
&&
!
TextUtils
.
isEmpty
(
commentUrl
)
)
{
...
...
@@ -1211,7 +1224,7 @@ class AudioHomeActivity :
}
finish
()
})
mPlayer
!!
.
start
(
false
,
true
)
mPlayer
?
.
start
(
false
,
true
)
}
/**
...
...
@@ -1219,7 +1232,7 @@ class AudioHomeActivity :
*/
private
fun
stopPlaying
()
{
if
(
mPlayer
!=
null
)
{
mPlayer
!!
.
pause
()
mPlayer
?
.
pause
()
}
}
...
...
@@ -1231,19 +1244,25 @@ class AudioHomeActivity :
phoneHandler
?.
removeCallbacksAndMessages
(
null
)
//通知服务端,此次通话已经接通,服务端开始订单
updateExpertStatus
(
false
,
0
)
rl_mute_on_off
.
isClickable
=
true
//是否开启外放
voiceManage
!!
.
getVoiceApi
().
setEnableSpeakerphone
(
false
)
voiceManage
?.
getVoiceApi
()
?.
setEnableSpeakerphone
(
false
)
if
(
iv_mute_on_off
.
isSelected
)
{
iv_mute_on_off
.
setImageResource
(
R
.
drawable
.
audiohome_muteoff
)
audio_mute_text
.
text
=
"麦克风已关"
}
else
{
iv_mute_on_off
.
isSelected
=
true
iv_mute_on_off
.
setImageResource
(
R
.
drawable
.
audiohome_muteon
)
audio_mute_text
.
text
=
"麦克风已开"
}
hands_free_text
.
text
=
"扬声器已关"
iv_hands_free
.
isSelected
=
false
iv_hands_free
.
setImageResource
(
R
.
drawable
.
audioim_img_hands_free_unuse
)
if
(
disposable
!=
null
)
{
disposable
!!
.
dispose
()
}
disposable
?.
dispose
()
stopPlaying
()
vibrator
!!
.
vibrate
(
1000
)
vibrator
?
.
vibrate
(
1000
)
//等待状态的相关ui隐藏(挂断按钮的倒计时不清除,挂断按钮必须在30s后才能点击)
tv_change_doctor
.
visibility
=
View
.
GONE
...
...
@@ -1262,10 +1281,17 @@ class AudioHomeActivity :
.
take
(
remainTime
!!
.
toLong
()
+
1
)
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
subscribe
({
localRemainTime
=
(
totalDuration
?:
1500
).
minus
(
remainTime
!!
.
toInt
()).
plus
(
it
.
toInt
())
localRemainTime
=
remainTime
!!
.
toInt
().
minus
(
it
.
toInt
())
if
(
localRemainTime
!!
>=
(
totalDuration
?:
1500
).
minus
(
60
))
{
if
(
localRemainTime
==
180
)
{
//三分钟语音播报
playNoticeMusic
(
3
)
}
if
(
localRemainTime
==
60
)
{
//一分钟语音播报
playNoticeMusic
(
1
)
}
if
(
localRemainTime
!!
<=
60
)
{
if
(
canChangeRoute
)
{
canChangeRoute
=
false
}
...
...
@@ -1277,7 +1303,6 @@ class AudioHomeActivity :
leaveChannel
()
uploadLog
()
callEventSave
(
"50"
,
"倾诉时间已用完"
)
YDLavManager
.
instances
.
callEndStatusUpdate
(
channelId
!!
,
3
,
"倾诉时间已用完"
)
//注意:自动挂断时,如果对方离开频道的回调已经触发,就不要再重复调用接口
showToast
(
"通话已结束"
)
...
...
@@ -1296,13 +1321,24 @@ class AudioHomeActivity :
if
(
mPlayer
==
null
)
{
mPlayer
=
AudioPlayer
(
this
)
}
if
(
3
==
min
)
{
mPlayer
!!
.
setDataSource
(
R
.
raw
.
audioim_last_3_min
)
}
else
{
mPlayer
!!
.
setDataSource
(
R
.
raw
.
audioim_last_1_min
)
when
(
min
)
{
0
->
{
//结束音
mPlayer
?.
setDataSource
(
R
.
raw
.
audioim_audio_out_channel
)
}
1
->
{
//1分钟提示
mPlayer
?.
setDataSource
(
R
.
raw
.
audioim_last_1_min
)
}
3
->
{
//3分钟提示
mPlayer
?.
setDataSource
(
R
.
raw
.
audioim_last_3_min
)
}
}
mPlayer
!!
.
switchPlayType
(
iv_hands_free
.
isSelected
)
mPlayer
!!
.
start
(
false
,
false
)
mPlayer
?.
switchPlayType
(
iv_hands_free
.
isSelected
)
mPlayer
?.
start
(
false
,
false
)
}
/**
...
...
@@ -1347,6 +1383,7 @@ class AudioHomeActivity :
LogUtil
.
e
(
"调用leaveChannel方法,isLeavelChannel=$isLeavelChannel"
)
if
(!
isLeavelChannel
)
{
isLeavelChannel
=
true
playNoticeMusic
(
0
)
//刷新h5页面
EventBus
.
getDefault
().
post
(
RefreshWebEvent
(
false
))
stopPlaying
()
...
...
@@ -1358,9 +1395,9 @@ class AudioHomeActivity :
override
fun
onResume
()
{
super
.
onResume
()
sensorManager
!!
.
registerListener
(
sensorManager
?
.
registerListener
(
this
,
sensorManager
!!
.
getDefaultSensor
(
Sensor
.
TYPE_PROXIMITY
),
sensorManager
?
.
getDefaultSensor
(
Sensor
.
TYPE_PROXIMITY
),
SensorManager
.
SENSOR_DELAY_NORMAL
)
ActionCountUtils
.
count
(
...
...
@@ -1379,14 +1416,14 @@ class AudioHomeActivity :
Sensor
.
TYPE_PROXIMITY
->
{
if
(
values
[
0
]
==
0.0f
)
{
//贴近手机
if
(
!
localWakeLock
!!
.
isHeld
)
{
localWakeLock
!!
.
acquire
()
if
(
localWakeLock
?.
isHeld
==
false
)
{
localWakeLock
?
.
acquire
()
}
}
else
{
//离开手机
//唤醒设备
if
(
localWakeLock
!!
.
isHeld
)
{
localWakeLock
!!
.
release
()
if
(
localWakeLock
?.
isHeld
==
true
)
{
localWakeLock
?
.
release
()
}
}
}
...
...
@@ -1520,33 +1557,33 @@ class AudioHomeActivity :
hasUpLoadLog
=
false
if
(
waitDisposable
!=
null
)
{
waitDisposable
!!
.
dispose
()
waitDisposable
?
.
dispose
()
}
if
(
disposable
!=
null
)
{
disposable
!!
.
dispose
()
disposable
?
.
dispose
()
}
if
(
totalDisposable
!=
null
)
{
totalDisposable
!!
.
dispose
()
totalDisposable
?
.
dispose
()
}
if
(
sensorManager
!=
null
)
{
sensorManager
!!
.
unregisterListener
(
this
)
sensorManager
?
.
unregisterListener
(
this
)
}
//唤醒设备
if
(
localWakeLock
!=
null
&&
localWakeLock
!!
.
isHeld
)
{
localWakeLock
!!
.
release
()
localWakeLock
?
.
release
()
}
sensorManager
=
null
localWakeLock
=
null
localPowerManager
=
null
if
(
null
!=
voiceManage
&&
null
!=
voiceManage
!!
.
getVoiceApi
())
{
voiceManage
!!
.
getVoiceApi
()
.
leaveChannel
()
voiceManage
!!
.
getVoiceApi
()
.
destroy
()
if
(
null
!=
voiceManage
&&
null
!=
voiceManage
?
.
getVoiceApi
())
{
voiceManage
?.
getVoiceApi
()
?
.
leaveChannel
()
voiceManage
?.
getVoiceApi
()
?
.
destroy
()
voiceManage
=
null
}
if
(
mPlayer
!=
null
)
{
mPlayer
!!
.
clear
()
mPlayer
?
.
clear
()
mPlayer
=
null
}
}
...
...
m-audioim/src/main/res/drawable-xhdpi/audiohome_hands_free_enable.png
0 → 100644
View file @
b5761291
4.42 KB
m-audioim/src/main/res/drawable-xhdpi/audioim_home_muteon_enable.png
0 → 100644
View file @
b5761291
3.92 KB
m-audioim/src/main/res/drawable-xhdpi/audioimhome_hang_up_enable.png
0 → 100644
View file @
b5761291
3.65 KB
m-audioim/src/main/res/layout/audioim_activity_audio_home.xml
View file @
b5761291
...
...
@@ -129,6 +129,7 @@
app:layout_constraintTop_toTopOf=
"parent"
/>
<TextView
android:id=
"@+id/tv_totalDuration"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_below=
"@+id/tv_notes"
...
...
@@ -232,7 +233,7 @@
android:layout_width=
"66dp"
android:layout_height=
"66dp"
android:layout_marginTop=
"1dp"
android:src=
"@drawable/audio
home_muteon
"
android:src=
"@drawable/audio
im_home_muteon_enable
"
android:visibility=
"visible"
/>
<TextView
...
...
m-audioim/src/main/res/raw/audioim_audio_out_channel.mp3
0 → 100644
View file @
b5761291
File added
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment