Commit 10f844d4 by upwork.021

feat: 修改ui

parent 4a55b7de
......@@ -40,11 +40,6 @@ android {
ndk {
abiFilters "arm64-v8a","armeabi-v7a" // 指定要ndk需要兼容的架构(这样其他依赖包里mips,x86,armeabi,arm-v8之类的so会被过滤掉)
}
manifestPlaceholders = [
// TPNS 推送服务 accessId、accessKey
XG_ACCESS_ID : "",
XG_ACCESS_KEY: ""
]
}
//配置签名文件
......@@ -194,8 +189,7 @@ dependencies {
implementation(rootProject.ext.dependencies["okhttp3"])
// TPNS SDK 主工程依赖包
implementation 'com.tencent.tpns:tpns:1.3.2.1-release'
implementation 'com.tencent.liteav:LiteAVSDK_TRTC:latest.release'
// implementation 'com.tencent.liteav:LiteAVSDK_TRTC:latest.release'
if (true) {
......
......@@ -75,7 +75,7 @@ dependencies {
kapt "com.alibaba:arouter-compiler:$arouter_compiler"
api "com.alibaba:arouter-api:$arouter_api"
api ('com.ydl:ydl-av:1.3.8@aar'){
api ('com.ydl:ydl-av:1.3.4@aar'){
transitive = true
}
......
......@@ -47,6 +47,15 @@ dependencies {
implementation(rootProject.ext.dependencies["okhttp3"])
implementation(rootProject.ext.dependencies["glide"])
implementation(rootProject.ext.dependencies["gson"])
if (rootProject.ext.dev_mode){
//开发时使用
api project(':ydl-platform')
}else {
//发布时使用
api(rootProject.ext.dependencies["ydl-platform"]) {
transitive = true
}
}
implementation "de.hdodenhof:circleimageview:3.1.0"
implementation "com.blankj:utilcode:1.25.9"
......
......@@ -5,14 +5,15 @@ import android.content.pm.PackageManager;
import android.os.Build;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;
import com.ydl.ydlcommon.base.BaseActivity;
import java.util.ArrayList;
import java.util.List;
public abstract class TRTCBaseActivity extends AppCompatActivity {
public abstract class TRTCBaseActivity extends BaseActivity {
protected static final int REQ_PERMISSION_CODE = 0x1000;
protected int mGrantedCount = 0;
......
package com.tencent.liteav.videocall;
import android.content.Intent;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.provider.Settings;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
......@@ -40,20 +37,6 @@ import java.util.List;
*
* - 详见接入文档{https://cloud.tencent.com/document/product/647/42045}
*/
/**
* Video Call
*
* Features:
* - Enter a video call room: {@link VideoCallingActivity#enterRoom()}
* - Exit a video call room: {@link VideoCallingActivity#exitRoom()}
* - Switch between the front and rear cameras: {@link VideoCallingActivity#switchCamera()}
* - Turn on/off the camera: {@link VideoCallingActivity#muteVideo()}
* - Turn on/off the mic: {@link VideoCallingActivity#muteAudio()}
* - Display the video of other users (max. 6) in the room: {@link TRTCCloudImplListener#refreshRemoteVideoViews()}
*
* - For more information, please see the integration document {https://cloud.tencent.com/document/product/647/42045}.
*/
public class VideoCallingActivity extends TRTCBaseActivity implements View.OnClickListener {
private static final String TAG = "VideoCallingActivity";
......@@ -62,10 +45,11 @@ public class VideoCallingActivity extends TRTCBaseActivity implements View.OnCli
private TextView mTextTitle;
private TXCloudVideoView mTXCVVLocalPreviewView;
private ImageView mImageBack;
private Button mButtonMuteVideo;
private Button mButtonMuteAudio;
private Button mButtonSwitchCamera;
private Button mButtonAudioRoute;
private TextView tvLeave;
private LinearLayout btnVideo;
private LinearLayout btnAudio;
private ImageView ivVideo;
private ImageView ivAudio;
private TRTCCloud mTRTCCloud;
private TXDeviceManager mTXDeviceManager;
......@@ -78,11 +62,20 @@ public class VideoCallingActivity extends TRTCBaseActivity implements View.OnCli
private boolean mAudioRouteFlag = true;
@Override
protected void initDataAndEvent() {
handleIntent();
}
@Override
protected int layoutResId() {
return R.layout.videocall_activity_calling;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.videocall_activity_calling);
handleIntent();
if (checkPermission()) {
initView();
......@@ -105,29 +98,33 @@ 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.txcvv_main);
mButtonMuteVideo = findViewById(R.id.btn_mute_video);
mButtonMuteAudio = findViewById(R.id.btn_mute_audio);
mButtonSwitchCamera = findViewById(R.id.btn_switch_camera);
mButtonAudioRoute = findViewById(R.id.btn_audio_route);
mTXCVVLocalPreviewView = findViewById(R.id.trtc_view_main);
btnVideo = findViewById(R.id.btn_video);
btnAudio = findViewById(R.id.btn_audio);
btnVideo.setSelected(true);
btnAudio.setSelected(true);
ivVideo = findViewById(R.id.iv_video);
ivAudio = findViewById(R.id.iv_audio);
tvLeave = findViewById(R.id.tv_leave);
if (!TextUtils.isEmpty(mRoomId)) {
mTextTitle.setText("房间号:" + mRoomId);
}
mImageBack.setOnClickListener(this);
mButtonMuteVideo.setOnClickListener(this);
mButtonMuteAudio.setOnClickListener(this);
mButtonSwitchCamera.setOnClickListener(this);
mButtonAudioRoute.setOnClickListener(this);
btnVideo.setOnClickListener(this);
btnAudio.setOnClickListener(this);
tvLeave.setOnClickListener(this);
mRemoteUidList = new ArrayList<>();
mRemoteViewList = new ArrayList<>();
mRemoteViewList.add((TXCloudVideoView)findViewById(R.id.trtc_view_1));
mRemoteViewList.add((TXCloudVideoView)findViewById(R.id.trtc_view_2));
mRemoteViewList.add((TXCloudVideoView)findViewById(R.id.trtc_view_3));
mRemoteViewList.add((TXCloudVideoView)findViewById(R.id.trtc_view_4));
mRemoteViewList.add((TXCloudVideoView)findViewById(R.id.trtc_view_5));
mRemoteViewList.add((TXCloudVideoView)findViewById(R.id.trtc_view_6));
mRemoteViewList.add(findViewById(R.id.trtc_view_1));
mRemoteViewList.add(findViewById(R.id.trtc_view_2));
mRemoteViewList.add(findViewById(R.id.trtc_view_3));
mRemoteViewList.add(findViewById(R.id.trtc_view_4));
mRemoteViewList.add(findViewById(R.id.trtc_view_5));
mRemoteViewList.add(findViewById(R.id.trtc_view_6));
mRemoteViewList.add(findViewById(R.id.trtc_view_main));
}
......@@ -186,63 +183,71 @@ public class VideoCallingActivity extends TRTCBaseActivity implements View.OnCli
@Override
public void onClick(View v) {
int id = v.getId();
if (id == R.id.iv_back) {
if (id == R.id.iv_back|| id == R.id.tv_leave) {
finish();
} else if (id == R.id.btn_mute_video) {
muteVideo();
} else if (id == R.id.btn_mute_audio) {
} else if (id == R.id.btn_audio){
muteAudio();
} else if (id == R.id.btn_switch_camera) {
switchCamera();
} else if (id == R.id.btn_audio_route) {
audioRoute();
} else if (id == R.id.btn_video){
muteVideo();
}
}
/**
* 操作摄像头打开或者关闭
*/
private void muteVideo() {
boolean isSelected = mButtonMuteVideo.isSelected();
if (!isSelected) {
boolean isSelected = btnVideo.isSelected();
if (isSelected) {
mTRTCCloud.stopLocalPreview();
mButtonMuteVideo.setText("打开摄像头");
ivVideo.setImageResource(R.drawable.trtccalling_ic_me_video_close);
} else {
mTRTCCloud.startLocalPreview(mIsFrontCamera, mTXCVVLocalPreviewView);
mButtonMuteVideo.setText("关闭摄像头");
ivVideo.setImageResource(R.drawable.trtccalling_ic_me_video_open);
}
mButtonMuteVideo.setSelected(!isSelected);
btnVideo.setSelected(!isSelected);
}
/**
* 操作麦克风开启或者关闭
*/
private void muteAudio() {
boolean isSelected = mButtonMuteAudio.isSelected();
boolean isSelected = btnAudio.isSelected();
if (!isSelected) {
mTRTCCloud.muteLocalAudio(true);
mButtonMuteAudio.setText("打开麦克风");
ivAudio.setImageResource(R.drawable.trtccalling_ic_me_audio_open);
} else {
mTRTCCloud.muteLocalAudio(false);
mButtonMuteAudio.setText("关闭麦克风");
ivAudio.setImageResource(R.drawable.trtccalling_ic_me_audio_close);
}
mButtonMuteAudio.setSelected(!isSelected);
btnAudio.setSelected(!isSelected);
}
/**
* 转换摄像头
*/
private void switchCamera() {
mIsFrontCamera = !mIsFrontCamera;
mTXDeviceManager.switchCamera(mIsFrontCamera);
if(mIsFrontCamera){
mButtonSwitchCamera.setText( "使用后置摄像头");
// mButtonSwitchCamera.setText( "使用后置摄像头");
}else{
mButtonSwitchCamera.setText("使用前置摄像头");
// mButtonSwitchCamera.setText("使用前置摄像头");
}
}
/**
* 听筒和扬声器切换
*/
private void audioRoute() {
if(mAudioRouteFlag){
mAudioRouteFlag = false;
mTXDeviceManager.setAudioRoute(TXDeviceManager.TXAudioRoute.TXAudioRouteEarpiece);
mButtonAudioRoute.setText("使用扬声器");
// mButtonAudioRoute.setText("使用扬声器");
}else{
mAudioRouteFlag = true;
mTXDeviceManager.setAudioRoute(TXDeviceManager.TXAudioRoute.TXAudioRouteSpeakerphone);
mButtonAudioRoute.setText("使用听筒");
// mButtonAudioRoute.setText("使用听筒");
}
}
......@@ -255,6 +260,37 @@ public class VideoCallingActivity extends TRTCBaseActivity implements View.OnCli
mContext = new WeakReference<>(activity);
}
/**
* 网络质量的实时统计回调
* @param localQuality
* @param remoteQuality
*/
@Override
public void onNetworkQuality(TRTCCloudDef.TRTCQuality localQuality, ArrayList<TRTCCloudDef.TRTCQuality> remoteQuality) {
// public static final int TRTC_QUALITY_UNKNOWN = 0;
// public static final int TRTC_QUALITY_Excellent = 1;
// public static final int TRTC_QUALITY_Good = 2;
// public static final int TRTC_QUALITY_Poor = 3;
// public static final int TRTC_QUALITY_Bad = 4;
// public static final int TRTC_QUALITY_Vbad = 5;
// public static final int TRTC_QUALITY_Down = 6;
}
/**
* 音频麦克风开启或关闭回调
* @param userId
* @param available
*/
@Override
public void onUserAudioAvailable(String userId, boolean available) {
}
/**
* 视频开启或关闭回调
* @param userId
* @param available
*/
@Override
public void onUserVideoAvailable(String userId, boolean available) {
Log.d(TAG, "onUserVideoAvailable userId " + userId + ", mUserCount " + mUserCount + ",available " + available);
......@@ -264,15 +300,14 @@ public class VideoCallingActivity extends TRTCBaseActivity implements View.OnCli
return;
}
mRemoteUidList.add(userId);
refreshRemoteVideoViews();
} else {
if (index == -1) {
return;
}
mTRTCCloud.stopRemoteView(userId);
mRemoteUidList.remove(index);
refreshRemoteVideoViews();
}
refreshRemoteVideoViews();
}
......
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle"
>
<solid android:color="@color/color_F0504A" />
<corners android:radius="4dp" />
</shape>
\ No newline at end of file
......@@ -15,13 +15,14 @@
android:id="@+id/iv_back"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginStart="10dp"
android:layout_marginTop="15dp"
android:background="@drawable/common_ic_back" />
<TextView
android:id="@+id/tv_room_number"
android:layout_width="match_parent"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="40dp"
android:layout_marginTop="15dp"
android:gravity="center_horizontal"
......@@ -29,13 +30,25 @@
android:textColor="@android:color/white"
android:textSize="20sp" />
<TextView
android:id="@+id/tv_leave"
android:layout_width="60dp"
android:layout_height="28dp"
android:textColor="@color/white"
android:gravity="center"
android:textSize="14sp"
android:layout_marginTop="15dp"
android:layout_marginEnd="16dp"
android:background="@drawable/trtccalling_shape_leave"
android:text="离开" />
</LinearLayout>
<com.tencent.rtmp.ui.TXCloudVideoView
android:id="@+id/trtc_view_1"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toTopOf="@id/txcvv_main"
app:layout_constraintBottom_toTopOf="@id/trtc_view_main"
app:layout_constraintHorizontal_weight="1"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toLeftOf="@id/trtc_view_2"
......@@ -56,7 +69,7 @@
app:layout_constraintVertical_weight="1" />
<com.tencent.rtmp.ui.TXCloudVideoView
android:id="@+id/txcvv_main"
android:id="@+id/trtc_view_main"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toTopOf="@id/trtc_view_5"
......@@ -73,11 +86,11 @@
android:layout_height="0dp"
android:layout_below="@id/trtc_view_2"
android:layout_alignParentRight="true"
app:layout_constraintBottom_toBottomOf="@id/txcvv_main"
app:layout_constraintBottom_toBottomOf="@id/trtc_view_main"
app:layout_constraintHorizontal_weight="1"
app:layout_constraintLeft_toRightOf="@id/txcvv_main"
app:layout_constraintLeft_toRightOf="@id/trtc_view_main"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="@id/txcvv_main"
app:layout_constraintTop_toTopOf="@id/trtc_view_main"
app:layout_constraintVertical_weight="1" />
......@@ -104,8 +117,8 @@
app:layout_constraintBottom_toTopOf="@id/ll_bottom"
app:layout_constraintHorizontal_weight="1"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="@id/txcvv_main"
app:layout_constraintTop_toBottomOf="@id/txcvv_main"
app:layout_constraintRight_toRightOf="@id/trtc_view_main"
app:layout_constraintTop_toBottomOf="@id/trtc_view_main"
app:layout_constraintVertical_weight="1" />
......@@ -114,94 +127,66 @@
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="@id/trtc_view_5"
app:layout_constraintTop_toTopOf="@id/trtc_view_5"
app:layout_constraintHorizontal_weight="1"
app:layout_constraintLeft_toRightOf="@id/trtc_view_5"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintHorizontal_weight="1"
app:layout_constraintTop_toTopOf="@id/trtc_view_5"
app:layout_constraintVertical_weight="1" />
<LinearLayout
android:id="@+id/ll_bottom"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginBottom="10dp"
android:orientation="vertical"
android:layout_height="120dp"
android:background="@color/white"
android:gravity="center_vertical"
android:orientation="horizontal"
app:layout_constraintBottom_toBottomOf="parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="视频选项"
android:textColor="#ff0000"
android:textSize="16sp" />
<LinearLayout
android:id="@+id/ll_controller"
android:layout_width="300dp"
android:id="@+id/btn_audio"
android:layout_width="0dp"
android:layout_height="match_parent"
android:orientation="horizontal"
android:visibility="visible">
android:layout_weight="1"
android:gravity="center"
android:orientation="vertical">
<Button
android:id="@+id/btn_switch_camera"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_gravity="center_horizontal"
android:background="@drawable/common_button_bg"
android:padding="5dp"
android:text="使用后置摄像头"
android:textColor="@android:color/white" />
<Button
android:id="@+id/btn_mute_video"
<ImageView
android:id="@+id/iv_audio"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_gravity="center_horizontal"
android:layout_marginLeft="10dp"
android:background="@drawable/common_button_bg"
android:padding="5dp"
android:text="关闭摄像头"
android:textColor="@android:color/white" />
</LinearLayout>
android:layout_height="wrap_content"
android:src="@drawable/trtccalling_ic_me_audio_open" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:text="音频选项"
android:textColor="#ff0000"
android:textSize="16sp" />
android:layout_marginTop="6dp"
android:text="麦克风"
android:textColor="@color/color_8595a9"
android:textSize="14sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:id="@+id/btn_video"
android:layout_width="0dp"
android:layout_height="match_parent"
android:orientation="horizontal"
android:visibility="visible">
android:layout_weight="1"
android:gravity="center"
android:orientation="vertical">
<Button
android:id="@+id/btn_mute_audio"
<ImageView
android:id="@+id/iv_video"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_gravity="center_horizontal"
android:background="@drawable/common_button_bg"
android:padding="5dp"
android:text="关闭麦克风"
android:textColor="@android:color/white" />
<Button
android:id="@+id/btn_audio_route"
android:layout_height="wrap_content"
android:src="@drawable/trtccalling_ic_me_video_open" />
<TextView
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_gravity="center_horizontal"
android:layout_marginLeft="10dp"
android:background="@drawable/common_button_bg"
android:padding="5dp"
android:text="使用听筒"
android:textColor="@android:color/white" />
android:layout_height="wrap_content"
android:layout_marginTop="6dp"
android:text="摄像头"
android:textColor="@color/color_8595a9"
android:textSize="14sp" />
</LinearLayout>
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
......@@ -24,4 +24,6 @@
<color name="trtccalling_color_disable">#DBDBDB</color>
<color name="trtccalling_color_transparent">#00000000</color>
<color name="trtccalling_color_green">#FF29CC85</color>
<color name="color_8595a9">#859aa9</color>
<color name="color_F0504A">#F0504A</color>
</resources>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment