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
0804dda8
Commit
0804dda8
authored
Apr 24, 2022
by
upwork.021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 通话页面ui和逻辑编写优化,通话组件升级
parent
f02775dc
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
421 additions
and
70 deletions
+421
-70
AndroidManifest.xml
app/src/main/AndroidManifest.xml
+1
-1
config.gradle
config.gradle
+1
-1
AndroidManifest.xml
ydl-tuicore/src/main/AndroidManifest.xml
+7
-2
LoginTUI.kt
ydl-tuicore/src/main/java/com/tencent/qcloud/tuicore/calling/login/LoginTUI.kt
+1
-1
TRTCCalling.java
ydl-tuicore/src/main/java/com/tencent/qcloud/tuicore/calling/trtccalling/model/TRTCCalling.java
+5
-3
VideoCallingActivity.java
ydl-tuicore/src/main/java/com/tencent/qcloud/tuicore/calling/videocall/VideoCallingActivity.java
+179
-55
YDLInvitionActivity.java
ydl-tuicore/src/main/java/com/tencent/qcloud/tuicore/calling/videocall/YDLInvitionActivity.java
+4
-0
StatusBarUtil.java
ydl-tuicore/src/main/java/com/tencent/qcloud/tuicore/util/StatusBarUtil.java
+162
-0
videocall_activity_calling.xml
ydl-tuicore/src/main/res/layout/videocall_activity_calling.xml
+51
-7
styles.xml
ydl-tuicore/src/main/res/values/styles.xml
+10
-0
No files found.
app/src/main/AndroidManifest.xml
View file @
0804dda8
...
...
@@ -74,7 +74,7 @@
<activity
android:name=
".home.HomeActivity"
android:launchMode=
"singleTask"
android:noHistory=
"true"
></activity
>
android:noHistory=
"true"
/
>
<activity
...
...
config.gradle
View file @
0804dda8
...
...
@@ -33,7 +33,7 @@ ext {
//-------------- 功能组件 --------------
//mdt 组件
"ydl-tuicore"
:
"0.0.1
2
"
,
"ydl-tuicore"
:
"0.0.1
4
"
,
// "m-tuicore-ydl" : "0.0.10",
//第一步
"ydl-platform"
:
"0.0.40.90"
,
...
...
ydl-tuicore/src/main/AndroidManifest.xml
View file @
0804dda8
...
...
@@ -19,11 +19,15 @@
<activity
android:name=
".calling.videocall.VideoCallingActivity"
android:launchMode=
"singleTask"
android:screenOrientation=
"portrait"
/>
android:screenOrientation=
"portrait"
android:theme=
"@style/VideoCallActivityTheme"
/>
<!--接听界面-->
<activity
android:name=
".calling.videocall.YDLInvitionActivity"
android:launchMode=
"singleTask"
android:screenOrientation=
"portrait"
/>
android:screenOrientation=
"portrait"
android:theme=
"@style/VideoCallActivityTheme"
/>
</application>
</manifest>
\ No newline at end of file
ydl-tuicore/src/main/java/com/tencent/qcloud/tuicore/calling/login/LoginTUI.kt
View file @
0804dda8
package
com.tencent.
liteav
.login
package
com.tencent.
qcloud.tuicore.calling
.login
import
android.content.Context
import
android.util.Log
...
...
ydl-tuicore/src/main/java/com/tencent/qcloud/tuicore/calling/trtccalling/model/TRTCCalling.java
View file @
0804dda8
...
...
@@ -332,11 +332,12 @@ public class TRTCCalling {
intent
.
putExtra
(
Constant
.
USER_ID
,
userModel
.
userId
);
intent
.
putExtra
(
Constant
.
INVITE_ID
,
inviter
);
intent
.
setFlags
(
Intent
.
FLAG_ACTIVITY_NEW_TASK
);
mContext
.
startActivity
(
intent
);
}
}
// handleRecvCallModel(inviteID, inviter, groupID, inviteeList, data);
// 响铃
startRing
();
}
@Override
...
...
@@ -2083,7 +2084,8 @@ public class TRTCCalling {
}
}
private
void
stopRing
()
{
public
void
stopRing
()
{
stopMusic
();
}
...
...
ydl-tuicore/src/main/java/com/tencent/qcloud/tuicore/calling/videocall/VideoCallingActivity.java
View file @
0804dda8
package
com
.
tencent
.
qcloud
.
tuicore
.
calling
.
videocall
;
import
android.annotation.SuppressLint
;
import
android.content.Intent
;
import
android.os.Build
;
import
android.os.Bundle
;
import
android.text.TextUtils
;
import
android.util.Log
;
import
android.view.View
;
import
android.view.Window
;
import
android.view.WindowManager
;
import
android.widget.ImageView
;
import
android.widget.LinearLayout
;
import
android.widget.TextView
;
import
android.widget.Toast
;
import
androidx.annotation.RequiresApi
;
import
com.blankj.utilcode.util.ToastUtils
;
import
com.tencent.liteav.TXLiteAVCode
;
import
com.tencent.liteav.device.TXDeviceManager
;
import
com.tencent.qcloud.tuicore.R
;
import
com.tencent.qcloud.tuicore.calling.basic.UserModel
;
import
com.tencent.qcloud.tuicore.calling.basic.UserModelManager
;
import
com.tencent.qcloud.tuicore.calling.trtccalling.model.impl.base.CallingInfoManager
;
import
com.tencent.qcloud.tuicore.util.StatusBarUtil
;
import
com.tencent.rtmp.ui.TXCloudVideoView
;
import
com.tencent.trtc.TRTCCloud
;
import
com.tencent.trtc.TRTCCloudDef
;
...
...
@@ -26,7 +35,7 @@ import java.util.List;
/**
* TRTC视频通话的主页面
*
*
<p>
* 包含如下简单功能:
* - 进入视频通话房间{@link VideoCallingActivity#enterRoom()}
* - 退出视频通话房间{@link VideoCallingActivity#exitRoom()}
...
...
@@ -34,7 +43,7 @@ import java.util.List;
* - 打开/关闭摄像头{@link VideoCallingActivity#muteVideo()}
* - 打开/关闭麦克风{@link VideoCallingActivity#muteAudio()}
* - 显示房间内其他用户的视频画面(当前示例最多可显示6个其他用户的视频画面){@link TRTCCloudImplListener#refreshRemoteVideoViews()}
*
*
<p>
* - 详见接入文档{https://cloud.tencent.com/document/product/647/42045}
*/
public
class
VideoCallingActivity
extends
TRTCBaseActivity
implements
View
.
OnClickListener
{
...
...
@@ -50,31 +59,57 @@ public class VideoCallingActivity extends TRTCBaseActivity implements View.OnCli
private
LinearLayout
btnAudio
;
private
ImageView
ivVideo
;
private
ImageView
ivAudio
;
private
ImageView
ivNetworkMe
;
private
ImageView
ivAudioMe
;
private
TextView
tvMe
;
private
LinearLayout
llMe
;
private
TRTCCloud
mTRTCCloud
;
private
TXDeviceManager
mTXDeviceManager
;
private
boolean
mIsFrontCamera
=
true
;
private
List
<
String
>
mRemoteUidList
;
private
List
<
TXCloudVideoView
>
mRemoteViewList
;
// 远端用户的昵称、网络状态、麦克风状态控件
private
List
<
LinearLayout
>
mLlUserViewList
;
private
List
<
ImageView
>
mIvNetWorkViewList
;
private
List
<
ImageView
>
mIvAudioViewList
;
private
List
<
LinearLayout
>
mLlUserViewList
;
private
List
<
TextView
>
mTvNameViewList
;
private
int
mUserCount
=
0
;
private
String
mRoomId
;
private
String
mUserId
;
private
boolean
mAudioRouteFlag
=
true
;
private
UserModel
mUserModel
;
@SuppressLint
(
"NewApi"
)
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
StatusBarUtil
.
StatusBarLightMode
(
this
);
handleIntent
();
setContentView
(
R
.
layout
.
videocall_activity_calling
);
// initStatusBar();
if
(
checkPermission
())
{
initView
();
enterRoom
();
}
}
// @RequiresApi(api = Build.VERSION_CODES.M)
// private void initStatusBar() {
// Window window = getWindow();
// //取消设置透明状态栏,使 ContentView 内容不再覆盖状态栏
// window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
// //需要设置这个 flag 才能调用 setStatusBarColor 来设置状态栏颜色
// window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
// //设置状态栏颜色
//// window.setStatusBarColor(color);
// //状态栏白底黑字的实现方法
// window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
// //去掉系统状态栏下的windowContentOverlay
// findViewById(android.R.id.content).setForeground(null);
// }
private
void
handleIntent
()
{
Intent
intent
=
getIntent
();
if
(
null
!=
intent
)
{
...
...
@@ -91,7 +126,7 @@ public class VideoCallingActivity extends TRTCBaseActivity implements View.OnCli
private
void
initView
()
{
mTextTitle
=
findViewById
(
R
.
id
.
tv_room_number
);
mImageBack
=
findViewById
(
R
.
id
.
iv_back
);
mTXCVVLocalPreviewView
=
findViewById
(
R
.
id
.
trtc_view_m
ain
);
mTXCVVLocalPreviewView
=
findViewById
(
R
.
id
.
trtc_view_m
e
);
btnVideo
=
findViewById
(
R
.
id
.
btn_video
);
btnAudio
=
findViewById
(
R
.
id
.
btn_audio
);
btnVideo
.
setSelected
(
true
);
...
...
@@ -99,6 +134,10 @@ public class VideoCallingActivity extends TRTCBaseActivity implements View.OnCli
ivVideo
=
findViewById
(
R
.
id
.
iv_video
);
ivAudio
=
findViewById
(
R
.
id
.
iv_audio
);
tvLeave
=
findViewById
(
R
.
id
.
tv_leave
);
ivNetworkMe
=
findViewById
(
R
.
id
.
iv_network_me
);
ivAudioMe
=
findViewById
(
R
.
id
.
iv_audio_me
);
tvMe
=
findViewById
(
R
.
id
.
tv_me
);
llMe
=
findViewById
(
R
.
id
.
ll_me
);
if
(!
TextUtils
.
isEmpty
(
mRoomId
))
{
...
...
@@ -111,9 +150,10 @@ public class VideoCallingActivity extends TRTCBaseActivity implements View.OnCli
mRemoteUidList
=
new
ArrayList
<>();
mRemoteViewList
=
new
ArrayList
<>();
mLlUserViewList
=
new
ArrayList
<>();
mIvNetWorkViewList
=
new
ArrayList
<>();
mIvAudioViewList
=
new
ArrayList
<>();
m
LlUser
ViewList
=
new
ArrayList
<>();
m
TvName
ViewList
=
new
ArrayList
<>();
mRemoteViewList
.
add
(
findViewById
(
R
.
id
.
trtc_view_1
));
mRemoteViewList
.
add
(
findViewById
(
R
.
id
.
trtc_view_2
));
mRemoteViewList
.
add
(
findViewById
(
R
.
id
.
trtc_view_3
));
...
...
@@ -138,19 +178,25 @@ public class VideoCallingActivity extends TRTCBaseActivity implements View.OnCli
mLlUserViewList
.
add
(
findViewById
(
R
.
id
.
ll_user_4
));
mLlUserViewList
.
add
(
findViewById
(
R
.
id
.
ll_user_5
));
mLlUserViewList
.
add
(
findViewById
(
R
.
id
.
ll_user_6
));
mTvNameViewList
.
add
(
findViewById
(
R
.
id
.
tv_name_1
));
mTvNameViewList
.
add
(
findViewById
(
R
.
id
.
tv_name_2
));
mTvNameViewList
.
add
(
findViewById
(
R
.
id
.
tv_name_3
));
mTvNameViewList
.
add
(
findViewById
(
R
.
id
.
tv_name_4
));
mTvNameViewList
.
add
(
findViewById
(
R
.
id
.
tv_name_5
));
mTvNameViewList
.
add
(
findViewById
(
R
.
id
.
tv_name_5
));
}
private
void
enterRoom
()
{
mTRTCCloud
=
TRTCCloud
.
sharedInstance
(
getApplicationContext
());
mTRTCCloud
.
setListener
(
new
TRTCCloudImplListener
(
VideoCallingActivity
.
this
));
mTXDeviceManager
=
mTRTCCloud
.
getDeviceManager
();
UserModel
u
serModel
=
UserModelManager
.
getInstance
().
getUserModel
();
mU
serModel
=
UserModelManager
.
getInstance
().
getUserModel
();
TRTCCloudDef
.
TRTCParams
trtcParams
=
new
TRTCCloudDef
.
TRTCParams
();
trtcParams
.
sdkAppId
=
u
serModel
.
appId
;
trtcParams
.
sdkAppId
=
mU
serModel
.
appId
;
trtcParams
.
userId
=
mUserId
;
trtcParams
.
roomId
=
Integer
.
parseInt
(
mRoomId
);
Log
.
d
(
"userSig"
,
u
serModel
.
userSig
);
trtcParams
.
userSig
=
u
serModel
.
userSig
;
Log
.
d
(
"userSig"
,
mU
serModel
.
userSig
);
trtcParams
.
userSig
=
mU
serModel
.
userSig
;
mTRTCCloud
.
startLocalPreview
(
mIsFrontCamera
,
mTXCVVLocalPreviewView
);
mTRTCCloud
.
startLocalAudio
(
TRTCCloudDef
.
TRTC_AUDIO_QUALITY_SPEECH
);
...
...
@@ -196,12 +242,12 @@ public class VideoCallingActivity extends TRTCBaseActivity implements View.OnCli
@Override
public
void
onClick
(
View
v
)
{
int
id
=
v
.
getId
();
if
(
id
==
R
.
id
.
iv_back
||
id
==
R
.
id
.
tv_leave
)
{
if
(
id
==
R
.
id
.
iv_back
||
id
==
R
.
id
.
tv_leave
)
{
exitRoom
();
finish
();
}
else
if
(
id
==
R
.
id
.
btn_audio
){
}
else
if
(
id
==
R
.
id
.
btn_audio
)
{
muteAudio
();
}
else
if
(
id
==
R
.
id
.
btn_video
){
}
else
if
(
id
==
R
.
id
.
btn_video
)
{
muteVideo
();
}
}
...
...
@@ -230,9 +276,11 @@ public class VideoCallingActivity extends TRTCBaseActivity implements View.OnCli
if
(!
isSelected
)
{
mTRTCCloud
.
muteLocalAudio
(
true
);
ivAudio
.
setImageResource
(
R
.
drawable
.
trtccalling_ic_me_audio_close
);
ivAudioMe
.
setImageResource
(
R
.
drawable
.
trtccalling_ic_other_audio_close
);
}
else
{
mTRTCCloud
.
muteLocalAudio
(
false
);
ivAudio
.
setImageResource
(
R
.
drawable
.
trtccalling_ic_me_audio_open
);
ivAudioMe
.
setImageResource
(
R
.
drawable
.
trtccalling_ic_other_audio_open
);
}
btnAudio
.
setSelected
(!
isSelected
);
}
...
...
@@ -243,9 +291,9 @@ public class VideoCallingActivity extends TRTCBaseActivity implements View.OnCli
private
void
switchCamera
()
{
mIsFrontCamera
=
!
mIsFrontCamera
;
mTXDeviceManager
.
switchCamera
(
mIsFrontCamera
);
if
(
mIsFrontCamera
)
{
if
(
mIsFrontCamera
)
{
// mButtonSwitchCamera.setText( "使用后置摄像头");
}
else
{
}
else
{
// mButtonSwitchCamera.setText("使用前置摄像头");
}
}
...
...
@@ -254,11 +302,11 @@ public class VideoCallingActivity extends TRTCBaseActivity implements View.OnCli
* 听筒和扬声器切换
*/
private
void
audioRoute
()
{
if
(
mAudioRouteFlag
)
{
if
(
mAudioRouteFlag
)
{
mAudioRouteFlag
=
false
;
mTXDeviceManager
.
setAudioRoute
(
TXDeviceManager
.
TXAudioRoute
.
TXAudioRouteEarpiece
);
// mButtonAudioRoute.setText("使用扬声器");
}
else
{
}
else
{
mAudioRouteFlag
=
true
;
mTXDeviceManager
.
setAudioRoute
(
TXDeviceManager
.
TXAudioRoute
.
TXAudioRouteSpeakerphone
);
// mButtonAudioRoute.setText("使用听筒");
...
...
@@ -280,8 +328,22 @@ public class VideoCallingActivity extends TRTCBaseActivity implements View.OnCli
}
/**
* 自己进入房间
*
* @param result
*/
@Override
public
void
onEnterRoom
(
long
result
)
{
super
.
onEnterRoom
(
result
);
llMe
.
setVisibility
(
View
.
VISIBLE
);
if
(
mUserModel
!=
null
)
{
tvMe
.
setText
(
mUserModel
.
userName
);
}
}
/**
* 离开房间
*
*
/
*/
@Override
public
void
onExitRoom
(
int
reason
)
{
super
.
onExitRoom
(
reason
);
...
...
@@ -289,33 +351,57 @@ public class VideoCallingActivity extends TRTCBaseActivity implements View.OnCli
}
/**
* 远端用户进入房间
*
* @param userId
*/
@Override
public
void
onRemoteUserEnterRoom
(
String
userId
)
{
super
.
onRemoteUserEnterRoom
(
userId
);
refreshRemoteUserName
();
}
/**
* 网络质量的实时统计回调
*
* @param localQuality
* @param remoteQuality
*/
@Override
public
void
onNetworkQuality
(
TRTCCloudDef
.
TRTCQuality
localQuality
,
ArrayList
<
TRTCCloudDef
.
TRTCQuality
>
remoteQuality
)
{
Log
.
e
(
TAG
,
"网络质量的实时统计回调 userId:"
+
localQuality
.
userId
+
"uid:"
+
localQuality
.
quality
+
remoteQuality
.
get
(
0
).
userId
+
"quality:"
+
localQuality
.
quality
+
remoteQuality
.
get
(
0
).
quality
);
// if (remoteQuality.size()>0){
// refreshNetWorkStatus(remoteQuality);
// }
Log
.
e
(
TAG
,
"网络质量的实时统计回调 userId:"
+
localQuality
.
userId
+
"uid:"
+
localQuality
.
quality
+
"quality:"
+
localQuality
.
quality
);
Log
.
e
(
TAG
,
"远端用户数量:"
+
remoteQuality
.
size
());
if
(
localQuality
.
quality
==
TRTCCloudDef
.
TRTC_VOICE_CHANGER_TYPE_0
)
{
ivNetworkMe
.
setImageResource
(
R
.
drawable
.
trtccalling_ic_network_bad
);
}
else
if
(
localQuality
.
quality
<=
TRTCCloudDef
.
TRTC_VOICE_CHANGER_TYPE_3
)
{
ivNetworkMe
.
setImageResource
(
R
.
drawable
.
trtccalling_ic_network_poor
);
}
else
if
(
localQuality
.
quality
<=
TRTCCloudDef
.
TRTC_VOICE_CHANGER_TYPE_8
)
{
ivNetworkMe
.
setImageResource
(
R
.
drawable
.
trtccalling_ic_network_good
);
}
else
if
(
localQuality
.
quality
<=
TRTCCloudDef
.
TRTC_VOICE_CHANGER_TYPE_11
)
{
ivNetworkMe
.
setImageResource
(
R
.
drawable
.
trtccalling_ic_network_excellent
);
}
if
(
remoteQuality
.
size
()
>
0
)
{
refreshRemoteUserNetWorkStatus
(
remoteQuality
);
}
}
/**
* 音频麦克风开启或关闭回调
*
* @param userId
* @param available
*/
@Override
public
void
onUserAudioAvailable
(
String
userId
,
boolean
available
)
{
Log
.
e
(
TAG
,
"onUserAudioAvailable userId "
+
userId
+
", mUserCount "
+
mUserCount
+
",available "
+
available
);
if
(!
TextUtils
.
isEmpty
(
userId
)
)
{
refreshAudioStatus
(
userId
,
available
);
if
(!
TextUtils
.
isEmpty
(
userId
)
&&
mRemoteUidList
.
size
()
>
0
)
{
refresh
RemoteUser
AudioStatus
(
userId
,
available
);
}
}
/**
* 视频开启或关闭回调
*
* @param userId
* @param available
*/
...
...
@@ -336,6 +422,7 @@ public class VideoCallingActivity extends TRTCBaseActivity implements View.OnCli
mRemoteUidList
.
remove
(
index
);
}
refreshRemoteVideoViews
();
refreshRemoteUserName
();
}
...
...
@@ -344,49 +431,19 @@ public class VideoCallingActivity extends TRTCBaseActivity implements View.OnCli
if
(
i
<
mRemoteUidList
.
size
())
{
String
remoteUid
=
mRemoteUidList
.
get
(
i
);
mRemoteViewList
.
get
(
i
).
setVisibility
(
View
.
VISIBLE
);
mTRTCCloud
.
startRemoteView
(
remoteUid
,
TRTCCloudDef
.
TRTC_VIDEO_STREAM_TYPE_SMALL
,
mRemoteViewList
.
get
(
i
));
mTRTCCloud
.
startRemoteView
(
remoteUid
,
TRTCCloudDef
.
TRTC_VIDEO_STREAM_TYPE_SMALL
,
mRemoteViewList
.
get
(
i
));
}
else
{
mRemoteViewList
.
get
(
i
).
setVisibility
(
View
.
GONE
);
}
}
}
private
void
refreshAudioStatus
(
String
userId
,
boolean
available
){
if
(
mRemoteUidList
.
size
()>
0
){
for
(
int
i
=
0
;
i
<
mIvAudioViewList
.
size
();
i
++)
{
if
(
userId
.
equals
(
mRemoteUidList
.
get
(
i
))){
if
(
available
){
mIvAudioViewList
.
get
(
i
).
setImageResource
(
R
.
drawable
.
trtccalling_ic_other_audio_open
);
}
else
{
mIvAudioViewList
.
get
(
i
).
setImageResource
(
R
.
drawable
.
trtccalling_ic_other_audio_close
);
}
return
;
}
}
}
}
private
void
refreshNetWorkStatus
(
ArrayList
<
TRTCCloudDef
.
TRTCQuality
>
remoteQuality
){
for
(
int
i
=
0
;
i
<
mIvNetWorkViewList
.
size
();
i
++)
{
int
quality
=
remoteQuality
.
get
(
i
).
quality
;
if
(
quality
==
TRTCCloudDef
.
TRTC_QUALITY_Excellent
){
mIvNetWorkViewList
.
get
(
i
).
setImageResource
(
R
.
drawable
.
trtccalling_ic_network_excellent
);
}
else
if
(
quality
==
TRTCCloudDef
.
TRTC_QUALITY_Good
){
mIvNetWorkViewList
.
get
(
i
).
setImageResource
(
R
.
drawable
.
trtccalling_ic_network_good
);
}
else
if
(
quality
==
TRTCCloudDef
.
TRTC_QUALITY_Poor
){
mIvNetWorkViewList
.
get
(
i
).
setImageResource
(
R
.
drawable
.
trtccalling_ic_network_poor
);
}
else
if
(
quality
==
TRTCCloudDef
.
TRTC_QUALITY_Bad
){
mIvNetWorkViewList
.
get
(
i
).
setImageResource
(
R
.
drawable
.
trtccalling_ic_network_bad
);
}
}
}
@Override
public
void
onError
(
int
errCode
,
String
errMsg
,
Bundle
extraInfo
)
{
Log
.
d
(
TAG
,
"sdk callback onError"
);
VideoCallingActivity
activity
=
mContext
.
get
();
if
(
activity
!=
null
)
{
Toast
.
makeText
(
activity
,
"onError: "
+
errMsg
+
"["
+
errCode
+
"]"
,
Toast
.
LENGTH_SHORT
).
show
();
Toast
.
makeText
(
activity
,
"onError: "
+
errMsg
+
"["
+
errCode
+
"]"
,
Toast
.
LENGTH_SHORT
).
show
();
if
(
errCode
==
TXLiteAVCode
.
ERR_ROOM_ENTER_FAIL
)
{
activity
.
exitRoom
();
}
...
...
@@ -395,4 +452,71 @@ public class VideoCallingActivity extends TRTCBaseActivity implements View.OnCli
}
/**
* 更新远端用户的麦开启或者关闭
*
* @param userId
* @param available
*/
private
void
refreshRemoteUserAudioStatus
(
String
userId
,
boolean
available
)
{
for
(
int
i
=
0
;
i
<
mRemoteUidList
.
size
();
i
++)
{
if
(
userId
.
equals
(
mRemoteUidList
.
get
(
i
)))
{
if
(
available
)
{
mIvAudioViewList
.
get
(
i
).
setImageResource
(
R
.
drawable
.
trtccalling_ic_other_audio_open
);
}
else
{
mIvAudioViewList
.
get
(
i
).
setImageResource
(
R
.
drawable
.
trtccalling_ic_other_audio_close
);
}
return
;
}
}
}
/**
* 更新远端用户的网络状态
*
* @param remoteQuality
*/
private
void
refreshRemoteUserNetWorkStatus
(
ArrayList
<
TRTCCloudDef
.
TRTCQuality
>
remoteQuality
)
{
for
(
int
i
=
0
;
i
<
remoteQuality
.
size
();
i
++)
{
if
(
mLlUserViewList
.
get
(
i
).
getVisibility
()
==
View
.
GONE
)
{
mLlUserViewList
.
get
(
i
).
setVisibility
(
View
.
VISIBLE
);
}
ImageView
ivNetWorkView
=
mIvNetWorkViewList
.
get
(
i
);
int
quality
=
remoteQuality
.
get
(
i
).
quality
;
if
(
quality
==
TRTCCloudDef
.
TRTC_VOICE_CHANGER_TYPE_0
)
{
ivNetWorkView
.
setImageResource
(
R
.
drawable
.
trtccalling_ic_network_excellent
);
}
else
if
(
quality
<=
TRTCCloudDef
.
TRTC_VOICE_CHANGER_TYPE_3
)
{
ivNetWorkView
.
setImageResource
(
R
.
drawable
.
trtccalling_ic_network_good
);
}
else
if
(
quality
<=
TRTCCloudDef
.
TRTC_VOICE_CHANGER_TYPE_8
)
{
ivNetWorkView
.
setImageResource
(
R
.
drawable
.
trtccalling_ic_network_poor
);
}
else
if
(
quality
<=
TRTCCloudDef
.
TRTC_VOICE_CHANGER_TYPE_11
)
{
ivNetWorkView
.
setImageResource
(
R
.
drawable
.
trtccalling_ic_network_bad
);
}
}
}
/**
* 更新远端用户的昵称
*/
private
void
refreshRemoteUserName
()
{
for
(
int
i
=
0
;
i
<
mRemoteUidList
.
size
();
i
++)
{
TextView
tvName
=
mTvNameViewList
.
get
(
i
);
CallingInfoManager
.
getInstance
().
getUserInfoByUserId
(
mRemoteUidList
.
get
(
i
),
new
CallingInfoManager
.
UserCallback
()
{
@Override
public
void
onSuccess
(
UserModel
model
)
{
tvName
.
setText
(
model
.
userName
);
}
@Override
public
void
onFailed
(
int
code
,
String
msg
)
{
if
(
code
==
206
)
{
ToastUtils
.
showLong
(
"用户不存在"
);
}
else
{
ToastUtils
.
showLong
(
getString
(
R
.
string
.
trtccalling_toast_search_fail
,
msg
));
}
}
});
}
}
}
ydl-tuicore/src/main/java/com/tencent/qcloud/tuicore/calling/videocall/YDLInvitionActivity.java
View file @
0804dda8
...
...
@@ -14,6 +14,7 @@ import com.tencent.qcloud.tuicore.calling.basic.UserModel;
import
com.tencent.qcloud.tuicore.calling.trtccalling.model.TRTCCalling
;
import
com.tencent.qcloud.tuicore.calling.trtccalling.model.impl.base.CallingInfoManager
;
import
com.tencent.qcloud.tuicore.calling.trtccalling.ui.common.RoundCornerImageView
;
import
com.tencent.qcloud.tuicore.util.StatusBarUtil
;
/**
* @Author: 刘鹏
...
...
@@ -50,6 +51,7 @@ public class YDLInvitionActivity extends TRTCBaseActivity {
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
StatusBarUtil
.
transparencyBar
(
this
);
handleIntent
();
setContentView
(
R
.
layout
.
video_invition_activity
);
initView
();
...
...
@@ -98,6 +100,8 @@ public class YDLInvitionActivity extends TRTCBaseActivity {
mIvVideoInviteRefuse
=
findViewById
(
R
.
id
.
iv_video_invite_refuse
);
//接听
mIvVideoInviteAccept
.
setOnClickListener
(
v
->
{
// 接听后停止响铃
TRTCCalling
.
sharedInstance
(
YDLInvitionActivity
.
this
).
stopRing
();
Intent
intent
=
new
Intent
(
YDLInvitionActivity
.
this
,
VideoCallingActivity
.
class
);
intent
.
putExtra
(
Constant
.
ROOM_ID
,
mRoomId
);
intent
.
putExtra
(
Constant
.
USER_ID
,
mUserId
);
...
...
ydl-tuicore/src/main/java/com/tencent/qcloud/tuicore/util/StatusBarUtil.java
0 → 100644
View file @
0804dda8
package
com
.
tencent
.
qcloud
.
tuicore
.
util
;
import
android.annotation.SuppressLint
;
import
android.annotation.TargetApi
;
import
android.app.Activity
;
import
android.graphics.Color
;
import
android.os.Build
;
import
android.view.View
;
import
android.view.Window
;
import
android.view.WindowManager
;
import
java.lang.reflect.Field
;
import
java.lang.reflect.Method
;
/**
* Created by Ykai on 2022/4/24.
*/
public
class
StatusBarUtil
{
/**
* 修改状态栏为全透明
*
* @param activity
*/
@SuppressLint
(
"ObsoleteSdkInt"
)
@TargetApi
(
19
)
public
static
void
transparencyBar
(
Activity
activity
)
{
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
LOLLIPOP
)
{
Window
window
=
activity
.
getWindow
();
window
.
clearFlags
(
WindowManager
.
LayoutParams
.
FLAG_TRANSLUCENT_STATUS
);
window
.
getDecorView
().
setSystemUiVisibility
(
View
.
SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
|
View
.
SYSTEM_UI_FLAG_LAYOUT_STABLE
);
window
.
addFlags
(
WindowManager
.
LayoutParams
.
FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS
);
window
.
setStatusBarColor
(
Color
.
TRANSPARENT
);
}
else
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
KITKAT
)
{
Window
window
=
activity
.
getWindow
();
window
.
setFlags
(
WindowManager
.
LayoutParams
.
FLAG_TRANSLUCENT_STATUS
,
WindowManager
.
LayoutParams
.
FLAG_TRANSLUCENT_STATUS
);
}
}
/**
* 状态栏亮色模式,设置状态栏黑色文字、图标,
* <p>
* 适配4.4以上版本MIUIV、Flyme和6.0以上版本其他Android
*
* @param activity
* @return 1:MIUUI 2:Flyme 3:android6.0
*/
public
static
int
StatusBarLightMode
(
Activity
activity
)
{
int
result
=
0
;
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
KITKAT
)
{
if
(
MIUISetStatusBarLightMode
(
activity
,
true
))
{
//小米
result
=
1
;
}
else
if
(
FlymeSetStatusBarLightMode
(
activity
.
getWindow
(),
true
))
{
//魅族
result
=
2
;
}
else
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
M
)
{
//6.0以上
activity
.
getWindow
().
getDecorView
().
setSystemUiVisibility
(
View
.
SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
|
View
.
SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
);
result
=
3
;
}
}
return
result
;
}
/**
* 设置状态栏图标为深色和魅族特定的文字风格
* <p>
* 可以用来判断是否为Flyme用户
*
* @param window 需要设置的窗口
* @param dark 是否把状态栏文字及图标颜色设置为深色
* @return boolean 成功执行返回true
*/
public
static
boolean
FlymeSetStatusBarLightMode
(
Window
window
,
boolean
dark
)
{
boolean
result
=
false
;
if
(
window
!=
null
)
{
try
{
WindowManager
.
LayoutParams
lp
=
window
.
getAttributes
();
Field
darkFlag
=
WindowManager
.
LayoutParams
.
class
.
getDeclaredField
(
"MEIZU_FLAG_DARK_STATUS_BAR_ICON"
);
Field
meizuFlags
=
WindowManager
.
LayoutParams
.
class
.
getDeclaredField
(
"meizuFlags"
);
darkFlag
.
setAccessible
(
true
);
meizuFlags
.
setAccessible
(
true
);
int
bit
=
darkFlag
.
getInt
(
null
);
int
value
=
meizuFlags
.
getInt
(
lp
);
if
(
dark
)
{
value
|=
bit
;
}
else
{
value
&=
~
bit
;
}
meizuFlags
.
setInt
(
lp
,
value
);
window
.
setAttributes
(
lp
);
result
=
true
;
}
catch
(
Exception
e
)
{
}
}
return
result
;
}
/**
* 需要MIUIV6以上
*
* @param activity
* @param dark 是否把状态栏文字及图标颜色设置为深色
* @return boolean 成功执行返回true
*/
public
static
boolean
MIUISetStatusBarLightMode
(
Activity
activity
,
boolean
dark
)
{
boolean
result
=
false
;
Window
window
=
activity
.
getWindow
();
if
(
window
!=
null
)
{
Class
clazz
=
window
.
getClass
();
try
{
int
darkModeFlag
=
0
;
Class
layoutParams
=
Class
.
forName
(
"android.view.MiuiWindowManager$LayoutParams"
);
Field
field
=
layoutParams
.
getField
(
"EXTRA_FLAG_STATUS_BAR_DARK_MODE"
);
darkModeFlag
=
field
.
getInt
(
layoutParams
);
Method
extraFlagField
=
clazz
.
getMethod
(
"setExtraFlags"
,
int
.
class
,
int
.
class
);
if
(
dark
)
{
extraFlagField
.
invoke
(
window
,
darkModeFlag
,
darkModeFlag
);
//状态栏透明且黑色字体
}
else
{
extraFlagField
.
invoke
(
window
,
0
,
darkModeFlag
);
//清除黑色字体
}
result
=
true
;
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
M
)
{
//开发版 7.7.13 及以后版本采用了系统API,旧方法无效但不会报错,所以两个方式都要加上
if
(
dark
)
{
activity
.
getWindow
().
getDecorView
().
setSystemUiVisibility
(
View
.
SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
|
View
.
SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
);
}
else
{
activity
.
getWindow
().
getDecorView
().
setSystemUiVisibility
(
View
.
SYSTEM_UI_FLAG_VISIBLE
);
}
}
}
catch
(
Exception
e
)
{
}
}
return
result
;
}
}
ydl-tuicore/src/main/res/layout/videocall_activity_calling.xml
View file @
0804dda8
...
...
@@ -3,6 +3,7 @@
xmlns:app=
"http://schemas.android.com/apk/res-auto"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:fitsSystemWindows=
"true"
android:background=
"#f6f7f9"
>
<LinearLayout
...
...
@@ -49,7 +50,7 @@
android:id=
"@+id/trtc_view_1"
android:layout_width=
"0dp"
android:layout_height=
"0dp"
app:layout_constraintBottom_toTopOf=
"@id/trtc_view_m
ain
"
app:layout_constraintBottom_toTopOf=
"@id/trtc_view_m
e
"
app:layout_constraintHorizontal_weight=
"1"
app:layout_constraintLeft_toLeftOf=
"parent"
app:layout_constraintRight_toLeftOf=
"@id/trtc_view_2"
...
...
@@ -158,7 +159,7 @@
</LinearLayout>
<com.tencent.rtmp.ui.TXCloudVideoView
android:id=
"@+id/trtc_view_m
ain
"
android:id=
"@+id/trtc_view_m
e
"
android:layout_width=
"0dp"
android:layout_height=
"0dp"
app:layout_constraintBottom_toTopOf=
"@id/trtc_view_5"
...
...
@@ -168,6 +169,49 @@
app:layout_constraintTop_toBottomOf=
"@id/trtc_view_1"
app:layout_constraintVertical_weight=
"1"
/>
<LinearLayout
android:id=
"@+id/ll_me"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:orientation=
"horizontal"
app:layout_constraintStart_toStartOf=
"@id/trtc_view_me"
app:layout_constraintBottom_toBottomOf=
"@id/trtc_view_me"
android:layout_marginStart=
"4dp"
android:layout_marginBottom=
"4dp"
android:background=
"@drawable/trtccalling_shape_white_r_10"
android:paddingStart=
"8dp"
android:paddingEnd=
"8dp"
android:gravity=
"center_vertical"
android:paddingTop=
"4dp"
android:paddingBottom=
"4dp"
android:visibility=
"gone"
>
<TextView
android:id=
"@+id/tv_me"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:textColor=
"@color/color_2D2F33"
android:textSize=
"12sp"
/>
<ImageView
android:id=
"@+id/iv_network_me"
android:layout_width=
"17dp"
android:layout_height=
"10dp"
android:src=
"@drawable/trtccalling_ic_network_excellent"
android:layout_marginStart=
"8dp"
/>
<ImageView
android:id=
"@+id/iv_audio_me"
android:layout_width=
"12dp"
android:layout_height=
"12dp"
android:layout_marginStart=
"8dp"
android:src=
"@drawable/trtccalling_ic_other_audio_open"
/>
</LinearLayout>
<com.tencent.rtmp.ui.TXCloudVideoView
android:id=
"@+id/trtc_view_3"
...
...
@@ -175,11 +219,11 @@
android:layout_height=
"0dp"
android:layout_below=
"@id/trtc_view_2"
android:layout_alignParentRight=
"true"
app:layout_constraintBottom_toBottomOf=
"@id/trtc_view_m
ain
"
app:layout_constraintBottom_toBottomOf=
"@id/trtc_view_m
e
"
app:layout_constraintHorizontal_weight=
"1"
app:layout_constraintLeft_toRightOf=
"@id/trtc_view_m
ain
"
app:layout_constraintLeft_toRightOf=
"@id/trtc_view_m
e
"
app:layout_constraintRight_toRightOf=
"parent"
app:layout_constraintTop_toTopOf=
"@id/trtc_view_m
ain
"
app:layout_constraintTop_toTopOf=
"@id/trtc_view_m
e
"
app:layout_constraintVertical_weight=
"1"
/>
<LinearLayout
...
...
@@ -292,8 +336,8 @@
app:layout_constraintBottom_toTopOf=
"@id/ll_bottom"
app:layout_constraintHorizontal_weight=
"1"
app:layout_constraintLeft_toLeftOf=
"parent"
app:layout_constraintRight_toRightOf=
"@id/trtc_view_m
ain
"
app:layout_constraintTop_toBottomOf=
"@id/trtc_view_m
ain
"
app:layout_constraintRight_toRightOf=
"@id/trtc_view_m
e
"
app:layout_constraintTop_toBottomOf=
"@id/trtc_view_m
e
"
app:layout_constraintVertical_weight=
"1"
/>
<LinearLayout
...
...
ydl-tuicore/src/main/res/values/styles.xml
View file @
0804dda8
...
...
@@ -18,4 +18,13 @@
<item
name=
"android:windowBackground"
>
@color/trtccalling_color_countrycode_bg_dialog
</item>
<item
name=
"android:windowSoftInputMode"
>
adjustResize
</item>
</style>
<style
name=
"VideoCallActivityTheme"
parent=
"Theme.AppCompat.Light.NoActionBar"
>
<!-- Customize your theme here. -->
<item
name=
"colorPrimary"
>
@color/white
</item>
<item
name=
"colorPrimaryDark"
>
@color/white
</item>
<item
name=
"colorAccent"
>
@color/white
</item>
<!--<item name="android:windowIsTranslucent">true</item>-->
<!--<item name="android:windowNoTitle">true</item>-->
</style>
</resources>
\ No newline at end of file
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