Commit 0804dda8 by upwork.021

feat: 通话页面ui和逻辑编写优化,通话组件升级

parent f02775dc
......@@ -74,7 +74,7 @@
<activity
android:name=".home.HomeActivity"
android:launchMode="singleTask"
android:noHistory="true"></activity>
android:noHistory="true"/>
<activity
......
......@@ -33,7 +33,7 @@ ext {
//-------------- 功能组件 --------------
//mdt 组件
"ydl-tuicore" : "0.0.12",
"ydl-tuicore" : "0.0.14",
// "m-tuicore-ydl" : "0.0.10",
//第一步
"ydl-platform" : "0.0.40.90",
......
......@@ -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
package com.tencent.liteav.login
package com.tencent.qcloud.tuicore.calling.login
import android.content.Context
import android.util.Log
......
......@@ -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();
}
......
......@@ -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);
......
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;
}
}
......@@ -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_main"
app:layout_constraintBottom_toTopOf="@id/trtc_view_me"
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_main"
android:id="@+id/trtc_view_me"
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_main"
app:layout_constraintBottom_toBottomOf="@id/trtc_view_me"
app:layout_constraintHorizontal_weight="1"
app:layout_constraintLeft_toRightOf="@id/trtc_view_main"
app:layout_constraintLeft_toRightOf="@id/trtc_view_me"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="@id/trtc_view_main"
app:layout_constraintTop_toTopOf="@id/trtc_view_me"
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_main"
app:layout_constraintTop_toBottomOf="@id/trtc_view_main"
app:layout_constraintRight_toRightOf="@id/trtc_view_me"
app:layout_constraintTop_toBottomOf="@id/trtc_view_me"
app:layout_constraintVertical_weight="1" />
<LinearLayout
......
......@@ -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
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