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
691f4ad3
Commit
691f4ad3
authored
May 31, 2022
by
fengquan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix bug 通话界面弹框提醒
parent
143a5d99
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
216 additions
and
30 deletions
+216
-30
AudioHomeActivity.kt
m-audioim/src/main/java/com/ydl/audioim/AudioHomeActivity.kt
+154
-30
ZDialog.java
m-audioim/src/main/java/com/ydl/audioim/widget/ZDialog.java
+6
-0
audioim_activity_time_alarm_dialog.xml
m-audioim/src/main/res/layout/audioim_activity_time_alarm_dialog.xml
+53
-0
strings.xml
m-audioim/src/main/res/values/strings.xml
+3
-0
No files found.
m-audioim/src/main/java/com/ydl/audioim/AudioHomeActivity.kt
View file @
691f4ad3
...
...
@@ -18,6 +18,7 @@ import android.text.TextUtils
import
android.view.View
import
android.view.WindowManager
import
android.view.animation.AccelerateInterpolator
import
android.widget.TextView
import
androidx.core.content.ContextCompat
import
com.alibaba.android.arouter.facade.annotation.Route
import
com.alibaba.android.arouter.launcher.ARouter
...
...
@@ -49,6 +50,7 @@ import com.ydl.ydlcommon.base.BaseMvpActivity
import
com.ydl.ydlcommon.modular.ModularServiceManager
import
com.ydl.ydlcommon.router.YdlCommonRouterManager
import
com.ydl.ydlcommon.utils.LogUtil
import
com.ydl.ydlcommon.utils.ScreenUtil
import
com.ydl.ydlcommon.utils.StatusBarUtils
import
com.ydl.ydlcommon.utils.Utils
import
com.ydl.ydlcommon.utils.actionutil.ActionCountUtils
...
...
@@ -152,6 +154,16 @@ class AudioHomeActivity :
private
var
localRemainTime
:
Int
?
=
0
/**
* 挂断电话需要等待时间
*/
private
var
onlineCallTime
:
Long
?
=
0
/**
* 跳转传统电话需要等待时间
*/
private
var
traditionCallTime
:
Long
?
=
0
/**
* 50s自动挂断倒计时
*/
private
var
waitDisposable
:
Disposable
?
=
null
...
...
@@ -192,7 +204,6 @@ class AudioHomeActivity :
private
var
voiceManage
:
YDLVoiceManager
?
=
null
//频道管理器
// private var channelManager: ChannelManager? = null
...
...
@@ -208,6 +219,14 @@ class AudioHomeActivity :
private
var
mStorageDialog
:
ZDialog
?
=
null
private
var
mHangUpTimeTraditionalDialog
:
ZDialog
?
=
null
private
var
mHangUpTimeOnlineDialog
:
ZDialog
?
=
null
private
var
canHangUp
:
Boolean
=
false
private
var
canChangeRoute
:
Boolean
=
false
/**
* 声网事件回调 (SDK 通过指定的事件通知应用程序 SDK 的运行事件,如: 加入或离开频道,新用户加入频道等)
*/
...
...
@@ -231,6 +250,7 @@ class AudioHomeActivity :
// 声网发出警告错误码,不应该直接离开房间
}
/**
* https://docs.agora.io/cn/Voice/API%20Reference/java/classio_1_1agora_1_1rtc_1_1_i_rtc_engine_event_handler_1_1_error_code.html
* */
...
...
@@ -316,6 +336,7 @@ class AudioHomeActivity :
// leaveChannel()
// }
}
/**
* https://docs.agora.io/cn/Voice/API%20Reference/java/classio_1_1agora_1_1rtc_1_1_i_rtc_engine_event_handler.html#a31b2974a574ec45e62bb768e17d1f49e
* */
...
...
@@ -383,7 +404,6 @@ class AudioHomeActivity :
},
500
)
}
...
...
@@ -542,7 +562,7 @@ class AudioHomeActivity :
writeAgoraLog
(
"主叫方发送的邀请通话消息内容:$content"
,
true
)
AliYunRichLogsHelper
.
getInstance
()
.
sendRichLog
(
AliYunLogConfig
.
AGORA
,
"主叫方发送的邀请通话消息内容:$content"
)
localRemainTime
=
(
totalDuration
?:
1500
).
minus
(
remainTime
?.
toInt
()
?:
1500
)
localRemainTime
=
(
totalDuration
?:
1500
).
minus
(
remainTime
?.
toInt
()
?:
1500
)
handler
=
Handler
()
vibrator
=
getSystemService
(
Service
.
VIBRATOR_SERVICE
)
as
Vibrator
?
...
...
@@ -550,9 +570,9 @@ class AudioHomeActivity :
var
count
=
0
phoneHandler
?.
postDelayed
(
object
:
Runnable
{
override
fun
run
()
{
if
(
count
%
2
==
0
)
{
if
(
count
%
2
==
0
)
{
tv_tips
.
text
=
"正在发送倾诉请求…"
}
else
{
}
else
{
tv_tips
.
text
=
"正在等待聆听者接受邀请…"
}
count
++
...
...
@@ -582,7 +602,6 @@ class AudioHomeActivity :
writeAgoraLog
(
"用户拨打电话界面开启"
)
AliYunRichLogsHelper
.
getInstance
()
.
sendRichLog
(
AliYunLogConfig
.
AGORA
,
"用户拨打电话界面开启"
)
ll_changeRoute
.
isEnabled
=
false
//水波纹view初始化
wave_view
.
setDuration
(
6000
)
wave_view
.
setStyle
(
Paint
.
Style
.
STROKE
)
...
...
@@ -591,7 +610,7 @@ class AudioHomeActivity :
wave_view
.
setInitialRadius
(
140f
)
wave_view
.
setInterpolator
(
AccelerateInterpolator
(
1.2f
))
//挂断按钮默认不可点击
iv_hang_up
.
isEnabled
=
false
//设置默认关闭扬声器
iv_hands_free
.
isSelected
=
false
...
...
@@ -626,22 +645,32 @@ class AudioHomeActivity :
if
(
iv_mute_on_off
.
isSelected
)
{
iv_mute_on_off
.
isSelected
=
false
iv_mute_on_off
.
setImageResource
(
R
.
drawable
.
audiohome_muteoff
)
audio_mute_text
.
text
=
"麦克风已关"
audio_mute_text
.
text
=
"麦克风已关"
voiceManage
?.
getVoiceApi
()
?.
enableLocalAudio
(
false
)
}
else
{
iv_mute_on_off
.
isSelected
=
true
iv_mute_on_off
.
setImageResource
(
R
.
drawable
.
audiohome_muteon
)
audio_mute_text
.
text
=
"麦克风已开"
audio_mute_text
.
text
=
"麦克风已开"
voiceManage
?.
getVoiceApi
()
?.
enableLocalAudio
(
true
)
}
}
//切换线路
ll_changeRoute
.
setOnClickListener
{
if
(!
canChangeRoute
)
{
showHangUpTimeTraditionalDialog
()
return
@setOnClickListener
}
ActionCountUtils
.
record
(
"call_phone_page"
,
"call_phone_icon_click"
,
"0"
,
"4"
)
showChooseDialog
(
1
)
}
//挂断
iv_hang_up
.
setOnClickListener
{
if
(!
canHangUp
)
{
showHangUpTimeOnlineDialog
()
return
@setOnClickListener
}
if
(
Utils
.
isFastClick
())
{
//防止连击
return
@setOnClickListener
...
...
@@ -738,19 +767,20 @@ class AudioHomeActivity :
}
}
private
fun
showStorageDialog
()
{
if
(
mStorageDialog
==
null
)
{
mStorageDialog
=
ZDialog
.
Builder
(
this
)
.
setContentView
(
R
.
layout
.
audioim_activity_permission_dialog
)
.
setOnClickListener
(
R
.
id
.
cancel_dialog
)
{
mStorageDialog
?.
dismiss
()
mStorageDialog
=
null
mStorageDialog
=
null
finish
()
}
.
setAnimation
(
0
)
//取消动画
.
setOnClickListener
(
R
.
id
.
dial_right_now
)
{
mStorageDialog
?.
dismiss
()
mStorageDialog
=
null
mStorageDialog
=
null
finish
()
val
intent
=
Intent
(
Settings
.
ACTION_APPLICATION_DETAILS_SETTINGS
)
val
uri
=
Uri
.
fromParts
(
"package"
,
packageName
,
null
)
...
...
@@ -760,6 +790,66 @@ class AudioHomeActivity :
.
show
()
}
}
private
fun
showHangUpTimeTraditionalDialog
()
{
if
(
mHangUpTimeTraditionalDialog
==
null
)
{
mHangUpTimeTraditionalDialog
=
ZDialog
.
Builder
(
this
)
.
setContentView
(
R
.
layout
.
audioim_activity_time_alarm_dialog
)
.
setOnClickListener
(
R
.
id
.
dial_right_now
)
{
mHangUpTimeTraditionalDialog
?.
dismiss
()
mHangUpTimeTraditionalDialog
=
null
}
.
setCancelAble
(
false
)
.
setAnimation
(
0
)
//取消动画
.
width
((
resources
.
displayMetrics
.
widthPixels
*
0.8f
).
toInt
())
.
show
()
val
text
=
String
.
format
(
getString
(
R
.
string
.
audioim_audio_time_alarm_msg_tradition_dialog
),
traditionCallTime
)
(
mHangUpTimeTraditionalDialog
?.
findDialogView
(
R
.
id
.
third_title
)
as
TextView
).
text
=
text
}
}
private
fun
dismissHangUpTimeTraditionalDialog
()
{
if
(
mHangUpTimeTraditionalDialog
!=
null
&&
mHangUpTimeTraditionalDialog
!!
.
isShowing
)
{
mHangUpTimeTraditionalDialog
!!
.
dismiss
()
mHangUpTimeTraditionalDialog
=
null
}
}
private
fun
dismissHangUpTimeOnlineDialog
()
{
if
(
mHangUpTimeOnlineDialog
!=
null
&&
mHangUpTimeOnlineDialog
!!
.
isShowing
)
{
mHangUpTimeOnlineDialog
!!
.
dismiss
()
mHangUpTimeOnlineDialog
=
null
}
}
private
fun
showHangUpTimeOnlineDialog
()
{
if
(
mHangUpTimeOnlineDialog
==
null
)
{
mHangUpTimeOnlineDialog
=
ZDialog
.
Builder
(
this
)
.
setContentView
(
R
.
layout
.
audioim_activity_time_alarm_dialog
)
.
setOnClickListener
(
R
.
id
.
dial_right_now
)
{
mHangUpTimeOnlineDialog
?.
dismiss
()
mHangUpTimeOnlineDialog
=
null
}
.
setCancelAble
(
false
)
.
setAnimation
(
0
)
//取消动画
.
width
((
resources
.
displayMetrics
.
widthPixels
*
0.8f
).
toInt
())
.
show
()
val
text
=
String
.
format
(
getString
(
R
.
string
.
audioim_audio_time_alarm_msg_online_dialog
),
onlineCallTime
)
(
mHangUpTimeOnlineDialog
?.
findDialogView
(
R
.
id
.
third_title
)
as
TextView
).
text
=
text
}
}
@SuppressLint
(
"CheckResult"
,
"SetTextI18n"
)
private
fun
init
()
{
wave_view
.
start
()
...
...
@@ -773,7 +863,7 @@ class AudioHomeActivity :
YdlCommonRouterManager
.
getYdlCommonRoute
().
getUserInfo
()
!!
.
headUrl
,
YdlCommonRouterManager
.
getYdlCommonRoute
().
getUserInfo
()
!!
.
userName
,
remainTime
!!
.
toInt
(),
totalDuration
?:
1500
,
totalDuration
?:
1500
,
relationId
,
callId
,
null
,
...
...
@@ -791,23 +881,43 @@ class AudioHomeActivity :
Observable
.
interval
(
0
,
100
,
TimeUnit
.
MILLISECONDS
).
subscribeOn
(
Schedulers
.
computation
())
.
take
(
600
).
observeOn
(
AndroidSchedulers
.
mainThread
()).
subscribe
({
val
remainTime
=
50
-
it
/
10
traditionCallTime
=
remainTime
if
(
remainTime
<=
0
)
{
dismissHangUpTimeTraditionalDialog
()
waittingStatus
()
}
else
{
tv_change_time_counter
.
text
=
"转传统电话(${remainTime}s)"
if
(
mHangUpTimeTraditionalDialog
!=
null
&&
mHangUpTimeTraditionalDialog
!!
.
isShowing
)
{
val
callTime
=
String
.
format
(
getString
(
R
.
string
.
audioim_audio_time_alarm_msg_tradition_dialog
),
traditionCallTime
)
(
mHangUpTimeTraditionalDialog
!!
.
findDialogView
(
R
.
id
.
third_title
)
as
TextView
).
text
=
callTime
}
}
onlineCallTime
=
remainTime
-
20
if
(
remainTime
<=
20
)
{
audio_hangup_text
.
text
=
"挂断"
dismissHangUpTimeOnlineDialog
()
}
else
{
audio_hangup_text
.
text
=
"挂断(${remainTime - 20}s)"
if
(
mHangUpTimeOnlineDialog
!=
null
&&
mHangUpTimeOnlineDialog
!!
.
isShowing
)
{
val
callTime
=
String
.
format
(
getString
(
R
.
string
.
audioim_audio_time_alarm_msg_online_dialog
),
onlineCallTime
)
(
mHangUpTimeOnlineDialog
!!
.
findDialogView
(
R
.
id
.
third_title
)
as
TextView
).
text
=
callTime
}
if
(
remainTime
<=
20
){
audio_hangup_text
.
text
=
"挂断"
}
else
{
audio_hangup_text
.
text
=
"挂断(${remainTime-20}s)"
}
var
result
=
it
.
toFloat
()
/
3f
var
result
=
it
.
toFloat
()
/
3f
progress_view
.
setProgress
(
result
)
if
(
result
>=
100f
&&
!
iv_hang_up
.
isEnabled
)
{
audio_hangup_text
.
text
=
"挂断"
if
(
result
>=
100f
&&
!
canHangUp
)
{
audio_hangup_text
.
text
=
"挂断"
//挂断按钮可点击
iv_hang_up
.
isEnabled
=
true
canHangUp
=
true
iv_hang_up
.
setImageResource
(
R
.
drawable
.
audioim_img_hang_up
)
}
...
...
@@ -817,10 +927,20 @@ class AudioHomeActivity :
LogUtil
.
d
(
it
.
message
)
AliYunRichLogsHelper
.
getInstance
()
.
sendRichLog
(
AliYunLogConfig
.
AGORA
,
"倒计时异常${it.message}"
)
dismissHangUpTimeOnlineDialog
()
dismissHangUpTimeTraditionalDialog
()
})
{
// waittingStatus()
if
(!
isConnectSuccess
)
{
//关闭音乐
dismissHangUpTimeOnlineDialog
()
dismissHangUpTimeTraditionalDialog
()
stopPlaying
()
callEventSave
(
"34"
,
"未接通挂断:50s等待倒计时结束挂断"
)
...
...
@@ -1034,7 +1154,7 @@ class AudioHomeActivity :
private
fun
waittingStatus
()
{
tv_change_time_counter
.
visibility
=
View
.
GONE
//挂断按钮可点击
iv_hang_up
.
isEnabled
=
true
canHangUp
=
true
iv_hang_up
.
setImageResource
(
R
.
drawable
.
audioim_img_hang_up
)
// if (!isConnectSuccess) {
// //页面等待文案调整
...
...
@@ -1046,7 +1166,7 @@ class AudioHomeActivity :
ll_changeRoute
.
visibility
=
View
.
GONE
}
else
{
//切换线路按钮可见
ll_changeRoute
.
isEnabled
=
true
canChangeRoute
=
true
}
}
...
...
@@ -1077,7 +1197,10 @@ class AudioHomeActivity :
mPlayer
!!
.
setCompletionListener
(
MediaPlayer
.
OnCompletionListener
{
LogUtil
.
e
(
"播放结束"
)
//通话剩余时间不足60s时,默认
if
(
localRemainTime
!!
>
(
totalDuration
?:
1500
).
minus
(
60
)
&&
!
TextUtils
.
isEmpty
(
commentUrl
))
{
if
(
localRemainTime
!!
>
(
totalDuration
?:
1500
).
minus
(
60
)
&&
!
TextUtils
.
isEmpty
(
commentUrl
)
)
{
val
h5Params
=
H5Params
(
commentUrl
!!
,
"评价"
)
NewH5Activity
.
start
(
this
@AudioHomeActivity
,
h5Params
)
}
...
...
@@ -1139,11 +1262,12 @@ class AudioHomeActivity :
.
take
(
remainTime
!!
.
toLong
()
+
1
)
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
subscribe
({
localRemainTime
=
(
totalDuration
?:
1500
).
minus
(
remainTime
!!
.
toInt
()).
plus
(
it
.
toInt
())
localRemainTime
=
(
totalDuration
?:
1500
).
minus
(
remainTime
!!
.
toInt
()).
plus
(
it
.
toInt
())
if
(
localRemainTime
!!
>=
(
totalDuration
?:
1500
).
minus
(
60
))
{
if
(
ll_changeRoute
.
isEnabled
)
{
ll_changeRoute
.
isEnabled
=
false
if
(
localRemainTime
!!
>=
(
totalDuration
?:
1500
).
minus
(
60
))
{
if
(
canChangeRoute
)
{
canChangeRoute
=
false
}
}
tv_remain_time
.
text
=
DateUtils
.
formatTime
(
localRemainTime
.
toString
())
...
...
@@ -1195,7 +1319,7 @@ class AudioHomeActivity :
YdlCommonRouterManager
.
getYdlCommonRoute
().
getUserInfo
()
!!
.
headUrl
,
YdlCommonRouterManager
.
getYdlCommonRoute
().
getUserInfo
()
!!
.
userName
,
remainTime
!!
.
toInt
(),
totalDuration
?:
1500
,
totalDuration
?:
1500
,
relationId
,
callId
,
null
,
...
...
@@ -1388,7 +1512,7 @@ class AudioHomeActivity :
handler
=
null
}
if
(
phoneHandler
!=
null
){
if
(
phoneHandler
!=
null
)
{
phoneHandler
=
null
}
...
...
@@ -1443,7 +1567,7 @@ class AudioHomeActivity :
session
:
String
?
=
channelId
,
line
:
String
=
"7"
)
{
YDLavManager
.
instances
.
callEventSave
(
status
,
res
,
session
,
line
)
YDLavManager
.
instances
.
callEventSave
(
status
,
res
,
session
,
line
)
}
private
fun
onStartCall
()
{
...
...
m-audioim/src/main/java/com/ydl/audioim/widget/ZDialog.java
View file @
691f4ad3
...
...
@@ -2,6 +2,7 @@ package com.ydl.audioim.widget;
import
android.app.Dialog
;
import
android.content.Context
;
import
android.os.Build
;
import
android.view.Gravity
;
import
android.view.View
;
import
android.view.ViewGroup
;
...
...
@@ -123,6 +124,11 @@ public class ZDialog extends Dialog {
return
this
;
}
public
Builder
width
(
int
width
){
mDialogParams
.
defaultWidth
=
width
;
return
this
;
}
public
Builder
setGravity
(
@ZDialogDirection
.
ZGravity
int
direction
)
{
switch
(
direction
)
{
case
ZDialogDirection
.
FROM_TOP
:
...
...
m-audioim/src/main/res/layout/audioim_activity_time_alarm_dialog.xml
0 → 100644
View file @
691f4ad3
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
xmlns:tools=
"http://schemas.android.com/tools"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_marginStart=
"@dimen/platform_dp_38"
android:layout_marginLeft=
"@dimen/platform_dp_38"
android:layout_marginEnd=
"@dimen/platform_dp_38"
android:background=
"@drawable/shape_bg_white_fillet8"
app:layout_goneMarginEnd=
"@dimen/platform_dp_38"
>
<TextView
android:id=
"@+id/third_title"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"@dimen/platform_dp_20"
android:textColor=
"@color/platform_color_242424"
android:textSize=
"15sp"
app:layout_constraintLeft_toLeftOf=
"parent"
app:layout_constraintRight_toRightOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
tools:layout_editor_absoluteY=
"85dp"
/>
<View
android:id=
"@+id/line"
android:layout_width=
"match_parent"
android:layout_height=
"0.5dp"
android:layout_marginTop=
"@dimen/platform_dp_28"
android:background=
"@color/platform_color_D8D8D8"
app:layout_constraintTop_toBottomOf=
"@id/third_title"
/>
<LinearLayout
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:orientation=
"horizontal"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@id/line"
>
<TextView
android:id=
"@+id/dial_right_now"
android:layout_width=
"match_parent"
android:layout_height=
"@dimen/platform_dp_48"
android:gravity=
"center"
android:text=
"@string/audioim_got_it"
android:textColor=
"@color/platform_color_1DA1F2"
android:textSize=
"17sp"
/>
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
m-audioim/src/main/res/values/strings.xml
View file @
691f4ad3
<resources>
<string
name=
"audioim_need_storage_permission_hint"
>
App正常工作需要内部存储使用权限,请开启
</string>
<string
name=
"audioim_got_it"
>
知道了
</string>
<string
name=
"audioim_audio_time_alarm_msg_tradition_dialog"
>
请等待 %s 秒后,点击跳转传统电话
</string>
<string
name=
"audioim_audio_time_alarm_msg_online_dialog"
>
请等待 %s 秒后,点击挂断
</string>
</resources>
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