Commit 389058c4 by upwork.021

feat: 逻辑优化,ui优化,组件升级

parent d7dbc192
......@@ -9,6 +9,7 @@ import android.webkit.WebView;
import com.facebook.drawee.backends.pipeline.Fresco;
import com.meituan.android.walle.WalleChannelReader;
import com.tencent.qcloud.tuicore.calling.trtccalling.model.TRTCCalling;
import com.umeng.analytics.MobclickAgent;
import com.umeng.commonsdk.UMConfigure;
import com.umeng.socialize.PlatformConfig;
......@@ -21,6 +22,7 @@ import com.ydl.ydlcommon.router.YdlCommonRouterManager;
import com.ydl.ydlcommon.utils.AppProgressUtils;
import com.ydl.ydlcommon.utils.Utils;
import com.yidianling.common.tools.LogUtil;
import com.yidianling.common.tools.ToastUtil;
import com.yidianling.course.lifeCallback.CoursePlayLifecycle;
......@@ -61,6 +63,23 @@ public class ComponentTestApp extends BaseApp {
registerActivityLifecycleCallbacks(new CoursePlayLifecycle());
Fresco.initialize(this);
TRTCCalling.sharedInstance(this).setMdtCallBack(new TRTCCalling.MdtCallBack() {
@Override
public void onReceiveNewInvitation(String roomId) {
ToastUtil.toastShort("电话邀请"+roomId);
}
@Override
public void onInviteeAccepted(String roomId) {
ToastUtil.toastShort("接受邀请"+roomId);
}
@Override
public void onInviteeRejected(String roomId) {
ToastUtil.toastShort("拒绝邀请"+roomId);
}
});
}
private void initUmeng() {
......
......@@ -33,10 +33,10 @@ ext {
//-------------- 功能组件 --------------
//mdt 组件
"ydl-tuicore" : "0.0.15",
"ydl-tuicore" : "0.0.20",
// "m-tuicore-ydl" : "0.0.10",
//第一步
"ydl-platform" : "0.0.40.95",
"ydl-platform" : "0.0.40.96",
//第二步 若干
"ydl-webview" : "0.0.38.58",
......@@ -121,7 +121,7 @@ ext {
"ydl-tuicore" : "0.0.9",
"m-tuicore-ydl" : "0.0.10",
//第一步
"ydl-platform" : "0.0.40.95",
"ydl-platform" : "0.0.40.96",
//第二步 若干
"ydl-webview" : "0.0.38.58",
......
......@@ -88,6 +88,7 @@ dependencies {
api project(':ydl-webview')
api project(':ydl-platform')
api project(":ydl-pay")
// implementation project(":ydl-tuicore")
implementation modularPublication('com.ydl:m-user-api')
implementation modularPublication('com.ydl:m-course-api')
implementation modularPublication('com.ydl:m-im-api')
......@@ -107,5 +108,6 @@ dependencies {
api(rootProject.ext.dependencies["ydl-platform"]) {
transitive = true
}
// implementation rootProject.ext.dependencies["ydl-tuicore"]
}
}
......@@ -157,6 +157,9 @@ class LogHelper private constructor() {
val agoraRtmLog = getAgoraRTMLog(BaseApp.getApp())
val agoraRtmBackLog = getAgoraRtmBackLog(BaseApp.getApp())
// 腾讯im日志
val tencentLog = getTencentLog(BaseApp.getApp())
if (zipFile.exists()) zipFile.delete()
zipFile.createNewFile()
......@@ -176,6 +179,10 @@ class LogHelper private constructor() {
files.add(agoraRtmBackLog)
}
if (tencentLog.exists()){
files.add(tencentLog)
}
// ZipUtils.toZip(getLogFolder().absolutePath, FileOutputStream(zipFile), true)
ZipUtils.toZip(files, FileOutputStream(zipFile))
return zipFile
......@@ -254,6 +261,12 @@ class LogHelper private constructor() {
return File(agoraRTMLog)
}
// 获取腾讯im日志
private fun getTencentLog(context: Context):File{
val agoraRTMLog = FileUtils.getSDDirectory() + "/Android/data/" + context.packageName + "/files/log/tencent/imsdk"
return File(agoraRTMLog)
}
private object Holder {
val INSTANCE = LogHelper()
......
......@@ -47,15 +47,7 @@ dependencies {
implementation(rootProject.ext.dependencies["okhttp3"])
implementation(rootProject.ext.dependencies["glide"])
implementation(rootProject.ext.dependencies["gson"])
// if (rootProject.ext.dev_mode){
// //开发时使用
// implementation project(':ydl-platform')
// }else {
// //发布时使用
// implementation(rootProject.ext.dependencies["ydl-platform"]) {
// transitive = true
// }
// }
implementation(rootProject.ext.dependencies["eventbus"])
implementation "com.blankj:utilcode:1.25.9"
api "com.tencent.liteav:LiteAVSDK_TRTC:latest.release"
......
package com.tencent.qcloud.tuicore;
import android.content.Context;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
......
......@@ -114,6 +114,11 @@ public class TRTCCalling {
public boolean mIsInRoom = false;
private long mEnterRoomTime = 0;
/**
* 是否正在接听界面
*/
public boolean mIsBeingInvited = false;
private String mRoomId = "0";
/**
* 当前邀请列表
* C2C通话时会记录自己邀请的用户
* IM群组通话时会同步群组内邀请的用户
......@@ -180,6 +185,20 @@ public class TRTCCalling {
private static TRTCCalling sInstance;
public MdtCallBack mdtCallBack;
public interface MdtCallBack{
void onReceiveNewInvitation(String roomId);
void onInviteeAccepted(String roomId);
void onInviteeRejected(String roomId);
}
public void setMdtCallBack(MdtCallBack mdtCallBack) {
this.mdtCallBack = mdtCallBack;
}
/**
* 用于获取单例
*
......@@ -321,7 +340,7 @@ public class TRTCCalling {
public void onReceiveNewInvitation(String inviteID, String inviter, String groupID, List<String> inviteeList, String data) {
TRTCLogger.e(TAG, "onReceiveNewInvitation inviteID:" + inviteID + ", inviter:" + inviter
+ ", groupID:" + groupID + ", inviteeList:" + inviteeList + " data:" + data);
mRoomId = groupID;
final UserModel userModel = UserModelManager.getInstance().getUserModel();
for (String s : inviteeList) {
......@@ -336,9 +355,9 @@ public class TRTCCalling {
}
}
if (!mIsInRoom){
// 响铃
startRing();
}
mdtCallBack.onReceiveNewInvitation(mRoomId);
}
@Override
......@@ -2071,7 +2090,7 @@ public class TRTCCalling {
stopMusic();
}
private void startRing() {
public void startRing() {
if (null == mMediaPlayHelper || mEnableMuteMode) {
return;
}
......@@ -2082,9 +2101,11 @@ public class TRTCCalling {
if (TextUtils.isEmpty(mCallingBellPath)) {
mMediaPlayHelper.start(R.raw.phone_ringing);
} else {
if (!mMediaPlayHelper.getMediaPlayer().isPlaying()){
mMediaPlayHelper.start(mCallingBellPath);
}
}
}
public void stopRing() {
......@@ -2170,4 +2191,9 @@ public class TRTCCalling {
e.printStackTrace();
}
}
/**
* ---------------------------自定义callback--------------------------------
*/
}
......@@ -33,6 +33,10 @@ public class MediaPlayHelper {
mResPath = "";
}
public MediaPlayer getMediaPlayer(){
return mMediaPlayer;
}
public void start(String path) {
start(path, -1, 0);
}
......
......@@ -2,21 +2,22 @@ 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.imsdk.v2.V2TIMCallback;
import com.tencent.imsdk.v2.V2TIMCreateGroupMemberInfo;
import com.tencent.imsdk.v2.V2TIMGroupInfo;
import com.tencent.imsdk.v2.V2TIMGroupListener;
import com.tencent.imsdk.v2.V2TIMGroupMemberInfo;
import com.tencent.imsdk.v2.V2TIMManager;
import com.tencent.liteav.TXLiteAVCode;
import com.tencent.liteav.device.TXDeviceManager;
import com.tencent.qcloud.tuicore.R;
......@@ -24,12 +25,13 @@ import com.tencent.qcloud.tuicore.calling.basic.UserModel;
import com.tencent.qcloud.tuicore.calling.basic.UserModelManager;
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.util.MDTRxActivityTool;
import com.tencent.qcloud.tuicore.util.StatusBarUtil;
import com.tencent.qcloud.tuicore.util.ToastUtil;
import com.tencent.rtmp.ui.TXCloudVideoView;
import com.tencent.trtc.TRTCCloud;
import com.tencent.trtc.TRTCCloudDef;
import com.tencent.trtc.TRTCCloudListener;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.List;
......@@ -89,6 +91,7 @@ public class VideoCallingActivity extends TRTCBaseActivity implements View.OnCli
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
MDTRxActivityTool.addActivity(this);
StatusBarUtil.StatusBarLightMode(this);
handleIntent();
setContentView(R.layout.videocall_activity_calling);
......@@ -96,6 +99,11 @@ public class VideoCallingActivity extends TRTCBaseActivity implements View.OnCli
initView();
enterRoom();
}
enterGroup();
}
private void enterGroup() {
V2TIMManager.getInstance().addGroupListener(mGroupListener);
}
private void handleIntent() {
......@@ -191,8 +199,16 @@ public class VideoCallingActivity extends TRTCBaseActivity implements View.OnCli
mTRTCCloud.startLocalPreview(mIsFrontCamera, mTXCVVLocalPreviewView);
mTRTCCloud.startLocalAudio(TRTCCloudDef.TRTC_AUDIO_QUALITY_SPEECH);
mTRTCCloud.enterRoom(trtcParams, TRTCCloudDef.TRTC_APP_SCENE_VIDEOCALL);
}
V2TIMGroupListener mGroupListener = new V2TIMGroupListener(){
@Override
public void onGroupDismissed(String groupID, V2TIMGroupMemberInfo opUser) {
super.onGroupDismissed(groupID, opUser);
ToastUtil.toastShortMessage("房间已解散");
}
};
@Override
protected void onStop() {
......@@ -202,7 +218,8 @@ public class VideoCallingActivity extends TRTCBaseActivity implements View.OnCli
@Override
protected void onDestroy() {
super.onDestroy();
MDTRxActivityTool.removeActivity(this);
V2TIMManager.getInstance().removeGroupListener(mGroupListener);
exitRoom();
}
......@@ -339,6 +356,7 @@ public class VideoCallingActivity extends TRTCBaseActivity implements View.OnCli
}
}
/**
* 离开房间
*/
......
......@@ -14,8 +14,12 @@ 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.event.ClearJPushEvent;
import com.tencent.qcloud.tuicore.util.MDTRxActivityTool;
import com.tencent.qcloud.tuicore.util.StatusBarUtil;
import de.greenrobot.event.EventBus;
/**
* @Author: 刘鹏
* @Description: 音视频接听界面
......@@ -52,8 +56,15 @@ public class YDLInvitionActivity extends TRTCBaseActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
StatusBarUtil.transparencyBar(this);
MDTRxActivityTool.addActivity(this);
handleIntent();
setContentView(R.layout.video_invition_activity);
// 响铃
TRTCCalling.sharedInstance(this).startRing();
// 正在被邀请
TRTCCalling.sharedInstance(this).mIsBeingInvited = true;
// 发送清空通知栏的通知
EventBus.getDefault().post(new ClearJPushEvent());
initView();
}
......@@ -102,6 +113,7 @@ public class YDLInvitionActivity extends TRTCBaseActivity {
mIvVideoInviteAccept.setOnClickListener(v -> {
// 接听后停止响铃
TRTCCalling.sharedInstance(YDLInvitionActivity.this).stopRing();
TRTCCalling.sharedInstance(YDLInvitionActivity.this).mdtCallBack.onInviteeAccepted(mRoomId);
Intent intent = new Intent(YDLInvitionActivity.this, VideoCallingActivity.class);
intent.putExtra(Constant.ROOM_ID, mRoomId);
intent.putExtra(Constant.USER_ID, mUserId);
......@@ -113,6 +125,7 @@ public class YDLInvitionActivity extends TRTCBaseActivity {
@Override
public void onClick(View v) {
TRTCCalling.sharedInstance(YDLInvitionActivity.this).reject();
TRTCCalling.sharedInstance(YDLInvitionActivity.this).mdtCallBack.onInviteeRejected(mRoomId);
finish();
}
});
......@@ -132,4 +145,12 @@ public class YDLInvitionActivity extends TRTCBaseActivity {
public void onBackPressed() {
}
@Override
protected void onDestroy() {
super.onDestroy();
MDTRxActivityTool.removeActivity(this);
// 被邀请结束
TRTCCalling.sharedInstance(this).mIsBeingInvited = false;
}
}
package com.tencent.qcloud.tuicore.event;
/**
* Created by Ykai on 2022/4/25.
* 清空通知栏事件bean
*/
public class ClearJPushEvent {
}
package com.tencent.qcloud.tuicore.util;
import android.app.Activity;
import android.app.ActivityManager;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.os.Bundle;
import android.util.Log;
import java.util.List;
import java.util.Stack;
/**
* Created by vondear on 2016/1/24.
* 封装Activity相关工具类
*/
public class MDTRxActivityTool {
private static Stack<Activity> activityStack = new Stack<>();
public static Stack<Activity> getStack() {
return activityStack;
}
/**
* 添加Activity 到栈
*
* @param activity
*/
public static void addActivity(Activity activity) {
Log.e("MDTRxActivityTool", "addActivity=" + activity.getClass());
activityStack.add(activity);
}
// 从栈中移除
public static void removeActivity(Activity activity) {
if (activityStack.contains(activity)) {
activityStack.remove(activity);
}
}
/**
* 获取当前的Activity(堆栈中最后一个压入的)
*/
public static Activity currentActivity() {
Activity activity = activityStack.lastElement();
return activity;
}
/**
* 获取当前栈顶的activity
*
* @return
*/
public static Activity getTopActivity() {
return activityStack.peek();
}
/**
* 获取当前activity栈中存放的activity数量
*
* @return
*/
public static int getActivitySize() {
return activityStack.size();
}
/**
* 结束当前Activity(堆栈中最后一个压入的)
*/
public static void finishActivity() {
Activity activity = activityStack.lastElement();
}
/**
* 结束指定的Activity
*
* @param activity
*/
public static void finishActivity(Activity activity) {
if (activity != null) {
activityStack.remove(activity);
Log.e("MDTRxActivityTool",activityStack.size() + "");
}
}
/**
* 结束指定类名的Activity
*/
public static void finishActivity(Class<?> cls) {
for (Activity activity : activityStack) {
if (activity.getClass().equals(cls)) {
finishActivity(activity);
}
}
}
/**
* 结束所有的Activity
*/
public static void finishAllActivity() {
int size = activityStack.size();
for (int i = 0; i < size; i++) {
if (null != activityStack.get(i)) {
activityStack.get(i).finish();
}
}
activityStack.clear();
}
/**
* 清空Activity容器,但不结束最后1个
*/
public static void cleanActivityButNotFinishLastOne() {
if (activityStack != null) {
while (activityStack.size() > 1) {
Activity activity = activityStack.get(0);
activity.finish();
activityStack.remove(activity);
}
}
}
/**
* 结束栈中最后几个activity
* @param num 数量
*/
public static void cleanLastActivity(int num) {
if (activityStack != null) {
while (activityStack.size() > num && num > 0) {
Activity activity = activityStack.get(activityStack.size() - 1);
activity.finish();
activityStack.remove(activity);
num--;
}
}
}
public static void AppExit(Context context) {
try {
finishAllActivity();
ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
activityManager.restartPackage(context.getPackageName());
System.exit(0);
} catch (Exception ignored) {
}
}
public static Stack<Activity> getActivityStack() {
return activityStack;
}
/**
* 判断是否存在指定Activity
*
* @param context 上下文
* @param packageName 包名
* @param className activity全路径类名
* @return {@code true}: 是<br>{@code false}: 否
*/
public static boolean isExistActivity(Context context, String packageName, String className) {
Intent intent = new Intent();
intent.setClassName(packageName, className);
return !(context.getPackageManager().resolveActivity(intent, 0) == null ||
intent.resolveActivity(context.getPackageManager()) == null ||
context.getPackageManager().queryIntentActivities(intent, 0).size() == 0);
}
public static boolean activityIsExists(Class<?> cls) {
for (Activity activity : MDTRxActivityTool.getActivityStack()) {
if (activity.getClass().equals(cls)) {
return true;
}
}
return false;
}
/**
* 要求最低API为11
* Activity 跳转
* 跳转后Finish之前所有的Activity
*
* @param context
* @param goal
*/
public static void skipActivityAndFinishAll(Context context, Class<?> goal, Bundle bundle) {
Intent intent = new Intent(context, goal);
intent.putExtras(bundle);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
context.startActivity(intent);
((Activity) context).finish();
}
/**
* 要求最低API为11
* Activity 跳转
* 跳转后Finish之前所有的Activity
*
* @param context
* @param goal
*/
public static void skipActivityAndFinishAll(Context context, Class<?> goal) {
Intent intent = new Intent(context, goal);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
context.startActivity(intent);
((Activity) context).finish();
}
/**
* Activity 跳转
*
* @param context
* @param goal
*/
public static void skipActivityAndFinish(Context context, Class<?> goal, Bundle bundle) {
Intent intent = new Intent(context, goal);
intent.putExtras(bundle);
context.startActivity(intent);
((Activity) context).finish();
}
/**
* Activity 跳转
*
* @param context
* @param goal
*/
public static void skipActivityAndFinish(Context context, Class<?> goal) {
Intent intent = new Intent(context, goal);
context.startActivity(intent);
((Activity) context).finish();
}
/**
* Activity 跳转
*
* @param context
* @param goal
*/
public static void skipActivity(Context context, Class<?> goal) {
Intent intent = new Intent(context, goal);
context.startActivity(intent);
}
/**
* Activity 跳转
*
* @param context
* @param goal
*/
public static void skipActivity(Context context, Class<?> goal, Bundle bundle) {
Intent intent = new Intent(context, goal);
intent.putExtras(bundle);
context.startActivity(intent);
}
public static void skipActivityForResult(Activity context, Class<?> goal, int requestCode) {
Intent intent = new Intent(context, goal);
context.startActivityForResult(intent, requestCode);
}
public static void skipActivityForResult(Activity context, Class<?> goal, Bundle bundle, int requestCode) {
Intent intent = new Intent(context, goal);
intent.putExtras(bundle);
context.startActivityForResult(intent, requestCode);
}
/**
* 获取launcher activity
*
* @param context 上下文
* @param packageName 包名
* @return launcher activity
*/
public static String getLauncherActivity(Context context, String packageName) {
Intent intent = new Intent(Intent.ACTION_MAIN, null);
intent.addCategory(Intent.CATEGORY_LAUNCHER);
PackageManager pm = context.getPackageManager();
List<ResolveInfo> infos = pm.queryIntentActivities(intent, 0);
for (ResolveInfo info : infos) {
if (info.activityInfo.packageName.equals(packageName)) {
return info.activityInfo.name;
}
}
return "no " + packageName;
}
}
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