初始代码
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
import org.gradle.util.VersionNumber
|
||||
|
||||
apply plugin: 'com.android.library'
|
||||
def projects = this.rootProject.getAllprojects().stream().map { project -> project.name }.collect()
|
||||
|
||||
android {
|
||||
namespace "com.tencent.cloud.tuikit.roomkit"
|
||||
compileSdk 35
|
||||
|
||||
defaultConfig {
|
||||
minSdkVersion 19
|
||||
multiDexEnabled = true
|
||||
targetSdkVersion 35
|
||||
}
|
||||
|
||||
buildFeatures {
|
||||
buildConfig = true
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
|
||||
def roomSourceJavaVersion = JavaVersion.VERSION_1_8
|
||||
VersionNumber currentGradleVersion = VersionNumber.parse(gradle.gradleVersion)
|
||||
if (currentGradleVersion.major >= 8) {
|
||||
roomSourceJavaVersion = JavaVersion.VERSION_17
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility roomSourceJavaVersion
|
||||
targetCompatibility roomSourceJavaVersion
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
api fileTree(include: ['*.jar', '*.aar'], dir: 'libs')
|
||||
|
||||
implementation "de.hdodenhof:circleimageview:3.1.0"
|
||||
implementation "com.github.bumptech.glide:glide:4.12.0"
|
||||
implementation 'com.google.zxing:core:3.5.3'
|
||||
implementation "androidx.appcompat:appcompat:1.0.0"
|
||||
implementation "com.google.code.gson:gson:2.9.1"
|
||||
implementation 'com.google.android.material:material:1.4.0'
|
||||
implementation "androidx.constraintlayout:constraintlayout:1.1.3"
|
||||
implementation 'androidx.core:core:1.0.2'
|
||||
implementation 'com.tencentcloudapi:tencentcloud-sdk-java:3.1.1113'
|
||||
|
||||
implementation project(':timcommon')
|
||||
|
||||
api rootProject.getProperties().containsKey("common") ? rootProject.ext.common : "io.trtc.uikit:common:2.8.0.634"
|
||||
api rootProject.getProperties().containsKey("roomEngineSdk") ? rootProject.ext.roomEngineSdk : "io.trtc.uikit:rtc_room_engine:2.8.+"
|
||||
api rootProject.getProperties().containsKey("liteavSdk") ? rootProject.ext.liteavSdk : "com.tencent.liteav:LiteAVSDK_Professional:12.5.+"
|
||||
api rootProject.getProperties().containsKey("liteavScreenCaptureSdk") ? rootProject.ext.liteavScreenCaptureSdk : "com.tencent.liteav:LiteAVSDK_ScreenCapture:12.5.+"
|
||||
if (projects.contains("tuicore")) {
|
||||
api project(':tuicore')
|
||||
} else {
|
||||
api "com.tencent.liteav.tuikit:tuicore:8.5.+"
|
||||
implementation rootProject.getProperties().containsKey("imSdk") ? rootProject.ext.imSdk : "com.tencent.imsdk:imsdk-plus:8.5.+"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
# Add project specific ProGuard rules here.
|
||||
# You can control the set of applied configuration files using the
|
||||
# proguardFiles setting in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
|
||||
# Uncomment this to preserve the line number information for
|
||||
# debugging stack traces.
|
||||
#-keepattributes SourceFile,LineNumberTable
|
||||
|
||||
# If you keep the line number information, uncomment this to
|
||||
# hide the original source file name.
|
||||
#-renamesourcefileattribute SourceFile
|
||||
@@ -0,0 +1,130 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<uses-feature android:name="android.hardware.camera" />
|
||||
<uses-feature android:name="android.hardware.camera.autofocus" />
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.RECORD_AUDIO" />
|
||||
<uses-permission android:name="android.permission.CAMERA" />
|
||||
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
|
||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK" />
|
||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_CONNECTED_DEVICE"/>
|
||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MICROPHONE"/>
|
||||
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
|
||||
|
||||
<application>
|
||||
|
||||
<activity
|
||||
android:name="com.tencent.cloud.tuikit.roomkit.ConferenceMainActivity"
|
||||
android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation"
|
||||
android:launchMode="singleTask"
|
||||
android:supportsPictureInPicture="true"
|
||||
android:theme="@style/Theme.AppCompat.NoActionBar"
|
||||
tools:targetApi="n" />
|
||||
|
||||
<activity
|
||||
android:name="com.tencent.cloud.tuikit.roomkit.view.create.CreateConferenceActivity"
|
||||
android:launchMode="singleTask"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/Theme.AppCompat.NoActionBar" />
|
||||
|
||||
<activity
|
||||
android:name="com.tencent.cloud.tuikit.roomkit.view.join.EnterConferenceActivity"
|
||||
android:launchMode="singleTask"
|
||||
android:screenOrientation="portrait"
|
||||
android:windowSoftInputMode="adjustResize"
|
||||
android:theme="@style/Theme.AppCompat.NoActionBar" />
|
||||
|
||||
<activity
|
||||
android:name="com.tencent.cloud.tuikit.roomkit.view.schedule.conferencedetails.ScheduledConferenceDetailActivity"
|
||||
android:launchMode="singleTask"
|
||||
android:screenOrientation="portrait"
|
||||
android:windowSoftInputMode="adjustResize"
|
||||
android:theme="@style/Theme.AppCompat.NoActionBar" />
|
||||
|
||||
<activity
|
||||
android:name="com.tencent.cloud.tuikit.roomkit.view.schedule.modifyconference.ModifyConferenceActivity"
|
||||
android:launchMode="singleTask"
|
||||
android:screenOrientation="portrait"
|
||||
android:windowSoftInputMode="adjustResize"
|
||||
android:theme="@style/Theme.AppCompat.NoActionBar" />
|
||||
|
||||
<activity
|
||||
android:name="com.tencent.cloud.tuikit.roomkit.ScheduleConferenceActivity"
|
||||
android:launchMode="singleTask"
|
||||
android:screenOrientation="portrait"
|
||||
android:windowSoftInputMode="adjustResize"
|
||||
android:theme="@style/Theme.AppCompat.NoActionBar" />
|
||||
|
||||
<activity
|
||||
android:name="com.tencent.cloud.tuikit.roomkit.view.schedule.timezone.TimeZoneActivity"
|
||||
android:launchMode="singleTask"
|
||||
android:screenOrientation="portrait"
|
||||
android:windowSoftInputMode="adjustResize"
|
||||
android:theme="@style/Theme.AppCompat.NoActionBar" />
|
||||
|
||||
<activity
|
||||
android:name="com.tencent.cloud.tuikit.roomkit.view.main.RoomMainActivity"
|
||||
android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation"
|
||||
android:launchMode="singleTask"
|
||||
android:supportsPictureInPicture="true"
|
||||
android:theme="@style/Theme.AppCompat.NoActionBar"
|
||||
tools:targetApi="n" />
|
||||
|
||||
<activity
|
||||
android:name="com.tencent.cloud.tuikit.roomkit.view.main.conferenceinvitation.InvitationReceivedActivity"
|
||||
android:launchMode="singleTask"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/Theme.AppCompat.NoActionBar" />
|
||||
<activity
|
||||
android:name="com.tencent.cloud.tuikit.roomkit.view.main.chat.ChatActivity"
|
||||
android:configChanges="orientation|screenSize"
|
||||
android:launchMode="singleTask"
|
||||
android:windowSoftInputMode="adjustResize|adjustPan"
|
||||
android:theme="@style/TUIRoomActivityTransparent" />
|
||||
|
||||
<activity
|
||||
android:name="com.tencent.cloud.tuikit.roomkit.view.bridge.chat.view.InviteToJoinRoomActivity"
|
||||
android:configChanges="orientation|screenSize"
|
||||
android:launchMode="singleTask"
|
||||
android:theme="@style/TUIRoomActivityTransparent" />
|
||||
<activity
|
||||
android:name="com.tencent.cloud.tuikit.roomkit.view.bridge.chat.view.InvitedToJoinRoomActivity"
|
||||
android:configChanges="orientation|screenSize"
|
||||
android:launchMode="singleTask"
|
||||
android:theme="@style/Theme.AppCompat.NoActionBar" />
|
||||
<activity
|
||||
android:name="com.tencent.cloud.tuikit.roomkit.view.bridge.chat.view.Chat2RoomExtensionSettingsActivity"
|
||||
android:configChanges="orientation|screenSize"
|
||||
android:launchMode="singleTask"
|
||||
android:theme="@style/Theme.AppCompat.NoActionBar" />
|
||||
<activity
|
||||
android:name="com.tencent.cloud.tuikit.roomkit.view.main.speechtotext.SpeechToTextActivity"
|
||||
android:configChanges="orientation|screenSize"
|
||||
android:launchMode="singleTask"
|
||||
android:theme="@style/Theme.AppCompat.NoActionBar" />
|
||||
<activity
|
||||
android:name="com.tencent.cloud.tuikit.roomkit.view.main.contacts.DefaultContactsActivity"
|
||||
android:configChanges="orientation|screenSize"
|
||||
android:launchMode="singleTask"
|
||||
android:theme="@style/Theme.AppCompat.NoActionBar" />
|
||||
<service
|
||||
android:name="com.tencent.cloud.tuikit.roomkit.common.utils.KeepAliveService"
|
||||
android:enabled="true"
|
||||
android:exported="false"
|
||||
android:foregroundServiceType="mediaPlayback" />
|
||||
<service
|
||||
android:name="com.tencent.cloud.tuikit.roomkit.view.main.floatwindow.videoplaying.RoomFloatViewService"
|
||||
android:enabled="true"
|
||||
android:exported="false" />
|
||||
<provider
|
||||
android:name="com.tencent.cloud.tuikit.roomkit.state.ConferenceServiceInitializer"
|
||||
android:authorities="${applicationId}.TUIRoom.Init"
|
||||
android:enabled="true"
|
||||
android:exported="false" />
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
+115
@@ -0,0 +1,115 @@
|
||||
package com.tencent.cloud.tuikit.roomkit;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.tencent.cloud.tuikit.engine.common.TUICommonDefine;
|
||||
import com.tencent.cloud.tuikit.engine.room.TUIRoomDefine;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Objects;
|
||||
|
||||
public class ConferenceDefine {
|
||||
public static final String KEY_START_CONFERENCE_PARAMS = "KEY_START_CONFERENCE_PARAMS";
|
||||
public static final String KEY_JOIN_CONFERENCE_PARAMS = "KEY_JOIN_CONFERENCE_PARAMS";
|
||||
|
||||
public static class StartConferenceParams implements Serializable {
|
||||
public final String roomId;
|
||||
|
||||
public boolean isOpenMicrophone = true;
|
||||
public boolean isOpenCamera = false;
|
||||
public boolean isOpenSpeaker = true;
|
||||
|
||||
public boolean isMicrophoneDisableForAllUser = false;
|
||||
public boolean isCameraDisableForAllUser = false;
|
||||
|
||||
public boolean isSeatEnabled = false;
|
||||
public String password = "";
|
||||
public String name = "";
|
||||
|
||||
public StartConferenceParams(String roomId) {
|
||||
this.roomId = roomId;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("roomId=").append(roomId);
|
||||
builder.append("; isOpenMicrophone=").append(isOpenMicrophone);
|
||||
builder.append("; isOpenCamera=").append(isOpenCamera);
|
||||
builder.append("; isOpenSpeaker=").append(isOpenSpeaker);
|
||||
builder.append("; isMicrophoneDisableForAllUser=").append(isMicrophoneDisableForAllUser);
|
||||
builder.append("; isCameraDisableForAllUser=").append(isCameraDisableForAllUser);
|
||||
builder.append("; isSeatEnabled=").append(isSeatEnabled);
|
||||
builder.append("; password=").append(password);
|
||||
builder.append("; name=").append(name);
|
||||
return builder.toString();
|
||||
}
|
||||
}
|
||||
|
||||
public static class JoinConferenceParams implements Serializable {
|
||||
public final String roomId;
|
||||
|
||||
public boolean isOpenMicrophone = true;
|
||||
public boolean isOpenCamera = false;
|
||||
public boolean isOpenSpeaker = true;
|
||||
|
||||
public JoinConferenceParams(String roomId) {
|
||||
this.roomId = roomId;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("roomId=").append(roomId);
|
||||
builder.append("; isOpenMicrophone=").append(isOpenMicrophone);
|
||||
builder.append("; isOpenCamera=").append(isOpenCamera);
|
||||
builder.append("; isOpenSpeaker=").append(isOpenSpeaker);
|
||||
return builder.toString();
|
||||
}
|
||||
}
|
||||
|
||||
public static abstract class ConferenceObserver {
|
||||
public void onConferenceStarted(TUIRoomDefine.RoomInfo roomInfo, TUICommonDefine.Error error, String message) {}
|
||||
|
||||
public void onConferenceJoined(TUIRoomDefine.RoomInfo roomInfo, TUICommonDefine.Error error, String message) {}
|
||||
|
||||
public void onConferenceExited(TUIRoomDefine.RoomInfo roomInfo, ConferenceExitedReason reason) {}
|
||||
|
||||
public void onConferenceFinished(TUIRoomDefine.RoomInfo roomInfo, ConferenceFinishedReason reason) {}
|
||||
}
|
||||
|
||||
public enum ConferenceFinishedReason {
|
||||
FINISHED_BY_OWNER,
|
||||
FINISHED_BY_SERVER
|
||||
}
|
||||
|
||||
public enum ConferenceExitedReason {
|
||||
EXITED_BY_SELF,
|
||||
EXITED_BY_ADMIN_KICK_OUT,
|
||||
EXITED_BY_SERVER_KICK_OUT,
|
||||
EXITED_BY_JOINED_ON_OTHER_DEVICE,
|
||||
EXITED_BY_KICKED_OUT_OF_LINE,
|
||||
EXITED_BY_USER_SIG_EXPIRED
|
||||
}
|
||||
|
||||
public static class User implements Serializable {
|
||||
public String name;
|
||||
public String id;
|
||||
public String avatarUrl;
|
||||
|
||||
@Override
|
||||
public boolean equals(Object object) {
|
||||
if (this == object) return true;
|
||||
if (!(object instanceof User)) return false;
|
||||
User user = (User) object;
|
||||
return Objects.equals(id, user.id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
+90
@@ -0,0 +1,90 @@
|
||||
package com.tencent.cloud.tuikit.roomkit;
|
||||
|
||||
import static com.tencent.cloud.tuikit.engine.common.TUICommonDefine.Error.ROOM_ID_NOT_EXIST;
|
||||
import static com.tencent.cloud.tuikit.roomkit.manager.constant.ConferenceConstant.KEY_ERROR;
|
||||
import static com.tencent.cloud.tuikit.roomkit.manager.eventcenter.ConferenceEventCenter.RoomEngineEvent.LOCAL_USER_ENTER_ROOM;
|
||||
import static com.tencent.cloud.tuikit.roomkit.manager.eventcenter.ConferenceEventCenter.RoomEngineEvent.UPDATE_CONFERENCE_LIST;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import com.tencent.cloud.tuikit.engine.common.TUICommonDefine;
|
||||
import com.tencent.cloud.tuikit.engine.room.TUIRoomDefine;
|
||||
import com.tencent.cloud.tuikit.roomkit.manager.eventcenter.ConferenceEventCenter;
|
||||
import com.tencent.cloud.tuikit.roomkit.manager.ScheduleController;
|
||||
import com.tencent.cloud.tuikit.roomkit.view.schedule.conferencelist.ScheduledConferenceListView;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class ConferenceListFragment extends Fragment implements ConferenceEventCenter.RoomEngineEventResponder {
|
||||
private static final String TAG = "ConferenceListFragment";
|
||||
|
||||
@Override
|
||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
Log.d(TAG, "onCreate");
|
||||
ConferenceEventCenter.getInstance().subscribeEngine(LOCAL_USER_ENTER_ROOM, this);
|
||||
ConferenceEventCenter.getInstance().subscribeEngine(UPDATE_CONFERENCE_LIST, this);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
return new ScheduledConferenceListView(requireContext());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
Log.d(TAG, "onStart");
|
||||
ScheduleController.sharedInstance().loginEngine(new TUIRoomDefine.ActionCallback() {
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
ScheduleController.sharedInstance().refreshRequiredConferences(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(TUICommonDefine.Error error, String s) {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
Log.d(TAG, "onDestroy");
|
||||
ScheduleController.sharedInstance().clearRequiredConferences();
|
||||
ConferenceEventCenter.getInstance().unsubscribeEngine(LOCAL_USER_ENTER_ROOM, this);
|
||||
ConferenceEventCenter.getInstance().unsubscribeEngine(UPDATE_CONFERENCE_LIST, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEngineEvent(ConferenceEventCenter.RoomEngineEvent event, Map<String, Object> params) {
|
||||
handleLocalUserEnterRoom(event, params);
|
||||
handleUpdateConferenceList(event);
|
||||
}
|
||||
|
||||
private void handleLocalUserEnterRoom(ConferenceEventCenter.RoomEngineEvent event, Map<String, Object> params) {
|
||||
if (LOCAL_USER_ENTER_ROOM == event) {
|
||||
TUICommonDefine.Error error = (TUICommonDefine.Error) params.get(KEY_ERROR);
|
||||
Log.i(TAG, "onEngineEvent error=" + error);
|
||||
if (error != ROOM_ID_NOT_EXIST) {
|
||||
return;
|
||||
}
|
||||
ScheduleController.sharedInstance().refreshRequiredConferences(null);
|
||||
}
|
||||
}
|
||||
|
||||
private void handleUpdateConferenceList(ConferenceEventCenter.RoomEngineEvent event) {
|
||||
if (UPDATE_CONFERENCE_LIST == event) {
|
||||
ScheduleController.sharedInstance().refreshRequiredConferences(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
+207
@@ -0,0 +1,207 @@
|
||||
package com.tencent.cloud.tuikit.roomkit;
|
||||
|
||||
import android.Manifest;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.graphics.Color;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.SystemClock;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.core.app.ActivityCompat;
|
||||
import androidx.fragment.app.FragmentTransaction;
|
||||
|
||||
import com.tencent.cloud.tuikit.roomkit.common.utils.RoomPermissionUtil;
|
||||
import com.tencent.cloud.tuikit.roomkit.manager.ConferenceController;
|
||||
import com.tencent.cloud.tuikit.roomkit.view.basic.BaseDialogFragment;
|
||||
import com.tencent.cloud.tuikit.roomkit.view.main.ConferenceMainFragment;
|
||||
import com.tencent.cloud.tuikit.roomkit.view.main.floatwindow.videoplaying.RoomFloatViewService;
|
||||
import com.tencent.qcloud.tuicore.util.TUIBuild;
|
||||
import com.trtc.tuikit.common.foregroundservice.AudioForegroundService;
|
||||
import com.trtc.tuikit.common.foregroundservice.MediaForegroundService;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class ConferenceMainActivity extends AppCompatActivity {
|
||||
private static final String TAG = "ConferenceMainAy";
|
||||
|
||||
private static final int DEBOUNCE_TIME_MS = 1000;
|
||||
private static final int POST_NOTIFICATIONS_REQUEST_CODE = 10001;
|
||||
|
||||
private final long mFirstStartTime = SystemClock.elapsedRealtime();
|
||||
|
||||
private Intent mNewIntent;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
Log.i(TAG, "onCreate : " + this);
|
||||
initStatusBar();
|
||||
setContentView(R.layout.tuiroomkit_activity_conference_main);
|
||||
dismissFloatWindowIfNeeded();
|
||||
ConferenceMainFragment fragment = new ConferenceMainFragment();
|
||||
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
|
||||
transaction.add(R.id.app_fl_conference_main, fragment);
|
||||
transaction.commitAllowingStateLoss();
|
||||
|
||||
Intent intent = getIntent();
|
||||
if (isRepeatConference(intent)) {
|
||||
showRepeatConferenceDialog();
|
||||
return;
|
||||
}
|
||||
if (!startConferenceIfNeeded(intent, fragment)) {
|
||||
joinConferenceIfNeeded(intent, fragment);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onNewIntent(Intent intent) {
|
||||
super.onNewIntent(intent);
|
||||
if (SystemClock.elapsedRealtime() - mFirstStartTime < DEBOUNCE_TIME_MS) {
|
||||
return;
|
||||
}
|
||||
mNewIntent = intent;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
startKeepAliveInBackground();
|
||||
if (mNewIntent == null) {
|
||||
return;
|
||||
}
|
||||
if (ConferenceController.sharedInstance().getViewState().isInPictureInPictureMode.get()) {
|
||||
return;
|
||||
}
|
||||
if (!isRepeatConference(mNewIntent)) {
|
||||
return;
|
||||
}
|
||||
showRepeatConferenceDialog();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
|
||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||
if (requestCode == POST_NOTIFICATIONS_REQUEST_CODE && grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
||||
startForegroundService();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
Log.i(TAG, "onDestroy : " + this);
|
||||
}
|
||||
|
||||
private boolean startConferenceIfNeeded(Intent intent, ConferenceMainFragment fragment) {
|
||||
Serializable startSerializable = intent.getSerializableExtra(ConferenceDefine.KEY_START_CONFERENCE_PARAMS);
|
||||
if (startSerializable == null) {
|
||||
return false;
|
||||
}
|
||||
if (!(startSerializable instanceof ConferenceDefine.StartConferenceParams)) {
|
||||
Log.e(TAG, "params is not instanceof ConferenceDefine.StartConferenceParams");
|
||||
return false;
|
||||
}
|
||||
ConferenceDefine.StartConferenceParams startConferenceParams = (ConferenceDefine.StartConferenceParams) startSerializable;
|
||||
Log.i(TAG, "startConference : " + startConferenceParams);
|
||||
fragment.startConference(startConferenceParams);
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean joinConferenceIfNeeded(Intent intent, ConferenceMainFragment fragment) {
|
||||
Serializable joinSerializable = intent.getSerializableExtra(ConferenceDefine.KEY_JOIN_CONFERENCE_PARAMS);
|
||||
if (joinSerializable == null) {
|
||||
return false;
|
||||
}
|
||||
if (!(joinSerializable instanceof ConferenceDefine.JoinConferenceParams)) {
|
||||
Log.e(TAG, "params is not instanceof ConferenceDefine.JoinConferenceParams");
|
||||
return false;
|
||||
}
|
||||
ConferenceDefine.JoinConferenceParams joinConferenceParams = (ConferenceDefine.JoinConferenceParams) joinSerializable;
|
||||
Log.i(TAG, "joinConference : " + joinConferenceParams);
|
||||
fragment.joinConference(joinConferenceParams);
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean isRepeatConference(Intent intent) {
|
||||
if (!isConferenceParams(intent)) {
|
||||
return false;
|
||||
}
|
||||
if (!ConferenceController.sharedInstance().getViewController().isProcessRoom()) {
|
||||
return false;
|
||||
}
|
||||
Serializable serializable = intent.getSerializableExtra(ConferenceDefine.KEY_START_CONFERENCE_PARAMS);
|
||||
if (serializable instanceof ConferenceDefine.StartConferenceParams) {
|
||||
return !((ConferenceDefine.StartConferenceParams) serializable).roomId.equals(ConferenceController.sharedInstance().getRoomState().roomId.get());
|
||||
}
|
||||
serializable = intent.getSerializableExtra(ConferenceDefine.KEY_JOIN_CONFERENCE_PARAMS);
|
||||
if (serializable instanceof ConferenceDefine.JoinConferenceParams) {
|
||||
return !((ConferenceDefine.JoinConferenceParams) serializable).roomId.equals(ConferenceController.sharedInstance().getRoomState().roomId.get());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean isConferenceParams(Intent intent) {
|
||||
Serializable startSerializable = intent.getSerializableExtra(ConferenceDefine.KEY_START_CONFERENCE_PARAMS);
|
||||
if (startSerializable instanceof ConferenceDefine.StartConferenceParams) {
|
||||
return true;
|
||||
}
|
||||
Serializable joinSerializable = intent.getSerializableExtra(ConferenceDefine.KEY_JOIN_CONFERENCE_PARAMS);
|
||||
return joinSerializable instanceof ConferenceDefine.JoinConferenceParams;
|
||||
}
|
||||
|
||||
private void showRepeatConferenceDialog() {
|
||||
BaseDialogFragment.build()
|
||||
.setTitle(getString(R.string.tuiroomkit_repeat_start_room_dialog_title))
|
||||
.setContent(getString(R.string.tuiroomkit_repeat_start_room_dialog_content))
|
||||
.hideNegativeView()
|
||||
.setPositiveName(getString(R.string.tuiroomkit_i_see))
|
||||
.showDialog(this, "showRepeatConferenceDialog");
|
||||
}
|
||||
|
||||
private void dismissFloatWindowIfNeeded() {
|
||||
Intent intent = new Intent(this, RoomFloatViewService.class);
|
||||
stopService(intent);
|
||||
}
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
private void initStatusBar() {
|
||||
Window window = getWindow();
|
||||
int sdkVersion = TUIBuild.getVersionInt();
|
||||
if (sdkVersion >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
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 (sdkVersion >= Build.VERSION_CODES.KITKAT) {
|
||||
window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
|
||||
}
|
||||
}
|
||||
|
||||
private void startKeepAliveInBackground() {
|
||||
if (RoomPermissionUtil.hasNotificationPermission()) {
|
||||
startForegroundService();
|
||||
return;
|
||||
}
|
||||
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.POST_NOTIFICATIONS}, POST_NOTIFICATIONS_REQUEST_CODE);
|
||||
}
|
||||
|
||||
private void startForegroundService() {
|
||||
String appName = getApplicationInfo().loadLabel(getPackageManager()).toString();
|
||||
String notificationText = getString(R.string.tuiroomkit_app_running);
|
||||
if (RoomPermissionUtil.hasRecordAudioPermission()) {
|
||||
AudioForegroundService.start(this, appName, notificationText, 0);
|
||||
} else {
|
||||
MediaForegroundService.start(this, appName, notificationText, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
package com.tencent.cloud.tuikit.roomkit;
|
||||
|
||||
import com.tencent.cloud.tuikit.roomkit.impl.ConferenceSessionImpl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public abstract class ConferenceSession {
|
||||
public static ConferenceSession sharedInstance() {
|
||||
return ConferenceSessionImpl.sharedInstance();
|
||||
}
|
||||
|
||||
public static void destroySharedInstance() {
|
||||
ConferenceSessionImpl.destroySharedInstance();
|
||||
}
|
||||
|
||||
public abstract void addObserver(ConferenceDefine.ConferenceObserver observer);
|
||||
|
||||
public abstract void removeObserver(ConferenceDefine.ConferenceObserver observer);
|
||||
|
||||
public abstract void enableWaterMark();
|
||||
|
||||
public abstract void setWaterMarkText(String waterMarkText);
|
||||
|
||||
public abstract void setContactsViewProvider(Class<?> contactsActivity);
|
||||
|
||||
public abstract void setParticipants(List<ConferenceDefine.User> participants);
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
package com.tencent.cloud.tuikit.roomkit;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import com.tencent.cloud.tuikit.roomkit.view.schedule.scheduleinfo.ScheduleConferenceView;
|
||||
|
||||
|
||||
public class ScheduleConferenceActivity extends AppCompatActivity {
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(new ScheduleConferenceView(this));
|
||||
}
|
||||
}
|
||||
+63
@@ -0,0 +1,63 @@
|
||||
/**
|
||||
* Copyright (c) 2021 Tencent. All rights reserved.
|
||||
* Module: TUIRoomKit
|
||||
* Function: Multi-person audio and video main function interface.
|
||||
*/
|
||||
|
||||
package com.tencent.cloud.tuikit.roomkit;
|
||||
|
||||
import com.tencent.cloud.tuikit.engine.room.TUIRoomDefine;
|
||||
import com.tencent.cloud.tuikit.roomkit.impl.TUIRoomKitImpl;
|
||||
|
||||
/**
|
||||
* @deprecated Please use ConferenceMainFragment for conference UI integration.
|
||||
*/
|
||||
@Deprecated
|
||||
public abstract class TUIRoomKit {
|
||||
/**
|
||||
* 1.1 Create TUIRoomKit instance (single case mode)
|
||||
*/
|
||||
@Deprecated
|
||||
public static TUIRoomKit createInstance() {
|
||||
return TUIRoomKitImpl.sharedInstance();
|
||||
}
|
||||
|
||||
/**
|
||||
* 1.2 Destroy TUIRoomKit instance (singleton mode)
|
||||
*/
|
||||
@Deprecated
|
||||
public static void destroyInstance() {
|
||||
TUIRoomKitImpl.destroyInstance();
|
||||
}
|
||||
|
||||
/**
|
||||
* 2.1 Set personal information, including username and avatar
|
||||
*
|
||||
* @param userName The individual's username.
|
||||
* @param avatarURL Personal avatar link.
|
||||
*/
|
||||
@Deprecated
|
||||
public abstract void setSelfInfo(String userName, String avatarURL, TUIRoomDefine.ActionCallback callback);
|
||||
|
||||
/**
|
||||
* 3.1 Create a room
|
||||
*
|
||||
* @param roomInfo Parameters for creating a room, including room number, room name, etc., where roomId is required, and the rest can be default values.
|
||||
*/
|
||||
@Deprecated
|
||||
public abstract void createRoom(TUIRoomDefine.RoomInfo roomInfo, TUIRoomDefine.ActionCallback callback);
|
||||
|
||||
/**
|
||||
* 3.2 Enter the room
|
||||
*
|
||||
* @param roomId The room number to enter the room.
|
||||
* @param enableAudio true Enter the room to turn on the microphone and push local audio data to the remote end. Other members can hear the local sound normally;
|
||||
* false When entering the room, only the microphone is turned on and local audio data is not pushed to the remote end. Other members cannot hear the local sound;
|
||||
* @param enableVideo true Enter the room to turn on the camera and push local video data to the remote end. Other members can see the local picture normally;
|
||||
* false When entering the room, the camera will not be turned on and local video data will not be pushed to the remote end. Other members will not be able to see the local video;
|
||||
* @param isSoundOnSpeaker Whether to use the speaker to play sound, true to use the speaker, false to use the earpiece.
|
||||
*/
|
||||
@Deprecated
|
||||
public abstract void enterRoom(String roomId, boolean enableAudio, boolean enableVideo, boolean isSoundOnSpeaker,
|
||||
TUIRoomDefine.GetRoomInfoCallback callback);
|
||||
}
|
||||
+103
@@ -0,0 +1,103 @@
|
||||
package com.tencent.cloud.tuikit.roomkit.common.utils;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import com.tencent.qcloud.tuicore.util.TUIBuild;
|
||||
|
||||
public class BrandUtils {
|
||||
private static final String TAG = "BrandUtils";
|
||||
|
||||
private static String mBrand = "";
|
||||
private static String mManufacturer = "";
|
||||
private static String mModel = "";
|
||||
private static String mOsVersion = "";
|
||||
|
||||
private static void init() {
|
||||
getBrand();
|
||||
getManufacturer();
|
||||
getModel();
|
||||
getOsVersion();
|
||||
}
|
||||
|
||||
private static void getBrand() {
|
||||
if (TextUtils.isEmpty(mBrand)) {
|
||||
synchronized (BrandUtils.class) {
|
||||
if (TextUtils.isEmpty(mBrand)) {
|
||||
mBrand = TUIBuild.getBrand();
|
||||
Log.i(TAG, "get BRAND by Build.BRAND :" + mBrand);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void getManufacturer() {
|
||||
if (TextUtils.isEmpty(mManufacturer)) {
|
||||
synchronized (BrandUtils.class) {
|
||||
if (TextUtils.isEmpty(mManufacturer)) {
|
||||
mManufacturer = TUIBuild.getManufacturer();
|
||||
Log.i(TAG, "get MANUFACTURER by Build.MANUFACTURER :" + mManufacturer);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static String getModel() {
|
||||
if (TextUtils.isEmpty(mModel)) {
|
||||
synchronized (BrandUtils.class) {
|
||||
if (TextUtils.isEmpty(mModel)) {
|
||||
mModel = TUIBuild.getModel();
|
||||
Log.i(TAG, "get MODEL by Build.MODEL :" + mModel);
|
||||
}
|
||||
}
|
||||
}
|
||||
return mModel;
|
||||
}
|
||||
|
||||
public static String getOsVersion() {
|
||||
if (TextUtils.isEmpty(mOsVersion)) {
|
||||
synchronized (BrandUtils.class) {
|
||||
if (TextUtils.isEmpty(mOsVersion)) {
|
||||
mOsVersion = String.valueOf(TUIBuild.getVersionInt());
|
||||
Log.i(TAG, "get OS version by Build.VERSION :" + mOsVersion);
|
||||
}
|
||||
}
|
||||
}
|
||||
return mOsVersion;
|
||||
}
|
||||
|
||||
public static boolean isBrandXiaoMi() {
|
||||
init();
|
||||
return "xiaomi".equalsIgnoreCase(mBrand)
|
||||
|| "xiaomi".equalsIgnoreCase(mManufacturer);
|
||||
}
|
||||
|
||||
public static boolean isBrandHuawei() {
|
||||
init();
|
||||
return "huawei".equalsIgnoreCase(mBrand)
|
||||
|| "huawei".equalsIgnoreCase(mManufacturer);
|
||||
}
|
||||
|
||||
public static boolean isBrandMeizu() {
|
||||
init();
|
||||
return "meizu".equalsIgnoreCase(mBrand)
|
||||
|| "meizu".equalsIgnoreCase(mManufacturer)
|
||||
|| "22c4185e".equalsIgnoreCase(mBrand);
|
||||
}
|
||||
|
||||
public static boolean isBrandOppo() {
|
||||
init();
|
||||
return "oppo".equalsIgnoreCase(mBrand)
|
||||
|| "realme".equalsIgnoreCase(mBrand)
|
||||
|| "oneplus".equalsIgnoreCase(mBrand)
|
||||
|| "oppo".equalsIgnoreCase(mManufacturer)
|
||||
|| "realme".equalsIgnoreCase(mManufacturer)
|
||||
|| "oneplus".equalsIgnoreCase(mManufacturer);
|
||||
}
|
||||
|
||||
public static boolean isBrandVivo() {
|
||||
init();
|
||||
return "vivo".equalsIgnoreCase(mBrand)
|
||||
|| "vivo".equalsIgnoreCase(mManufacturer);
|
||||
}
|
||||
}
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
package com.tencent.cloud.tuikit.roomkit.common.utils;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import com.tencent.qcloud.tuicore.TUILogin;
|
||||
|
||||
public class BusinessSceneUtil {
|
||||
private static final String TAG = "BusinessSceneUtil";
|
||||
|
||||
private static boolean sIsChatAccessRoom = false;
|
||||
|
||||
private static String sCurRoomId = null;
|
||||
|
||||
public static boolean canJoinRoom() {
|
||||
int businessScene = TUILogin.getCurrentBusinessScene();
|
||||
Log.d(TAG, "canJoinRoom businessScene=" + businessScene);
|
||||
return businessScene == TUILogin.TUIBusinessScene.NONE
|
||||
|| businessScene == TUILogin.TUIBusinessScene.IN_MEETING_ROOM;
|
||||
}
|
||||
|
||||
public static void setJoinRoomFlag() {
|
||||
Log.d(TAG, "setJoinRoomFlag setCurrentBusinessScene : " + TUILogin.TUIBusinessScene.IN_MEETING_ROOM);
|
||||
TUILogin.setCurrentBusinessScene(TUILogin.TUIBusinessScene.IN_MEETING_ROOM);
|
||||
}
|
||||
|
||||
public static void clearJoinRoomFlag() {
|
||||
Log.d(TAG, "clearJoinRoomFlag setCurrentBusinessScene : " + TUILogin.TUIBusinessScene.NONE);
|
||||
TUILogin.setCurrentBusinessScene(TUILogin.TUIBusinessScene.NONE);
|
||||
}
|
||||
|
||||
public static boolean isChatAccessRoom() {
|
||||
return sIsChatAccessRoom;
|
||||
}
|
||||
|
||||
public static void setChatAccessRoom(boolean isChatAccessRoom) {
|
||||
Log.d(TAG, "setChatAccessRoom : " + isChatAccessRoom);
|
||||
sIsChatAccessRoom = isChatAccessRoom;
|
||||
}
|
||||
|
||||
public static void setCurRoomId(String roomId) {
|
||||
Log.d(TAG, "setCurRoomId : " + roomId);
|
||||
sCurRoomId = roomId;
|
||||
}
|
||||
|
||||
public static boolean isInTheRoom(String roomId) {
|
||||
return !TextUtils.isEmpty(roomId) && roomId.equals(sCurRoomId);
|
||||
}
|
||||
}
|
||||
+86
@@ -0,0 +1,86 @@
|
||||
package com.tencent.cloud.tuikit.roomkit.common.utils;
|
||||
|
||||
import android.content.ClipData;
|
||||
import android.content.ClipboardManager;
|
||||
import android.content.Context;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Color;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.google.zxing.BarcodeFormat;
|
||||
import com.google.zxing.EncodeHintType;
|
||||
import com.google.zxing.WriterException;
|
||||
import com.google.zxing.common.BitMatrix;
|
||||
import com.google.zxing.qrcode.QRCodeWriter;
|
||||
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
|
||||
import com.tencent.cloud.tuikit.roomkit.view.basic.RoomToast;
|
||||
import com.tencent.qcloud.tuicore.TUILogin;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class CommonUtils {
|
||||
|
||||
private static final int QR_CODE_MARGIN = 2;
|
||||
private static final String LABEL = "Label";
|
||||
private static final String ROBOT_PREFIX = "robot_";
|
||||
|
||||
public static String getAppName(Context context) {
|
||||
ApplicationInfo applicationInfo = context.getApplicationInfo();
|
||||
return context.getPackageManager().getApplicationLabel(applicationInfo).toString();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static Bitmap createQRCodeBitmap(String content, int width, int height) {
|
||||
Charset charset = StandardCharsets.UTF_8;
|
||||
if (TextUtils.isEmpty(content)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (width <= 0 || height <= 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Map<EncodeHintType, Object> hints = new HashMap<>();
|
||||
|
||||
if (charset != null && !TextUtils.isEmpty(charset.name())) {
|
||||
hints.put(EncodeHintType.CHARACTER_SET, charset.name());
|
||||
}
|
||||
hints.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.H);
|
||||
hints.put(EncodeHintType.MARGIN, QR_CODE_MARGIN);
|
||||
|
||||
try {
|
||||
BitMatrix bitMatrix = new QRCodeWriter().encode(content, BarcodeFormat.QR_CODE, width, height, hints);
|
||||
|
||||
int[] pixels = new int[width * height];
|
||||
for (int y = 0; y < height; y++) {
|
||||
for (int x = 0; x < width; x++) {
|
||||
pixels[y * width + x] = bitMatrix.get(x, y) ? Color.BLACK : Color.WHITE;
|
||||
}
|
||||
}
|
||||
|
||||
Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
|
||||
bitmap.setPixels(pixels, 0, width, 0, 0, width, height);
|
||||
return bitmap;
|
||||
} catch (WriterException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void copyToClipboard(String content, String toastMessage) {
|
||||
ClipboardManager cm = (ClipboardManager) TUILogin.getAppContext().getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
ClipData mClipData = ClipData.newPlainText(LABEL, content);
|
||||
cm.setPrimaryClip(mClipData);
|
||||
RoomToast.toastShortMessageCenter(toastMessage);
|
||||
}
|
||||
|
||||
public static boolean isRobot(String userId) {
|
||||
return !TextUtils.isEmpty(userId) && userId.startsWith(ROBOT_PREFIX);
|
||||
}
|
||||
}
|
||||
+142
@@ -0,0 +1,142 @@
|
||||
package com.tencent.cloud.tuikit.roomkit.common.utils;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.AppOpsManager;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.database.Cursor;
|
||||
import android.net.Uri;
|
||||
import android.os.Binder;
|
||||
import android.os.Build;
|
||||
import android.provider.Settings;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.tencent.qcloud.tuicore.TUILogin;
|
||||
import com.tencent.qcloud.tuicore.util.TUIBuild;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
public class DrawOverlaysPermissionUtil {
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
public static boolean isGrantedDrawOverlays() {
|
||||
Context context = TUILogin.getAppContext();
|
||||
if (BrandUtils.isBrandXiaoMi()) {
|
||||
if (TUIBuild.getVersionInt() >= Build.VERSION_CODES.M) {
|
||||
return Settings.canDrawOverlays(context);
|
||||
}
|
||||
|
||||
if (TUIBuild.getVersionInt() >= Build.VERSION_CODES.KITKAT) {
|
||||
return isXiaomiBgStartPermissionAllowed(context);
|
||||
}
|
||||
return true;
|
||||
} else if (BrandUtils.isBrandVivo()) {
|
||||
return isVivoBgStartPermissionAllowed(context);
|
||||
} else {
|
||||
if (TUIBuild.getVersionInt() >= Build.VERSION_CODES.M) {
|
||||
return Settings.canDrawOverlays(context);
|
||||
} else if (TUIBuild.getVersionInt() >= Build.VERSION_CODES.KITKAT) {
|
||||
return hasPermissionBelowMarshmallow(context);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public static void requestDrawOverlays() {
|
||||
Context context = TUILogin.getAppContext();
|
||||
if (isGrantedDrawOverlays()) {
|
||||
return;
|
||||
}
|
||||
if (BrandUtils.isBrandVivo()) {
|
||||
requestVivoFloatPermission(context);
|
||||
} else {
|
||||
startCommonSettings(context);
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean hasPermissionBelowMarshmallow(Context context) {
|
||||
try {
|
||||
AppOpsManager manager = null;
|
||||
if (TUIBuild.getVersionInt() >= Build.VERSION_CODES.KITKAT) {
|
||||
manager = (AppOpsManager) context.getSystemService(Context.APP_OPS_SERVICE);
|
||||
}
|
||||
if (manager == null) {
|
||||
return false;
|
||||
}
|
||||
Method dispatchMethod = AppOpsManager.class.getMethod("checkOp", int.class, int.class, String.class);
|
||||
return AppOpsManager.MODE_ALLOWED == (Integer) dispatchMethod.invoke(
|
||||
manager, 24, Binder.getCallingUid(), context.getApplicationContext().getPackageName());
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isXiaomiBgStartPermissionAllowed(Context context) {
|
||||
try {
|
||||
AppOpsManager appOpsManager = null;
|
||||
if (TUIBuild.getVersionInt() >= Build.VERSION_CODES.KITKAT) {
|
||||
appOpsManager = (AppOpsManager) context.getSystemService(Context.APP_OPS_SERVICE);
|
||||
}
|
||||
if (appOpsManager == null) {
|
||||
return false;
|
||||
}
|
||||
int op = 10021;
|
||||
Method method = appOpsManager.getClass().getMethod("checkOpNoThrow",
|
||||
new Class[]{int.class, int.class, String.class});
|
||||
method.setAccessible(true);
|
||||
int result = (int) method.invoke(appOpsManager, op, android.os.Process.myUid(), context.getPackageName());
|
||||
return AppOpsManager.MODE_ALLOWED == result;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static boolean isVivoBgStartPermissionAllowed(Context context) {
|
||||
try {
|
||||
Uri uri = Uri.parse("content://com.vivo.permissionmanager.provider.permission/start_bg_activity");
|
||||
Cursor cursor = context.getContentResolver().query(uri, null, "pkgname = ?",
|
||||
new String[]{context.getPackageName()},
|
||||
null);
|
||||
if (cursor.moveToFirst()) {
|
||||
int state = cursor.getInt(cursor.getColumnIndex("currentstate"));
|
||||
return 0 == state;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static void startCommonSettings(Context context) {
|
||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) {
|
||||
Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION);
|
||||
intent.setData(Uri.parse("package:" + context.getPackageName()));
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
context.startActivity(intent);
|
||||
}
|
||||
}
|
||||
|
||||
private static void requestVivoFloatPermission(Context context) {
|
||||
Intent vivoIntent = new Intent();
|
||||
String model = BrandUtils.getModel();
|
||||
boolean isVivoY85 = false;
|
||||
if (!TextUtils.isEmpty(model)) {
|
||||
isVivoY85 = model.contains("Y85") && !model.contains("Y85A");
|
||||
}
|
||||
|
||||
if (!TextUtils.isEmpty(model) && (isVivoY85 || model.contains("vivo Y53L"))) {
|
||||
vivoIntent.setClassName("com.vivo.permissionmanager",
|
||||
"com.vivo.permissionmanager.activity.PurviewTabActivity");
|
||||
vivoIntent.putExtra("tabId", "1");
|
||||
} else {
|
||||
vivoIntent.setClassName("com.vivo.permissionmanager",
|
||||
"com.vivo.permissionmanager.activity.SoftPermissionDetailActivity");
|
||||
vivoIntent.setAction("secure.intent.action.softPermissionDetail");
|
||||
}
|
||||
|
||||
vivoIntent.putExtra("packagename", context.getPackageName());
|
||||
vivoIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
context.startActivity(vivoIntent);
|
||||
}
|
||||
}
|
||||
+79
@@ -0,0 +1,79 @@
|
||||
package com.tencent.cloud.tuikit.roomkit.common.utils;
|
||||
|
||||
import static com.tencent.imsdk.BaseConstants.ERR_SUCC;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import com.tencent.imsdk.v2.V2TIMGroupInfoResult;
|
||||
import com.tencent.imsdk.v2.V2TIMManager;
|
||||
import com.tencent.imsdk.v2.V2TIMValueCallback;
|
||||
import com.tencent.qcloud.tuicore.interfaces.TUICallback;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
public class FetchRoomId {
|
||||
private static final String TAG = "FetchRoomId";
|
||||
|
||||
private static final int ROOM_ID_LENGTH = 6;
|
||||
|
||||
public interface GetRoomIdCallback {
|
||||
void onGetRoomId(String roomId);
|
||||
}
|
||||
|
||||
public static void fetch(GetRoomIdCallback callback) {
|
||||
String roomId = generateRandomRoomId(ROOM_ID_LENGTH);
|
||||
isRoomIdExisted(roomId, new TUICallback() {
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
fetch(callback);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(int errorCode, String errorMessage) {
|
||||
if (callback != null) {
|
||||
callback.onGetRoomId(roomId);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static String generateRandomRoomId(int numberOfDigits) {
|
||||
Random random = new Random();
|
||||
int minNumber = (int) Math.pow(10, numberOfDigits - 1);
|
||||
int maxNumber = (int) Math.pow(10, numberOfDigits) - 1;
|
||||
int randomNumber = random.nextInt(maxNumber - minNumber) + minNumber;
|
||||
String roomId = randomNumber + "";
|
||||
Log.d(TAG, "generateRandomRoomId : " + roomId);
|
||||
return roomId;
|
||||
}
|
||||
|
||||
private static void isRoomIdExisted(String roomId, TUICallback callback) {
|
||||
List<String> idList = new ArrayList<>(1);
|
||||
idList.add(roomId);
|
||||
Log.d(TAG, "getGroupsInfo roomId=" + roomId);
|
||||
V2TIMManager.getGroupManager().getGroupsInfo(idList, new V2TIMValueCallback<List<V2TIMGroupInfoResult>>() {
|
||||
@Override
|
||||
public void onSuccess(List<V2TIMGroupInfoResult> v2TIMGroupInfoResults) {
|
||||
Log.d(TAG, "getGroupsInfo onSuccess");
|
||||
if (v2TIMGroupInfoResults == null || v2TIMGroupInfoResults.isEmpty()) {
|
||||
callback.onError(0, "result is empty");
|
||||
return;
|
||||
}
|
||||
if (v2TIMGroupInfoResults.get(0).getResultCode() == ERR_SUCC) {
|
||||
callback.onSuccess();
|
||||
return;
|
||||
}
|
||||
callback.onError(v2TIMGroupInfoResults.get(0).getResultCode(),
|
||||
v2TIMGroupInfoResults.get(0).getResultMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(int code, String desc) {
|
||||
Log.d(TAG, "getGroupsInfo onError code=" + code + " desc=" + desc);
|
||||
callback.onError(code, desc);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
+152
@@ -0,0 +1,152 @@
|
||||
package com.tencent.cloud.tuikit.roomkit.common.utils;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapShader;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.RectF;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.text.TextUtils;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import androidx.annotation.DrawableRes;
|
||||
import androidx.annotation.RawRes;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.bumptech.glide.RequestBuilder;
|
||||
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
|
||||
import com.bumptech.glide.load.resource.bitmap.BitmapTransformation;
|
||||
import com.bumptech.glide.request.RequestOptions;
|
||||
|
||||
import java.security.MessageDigest;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
public class ImageLoader {
|
||||
private static int radius = 15;
|
||||
|
||||
public static void clear(Context context, ImageView imageView) {
|
||||
Glide.with(context).clear(imageView);
|
||||
}
|
||||
|
||||
public static void clear(Context context) {
|
||||
Glide.with(context).pauseRequests();
|
||||
}
|
||||
|
||||
public static void loadImage(Context context, ImageView imageView, String url) {
|
||||
loadImage(context, imageView, url, 0, radius);
|
||||
}
|
||||
|
||||
public static void loadImage(Context context, ImageView imageView, String url, @DrawableRes int errorResId) {
|
||||
loadImage(context, imageView, url, errorResId, radius);
|
||||
}
|
||||
|
||||
public static void loadImage(Context context, ImageView imageView, String url,
|
||||
@DrawableRes int errorResId, int radius) {
|
||||
if (TextUtils.isEmpty(url)) {
|
||||
if (imageView != null && errorResId != 0) {
|
||||
imageView.setImageResource(errorResId);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (context instanceof Activity && ((Activity)context).isDestroyed()) {
|
||||
return;
|
||||
}
|
||||
Glide.with(context).load(url).error(loadTransform(context, errorResId, radius)).into(imageView);
|
||||
}
|
||||
|
||||
public static void loadImage(Context context, ImageView imageView, @RawRes @DrawableRes Integer resourceId) {
|
||||
Glide.with(context).load(resourceId).into(imageView);
|
||||
}
|
||||
|
||||
public static Bitmap getImage(Context context, String url, int width, int height) {
|
||||
if (TextUtils.isEmpty(url)) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
Bitmap bitmap = Glide.with(context)
|
||||
.asBitmap()
|
||||
.load(url)
|
||||
.into(width, height)
|
||||
.get();
|
||||
return bitmap;
|
||||
} catch (ExecutionException e) {
|
||||
e.printStackTrace();
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void loadImageThumbnail(Context context, ImageView imageView,
|
||||
String url, @DrawableRes int resourceId, int radius) {
|
||||
Glide.with(context).load(url)
|
||||
.apply(new RequestOptions().placeholder(resourceId).error(resourceId).centerCrop()
|
||||
.transform(new GlideRoundTransform(imageView.getContext(), radius)))
|
||||
.thumbnail(loadTransform(imageView.getContext(), resourceId, radius))
|
||||
.into(imageView);
|
||||
}
|
||||
|
||||
public static void loadGifImage(Context context, ImageView imageView, String url) {
|
||||
loadGifImage(context, imageView, url, 0);
|
||||
}
|
||||
|
||||
public static void loadGifImage(Context context, ImageView imageView, String url, @DrawableRes int errorResId) {
|
||||
if (TextUtils.isEmpty(url)) {
|
||||
if (imageView != null && errorResId != 0) {
|
||||
imageView.setImageResource(errorResId);
|
||||
}
|
||||
return;
|
||||
}
|
||||
Glide.with(context).asGif().load(url).into(imageView);
|
||||
}
|
||||
|
||||
public static void loadGifImage(Context context, ImageView imageView, @RawRes @DrawableRes int resourceId) {
|
||||
Glide.with(context).asGif().load(resourceId).into(imageView);
|
||||
}
|
||||
|
||||
private static RequestBuilder<Drawable> loadTransform(Context context, @DrawableRes int placeholderId, int radius) {
|
||||
return Glide.with(context).load(placeholderId)
|
||||
.apply(new RequestOptions().centerCrop().transform(new GlideRoundTransform(context, radius)));
|
||||
}
|
||||
|
||||
public static class GlideRoundTransform extends BitmapTransformation {
|
||||
|
||||
private static float radius = 0f;
|
||||
|
||||
public GlideRoundTransform(Context context, int dp) {
|
||||
radius = Resources.getSystem().getDisplayMetrics().density * dp;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Bitmap transform(BitmapPool pool, Bitmap toTransform, int outWidth, int outHeight) {
|
||||
return roundCrop(pool, toTransform);
|
||||
}
|
||||
|
||||
private static Bitmap roundCrop(BitmapPool pool, Bitmap source) {
|
||||
if (source == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Bitmap result = pool.get(source.getWidth(), source.getHeight(), Bitmap.Config.ARGB_8888);
|
||||
if (result == null) {
|
||||
result = Bitmap.createBitmap(source.getWidth(), source.getHeight(), Bitmap.Config.ARGB_8888);
|
||||
}
|
||||
|
||||
Canvas canvas = new Canvas(result);
|
||||
Paint paint = new Paint();
|
||||
paint.setShader(new BitmapShader(source, BitmapShader.TileMode.CLAMP, BitmapShader.TileMode.CLAMP));
|
||||
paint.setAntiAlias(true);
|
||||
RectF rectF = new RectF(0f, 0f, source.getWidth(), source.getHeight());
|
||||
canvas.drawRoundRect(rectF, radius, radius, paint);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateDiskCacheKey(MessageDigest messageDigest) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
package com.tencent.cloud.tuikit.roomkit.common.utils;
|
||||
|
||||
import android.app.Application;
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.util.Log;
|
||||
|
||||
public class IntentUtils {
|
||||
private static final String TAG = "IntentUtils";
|
||||
|
||||
public static void safeStartActivity(Context context, Intent intent) {
|
||||
if (intent == null || context == null) {
|
||||
Log.e(TAG, "intent or activity is null");
|
||||
return;
|
||||
}
|
||||
if (context.getPackageManager().resolveActivity(intent, PackageManager.MATCH_DEFAULT_ONLY) == null) {
|
||||
Log.w(TAG, "No activity match : " + intent.toString());
|
||||
return;
|
||||
}
|
||||
try {
|
||||
if (context instanceof Application) {
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
}
|
||||
context.startActivity(intent);
|
||||
} catch (ActivityNotFoundException e) {
|
||||
Log.e(TAG, "ActivityNotFoundException : " + intent.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
package com.tencent.cloud.tuikit.roomkit.common.utils;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import com.tencent.cloud.tuikit.engine.room.TUIRoomEngine;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
public class MetricsStats {
|
||||
private static final String TAG = "MetricsStats";
|
||||
|
||||
public static final int T_METRICS_WATER_MARK_ENABLE = 106054;
|
||||
public static final int T_METRICS_CHAT_PANEL_SHOW = 106057;
|
||||
public static final int T_METRICS_WATER_MARK_CUSTOM_TEXT = 106060;
|
||||
public static final int T_METRICS_BARRAGE_PANEL_SHOW = 106061;
|
||||
public static final int T_METRICS_BARRAGE_SEND_MESSAGE = 106062;
|
||||
public static final int T_METRICS_FLOAT_WINDOW_SHOW = 106063;
|
||||
public static final int T_METRICS_USER_LIST_PANEL_SHOW = 106064;
|
||||
public static final int T_METRICS_USER_LIST_SEARCH = 106065;
|
||||
public static final int T_METRICS_SETTINGS_PANEL_SHOW = 106066;
|
||||
public static final int T_METRICS_SHARE_ROOM_INFO_PANEL_SHOW = 106067;
|
||||
public static final int T_METRICS_CONFERENCE_SCHEDULE_PANEL_SHOW = 106068;
|
||||
public static final int T_METRICS_CONFERENCE_MODIFY_PANEL_SHOW = 106069;
|
||||
public static final int T_METRICS_CONFERENCE_INFO_PANEL_SHOW = 106070;
|
||||
public static final int T_METRICS_CONFERENCE_ATTENDEE = 106071;
|
||||
|
||||
public static void submit(int eventKey) {
|
||||
try {
|
||||
JSONObject params = new JSONObject();
|
||||
params.put("key", eventKey);
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("api", "KeyMetricsStats");
|
||||
jsonObject.put("params", params);
|
||||
String json = jsonObject.toString();
|
||||
TUIRoomEngine.callExperimentalAPI(json);
|
||||
Log.i(TAG, "submit : " + json);
|
||||
} catch (JSONException e) {
|
||||
Log.e(TAG, "submit JSONException : " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
package com.tencent.cloud.tuikit.roomkit.common.utils;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Application;
|
||||
import android.content.Context;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
||||
public class RTCubeUtils {
|
||||
private static final String RTCUBE_PACKAGE_NAME = "com.tencent.trtc";
|
||||
private static final String PACKAGE_TENCENT_RTC = "com.tencent.rtc.app";
|
||||
|
||||
public static String getApplicationName(Context context) {
|
||||
PackageManager packageManager = null;
|
||||
ApplicationInfo applicationInfo;
|
||||
try {
|
||||
packageManager = context.getPackageManager();
|
||||
applicationInfo = packageManager.getApplicationInfo(context.getPackageName(), 0);
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
applicationInfo = null;
|
||||
}
|
||||
String applicationName = (String) packageManager.getApplicationLabel(applicationInfo);
|
||||
return TextUtils.isEmpty(applicationName) ? "" : applicationName;
|
||||
}
|
||||
|
||||
public static boolean isRTCubeApp(Context context) {
|
||||
return RTCUBE_PACKAGE_NAME.equals(context.getPackageName());
|
||||
}
|
||||
|
||||
public static boolean isTencentRTC(Context context) {
|
||||
return TextUtils.equals(context.getPackageName(), PACKAGE_TENCENT_RTC);
|
||||
}
|
||||
|
||||
public static String getPackageName() {
|
||||
return getApplicationByReflect().getPackageName();
|
||||
}
|
||||
|
||||
public static Application getApplicationByReflect() {
|
||||
try {
|
||||
@SuppressLint("PrivateApi") Class<?> activityThread = Class.forName("android.app.ActivityThread");
|
||||
Object thread = activityThread.getMethod("currentActivityThread").invoke(null);
|
||||
Object app = activityThread.getMethod("getApplication").invoke(thread);
|
||||
if (app == null) {
|
||||
throw new NullPointerException("You should init first.");
|
||||
}
|
||||
return (Application) app;
|
||||
} catch (NoSuchMethodException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
} catch (InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
} catch (ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
throw new NullPointerException("You should init first.");
|
||||
}
|
||||
}
|
||||
+75
@@ -0,0 +1,75 @@
|
||||
package com.tencent.cloud.tuikit.roomkit.common.utils;
|
||||
|
||||
import android.Manifest;
|
||||
import android.content.Context;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.Build;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
import com.tencent.cloud.tuikit.roomkit.R;
|
||||
import com.tencent.qcloud.tuicore.TUIConstants;
|
||||
import com.tencent.qcloud.tuicore.TUICore;
|
||||
import com.tencent.qcloud.tuicore.permission.PermissionCallback;
|
||||
import com.tencent.qcloud.tuicore.permission.PermissionRequester;
|
||||
import com.tencent.qcloud.tuicore.util.TUIBuild;
|
||||
import com.trtc.tuikit.common.system.ContextProvider;
|
||||
|
||||
public class RoomPermissionUtil {
|
||||
public static void requestCameraPermission(Context context, PermissionCallback callback) {
|
||||
String title =
|
||||
context.getString(R.string.tuiroomkit_permission_camera_reason_title, CommonUtils.getAppName(context));
|
||||
String description = (String) TUICore.createObject(TUIConstants.Privacy.PermissionsFactory.FACTORY_NAME,
|
||||
TUIConstants.Privacy.PermissionsFactory.PermissionsName.CAMERA_PERMISSIONS, null);
|
||||
description = TextUtils.isEmpty(description) ? context.getString(R.string.tuiroomkit_permission_camera_reason) :
|
||||
description;
|
||||
|
||||
String tip = (String) TUICore.createObject(TUIConstants.Privacy.PermissionsFactory.FACTORY_NAME,
|
||||
TUIConstants.Privacy.PermissionsFactory.PermissionsName.CAMERA_PERMISSIONS_TIP, null);
|
||||
tip = TextUtils.isEmpty(tip) ? context.getString(R.string.tuiroomkit_tips_start_camera) : tip;
|
||||
|
||||
PermissionRequester.newInstance(Manifest.permission.CAMERA)
|
||||
.title(title)
|
||||
.description(description)
|
||||
.settingsTip(tip)
|
||||
.callback(callback)
|
||||
.request();
|
||||
}
|
||||
|
||||
public static void requestAudioPermission(Context context, PermissionCallback callback) {
|
||||
String title =
|
||||
context.getString(R.string.tuiroomkit_permission_mic_reason_title, CommonUtils.getAppName(context));
|
||||
String description = (String) TUICore.createObject(TUIConstants.Privacy.PermissionsFactory.FACTORY_NAME,
|
||||
TUIConstants.Privacy.PermissionsFactory.PermissionsName.MICROPHONE_PERMISSIONS, null);
|
||||
description = TextUtils.isEmpty(description) ? context.getString(R.string.tuiroomkit_permission_mic_reason) :
|
||||
description;
|
||||
|
||||
String tip = (String) TUICore.createObject(TUIConstants.Privacy.PermissionsFactory.FACTORY_NAME,
|
||||
TUIConstants.Privacy.PermissionsFactory.PermissionsName.MICROPHONE_PERMISSIONS_TIP, null);
|
||||
tip = TextUtils.isEmpty(tip) ? context.getString(R.string.tuiroomkit_tips_start_audio) : tip;
|
||||
|
||||
PermissionRequester.newInstance(Manifest.permission.RECORD_AUDIO)
|
||||
.title(title)
|
||||
.description(description)
|
||||
.settingsTip(tip)
|
||||
.callback(callback)
|
||||
.request();
|
||||
}
|
||||
|
||||
public static boolean hasRecordAudioPermission() {
|
||||
if (TUIBuild.getVersionInt() < Build.VERSION_CODES.M) {
|
||||
return true;
|
||||
}
|
||||
return ContextCompat.checkSelfPermission(ContextProvider.getApplicationContext(), Manifest.permission.RECORD_AUDIO)
|
||||
== PackageManager.PERMISSION_GRANTED;
|
||||
}
|
||||
|
||||
public static boolean hasNotificationPermission() {
|
||||
if (TUIBuild.getVersionInt() < Build.VERSION_CODES.TIRAMISU) {
|
||||
return true;
|
||||
}
|
||||
return ContextCompat.checkSelfPermission(ContextProvider.getApplicationContext(), Manifest.permission.POST_NOTIFICATIONS)
|
||||
== PackageManager.PERMISSION_GRANTED;
|
||||
}
|
||||
}
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
package com.tencent.cloud.tuikit.roomkit.common.utils;
|
||||
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.tencent.qcloud.tuicore.TUILogin;
|
||||
import com.tencent.qcloud.tuicore.util.SPUtils;
|
||||
|
||||
public class RoomSpUtil {
|
||||
private static final String ROOM_SP_FILE_NAME = "ROOM_SP_FILE_NAME";
|
||||
private static final String SP_ROOM_ID = "ROOM_ID";
|
||||
private static final String SP_ROOM_AUDIO_SWITCH = "ROOM_AUDIO_SWITCH";
|
||||
private static final String SP_ROOM_VIDEO_SWITCH = "ROOM_VIDEO_SWITCH";
|
||||
|
||||
public static void saveAudioSwitchToSp(boolean isOpen) {
|
||||
SPUtils sp = SPUtils.getInstance(ROOM_SP_FILE_NAME);
|
||||
sp.put(SP_ROOM_AUDIO_SWITCH, isOpen);
|
||||
}
|
||||
|
||||
public static boolean getAudioSwitchFromSp() {
|
||||
SPUtils sp = SPUtils.getInstance(ROOM_SP_FILE_NAME);
|
||||
return sp.getBoolean(SP_ROOM_AUDIO_SWITCH, true);
|
||||
}
|
||||
|
||||
public static void saveVideoSwitchToSp(boolean isOpen) {
|
||||
SPUtils sp = SPUtils.getInstance(ROOM_SP_FILE_NAME);
|
||||
sp.put(SP_ROOM_VIDEO_SWITCH, isOpen);
|
||||
}
|
||||
|
||||
public static boolean getVideoSwitchFromSp() {
|
||||
SPUtils sp = SPUtils.getInstance(ROOM_SP_FILE_NAME);
|
||||
return sp.getBoolean(SP_ROOM_VIDEO_SWITCH, true);
|
||||
}
|
||||
|
||||
public static String getUniqueRoomId() {
|
||||
SPUtils sp = SPUtils.getInstance(ROOM_SP_FILE_NAME);
|
||||
String roomId = sp.getString(SP_ROOM_ID);
|
||||
if (TextUtils.isEmpty(roomId) || roomId.length() < 4) {
|
||||
roomId = "100" + TUILogin.getUserId();
|
||||
sp.put(SP_ROOM_ID, roomId);
|
||||
return roomId;
|
||||
}
|
||||
String str = roomId.substring(0, 3);
|
||||
int count = 100;
|
||||
try {
|
||||
count = Integer.parseInt(str) + 1;
|
||||
} catch (NumberFormatException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
count = count < 1000 ? count : 100;
|
||||
roomId = count + TUILogin.getUserId();
|
||||
sp.put(SP_ROOM_ID, roomId);
|
||||
return roomId;
|
||||
}
|
||||
}
|
||||
+94
@@ -0,0 +1,94 @@
|
||||
package com.tencent.cloud.tuikit.roomkit.common.utils;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.os.Handler;
|
||||
import android.os.HandlerThread;
|
||||
import android.os.Looper;
|
||||
import android.provider.MediaStore;
|
||||
|
||||
import com.tencent.cloud.tuikit.roomkit.R;
|
||||
import com.tencent.cloud.tuikit.roomkit.view.basic.RoomToast;
|
||||
|
||||
public class SaveBitMap {
|
||||
|
||||
private boolean mIsPrecessing;
|
||||
private Handler mHandler;
|
||||
private HandlerThread mHandlerThread;
|
||||
|
||||
public SaveBitMap() {
|
||||
mHandlerThread = new HandlerThread("save-bitmap-thread");
|
||||
mHandlerThread.start();
|
||||
mHandler = new Handler(mHandlerThread.getLooper());
|
||||
mIsPrecessing = false;
|
||||
}
|
||||
|
||||
public void saveToAlbum(final Context context, final Bitmap bitmap) {
|
||||
if (bitmap == null) {
|
||||
RoomToast.toastShortMessage(context.getString(R.string.tuiroomkit_get_image_failed));
|
||||
return;
|
||||
}
|
||||
if (mIsPrecessing) {
|
||||
return;
|
||||
}
|
||||
mIsPrecessing = true;
|
||||
final SaveBitMapRunnable runnable = new SaveBitMapRunnable(context, bitmap);
|
||||
runnable.setListener(new SaveProgressListener() {
|
||||
@Override
|
||||
public void onEnd() {
|
||||
mIsPrecessing = false;
|
||||
mHandler.removeCallbacks(runnable);
|
||||
}
|
||||
});
|
||||
mHandler.post(runnable);
|
||||
}
|
||||
|
||||
private static class SaveBitMapRunnable implements Runnable {
|
||||
private Context mContext;
|
||||
private Bitmap mBitmap;
|
||||
private SaveProgressListener mListener;
|
||||
private Handler mMainHandler;
|
||||
|
||||
public SaveBitMapRunnable(Context context, Bitmap bitmap) {
|
||||
mMainHandler = new Handler(Looper.getMainLooper());
|
||||
mContext = context;
|
||||
mBitmap = bitmap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
MediaStore.Images.Media.insertImage(mContext.getContentResolver(), mBitmap,
|
||||
null, null);
|
||||
mMainHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (mListener != null) {
|
||||
mListener.onEnd();
|
||||
}
|
||||
RoomToast.toastShortMessage(mContext.getString(R.string.tuiroomkit_save_image_success));
|
||||
}
|
||||
});
|
||||
} catch (Exception e) {
|
||||
mMainHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (mListener != null) {
|
||||
mListener.onEnd();
|
||||
}
|
||||
RoomToast.toastShortMessage(mContext.getString(R.string.tuiroomkit_save_image_failed));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public void setListener(SaveProgressListener listener) {
|
||||
this.mListener = listener;
|
||||
}
|
||||
}
|
||||
|
||||
public interface SaveProgressListener {
|
||||
void onEnd();
|
||||
}
|
||||
}
|
||||
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
package com.tencent.cloud.tuikit.roomkit.common.utils;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class UserModel implements Serializable {
|
||||
public String phone;
|
||||
public String email;
|
||||
public String userId;
|
||||
public int appId;
|
||||
public String userSig;
|
||||
public String userName;
|
||||
public String userAvatar;
|
||||
public UserType userType = UserType.NONE;
|
||||
|
||||
public enum UserType {
|
||||
NONE,
|
||||
ROOM,
|
||||
CALLING,
|
||||
CHAT_SALON,
|
||||
VOICE_ROOM,
|
||||
LIVE_ROOM,
|
||||
CHORUS,
|
||||
KARAOKE
|
||||
}
|
||||
}
|
||||
+115
@@ -0,0 +1,115 @@
|
||||
package com.tencent.cloud.tuikit.roomkit.common.utils;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.tencent.qcloud.tuicore.util.SPUtils;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
public class UserModelManager {
|
||||
private static final String TAG = "UserModelManager";
|
||||
|
||||
private static final String PER_DATA = "per_profile_manager";
|
||||
private static final String PER_USER_MODEL = "per_user_model";
|
||||
private static final String PER_USER_DATE = "per_user_publish_video_date";
|
||||
private static final String USAGE_MODEL = "usage_model";
|
||||
private static final String HAVE_BACKSTAGE = "have_backstage";
|
||||
|
||||
private static UserModelManager sInstance;
|
||||
private UserModel mUserModel;
|
||||
private String mUserPubishVideoDate;
|
||||
private Boolean mHaveBackstage;
|
||||
|
||||
public static UserModelManager getInstance() {
|
||||
if (sInstance == null) {
|
||||
synchronized (UserModelManager.class) {
|
||||
if (sInstance == null) {
|
||||
sInstance = new UserModelManager();
|
||||
}
|
||||
}
|
||||
}
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
public synchronized UserModel getUserModel() {
|
||||
if (mUserModel == null) {
|
||||
loadUserModel();
|
||||
}
|
||||
return mUserModel == null ? new UserModel() : mUserModel;
|
||||
}
|
||||
|
||||
public synchronized void setUserModel(UserModel model) {
|
||||
mUserModel = model;
|
||||
try {
|
||||
Gson gson = new Gson();
|
||||
SPUtils.getInstance(PER_DATA).put(PER_USER_MODEL, gson.toJson(mUserModel));
|
||||
} catch (Exception e) {
|
||||
Log.d(TAG, "");
|
||||
}
|
||||
}
|
||||
|
||||
private void loadUserModel() {
|
||||
try {
|
||||
String json = SPUtils.getInstance(PER_DATA).getString(PER_USER_MODEL);
|
||||
Gson gson = new Gson();
|
||||
mUserModel = gson.fromJson(json, UserModel.class);
|
||||
} catch (Exception e) {
|
||||
Log.d(TAG, "loadUserModel failed:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void clearUserModel() {
|
||||
mUserModel = null;
|
||||
try {
|
||||
SPUtils.getInstance(PER_DATA).put(PER_USER_MODEL, "");
|
||||
} catch (Exception e) {
|
||||
Log.d(TAG, "clea user model error:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private String getUserPublishVideoDate() {
|
||||
if (mUserPubishVideoDate == null) {
|
||||
mUserPubishVideoDate = SPUtils.getInstance(PER_DATA).getString(PER_USER_DATE, "");
|
||||
}
|
||||
return mUserPubishVideoDate;
|
||||
}
|
||||
|
||||
private void setUserPublishVideoDate(String date) {
|
||||
mUserPubishVideoDate = date;
|
||||
try {
|
||||
SPUtils.getInstance(PER_DATA).put(PER_USER_DATE, mUserPubishVideoDate);
|
||||
} catch (Exception e) {
|
||||
Log.d(TAG, "setUserPublishVideoDate failed:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public void setUsageModel(boolean haveBackstage) {
|
||||
mHaveBackstage = haveBackstage;
|
||||
try {
|
||||
SPUtils.getInstance(USAGE_MODEL).put(HAVE_BACKSTAGE, mHaveBackstage);
|
||||
} catch (Exception e) {
|
||||
Log.d(TAG, "setUsageModel failed");
|
||||
}
|
||||
}
|
||||
|
||||
public boolean haveBackstage() {
|
||||
if (mHaveBackstage == null) {
|
||||
mHaveBackstage = SPUtils.getInstance(USAGE_MODEL).getBoolean(HAVE_BACKSTAGE, true);
|
||||
}
|
||||
return mHaveBackstage;
|
||||
}
|
||||
|
||||
public boolean needShowSecurityTips() {
|
||||
String profileDate = getUserPublishVideoDate();
|
||||
Date date = new Date();
|
||||
SimpleDateFormat formatter = new SimpleDateFormat("dd");
|
||||
String day = formatter.format(date);
|
||||
if (!day.equals(profileDate)) {
|
||||
setUserPublishVideoDate(day);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
+174
@@ -0,0 +1,174 @@
|
||||
package com.tencent.cloud.tuikit.roomkit.debug;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import android.util.Base64;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.Arrays;
|
||||
import java.util.zip.Deflater;
|
||||
|
||||
import javax.crypto.Mac;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
|
||||
/*
|
||||
*
|
||||
*
|
||||
* Description: Generates UserSig for testing. UserSig is a security signature designed
|
||||
* by Tencent Cloud for its cloud services.
|
||||
* It is calculated based on `SDKAppID`, `UserID`,
|
||||
* and `EXPIRE_TIME` using the HMAC-SHA256 encryption algorithm.
|
||||
*
|
||||
* Attention: For the following reasons, do not use the code below in your commercial application.
|
||||
*
|
||||
* The code may be able to calculate UserSig correctly, b
|
||||
* ut it is only for quick testing of the SDK’s basic features,
|
||||
* not for commercial applications.
|
||||
* `SDKSecretKey` in client code can be easily decompiled and reversed, especially on web.
|
||||
* Once your key is disclosed, attackers will be able to steal your Tencent Cloud traffic.
|
||||
*
|
||||
* The correct method is to deploy the `UserSig` calculation code and encryption key on your server
|
||||
* so that your application can request a `UserSig` from your server,
|
||||
* which will calculate it whenever one is needed.
|
||||
* Given that it is more difficult to hack a server than a client application,
|
||||
* server-end calculation can better protect your key.
|
||||
*
|
||||
* Reference: https://cloud.tencent.com/document/product/269/32688#Server
|
||||
*/
|
||||
public class GenerateTestUserSig {
|
||||
|
||||
/**
|
||||
* Signature validity period, which should not be set too short
|
||||
* <p>
|
||||
* Unit: Second
|
||||
* Default value: 604800 (seven days)
|
||||
*/
|
||||
private static final int EXPIRE_TIME = 604800;
|
||||
|
||||
/**
|
||||
* Calculating UserSig
|
||||
* <p>
|
||||
* The asymmetric encryption algorithm HMAC-SHA256 is used in the
|
||||
* function to calculate UserSig based on `SDKAppID`, `UserID`, and `EXPIRE_TIME`.
|
||||
*
|
||||
* @note: For the following reasons, do not use the code below in your commercial application.
|
||||
* <p>
|
||||
* The code may be able to calculate UserSig correctly,
|
||||
* but it is only for quick testing of the SDK’s basic features,
|
||||
* not for commercial applications.
|
||||
* SDKSecretKey in client code can be easily decompiled and reversed, especially on web.
|
||||
* Once your key is disclosed, attackers will be able to steal your Tencent Cloud traffic.
|
||||
* <p>
|
||||
* The correct method is to deploy the `UserSig` calculation code and encryption key on your server
|
||||
* so that your application can request a `UserSig` from your server,
|
||||
* which will calculate it whenever one is needed.
|
||||
* Given that it is more difficult to hack a server than a client application,
|
||||
* server-end calculation can better protect your key.
|
||||
* <p>
|
||||
* Documentation: https://cloud.tencent.com/document/product/269/32688#Server
|
||||
*/
|
||||
public static String genTestUserSig(int sdkAppId, String userId, String sdkSecretKey) {
|
||||
return genTLSSignature(sdkAppId, userId, EXPIRE_TIME, null, sdkSecretKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generating a TLS Ticket
|
||||
*
|
||||
* @param sdkappid `appid` of your application
|
||||
* @param userId User ID
|
||||
* @param expire Validity period in seconds
|
||||
* @param userbuf `null` by default
|
||||
* @param priKeyContent Private key required for generating a TLS ticket
|
||||
* @return If an error occurs, an empty string will be returned or exceptions printed.
|
||||
* If the operation succeeds, a valid ticket will be returned.
|
||||
*/
|
||||
private static String genTLSSignature(long sdkappid, String userId,
|
||||
long expire, byte[] userbuf, String priKeyContent) {
|
||||
if (TextUtils.isEmpty(priKeyContent)) {
|
||||
return "";
|
||||
}
|
||||
long currTime = System.currentTimeMillis() / 1000;
|
||||
JSONObject sigDoc = new JSONObject();
|
||||
try {
|
||||
sigDoc.put("TLS.ver", "2.0");
|
||||
sigDoc.put("TLS.identifier", userId);
|
||||
sigDoc.put("TLS.sdkappid", sdkappid);
|
||||
sigDoc.put("TLS.expire", expire);
|
||||
sigDoc.put("TLS.time", currTime);
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
String base64UserBuf = null;
|
||||
if (null != userbuf) {
|
||||
base64UserBuf = Base64.encodeToString(userbuf, Base64.NO_WRAP);
|
||||
try {
|
||||
sigDoc.put("TLS.userbuf", base64UserBuf);
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
String sig = hmacsha256(sdkappid, userId, currTime, expire, priKeyContent, base64UserBuf);
|
||||
if (sig.length() == 0) {
|
||||
return "";
|
||||
}
|
||||
try {
|
||||
sigDoc.put("TLS.sig", sig);
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
Deflater compressor = new Deflater();
|
||||
compressor.setInput(sigDoc.toString().getBytes(Charset.forName("UTF-8")));
|
||||
compressor.finish();
|
||||
byte[] compressedBytes = new byte[2048];
|
||||
int compressedBytesLength = compressor.deflate(compressedBytes);
|
||||
compressor.end();
|
||||
return new String(base64EncodeUrl(Arrays.copyOfRange(compressedBytes, 0, compressedBytesLength)));
|
||||
}
|
||||
|
||||
|
||||
private static String hmacsha256(long sdkappid, String userId, long currTime,
|
||||
long expire, String priKeyContent, String base64Userbuf) {
|
||||
String contentToBeSigned = "TLS.identifier:" + userId + "\n"
|
||||
+ "TLS.sdkappid:" + sdkappid + "\n"
|
||||
+ "TLS.time:" + currTime + "\n"
|
||||
+ "TLS.expire:" + expire + "\n";
|
||||
if (null != base64Userbuf) {
|
||||
contentToBeSigned += "TLS.userbuf:" + base64Userbuf + "\n";
|
||||
}
|
||||
try {
|
||||
byte[] byteKey = priKeyContent.getBytes("UTF-8");
|
||||
Mac hmac = Mac.getInstance("HmacSHA256");
|
||||
SecretKeySpec keySpec = new SecretKeySpec(byteKey, "HmacSHA256");
|
||||
hmac.init(keySpec);
|
||||
byte[] byteSig = hmac.doFinal(contentToBeSigned.getBytes("UTF-8"));
|
||||
return new String(Base64.encode(byteSig, Base64.NO_WRAP));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
private static byte[] base64EncodeUrl(byte[] input) {
|
||||
byte[] base64 = new String(Base64.encode(input, Base64.NO_WRAP)).getBytes();
|
||||
for (int i = 0; i < base64.length; ++i) {
|
||||
switch (base64[i]) {
|
||||
case '+':
|
||||
base64[i] = '*';
|
||||
break;
|
||||
case '/':
|
||||
base64[i] = '-';
|
||||
break;
|
||||
case '=':
|
||||
base64[i] = '_';
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
return base64;
|
||||
}
|
||||
|
||||
}
|
||||
+79
@@ -0,0 +1,79 @@
|
||||
package com.tencent.cloud.tuikit.roomkit.impl;
|
||||
|
||||
import com.tencent.cloud.tuikit.roomkit.ConferenceDefine;
|
||||
import com.tencent.cloud.tuikit.roomkit.ConferenceSession;
|
||||
import com.tencent.cloud.tuikit.roomkit.common.utils.MetricsStats;
|
||||
import com.tencent.cloud.tuikit.roomkit.manager.observer.ConferenceObserverManager;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ConferenceSessionImpl extends ConferenceSession {
|
||||
public boolean mIsEnableWaterMark = false;
|
||||
public String mWaterMarkText = "";
|
||||
|
||||
public Class<?> mContactsActivity;
|
||||
public List<ConferenceDefine.User> mParticipants;
|
||||
|
||||
private static ConferenceSessionImpl sInstance;
|
||||
private final ConferenceObserverManager mConferenceObserverManager = new ConferenceObserverManager();
|
||||
|
||||
public boolean isShowAISpeechToTextButton = false;
|
||||
|
||||
private ConferenceSessionImpl() {}
|
||||
|
||||
public static ConferenceSessionImpl sharedInstance() {
|
||||
if (sInstance == null) {
|
||||
synchronized (ConferenceSessionImpl.class) {
|
||||
if (sInstance == null) {
|
||||
sInstance = new ConferenceSessionImpl();
|
||||
}
|
||||
}
|
||||
}
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
public static void destroySharedInstance() {
|
||||
synchronized (ConferenceSessionImpl.class) {
|
||||
if (sInstance != null) {
|
||||
sInstance.destroy();
|
||||
sInstance = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addObserver(ConferenceDefine.ConferenceObserver observer) {
|
||||
mConferenceObserverManager.addObserver(observer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeObserver(ConferenceDefine.ConferenceObserver observer) {
|
||||
mConferenceObserverManager.removeObserver(observer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enableWaterMark() {
|
||||
mIsEnableWaterMark = true;
|
||||
MetricsStats.submit(MetricsStats.T_METRICS_WATER_MARK_ENABLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setWaterMarkText(String waterMarkText) {
|
||||
mWaterMarkText = waterMarkText;
|
||||
MetricsStats.submit(MetricsStats.T_METRICS_WATER_MARK_CUSTOM_TEXT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setContactsViewProvider(Class<?> contactsActivity) {
|
||||
mContactsActivity = contactsActivity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setParticipants(List<ConferenceDefine.User> participants) {
|
||||
mParticipants = participants;
|
||||
}
|
||||
|
||||
private void destroy() {
|
||||
mConferenceObserverManager.destroy();
|
||||
}
|
||||
}
|
||||
+99
@@ -0,0 +1,99 @@
|
||||
package com.tencent.cloud.tuikit.roomkit.impl;
|
||||
|
||||
import static com.tencent.cloud.tuikit.engine.common.TUICommonDefine.Error.ROOM_ID_INVALID;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import com.tencent.cloud.tuikit.engine.common.TUICommonDefine;
|
||||
import com.tencent.cloud.tuikit.engine.room.TUIRoomDefine;
|
||||
import com.tencent.cloud.tuikit.roomkit.TUIRoomKit;
|
||||
import com.tencent.cloud.tuikit.roomkit.manager.ConferenceController;
|
||||
import com.tencent.cloud.tuikit.roomkit.view.main.RoomMainActivity;
|
||||
import com.tencent.qcloud.tuicore.TUILogin;
|
||||
|
||||
public class TUIRoomKitImpl extends TUIRoomKit {
|
||||
private static final String TAG = "TUIRoomKitImpl";
|
||||
|
||||
private static TUIRoomKit sInstance;
|
||||
|
||||
private Context mContext;
|
||||
|
||||
public static TUIRoomKit sharedInstance() {
|
||||
if (sInstance == null) {
|
||||
synchronized (TUIRoomKitImpl.class) {
|
||||
if (sInstance == null) {
|
||||
sInstance = new TUIRoomKitImpl();
|
||||
}
|
||||
}
|
||||
}
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
public static void destroyInstance() {
|
||||
sInstance = null;
|
||||
}
|
||||
|
||||
private TUIRoomKitImpl() {
|
||||
mContext = TUILogin.getAppContext();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSelfInfo(String userName, String avatarURL, TUIRoomDefine.ActionCallback callback) {
|
||||
Log.i(TAG, "set self info userName=" + userName + " avatarURL=" + avatarURL);
|
||||
ConferenceController.sharedInstance().setSelfInfo(userName, avatarURL, callback);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void createRoom(TUIRoomDefine.RoomInfo roomInfo, TUIRoomDefine.ActionCallback callback) {
|
||||
Log.i(TAG, "createRoom roomInfo=" + roomInfo);
|
||||
if (roomInfo == null || TextUtils.isEmpty(roomInfo.roomId)) {
|
||||
if (callback != null) {
|
||||
callback.onError(ROOM_ID_INVALID, "room id is empty");
|
||||
}
|
||||
return;
|
||||
}
|
||||
ConferenceController.sharedInstance().createRoom(roomInfo, callback);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enterRoom(String roomId, boolean enableAudio, boolean enableVideo, boolean isSoundOnSpeaker,
|
||||
TUIRoomDefine.GetRoomInfoCallback callback) {
|
||||
Log.i(TAG, "enterRoom roomId=" + roomId + " enableAudio=" + enableAudio + " enableVideo=" + enableVideo
|
||||
+ " isSoundOnSpeaker=" + isSoundOnSpeaker);
|
||||
if (TextUtils.isEmpty(roomId)) {
|
||||
if (callback != null) {
|
||||
callback.onError(ROOM_ID_INVALID, "room id is empty");
|
||||
}
|
||||
return;
|
||||
}
|
||||
ConferenceController.sharedInstance()
|
||||
.enterRoom(roomId, enableAudio, enableVideo, isSoundOnSpeaker, new TUIRoomDefine.GetRoomInfoCallback() {
|
||||
@Override
|
||||
public void onSuccess(TUIRoomDefine.RoomInfo roomInfo) {
|
||||
if (ConferenceController.sharedInstance().getConferenceState().isAutoShowRoomMainUi()) {
|
||||
goRoomMainActivity();
|
||||
}
|
||||
if (callback != null) {
|
||||
callback.onSuccess(roomInfo);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(TUICommonDefine.Error error, String message) {
|
||||
if (callback != null) {
|
||||
callback.onError(error, message);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void goRoomMainActivity() {
|
||||
Intent intent = new Intent(mContext, RoomMainActivity.class);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
mContext.startActivity(intent);
|
||||
}
|
||||
}
|
||||
+1187
File diff suppressed because it is too large
Load Diff
+36
@@ -0,0 +1,36 @@
|
||||
package com.tencent.cloud.tuikit.roomkit.manager;
|
||||
|
||||
import com.tencent.cloud.tuikit.engine.room.TUIRoomEngine;
|
||||
import com.tencent.cloud.tuikit.roomkit.state.ConferenceState;
|
||||
import com.tencent.cloud.tuikit.roomkit.state.InvitationState;
|
||||
import com.tencent.cloud.tuikit.roomkit.state.MediaState;
|
||||
import com.tencent.cloud.tuikit.roomkit.state.RoomState;
|
||||
import com.tencent.cloud.tuikit.roomkit.state.SeatState;
|
||||
import com.tencent.cloud.tuikit.roomkit.state.UserState;
|
||||
import com.tencent.cloud.tuikit.roomkit.state.ViewState;
|
||||
|
||||
public abstract class Controller {
|
||||
protected ConferenceState mConferenceState;
|
||||
protected ViewState mViewState;
|
||||
protected SeatState mSeatState;
|
||||
protected RoomState mRoomState;
|
||||
protected UserState mUserState;
|
||||
protected MediaState mMediaState;
|
||||
protected InvitationState mInvitationState;
|
||||
|
||||
protected TUIRoomEngine mRoomEngine;
|
||||
|
||||
protected Controller(ConferenceState conferenceState, TUIRoomEngine engine) {
|
||||
mConferenceState = conferenceState;
|
||||
mViewState = conferenceState.viewState;
|
||||
mSeatState = conferenceState.seatState;
|
||||
mRoomState = conferenceState.roomState;
|
||||
mUserState = conferenceState.userState;
|
||||
mMediaState = conferenceState.mediaState;
|
||||
mInvitationState = conferenceState.invitationState;
|
||||
|
||||
mRoomEngine = engine;
|
||||
}
|
||||
|
||||
public abstract void destroy();
|
||||
}
|
||||
+243
@@ -0,0 +1,243 @@
|
||||
package com.tencent.cloud.tuikit.roomkit.manager;
|
||||
|
||||
import static com.tencent.cloud.tuikit.engine.common.TUICommonDefine.ExtensionType.CONFERENCE_INVITATION_MANAGER;
|
||||
import static com.tencent.cloud.tuikit.engine.common.TUICommonDefine.ExtensionType.CONFERENCE_LIST_MANAGER;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import com.tencent.cloud.tuikit.engine.common.TUICommonDefine;
|
||||
import com.tencent.cloud.tuikit.engine.extension.TUIConferenceInvitationManager;
|
||||
import com.tencent.cloud.tuikit.engine.extension.TUIConferenceListManager;
|
||||
import com.tencent.cloud.tuikit.engine.room.TUIRoomDefine;
|
||||
import com.tencent.cloud.tuikit.engine.room.TUIRoomEngine;
|
||||
import com.tencent.cloud.tuikit.roomkit.R;
|
||||
import com.tencent.cloud.tuikit.roomkit.view.basic.RoomToast;
|
||||
import com.tencent.cloud.tuikit.roomkit.state.ConferenceState;
|
||||
import com.tencent.cloud.tuikit.roomkit.state.InvitationState;
|
||||
import com.tencent.cloud.tuikit.roomkit.state.UserState;
|
||||
import com.tencent.qcloud.tuicore.TUILogin;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class InvitationController extends Controller {
|
||||
private static final String TAG = "InvitationController";
|
||||
|
||||
private String getAttendeeListCursor = "";
|
||||
private String getInvitationListCursor = "";
|
||||
|
||||
private static final int INVITE_TIME_OUT_SECONDS = 60;
|
||||
private static final int SINGLE_FETCH_COUNT = 20;
|
||||
|
||||
private final TUIConferenceInvitationManager mConferenceInvitationManager;
|
||||
private final InvitationObserver mObserver;
|
||||
|
||||
public InvitationController(ConferenceState conferenceState, TUIRoomEngine roomEngine) {
|
||||
super(conferenceState, roomEngine);
|
||||
mConferenceInvitationManager = (TUIConferenceInvitationManager) roomEngine.getExtension(CONFERENCE_INVITATION_MANAGER);
|
||||
mObserver = new InvitationObserver();
|
||||
mConferenceInvitationManager.addObserver(mObserver);
|
||||
}
|
||||
|
||||
public void destroy() {
|
||||
mConferenceInvitationManager.removeObserver(mObserver);
|
||||
}
|
||||
|
||||
public List<UserState.UserInfo> getInviteeListFormInvitationList(List<InvitationState.Invitation> invitationList) {
|
||||
List<UserState.UserInfo> userInfoList = new ArrayList<>();
|
||||
for (InvitationState.Invitation invitation : invitationList) {
|
||||
userInfoList.add(invitation.invitee);
|
||||
}
|
||||
return userInfoList;
|
||||
}
|
||||
|
||||
public void inviteUsers(List<UserState.UserInfo> userInfoList, TUIConferenceInvitationManager.InviteUsersCallback callback) {
|
||||
Log.d(TAG, "inviteUsers");
|
||||
if (userInfoList.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
RoomToast.toastShortMessageCenter(TUILogin.getAppContext().getString(R.string.tuiroomkit_invitation_has_been_sent));
|
||||
mConferenceInvitationManager.inviteUsers(mRoomState.roomId.get(), getUserIdListFromUserList(userInfoList), INVITE_TIME_OUT_SECONDS, "", new TUIConferenceInvitationManager.InviteUsersCallback() {
|
||||
@Override
|
||||
public void onSuccess(Map<String, TUIConferenceInvitationManager.InvitationCode> invitationResultMap) {
|
||||
Log.d(TAG, "inviteUsers success");
|
||||
if (callback != null) {
|
||||
callback.onSuccess(invitationResultMap);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(TUICommonDefine.Error error, String message) {
|
||||
Log.d(TAG, "inviteUsers error=" + error + " message=" + message);
|
||||
if (callback != null) {
|
||||
callback.onError(error, message);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private List<String> getUserIdListFromUserList(List<UserState.UserInfo> userInfoList) {
|
||||
List<String> userIdList = new ArrayList<>();
|
||||
for (UserState.UserInfo userInfo : userInfoList) {
|
||||
userIdList.add(userInfo.userId);
|
||||
}
|
||||
return userIdList;
|
||||
}
|
||||
|
||||
public void accept(String roomId, TUIRoomDefine.ActionCallback callback) {
|
||||
Log.d(TAG, "accept");
|
||||
mConferenceInvitationManager.accept(roomId, new TUIRoomDefine.ActionCallback() {
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
Log.d(TAG, "accept success");
|
||||
if (callback != null) {
|
||||
callback.onSuccess();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(TUICommonDefine.Error error, String message) {
|
||||
Log.d(TAG, "accept error=" + error + " message=" + message);
|
||||
if (callback != null) {
|
||||
callback.onError(error, message);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void reject(String roomId, TUIConferenceInvitationManager.RejectedReason reason, TUIRoomDefine.ActionCallback callback) {
|
||||
Log.d(TAG, "reject roomId= " + roomId + " reason=" + reason);
|
||||
mConferenceInvitationManager.reject(roomId, reason, new TUIRoomDefine.ActionCallback() {
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
Log.d(TAG, "reject success");
|
||||
if (callback != null) {
|
||||
callback.onSuccess();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(TUICommonDefine.Error error, String message) {
|
||||
Log.d(TAG, "reject error=" + error + " message=" + message);
|
||||
if (callback != null) {
|
||||
callback.onError(error, message);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void getInvitationList() {
|
||||
Log.d(TAG, "getInvitationList");
|
||||
mConferenceInvitationManager.getInvitationList(mRoomState.roomId.get(), getAttendeeListCursor, SINGLE_FETCH_COUNT, new TUIConferenceInvitationManager.GetInvitationListCallback() {
|
||||
@Override
|
||||
public void onSuccess(TUIConferenceInvitationManager.InvitationListResult invitationListResult) {
|
||||
Log.d(TAG, "getInvitationList");
|
||||
for (TUIConferenceInvitationManager.Invitation invitation : invitationListResult.invitationList) {
|
||||
InvitationState.Invitation invitationState = new InvitationState.Invitation();
|
||||
invitationState.invitee = new UserState.UserInfo(invitation.invitee);
|
||||
invitationState.inviter = new UserState.UserInfo(invitation.inviter);
|
||||
invitationState.invitationStatus = invitation.status;
|
||||
mInvitationState.invitationList.add(invitationState);
|
||||
}
|
||||
getInvitationListCursor = invitationListResult.cursor;
|
||||
if (!"".equals(getInvitationListCursor)) {
|
||||
getInvitationList();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(TUICommonDefine.Error error, String message) {
|
||||
Log.d(TAG, "getInvitationList onError error=" + error + " message=" + message);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void initInvitationList() {
|
||||
((TUIConferenceListManager) TUIRoomEngine.sharedInstance().getExtension(CONFERENCE_LIST_MANAGER))
|
||||
.fetchAttendeeList(mRoomState.roomId.get(), getAttendeeListCursor, SINGLE_FETCH_COUNT, new TUIConferenceListManager.FetchScheduledAttendeesCallback() {
|
||||
@Override
|
||||
public void onSuccess(TUIConferenceListManager.ScheduledAttendeesResult scheduledAttendeesResult) {
|
||||
Log.d(TAG, "fetchAttendeeList onSuccess");
|
||||
for (TUIRoomDefine.UserInfo attendee : scheduledAttendeesResult.scheduleAttendees) {
|
||||
if (mConferenceState.userState.allUsers.contains(new UserState.UserInfo(attendee))) {
|
||||
continue;
|
||||
}
|
||||
InvitationState.Invitation invitation = new InvitationState.Invitation();
|
||||
invitation.invitee = new UserState.UserInfo(attendee);
|
||||
mInvitationState.invitationList.add(invitation);
|
||||
}
|
||||
getAttendeeListCursor = scheduledAttendeesResult.cursor;
|
||||
if ("".equals(getAttendeeListCursor)) {
|
||||
getInvitationList();
|
||||
} else {
|
||||
initInvitationList();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(TUICommonDefine.Error error, String s) {
|
||||
Log.d(TAG, "fetchAttendeeList onError, error=" + error + " s=" + s);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private class InvitationObserver extends TUIConferenceInvitationManager.Observer {
|
||||
@Override
|
||||
public void onInvitationHandledByOtherDevice(TUIRoomDefine.RoomInfo roomInfo, boolean accepted) {
|
||||
Log.d(TAG, "onInvitationHandledByOtherDevice roomId=" + roomInfo.roomId + " accepted=" + accepted);
|
||||
if (mViewState.isInvitationPending.get()) {
|
||||
mViewState.isInvitationPending.set(false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInvitationRevokedByAdmin(TUIRoomDefine.RoomInfo roomInfo, TUIConferenceInvitationManager.Invitation invitation, TUIRoomDefine.UserInfo admin) {
|
||||
Log.d(TAG, "onInvitationRevokedByAdmin roomId=" + roomInfo.roomId + " admin=" + admin.userId);
|
||||
if (mViewState.isInvitationPending.get()) {
|
||||
mViewState.isInvitationPending.set(false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInvitationTimeout(TUIRoomDefine.RoomInfo roomInfo, TUIConferenceInvitationManager.Invitation invitation) {
|
||||
Log.d(TAG, "onInvitationTimeout roomId=" + roomInfo.roomId + " inviterId="
|
||||
+ invitation.inviter.userId + " inviteeId=" + invitation.invitee.userId);
|
||||
if (mViewState.isInvitationPending.get()) {
|
||||
mViewState.isInvitationPending.set(false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInvitationAdded(String roomId, TUIConferenceInvitationManager.Invitation invitation) {
|
||||
Log.d(TAG, "onInvitationAdded roomId=" + roomId + " inviterId=" + invitation.inviter.userId + " inviteeId=" + invitation.invitee.userId);
|
||||
InvitationState.Invitation newInvitation = new InvitationState.Invitation(invitation);
|
||||
if (mInvitationState.invitationList.contains(newInvitation)) {
|
||||
mInvitationState.invitationList.change(newInvitation);
|
||||
} else {
|
||||
mInvitationState.invitationList.insert(0, newInvitation);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInvitationRemoved(String roomId, TUIConferenceInvitationManager.Invitation invitation) {
|
||||
Log.d(TAG, "onInvitationRemoved roomId=" + roomId + " inviterId= " + invitation.inviter.userId + " inviteeId=" + invitation.invitee.userId);
|
||||
mInvitationState.invitationList.remove(new InvitationState.Invitation(invitation));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInvitationStatusChanged(String roomId, TUIConferenceInvitationManager.Invitation invitation) {
|
||||
Log.d(TAG, "onInvitationStatusChanged roomId=" + roomId + " inviterId=" + invitation.inviter.userId + " inviteeId=" + invitation.invitee.userId);
|
||||
InvitationState.Invitation newInvitation = new InvitationState.Invitation(invitation);
|
||||
if (mInvitationState.invitationList.contains(newInvitation)) {
|
||||
mInvitationState.invitationList.change(newInvitation);
|
||||
} else if ((!mUserState.allUsers.contains(newInvitation.invitee))) {
|
||||
mInvitationState.invitationList.insert(0, newInvitation);
|
||||
}
|
||||
if (invitation.invitee.userId.equals(mUserState.selfInfo.get().userId)) {
|
||||
mViewState.isInvitationPending.set(invitation.status == TUIConferenceInvitationManager.InvitationStatus.PENDING);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
package com.tencent.cloud.tuikit.roomkit.manager;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import com.tencent.cloud.tuikit.engine.common.TUIVideoView;
|
||||
import com.tencent.cloud.tuikit.engine.extension.TUIRoomDeviceManager;
|
||||
import com.tencent.cloud.tuikit.engine.room.TUIRoomDefine;
|
||||
import com.tencent.cloud.tuikit.engine.room.TUIRoomEngine;
|
||||
import com.tencent.cloud.tuikit.roomkit.state.ConferenceState;
|
||||
|
||||
public class MediaController extends Controller {
|
||||
private static final String TAG = "MediaController";
|
||||
|
||||
public MediaController(ConferenceState conferenceState, TUIRoomEngine engine) {
|
||||
super(conferenceState, engine);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
}
|
||||
|
||||
public void startPlayRemoteVideo(String userId, TUIRoomDefine.VideoStreamType videoStreamType,
|
||||
TUIVideoView videoView) {
|
||||
mRoomEngine.setRemoteVideoView(userId, videoStreamType, videoView);
|
||||
Log.d(TAG, "startPlayRemoteVideo userId=" + userId + " videoStreamType=" + videoStreamType + " videoView="
|
||||
+ videoView);
|
||||
mRoomEngine.startPlayRemoteVideo(userId, videoStreamType, null);
|
||||
}
|
||||
|
||||
public void stopPlayRemoteVideo(String userId, TUIRoomDefine.VideoStreamType videoStreamType) {
|
||||
Log.d(TAG, "stopPlayRemoteVideo userId=" + userId + " videoStreamType=" + videoStreamType);
|
||||
mRoomEngine.stopPlayRemoteVideo(userId, videoStreamType);
|
||||
}
|
||||
|
||||
public void switchAudioRoute() {
|
||||
boolean isOpenSpeaker = !mMediaState.isSpeakerOpened.get();
|
||||
setAudioRoute(isOpenSpeaker);
|
||||
}
|
||||
|
||||
public void setAudioRoute(boolean isOpenSpeaker) {
|
||||
mRoomEngine.getMediaDeviceManager().setAudioRoute(
|
||||
isOpenSpeaker ? TUIRoomDeviceManager.AudioRoute.SPEAKERPHONE :
|
||||
TUIRoomDeviceManager.AudioRoute.EARPIECE);
|
||||
mConferenceState.mediaState.isSpeakerOpened.set(isOpenSpeaker);
|
||||
}
|
||||
|
||||
public void switchCamera() {
|
||||
boolean isFrontCamera = !mMediaState.isFrontCamera.get();
|
||||
mRoomEngine.getMediaDeviceManager().switchCamera(isFrontCamera);
|
||||
mMediaState.isFrontCamera.set(isFrontCamera);
|
||||
}
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
package com.tencent.cloud.tuikit.roomkit.manager;
|
||||
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.tencent.cloud.tuikit.engine.room.TUIRoomEngine;
|
||||
import com.tencent.cloud.tuikit.roomkit.state.ConferenceState;
|
||||
|
||||
public class RoomController extends Controller {
|
||||
|
||||
public RoomController(ConferenceState roomStore, TUIRoomEngine engine) {
|
||||
super(roomStore, engine);
|
||||
}
|
||||
|
||||
public boolean isInRoom() {
|
||||
return !TextUtils.isEmpty(mRoomState.roomId.get());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
}
|
||||
}
|
||||
+415
@@ -0,0 +1,415 @@
|
||||
package com.tencent.cloud.tuikit.roomkit.manager;
|
||||
|
||||
import static com.tencent.cloud.tuikit.engine.common.TUICommonDefine.Error.FAILED;
|
||||
import static com.tencent.cloud.tuikit.engine.common.TUICommonDefine.Error.PERMISSION_DENIED;
|
||||
import static com.tencent.cloud.tuikit.engine.common.TUICommonDefine.ExtensionType.CONFERENCE_LIST_MANAGER;
|
||||
import static com.tencent.cloud.tuikit.roomkit.state.ConferenceListState.FETCH_CURSOR_OF_END;
|
||||
import static com.tencent.cloud.tuikit.roomkit.state.ConferenceListState.FETCH_CURSOR_OF_INIT;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import com.tencent.cloud.tuikit.engine.common.TUICommonDefine;
|
||||
import com.tencent.cloud.tuikit.engine.extension.TUIConferenceListManager;
|
||||
import com.tencent.cloud.tuikit.engine.room.TUIRoomDefine;
|
||||
import com.tencent.cloud.tuikit.engine.room.TUIRoomEngine;
|
||||
import com.tencent.cloud.tuikit.roomkit.state.ConferenceListState;
|
||||
import com.tencent.cloud.tuikit.roomkit.state.UserState;
|
||||
import com.tencent.qcloud.tuicore.TUILogin;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
public class ScheduleController {
|
||||
private static final String TAG = "ScheduleController";
|
||||
|
||||
private static final int SINGLE_FETCH_COUNT = 10;
|
||||
|
||||
private static ScheduleController sInstance;
|
||||
|
||||
private final TUIConferenceListManager mConferenceListManager;
|
||||
private final ConferenceListObserver mConferenceListObserver;
|
||||
|
||||
private final ConferenceListState mConferenceListState;
|
||||
private final ScheduledConferenceComparator mScheduledConferenceComparator = new ScheduledConferenceComparator();
|
||||
|
||||
private ScheduleController() {
|
||||
mConferenceListManager = (TUIConferenceListManager) TUIRoomEngine.sharedInstance().getExtension(CONFERENCE_LIST_MANAGER);
|
||||
mConferenceListObserver = new ConferenceListObserver();
|
||||
mConferenceListState = new ConferenceListState();
|
||||
}
|
||||
|
||||
public static ScheduleController sharedInstance() {
|
||||
if (sInstance == null) {
|
||||
synchronized (ScheduleController.class) {
|
||||
if (sInstance == null) {
|
||||
sInstance = new ScheduleController();
|
||||
}
|
||||
}
|
||||
}
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
public ConferenceListState getConferenceListState() {
|
||||
return mConferenceListState;
|
||||
}
|
||||
|
||||
public void loginEngine(TUIRoomDefine.ActionCallback callback) {
|
||||
Log.d(TAG, "TUIRoomEngine.login");
|
||||
TUIRoomEngine.login(TUILogin.getAppContext(), TUILogin.getSdkAppId(), TUILogin.getUserId(), TUILogin.getUserSig(), new TUIRoomDefine.ActionCallback() {
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
Log.d(TAG, "login onSuccess");
|
||||
if (callback != null) {
|
||||
callback.onSuccess();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(TUICommonDefine.Error error, String message) {
|
||||
Log.d(TAG, "login onError error=" + error + " message=" + message);
|
||||
if (callback != null) {
|
||||
callback.onError(error, message);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void scheduleConference(ConferenceListState.ConferenceInfo conferenceInfo, TUIRoomDefine.ActionCallback callback) {
|
||||
Log.d(TAG, "scheduleConference conferenceId=" + conferenceInfo.basicRoomInfo.roomId);
|
||||
mConferenceListManager.scheduleConference(conferenceInfo.transferToEngineData(), new TUIRoomDefine.ActionCallback() {
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
Log.d(TAG, "scheduleConference onSuccess conferenceId=" + conferenceInfo.basicRoomInfo.roomId);
|
||||
if (callback != null) {
|
||||
callback.onSuccess();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(TUICommonDefine.Error error, String message) {
|
||||
Log.d(TAG, "scheduleConference onError error=" + error + " message=" + message);
|
||||
if (callback != null) {
|
||||
callback.onError(error, message);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void cancelConference(String conferenceId, TUIRoomDefine.ActionCallback callback) {
|
||||
Log.d(TAG, "cancelConference conferenceId=" + conferenceId);
|
||||
ConferenceListState.ConferenceInfo conferenceInfo = mConferenceListState.scheduledConferences.find(new ConferenceListState.ConferenceInfo(conferenceId));
|
||||
if (conferenceInfo.status == TUIConferenceListManager.ConferenceStatus.RUNNING) {
|
||||
Log.e(TAG, "cancelConference onError error=" + FAILED + " message=Ongoing meetings cannot be cancelled.");
|
||||
callback.onError(FAILED, null);
|
||||
return;
|
||||
}
|
||||
mConferenceListManager.cancelConference(conferenceId, new TUIRoomDefine.ActionCallback() {
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
Log.d(TAG, "cancelConference onSuccess conferenceId=" + conferenceId);
|
||||
if (callback != null) {
|
||||
callback.onSuccess();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(TUICommonDefine.Error error, String message) {
|
||||
Log.d(TAG, "cancelConference onError error=" + error + " message=" + message);
|
||||
if (callback != null) {
|
||||
callback.onError(error, message);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void updateConferenceInfo(ConferenceListState.ConferenceInfo newInfo, TUIRoomDefine.ActionCallback callback) {
|
||||
Log.d(TAG, "updateConferenceInfo conferenceId=" + newInfo.basicRoomInfo.roomId);
|
||||
ConferenceListState.ConferenceInfo oldInfo = mConferenceListState.scheduledConferences.find(newInfo);
|
||||
if (oldInfo == null) {
|
||||
Log.e(TAG, "updateConferenceInfo conference not found : " + newInfo.basicRoomInfo.roomId);
|
||||
callback.onError(FAILED, null);
|
||||
return;
|
||||
}
|
||||
if (oldInfo.status == TUIConferenceListManager.ConferenceStatus.RUNNING) {
|
||||
Log.e(TAG, "updateConferenceInfo onError error=" + PERMISSION_DENIED + " message=Ongoing meetings cannot be modified.");
|
||||
callback.onError(PERMISSION_DENIED, null);
|
||||
return;
|
||||
}
|
||||
updateConferenceInfoInternal(newInfo, oldInfo, callback);
|
||||
}
|
||||
|
||||
public void refreshRequiredConferences(TUIRoomDefine.ActionCallback callback) {
|
||||
Log.d(TAG, "refreshRequiredConferences");
|
||||
clearRequiredConferences();
|
||||
fetchRequiredConferences(callback);
|
||||
}
|
||||
|
||||
public void fetchRequiredConferences(TUIRoomDefine.ActionCallback callback) {
|
||||
String cursor = mConferenceListState.fetchScheduledConferencesCursor;
|
||||
if (TextUtils.equals(FETCH_CURSOR_OF_END, cursor)) {
|
||||
return;
|
||||
}
|
||||
if (TextUtils.equals(FETCH_CURSOR_OF_INIT, cursor)) {
|
||||
mConferenceListManager.addObserver(mConferenceListObserver);
|
||||
cursor = "";
|
||||
}
|
||||
List<TUIConferenceListManager.ConferenceStatus> statusFilter = new ArrayList<>(2);
|
||||
statusFilter.add(TUIConferenceListManager.ConferenceStatus.RUNNING);
|
||||
statusFilter.add(TUIConferenceListManager.ConferenceStatus.NOT_STARTED);
|
||||
Log.d(TAG, "fetchRequiredConferences cursor=" + cursor);
|
||||
mConferenceListManager.fetchScheduledConferenceList(statusFilter, cursor, SINGLE_FETCH_COUNT, new TUIConferenceListManager.FetchScheduledConferenceListCallback() {
|
||||
@Override
|
||||
public void onSuccess(TUIConferenceListManager.ScheduledConferenceListResult result) {
|
||||
Log.d(TAG, "fetchRequiredConferences onSuccess");
|
||||
mConferenceListState.fetchScheduledConferencesCursor = TextUtils.isEmpty(result.cursor) ? FETCH_CURSOR_OF_END : result.cursor;
|
||||
for (TUIConferenceListManager.ConferenceInfo item : result.conferenceInfoList) {
|
||||
mConferenceListState.scheduledConferences.insert(new ConferenceListState.ConferenceInfo(item), mScheduledConferenceComparator);
|
||||
}
|
||||
if (callback != null) {
|
||||
callback.onSuccess();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(TUICommonDefine.Error error, String message) {
|
||||
Log.d(TAG, "fetchRequiredConferences onError error=" + error + " message=" + message);
|
||||
if (callback != null) {
|
||||
callback.onError(error, message);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void clearRequiredConferences() {
|
||||
Log.d(TAG, "clearRequiredConferences");
|
||||
mConferenceListState.fetchScheduledConferencesCursor = FETCH_CURSOR_OF_INIT;
|
||||
mConferenceListState.scheduledConferences.clear();
|
||||
mConferenceListManager.removeObserver(mConferenceListObserver);
|
||||
}
|
||||
|
||||
public void fetchAttendeeList(String conferenceId, TUIRoomDefine.ActionCallback callback) {
|
||||
ConferenceListState.ConferenceInfo conferenceInfo = mConferenceListState.scheduledConferences.find(new ConferenceListState.ConferenceInfo(conferenceId));
|
||||
String cursor = conferenceInfo.fetchScheduledAttendeesCursor;
|
||||
Log.d(TAG, "fetchAttendeeList conferenceId=" + conferenceId + " fetchScheduledAttendeesCursor=" + conferenceInfo.fetchScheduledAttendeesCursor);
|
||||
if (TextUtils.equals(FETCH_CURSOR_OF_END, cursor)) {
|
||||
return;
|
||||
}
|
||||
cursor = TextUtils.equals(cursor, FETCH_CURSOR_OF_INIT) ? "" : cursor;
|
||||
mConferenceListManager.fetchAttendeeList(conferenceId, cursor, SINGLE_FETCH_COUNT, new TUIConferenceListManager.FetchScheduledAttendeesCallback() {
|
||||
@Override
|
||||
public void onSuccess(TUIConferenceListManager.ScheduledAttendeesResult result) {
|
||||
conferenceInfo.fetchScheduledAttendeesCursor = TextUtils.isEmpty(result.cursor) ? FETCH_CURSOR_OF_END : result.cursor;
|
||||
if (conferenceInfo.hadScheduledAttendeeCount.get() != result.totalAttendeeCount) {
|
||||
conferenceInfo.hadScheduledAttendeeCount.set(result.totalAttendeeCount);
|
||||
}
|
||||
Log.d(TAG, "fetchAttendeeList onSuccess mFetchAttendeeCursor=" + result.cursor);
|
||||
List<UserState.UserInfo> attendees = conferenceInfo.hadScheduledAttendees.getList();
|
||||
for (TUIRoomDefine.UserInfo item : result.scheduleAttendees) {
|
||||
UserState.UserInfo userInfo = new UserState.UserInfo(item);
|
||||
attendees.add(userInfo);
|
||||
}
|
||||
conferenceInfo.hadScheduledAttendees.redirect(attendees);
|
||||
if (TextUtils.equals(FETCH_CURSOR_OF_END, conferenceInfo.fetchScheduledAttendeesCursor)) {
|
||||
if (callback != null) {
|
||||
callback.onSuccess();
|
||||
}
|
||||
} else {
|
||||
fetchAttendeeList(conferenceId, callback);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(TUICommonDefine.Error error, String message) {
|
||||
Log.d(TAG, "fetchAttendeeList onError error=" + error + " message=" + message);
|
||||
if (callback != null) {
|
||||
callback.onError(error, message);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void clearAttendeeList(String conferenceId) {
|
||||
ConferenceListState.ConferenceInfo conferenceInfo = mConferenceListState.scheduledConferences.find(new ConferenceListState.ConferenceInfo(conferenceId));
|
||||
conferenceInfo.fetchScheduledAttendeesCursor = FETCH_CURSOR_OF_INIT;
|
||||
conferenceInfo.hadScheduledAttendees.clear();
|
||||
conferenceInfo.hadScheduledAttendeeCount.set(0);
|
||||
}
|
||||
|
||||
public void fetchRoomInfo(String roomId, TUIRoomDefine.GetRoomInfoCallback callback) {
|
||||
TUIRoomEngine.sharedInstance().fetchRoomInfo(roomId, TUIRoomDefine.RoomType.CONFERENCE, new TUIRoomDefine.GetRoomInfoCallback() {
|
||||
@Override
|
||||
public void onSuccess(TUIRoomDefine.RoomInfo roomInfo) {
|
||||
callback.onSuccess(roomInfo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(TUICommonDefine.Error error, String message) {
|
||||
Log.d(TAG, "fetchRoomInfo onError error=" + error + " message=" + message);
|
||||
callback.onError(error, message);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private class ConferenceListObserver extends TUIConferenceListManager.Observer {
|
||||
@Override
|
||||
public void onConferenceScheduled(TUIConferenceListManager.ConferenceInfo conferenceInfo) {
|
||||
Log.d(TAG, "onConferenceScheduled conferenceId=" + conferenceInfo.basicRoomInfo.roomId);
|
||||
mConferenceListState.scheduledConferences.insert(new ConferenceListState.ConferenceInfo(conferenceInfo), mScheduledConferenceComparator);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConferenceWillStart(TUIConferenceListManager.ConferenceInfo conferenceInfo) {
|
||||
Log.d(TAG, "onConferenceWillStart conferenceId=" + conferenceInfo.basicRoomInfo.roomId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConferenceCancelled(String conferenceId, TUIConferenceListManager.ConferenceCancelReason reason, TUIRoomDefine.UserInfo operateUser) {
|
||||
Log.d(TAG, "onConferenceCancelled conferenceId=" + conferenceId);
|
||||
mConferenceListState.scheduledConferences.remove(new ConferenceListState.ConferenceInfo(conferenceId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConferenceInfoChanged(TUIConferenceListManager.ConferenceInfo conferenceInfo, List<TUIConferenceListManager.ConferenceModifyFlag> modifyFlagList) {
|
||||
Log.d(TAG, "onConferenceInfoChanged conferenceId=" + conferenceInfo.basicRoomInfo.roomId);
|
||||
ConferenceListState.ConferenceInfo newInfo = new ConferenceListState.ConferenceInfo(conferenceInfo);
|
||||
ConferenceListState.ConferenceInfo oldInfo = mConferenceListState.scheduledConferences.find(newInfo);
|
||||
if (oldInfo == null) {
|
||||
mConferenceListState.scheduledConferences.insert(newInfo, mScheduledConferenceComparator);
|
||||
return;
|
||||
}
|
||||
oldInfo.update(conferenceInfo);
|
||||
mConferenceListState.scheduledConferences.change(oldInfo);
|
||||
mConferenceListState.scheduledConferences.move(oldInfo, mScheduledConferenceComparator);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onScheduleAttendeesChanged(String roomId, List<TUIRoomDefine.UserInfo> leftUsers, List<TUIRoomDefine.UserInfo> joinedUsers) {
|
||||
ConferenceListState.ConferenceInfo conferenceInfo = mConferenceListState.scheduledConferences.find(new ConferenceListState.ConferenceInfo(roomId));
|
||||
if (conferenceInfo == null) {
|
||||
return;
|
||||
}
|
||||
for (TUIRoomDefine.UserInfo item : leftUsers) {
|
||||
conferenceInfo.hadScheduledAttendees.remove(new UserState.UserInfo(item.userId));
|
||||
}
|
||||
for (TUIRoomDefine.UserInfo item : joinedUsers) {
|
||||
conferenceInfo.hadScheduledAttendees.add(new UserState.UserInfo(item));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConferenceStatusChanged(String roomId, TUIConferenceListManager.ConferenceStatus status) {
|
||||
ConferenceListState.ConferenceInfo conferenceInfo = mConferenceListState.scheduledConferences.find(new ConferenceListState.ConferenceInfo(roomId));
|
||||
if (conferenceInfo == null) {
|
||||
return;
|
||||
}
|
||||
conferenceInfo.status = status;
|
||||
mConferenceListState.scheduledConferences.change(conferenceInfo);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateConferenceInfoInternal(ConferenceListState.ConferenceInfo newInfo, ConferenceListState.ConferenceInfo oldInfo, TUIRoomDefine.ActionCallback callback) {
|
||||
List<TUIConferenceListManager.ConferenceModifyFlag> modifyFlagList = new LinkedList<>();
|
||||
if (!TextUtils.equals(newInfo.basicRoomInfo.name, oldInfo.basicRoomInfo.name)) {
|
||||
modifyFlagList.add(TUIConferenceListManager.ConferenceModifyFlag.ROOM_NAME);
|
||||
}
|
||||
if (newInfo.scheduleStartTime != oldInfo.scheduleStartTime) {
|
||||
modifyFlagList.add(TUIConferenceListManager.ConferenceModifyFlag.SCHEDULE_START_TIME);
|
||||
}
|
||||
if (newInfo.scheduleEndTime != oldInfo.scheduleEndTime) {
|
||||
modifyFlagList.add(TUIConferenceListManager.ConferenceModifyFlag.SCHEDULE_END_TIME);
|
||||
}
|
||||
Log.d(TAG, "updateConferenceInfo conferenceId=" + newInfo.basicRoomInfo.roomId);
|
||||
mConferenceListManager.updateConferenceInfo(newInfo.transferToEngineData(), modifyFlagList, new TUIRoomDefine.ActionCallback() {
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
Log.d(TAG, "updateConferenceInfo onSuccess");
|
||||
if (callback != null) {
|
||||
callback.onSuccess();
|
||||
}
|
||||
addAttendeesByAdmin(newInfo, oldInfo);
|
||||
removeAttendeesByAdmin(newInfo, oldInfo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(TUICommonDefine.Error error, String message) {
|
||||
Log.d(TAG, "updateConferenceInfo onError error=" + error + " message=" + message);
|
||||
if (callback != null) {
|
||||
callback.onError(error, message);
|
||||
}
|
||||
addAttendeesByAdmin(newInfo, oldInfo);
|
||||
removeAttendeesByAdmin(newInfo, oldInfo);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void addAttendeesByAdmin(ConferenceListState.ConferenceInfo newInfo, ConferenceListState.ConferenceInfo oldInfo) {
|
||||
List<UserState.UserInfo> newList = newInfo.hadScheduledAttendees.getList();
|
||||
List<UserState.UserInfo> oldList = oldInfo.hadScheduledAttendees.getList();
|
||||
List<String> userIdList = new LinkedList<>();
|
||||
for (UserState.UserInfo item : newList) {
|
||||
if (oldList.contains(item)) {
|
||||
continue;
|
||||
}
|
||||
userIdList.add(item.userId);
|
||||
}
|
||||
if (userIdList.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
Log.d(TAG, "addAttendeesByAdmin conferenceId=" + newInfo.basicRoomInfo.roomId);
|
||||
mConferenceListManager.addAttendeesByAdmin(newInfo.basicRoomInfo.roomId, userIdList, new TUIRoomDefine.ActionCallback() {
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
Log.d(TAG, "addAttendeesByAdmin onSuccess");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(TUICommonDefine.Error error, String message) {
|
||||
Log.d(TAG, "addAttendeesByAdmin onError error=" + error + " message=" + message);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void removeAttendeesByAdmin(ConferenceListState.ConferenceInfo newInfo, ConferenceListState.ConferenceInfo oldInfo) {
|
||||
List<UserState.UserInfo> newList = newInfo.hadScheduledAttendees.getList();
|
||||
List<UserState.UserInfo> oldList = oldInfo.hadScheduledAttendees.getList();
|
||||
List<String> userIdList = new LinkedList<>();
|
||||
for (UserState.UserInfo item : oldList) {
|
||||
if (newList.contains(item)) {
|
||||
continue;
|
||||
}
|
||||
userIdList.add(item.userId);
|
||||
}
|
||||
if (userIdList.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
Log.d(TAG, "removeAttendeesByAdmin conferenceId=" + newInfo.basicRoomInfo.roomId);
|
||||
mConferenceListManager.removeAttendeesByAdmin(newInfo.basicRoomInfo.roomId, userIdList, new TUIRoomDefine.ActionCallback() {
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
Log.d(TAG, "removeAttendeesByAdmin onSuccess");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(TUICommonDefine.Error error, String message) {
|
||||
Log.d(TAG, "removeAttendeesByAdmin onError error=" + error + " message=" + message);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static class ScheduledConferenceComparator implements Comparator<ConferenceListState.ConferenceInfo> {
|
||||
@Override
|
||||
public int compare(ConferenceListState.ConferenceInfo o1, ConferenceListState.ConferenceInfo o2) {
|
||||
if (o1 == null || o2 == null) {
|
||||
return -1;
|
||||
}
|
||||
int scheduleDiff = (int) (o1.scheduleStartTime - o2.scheduleStartTime);
|
||||
if (scheduleDiff != 0) {
|
||||
return scheduleDiff;
|
||||
}
|
||||
return (int) (o1.basicRoomInfo.createTime - o2.basicRoomInfo.createTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
package com.tencent.cloud.tuikit.roomkit.manager;
|
||||
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.tencent.cloud.tuikit.engine.room.TUIRoomEngine;
|
||||
import com.tencent.cloud.tuikit.roomkit.state.ConferenceState;
|
||||
|
||||
public class UserController extends Controller {
|
||||
|
||||
public UserController(ConferenceState roomStore, TUIRoomEngine engine) {
|
||||
super(roomStore, engine);
|
||||
}
|
||||
|
||||
public boolean isSelf(String userId) {
|
||||
return TextUtils.equals(userId, mUserState.selfInfo.get().userId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
|
||||
}
|
||||
}
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
package com.tencent.cloud.tuikit.roomkit.manager;
|
||||
|
||||
import android.content.res.Configuration;
|
||||
import android.os.SystemClock;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.tencent.cloud.tuikit.engine.room.TUIRoomEngine;
|
||||
import com.tencent.cloud.tuikit.roomkit.state.ConferenceState;
|
||||
import com.tencent.cloud.tuikit.roomkit.state.ViewState;
|
||||
|
||||
public class ViewController extends Controller {
|
||||
public ViewController(ConferenceState roomStore, TUIRoomEngine engine) {
|
||||
super(roomStore, engine);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
}
|
||||
|
||||
public void clearPendingTakeSeatRequests() {
|
||||
mViewState.clearPendingTakeSeatRequests();
|
||||
}
|
||||
|
||||
public void updateScreenOrientation(Configuration newConfig) {
|
||||
boolean isPortrait = newConfig.orientation == Configuration.ORIENTATION_PORTRAIT;
|
||||
if (isPortrait == mViewState.isScreenPortrait.get()) {
|
||||
return;
|
||||
}
|
||||
mViewState.isScreenPortrait.set(isPortrait);
|
||||
}
|
||||
|
||||
public void updateUserTypeSelected(ViewState.UserListType type) {
|
||||
mViewState.userListType.set(type);
|
||||
}
|
||||
|
||||
public void updateSearchUserKeyWord(String newWord) {
|
||||
String oldWord = mViewState.searchUserKeyWord.get();
|
||||
if (TextUtils.equals(newWord, oldWord)) {
|
||||
return;
|
||||
}
|
||||
mViewState.searchUserKeyWord.set(newWord);
|
||||
}
|
||||
|
||||
public void updateRoomProcess(ViewState.RoomProcess roomProcess) {
|
||||
mViewState.roomProcess.set(roomProcess);
|
||||
}
|
||||
|
||||
public boolean isProcessRoom() {
|
||||
return mViewState.roomProcess.get() != ViewState.RoomProcess.NONE;
|
||||
}
|
||||
|
||||
public void anchorEnterRoomTimeFromBoot() {
|
||||
mViewState.enterRoomTimeFromBoot.set(SystemClock.elapsedRealtime());
|
||||
}
|
||||
}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
package com.tencent.cloud.tuikit.roomkit.manager.constant;
|
||||
|
||||
import static com.tencent.cloud.tuikit.engine.room.TUIRoomDefine.VideoQuality.Q_720P;
|
||||
|
||||
import com.tencent.cloud.tuikit.engine.room.TUIRoomDefine;
|
||||
|
||||
public class ConferenceConstant {
|
||||
public static final int DEFAULT_AUDIO_CAPTURE_VOLUME = 100;
|
||||
public static final int DEFAULT_AUDIO_PLAY_VOLUME = 100;
|
||||
public static final boolean DEFAULT_AUDIO_VOLUME_EVALUATION = true;
|
||||
|
||||
public static final int DEFAULT_VIDEO_FPS = 15;
|
||||
public static final int DEFAULT_VIDEO_BITRATE = 1200;
|
||||
public static final TUIRoomDefine.VideoQuality DEFAULT_VIDEO_RESOLUTION = Q_720P;
|
||||
public static final boolean DEFAULT_VIDEO_LOCAL_MIRROR = true;
|
||||
|
||||
public static final boolean DEFAULT_CAMERA_FRONT = true;
|
||||
|
||||
public static final int DURATION_FOREVER = 0;
|
||||
|
||||
|
||||
public static final int USER_NOT_FOUND = -1;
|
||||
|
||||
public static final int VOLUME_CAN_HEARD_MIN_LIMIT = 10;
|
||||
public static final int VOLUME_INDICATOR_SHOW_TIME_MS = 500;
|
||||
|
||||
|
||||
public static final String KEY_ERROR = "KEY_ERROR";
|
||||
public static final String KEY_ROOM_RAISE_HAND_TIP_SHOWED = "KEY_ROOM_RAISE_HAND_TIP_SHOWED";
|
||||
public static final String KEY_CONFERENCE_ID = "KEY_CONFERENCE_ID";
|
||||
}
|
||||
+223
@@ -0,0 +1,223 @@
|
||||
package com.tencent.cloud.tuikit.roomkit.manager.eventcenter;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import com.tencent.qcloud.tuicore.TUICore;
|
||||
import com.tencent.qcloud.tuicore.interfaces.ITUINotification;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
public class ConferenceEventCenter {
|
||||
private static final String TAG = "ConferenceEventCenter";
|
||||
|
||||
private Map<RoomEngineEvent, List<RoomEngineEventResponder>> mEngineResponderMap;
|
||||
private Map<String, List<TUINotificationAdapter>> mUIEventResponderMap;
|
||||
|
||||
public enum RoomEngineEvent {
|
||||
ERROR,
|
||||
KICKED_OFF_LINE,
|
||||
USER_SIG_EXPIRED,
|
||||
ROOM_NAME_CHANGED,
|
||||
LOCAL_CAMERA_STATE_CHANGED,
|
||||
LOCAL_SCREEN_STATE_CHANGED,
|
||||
LOCAL_AUDIO_STATE_CHANGED,
|
||||
ALL_USER_MICROPHONE_DISABLE_CHANGED,
|
||||
ALL_USER_CAMERA_DISABLE_CHANGED,
|
||||
SEND_MESSAGE_FOR_ALL_USER_DISABLE_CHANGED,
|
||||
ROOM_DISMISSED,
|
||||
KICKED_OUT_OF_ROOM,
|
||||
GET_USER_LIST_COMPLETED_FOR_ENTER_ROOM,
|
||||
REMOTE_USER_ENTER_ROOM,
|
||||
REMOTE_USER_LEAVE_ROOM,
|
||||
LOCAL_USER_CREATE_ROOM,
|
||||
LOCAL_USER_ENTER_ROOM,
|
||||
LOCAL_USER_EXIT_ROOM,
|
||||
LOCAL_USER_DESTROY_ROOM,
|
||||
USER_ROLE_CHANGED,
|
||||
USER_SCREEN_STATE_CHANGED,
|
||||
USER_CAMERA_STATE_CHANGED,
|
||||
USER_MIC_STATE_CHANGED,
|
||||
USER_VOICE_VOLUME_CHANGED,
|
||||
USER_SEND_MESSAGE_ABILITY_CHANGED,
|
||||
USER_NETWORK_QUALITY_CHANGED,
|
||||
USER_SCREEN_CAPTURE_STOPPED,
|
||||
REMOTE_USER_TAKE_SEAT,
|
||||
REMOTE_USER_LEAVE_SEAT,
|
||||
REQUEST_RECEIVED,
|
||||
KICKED_OFF_SEAT,
|
||||
USER_TAKE_SEAT_REQUEST_ADD,
|
||||
USER_TAKE_SEAT_REQUEST_REMOVE,
|
||||
LOCAL_VIDEO_FPS_CHANGED,
|
||||
LOCAL_VIDEO_BITRATE_CHANGED,
|
||||
LOCAL_VIDEO_RESOLUTION_CHANGED,
|
||||
LOCAL_AUDIO_CAPTURE_VOLUME_CHANGED,
|
||||
LOCAL_AUDIO_PLAY_VOLUME_CHANGED,
|
||||
LOCAL_AUDIO_VOLUME_EVALUATION_CHANGED,
|
||||
LOCAL_USER_GENERAL_TO_MANAGER,
|
||||
LOCAL_USER_MANAGER_TO_GENERAL,
|
||||
LOCAL_USER_TO_OWNER,
|
||||
ON_STATISTICS,
|
||||
LOCAL_SHARE_STOPPED_BY_ADMIN,
|
||||
UPDATE_CONFERENCE_LIST,
|
||||
}
|
||||
|
||||
public static class RoomKitUIEvent {
|
||||
public static final String ROOM_KIT_EVENT = "ROOM_KIT_EVENT";
|
||||
public static final String CONFIGURATION_CHANGE = "CONFIGURATION_CHANGE";
|
||||
public static final String START_LOGIN = "START_LOGIN";
|
||||
public static final String AGREE_TAKE_SEAT = "AGREE_TAKE_SEAT";
|
||||
public static final String DISAGREE_TAKE_SEAT = "DISAGREE_TAKE_SEAT";
|
||||
public static final String INVITE_TAKE_SEAT = "INVITE_TAKE_SEAT";
|
||||
|
||||
public static final String SHOW_USER_MANAGEMENT = "SHOW_USER_MANAGEMENT";
|
||||
public static final String DISMISS_USER_MANAGEMENT = "DISMISS_USER_MANAGEMENT";
|
||||
public static final String SHOW_EXIT_ROOM_VIEW = "SHOW_EXIT_ROOM_VIEW";
|
||||
public static final String DISMISS_EXIT_ROOM_VIEW = "DISMISS_EXIT_ROOM_VIEW";
|
||||
public static final String DISMISS_MEETING_INFO = "DISMISS_MEETING_INFO";
|
||||
public static final String SHOW_USER_LIST = "SHOW_USER_LIST";
|
||||
public static final String DISMISS_USER_LIST = "DISMISS_USER_LIST";
|
||||
public static final String SHOW_APPLY_LIST = "SHOW_APPLY_LIST";
|
||||
public static final String DISMISS_APPLY_LIST = "DISMISS_APPLY_LIST";
|
||||
public static final String SHOW_QRCODE_VIEW = "SHOW_QRCODE_VIEW";
|
||||
public static final String DISMISS_QRCODE_VIEW = "DISMISS_QRCODE_VIEW";
|
||||
public static final String SHOW_MEDIA_SETTING_PANEL = "SHOW_MEDIA_SETTING_PANEL";
|
||||
public static final String DISMISS_MEDIA_SETTING_PANEL = "DISMISS_MEDIA_SETTING_PANEL";
|
||||
public static final String SHOW_INVITE_PANEL = "SHOW_INVITE_PANEL";
|
||||
public static final String DISMISS_INVITE_PANEL = "DISMISS_INVITE_PANEL";
|
||||
public static final String SHOW_MORE_FUNCTION_PANEL = "SHOW_MORE_FUNCTION_PANEL";
|
||||
public static final String DISMISS_MORE_FUNCTION_PANEL = "DISMISS_INVITE_PANEL_SECOND";
|
||||
public static final String SHOW_SHARE_ROOM_PANEL = "SHOW_SHARE_ROOM_PANEL";
|
||||
public static final String DISMISS_SHARE_ROOM_PANEL = "DISMISS_SHARE_ROOM_PANEL";
|
||||
public static final String SHOW_SELECT_USER_TO_CALL_VIEW = "SHOW_SELECT_USER_TO_CALL_VIEW";
|
||||
public static final String SHOW_OWNER_EXIT_ROOM_PANEL = "SHOW_OWNER_EXIT_ROOM_PANEL";
|
||||
public static final String DISMISS_OWNER_EXIT_ROOM_PANEL = "DISMISS_OWNER_EXIT_ROOM_PANEL";
|
||||
|
||||
public static final String ENTER_FLOAT_WINDOW = "ENTER_FLOAT_WINDOW";
|
||||
public static final String EXIT_FLOAT_WINDOW = "EXIT_FLOAT_WINDOW";
|
||||
|
||||
public static final String SEND_IM_MSG_COMPLETE = "SEND_IM_MSG_COMPLETE";
|
||||
|
||||
public static final String BAR_SHOW_TIME_RECOUNT = "BAR_SHOW_TIME_RECOUNT";
|
||||
public static final String DISMISS_MAIN_ACTIVITY = "DISMISS_MAIN_ACTIVITY";
|
||||
public static final String ENABLE_FLOAT_CHAT = "ENABLE_FLOAT_CHAT";
|
||||
public static final String SCHEDULED_CONFERENCE_SUCCESS = "SCHEDULED_CONFERENCE_SUCCESS";
|
||||
|
||||
public static final String DESTROY_INVITATION_RECEIVED_ACTIVITY = "DESTROY_INVITATION_RECEIVED_ACTIVITY";
|
||||
public static final String ENTER_PIP_MODE = "ENTER_PIP_MODE";
|
||||
public static final String EXIT_PIP_MODE = "EXIT_PIP_MODE";
|
||||
}
|
||||
|
||||
public interface RoomEngineEventResponder {
|
||||
void onEngineEvent(RoomEngineEvent event, Map<String, Object> params);
|
||||
}
|
||||
|
||||
public interface RoomKitUIEventResponder {
|
||||
void onNotifyUIEvent(String key, Map<String, Object> params);
|
||||
}
|
||||
|
||||
public static ConferenceEventCenter getInstance() {
|
||||
return ConferenceEventCenter.LazyHolder.INSTANCE;
|
||||
}
|
||||
|
||||
private static class LazyHolder {
|
||||
private static final ConferenceEventCenter INSTANCE = new ConferenceEventCenter();
|
||||
}
|
||||
|
||||
private ConferenceEventCenter() {
|
||||
mEngineResponderMap = new ConcurrentHashMap<>();
|
||||
mUIEventResponderMap = new ConcurrentHashMap<>();
|
||||
}
|
||||
|
||||
public void subscribeEngine(RoomEngineEvent event, RoomEngineEventResponder observer) {
|
||||
if (event == null || observer == null) {
|
||||
return;
|
||||
}
|
||||
if (mEngineResponderMap.containsKey(event)) {
|
||||
mEngineResponderMap.get(event).add(observer);
|
||||
} else {
|
||||
List<RoomEngineEventResponder> list = new CopyOnWriteArrayList<>();
|
||||
list.add(observer);
|
||||
mEngineResponderMap.put(event, list);
|
||||
}
|
||||
}
|
||||
|
||||
public void unsubscribeEngine(RoomEngineEvent event, RoomEngineEventResponder observer) {
|
||||
if (observer == null) {
|
||||
return;
|
||||
}
|
||||
List<RoomEngineEventResponder> list = mEngineResponderMap.get(event);
|
||||
if (list == null) {
|
||||
return;
|
||||
}
|
||||
list.remove(observer);
|
||||
}
|
||||
|
||||
public void subscribeUIEvent(String event, RoomKitUIEventResponder responder) {
|
||||
if (TextUtils.isEmpty(event) || responder == null) {
|
||||
return;
|
||||
}
|
||||
TUINotificationAdapter adapter = new TUINotificationAdapter(responder);
|
||||
if (mUIEventResponderMap.containsKey(event)) {
|
||||
mUIEventResponderMap.get(event).add(adapter);
|
||||
} else {
|
||||
List<TUINotificationAdapter> list = new CopyOnWriteArrayList<>();
|
||||
list.add(adapter);
|
||||
mUIEventResponderMap.put(event, list);
|
||||
}
|
||||
TUICore.registerEvent(RoomKitUIEvent.ROOM_KIT_EVENT, event, adapter);
|
||||
}
|
||||
|
||||
public void notifyUIEvent(String event, Map<String, Object> params) {
|
||||
TUICore.notifyEvent(RoomKitUIEvent.ROOM_KIT_EVENT, event, params);
|
||||
}
|
||||
|
||||
public void unsubscribeUIEvent(String event, RoomKitUIEventResponder responder) {
|
||||
if (TextUtils.isEmpty(event) || responder == null) {
|
||||
return;
|
||||
}
|
||||
List<TUINotificationAdapter> list = mUIEventResponderMap.get(event);
|
||||
if (list == null) {
|
||||
return;
|
||||
}
|
||||
TUINotificationAdapter notificationAdapter = null;
|
||||
Iterator<TUINotificationAdapter> iterator = list.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
TUINotificationAdapter adapter = iterator.next();
|
||||
if (adapter != null && responder.equals(adapter.mResponder)) {
|
||||
notificationAdapter = adapter;
|
||||
break;
|
||||
}
|
||||
}
|
||||
list.remove(notificationAdapter);
|
||||
TUICore.unRegisterEvent(RoomKitUIEvent.ROOM_KIT_EVENT, event, notificationAdapter);
|
||||
}
|
||||
|
||||
public void notifyEngineEvent(RoomEngineEvent event, Map<String, Object> params) {
|
||||
List<RoomEngineEventResponder> list = mEngineResponderMap.get(event);
|
||||
if (list == null) {
|
||||
return;
|
||||
}
|
||||
for (RoomEngineEventResponder roomEngineEventResponder : list) {
|
||||
roomEngineEventResponder.onEngineEvent(event, params);
|
||||
Log.d(TAG, "onEngineEvent : " + event);
|
||||
}
|
||||
}
|
||||
|
||||
static class TUINotificationAdapter implements ITUINotification {
|
||||
private final RoomKitUIEventResponder mResponder;
|
||||
|
||||
public TUINotificationAdapter(RoomKitUIEventResponder responder) {
|
||||
mResponder = responder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNotifyEvent(String key, String subKey, Map<String, Object> param) {
|
||||
mResponder.onNotifyUIEvent(subKey, param);
|
||||
}
|
||||
}
|
||||
}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
package com.tencent.cloud.tuikit.roomkit.manager.eventcenter;
|
||||
|
||||
public class ConferenceEventConstant {
|
||||
public static final String KEY_CONFERENCE = "KEY_CONFERENCE";
|
||||
public static final String KEY_CONFERENCE_STARTED = "KEY_CONFERENCE_STARTED";
|
||||
public static final String KEY_CONFERENCE_JOINED = "KEY_CONFERENCE_JOINED";
|
||||
public static final String KEY_CONFERENCE_EXITED = "KEY_CONFERENCE_EXITED";
|
||||
public static final String KEY_CONFERENCE_FINISHED = "KEY_CONFERENCE_FINISHED";
|
||||
public static final String KEY_CONFERENCE_ID = "KEY_CONFERENCE_ID";
|
||||
public static final String KEY_CONFERENCE_INFO = "KEY_CONFERENCE_INFO";
|
||||
public static final String KEY_CONFERENCE_ERROR = "KEY_CONFERENCE_ERROR";
|
||||
public static final String KEY_CONFERENCE_MESSAGE = "KEY_CONFERENCE_MESSAGE";
|
||||
|
||||
public static final String KEY_ROOM_URL = "roomURL";
|
||||
public static final String KEY_ERROR_CODE = "errorCode";
|
||||
public static final String KEY_MESSAGE = "message";
|
||||
public static final String KEY_ROOM_ID = "roomId";
|
||||
public static final String KEY_USER_ID = "userId";
|
||||
public static final String KEY_USER_MODEL = "userModel";
|
||||
public static final String KEY_USER_INFO = "userInfo";
|
||||
public static final String KEY_ROLE = "role";
|
||||
public static final String KEY_STREAM_TYPE = "streamType";
|
||||
public static final String KEY_HAS_VIDEO = "hasVideo";
|
||||
public static final String KEY_HAS_AUDIO = "hasAudio";
|
||||
public static final String KEY_REASON = "reason";
|
||||
public static final String KEY_VOLUME_MAP = "volumeMap";
|
||||
public static final String KEY_NETWORK_MAP = "networkMap";
|
||||
public static final String KEY_SEAT_LIST = "seatList";
|
||||
public static final String KEY_SEATED_LIST = "seatedList";
|
||||
public static final String KEY_LEFT_LIST = "leftList";
|
||||
public static final String KEY_REQUEST = "request";
|
||||
public static final String KEY_REQUEST_ID = "requestId";
|
||||
public static final String KEY_IS_FREE_SPEECH = "isFreeSpeech";
|
||||
public static final String KEY_CONFIGURATION = "configuration";
|
||||
public static final String KEY_IS_DISABLE = "isDisable";
|
||||
public static final String KEY_MAX_SEAT_COUNT = "maxSeatCount";
|
||||
public static final String KEY_ROOM_NAME = "roomName";
|
||||
|
||||
public static final String KEY_USER_POSITION = "KEY_USER_POSITION";
|
||||
public static final String KEY_SEAT_USER_POSITION = "KEY_SEAT_USER_POSITION";
|
||||
public static final String KEY_ON_STATISTICS = "KEY_ON_STATISTICS";
|
||||
public static final String KEY_ENABLE_FLOAT_CHAT = "KEY_ENABLE_FLOAT_CHAT";
|
||||
}
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
package com.tencent.cloud.tuikit.roomkit.manager.observer;
|
||||
|
||||
import static com.tencent.cloud.tuikit.engine.extension.TUIConferenceListManager.ConferenceModifyFlag.ROOM_NAME;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import com.tencent.cloud.tuikit.engine.extension.TUIConferenceListManager;
|
||||
import com.tencent.cloud.tuikit.roomkit.manager.eventcenter.ConferenceEventCenter;
|
||||
import com.tencent.cloud.tuikit.roomkit.manager.eventcenter.ConferenceEventConstant;
|
||||
import com.tencent.cloud.tuikit.roomkit.state.ConferenceState;
|
||||
import com.tencent.cloud.tuikit.roomkit.state.RoomState;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class ConferenceListObserver extends TUIConferenceListManager.Observer {
|
||||
private static final String TAG = "ConferenceListObserver";
|
||||
|
||||
private final RoomState mRoomState;
|
||||
|
||||
public ConferenceListObserver(ConferenceState conferenceState) {
|
||||
mRoomState = conferenceState.roomState;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConferenceInfoChanged(TUIConferenceListManager.ConferenceInfo conferenceInfo, List<TUIConferenceListManager.ConferenceModifyFlag> modifyFlagList) {
|
||||
Log.d(TAG, "onConferenceInfoChanged conferenceId=" + conferenceInfo.basicRoomInfo.roomId + " name=" + conferenceInfo.basicRoomInfo.name);
|
||||
if (!TextUtils.equals(mRoomState.roomId.get(), conferenceInfo.basicRoomInfo.roomId)) {
|
||||
return;
|
||||
}
|
||||
if (!isConferenceNameChanged(modifyFlagList)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put(ConferenceEventConstant.KEY_ROOM_ID, conferenceInfo.basicRoomInfo.roomId);
|
||||
map.put(ConferenceEventConstant.KEY_ROOM_NAME, conferenceInfo.basicRoomInfo.name);
|
||||
mRoomState.roomName.set(conferenceInfo.basicRoomInfo.name);
|
||||
ConferenceEventCenter.getInstance().notifyEngineEvent(ConferenceEventCenter.RoomEngineEvent.ROOM_NAME_CHANGED, map);
|
||||
}
|
||||
|
||||
private boolean isConferenceNameChanged(List<TUIConferenceListManager.ConferenceModifyFlag> modifyFlagList) {
|
||||
for (TUIConferenceListManager.ConferenceModifyFlag flag : modifyFlagList) {
|
||||
if (flag == ROOM_NAME) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
+124
@@ -0,0 +1,124 @@
|
||||
package com.tencent.cloud.tuikit.roomkit.manager.observer;
|
||||
|
||||
import static com.tencent.cloud.tuikit.roomkit.manager.eventcenter.ConferenceEventConstant.KEY_CONFERENCE;
|
||||
import static com.tencent.cloud.tuikit.roomkit.manager.eventcenter.ConferenceEventConstant.KEY_CONFERENCE_ERROR;
|
||||
import static com.tencent.cloud.tuikit.roomkit.manager.eventcenter.ConferenceEventConstant.KEY_CONFERENCE_EXITED;
|
||||
import static com.tencent.cloud.tuikit.roomkit.manager.eventcenter.ConferenceEventConstant.KEY_CONFERENCE_FINISHED;
|
||||
import static com.tencent.cloud.tuikit.roomkit.manager.eventcenter.ConferenceEventConstant.KEY_CONFERENCE_INFO;
|
||||
import static com.tencent.cloud.tuikit.roomkit.manager.eventcenter.ConferenceEventConstant.KEY_CONFERENCE_JOINED;
|
||||
import static com.tencent.cloud.tuikit.roomkit.manager.eventcenter.ConferenceEventConstant.KEY_CONFERENCE_MESSAGE;
|
||||
import static com.tencent.cloud.tuikit.roomkit.manager.eventcenter.ConferenceEventConstant.KEY_CONFERENCE_STARTED;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import com.tencent.cloud.tuikit.engine.common.TUICommonDefine;
|
||||
import com.tencent.cloud.tuikit.engine.room.TUIRoomDefine;
|
||||
import com.tencent.cloud.tuikit.roomkit.ConferenceDefine;
|
||||
import com.tencent.cloud.tuikit.roomkit.manager.eventcenter.ConferenceEventConstant;
|
||||
import com.tencent.qcloud.tuicore.TUICore;
|
||||
import com.tencent.qcloud.tuicore.interfaces.ITUINotification;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
public class ConferenceObserverManager implements ITUINotification {
|
||||
private static final String TAG = "ConferenceObserverMg";
|
||||
|
||||
private final List<ConferenceDefine.ConferenceObserver> mObserverList = new CopyOnWriteArrayList<>();
|
||||
|
||||
public ConferenceObserverManager() {
|
||||
registerEvent();
|
||||
}
|
||||
|
||||
public void destroy() {
|
||||
unRegisterEvent();
|
||||
}
|
||||
|
||||
public void addObserver(ConferenceDefine.ConferenceObserver observer) {
|
||||
Log.i(TAG, "addObserver : " + observer);
|
||||
if (observer != null && !mObserverList.contains(observer)) {
|
||||
mObserverList.add(observer);
|
||||
}
|
||||
}
|
||||
|
||||
public void removeObserver(ConferenceDefine.ConferenceObserver observer) {
|
||||
Log.i(TAG, "removeObserver : " + observer);
|
||||
if (observer != null) {
|
||||
mObserverList.remove(observer);
|
||||
}
|
||||
}
|
||||
|
||||
private void registerEvent() {
|
||||
TUICore.registerEvent(KEY_CONFERENCE, KEY_CONFERENCE_STARTED, this);
|
||||
TUICore.registerEvent(KEY_CONFERENCE, KEY_CONFERENCE_JOINED, this);
|
||||
TUICore.registerEvent(KEY_CONFERENCE, KEY_CONFERENCE_EXITED, this);
|
||||
TUICore.registerEvent(KEY_CONFERENCE, KEY_CONFERENCE_FINISHED, this);
|
||||
}
|
||||
|
||||
private void unRegisterEvent() {
|
||||
TUICore.unRegisterEvent(KEY_CONFERENCE, KEY_CONFERENCE_STARTED, this);
|
||||
TUICore.unRegisterEvent(KEY_CONFERENCE, KEY_CONFERENCE_JOINED, this);
|
||||
TUICore.unRegisterEvent(KEY_CONFERENCE, KEY_CONFERENCE_EXITED, this);
|
||||
TUICore.unRegisterEvent(KEY_CONFERENCE, KEY_CONFERENCE_FINISHED, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNotifyEvent(String key, String subKey, Map<String, Object> param) {
|
||||
handleEventConferenceStarted(subKey, param);
|
||||
handleEventConferenceJoined(subKey, param);
|
||||
handleEventConferenceExited(subKey, param);
|
||||
handleEventConferenceFinished(subKey, param);
|
||||
}
|
||||
|
||||
private void handleEventConferenceStarted(String subKey, Map<String, Object> param) {
|
||||
if (!TextUtils.equals(subKey, KEY_CONFERENCE_STARTED)) {
|
||||
return;
|
||||
}
|
||||
TUIRoomDefine.RoomInfo roomInfo = (TUIRoomDefine.RoomInfo) param.get(KEY_CONFERENCE_INFO);
|
||||
TUICommonDefine.Error error = (TUICommonDefine.Error) param.get(KEY_CONFERENCE_ERROR);
|
||||
String message = (String) param.get(KEY_CONFERENCE_MESSAGE);
|
||||
for (ConferenceDefine.ConferenceObserver observer : mObserverList) {
|
||||
observer.onConferenceStarted(roomInfo, error, message);
|
||||
}
|
||||
}
|
||||
|
||||
private void handleEventConferenceJoined(String subKey, Map<String, Object> param) {
|
||||
if (!TextUtils.equals(subKey, KEY_CONFERENCE_JOINED)) {
|
||||
return;
|
||||
}
|
||||
TUIRoomDefine.RoomInfo roomInfo = (TUIRoomDefine.RoomInfo) param.get(KEY_CONFERENCE_INFO);
|
||||
TUICommonDefine.Error error = (TUICommonDefine.Error) param.get(KEY_CONFERENCE_ERROR);
|
||||
String message = (String) param.get(KEY_CONFERENCE_MESSAGE);
|
||||
for (ConferenceDefine.ConferenceObserver observer : mObserverList) {
|
||||
observer.onConferenceJoined(roomInfo, error, message);
|
||||
}
|
||||
}
|
||||
|
||||
private void handleEventConferenceExited(String subKey, Map<String, Object> param) {
|
||||
if (!TextUtils.equals(subKey, KEY_CONFERENCE_EXITED)) {
|
||||
return;
|
||||
}
|
||||
TUIRoomDefine.RoomInfo roomInfo = (TUIRoomDefine.RoomInfo) param.get(ConferenceEventConstant.KEY_CONFERENCE);
|
||||
ConferenceDefine.ConferenceExitedReason reason = (ConferenceDefine.ConferenceExitedReason) param.get(ConferenceEventConstant.KEY_REASON);
|
||||
assert roomInfo != null;
|
||||
Log.i(TAG, "onConferenceExited roomId=" + roomInfo.roomId + " ownerId=" + roomInfo.ownerId + " roomName=" + roomInfo.name + " reason=" + reason);
|
||||
for (ConferenceDefine.ConferenceObserver observer : mObserverList) {
|
||||
observer.onConferenceExited(roomInfo, reason);
|
||||
}
|
||||
}
|
||||
|
||||
private void handleEventConferenceFinished(String subKey, Map<String, Object> param) {
|
||||
if (!TextUtils.equals(subKey, KEY_CONFERENCE_FINISHED)) {
|
||||
return;
|
||||
}
|
||||
TUIRoomDefine.RoomInfo roomInfo = (TUIRoomDefine.RoomInfo) param.get(ConferenceEventConstant.KEY_CONFERENCE);
|
||||
ConferenceDefine.ConferenceFinishedReason reason = (ConferenceDefine.ConferenceFinishedReason) param.get(ConferenceEventConstant.KEY_REASON);
|
||||
assert roomInfo != null;
|
||||
Log.i(TAG, "onConferenceFinished roomId=" + roomInfo.roomId + " ownerId=" + roomInfo.ownerId + " roomName=" + roomInfo.name + " reason=" + reason);
|
||||
for (ConferenceDefine.ConferenceObserver observer : mObserverList) {
|
||||
observer.onConferenceFinished(roomInfo, reason);
|
||||
}
|
||||
}
|
||||
}
|
||||
+381
@@ -0,0 +1,381 @@
|
||||
package com.tencent.cloud.tuikit.roomkit.manager.observer;
|
||||
|
||||
import static com.tencent.cloud.tuikit.engine.room.TUIRoomDefine.RoomDismissedReason.BY_SERVER;
|
||||
import static com.tencent.cloud.tuikit.engine.room.TUIRoomDefine.UserInfoModifyFlag.NAME_CARD;
|
||||
import static com.tencent.cloud.tuikit.engine.room.TUIRoomDefine.UserInfoModifyFlag.USER_ROLE;
|
||||
import static com.tencent.cloud.tuikit.engine.room.TUIRoomDefine.VideoStreamType.CAMERA_STREAM;
|
||||
import static com.tencent.cloud.tuikit.engine.room.TUIRoomDefine.VideoStreamType.CAMERA_STREAM_LOW;
|
||||
import static com.tencent.cloud.tuikit.engine.room.TUIRoomDefine.VideoStreamType.SCREEN_STREAM;
|
||||
import static com.tencent.cloud.tuikit.roomkit.ConferenceDefine.ConferenceExitedReason.EXITED_BY_ADMIN_KICK_OUT;
|
||||
import static com.tencent.cloud.tuikit.roomkit.ConferenceDefine.ConferenceExitedReason.EXITED_BY_JOINED_ON_OTHER_DEVICE;
|
||||
import static com.tencent.cloud.tuikit.roomkit.ConferenceDefine.ConferenceExitedReason.EXITED_BY_KICKED_OUT_OF_LINE;
|
||||
import static com.tencent.cloud.tuikit.roomkit.ConferenceDefine.ConferenceExitedReason.EXITED_BY_SERVER_KICK_OUT;
|
||||
import static com.tencent.cloud.tuikit.roomkit.ConferenceDefine.ConferenceExitedReason.EXITED_BY_USER_SIG_EXPIRED;
|
||||
import static com.tencent.cloud.tuikit.roomkit.ConferenceDefine.ConferenceFinishedReason.FINISHED_BY_OWNER;
|
||||
import static com.tencent.cloud.tuikit.roomkit.manager.eventcenter.ConferenceEventConstant.KEY_CONFERENCE;
|
||||
import static com.tencent.cloud.tuikit.roomkit.manager.eventcenter.ConferenceEventConstant.KEY_CONFERENCE_EXITED;
|
||||
import static com.tencent.cloud.tuikit.roomkit.manager.eventcenter.ConferenceEventConstant.KEY_CONFERENCE_FINISHED;
|
||||
import static com.tencent.cloud.tuikit.roomkit.manager.eventcenter.ConferenceEventConstant.KEY_REASON;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import com.tencent.cloud.tuikit.engine.common.TUICommonDefine;
|
||||
import com.tencent.cloud.tuikit.engine.room.TUIRoomDefine;
|
||||
import com.tencent.cloud.tuikit.engine.room.TUIRoomObserver;
|
||||
import com.tencent.cloud.tuikit.roomkit.ConferenceDefine;
|
||||
import com.tencent.cloud.tuikit.roomkit.manager.eventcenter.ConferenceEventCenter;
|
||||
import com.tencent.cloud.tuikit.roomkit.manager.eventcenter.ConferenceEventConstant;
|
||||
import com.tencent.cloud.tuikit.roomkit.state.ConferenceState;
|
||||
import com.tencent.cloud.tuikit.roomkit.manager.ConferenceController;
|
||||
import com.tencent.cloud.tuikit.roomkit.state.InvitationState;
|
||||
import com.tencent.cloud.tuikit.roomkit.state.MediaState;
|
||||
import com.tencent.cloud.tuikit.roomkit.state.RoomState;
|
||||
import com.tencent.cloud.tuikit.roomkit.state.SeatState;
|
||||
import com.tencent.cloud.tuikit.roomkit.state.UserState;
|
||||
import com.tencent.cloud.tuikit.roomkit.state.ViewState;
|
||||
import com.tencent.cloud.tuikit.roomkit.state.entity.UserEntity;
|
||||
import com.tencent.qcloud.tuicore.TUICore;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class RoomEngineObserver extends TUIRoomObserver {
|
||||
private static final String TAG = "RoomEngineObserver";
|
||||
|
||||
private final ConferenceState mConferenceState;
|
||||
private final SeatState mSeatState;
|
||||
private final ViewState mViewState;
|
||||
private final UserState mUserState;
|
||||
private final RoomState mRoomState;
|
||||
private final MediaState mMediaState;
|
||||
private final InvitationState mInvitationState;
|
||||
|
||||
public RoomEngineObserver(ConferenceState conferenceState) {
|
||||
mConferenceState = conferenceState;
|
||||
mSeatState = conferenceState.seatState;
|
||||
mViewState = conferenceState.viewState;
|
||||
mUserState = conferenceState.userState;
|
||||
mRoomState = conferenceState.roomState;
|
||||
mMediaState = conferenceState.mediaState;
|
||||
mInvitationState = conferenceState.invitationState;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(TUICommonDefine.Error errorCode, String message) {
|
||||
Log.d(TAG, "onError errorCode=" + errorCode + " message=" + message);
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put(ConferenceEventConstant.KEY_ERROR_CODE, errorCode);
|
||||
map.put(ConferenceEventConstant.KEY_MESSAGE, message);
|
||||
ConferenceEventCenter.getInstance().notifyEngineEvent(ConferenceEventCenter.RoomEngineEvent.ERROR, map);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onKickedOffLine(String message) {
|
||||
Log.d(TAG, "onKickedOffLine message=" + message);
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put(ConferenceEventConstant.KEY_MESSAGE, message);
|
||||
ConferenceEventCenter.getInstance().notifyEngineEvent(ConferenceEventCenter.RoomEngineEvent.KICKED_OFF_LINE, map);
|
||||
|
||||
Map<String, Object> param = new HashMap<>(2);
|
||||
param.put(KEY_CONFERENCE, mConferenceState.roomState.roomInfo);
|
||||
param.put(KEY_REASON, EXITED_BY_KICKED_OUT_OF_LINE);
|
||||
TUICore.notifyEvent(KEY_CONFERENCE, KEY_CONFERENCE_EXITED, param);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUserSigExpired() {
|
||||
Log.d(TAG, "onUserSigExpired");
|
||||
ConferenceEventCenter.getInstance().notifyEngineEvent(ConferenceEventCenter.RoomEngineEvent.USER_SIG_EXPIRED, null);
|
||||
|
||||
Map<String, Object> param = new HashMap<>(2);
|
||||
param.put(KEY_CONFERENCE, mConferenceState.roomState.roomInfo);
|
||||
param.put(KEY_REASON, EXITED_BY_USER_SIG_EXPIRED);
|
||||
TUICore.notifyEvent(KEY_CONFERENCE, KEY_CONFERENCE_EXITED, param);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRoomNameChanged(String roomId, String roomName) {
|
||||
Log.d(TAG, "onRoomNameChanged roomId=" + roomId + ",roomName=" + roomName);
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put(ConferenceEventConstant.KEY_ROOM_ID, roomId);
|
||||
map.put(ConferenceEventConstant.KEY_ROOM_NAME, roomName);
|
||||
mConferenceState.roomState.roomName.set(roomName);
|
||||
ConferenceEventCenter.getInstance().notifyEngineEvent(ConferenceEventCenter.RoomEngineEvent.ROOM_NAME_CHANGED, map);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAllUserMicrophoneDisableChanged(String roomId, boolean isDisable) {
|
||||
mConferenceState.roomInfo.isMicrophoneDisableForAllUser = isDisable;
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put(ConferenceEventConstant.KEY_ROOM_ID, roomId);
|
||||
map.put(ConferenceEventConstant.KEY_IS_DISABLE, isDisable);
|
||||
ConferenceEventCenter.getInstance()
|
||||
.notifyEngineEvent(ConferenceEventCenter.RoomEngineEvent.ALL_USER_MICROPHONE_DISABLE_CHANGED, map);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAllUserCameraDisableChanged(String roomId, boolean isDisable) {
|
||||
mConferenceState.roomInfo.isCameraDisableForAllUser = isDisable;
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put(ConferenceEventConstant.KEY_ROOM_ID, roomId);
|
||||
map.put(ConferenceEventConstant.KEY_IS_DISABLE, isDisable);
|
||||
ConferenceEventCenter.getInstance()
|
||||
.notifyEngineEvent(ConferenceEventCenter.RoomEngineEvent.ALL_USER_CAMERA_DISABLE_CHANGED, map);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onScreenShareForAllUserDisableChanged(String roomId, boolean isDisable) {
|
||||
Log.d(TAG, "onScreenShareForAllUserDisableChanged roomId=" + roomId + ",isDisable=" + isDisable);
|
||||
mConferenceState.roomState.isDisableScreen.set(isDisable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSendMessageForAllUserDisableChanged(String roomId, boolean isDisable) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put(ConferenceEventConstant.KEY_ROOM_ID, roomId);
|
||||
map.put(ConferenceEventConstant.KEY_IS_DISABLE, isDisable);
|
||||
ConferenceEventCenter.getInstance()
|
||||
.notifyEngineEvent(ConferenceEventCenter.RoomEngineEvent.SEND_MESSAGE_FOR_ALL_USER_DISABLE_CHANGED, map);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRoomDismissed(String roomId, TUIRoomDefine.RoomDismissedReason reason) {
|
||||
Log.d(TAG, "onRoomDismissed roomId=" + roomId);
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put(ConferenceEventConstant.KEY_ROOM_ID, roomId);
|
||||
ConferenceEventCenter.getInstance().notifyEngineEvent(ConferenceEventCenter.RoomEngineEvent.ROOM_DISMISSED, map);
|
||||
|
||||
Map<String, Object> param = new HashMap<>(2);
|
||||
param.put(KEY_CONFERENCE, mRoomState.roomInfo);
|
||||
param.put(KEY_REASON, FINISHED_BY_OWNER);
|
||||
TUICore.notifyEvent(KEY_CONFERENCE, KEY_CONFERENCE_FINISHED, param);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onKickedOutOfRoom(String roomId, TUIRoomDefine.KickedOutOfRoomReason reason, String message) {
|
||||
Log.d(TAG, "onKickedOutOfRoom roomId=" + roomId + " reason=" + reason + " message=" + message);
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put(ConferenceEventConstant.KEY_ROOM_ID, roomId);
|
||||
map.put(ConferenceEventConstant.KEY_MESSAGE, message);
|
||||
ConferenceEventCenter.getInstance().notifyEngineEvent(ConferenceEventCenter.RoomEngineEvent.KICKED_OUT_OF_ROOM, map);
|
||||
|
||||
Map<String, Object> param = new HashMap<>(2);
|
||||
param.put(KEY_CONFERENCE, mRoomState.roomInfo);
|
||||
ConferenceDefine.ConferenceExitedReason exitedReason = reason == TUIRoomDefine.KickedOutOfRoomReason.BY_ADMIN
|
||||
? EXITED_BY_ADMIN_KICK_OUT : reason == TUIRoomDefine.KickedOutOfRoomReason.BY_SERVER
|
||||
? EXITED_BY_SERVER_KICK_OUT : EXITED_BY_JOINED_ON_OTHER_DEVICE;
|
||||
param.put(KEY_REASON, exitedReason);
|
||||
TUICore.notifyEvent(KEY_CONFERENCE, KEY_CONFERENCE_EXITED, param);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRemoteUserEnterRoom(String roomId, TUIRoomDefine.UserInfo userInfo) {
|
||||
Log.d(TAG, "onRemoteUserEnterRoom userId=" + userInfo.userId);
|
||||
mConferenceState.remoteUserEnterRoom(userInfo);
|
||||
mUserState.remoteUserEnterRoom(userInfo);
|
||||
mInvitationState.remoteUserEnterRoom(userInfo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRemoteUserLeaveRoom(String roomId, TUIRoomDefine.UserInfo userInfo) {
|
||||
Log.d(TAG, "onRemoteUserLeaveRoom userId=" + userInfo.userId);
|
||||
mConferenceState.remoteUserLeaveRoom(userInfo.userId);
|
||||
mUserState.remoteUserLeaveRoom(userInfo);
|
||||
mConferenceState.removeTakeSeatRequestByUserId(userInfo.userId);
|
||||
mSeatState.removeTakeSeatRequestByUserId(userInfo.userId);
|
||||
mViewState.removePendingTakeSeatRequestByUserId(userInfo.userId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUserInfoChanged(TUIRoomDefine.UserInfo userInfo, List<TUIRoomDefine.UserInfoModifyFlag> modifyFlag) {
|
||||
Log.d(TAG, "onUserInfoChanged userId=" + userInfo.userId + " role=" + userInfo.userRole);
|
||||
handleUserRoleChangedIfNeeded(userInfo, modifyFlag);
|
||||
handleNameCardChangedIfNeeded(userInfo, modifyFlag);
|
||||
}
|
||||
|
||||
private void handleUserRoleChangedIfNeeded(TUIRoomDefine.UserInfo userInfo, List<TUIRoomDefine.UserInfoModifyFlag> modifyFlag) {
|
||||
if (!modifyFlag.contains(USER_ROLE)) {
|
||||
return;
|
||||
}
|
||||
if (userInfo.userRole == TUIRoomDefine.Role.ROOM_OWNER) {
|
||||
mConferenceState.roomState.ownerName.set(TextUtils.isEmpty(userInfo.nameCard) ? userInfo.userName : userInfo.nameCard);
|
||||
}
|
||||
if (TextUtils.equals(userInfo.userId, mConferenceState.userModel.userId)) {
|
||||
if (mConferenceState.userModel.getRole() == TUIRoomDefine.Role.GENERAL_USER
|
||||
&& userInfo.userRole != TUIRoomDefine.Role.GENERAL_USER) {
|
||||
ConferenceController.sharedInstance().getSeatApplicationList();
|
||||
}
|
||||
mConferenceState.userModel.changeRole(userInfo.userRole);
|
||||
ConferenceController.sharedInstance().autoTakeSeatForOwner(null);
|
||||
ConferenceController.sharedInstance().enableSendingMessageForOwner();
|
||||
}
|
||||
mConferenceState.handleUserRoleChanged(userInfo.userId, userInfo.userRole);
|
||||
mUserState.handleUserRoleChanged(userInfo);
|
||||
}
|
||||
|
||||
private void handleNameCardChangedIfNeeded(TUIRoomDefine.UserInfo userInfo, List<TUIRoomDefine.UserInfoModifyFlag> modifyFlag) {
|
||||
if (!modifyFlag.contains(NAME_CARD)) {
|
||||
return;
|
||||
}
|
||||
mSeatState.updateTakeSeatRequestUserName(userInfo.userId, userInfo.nameCard);
|
||||
mConferenceState.setUserNameCard(userInfo.userId, userInfo.nameCard);
|
||||
mConferenceState.updateTakeSeatRequestUserName(userInfo.userId, userInfo.nameCard);
|
||||
mUserState.userNameCardChanged(userInfo);
|
||||
if (userInfo.userRole == TUIRoomDefine.Role.ROOM_OWNER) {
|
||||
mRoomState.ownerName.set(userInfo.nameCard);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUserVideoStateChanged(String userId, TUIRoomDefine.VideoStreamType streamType, boolean hasVideo,
|
||||
TUIRoomDefine.ChangeReason reason) {
|
||||
Log.d(TAG, "onUserVideoStateChanged userId=" + userId + " hasVideo=" + hasVideo + " type=" + streamType);
|
||||
if (TextUtils.equals(userId, mConferenceState.userModel.userId) && streamType == CAMERA_STREAM_LOW) {
|
||||
return;
|
||||
}
|
||||
if (TextUtils.equals(userId, mConferenceState.userModel.userId) && streamType == CAMERA_STREAM) {
|
||||
mMediaState.isCameraOpened.set(hasVideo);
|
||||
}
|
||||
if (streamType == SCREEN_STREAM) {
|
||||
mConferenceState.handleUserScreenStateChanged(userId, hasVideo);
|
||||
mUserState.updateUserScreenState(userId, hasVideo);
|
||||
} else {
|
||||
mConferenceState.updateUserCameraState(userId, streamType, hasVideo, reason);
|
||||
mUserState.updateUserCameraState(userId, hasVideo, streamType);
|
||||
}
|
||||
if (TextUtils.equals(userId, mConferenceState.userModel.userId) && streamType == SCREEN_STREAM && !hasVideo && reason == TUIRoomDefine.ChangeReason.BY_ADMIN) {
|
||||
ConferenceEventCenter.getInstance().notifyEngineEvent(ConferenceEventCenter.RoomEngineEvent.LOCAL_SHARE_STOPPED_BY_ADMIN, null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUserAudioStateChanged(String userId, boolean hasAudio, TUIRoomDefine.ChangeReason reason) {
|
||||
Log.d(TAG, "onUserAudioStateChanged userId=" + userId + " hasAudio=" + hasAudio);
|
||||
mConferenceState.updateUserAudioState(userId, hasAudio, reason);
|
||||
mUserState.updateUserAudioState(userId, hasAudio);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUserVoiceVolumeChanged(Map<String, Integer> volumeMap) {
|
||||
Map<String, Integer> volumes = mMediaState.volumeInfos.get();
|
||||
for (Map.Entry<String, Integer> entry : volumeMap.entrySet()) {
|
||||
String userId = entry.getKey();
|
||||
if (TextUtils.isEmpty(userId)) {
|
||||
continue;
|
||||
}
|
||||
if (TextUtils.equals(userId, mConferenceState.userModel.userId) && !mConferenceState.audioModel.isHasAudioStream()) {
|
||||
continue;
|
||||
}
|
||||
volumes.put(entry.getKey(), entry.getValue());
|
||||
int volume = entry.getValue();
|
||||
mConferenceState.updateUserAudioVolume(userId, volume);
|
||||
UserState.UserVolumeInfo userVolumeInfo = mUserState.userVolumeInfo.get();
|
||||
userVolumeInfo.update(userId, volume);
|
||||
mUserState.userVolumeInfo.set(userVolumeInfo);
|
||||
}
|
||||
mMediaState.volumeInfos.set(volumes);
|
||||
volumes.clear();
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put(ConferenceEventConstant.KEY_VOLUME_MAP, volumeMap);
|
||||
ConferenceEventCenter.getInstance().notifyEngineEvent(ConferenceEventCenter.RoomEngineEvent.USER_VOICE_VOLUME_CHANGED, map);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSendMessageForUserDisableChanged(String roomId, String userId, boolean isDisable) {
|
||||
Log.d(TAG, "onSendMessageForUserDisableChanged userId=" + userId + " isDisable=" + isDisable);
|
||||
mConferenceState.enableUserSendingMsg(userId, !isDisable);
|
||||
mUserState.updateUserMessageState(userId, isDisable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUserNetworkQualityChanged(Map<String, TUICommonDefine.NetworkInfo> networkMap) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put(ConferenceEventConstant.KEY_NETWORK_MAP, networkMap);
|
||||
ConferenceEventCenter.getInstance().
|
||||
notifyEngineEvent(ConferenceEventCenter.RoomEngineEvent.USER_NETWORK_QUALITY_CHANGED, map);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUserScreenCaptureStopped(int reason) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put(ConferenceEventConstant.KEY_REASON, reason);
|
||||
ConferenceEventCenter.getInstance().
|
||||
notifyEngineEvent(ConferenceEventCenter.RoomEngineEvent.USER_SCREEN_CAPTURE_STOPPED, map);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSeatListChanged(List<TUIRoomDefine.SeatInfo> seatList, List<TUIRoomDefine.SeatInfo> seatedList,
|
||||
List<TUIRoomDefine.SeatInfo> leftList) {
|
||||
Log.d(TAG, "onSeatListChanged");
|
||||
ConferenceController manager = ConferenceController.sharedInstance();
|
||||
for (TUIRoomDefine.SeatInfo item : seatedList) {
|
||||
mSeatState.seatedUsers.add(item.userId);
|
||||
manager.getUserInfo(item.userId, new TUIRoomDefine.GetUserInfoCallback() {
|
||||
@Override
|
||||
public void onSuccess(TUIRoomDefine.UserInfo userInfo) {
|
||||
Log.d(TAG, "onSeatListChanged remoteUserTakeSeat userId=" + userInfo.userId);
|
||||
mConferenceState.remoteUserTakeSeat(userInfo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(TUICommonDefine.Error error, String s) {
|
||||
Log.e(TAG, "onSeatListChanged getUserInfo onError, error=" + error + " s=" + s);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
for (TUIRoomDefine.SeatInfo item : leftList) {
|
||||
Log.d(TAG, "onSeatListChanged remoteUserLeaveSeat userId=" + item.userId);
|
||||
mConferenceState.remoteUserLeaveSeat(item.userId);
|
||||
mSeatState.seatedUsers.remove(item.userId);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRequestReceived(TUIRoomDefine.Request request) {
|
||||
Log.d(TAG, "onRequestReceived userId=" + request.userId + " action=" + request.requestAction);
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put(ConferenceEventConstant.KEY_REQUEST, request);
|
||||
UserEntity user = mConferenceState.findUserWithCameraStream(mConferenceState.allUserList, request.userId);
|
||||
map.put(ConferenceEventConstant.KEY_ROLE, user == null ? TUIRoomDefine.Role.ROOM_OWNER : user.getRole());
|
||||
ConferenceEventCenter.getInstance().notifyEngineEvent(ConferenceEventCenter.RoomEngineEvent.REQUEST_RECEIVED, map);
|
||||
|
||||
if (TUIRoomDefine.RequestAction.REQUEST_TO_TAKE_SEAT == request.requestAction) {
|
||||
if (mConferenceState.userModel.getRole() == TUIRoomDefine.Role.ROOM_OWNER && TextUtils.equals(request.userId,
|
||||
mConferenceState.userModel.userId)) {
|
||||
ConferenceController.sharedInstance()
|
||||
.responseRemoteRequest(request.requestAction, request.requestId, true, null);
|
||||
} else {
|
||||
mConferenceState.addTakeSeatRequest(request);
|
||||
mSeatState.addTakeSeatRequest(request);
|
||||
mViewState.addPendingTakeSeatRequest(request.requestId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRequestCancelled(TUIRoomDefine.Request request, TUIRoomDefine.UserInfo operateUser) {
|
||||
Log.d(TAG, "onRequestCancelled userId=" + request.userId + " action=" + request.requestAction);
|
||||
mConferenceState.removeTakeSeatRequest(request.requestId);
|
||||
mSeatState.removeTakeSeatRequest(request.requestId);
|
||||
mViewState.removePendingTakeSeatRequest(request.requestId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRequestProcessed(TUIRoomDefine.Request request, TUIRoomDefine.UserInfo operateUser) {
|
||||
Log.d(TAG, "onRequestProcessed userId=" + request.userId + " action=" + request.requestAction);
|
||||
mConferenceState.removeTakeSeatRequest(request.requestId);
|
||||
mSeatState.removeTakeSeatRequest(request.requestId);
|
||||
mViewState.removePendingTakeSeatRequest(request.requestId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onKickedOffSeat(int seatIndex, TUIRoomDefine.UserInfo operateUser) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put(ConferenceEventConstant.KEY_USER_ID, operateUser.userId);
|
||||
ConferenceEventCenter.getInstance().notifyEngineEvent(ConferenceEventCenter.RoomEngineEvent.KICKED_OFF_SEAT, map);
|
||||
mConferenceState.audioModel.setMicOpen(false);
|
||||
}
|
||||
}
|
||||
+124
@@ -0,0 +1,124 @@
|
||||
package com.tencent.cloud.tuikit.roomkit.manager.observer;
|
||||
|
||||
import static com.tencent.cloud.tuikit.roomkit.state.ASRState.ASR_TYPE_TRANSCRIPTION;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import com.tencent.cloud.tuikit.roomkit.manager.eventcenter.ConferenceEventCenter;
|
||||
import com.tencent.cloud.tuikit.roomkit.manager.eventcenter.ConferenceEventConstant;
|
||||
import com.tencent.cloud.tuikit.roomkit.manager.ConferenceController;
|
||||
import com.tencent.cloud.tuikit.roomkit.state.ASRState;
|
||||
import com.tencent.cloud.tuikit.roomkit.state.UserState;
|
||||
import com.tencent.trtc.TRTCCloudListener;
|
||||
import com.tencent.trtc.TRTCStatistics;
|
||||
import com.trtc.tuikit.common.livedata.LiveListData;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class TRTCObserver extends TRTCCloudListener {
|
||||
private static final String TAG = "TRTCObserver";
|
||||
|
||||
@Override
|
||||
public void onRecvCustomCmdMsg(String userId, int cmdID, int seq, byte[] message) {
|
||||
if (cmdID != 1 || message == null) {
|
||||
return;
|
||||
}
|
||||
JSONObject data;
|
||||
String type;
|
||||
try {
|
||||
data = new JSONObject(new String(message));
|
||||
type = data.getString("type");
|
||||
} catch (JSONException e) {
|
||||
Log.e(TAG, "onRecvCustomCmdMsg JSONException");
|
||||
return;
|
||||
}
|
||||
if (TextUtils.isEmpty(type)) {
|
||||
return;
|
||||
}
|
||||
ASRState.SpeechToText speechToText;
|
||||
if (TextUtils.equals("10000", type)) {
|
||||
speechToText = parseNumberTypeData(data);
|
||||
} else {
|
||||
speechToText = parseStringTypeData(data);
|
||||
}
|
||||
saveTextData(speechToText);
|
||||
}
|
||||
|
||||
private ASRState.SpeechToText parseStringTypeData(JSONObject data) {
|
||||
ASRState.SpeechToText speechToText = new ASRState.SpeechToText();
|
||||
try {
|
||||
speechToText.roundId = data.getString("roundid");
|
||||
speechToText.userId = data.getString("userid");
|
||||
speechToText.text = data.getString("text");
|
||||
speechToText.startTimeMs = data.getLong("start_ms_ts");
|
||||
speechToText.endTimeMs = data.getLong("end_ms_ts");
|
||||
speechToText.isSpeechEnd = TextUtils.equals(ASR_TYPE_TRANSCRIPTION, data.getString("type"));
|
||||
} catch (JSONException e) {
|
||||
Log.w(TAG, "parseStringTypeData JSONException");
|
||||
}
|
||||
return speechToText;
|
||||
}
|
||||
|
||||
private ASRState.SpeechToText parseNumberTypeData(JSONObject data) {
|
||||
ASRState.SpeechToText speechToText = new ASRState.SpeechToText();
|
||||
try {
|
||||
speechToText.userId = data.getString("sender");
|
||||
speechToText.startTimeMs = data.getLong("start_ms_ts");
|
||||
speechToText.endTimeMs = data.getLong("end_ms_ts");
|
||||
JSONObject payload = data.getJSONObject("payload");
|
||||
speechToText.roundId = payload.getString("roundid");
|
||||
speechToText.text = payload.getString("text");
|
||||
speechToText.isSpeechEnd = payload.getBoolean("end");
|
||||
} catch (JSONException e) {
|
||||
Log.w(TAG, "parseNumberTypeData JSONException");
|
||||
}
|
||||
return speechToText;
|
||||
}
|
||||
|
||||
private void saveTextData(ASRState.SpeechToText speechToText) {
|
||||
if (speechToText == null || TextUtils.isEmpty(speechToText.roundId)) {
|
||||
return;
|
||||
}
|
||||
UserState.UserInfo userInfo = ConferenceController.sharedInstance().getUserState().allUsers.find(new UserState.UserInfo(speechToText.userId));
|
||||
if (userInfo != null && !TextUtils.isEmpty(userInfo.userName)) {
|
||||
speechToText.userName = userInfo.userName;
|
||||
}
|
||||
if (userInfo != null && !TextUtils.isEmpty(userInfo.avatarUrl)) {
|
||||
speechToText.avatarUrl = userInfo.avatarUrl;
|
||||
}
|
||||
LiveListData<ASRState.SpeechToText> speechToTexts = ConferenceController.sharedInstance().getASRState().speechToTexts;
|
||||
if (speechToTexts.contains(speechToText)) {
|
||||
speechToTexts.change(speechToText);
|
||||
} else {
|
||||
speechToTexts.add(speechToText);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConnectionLost() {
|
||||
Log.d(TAG, "onConnectionLost");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTryToReconnect() {
|
||||
Log.d(TAG, "onTryToReconnect");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConnectionRecovery() {
|
||||
Log.d(TAG, "onConnectionRecovery");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStatistics(TRTCStatistics statistics) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put(ConferenceEventConstant.KEY_ON_STATISTICS, statistics);
|
||||
ConferenceEventCenter.getInstance().notifyEngineEvent(ConferenceEventCenter.RoomEngineEvent.ON_STATISTICS, map);
|
||||
}
|
||||
|
||||
}
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
package com.tencent.cloud.tuikit.roomkit.manager.observer;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import com.tencent.cloud.tuikit.roomkit.state.ConferenceState;
|
||||
|
||||
import com.tencent.cloud.tuikit.roomkit.state.UserState;
|
||||
import com.tencent.qcloud.tuicore.TUIConstants;
|
||||
import com.tencent.qcloud.tuicore.TUICore;
|
||||
import com.tencent.qcloud.tuicore.TUILogin;
|
||||
import com.tencent.qcloud.tuicore.interfaces.ITUINotification;
|
||||
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class TUILoginStateObserver implements ITUINotification {
|
||||
private static final String TAG = "TUILoginStateObserver";
|
||||
|
||||
private ConferenceState mConferenceState;
|
||||
|
||||
public TUILoginStateObserver(ConferenceState conferenceState) {
|
||||
mConferenceState = conferenceState;
|
||||
}
|
||||
|
||||
public void registerObserver() {
|
||||
TUICore.registerEvent(TUIConstants.TUILogin.EVENT_LOGIN_STATE_CHANGED, TUIConstants.TUILogin.EVENT_SUB_KEY_USER_LOGIN_SUCCESS, this);
|
||||
}
|
||||
|
||||
public void unregisterObserver() {
|
||||
TUICore.unRegisterEvent(TUIConstants.TUILogin.EVENT_LOGIN_STATE_CHANGED, TUIConstants.TUILogin.EVENT_SUB_KEY_USER_LOGIN_SUCCESS, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNotifyEvent(String key, String subKey, Map<String, Object> param) {
|
||||
Log.i(TAG, "onNotifyEvent key = " + key + "subKey = " + subKey);
|
||||
if (!TUIConstants.TUILogin.EVENT_LOGIN_STATE_CHANGED.equals(key) || !TUIConstants.TUILogin.EVENT_SUB_KEY_USER_LOGIN_SUCCESS.equals(subKey)) {
|
||||
return;
|
||||
}
|
||||
mConferenceState.userModel.userId = TUILogin.getUserId();
|
||||
UserState.UserInfo userInfo = mConferenceState.userState.selfInfo.get();
|
||||
userInfo.userId = TUILogin.getUserId();
|
||||
mConferenceState.userState.selfInfo.set(userInfo);
|
||||
}
|
||||
}
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
package com.tencent.cloud.tuikit.roomkit.state;
|
||||
|
||||
import android.text.TextUtils;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.trtc.tuikit.common.livedata.LiveListData;
|
||||
|
||||
public class ASRState {
|
||||
public LiveListData<SpeechToText> speechToTexts = new LiveListData<>();
|
||||
|
||||
public static class SpeechToText {
|
||||
public String roundId = "";
|
||||
public String userId = "";
|
||||
public String userName = "";
|
||||
public String avatarUrl = "";
|
||||
public String text = "";
|
||||
public long startTimeMs = 0L;
|
||||
public long endTimeMs = 0L;
|
||||
public boolean isSpeechEnd = false;
|
||||
|
||||
@Override
|
||||
public boolean equals(@Nullable Object obj) {
|
||||
if (obj instanceof SpeechToText) {
|
||||
return TextUtils.equals(this.roundId, ((SpeechToText) obj).roundId);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static final String ASR_TYPE_SUBTITLE = "subtitle";
|
||||
public static final String ASR_TYPE_TRANSCRIPTION = "transcription";
|
||||
}
|
||||
+73
@@ -0,0 +1,73 @@
|
||||
package com.tencent.cloud.tuikit.roomkit.state;
|
||||
|
||||
import android.text.TextUtils;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.tencent.cloud.tuikit.engine.extension.TUIConferenceListManager;
|
||||
import com.tencent.cloud.tuikit.engine.room.TUIRoomDefine;
|
||||
import com.trtc.tuikit.common.livedata.LiveData;
|
||||
import com.trtc.tuikit.common.livedata.LiveListData;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ConferenceListState {
|
||||
public LiveListData<ConferenceInfo> scheduledConferences = new LiveListData<>();
|
||||
public String fetchScheduledConferencesCursor = FETCH_CURSOR_OF_INIT;
|
||||
|
||||
public static final String FETCH_CURSOR_OF_INIT = "init";
|
||||
public static final String FETCH_CURSOR_OF_END = "end";
|
||||
|
||||
public static class ConferenceInfo {
|
||||
public long scheduleStartTime = 0L;
|
||||
public long scheduleEndTime = 0L;
|
||||
public List<UserState.UserInfo> scheduleAttendees = new ArrayList<>();
|
||||
public LiveListData<UserState.UserInfo> hadScheduledAttendees = new LiveListData<>();
|
||||
public String fetchScheduledAttendeesCursor = FETCH_CURSOR_OF_INIT;
|
||||
public LiveData<Integer> hadScheduledAttendeeCount = new LiveData<>(0);
|
||||
public int reminderSecondsBeforeStart = 0;
|
||||
public TUIConferenceListManager.ConferenceStatus status = TUIConferenceListManager.ConferenceStatus.NONE;
|
||||
public TUIRoomDefine.RoomInfo basicRoomInfo = new TUIRoomDefine.RoomInfo();
|
||||
|
||||
public ConferenceInfo(String conferenceId) {
|
||||
this.basicRoomInfo.roomId = conferenceId;
|
||||
this.basicRoomInfo.seatMode = TUIRoomDefine.SeatMode.APPLY_TO_TAKE;
|
||||
}
|
||||
|
||||
public ConferenceInfo(TUIConferenceListManager.ConferenceInfo conferenceInfo) {
|
||||
this.status = conferenceInfo.status;
|
||||
update(conferenceInfo);
|
||||
}
|
||||
|
||||
public void update(TUIConferenceListManager.ConferenceInfo conferenceInfo) {
|
||||
this.scheduleStartTime = conferenceInfo.scheduleStartTime;
|
||||
this.scheduleEndTime = conferenceInfo.scheduleEndTime;
|
||||
this.reminderSecondsBeforeStart = conferenceInfo.reminderSecondsBeforeStart;
|
||||
this.basicRoomInfo = conferenceInfo.basicRoomInfo;
|
||||
}
|
||||
|
||||
public TUIConferenceListManager.ConferenceInfo transferToEngineData() {
|
||||
TUIConferenceListManager.ConferenceInfo info = new TUIConferenceListManager.ConferenceInfo();
|
||||
info.scheduleStartTime = this.scheduleStartTime;
|
||||
info.scheduleEndTime = this.scheduleEndTime;
|
||||
info.scheduleAttendees = new ArrayList<>(this.scheduleAttendees.size());
|
||||
for (UserState.UserInfo item : this.scheduleAttendees) {
|
||||
info.scheduleAttendees.add(item.userId);
|
||||
}
|
||||
info.reminderSecondsBeforeStart = this.reminderSecondsBeforeStart;
|
||||
info.status = this.status;
|
||||
info.basicRoomInfo = this.basicRoomInfo;
|
||||
return info;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(@Nullable Object obj) {
|
||||
if (obj instanceof ConferenceInfo) {
|
||||
return TextUtils.equals(this.basicRoomInfo.roomId, ((ConferenceInfo) obj).basicRoomInfo.roomId);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+319
@@ -0,0 +1,319 @@
|
||||
package com.tencent.cloud.tuikit.roomkit.state;
|
||||
|
||||
import static com.tencent.cloud.tuikit.engine.extension.TUIConferenceInvitationManager.RejectedReason.IN_OTHER_CONFERENCE;
|
||||
import static com.tencent.cloud.tuikit.engine.extension.TUIConferenceInvitationManager.RejectedReason.REJECT_TO_ENTER;
|
||||
import static com.tencent.cloud.tuikit.roomkit.view.bridge.chat.AccessRoomConstants.BUSINESS_ID_ROOM_MESSAGE;
|
||||
import static com.tencent.cloud.tuikit.roomkit.view.bridge.chat.AccessRoomConstants.KEY_INVITE_DATA;
|
||||
import static com.tencent.cloud.tuikit.roomkit.view.bridge.chat.AccessRoomConstants.ROOM_INVITE_SINGLING;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
|
||||
import com.tencent.cloud.tuikit.engine.common.TUICommonDefine;
|
||||
import com.tencent.cloud.tuikit.engine.extension.TUIConferenceInvitationManager;
|
||||
import com.tencent.cloud.tuikit.engine.room.TUIRoomDefine;
|
||||
import com.tencent.cloud.tuikit.engine.room.TUIRoomEngine;
|
||||
import com.tencent.cloud.tuikit.roomkit.R;
|
||||
import com.tencent.cloud.tuikit.roomkit.common.utils.BusinessSceneUtil;
|
||||
import com.tencent.cloud.tuikit.roomkit.view.bridge.chat.model.manager.RoomMsgManager;
|
||||
import com.tencent.cloud.tuikit.roomkit.view.bridge.chat.view.InvitedToJoinRoomActivity;
|
||||
import com.tencent.cloud.tuikit.roomkit.view.bridge.chat.view.RoomClickListener;
|
||||
import com.tencent.cloud.tuikit.roomkit.view.bridge.chat.view.RoomMessageBean;
|
||||
import com.tencent.cloud.tuikit.roomkit.view.bridge.chat.view.RoomMessageHolder;
|
||||
import com.tencent.cloud.tuikit.roomkit.manager.ConferenceController;
|
||||
import com.tencent.imsdk.v2.V2TIMManager;
|
||||
import com.tencent.imsdk.v2.V2TIMSignalingListener;
|
||||
import com.tencent.qcloud.tuicore.ServiceInitializer;
|
||||
import com.tencent.qcloud.tuicore.TUIConfig;
|
||||
import com.tencent.qcloud.tuicore.TUIConstants;
|
||||
import com.tencent.qcloud.tuicore.TUICore;
|
||||
import com.tencent.qcloud.tuicore.TUILogin;
|
||||
import com.tencent.qcloud.tuicore.interfaces.ITUIExtension;
|
||||
import com.tencent.qcloud.tuicore.interfaces.ITUINotification;
|
||||
import com.tencent.qcloud.tuicore.interfaces.TUIExtensionInfo;
|
||||
import com.tencent.qcloud.tuikit.timcommon.component.LineControllerView;
|
||||
import com.tencent.qcloud.tuikit.timcommon.interfaces.ChatInputMoreListener;
|
||||
import com.trtc.tuikit.common.system.ContextProvider;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class ConferenceServiceInitializer extends ServiceInitializer implements ITUIExtension {
|
||||
private static final String TAG = "RoomServiceInitializer";
|
||||
|
||||
private static final String CONFERENCE_INVITATION = "conference_invitation";
|
||||
|
||||
private String mGetInvitationListCursor = "";
|
||||
|
||||
private static final int SINGLE_FETCH_COUNT = 20;
|
||||
|
||||
private final TUIRoomDefine.RoomInfo mInvitationRoomInfo = new TUIRoomDefine.RoomInfo();
|
||||
|
||||
@Override
|
||||
public void init(Context context) {
|
||||
ContextProvider.setApplicationContext(context);
|
||||
initExtension();
|
||||
initRoomMessage();
|
||||
initSignalingListener();
|
||||
registerInvitationNotifyEvent();
|
||||
registerLoginEvent();
|
||||
}
|
||||
|
||||
private void initExtension() {
|
||||
TUICore.registerExtension(TUIConstants.TUIChat.Extension.InputMore.CLASSIC_EXTENSION_ID, this);
|
||||
TUICore.registerExtension(TUIConstants.TIMAppKit.Extension.ProfileSettings.CLASSIC_EXTENSION_ID, this);
|
||||
}
|
||||
|
||||
private void initRoomMessage() {
|
||||
Map<String, Object> roomMsgParam = new HashMap<>();
|
||||
roomMsgParam.put(TUIConstants.TUIChat.Method.RegisterCustomMessage.MESSAGE_BUSINESS_ID,
|
||||
BUSINESS_ID_ROOM_MESSAGE);
|
||||
roomMsgParam.put(TUIConstants.TUIChat.Method.RegisterCustomMessage.MESSAGE_BEAN_CLASS, RoomMessageBean.class);
|
||||
roomMsgParam.put(TUIConstants.TUIChat.Method.RegisterCustomMessage.MESSAGE_VIEW_HOLDER_CLASS,
|
||||
RoomMessageHolder.class);
|
||||
TUICore.callService(TUIConstants.TUIChat.Method.RegisterCustomMessage.CLASSIC_SERVICE_NAME,
|
||||
TUIConstants.TUIChat.Method.RegisterCustomMessage.METHOD_NAME, roomMsgParam);
|
||||
|
||||
}
|
||||
|
||||
private void initSignalingListener() {
|
||||
V2TIMManager.getSignalingManager().addSignalingListener(new V2TIMSignalingListener() {
|
||||
@Override
|
||||
public void onReceiveNewInvitation(String inviteID, String inviter, String groupID,
|
||||
List<String> inviteeList, String data) {
|
||||
if (!isRoomInviteSingling(data)) {
|
||||
return;
|
||||
}
|
||||
if (!isInvited(inviteeList)) {
|
||||
return;
|
||||
}
|
||||
Log.d(TAG, "onReceiveNewInvitation inviteID=" + inviteID + " inviter=" + inviter + " groupID=" + groupID
|
||||
+ " data=" + data);
|
||||
if (!BusinessSceneUtil.canJoinRoom()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Context context = TUIConfig.getAppContext();
|
||||
if (context == null) {
|
||||
return;
|
||||
}
|
||||
Intent intent = new Intent(context, InvitedToJoinRoomActivity.class);
|
||||
intent.putExtra(KEY_INVITE_DATA, data);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
context.startActivity(intent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInviteeAccepted(String inviteID, String invitee, String data) {
|
||||
Log.d(TAG, "onInviteeAccepted inviteID=" + inviteID + " invitee=" + invitee + " data=" + data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInviteeRejected(String inviteID, String invitee, String data) {
|
||||
Log.d(TAG, "onInviteeRejected inviteID=" + inviteID + " invitee=" + invitee + " data=" + data);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private boolean isRoomInviteSingling(String data) {
|
||||
return !TextUtils.isEmpty(data) && data.contains(ROOM_INVITE_SINGLING);
|
||||
}
|
||||
|
||||
private boolean isInvited(List<String> inviteeList) {
|
||||
String myId = TUILogin.getUserId();
|
||||
for (String item : inviteeList) {
|
||||
if (myId.equals(item)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void observerOnlineConferenceInvitation() {
|
||||
TUIConferenceInvitationManager invitationManager = (TUIConferenceInvitationManager) TUIRoomEngine.sharedInstance().getExtension(TUICommonDefine.ExtensionType.CONFERENCE_INVITATION_MANAGER);
|
||||
invitationManager.addObserver(new TUIConferenceInvitationManager.Observer() {
|
||||
@Override
|
||||
public void onReceiveInvitation(TUIRoomDefine.RoomInfo roomInfo, TUIConferenceInvitationManager.Invitation invitation, String extensionInfo) {
|
||||
if (ConferenceController.sharedInstance().getViewState().isInvitationPending.get()) {
|
||||
ConferenceController.sharedInstance().getInvitationController().reject(roomInfo.roomId, REJECT_TO_ENTER, null);
|
||||
return;
|
||||
}
|
||||
if (ConferenceController.sharedInstance().getRoomController().isInRoom()) {
|
||||
ConferenceController.sharedInstance().getInvitationController().reject(roomInfo.roomId, IN_OTHER_CONFERENCE, null);
|
||||
return;
|
||||
}
|
||||
|
||||
startInvitationReceivedActivity(roomInfo.roomId, roomInfo.name, roomInfo.ownerName, invitation.inviter.userName,
|
||||
invitation.inviter.avatarUrl, roomInfo.memberCount);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void startInvitationReceivedActivity(String roomId, String conferenceName, String ownerName, String inviterName, String inviterAvatarUrl, int memberCount) {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("roomId", roomId);
|
||||
bundle.putString("conferenceName", conferenceName);
|
||||
bundle.putString("ownerName", ownerName);
|
||||
bundle.putString("inviterName", inviterName);
|
||||
bundle.putString("inviterAvatarUrl", inviterAvatarUrl);
|
||||
bundle.putInt("memberCount", memberCount);
|
||||
TUICore.startActivity("InvitationReceivedActivity", bundle);
|
||||
}
|
||||
|
||||
private void registerInvitationNotifyEvent() {
|
||||
TUICore.registerEvent(TUIConstants.TIMPush.EVENT_NOTIFY, TUIConstants.TIMPush.EVENT_NOTIFY_NOTIFICATION, new ITUINotification() {
|
||||
@Override
|
||||
public void onNotifyEvent(String key, String subKey, Map<String, Object> param) {
|
||||
if (!(TUIConstants.TIMPush.EVENT_NOTIFY.equals(key) && TUIConstants.TIMPush.EVENT_NOTIFY_NOTIFICATION.equals(subKey))) {
|
||||
return;
|
||||
}
|
||||
if (param == null) {
|
||||
return;
|
||||
}
|
||||
if (!TextUtils.isEmpty(mInvitationRoomInfo.roomId)) {
|
||||
return;
|
||||
}
|
||||
String extString = (String) param.get(TUIConstants.TIMPush.NOTIFICATION_EXT_KEY);
|
||||
try {
|
||||
JSONObject roomObject = new JSONObject(extString);
|
||||
String notificationType = roomObject.getString("NotificationType");
|
||||
if (!CONFERENCE_INVITATION.equals(notificationType)) {
|
||||
return;
|
||||
}
|
||||
String roomId = roomObject.getString("RoomId");
|
||||
if (TextUtils.isEmpty(roomId)) {
|
||||
return;
|
||||
}
|
||||
mInvitationRoomInfo.roomId = roomId;
|
||||
mInvitationRoomInfo.name = roomObject.getString("RoomName");
|
||||
mInvitationRoomInfo.ownerName = roomObject.getString("OwnerName");
|
||||
mInvitationRoomInfo.memberCount = roomObject.getInt("MemberCount");
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "get param from event error key = " + key + "subKey = " + subKey + "error =" + e.getMessage());
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void registerLoginEvent() {
|
||||
TUICore.registerEvent(TUIConstants.TUILogin.EVENT_LOGIN_STATE_CHANGED, TUIConstants.TUILogin.EVENT_SUB_KEY_USER_LOGIN_SUCCESS, new ITUINotification() {
|
||||
@Override
|
||||
public void onNotifyEvent(String key, String subKey, Map<String, Object> param) {
|
||||
Log.i(TAG, "onNotifyEvent key = " + key + "subKey = " + subKey);
|
||||
if (!TUIConstants.TUILogin.EVENT_LOGIN_STATE_CHANGED.equals(key) || !TUIConstants.TUILogin.EVENT_SUB_KEY_USER_LOGIN_SUCCESS.equals(subKey)) {
|
||||
return;
|
||||
}
|
||||
observerOnlineConferenceInvitation();
|
||||
getOfflineConferenceInvitation();
|
||||
}
|
||||
});
|
||||
if (TUILogin.isUserLogined()) {
|
||||
observerOnlineConferenceInvitation();
|
||||
getOfflineConferenceInvitation();
|
||||
}
|
||||
}
|
||||
|
||||
private void getOfflineConferenceInvitation() {
|
||||
TUIRoomEngine.login(TUILogin.getAppContext(), TUILogin.getSdkAppId(), TUILogin.getUserId(), TUILogin.getUserSig(), new TUIRoomDefine.ActionCallback() {
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
Log.i(TAG, "TUIRoomEngine.login success");
|
||||
getInvitationList(mInvitationRoomInfo.roomId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(TUICommonDefine.Error error, String s) {
|
||||
Log.e(TAG, "TUIRoomEngine.login error =" + error + " message =" + s);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void getInvitationList(String roomId) {
|
||||
if (TextUtils.isEmpty(roomId)) {
|
||||
return;
|
||||
}
|
||||
Log.d(TAG, "getInvitationList");
|
||||
TUIConferenceInvitationManager invitationManager = (TUIConferenceInvitationManager) TUIRoomEngine.sharedInstance().getExtension(TUICommonDefine.ExtensionType.CONFERENCE_INVITATION_MANAGER);
|
||||
invitationManager.getInvitationList(roomId, mGetInvitationListCursor, SINGLE_FETCH_COUNT, new TUIConferenceInvitationManager.GetInvitationListCallback() {
|
||||
@Override
|
||||
public void onSuccess(TUIConferenceInvitationManager.InvitationListResult invitationListResult) {
|
||||
Log.d(TAG, "getInvitationList");
|
||||
for (TUIConferenceInvitationManager.Invitation invitation : invitationListResult.invitationList) {
|
||||
if (!invitation.invitee.userId.equals(TUILogin.getUserId())) {
|
||||
continue;
|
||||
}
|
||||
if (TUIConferenceInvitationManager.InvitationStatus.PENDING.equals(invitation.status)) {
|
||||
startInvitationReceivedActivity(mInvitationRoomInfo.roomId, mInvitationRoomInfo.name, mInvitationRoomInfo.ownerName,
|
||||
invitation.inviter.userName, invitation.inviter.avatarUrl, mInvitationRoomInfo.memberCount);
|
||||
mInvitationRoomInfo.roomId = "";
|
||||
return;
|
||||
}
|
||||
}
|
||||
mGetInvitationListCursor = invitationListResult.cursor;
|
||||
if (!"".equals(mGetInvitationListCursor)) {
|
||||
getInvitationList(roomId);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(TUICommonDefine.Error error, String message) {
|
||||
Log.d(TAG, "getInvitationList onError error=" + error + " message=" + message);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TUIExtensionInfo> onGetExtension(String extensionID, Map<String, Object> param) {
|
||||
if (TextUtils.equals(extensionID, TUIConstants.TUIChat.Extension.InputMore.CLASSIC_EXTENSION_ID)
|
||||
&& !TextUtils.isEmpty((String) param.get(TUIConstants.TUIChat.Extension.InputMore.GROUP_ID))) {
|
||||
if (TextUtils.isEmpty(extensionID) || param == null) {
|
||||
Log.e(TAG, "onGetExtension TUIConstants.TUIChat.Extension.InputMore.GROUP_ID params is illegal");
|
||||
return null;
|
||||
}
|
||||
Object obj = param.get(TUIConstants.TUIChat.Extension.InputMore.FILTER_ROOM);
|
||||
if (obj != null && obj instanceof Boolean && ((boolean) obj)) {
|
||||
return null;
|
||||
}
|
||||
ChatInputMoreListener chatInputMoreListener =
|
||||
(ChatInputMoreListener) param.get(TUIConstants.TUIChat.Extension.InputMore.INPUT_MORE_LISTENER);
|
||||
RoomMsgManager.setChatInputMoreListenerRef(new WeakReference<>(chatInputMoreListener));
|
||||
|
||||
TUIExtensionInfo roomExtension = new TUIExtensionInfo();
|
||||
roomExtension.setWeight(200);
|
||||
roomExtension.setText(getAppContext().getString(R.string.tuiroomkit_chat_access_room));
|
||||
roomExtension.setIcon(R.drawable.tuiroomkit_chat_access_room_icon);
|
||||
roomExtension.setExtensionListener(new RoomClickListener());
|
||||
return Collections.singletonList(roomExtension);
|
||||
}
|
||||
if (TextUtils.equals(extensionID, TUIConstants.TIMAppKit.Extension.ProfileSettings.CLASSIC_EXTENSION_ID)) {
|
||||
View settingView = LayoutInflater.from(getAppContext())
|
||||
.inflate(R.layout.tuiroomkit_room_setting_extention_layout, null);
|
||||
settingView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
TUICore.startActivity("Chat2RoomExtensionSettingsActivity", new Bundle());
|
||||
}
|
||||
});
|
||||
|
||||
LineControllerView groupView = settingView.findViewById(R.id.tuiroomkit_extension_setting);
|
||||
groupView.setCanNav(true);
|
||||
HashMap<String, Object> paramMap = new HashMap<>();
|
||||
paramMap.put(TUIConstants.TIMAppKit.Extension.ProfileSettings.KEY_VIEW, settingView);
|
||||
TUIExtensionInfo extensionInfo = new TUIExtensionInfo();
|
||||
extensionInfo.setData(paramMap);
|
||||
extensionInfo.setWeight(501);
|
||||
return Collections.singletonList(extensionInfo);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
+551
@@ -0,0 +1,551 @@
|
||||
package com.tencent.cloud.tuikit.roomkit.state;
|
||||
|
||||
import static com.tencent.cloud.tuikit.engine.room.TUIRoomDefine.VideoStreamType.SCREEN_STREAM;
|
||||
import static com.tencent.cloud.tuikit.roomkit.manager.constant.ConferenceConstant.USER_NOT_FOUND;
|
||||
import static com.tencent.cloud.tuikit.roomkit.manager.eventcenter.ConferenceEventCenter.RoomEngineEvent.USER_CAMERA_STATE_CHANGED;
|
||||
import static com.tencent.cloud.tuikit.roomkit.manager.eventcenter.ConferenceEventCenter.RoomEngineEvent.USER_SCREEN_STATE_CHANGED;
|
||||
import static com.tencent.cloud.tuikit.roomkit.manager.eventcenter.ConferenceEventCenter.RoomEngineEvent.USER_SEND_MESSAGE_ABILITY_CHANGED;
|
||||
import static com.tencent.cloud.tuikit.roomkit.manager.eventcenter.ConferenceEventCenter.RoomKitUIEvent.ENTER_FLOAT_WINDOW;
|
||||
import static com.tencent.cloud.tuikit.roomkit.manager.eventcenter.ConferenceEventCenter.RoomKitUIEvent.EXIT_FLOAT_WINDOW;
|
||||
import static com.tencent.cloud.tuikit.roomkit.manager.eventcenter.ConferenceEventConstant.KEY_REASON;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import com.tencent.cloud.tuikit.engine.room.TUIRoomDefine;
|
||||
import com.tencent.cloud.tuikit.roomkit.manager.eventcenter.ConferenceEventCenter;
|
||||
import com.tencent.cloud.tuikit.roomkit.manager.eventcenter.ConferenceEventConstant;
|
||||
import com.tencent.cloud.tuikit.roomkit.state.entity.AudioModel;
|
||||
import com.tencent.cloud.tuikit.roomkit.state.entity.TakeSeatRequestEntity;
|
||||
import com.tencent.cloud.tuikit.roomkit.state.entity.UserEntity;
|
||||
import com.tencent.cloud.tuikit.roomkit.state.entity.UserModel;
|
||||
import com.tencent.cloud.tuikit.roomkit.state.entity.VideoModel;
|
||||
import com.tencent.qcloud.tuicore.TUILogin;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
public class ConferenceState {
|
||||
private static final String TAG = "ConferenceState";
|
||||
|
||||
public ViewState viewState = new ViewState();
|
||||
public SeatState seatState = new SeatState();
|
||||
public RoomState roomState = new RoomState();
|
||||
public UserState userState = new UserState();
|
||||
public MediaState mediaState = new MediaState();
|
||||
public InvitationState invitationState = new InvitationState();
|
||||
public ASRState asrState = new ASRState();
|
||||
|
||||
public TUIRoomDefine.RoomInfo roomInfo;
|
||||
public UserModel userModel;
|
||||
public AudioModel audioModel;
|
||||
public VideoModel videoModel;
|
||||
|
||||
public List<UserEntity> allUserList;
|
||||
public List<UserEntity> seatUserList;
|
||||
|
||||
public List<TakeSeatRequestEntity> takeSeatRequestList;
|
||||
|
||||
private Class mainActivityClass;
|
||||
|
||||
private boolean isInFloatWindow = false;
|
||||
private boolean isAutoShowRoomMainUi = true;
|
||||
private boolean enableFloatChat = true;
|
||||
|
||||
public ConferenceState() {
|
||||
Log.d(TAG, "new RoomStore instance : " + this);
|
||||
roomInfo = new TUIRoomDefine.RoomInfo();
|
||||
userModel = new UserModel();
|
||||
audioModel = new AudioModel();
|
||||
videoModel = new VideoModel();
|
||||
allUserList = new CopyOnWriteArrayList<>();
|
||||
seatUserList = new CopyOnWriteArrayList<>();
|
||||
takeSeatRequestList = new CopyOnWriteArrayList<>();
|
||||
}
|
||||
|
||||
public Class getMainActivityClass() {
|
||||
Log.d(TAG, "getMainActivityClass : " + mainActivityClass);
|
||||
return mainActivityClass;
|
||||
}
|
||||
|
||||
public void setMainActivityClass(Class mainActivityClass) {
|
||||
Log.d(TAG, "setMainActivityClass : " + mainActivityClass);
|
||||
this.mainActivityClass = mainActivityClass;
|
||||
}
|
||||
|
||||
public void handleUserRoleChanged(String userId, TUIRoomDefine.Role role) {
|
||||
if (role == TUIRoomDefine.Role.ROOM_OWNER) {
|
||||
roomInfo.ownerId = userId;
|
||||
}
|
||||
|
||||
int seatPosition = USER_NOT_FOUND;
|
||||
for (int i = 0; i < seatUserList.size(); i++) {
|
||||
if (TextUtils.equals(userId, seatUserList.get(i).getUserId())
|
||||
&& seatUserList.get(i).getVideoStreamType() != SCREEN_STREAM) {
|
||||
seatUserList.get(i).setRole(role);
|
||||
seatPosition = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
int userPosition = USER_NOT_FOUND;
|
||||
for (int i = 0; i < allUserList.size(); i++) {
|
||||
if (TextUtils.equals(userId, allUserList.get(i).getUserId())
|
||||
&& allUserList.get(i).getVideoStreamType() != SCREEN_STREAM) {
|
||||
allUserList.get(i).setRole(role);
|
||||
userPosition = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put(ConferenceEventConstant.KEY_SEAT_USER_POSITION, seatPosition);
|
||||
map.put(ConferenceEventConstant.KEY_USER_POSITION, userPosition);
|
||||
ConferenceEventCenter.getInstance().notifyEngineEvent(ConferenceEventCenter.RoomEngineEvent.USER_ROLE_CHANGED, map);
|
||||
}
|
||||
|
||||
public void addTakeSeatRequest(TUIRoomDefine.Request request) {
|
||||
String name = TextUtils.isEmpty(request.nameCard) ? request.userName : request.nameCard;
|
||||
TakeSeatRequestEntity takeSeatRequestEntity =
|
||||
new TakeSeatRequestEntity(request.userId, name, request.avatarUrl, request);
|
||||
takeSeatRequestList.add(takeSeatRequestEntity);
|
||||
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put(ConferenceEventConstant.KEY_USER_POSITION, takeSeatRequestList.size() - 1);
|
||||
ConferenceEventCenter.getInstance()
|
||||
.notifyEngineEvent(ConferenceEventCenter.RoomEngineEvent.USER_TAKE_SEAT_REQUEST_ADD, map);
|
||||
}
|
||||
|
||||
public void removeTakeSeatRequestByUserId(String userId) {
|
||||
int index = -1;
|
||||
for (int i = 0; i < takeSeatRequestList.size(); i++) {
|
||||
if (TextUtils.equals(userId, takeSeatRequestList.get(i).getUserId())) {
|
||||
index = i;
|
||||
takeSeatRequestList.remove(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (index == -1) {
|
||||
return;
|
||||
}
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put(ConferenceEventConstant.KEY_USER_POSITION, index);
|
||||
ConferenceEventCenter.getInstance()
|
||||
.notifyEngineEvent(ConferenceEventCenter.RoomEngineEvent.USER_TAKE_SEAT_REQUEST_REMOVE, map);
|
||||
}
|
||||
|
||||
public void removeTakeSeatRequest(String requestId) {
|
||||
int index = -1;
|
||||
for (int i = 0; i < takeSeatRequestList.size(); i++) {
|
||||
if (TextUtils.equals(requestId, takeSeatRequestList.get(i).getRequest().requestId)) {
|
||||
index = i;
|
||||
takeSeatRequestList.remove(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (index == -1) {
|
||||
return;
|
||||
}
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put(ConferenceEventConstant.KEY_USER_POSITION, index);
|
||||
ConferenceEventCenter.getInstance()
|
||||
.notifyEngineEvent(ConferenceEventCenter.RoomEngineEvent.USER_TAKE_SEAT_REQUEST_REMOVE, map);
|
||||
}
|
||||
|
||||
public TakeSeatRequestEntity getTakeSeatRequestEntity(String userId) {
|
||||
for (TakeSeatRequestEntity item : takeSeatRequestList) {
|
||||
if (TextUtils.equals(item.getUserId(), userId)) {
|
||||
return item;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean hasScreenSharingInRoom() {
|
||||
if (allUserList.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
UserEntity firstUser = allUserList.get(0);
|
||||
return firstUser.isHasVideoStream() && firstUser.getVideoStreamType() == SCREEN_STREAM;
|
||||
}
|
||||
|
||||
public boolean isInFloatWindow() {
|
||||
return isInFloatWindow;
|
||||
}
|
||||
|
||||
public void setInFloatWindow(boolean inFloatWindow) {
|
||||
isInFloatWindow = inFloatWindow;
|
||||
String key = isInFloatWindow ? ENTER_FLOAT_WINDOW : EXIT_FLOAT_WINDOW;
|
||||
ConferenceEventCenter.getInstance().notifyUIEvent(key, null);
|
||||
}
|
||||
|
||||
public boolean isAutoShowRoomMainUi() {
|
||||
return isAutoShowRoomMainUi;
|
||||
}
|
||||
|
||||
public void setAutoShowRoomMainUi(boolean autoShowRoomMainUi) {
|
||||
isAutoShowRoomMainUi = autoShowRoomMainUi;
|
||||
}
|
||||
|
||||
public int getTotalUserCount() {
|
||||
if (allUserList.isEmpty()) {
|
||||
return 0;
|
||||
}
|
||||
if (allUserList.get(0).getVideoStreamType() == SCREEN_STREAM) {
|
||||
return allUserList.size() - 1;
|
||||
}
|
||||
return allUserList.size();
|
||||
}
|
||||
|
||||
public void remoteUserEnterRoom(TUIRoomDefine.UserInfo userInfo) {
|
||||
if (findUser(allUserList, userInfo.userId) != null) {
|
||||
return;
|
||||
}
|
||||
if (TextUtils.equals(userInfo.userId, userModel.userId)) {
|
||||
userModel.initRole(userInfo.userRole);
|
||||
}
|
||||
if (userInfo.hasScreenStream) {
|
||||
allUserList.add(0, UserEntity.toUserEntityForScreenStream(userInfo));
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put(ConferenceEventConstant.KEY_USER_POSITION, 0);
|
||||
ConferenceEventCenter.getInstance()
|
||||
.notifyEngineEvent(ConferenceEventCenter.RoomEngineEvent.REMOTE_USER_ENTER_ROOM, map);
|
||||
}
|
||||
allUserList.add(UserEntity.toUserEntityForCameraStream(userInfo));
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put(ConferenceEventConstant.KEY_USER_POSITION, allUserList.size() - 1);
|
||||
ConferenceEventCenter.getInstance().notifyEngineEvent(ConferenceEventCenter.RoomEngineEvent.REMOTE_USER_ENTER_ROOM, map);
|
||||
}
|
||||
|
||||
public void remoteUserLeaveRoom(String userId) {
|
||||
for (int i = 0; i < allUserList.size(); i++) {
|
||||
if (TextUtils.equals(userId, allUserList.get(i).getUserId())) {
|
||||
allUserList.remove(i);
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put(ConferenceEventConstant.KEY_USER_POSITION, i);
|
||||
ConferenceEventCenter.getInstance()
|
||||
.notifyEngineEvent(ConferenceEventCenter.RoomEngineEvent.REMOTE_USER_LEAVE_ROOM, map);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void remoteUserTakeSeat(TUIRoomDefine.UserInfo userInfo) {
|
||||
Log.d(TAG, "remoteUserTakeSeat userId=" + userInfo.userId);
|
||||
if (TextUtils.equals(userInfo.userId, TUILogin.getUserId())) {
|
||||
userModel.setSeatStatus(UserModel.SeatStatus.ON_SEAT);
|
||||
}
|
||||
if (findUser(allUserList, userInfo.userId) == null) {
|
||||
return;
|
||||
}
|
||||
if (userInfo.hasScreenStream) {
|
||||
remoteScreenUserTakeSeat(userInfo);
|
||||
}
|
||||
remoteCameraUserTakeSeat(userInfo);
|
||||
}
|
||||
|
||||
private void remoteScreenUserTakeSeat(TUIRoomDefine.UserInfo userInfo) {
|
||||
for (UserEntity item : seatUserList) {
|
||||
if (TextUtils.equals(item.getUserId(), userInfo.userId) && item.getVideoStreamType() == SCREEN_STREAM) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
seatUserList.add(0, UserEntity.toUserEntityForScreenStream(userInfo));
|
||||
int userPosition = USER_NOT_FOUND;
|
||||
for (int i = 0; i < allUserList.size(); i++) {
|
||||
if (TextUtils.equals(allUserList.get(i).getUserId(), userInfo.userId)
|
||||
&& allUserList.get(i).getVideoStreamType() == SCREEN_STREAM) {
|
||||
allUserList.get(i).setOnSeat(true);
|
||||
userPosition = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put(ConferenceEventConstant.KEY_SEAT_USER_POSITION, 0);
|
||||
map.put(ConferenceEventConstant.KEY_USER_POSITION, userPosition);
|
||||
ConferenceEventCenter.getInstance().notifyEngineEvent(ConferenceEventCenter.RoomEngineEvent.REMOTE_USER_TAKE_SEAT, map);
|
||||
}
|
||||
|
||||
private void remoteCameraUserTakeSeat(TUIRoomDefine.UserInfo userInfo) {
|
||||
for (UserEntity item : seatUserList) {
|
||||
if (TextUtils.equals(item.getUserId(), userInfo.userId) && item.getVideoStreamType() != SCREEN_STREAM) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
seatUserList.add(UserEntity.toUserEntityForCameraStream(userInfo));
|
||||
int userPosition = USER_NOT_FOUND;
|
||||
for (int i = 0; i < allUserList.size(); i++) {
|
||||
if (TextUtils.equals(allUserList.get(i).getUserId(), userInfo.userId)
|
||||
&& allUserList.get(i).getVideoStreamType() != SCREEN_STREAM) {
|
||||
allUserList.get(i).setOnSeat(true);
|
||||
userPosition = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put(ConferenceEventConstant.KEY_SEAT_USER_POSITION, seatUserList.size() - 1);
|
||||
map.put(ConferenceEventConstant.KEY_USER_POSITION, userPosition);
|
||||
ConferenceEventCenter.getInstance().notifyEngineEvent(ConferenceEventCenter.RoomEngineEvent.REMOTE_USER_TAKE_SEAT, map);
|
||||
}
|
||||
|
||||
public void remoteUserLeaveSeat(String userId) {
|
||||
Log.d(TAG, "remoteUserLeaveSeat userId=" + userId);
|
||||
if (TextUtils.equals(userId, TUILogin.getUserId())) {
|
||||
userModel.setSeatStatus(UserModel.SeatStatus.OFF_SEAT);
|
||||
}
|
||||
remoteScreenUserLeaveSeat(userId);
|
||||
remoteCameraUserLeaveSeat(userId);
|
||||
}
|
||||
|
||||
private void remoteScreenUserLeaveSeat(String userId) {
|
||||
int seatPosition = USER_NOT_FOUND;
|
||||
for (int i = 0; i < seatUserList.size(); i++) {
|
||||
if (seatUserList.get(i).getVideoStreamType() == SCREEN_STREAM && TextUtils.equals(userId, seatUserList.get(i).getUserId())) {
|
||||
seatPosition = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (seatPosition == USER_NOT_FOUND) {
|
||||
return;
|
||||
}
|
||||
int userPosition = USER_NOT_FOUND;
|
||||
for (int i = 0; i < allUserList.size(); i++) {
|
||||
if (allUserList.get(i).getVideoStreamType() == SCREEN_STREAM && TextUtils.equals(userId, allUserList.get(i).getUserId())) {
|
||||
userPosition = i;
|
||||
allUserList.get(i).setOnSeat(false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put(ConferenceEventConstant.KEY_SEAT_USER_POSITION, seatPosition);
|
||||
map.put(ConferenceEventConstant.KEY_USER_POSITION, userPosition);
|
||||
ConferenceEventCenter.getInstance()
|
||||
.notifyEngineEvent(ConferenceEventCenter.RoomEngineEvent.REMOTE_USER_LEAVE_SEAT, map);
|
||||
seatUserList.remove(seatPosition);
|
||||
}
|
||||
|
||||
private void remoteCameraUserLeaveSeat(String userId) {
|
||||
int seatPosition = USER_NOT_FOUND;
|
||||
for (int i = 0; i < seatUserList.size(); i++) {
|
||||
if (seatUserList.get(i).getVideoStreamType() != SCREEN_STREAM && TextUtils.equals(userId, seatUserList.get(i).getUserId())) {
|
||||
seatPosition = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (seatPosition == USER_NOT_FOUND) {
|
||||
return;
|
||||
}
|
||||
int userPosition = USER_NOT_FOUND;
|
||||
for (int i = 0; i < allUserList.size(); i++) {
|
||||
if (allUserList.get(i).getVideoStreamType() != SCREEN_STREAM && TextUtils.equals(userId, allUserList.get(i).getUserId())) {
|
||||
userPosition = i;
|
||||
allUserList.get(i).setOnSeat(false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put(ConferenceEventConstant.KEY_SEAT_USER_POSITION, seatPosition);
|
||||
map.put(ConferenceEventConstant.KEY_USER_POSITION, userPosition);
|
||||
ConferenceEventCenter.getInstance()
|
||||
.notifyEngineEvent(ConferenceEventCenter.RoomEngineEvent.REMOTE_USER_LEAVE_SEAT, map);
|
||||
seatUserList.remove(seatPosition);
|
||||
}
|
||||
|
||||
public void enableUserSendingMsg(String userId, boolean enable) {
|
||||
int seatPosition = USER_NOT_FOUND;
|
||||
for (int i = 0; i < seatUserList.size(); i++) {
|
||||
if (TextUtils.equals(userId, seatUserList.get(i).getUserId())
|
||||
&& seatUserList.get(i).getVideoStreamType() != SCREEN_STREAM) {
|
||||
seatUserList.get(i).setEnableSendingMessage(enable);
|
||||
seatPosition = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
int userPosition = USER_NOT_FOUND;
|
||||
for (int i = 0; i < allUserList.size(); i++) {
|
||||
if (TextUtils.equals(userId, allUserList.get(i).getUserId())
|
||||
&& allUserList.get(i).getVideoStreamType() != SCREEN_STREAM) {
|
||||
allUserList.get(i).setEnableSendingMessage(enable);
|
||||
userPosition = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put(ConferenceEventConstant.KEY_SEAT_USER_POSITION, seatPosition);
|
||||
map.put(ConferenceEventConstant.KEY_USER_POSITION, userPosition);
|
||||
ConferenceEventCenter.getInstance().notifyEngineEvent(USER_SEND_MESSAGE_ABILITY_CHANGED, map);
|
||||
}
|
||||
|
||||
public void updateUserAudioVolume(String userId, int volume) {
|
||||
for (UserEntity item : allUserList) {
|
||||
if (TextUtils.equals(userId, item.getUserId())) {
|
||||
item.setUserVoiceVolume(volume);
|
||||
}
|
||||
}
|
||||
for (UserEntity item : seatUserList) {
|
||||
if (TextUtils.equals(userId, item.getUserId())) {
|
||||
item.setUserVoiceVolume(volume);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void updateUserAudioState(String userId, boolean hasAudio, TUIRoomDefine.ChangeReason reason) {
|
||||
int seatPosition = USER_NOT_FOUND;
|
||||
for (int i = 0; i < seatUserList.size(); i++) {
|
||||
if (TextUtils.equals(userId, seatUserList.get(i).getUserId())
|
||||
&& seatUserList.get(i).getVideoStreamType() != SCREEN_STREAM) {
|
||||
seatUserList.get(i).setHasAudioStream(hasAudio);
|
||||
seatPosition = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
int userPosition = USER_NOT_FOUND;
|
||||
for (int i = 0; i < allUserList.size(); i++) {
|
||||
if (TextUtils.equals(userId, allUserList.get(i).getUserId())
|
||||
&& allUserList.get(i).getVideoStreamType() != SCREEN_STREAM) {
|
||||
allUserList.get(i).setHasAudioStream(hasAudio);
|
||||
userPosition = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (TextUtils.equals(TUILogin.getUserId(), userId)) {
|
||||
audioModel.setHasAudioStream(hasAudio);
|
||||
}
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put(ConferenceEventConstant.KEY_SEAT_USER_POSITION, seatPosition);
|
||||
map.put(ConferenceEventConstant.KEY_USER_POSITION, userPosition);
|
||||
map.put(KEY_REASON, reason);
|
||||
ConferenceEventCenter.getInstance().notifyEngineEvent(ConferenceEventCenter.RoomEngineEvent.USER_MIC_STATE_CHANGED, map);
|
||||
}
|
||||
|
||||
public void updateUserCameraState(String userId, TUIRoomDefine.VideoStreamType streamType, boolean hasCamera,
|
||||
TUIRoomDefine.ChangeReason reason) {
|
||||
int seatPosition = USER_NOT_FOUND;
|
||||
for (int i = 0; i < seatUserList.size(); i++) {
|
||||
if (TextUtils.equals(userId, seatUserList.get(i).getUserId())
|
||||
&& seatUserList.get(i).getVideoStreamType() != SCREEN_STREAM) {
|
||||
seatUserList.get(i).setHasVideoStream(hasCamera);
|
||||
seatUserList.get(i).setVideoStreamType(streamType);
|
||||
seatPosition = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
int userPosition = USER_NOT_FOUND;
|
||||
for (int i = 0; i < allUserList.size(); i++) {
|
||||
if (TextUtils.equals(userId, allUserList.get(i).getUserId())
|
||||
&& allUserList.get(i).getVideoStreamType() != SCREEN_STREAM) {
|
||||
allUserList.get(i).setHasVideoStream(hasCamera);
|
||||
allUserList.get(i).setVideoStreamType(streamType);
|
||||
userPosition = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (TextUtils.equals(TUILogin.getUserId(), userId)) {
|
||||
videoModel.setCameraOpened(hasCamera);
|
||||
}
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put(ConferenceEventConstant.KEY_SEAT_USER_POSITION, seatPosition);
|
||||
map.put(ConferenceEventConstant.KEY_USER_POSITION, userPosition);
|
||||
map.put(KEY_REASON, reason);
|
||||
ConferenceEventCenter.getInstance().notifyEngineEvent(USER_CAMERA_STATE_CHANGED, map);
|
||||
}
|
||||
|
||||
public void handleUserScreenStateChanged(String userId, boolean hasScreen) {
|
||||
Log.d(TAG, "handleUserScreenStateChanged userId=" + userId + " hasScreen=" + hasScreen);
|
||||
if (TextUtils.equals(TUILogin.getUserId(), userId)) {
|
||||
videoModel.setScreenSharing(hasScreen);
|
||||
}
|
||||
if (hasScreen) {
|
||||
UserEntity user = findUser(allUserList, userId);
|
||||
if (user == null || allUserList.get(0).getVideoStreamType() == SCREEN_STREAM) {
|
||||
return;
|
||||
}
|
||||
UserEntity screenUser = user.copy();
|
||||
screenUser.setHasVideoStream(true);
|
||||
screenUser.setVideoStreamType(SCREEN_STREAM);
|
||||
allUserList.add(0, screenUser);
|
||||
int seatPosition = USER_NOT_FOUND;
|
||||
UserEntity seatUser = findUser(seatUserList, userId);
|
||||
if (seatUser != null) {
|
||||
seatUserList.add(0, screenUser);
|
||||
seatPosition = 0;
|
||||
}
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put(ConferenceEventConstant.KEY_SEAT_USER_POSITION, seatPosition);
|
||||
map.put(ConferenceEventConstant.KEY_USER_POSITION, 0);
|
||||
ConferenceEventCenter.getInstance().notifyEngineEvent(USER_SCREEN_STATE_CHANGED, map);
|
||||
ConferenceEventCenter.getInstance()
|
||||
.notifyEngineEvent(ConferenceEventCenter.RoomEngineEvent.REMOTE_USER_ENTER_ROOM, map);
|
||||
} else {
|
||||
if (allUserList.isEmpty() || !TextUtils.equals(allUserList.get(0).getUserId(), userId)) {
|
||||
return;
|
||||
}
|
||||
allUserList.get(0).setHasVideoStream(false);
|
||||
if (!seatUserList.isEmpty()) {
|
||||
seatUserList.get(0).setHasVideoStream(false);
|
||||
}
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put(ConferenceEventConstant.KEY_SEAT_USER_POSITION, seatUserList.isEmpty() ? USER_NOT_FOUND : 0);
|
||||
map.put(ConferenceEventConstant.KEY_USER_POSITION, 0);
|
||||
ConferenceEventCenter.getInstance().notifyEngineEvent(USER_SCREEN_STATE_CHANGED, map);
|
||||
ConferenceEventCenter.getInstance()
|
||||
.notifyEngineEvent(ConferenceEventCenter.RoomEngineEvent.REMOTE_USER_LEAVE_ROOM, map);
|
||||
allUserList.remove(0);
|
||||
if (!seatUserList.isEmpty()) {
|
||||
seatUserList.remove(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private UserEntity findUser(List<UserEntity> list, String userId) {
|
||||
for (UserEntity item : list) {
|
||||
if (TextUtils.equals(userId, item.getUserId())) {
|
||||
return item;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public UserEntity findUserWithCameraStream(List<UserEntity> list, String userId) {
|
||||
for (UserEntity item : list) {
|
||||
if (TextUtils.equals(userId, item.getUserId()) && item.getVideoStreamType() != SCREEN_STREAM) {
|
||||
return item;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setUserNameCard(String userId, String nameCard) {
|
||||
if (allUserList.isEmpty() || TextUtils.isEmpty(userId) || TextUtils.isEmpty(nameCard)) {
|
||||
return;
|
||||
}
|
||||
for (UserEntity user : allUserList) {
|
||||
if (TextUtils.equals(user.getUserId(), userId)) {
|
||||
user.setNameCard(nameCard);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void updateTakeSeatRequestUserName(String userId, String userName) {
|
||||
if (takeSeatRequestList.isEmpty() || TextUtils.isEmpty(userId) || TextUtils.isEmpty(userName)) {
|
||||
return;
|
||||
}
|
||||
for (TakeSeatRequestEntity request : takeSeatRequestList) {
|
||||
if (TextUtils.equals(request.getUserId(), userId)) {
|
||||
request.setUserName(userName);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setEnableFloatChat(boolean enable) {
|
||||
enableFloatChat = enable;
|
||||
}
|
||||
|
||||
public boolean getEnableFloatChat() {
|
||||
return enableFloatChat;
|
||||
}
|
||||
}
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
package com.tencent.cloud.tuikit.roomkit.state;
|
||||
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.tencent.cloud.tuikit.engine.extension.TUIConferenceInvitationManager;
|
||||
import com.tencent.cloud.tuikit.engine.room.TUIRoomDefine;
|
||||
import com.trtc.tuikit.common.livedata.LiveListData;
|
||||
|
||||
public class InvitationState {
|
||||
public LiveListData<Invitation> invitationList = new LiveListData<>();
|
||||
|
||||
public void remoteUserEnterRoom(TUIRoomDefine.UserInfo userInfo) {
|
||||
InvitationState.Invitation invitation = new InvitationState.Invitation();
|
||||
invitation.invitee = new UserState.UserInfo(userInfo);
|
||||
invitationList.remove(invitation);
|
||||
}
|
||||
|
||||
public static class Invitation {
|
||||
public TUIConferenceInvitationManager.InvitationStatus invitationStatus = TUIConferenceInvitationManager.InvitationStatus.NONE;
|
||||
public UserState.UserInfo inviter;
|
||||
public UserState.UserInfo invitee;
|
||||
|
||||
public Invitation() {
|
||||
}
|
||||
|
||||
public Invitation(String inviteeUserId) {
|
||||
this.invitee = new UserState.UserInfo(inviteeUserId);
|
||||
}
|
||||
|
||||
public Invitation(TUIConferenceInvitationManager.Invitation invitation) {
|
||||
this.invitationStatus = invitation.status;
|
||||
this.inviter = new UserState.UserInfo(invitation.inviter);
|
||||
this.invitee = new UserState.UserInfo(invitation.invitee);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
Invitation that = (Invitation) o;
|
||||
return TextUtils.equals(invitee.userId, that.invitee.userId);
|
||||
}
|
||||
}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
package com.tencent.cloud.tuikit.roomkit.state;
|
||||
|
||||
|
||||
import com.trtc.tuikit.common.livedata.LiveData;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class MediaState {
|
||||
public LiveData<Boolean> isSpeakerOpened = new LiveData<>(true);
|
||||
public LiveData<Boolean> isCameraOpened = new LiveData<>(false);
|
||||
public LiveData<Boolean> isFrontCamera = new LiveData<>(true);
|
||||
public LiveData<Map<String, Integer>> volumeInfos = new LiveData<>(new HashMap<>());
|
||||
}
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
package com.tencent.cloud.tuikit.roomkit.state;
|
||||
|
||||
import com.tencent.cloud.tuikit.engine.room.TUIRoomDefine;
|
||||
import com.trtc.tuikit.common.livedata.LiveData;
|
||||
|
||||
public class RoomState {
|
||||
public LiveData<String> roomId = new LiveData<>("");
|
||||
public long createTime = 0L;
|
||||
public LiveData<String> ownerId = new LiveData<>("");
|
||||
public LiveData<String> ownerName = new LiveData<>("");
|
||||
public LiveData<String> roomName = new LiveData<>("");
|
||||
public LiveData<Integer> maxSeatCount = new LiveData<>(20);
|
||||
public LiveData<Boolean> isSeatEnabled = new LiveData<>(false);
|
||||
public LiveData<Boolean> isDisableScreen = new LiveData<>(false);
|
||||
public LiveData<TUIRoomDefine.SeatMode> seatMode = new LiveData<>(TUIRoomDefine.SeatMode.FREE_TO_TAKE);
|
||||
public TUIRoomDefine.RoomInfo roomInfo = new TUIRoomDefine.RoomInfo();
|
||||
|
||||
public void updateState(TUIRoomDefine.RoomInfo roomInfo) {
|
||||
roomId.set(roomInfo.roomId);
|
||||
createTime = roomInfo.createTime;
|
||||
ownerId.set(roomInfo.ownerId);
|
||||
ownerName.set(roomInfo.ownerName);
|
||||
roomName.set(roomInfo.name);
|
||||
maxSeatCount.set(roomInfo.maxSeatCount);
|
||||
isSeatEnabled.set(roomInfo.isSeatEnabled);
|
||||
seatMode.set(roomInfo.seatMode);
|
||||
isDisableScreen.set(roomInfo.isScreenShareDisableForAllUser);
|
||||
this.roomInfo = roomInfo;
|
||||
}
|
||||
}
|
||||
+95
@@ -0,0 +1,95 @@
|
||||
package com.tencent.cloud.tuikit.roomkit.state;
|
||||
|
||||
import static com.tencent.cloud.tuikit.roomkit.manager.constant.ConferenceConstant.USER_NOT_FOUND;
|
||||
|
||||
import android.text.TextUtils;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.tencent.cloud.tuikit.engine.room.TUIRoomDefine;
|
||||
import com.tencent.cloud.tuikit.roomkit.state.entity.Request;
|
||||
import com.trtc.tuikit.common.livedata.LiveListData;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class SeatState {
|
||||
public LiveListData<Request> takeSeatRequests = new LiveListData<>();
|
||||
public LiveListData<String> seatedUsers = new LiveListData<>();
|
||||
|
||||
public void addTakeSeatRequest(TUIRoomDefine.Request engineRequest) {
|
||||
Request request = new Request(engineRequest);
|
||||
takeSeatRequests.add(request);
|
||||
}
|
||||
|
||||
public void removeTakeSeatRequestByUserId(String userId) {
|
||||
List<Request> takeSeatRequestList = takeSeatRequests.getList();
|
||||
int position = USER_NOT_FOUND;
|
||||
for (int i = 0; i < takeSeatRequestList.size(); i++) {
|
||||
if (TextUtils.equals(userId, takeSeatRequestList.get(i).userId)) {
|
||||
position = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (position == USER_NOT_FOUND) {
|
||||
return;
|
||||
}
|
||||
takeSeatRequests.remove(position);
|
||||
}
|
||||
|
||||
public void removeTakeSeatRequest(String requestId) {
|
||||
List<Request> takeSeatRequestList = takeSeatRequests.getList();
|
||||
int position = USER_NOT_FOUND;
|
||||
for (int i = 0; i < takeSeatRequestList.size(); i++) {
|
||||
if (TextUtils.equals(requestId, takeSeatRequestList.get(i).requestId)) {
|
||||
position = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (position == USER_NOT_FOUND) {
|
||||
return;
|
||||
}
|
||||
takeSeatRequests.remove(position);
|
||||
}
|
||||
|
||||
public void updateTakeSeatRequestUserName(String userId, String userName) {
|
||||
List<Request> takeSeatRequestList = takeSeatRequests.getList();
|
||||
int position = USER_NOT_FOUND;
|
||||
for (int i = 0; i < takeSeatRequestList.size(); i++) {
|
||||
if (TextUtils.equals(userId, takeSeatRequestList.get(i).userId)) {
|
||||
position = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (position == USER_NOT_FOUND) {
|
||||
return;
|
||||
}
|
||||
takeSeatRequests.get(position).userName = userName;
|
||||
}
|
||||
|
||||
public void clearTakeSeatRequests() {
|
||||
takeSeatRequests.clear();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Request findTakeSeatRequestByUserId(String userId) {
|
||||
List<Request> takeSeatRequestList = takeSeatRequests.getList();
|
||||
int size = takeSeatRequestList.size();
|
||||
for (int i = 0; i < size; i++) {
|
||||
if (TextUtils.equals(userId, takeSeatRequestList.get(i).userId)) {
|
||||
return takeSeatRequestList.get(i);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Request findTakeSeatRequestByRequestId(String requestId) {
|
||||
List<Request> takeSeatRequestList = takeSeatRequests.getList();
|
||||
int size = takeSeatRequestList.size();
|
||||
for (int i = 0; i < size; i++) {
|
||||
if (TextUtils.equals(requestId, takeSeatRequestList.get(i).requestId)) {
|
||||
return takeSeatRequestList.get(i);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
+149
@@ -0,0 +1,149 @@
|
||||
package com.tencent.cloud.tuikit.roomkit.state;
|
||||
|
||||
import android.text.TextUtils;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.tencent.cloud.tuikit.engine.room.TUIRoomDefine;
|
||||
import com.tencent.qcloud.tuicore.TUILogin;
|
||||
import com.trtc.tuikit.common.livedata.LiveData;
|
||||
import com.trtc.tuikit.common.livedata.LiveListData;
|
||||
|
||||
public class UserState {
|
||||
public LiveData<UserInfo> selfInfo = new LiveData<>(new UserInfo(TUILogin.getUserId()));
|
||||
|
||||
public LiveListData<UserInfo> allUsers = new LiveListData<>();
|
||||
|
||||
public LiveListData<String> hasAudioStreamUsers = new LiveListData<>();
|
||||
public LiveListData<String> hasCameraStreamUsers = new LiveListData<>();
|
||||
public LiveListData<String> playBigCameraStreamUsers = new LiveListData<>();
|
||||
public LiveListData<String> disableMessageUsers = new LiveListData<>();
|
||||
|
||||
public LiveData<String> screenStreamUser = new LiveData<>("");
|
||||
public LiveData<UserVolumeInfo> userVolumeInfo = new LiveData<>(new UserVolumeInfo("", 0));
|
||||
|
||||
public void remoteUserEnterRoom(TUIRoomDefine.UserInfo userInfo) {
|
||||
UserInfo user = new UserInfo(userInfo);
|
||||
if (allUsers.contains(user)) {
|
||||
return;
|
||||
}
|
||||
UserInfo self = selfInfo.get();
|
||||
if (TextUtils.equals(userInfo.userId, self.userId)) {
|
||||
self.updateUserInfo(userInfo);
|
||||
selfInfo.set(self);
|
||||
}
|
||||
allUsers.add(user);
|
||||
if (userInfo.isMessageDisabled) {
|
||||
disableMessageUsers.add(userInfo.userId);
|
||||
}
|
||||
}
|
||||
|
||||
public void remoteUserLeaveRoom(TUIRoomDefine.UserInfo userInfo) {
|
||||
UserInfo user = new UserInfo(userInfo);
|
||||
allUsers.remove(user);
|
||||
disableMessageUsers.remove(userInfo.userId);
|
||||
}
|
||||
|
||||
public void userNameCardChanged(TUIRoomDefine.UserInfo userInfo) {
|
||||
UserInfo user = new UserInfo(userInfo);
|
||||
allUsers.change(user);
|
||||
}
|
||||
|
||||
public void handleUserRoleChanged(TUIRoomDefine.UserInfo userInfo) {
|
||||
UserInfo self = selfInfo.get();
|
||||
if (TextUtils.equals(userInfo.userId, self.userId)) {
|
||||
self.updateUserInfo(userInfo);
|
||||
selfInfo.set(self);
|
||||
}
|
||||
UserInfo user = new UserInfo(userInfo);
|
||||
allUsers.change(user);
|
||||
}
|
||||
|
||||
public void updateUserAudioState(String userId, boolean hasAudioStream) {
|
||||
if (hasAudioStream) {
|
||||
hasAudioStreamUsers.add(userId);
|
||||
} else {
|
||||
hasAudioStreamUsers.remove(userId);
|
||||
}
|
||||
}
|
||||
|
||||
public void updateUserCameraState(String userId, boolean hasCameraStream,
|
||||
TUIRoomDefine.VideoStreamType streamType) {
|
||||
if (hasCameraStream) {
|
||||
hasCameraStreamUsers.add(userId);
|
||||
if (streamType == TUIRoomDefine.VideoStreamType.CAMERA_STREAM) {
|
||||
playBigCameraStreamUsers.add(userId);
|
||||
}
|
||||
} else {
|
||||
hasCameraStreamUsers.remove(userId);
|
||||
if (streamType == TUIRoomDefine.VideoStreamType.CAMERA_STREAM) {
|
||||
playBigCameraStreamUsers.remove(userId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void updateUserScreenState(String userId, boolean hasScreenStream) {
|
||||
String sharingUserId = screenStreamUser.get();
|
||||
if (hasScreenStream && TextUtils.isEmpty(sharingUserId)) {
|
||||
screenStreamUser.set(userId);
|
||||
return;
|
||||
}
|
||||
if (!hasScreenStream && TextUtils.equals(userId, sharingUserId)) {
|
||||
screenStreamUser.set("");
|
||||
}
|
||||
}
|
||||
|
||||
public void updateUserMessageState(String userId, boolean isDisable) {
|
||||
if (isDisable) {
|
||||
disableMessageUsers.add(userId);
|
||||
} else {
|
||||
disableMessageUsers.remove(userId);
|
||||
}
|
||||
}
|
||||
|
||||
public static class UserInfo {
|
||||
public String userId = "";
|
||||
public String userName = "";
|
||||
public String avatarUrl = "";
|
||||
public LiveData<TUIRoomDefine.Role> role = new LiveData<>(TUIRoomDefine.Role.GENERAL_USER);
|
||||
|
||||
public UserInfo(String userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public UserInfo(TUIRoomDefine.UserInfo userInfo) {
|
||||
updateUserInfo(userInfo);
|
||||
}
|
||||
|
||||
public void updateUserInfo(TUIRoomDefine.UserInfo userInfo) {
|
||||
this.userId = userInfo.userId;
|
||||
this.userName = TextUtils.isEmpty(userInfo.nameCard) ? userInfo.userName : userInfo.nameCard;
|
||||
this.avatarUrl = userInfo.avatarUrl;
|
||||
this.role.set(userInfo.userRole);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(@Nullable Object obj) {
|
||||
if (obj instanceof UserInfo) {
|
||||
return TextUtils.equals(this.userId, ((UserInfo) obj).userId);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static class UserVolumeInfo {
|
||||
public String userId;
|
||||
public int volume;
|
||||
|
||||
public UserVolumeInfo(String userId, int volume) {
|
||||
this.userId = userId;
|
||||
this.volume = volume;
|
||||
}
|
||||
|
||||
public void update(String userId, int volume) {
|
||||
this.userId = userId;
|
||||
this.volume = volume;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+65
@@ -0,0 +1,65 @@
|
||||
package com.tencent.cloud.tuikit.roomkit.state;
|
||||
|
||||
import com.tencent.cloud.tuikit.roomkit.state.entity.Request;
|
||||
import com.tencent.cloud.tuikit.roomkit.manager.ConferenceController;
|
||||
import com.trtc.tuikit.common.livedata.LiveData;
|
||||
import com.trtc.tuikit.common.livedata.LiveListData;
|
||||
|
||||
public class ViewState {
|
||||
public LiveListData<String> pendingTakeSeatRequests = new LiveListData<>();
|
||||
|
||||
public LiveData<Boolean> isScreenPortrait = new LiveData<>(true);
|
||||
|
||||
public LiveData<String> searchUserKeyWord = new LiveData<>("");
|
||||
public LiveData<UserListType> userListType = new LiveData<>(UserListType.IN_ROOM);
|
||||
|
||||
public LiveData<RoomProcess> roomProcess = new LiveData<>(RoomProcess.NONE);
|
||||
public LiveData<Long> enterRoomTimeFromBoot = new LiveData<>(0L);
|
||||
|
||||
public LiveData<Boolean> isInvitationPending = new LiveData<>(false);
|
||||
public LiveData<Boolean> isSpeechToTextSubTitleShowing = new LiveData<>(false);
|
||||
|
||||
public FloatWindowType floatWindowType = FloatWindowType.NONE;
|
||||
public LiveData<Boolean> isInPictureInPictureMode = new LiveData<>(false);
|
||||
|
||||
public void addPendingTakeSeatRequest(String requestId) {
|
||||
pendingTakeSeatRequests.add(requestId);
|
||||
}
|
||||
|
||||
public void removePendingTakeSeatRequestByUserId(String userId) {
|
||||
SeatState seatState = ConferenceController.sharedInstance().getSeatState();
|
||||
Request request = seatState.findTakeSeatRequestByUserId(userId);
|
||||
if (request == null) {
|
||||
return;
|
||||
}
|
||||
removePendingTakeSeatRequest(request.requestId);
|
||||
}
|
||||
|
||||
public void removePendingTakeSeatRequest(String requestId) {
|
||||
pendingTakeSeatRequests.remove(requestId);
|
||||
}
|
||||
|
||||
public void clearPendingTakeSeatRequests() {
|
||||
pendingTakeSeatRequests.clear();
|
||||
}
|
||||
|
||||
public enum RoomProcess {
|
||||
NONE,
|
||||
COMING,
|
||||
IN,
|
||||
OUTING
|
||||
}
|
||||
|
||||
public enum UserListType {
|
||||
ON_SEAT,
|
||||
OFF_SEAT,
|
||||
IN_ROOM,
|
||||
OUT_ROOM
|
||||
}
|
||||
|
||||
public enum FloatWindowType {
|
||||
NONE,
|
||||
WINDOW_MANAGER,
|
||||
PICTURE_IN_PICTURE,
|
||||
}
|
||||
}
|
||||
+62
@@ -0,0 +1,62 @@
|
||||
package com.tencent.cloud.tuikit.roomkit.state.entity;
|
||||
|
||||
import static com.tencent.cloud.tuikit.roomkit.manager.eventcenter.ConferenceEventCenter.RoomEngineEvent.LOCAL_AUDIO_CAPTURE_VOLUME_CHANGED;
|
||||
import static com.tencent.cloud.tuikit.roomkit.manager.eventcenter.ConferenceEventCenter.RoomEngineEvent.LOCAL_AUDIO_PLAY_VOLUME_CHANGED;
|
||||
import static com.tencent.cloud.tuikit.roomkit.manager.eventcenter.ConferenceEventCenter.RoomEngineEvent.LOCAL_AUDIO_STATE_CHANGED;
|
||||
import static com.tencent.cloud.tuikit.roomkit.manager.eventcenter.ConferenceEventCenter.RoomEngineEvent.LOCAL_AUDIO_VOLUME_EVALUATION_CHANGED;
|
||||
|
||||
import com.tencent.cloud.tuikit.roomkit.manager.constant.ConferenceConstant;
|
||||
import com.tencent.cloud.tuikit.roomkit.manager.eventcenter.ConferenceEventCenter;
|
||||
|
||||
public class AudioModel {
|
||||
private int captureVolume = ConferenceConstant.DEFAULT_AUDIO_CAPTURE_VOLUME;
|
||||
private int playVolume = ConferenceConstant.DEFAULT_AUDIO_PLAY_VOLUME;
|
||||
private boolean enableVolumeEvaluation = ConferenceConstant.DEFAULT_AUDIO_VOLUME_EVALUATION;
|
||||
|
||||
private boolean hasAudioStream = false;
|
||||
private boolean isMicOpen = false;
|
||||
|
||||
public int getCaptureVolume() {
|
||||
return captureVolume;
|
||||
}
|
||||
|
||||
public void setCaptureVolume(int captureVolume) {
|
||||
this.captureVolume = captureVolume;
|
||||
ConferenceEventCenter.getInstance().notifyEngineEvent(LOCAL_AUDIO_CAPTURE_VOLUME_CHANGED, null);
|
||||
}
|
||||
|
||||
public int getPlayVolume() {
|
||||
return playVolume;
|
||||
}
|
||||
|
||||
public void setPlayVolume(int playVolume) {
|
||||
this.playVolume = playVolume;
|
||||
ConferenceEventCenter.getInstance().notifyEngineEvent(LOCAL_AUDIO_PLAY_VOLUME_CHANGED, null);
|
||||
}
|
||||
|
||||
public boolean isEnableVolumeEvaluation() {
|
||||
return enableVolumeEvaluation;
|
||||
}
|
||||
|
||||
public void setEnableVolumeEvaluation(boolean enableVolumeEvaluation) {
|
||||
this.enableVolumeEvaluation = enableVolumeEvaluation;
|
||||
ConferenceEventCenter.getInstance().notifyEngineEvent(LOCAL_AUDIO_VOLUME_EVALUATION_CHANGED, null);
|
||||
}
|
||||
|
||||
public boolean isHasAudioStream() {
|
||||
return hasAudioStream;
|
||||
}
|
||||
|
||||
public void setHasAudioStream(boolean hasAudioStream) {
|
||||
this.hasAudioStream = hasAudioStream;
|
||||
ConferenceEventCenter.getInstance().notifyEngineEvent(LOCAL_AUDIO_STATE_CHANGED, null);
|
||||
}
|
||||
|
||||
public boolean isMicOpen() {
|
||||
return isMicOpen;
|
||||
}
|
||||
|
||||
public void setMicOpen(boolean micOpened) {
|
||||
isMicOpen = micOpened;
|
||||
}
|
||||
}
|
||||
+145
@@ -0,0 +1,145 @@
|
||||
package com.tencent.cloud.tuikit.roomkit.state.entity;
|
||||
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.DrawableRes;
|
||||
|
||||
public class BottomItemData {
|
||||
private boolean enable;
|
||||
|
||||
@DrawableRes
|
||||
private int iconId;
|
||||
|
||||
@DrawableRes
|
||||
private int disableIconId;
|
||||
|
||||
@DrawableRes
|
||||
private int backgroundIconId;
|
||||
|
||||
private int width;
|
||||
|
||||
private int height;
|
||||
|
||||
private String name;
|
||||
|
||||
private BottomSelectItemData selectItemData;
|
||||
|
||||
private Type type;
|
||||
|
||||
private View view;
|
||||
|
||||
private OnItemClickListener onItemClickListener;
|
||||
|
||||
public Type getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(Type type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public void setView(View view) {
|
||||
this.view = view;
|
||||
}
|
||||
|
||||
public View getView() {
|
||||
return view;
|
||||
}
|
||||
|
||||
public int getBackground() {
|
||||
return backgroundIconId;
|
||||
}
|
||||
|
||||
public void setBackground(int backgroundIconId) {
|
||||
this.backgroundIconId = backgroundIconId;
|
||||
}
|
||||
|
||||
public int getWidth() {
|
||||
return width;
|
||||
}
|
||||
|
||||
public void setWidth(int width) {
|
||||
this.width = width;
|
||||
}
|
||||
|
||||
public int getHeight() {
|
||||
return height;
|
||||
}
|
||||
|
||||
public void setHeight(int height) {
|
||||
this.height = height;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public OnItemClickListener getOnItemClickListener() {
|
||||
return onItemClickListener;
|
||||
}
|
||||
|
||||
public void setOnItemClickListener(OnItemClickListener listener) {
|
||||
this.onItemClickListener = listener;
|
||||
}
|
||||
|
||||
|
||||
public boolean isEnable() {
|
||||
return enable;
|
||||
}
|
||||
|
||||
public void setEnable(boolean enable) {
|
||||
this.enable = enable;
|
||||
}
|
||||
|
||||
public int getIconId() {
|
||||
return iconId;
|
||||
}
|
||||
|
||||
public void setIconId(int iconId) {
|
||||
this.iconId = iconId;
|
||||
}
|
||||
|
||||
public int getDisableIconId() {
|
||||
return disableIconId;
|
||||
}
|
||||
|
||||
public void setDisableIconId(int disableIconId) {
|
||||
this.disableIconId = disableIconId;
|
||||
}
|
||||
|
||||
public BottomSelectItemData getSelectItemData() {
|
||||
return selectItemData;
|
||||
}
|
||||
|
||||
public void setSelectItemData(BottomSelectItemData selectItemData) {
|
||||
this.selectItemData = selectItemData;
|
||||
}
|
||||
|
||||
public interface OnItemClickListener {
|
||||
void onItemClick();
|
||||
}
|
||||
|
||||
public enum Type {
|
||||
EXIT,
|
||||
AUDIO,
|
||||
VIDEO,
|
||||
RAISE_HAND,
|
||||
OFF_STAGE,
|
||||
APPLY,
|
||||
BEAUTY,
|
||||
BARRAGE,
|
||||
MEMBER_LIST,
|
||||
EXTENSION,
|
||||
CHAT,
|
||||
SHARE,
|
||||
INVITE,
|
||||
MINIMIZE,
|
||||
RECORD,
|
||||
AI,
|
||||
SETTING
|
||||
}
|
||||
}
|
||||
+71
@@ -0,0 +1,71 @@
|
||||
package com.tencent.cloud.tuikit.roomkit.state.entity;
|
||||
|
||||
import androidx.annotation.DrawableRes;
|
||||
|
||||
public class BottomSelectItemData {
|
||||
private boolean isSelected;
|
||||
|
||||
@DrawableRes
|
||||
private int unSelectedIconId;
|
||||
|
||||
@DrawableRes
|
||||
private int selectedIconId;
|
||||
|
||||
private String unSelectedName;
|
||||
|
||||
private String selectedName;
|
||||
|
||||
private OnItemSelectListener mOnItemSelectListener;
|
||||
|
||||
public OnItemSelectListener getOnItemSelectListener() {
|
||||
return mOnItemSelectListener;
|
||||
}
|
||||
|
||||
public void setOnItemSelectListener(OnItemSelectListener listener) {
|
||||
this.mOnItemSelectListener = listener;
|
||||
}
|
||||
|
||||
public boolean isSelected() {
|
||||
return isSelected;
|
||||
}
|
||||
|
||||
public void setSelected(boolean selected) {
|
||||
isSelected = selected;
|
||||
}
|
||||
|
||||
public int getUnSelectedIconId() {
|
||||
return unSelectedIconId;
|
||||
}
|
||||
|
||||
public void setUnSelectedIconId(int unSelectedIconId) {
|
||||
this.unSelectedIconId = unSelectedIconId;
|
||||
}
|
||||
|
||||
public String getSelectedName() {
|
||||
return selectedName;
|
||||
}
|
||||
|
||||
public void setSelectedName(String selectedName) {
|
||||
this.selectedName = selectedName;
|
||||
}
|
||||
|
||||
public String getUnSelectedName() {
|
||||
return unSelectedName;
|
||||
}
|
||||
|
||||
public void setUnSelectedName(String unSelectedName) {
|
||||
this.unSelectedName = unSelectedName;
|
||||
}
|
||||
|
||||
public int getSelectedIconId() {
|
||||
return selectedIconId;
|
||||
}
|
||||
|
||||
public void setSelectedIconId(int selectedIconId) {
|
||||
this.selectedIconId = selectedIconId;
|
||||
}
|
||||
|
||||
public interface OnItemSelectListener {
|
||||
void onItemSelected(boolean isSelected);
|
||||
}
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
package com.tencent.cloud.tuikit.roomkit.state.entity;
|
||||
|
||||
import android.os.SystemClock;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.tencent.cloud.tuikit.engine.room.TUIRoomDefine;
|
||||
|
||||
public class Request {
|
||||
public String requestId;
|
||||
public String userId;
|
||||
public String userName;
|
||||
public String avatarUrl;
|
||||
public long timestamp;
|
||||
|
||||
public Request(TUIRoomDefine.Request request) {
|
||||
this.requestId = request.requestId;
|
||||
this.userName = TextUtils.isEmpty(request.nameCard) ? request.userName : request.nameCard;
|
||||
this.avatarUrl = request.avatarUrl;
|
||||
this.userId = request.userId;
|
||||
this.timestamp = SystemClock.elapsedRealtime();
|
||||
}
|
||||
}
|
||||
+64
@@ -0,0 +1,64 @@
|
||||
package com.tencent.cloud.tuikit.roomkit.state.entity;
|
||||
|
||||
import android.os.SystemClock;
|
||||
|
||||
import com.tencent.cloud.tuikit.engine.room.TUIRoomDefine;
|
||||
|
||||
public class TakeSeatRequestEntity {
|
||||
public final long receiveTimeMS = SystemClock.elapsedRealtime();
|
||||
|
||||
private String userId;
|
||||
private String userName;
|
||||
private String avatarUrl;
|
||||
|
||||
private TUIRoomDefine.Request request;
|
||||
|
||||
private boolean isChecked = false;
|
||||
|
||||
public TakeSeatRequestEntity(String userId, String userName, String avatarUrl, TUIRoomDefine.Request request) {
|
||||
this.userId = userId;
|
||||
this.userName = userName;
|
||||
this.avatarUrl = avatarUrl;
|
||||
this.request = request;
|
||||
}
|
||||
|
||||
public String getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(String userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public String getUserName() {
|
||||
return userName;
|
||||
}
|
||||
|
||||
public void setUserName(String userName) {
|
||||
this.userName = userName;
|
||||
}
|
||||
|
||||
public String getAvatarUrl() {
|
||||
return avatarUrl;
|
||||
}
|
||||
|
||||
public void setAvatarUrl(String avatarUrl) {
|
||||
this.avatarUrl = avatarUrl;
|
||||
}
|
||||
|
||||
public TUIRoomDefine.Request getRequest() {
|
||||
return request;
|
||||
}
|
||||
|
||||
public void setRequest(TUIRoomDefine.Request request) {
|
||||
this.request = request;
|
||||
}
|
||||
|
||||
public boolean isChecked() {
|
||||
return isChecked;
|
||||
}
|
||||
|
||||
public void setChecked(boolean checked) {
|
||||
isChecked = checked;
|
||||
}
|
||||
}
|
||||
+151
@@ -0,0 +1,151 @@
|
||||
package com.tencent.cloud.tuikit.roomkit.state.entity;
|
||||
|
||||
import com.tencent.cloud.tuikit.engine.room.TUIRoomDefine;
|
||||
|
||||
public class UserEntity {
|
||||
private String userId;
|
||||
private String userName;
|
||||
private String nameCard;
|
||||
private String avatarUrl;
|
||||
|
||||
private int userVoiceVolume = 0;
|
||||
private boolean hasAudioStream = false;
|
||||
|
||||
private boolean hasVideoStream = false;
|
||||
private TUIRoomDefine.VideoStreamType videoStreamType = TUIRoomDefine.VideoStreamType.CAMERA_STREAM;
|
||||
|
||||
private boolean isOnSeat = false;
|
||||
|
||||
private boolean enableSendingMessage = true;
|
||||
|
||||
private TUIRoomDefine.Role role = TUIRoomDefine.Role.GENERAL_USER;
|
||||
|
||||
public String getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(String userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public String getUserName() {
|
||||
return userName;
|
||||
}
|
||||
|
||||
public String getNameCard() {
|
||||
return nameCard;
|
||||
}
|
||||
|
||||
public void setUserName(String userName) {
|
||||
this.userName = userName;
|
||||
}
|
||||
|
||||
public void setNameCard(String nameCard) {
|
||||
this.nameCard = nameCard;
|
||||
}
|
||||
|
||||
public String getAvatarUrl() {
|
||||
return avatarUrl;
|
||||
}
|
||||
|
||||
public void setAvatarUrl(String avatarUrl) {
|
||||
this.avatarUrl = avatarUrl;
|
||||
}
|
||||
|
||||
public int getUserVoiceVolume() {
|
||||
return userVoiceVolume;
|
||||
}
|
||||
|
||||
public void setUserVoiceVolume(int userVoiceVolume) {
|
||||
this.userVoiceVolume = userVoiceVolume;
|
||||
}
|
||||
|
||||
public boolean isHasAudioStream() {
|
||||
return hasAudioStream;
|
||||
}
|
||||
|
||||
public void setHasAudioStream(boolean hasAudioStream) {
|
||||
this.hasAudioStream = hasAudioStream;
|
||||
}
|
||||
|
||||
public boolean isHasVideoStream() {
|
||||
return hasVideoStream;
|
||||
}
|
||||
|
||||
public void setHasVideoStream(boolean hasVideoStream) {
|
||||
this.hasVideoStream = hasVideoStream;
|
||||
}
|
||||
|
||||
public TUIRoomDefine.VideoStreamType getVideoStreamType() {
|
||||
return videoStreamType;
|
||||
}
|
||||
|
||||
public void setVideoStreamType(TUIRoomDefine.VideoStreamType videoStreamType) {
|
||||
this.videoStreamType = videoStreamType;
|
||||
}
|
||||
|
||||
public boolean isOnSeat() {
|
||||
return isOnSeat;
|
||||
}
|
||||
|
||||
public void setOnSeat(boolean onSeat) {
|
||||
isOnSeat = onSeat;
|
||||
}
|
||||
|
||||
public boolean isEnableSendingMessage() {
|
||||
return enableSendingMessage;
|
||||
}
|
||||
|
||||
public void setEnableSendingMessage(boolean enableSendingMessage) {
|
||||
this.enableSendingMessage = enableSendingMessage;
|
||||
}
|
||||
|
||||
public TUIRoomDefine.Role getRole() {
|
||||
return role;
|
||||
}
|
||||
|
||||
public void setRole(TUIRoomDefine.Role role) {
|
||||
this.role = role;
|
||||
}
|
||||
|
||||
public UserEntity copy() {
|
||||
UserEntity userEntity = new UserEntity();
|
||||
userEntity.setUserId(userId);
|
||||
userEntity.setUserName(userName);
|
||||
userEntity.setAvatarUrl(avatarUrl);
|
||||
userEntity.setUserVoiceVolume(userVoiceVolume);
|
||||
userEntity.setHasAudioStream(hasAudioStream);
|
||||
userEntity.setHasVideoStream(hasVideoStream);
|
||||
userEntity.setVideoStreamType(videoStreamType);
|
||||
userEntity.setOnSeat(isOnSeat);
|
||||
userEntity.setEnableSendingMessage(enableSendingMessage);
|
||||
userEntity.setRole(role);
|
||||
return userEntity;
|
||||
}
|
||||
|
||||
public static UserEntity toUserEntityForCameraStream(TUIRoomDefine.UserInfo userInfo) {
|
||||
UserEntity userEntity = new UserEntity();
|
||||
userEntity.userId = userInfo.userId;
|
||||
userEntity.userName = userInfo.userName;
|
||||
userEntity.nameCard = userInfo.nameCard;
|
||||
userEntity.avatarUrl = userInfo.avatarUrl;
|
||||
userEntity.hasAudioStream = userInfo.hasAudioStream;
|
||||
userEntity.hasVideoStream = userInfo.hasVideoStream;
|
||||
userEntity.videoStreamType = TUIRoomDefine.VideoStreamType.CAMERA_STREAM;
|
||||
userEntity.role = userInfo.userRole;
|
||||
return userEntity;
|
||||
}
|
||||
|
||||
public static UserEntity toUserEntityForScreenStream(TUIRoomDefine.UserInfo userInfo) {
|
||||
UserEntity userEntity = new UserEntity();
|
||||
userEntity.userId = userInfo.userId;
|
||||
userEntity.userName = userInfo.userName;
|
||||
userEntity.nameCard = userInfo.nameCard;
|
||||
userEntity.avatarUrl = userInfo.avatarUrl;
|
||||
userEntity.hasAudioStream = userInfo.hasAudioStream;
|
||||
userEntity.hasVideoStream = userInfo.hasScreenStream;
|
||||
userEntity.videoStreamType = TUIRoomDefine.VideoStreamType.SCREEN_STREAM;
|
||||
userEntity.role = userInfo.userRole;
|
||||
return userEntity;
|
||||
}
|
||||
}
|
||||
+64
@@ -0,0 +1,64 @@
|
||||
package com.tencent.cloud.tuikit.roomkit.state.entity;
|
||||
|
||||
import static com.tencent.cloud.tuikit.roomkit.manager.eventcenter.ConferenceEventCenter.RoomEngineEvent.LOCAL_USER_GENERAL_TO_MANAGER;
|
||||
import static com.tencent.cloud.tuikit.roomkit.manager.eventcenter.ConferenceEventCenter.RoomEngineEvent.LOCAL_USER_MANAGER_TO_GENERAL;
|
||||
import static com.tencent.cloud.tuikit.roomkit.manager.eventcenter.ConferenceEventCenter.RoomEngineEvent.LOCAL_USER_TO_OWNER;
|
||||
|
||||
import com.tencent.cloud.tuikit.engine.room.TUIRoomDefine;
|
||||
import com.tencent.cloud.tuikit.roomkit.manager.eventcenter.ConferenceEventCenter;
|
||||
import com.tencent.qcloud.tuicore.TUILogin;
|
||||
|
||||
public class UserModel {
|
||||
public String userId;
|
||||
|
||||
public String takeSeatRequestId;
|
||||
public long enterRoomTime = 0L;
|
||||
|
||||
private TUIRoomDefine.Role role;
|
||||
private SeatStatus seatStatus = SeatStatus.OFF_SEAT;
|
||||
|
||||
public UserModel() {
|
||||
userId = TUILogin.getUserId();
|
||||
}
|
||||
|
||||
public TUIRoomDefine.Role getRole() {
|
||||
return role;
|
||||
}
|
||||
|
||||
public void initRole(TUIRoomDefine.Role role) {
|
||||
this.role = role;
|
||||
}
|
||||
|
||||
public void changeRole(TUIRoomDefine.Role role) {
|
||||
if (this.role == TUIRoomDefine.Role.GENERAL_USER && role == TUIRoomDefine.Role.MANAGER) {
|
||||
ConferenceEventCenter.getInstance().notifyEngineEvent(LOCAL_USER_GENERAL_TO_MANAGER, null);
|
||||
} else if (this.role == TUIRoomDefine.Role.MANAGER && role == TUIRoomDefine.Role.GENERAL_USER) {
|
||||
ConferenceEventCenter.getInstance().notifyEngineEvent(LOCAL_USER_MANAGER_TO_GENERAL, null);
|
||||
} else if (this.role != TUIRoomDefine.Role.ROOM_OWNER && role == TUIRoomDefine.Role.ROOM_OWNER) {
|
||||
ConferenceEventCenter.getInstance().notifyEngineEvent(LOCAL_USER_TO_OWNER, null);
|
||||
}
|
||||
this.role = role;
|
||||
}
|
||||
|
||||
public SeatStatus getSeatStatus() {
|
||||
return seatStatus;
|
||||
}
|
||||
|
||||
public void setSeatStatus(SeatStatus seatStatus) {
|
||||
this.seatStatus = seatStatus;
|
||||
}
|
||||
|
||||
public enum SeatStatus {
|
||||
OFF_SEAT,
|
||||
APPLYING_TAKE_SEAT,
|
||||
ON_SEAT
|
||||
}
|
||||
|
||||
public boolean isOnSeat() {
|
||||
return seatStatus == SeatStatus.ON_SEAT;
|
||||
}
|
||||
|
||||
public boolean isOffSeat() {
|
||||
return seatStatus == SeatStatus.OFF_SEAT;
|
||||
}
|
||||
}
|
||||
+109
@@ -0,0 +1,109 @@
|
||||
package com.tencent.cloud.tuikit.roomkit.state.entity;
|
||||
|
||||
import static com.tencent.cloud.tuikit.engine.room.TUIRoomDefine.VideoQuality.Q_1080P;
|
||||
import static com.tencent.cloud.tuikit.engine.room.TUIRoomDefine.VideoQuality.Q_360P;
|
||||
import static com.tencent.cloud.tuikit.engine.room.TUIRoomDefine.VideoQuality.Q_540P;
|
||||
import static com.tencent.cloud.tuikit.engine.room.TUIRoomDefine.VideoQuality.Q_720P;
|
||||
import static com.tencent.cloud.tuikit.roomkit.manager.eventcenter.ConferenceEventCenter.RoomEngineEvent.LOCAL_CAMERA_STATE_CHANGED;
|
||||
import static com.tencent.cloud.tuikit.roomkit.manager.eventcenter.ConferenceEventCenter.RoomEngineEvent.LOCAL_SCREEN_STATE_CHANGED;
|
||||
import static com.tencent.cloud.tuikit.roomkit.manager.eventcenter.ConferenceEventCenter.RoomEngineEvent.LOCAL_VIDEO_FPS_CHANGED;
|
||||
import static com.tencent.cloud.tuikit.roomkit.manager.eventcenter.ConferenceEventCenter.RoomEngineEvent.LOCAL_VIDEO_RESOLUTION_CHANGED;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.tencent.cloud.tuikit.engine.room.TUIRoomDefine;
|
||||
import com.tencent.cloud.tuikit.roomkit.R;
|
||||
import com.tencent.cloud.tuikit.roomkit.manager.constant.ConferenceConstant;
|
||||
import com.tencent.cloud.tuikit.roomkit.manager.eventcenter.ConferenceEventCenter;
|
||||
import com.tencent.qcloud.tuicore.TUILogin;
|
||||
|
||||
public class VideoModel {
|
||||
Context mContext = TUILogin.getAppContext();
|
||||
public VideoResolutionMap[] mVideoResolutionMaps = {
|
||||
new VideoResolutionMap(mContext.getString(R.string.tuiroomkit_video_resolution_smooth), Q_360P, 550),
|
||||
new VideoResolutionMap(mContext.getString(R.string.tuiroomkit_video_resolution_sd), Q_540P, 850),
|
||||
new VideoResolutionMap(mContext.getString(R.string.tuiroomkit_video_resolution_hd), Q_720P, 1200),
|
||||
new VideoResolutionMap(mContext.getString(R.string.tuiroomkit_video_resolution_uhd), Q_1080P, 2000)};
|
||||
|
||||
private int fps = ConferenceConstant.DEFAULT_VIDEO_FPS;
|
||||
private int bitrate = ConferenceConstant.DEFAULT_VIDEO_BITRATE;
|
||||
private TUIRoomDefine.VideoQuality resolution = ConferenceConstant.DEFAULT_VIDEO_RESOLUTION;
|
||||
public boolean isLocalMirror = ConferenceConstant.DEFAULT_VIDEO_LOCAL_MIRROR;
|
||||
public boolean isFrontCamera = ConferenceConstant.DEFAULT_CAMERA_FRONT;
|
||||
|
||||
private boolean isScreenSharing = false;
|
||||
private boolean isCameraOpened = false;
|
||||
|
||||
public int getFps() {
|
||||
return fps;
|
||||
}
|
||||
|
||||
public void setFps(int fps) {
|
||||
this.fps = fps;
|
||||
ConferenceEventCenter.getInstance().notifyEngineEvent(LOCAL_VIDEO_FPS_CHANGED, null);
|
||||
}
|
||||
|
||||
public int getBitrate() {
|
||||
return bitrate;
|
||||
}
|
||||
|
||||
public TUIRoomDefine.VideoQuality getResolution() {
|
||||
return resolution;
|
||||
}
|
||||
|
||||
public void setResolution(TUIRoomDefine.VideoQuality resolution) {
|
||||
this.resolution = resolution;
|
||||
this.bitrate = getBitrateByResolution(resolution);
|
||||
ConferenceEventCenter.getInstance().notifyEngineEvent(LOCAL_VIDEO_RESOLUTION_CHANGED, null);
|
||||
}
|
||||
|
||||
public boolean isScreenSharing() {
|
||||
return isScreenSharing;
|
||||
}
|
||||
|
||||
public void setScreenSharing(boolean screenSharing) {
|
||||
isScreenSharing = screenSharing;
|
||||
ConferenceEventCenter.getInstance().notifyEngineEvent(LOCAL_SCREEN_STATE_CHANGED, null);
|
||||
}
|
||||
|
||||
public boolean isCameraOpened() {
|
||||
return isCameraOpened;
|
||||
}
|
||||
|
||||
public void setCameraOpened(boolean cameraOpened) {
|
||||
isCameraOpened = cameraOpened;
|
||||
ConferenceEventCenter.getInstance().notifyEngineEvent(LOCAL_CAMERA_STATE_CHANGED, null);
|
||||
}
|
||||
|
||||
class VideoResolutionMap {
|
||||
public String name;
|
||||
public TUIRoomDefine.VideoQuality resolution;
|
||||
public int bitrate;
|
||||
|
||||
public VideoResolutionMap(String name, TUIRoomDefine.VideoQuality resolution, int bitrate) {
|
||||
this.name = name;
|
||||
this.resolution = resolution;
|
||||
this.bitrate = bitrate;
|
||||
}
|
||||
}
|
||||
|
||||
private int getBitrateByResolution(TUIRoomDefine.VideoQuality resolution) {
|
||||
int tmpBitrate = bitrate;
|
||||
for (int i = 0; i < mVideoResolutionMaps.length; i++) {
|
||||
if (resolution == mVideoResolutionMaps[i].resolution) {
|
||||
tmpBitrate = mVideoResolutionMaps[i].bitrate;
|
||||
}
|
||||
}
|
||||
return tmpBitrate;
|
||||
}
|
||||
|
||||
public String getCurrentResolutionName() {
|
||||
String name = "";
|
||||
for (int i = 0; i < mVideoResolutionMaps.length; i++) {
|
||||
if (resolution == mVideoResolutionMaps[i].resolution) {
|
||||
name = mVideoResolutionMaps[i].name;
|
||||
}
|
||||
}
|
||||
return name;
|
||||
}
|
||||
}
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
package com.tencent.cloud.tuikit.roomkit.view;
|
||||
|
||||
import com.tencent.cloud.tuikit.roomkit.manager.ViewController;
|
||||
import com.tencent.cloud.tuikit.roomkit.state.InvitationState;
|
||||
import com.tencent.cloud.tuikit.roomkit.state.RoomState;
|
||||
import com.tencent.cloud.tuikit.roomkit.state.SeatState;
|
||||
import com.tencent.cloud.tuikit.roomkit.state.UserState;
|
||||
import com.tencent.cloud.tuikit.roomkit.state.ViewState;
|
||||
import com.tencent.cloud.tuikit.roomkit.manager.ConferenceController;
|
||||
|
||||
public class StateHolder {
|
||||
protected ViewState mViewState;
|
||||
protected SeatState mSeatState;
|
||||
protected RoomState mRoomState;
|
||||
protected UserState mUserState;
|
||||
protected InvitationState mInvitationState;
|
||||
|
||||
protected ViewController mViewController;
|
||||
|
||||
public StateHolder() {
|
||||
ConferenceController controller = ConferenceController.sharedInstance();
|
||||
mViewState = controller.getViewState();
|
||||
mSeatState = controller.getSeatState();
|
||||
mRoomState = controller.getRoomState();
|
||||
mUserState = controller.getUserState();
|
||||
mInvitationState = controller.getInvitationState();
|
||||
|
||||
mViewController = controller.getViewController();
|
||||
}
|
||||
}
|
||||
+148
@@ -0,0 +1,148 @@
|
||||
package com.tencent.cloud.tuikit.roomkit.view.basic;
|
||||
|
||||
|
||||
import static com.tencent.cloud.tuikit.roomkit.manager.eventcenter.ConferenceEventCenter.RoomKitUIEvent.DISMISS_MAIN_ACTIVITY;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.res.Configuration;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.google.android.material.bottomsheet.BottomSheetBehavior;
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialog;
|
||||
import com.tencent.cloud.tuikit.roomkit.R;
|
||||
import com.tencent.cloud.tuikit.roomkit.manager.eventcenter.ConferenceEventCenter;
|
||||
import com.tencent.qcloud.tuicore.util.ScreenUtil;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public abstract class BaseBottomDialog extends BottomSheetDialog implements ConferenceEventCenter.RoomKitUIEventResponder {
|
||||
private static final String TAG = "BaseBottomDialog";
|
||||
|
||||
private View bottomSheetView;
|
||||
private BottomSheetBehavior<View> mBehavior;
|
||||
|
||||
private Context mContext;
|
||||
|
||||
public BaseBottomDialog(@NonNull Context context) {
|
||||
super(context);
|
||||
mContext = context;
|
||||
ConferenceEventCenter.getInstance().subscribeUIEvent(DISMISS_MAIN_ACTIVITY, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dismiss() {
|
||||
super.dismiss();
|
||||
ConferenceEventCenter.getInstance().unsubscribeUIEvent(DISMISS_MAIN_ACTIVITY, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
initRootView();
|
||||
}
|
||||
|
||||
public void setPortraitHeightPercentOfScreen(View view, float percentOfScreen) {
|
||||
Configuration configuration = mContext.getResources().getConfiguration();
|
||||
if (configuration.orientation != Configuration.ORIENTATION_PORTRAIT) {
|
||||
return;
|
||||
}
|
||||
ViewGroup.LayoutParams layoutParams = view.getLayoutParams();
|
||||
if (layoutParams == null) {
|
||||
return;
|
||||
}
|
||||
layoutParams.width = ViewGroup.LayoutParams.MATCH_PARENT;
|
||||
int screenHeight = ScreenUtil.getScreenHeight(mContext);
|
||||
layoutParams.height = (int) (screenHeight * percentOfScreen);
|
||||
view.setLayoutParams(layoutParams);
|
||||
}
|
||||
|
||||
private void initRootView() {
|
||||
setContentView(getLayoutId());
|
||||
bottomSheetView = findViewById(com.google.android.material.R.id.design_bottom_sheet);
|
||||
if (bottomSheetView != null) {
|
||||
mBehavior = BottomSheetBehavior.from(bottomSheetView);
|
||||
}
|
||||
initView();
|
||||
|
||||
updateBackground();
|
||||
handleScreenOrientationChanged(getContext().getResources().getConfiguration());
|
||||
mBehavior.setSkipCollapsed(true);
|
||||
mBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
|
||||
mBehavior.setPeekHeight(getContext().getResources().getDisplayMetrics().heightPixels);
|
||||
}
|
||||
|
||||
protected abstract int getLayoutId();
|
||||
|
||||
protected abstract void initView();
|
||||
|
||||
public void changeConfiguration(Configuration configuration) {
|
||||
initRootView();
|
||||
}
|
||||
|
||||
private void handleScreenOrientationChanged(Configuration configuration) {
|
||||
if (mContext != null && mContext instanceof Activity) {
|
||||
Activity activity = (Activity) mContext;
|
||||
if (activity.isFinishing()) {
|
||||
Log.e(TAG, "handleScreenOrientationChanged activity is finishing");
|
||||
return;
|
||||
}
|
||||
}
|
||||
Window window = getWindow();
|
||||
if (window == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
window.setBackgroundDrawableResource(android.R.color.transparent);
|
||||
WindowManager.LayoutParams params = window.getAttributes();
|
||||
int resId;
|
||||
if (configuration.orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||
resId = R.style.TUIRoomBottomDialogHorizontalAnim;
|
||||
params.gravity = Gravity.END;
|
||||
params.width = getContext().getResources().getDisplayMetrics().widthPixels / 2;
|
||||
} else {
|
||||
resId = R.style.TUIRoomBottomDialogVerticalAnim;
|
||||
params.gravity = Gravity.BOTTOM;
|
||||
params.width = WindowManager.LayoutParams.MATCH_PARENT;
|
||||
}
|
||||
window.setWindowAnimations(resId);
|
||||
params.height = getContext().getResources().getDisplayMetrics().heightPixels;
|
||||
params.flags =
|
||||
WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS;
|
||||
window.setAttributes(params);
|
||||
|
||||
ViewGroup.LayoutParams viewParams = bottomSheetView.getLayoutParams();
|
||||
viewParams.height =
|
||||
configuration.orientation == Configuration.ORIENTATION_LANDSCAPE ? ViewGroup.LayoutParams.MATCH_PARENT :
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT;
|
||||
bottomSheetView.setLayoutParams(viewParams);
|
||||
}
|
||||
|
||||
private void updateBackground() {
|
||||
if (getWindow() == null) {
|
||||
return;
|
||||
}
|
||||
int resId = getContext().getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE
|
||||
? R.drawable.tuiroomkit_bg_bottom_dialog_black_landscape
|
||||
: R.drawable.tuiroomkit_bg_bottom_dialog_black_portrait;
|
||||
getWindow().findViewById(com.google.android.material.R.id.design_bottom_sheet)
|
||||
.setBackgroundResource(resId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNotifyUIEvent(String key, Map<String, Object> params) {
|
||||
if (key != DISMISS_MAIN_ACTIVITY) {
|
||||
return;
|
||||
}
|
||||
dismiss();
|
||||
}
|
||||
}
|
||||
+168
@@ -0,0 +1,168 @@
|
||||
package com.tencent.cloud.tuikit.roomkit.view.basic;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.Window;
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.DialogFragment;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
|
||||
import com.tencent.cloud.tuikit.roomkit.R;
|
||||
|
||||
public class BaseDialogFragment extends DialogFragment {
|
||||
private static final String TAG = "BaseDialogFragment";
|
||||
|
||||
private View mRootView;
|
||||
|
||||
private String mTitle;
|
||||
private String mContent;
|
||||
private String mNegativeName;
|
||||
private String mPositiveName;
|
||||
private int mPositiveButtonColor = 0;
|
||||
|
||||
private boolean mIsHideNegativeView;
|
||||
|
||||
private ClickListener mNegativeListener;
|
||||
private ClickListener mPositiveListener;
|
||||
|
||||
public interface ClickListener {
|
||||
void onClick();
|
||||
}
|
||||
|
||||
public static BaseDialogFragment build() {
|
||||
BaseDialogFragment dialog = new BaseDialogFragment();
|
||||
return dialog;
|
||||
}
|
||||
|
||||
public BaseDialogFragment setTitle(String title) {
|
||||
mTitle = title;
|
||||
return this;
|
||||
}
|
||||
|
||||
public BaseDialogFragment setContent(String content) {
|
||||
mContent = content;
|
||||
return this;
|
||||
}
|
||||
|
||||
public BaseDialogFragment setNegativeName(String negativeName) {
|
||||
mNegativeName = negativeName;
|
||||
return this;
|
||||
}
|
||||
|
||||
public BaseDialogFragment setPositiveName(String positiveName) {
|
||||
mPositiveName = positiveName;
|
||||
return this;
|
||||
}
|
||||
|
||||
public BaseDialogFragment setNegativeListener(ClickListener negativeListener) {
|
||||
mNegativeListener = negativeListener;
|
||||
return this;
|
||||
}
|
||||
|
||||
public BaseDialogFragment setPositiveListener(ClickListener positiveListener) {
|
||||
mPositiveListener = positiveListener;
|
||||
return this;
|
||||
}
|
||||
|
||||
public BaseDialogFragment hideNegativeView() {
|
||||
mIsHideNegativeView = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
public BaseDialogFragment setPositiveButtonColor(int color) {
|
||||
mPositiveButtonColor = color;
|
||||
return this;
|
||||
}
|
||||
|
||||
public void showDialog(@NonNull Context context, @Nullable String tag) {
|
||||
if (!(context instanceof FragmentActivity)) {
|
||||
Log.e(TAG, "context is not instance of FragmentActivity");
|
||||
return;
|
||||
}
|
||||
FragmentManager manager = ((FragmentActivity) context).getSupportFragmentManager();
|
||||
Fragment fragment = manager.findFragmentByTag(tag);
|
||||
if (fragment != null && fragment instanceof DialogFragment) {
|
||||
return;
|
||||
}
|
||||
setCancelable(false);
|
||||
this.show(manager, tag);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
mRootView = inflater.inflate(R.layout.tuiroomkit_dialog_base, container, false);
|
||||
return mRootView;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
TextView tvTitle = mRootView.findViewById(R.id.tuiroomkit_dialog_title);
|
||||
if (TextUtils.isEmpty(mTitle)) {
|
||||
tvTitle.setVisibility(View.GONE);
|
||||
} else {
|
||||
tvTitle.setText(mTitle);
|
||||
}
|
||||
TextView tvContent = mRootView.findViewById(R.id.tuiroomkit_dialog_content);
|
||||
if (TextUtils.isEmpty(mContent)) {
|
||||
tvContent.setVisibility(View.GONE);
|
||||
} else {
|
||||
tvContent.setText(mContent);
|
||||
}
|
||||
|
||||
Button btnNegative = mRootView.findViewById(R.id.tuiroomkit_btn_dialog_negative);
|
||||
if (mIsHideNegativeView) {
|
||||
btnNegative.setVisibility(View.GONE);
|
||||
} else {
|
||||
if (!TextUtils.isEmpty(mNegativeName)) {
|
||||
btnNegative.setText(mNegativeName);
|
||||
}
|
||||
btnNegative.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
btnNegative.setClickable(false);
|
||||
if (mNegativeListener != null) {
|
||||
mNegativeListener.onClick();
|
||||
}
|
||||
dismissAllowingStateLoss();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Button btnPositive = mRootView.findViewById(R.id.tuiroomkit_btn_dialog_positive);
|
||||
if (!TextUtils.isEmpty(mPositiveName)) {
|
||||
btnPositive.setText(mPositiveName);
|
||||
}
|
||||
if (mPositiveButtonColor != 0) {
|
||||
btnPositive.setTextColor(mPositiveButtonColor);
|
||||
}
|
||||
btnPositive.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
btnPositive.setClickable(false);
|
||||
if (mPositiveListener != null) {
|
||||
mPositiveListener.onClick();
|
||||
}
|
||||
dismissAllowingStateLoss();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
Window window = getDialog().getWindow();
|
||||
window.setBackgroundDrawableResource(android.R.color.transparent);
|
||||
}
|
||||
}
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
package com.tencent.cloud.tuikit.roomkit.view.basic;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class BaseSettingItem {
|
||||
protected Context mContext;
|
||||
protected LayoutInflater mInflater;
|
||||
protected ItemText mItemText;
|
||||
|
||||
public BaseSettingItem(Context context,
|
||||
@NonNull ItemText itemText) {
|
||||
mContext = context;
|
||||
mItemText = itemText;
|
||||
mInflater = LayoutInflater.from(context);
|
||||
}
|
||||
|
||||
public abstract View getView();
|
||||
|
||||
public static class ItemText {
|
||||
public String title;
|
||||
public List<String> contentText;
|
||||
|
||||
public ItemText(String title, String... textList) {
|
||||
this.title = title;
|
||||
this.contentText = Arrays.asList(textList);
|
||||
}
|
||||
}
|
||||
}
|
||||
+161
@@ -0,0 +1,161 @@
|
||||
package com.tencent.cloud.tuikit.roomkit.view.basic;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.os.CountDownTimer;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.tencent.cloud.tuikit.roomkit.R;
|
||||
|
||||
public class ConfirmDialog extends Dialog {
|
||||
private static final String TAG = "ConfirmDialogFragment";
|
||||
|
||||
private View mDivideLine;
|
||||
private String mMessageText;
|
||||
private String mPositiveText;
|
||||
private String mNegativeText;
|
||||
private PositiveClickListener mPositiveClickListener;
|
||||
private NegativeClickListener mNegativeClickListener;
|
||||
|
||||
private TextView mTextCountDown;
|
||||
private CountDownTimer mCountDownTimer;
|
||||
private int mAutoConfirmSeconds = 0;
|
||||
|
||||
public ConfirmDialog(@NonNull Context context) {
|
||||
super(context, R.style.TUIRoomDialogTheme);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.tuiroomkit_dialog_confirm);
|
||||
setCancelable(false);
|
||||
mDivideLine = findViewById(R.id.divide_line);
|
||||
initTextMessage();
|
||||
initButtonPositive();
|
||||
initButtonNegative();
|
||||
initTextCountDown();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void show() {
|
||||
super.show();
|
||||
if (mAutoConfirmSeconds == 0) {
|
||||
return;
|
||||
}
|
||||
mCountDownTimer = new CountDownTimer(mAutoConfirmSeconds * 1000L, 1000) {
|
||||
@Override
|
||||
public void onTick(long millisUntilFinished) {
|
||||
mTextCountDown.setText(getContext().getString(R.string.tuiroomkit_confirm_dialog_count_down_text, String.valueOf(millisUntilFinished / 1000)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFinish() {
|
||||
if (mPositiveClickListener != null) {
|
||||
mPositiveClickListener.onClick();
|
||||
}
|
||||
mCountDownTimer.cancel();
|
||||
}
|
||||
};
|
||||
mCountDownTimer.start();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dismiss() {
|
||||
super.dismiss();
|
||||
if (mCountDownTimer != null) {
|
||||
mCountDownTimer.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
private void initTextMessage() {
|
||||
TextView textMessage = findViewById(R.id.tv_message);
|
||||
textMessage.setText(mMessageText);
|
||||
}
|
||||
|
||||
private void initButtonPositive() {
|
||||
LinearLayout positiveLayout = findViewById(R.id.btn_positive);
|
||||
|
||||
if (mPositiveClickListener == null) {
|
||||
positiveLayout.setVisibility(View.GONE);
|
||||
return;
|
||||
}
|
||||
if (!TextUtils.isEmpty(mPositiveText)) {
|
||||
TextView positiveTextView = findViewById(R.id.text_positive);
|
||||
positiveTextView.setText(mPositiveText);
|
||||
}
|
||||
positiveLayout.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
mPositiveClickListener.onClick();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void initButtonNegative() {
|
||||
Button buttonNegative = findViewById(R.id.btn_negative);
|
||||
|
||||
if (mNegativeClickListener == null) {
|
||||
buttonNegative.setVisibility(View.GONE);
|
||||
mDivideLine.setVisibility(View.GONE);
|
||||
return;
|
||||
}
|
||||
if (!TextUtils.isEmpty(mNegativeText)) {
|
||||
buttonNegative.setText(mNegativeText);
|
||||
}
|
||||
buttonNegative.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
mNegativeClickListener.onClick();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void initTextCountDown() {
|
||||
mTextCountDown = findViewById(R.id.tv_count_down);
|
||||
if (mAutoConfirmSeconds == 0) {
|
||||
return;
|
||||
}
|
||||
mTextCountDown.setVisibility(View.VISIBLE);
|
||||
mTextCountDown.setText(getContext().getString(R.string.tuiroomkit_confirm_dialog_count_down_text, String.valueOf(mAutoConfirmSeconds)));
|
||||
}
|
||||
|
||||
public void setAutoConfirmSeconds(int seconds) {
|
||||
mAutoConfirmSeconds = seconds;
|
||||
}
|
||||
|
||||
public void setMessage(String message) {
|
||||
mMessageText = message;
|
||||
}
|
||||
|
||||
public void setPositiveText(String text) {
|
||||
mPositiveText = text;
|
||||
}
|
||||
|
||||
public void setNegativeText(String text) {
|
||||
mNegativeText = text;
|
||||
}
|
||||
|
||||
public void setPositiveClickListener(PositiveClickListener listener) {
|
||||
this.mPositiveClickListener = listener;
|
||||
}
|
||||
|
||||
public void setNegativeClickListener(NegativeClickListener listener) {
|
||||
this.mNegativeClickListener = listener;
|
||||
}
|
||||
|
||||
public interface PositiveClickListener {
|
||||
void onClick();
|
||||
}
|
||||
|
||||
public interface NegativeClickListener {
|
||||
void onClick();
|
||||
}
|
||||
}
|
||||
+89
@@ -0,0 +1,89 @@
|
||||
package com.tencent.cloud.tuikit.roomkit.view.basic;
|
||||
|
||||
import static com.tencent.cloud.tuikit.roomkit.manager.constant.ConferenceConstant.DURATION_FOREVER;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.tencent.cloud.tuikit.roomkit.R;
|
||||
|
||||
public class NotificationView extends FrameLayout {
|
||||
protected Context mContext;
|
||||
|
||||
private TextView mTvMessage;
|
||||
private Button mBtnConfirm;
|
||||
|
||||
private int mDurationMS;
|
||||
|
||||
private final Runnable mDismissRun = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
setVisibility(GONE);
|
||||
}
|
||||
};
|
||||
|
||||
public NotificationView(Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
|
||||
public NotificationView(Context context, AttributeSet attrs) {
|
||||
this(context, attrs, 0);
|
||||
}
|
||||
|
||||
public NotificationView(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.NotificationView);
|
||||
mDurationMS = typedArray.getInt(R.styleable.NotificationView_durationMS, DURATION_FOREVER);
|
||||
typedArray.recycle();
|
||||
|
||||
mContext = context;
|
||||
setVisibility(GONE);
|
||||
View roomView = inflate(mContext, R.layout.tuiroomkit_layout_notification, this);
|
||||
mTvMessage = roomView.findViewById(R.id.tuiroomkit_notification_message);
|
||||
mBtnConfirm = roomView.findViewById(R.id.tuiroomkit_notification_confirm);
|
||||
}
|
||||
|
||||
public NotificationView setMessage(String message) {
|
||||
mTvMessage.setText(message);
|
||||
return this;
|
||||
}
|
||||
|
||||
public NotificationView setDuration(int duration) {
|
||||
mDurationMS = duration;
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getDuration() {
|
||||
return mDurationMS;
|
||||
}
|
||||
|
||||
public NotificationView setClickListener(OnClickListener clickListener) {
|
||||
mBtnConfirm.setOnClickListener(clickListener);
|
||||
return this;
|
||||
}
|
||||
|
||||
public void show() {
|
||||
setVisibility(VISIBLE);
|
||||
removeCallbacks(mDismissRun);
|
||||
if (mDurationMS == DURATION_FOREVER) {
|
||||
return;
|
||||
}
|
||||
postDelayed(mDismissRun, mDurationMS);
|
||||
}
|
||||
|
||||
public void dismiss() {
|
||||
setVisibility(GONE);
|
||||
removeCallbacks(mDismissRun);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow();
|
||||
removeCallbacks(mDismissRun);
|
||||
}
|
||||
}
|
||||
+174
@@ -0,0 +1,174 @@
|
||||
package com.tencent.cloud.tuikit.roomkit.view.basic;
|
||||
|
||||
import static com.tencent.cloud.tuikit.roomkit.manager.eventcenter.ConferenceEventCenter.RoomKitUIEvent.SCHEDULED_CONFERENCE_SUCCESS;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
import androidx.constraintlayout.widget.ConstraintSet;
|
||||
import androidx.fragment.app.FragmentTransaction;
|
||||
|
||||
import com.tencent.cloud.tuikit.engine.room.TUIRoomDefine;
|
||||
import com.tencent.cloud.tuikit.engine.room.TUIRoomEngine;
|
||||
import com.tencent.cloud.tuikit.roomkit.ConferenceListFragment;
|
||||
import com.tencent.cloud.tuikit.roomkit.R;
|
||||
import com.tencent.cloud.tuikit.roomkit.ScheduleConferenceActivity;
|
||||
import com.tencent.cloud.tuikit.roomkit.common.utils.ImageLoader;
|
||||
import com.tencent.cloud.tuikit.roomkit.manager.eventcenter.ConferenceEventCenter;
|
||||
import com.tencent.cloud.tuikit.roomkit.view.schedule.scheduleinfo.ScheduleInviteMemberView;
|
||||
import com.tencent.qcloud.tuicore.TUICore;
|
||||
import com.tencent.qcloud.tuicore.TUILogin;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import de.hdodenhof.circleimageview.CircleImageView;
|
||||
|
||||
public class PrepareView extends RelativeLayout implements View.OnClickListener,
|
||||
ConferenceEventCenter.RoomKitUIEventResponder {
|
||||
|
||||
private Context mContext;
|
||||
private TextView mTextUserName;
|
||||
private ImageView mImageBack;
|
||||
private CircleImageView mImageHead;
|
||||
private LinearLayout mLayoutEnterRoom;
|
||||
private LinearLayout mLayoutCreateRoom;
|
||||
private LinearLayout mLayoutScheduleRoom;
|
||||
private ConstraintLayout mLayoutRoot;
|
||||
private ConstraintSet mPreSet;
|
||||
|
||||
public PrepareView(Context context, boolean enablePreview) {
|
||||
super(context);
|
||||
mContext = context;
|
||||
subscribeEvent();
|
||||
initView();
|
||||
updatePreviewLayout(enablePreview);
|
||||
}
|
||||
|
||||
private void subscribeEvent() {
|
||||
ConferenceEventCenter eventCenter = ConferenceEventCenter.getInstance();
|
||||
eventCenter.subscribeUIEvent(SCHEDULED_CONFERENCE_SUCCESS, this);
|
||||
}
|
||||
|
||||
private void unSubscribeEvent() {
|
||||
ConferenceEventCenter eventCenter = ConferenceEventCenter.getInstance();
|
||||
eventCenter.unsubscribeUIEvent(SCHEDULED_CONFERENCE_SUCCESS, this);
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
View.inflate(mContext, R.layout.tuiroomkit_view_prepare, this);
|
||||
|
||||
mLayoutRoot = findViewById(R.id.cl_root_prepare);
|
||||
mImageHead = findViewById(R.id.img_head_prepare);
|
||||
mTextUserName = findViewById(R.id.tv_name_prepare);
|
||||
mImageBack = findViewById(R.id.img_back);
|
||||
mLayoutEnterRoom = findViewById(R.id.ll_enter_room);
|
||||
mLayoutCreateRoom = findViewById(R.id.ll_create_room);
|
||||
mLayoutScheduleRoom = findViewById(R.id.ll_schedule_conference);
|
||||
|
||||
mImageBack.setOnClickListener(this);
|
||||
mImageHead.setOnClickListener(this);
|
||||
mLayoutEnterRoom.setOnClickListener(this);
|
||||
mLayoutCreateRoom.setOnClickListener(this);
|
||||
mLayoutScheduleRoom.setOnClickListener(this);
|
||||
|
||||
TUIRoomDefine.LoginUserInfo userInfo = TUIRoomEngine.getSelfInfo();
|
||||
ImageLoader.loadImage(mContext, mImageHead, userInfo.avatarUrl,
|
||||
R.drawable.tuiroomkit_ic_avatar);
|
||||
mTextUserName.setText(userInfo.userName);
|
||||
|
||||
mPreSet = new ConstraintSet();
|
||||
mPreSet.clone(mLayoutRoot);
|
||||
|
||||
if (mContext instanceof AppCompatActivity) {
|
||||
AppCompatActivity activity = (AppCompatActivity) mContext;
|
||||
ConferenceListFragment fragment = new ConferenceListFragment();
|
||||
FragmentTransaction transaction = activity.getSupportFragmentManager().beginTransaction();
|
||||
transaction.add(R.id.tuiroomkit_fl_conference_list_container, fragment);
|
||||
transaction.commitAllowingStateLoss();
|
||||
}
|
||||
}
|
||||
|
||||
private void updatePreviewLayout(boolean enableVideoPreview) {
|
||||
if (enableVideoPreview) {
|
||||
mPreSet.applyTo(mLayoutRoot);
|
||||
} else {
|
||||
ConstraintSet set = new ConstraintSet();
|
||||
set.clone(mLayoutRoot);
|
||||
set.clear(mLayoutCreateRoom.getId());
|
||||
set.clear(mLayoutEnterRoom.getId());
|
||||
|
||||
set.centerHorizontally(mLayoutCreateRoom.getId(), ConstraintSet.PARENT_ID);
|
||||
set.constrainHeight(mLayoutCreateRoom.getId(), ConstraintSet.WRAP_CONTENT);
|
||||
set.constrainPercentWidth(mLayoutCreateRoom.getId(), 0.5f);
|
||||
set.connect(mLayoutCreateRoom.getId(), ConstraintSet.BOTTOM, mLayoutRoot.getId(),
|
||||
ConstraintSet.BOTTOM,
|
||||
getResources().getDimensionPixelSize(R.dimen.tuiroomkit_create_room_margin_bottom));
|
||||
set.connect(mLayoutCreateRoom.getId(), ConstraintSet.START, ConstraintSet.PARENT_ID, ConstraintSet.START);
|
||||
set.connect(mLayoutCreateRoom.getId(), ConstraintSet.END, ConstraintSet.PARENT_ID, ConstraintSet.END);
|
||||
|
||||
set.connect(mLayoutEnterRoom.getId(), ConstraintSet.BOTTOM, mLayoutCreateRoom.getId(), ConstraintSet.TOP,
|
||||
getResources().getDimensionPixelSize(R.dimen.tuiroomkit_enter_room_margin_bottom));
|
||||
set.connect(mLayoutEnterRoom.getId(), ConstraintSet.LEFT, mLayoutCreateRoom.getId(), ConstraintSet.LEFT);
|
||||
set.connect(mLayoutEnterRoom.getId(), ConstraintSet.RIGHT, mLayoutCreateRoom.getId(), ConstraintSet.RIGHT);
|
||||
set.constrainWidth(mLayoutEnterRoom.getId(), ConstraintSet.MATCH_CONSTRAINT);
|
||||
set.constrainHeight(mLayoutEnterRoom.getId(), ConstraintSet.WRAP_CONTENT);
|
||||
set.setVerticalBias(mLayoutEnterRoom.getId(), 100f);
|
||||
|
||||
set.applyTo(mLayoutRoot);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (v.getId() == R.id.img_back) {
|
||||
finishActivity();
|
||||
} else if (v.getId() == R.id.ll_enter_room) {
|
||||
enterRoom();
|
||||
} else if (v.getId() == R.id.ll_create_room) {
|
||||
createRoom();
|
||||
} else if (v.getId() == R.id.ll_schedule_conference) {
|
||||
Intent intent = new Intent(this.getContext(), ScheduleConferenceActivity.class);
|
||||
this.getContext().startActivity(intent);
|
||||
}
|
||||
}
|
||||
|
||||
private void finishActivity() {
|
||||
if (!(mContext instanceof Activity)) {
|
||||
return;
|
||||
}
|
||||
Activity activity = (Activity) mContext;
|
||||
activity.finish();
|
||||
}
|
||||
|
||||
private void createRoom() {
|
||||
TUICore.startActivity("CreateConferenceActivity", null);
|
||||
}
|
||||
|
||||
private void enterRoom() {
|
||||
TUICore.startActivity("EnterConferenceActivity", null);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow();
|
||||
unSubscribeEvent();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNotifyUIEvent(String key, Map<String, Object> params) {
|
||||
if (TextUtils.equals(key, SCHEDULED_CONFERENCE_SUCCESS) && params != null) {
|
||||
ScheduleInviteMemberView scheduleSuccessView = new ScheduleInviteMemberView(mContext, params);
|
||||
scheduleSuccessView.show();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
package com.tencent.cloud.tuikit.roomkit.view.basic;
|
||||
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.tencent.qcloud.tuicore.ServiceInitializer;
|
||||
|
||||
public class RoomToast {
|
||||
public static void toastShortMessage(String message) {
|
||||
toastMessage(message, Toast.LENGTH_SHORT, Gravity.BOTTOM);
|
||||
}
|
||||
|
||||
public static void toastLongMessage(String message) {
|
||||
toastMessage(message, Toast.LENGTH_LONG, Gravity.BOTTOM);
|
||||
}
|
||||
|
||||
public static void toastLongMessageCenter(final String message) {
|
||||
toastMessage(message, Toast.LENGTH_LONG, Gravity.CENTER);
|
||||
}
|
||||
|
||||
public static void toastShortMessageCenter(final String message) {
|
||||
toastMessage(message, Toast.LENGTH_SHORT, Gravity.CENTER);
|
||||
}
|
||||
|
||||
private static void toastMessage(String message, int duration, int gravity) {
|
||||
Toast toast = Toast.makeText(ServiceInitializer.getAppContext(), message, duration);
|
||||
toast.setGravity(gravity, 0, 0);
|
||||
View view = toast.getView();
|
||||
if (view != null) {
|
||||
TextView textView = view.findViewById(android.R.id.message);
|
||||
if (textView != null) {
|
||||
textView.setGravity(Gravity.CENTER);
|
||||
}
|
||||
}
|
||||
toast.show();
|
||||
}
|
||||
}
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
package com.tencent.cloud.tuikit.roomkit.view.basic;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Path;
|
||||
import android.graphics.RectF;
|
||||
import android.graphics.Region;
|
||||
import android.util.AttributeSet;
|
||||
import android.widget.RelativeLayout;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
|
||||
public class RoundRelativeLayout extends RelativeLayout {
|
||||
private static final int RADIUS = 48;
|
||||
|
||||
private int mRadius;
|
||||
private RectF mRect;
|
||||
private Path mPath;
|
||||
|
||||
public RoundRelativeLayout(Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
|
||||
public RoundRelativeLayout(Context context, @Nullable AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
setWillNotDraw(false);
|
||||
mRadius = RADIUS;
|
||||
mPath = new Path();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
|
||||
super.onSizeChanged(w, h, oldw, oldh);
|
||||
mRect = new RectF(0, 0, getWidth(), getHeight());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Canvas canvas) {
|
||||
mPath.reset();
|
||||
mPath.addRoundRect(mRect, mRadius, mRadius, Path.Direction.CW);
|
||||
int saveCount = canvas.save();
|
||||
canvas.clipPath(mPath, Region.Op.INTERSECT);
|
||||
super.draw(canvas);
|
||||
canvas.restoreToCount(saveCount);
|
||||
}
|
||||
}
|
||||
|
||||
+75
@@ -0,0 +1,75 @@
|
||||
package com.tencent.cloud.tuikit.roomkit.view.basic;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.View;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.widget.SwitchCompat;
|
||||
|
||||
import com.tencent.cloud.tuikit.roomkit.R;
|
||||
|
||||
public class SwitchSettingItem extends BaseSettingItem {
|
||||
private Listener mListener;
|
||||
private ItemViewHolder mItemViewHolder;
|
||||
|
||||
public SwitchSettingItem(Context context,
|
||||
@NonNull ItemText itemText,
|
||||
Listener listener) {
|
||||
super(context, itemText);
|
||||
mItemViewHolder = new ItemViewHolder(
|
||||
mInflater.inflate(R.layout.tuiroomkit_item_setting_switch, null)
|
||||
);
|
||||
mListener = listener;
|
||||
}
|
||||
|
||||
public SwitchSettingItem setCheck(final boolean isCheck) {
|
||||
mItemViewHolder.mItemSwitch.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
mItemViewHolder.mItemSwitch.setChecked(isCheck);
|
||||
}
|
||||
});
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView() {
|
||||
if (mItemViewHolder != null) {
|
||||
return mItemViewHolder.mRootView;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void hideBottomLine() {
|
||||
mItemViewHolder.mBottomLine.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
public interface Listener {
|
||||
void onSwitchChecked(boolean isChecked);
|
||||
}
|
||||
|
||||
public class ItemViewHolder {
|
||||
public View mRootView;
|
||||
private View mBottomLine;
|
||||
private TextView mTitle;
|
||||
private SwitchCompat mItemSwitch;
|
||||
|
||||
public ItemViewHolder(@NonNull final View itemView) {
|
||||
mRootView = itemView;
|
||||
mTitle = itemView.findViewById(R.id.title);
|
||||
mTitle.setText(mItemText.title);
|
||||
mBottomLine = itemView.findViewById(R.id.bottom_line);
|
||||
mItemSwitch = itemView.findViewById(R.id.switch_item);
|
||||
mItemSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
if (mListener != null) {
|
||||
mListener.onSwitchChecked(isChecked);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
package com.tencent.cloud.tuikit.roomkit.view.basic;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.tencent.cloud.tuikit.roomkit.R;
|
||||
|
||||
public class TipToast {
|
||||
private String mMessage;
|
||||
|
||||
private int mDuration = Toast.LENGTH_SHORT;
|
||||
|
||||
private int mGravity = Gravity.TOP;
|
||||
|
||||
public static TipToast build() {
|
||||
TipToast toast = new TipToast();
|
||||
return toast;
|
||||
}
|
||||
|
||||
public TipToast setMessage(String message) {
|
||||
mMessage = message;
|
||||
return this;
|
||||
}
|
||||
|
||||
public TipToast setDuration(int duration) {
|
||||
mDuration = duration;
|
||||
return this;
|
||||
}
|
||||
|
||||
public TipToast setGravity(int gravity) {
|
||||
mGravity = gravity;
|
||||
return this;
|
||||
}
|
||||
|
||||
public void show(Context context) {
|
||||
View tipView = LayoutInflater.from(context).inflate(R.layout.tuiroomkit_toast_tip, null);
|
||||
TextView tvMessage = tipView.findViewById(R.id.tuiroomkit_tv_toast_tip_message);
|
||||
tvMessage.setText(mMessage);
|
||||
|
||||
Toast toast = new Toast(context.getApplicationContext());
|
||||
toast.setGravity(Gravity.CENTER_HORIZONTAL | mGravity, 0, 80);
|
||||
toast.setDuration(mDuration);
|
||||
toast.setView(tipView);
|
||||
toast.show();
|
||||
}
|
||||
}
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
package com.tencent.cloud.tuikit.roomkit.view.bridge.chat;
|
||||
|
||||
public interface AccessRoomConstants {
|
||||
|
||||
String KEY_INVITE_DATA = "KEY_INVITE_DATA";
|
||||
|
||||
String BUSINESS_ID_ROOM_MESSAGE = "group_room_message";
|
||||
|
||||
String ROOM_INVITE_SINGLING = "ROOM_INVITE_ACTION";
|
||||
|
||||
int DATA_VERSION = 1;
|
||||
|
||||
int MSG_MAX_SHOW_MEMBER_COUNT = 5;
|
||||
|
||||
enum RoomState {
|
||||
creating,
|
||||
created,
|
||||
destroying,
|
||||
destroyed
|
||||
}
|
||||
|
||||
enum SelfRoomStatus {
|
||||
NO_IN_ROOM,
|
||||
JOINING_ROOM,
|
||||
JOINED_ROOM,
|
||||
LEAVING_ROOM
|
||||
}
|
||||
|
||||
enum RoomResult {
|
||||
SUCCESS,
|
||||
FAILED
|
||||
}
|
||||
}
|
||||
+135
@@ -0,0 +1,135 @@
|
||||
package com.tencent.cloud.tuikit.roomkit.view.bridge.chat.extensions;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.AssetFileDescriptor;
|
||||
import android.media.AudioManager;
|
||||
import android.media.MediaPlayer;
|
||||
import android.os.Handler;
|
||||
import android.os.HandlerThread;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.tencent.cloud.tuikit.roomkit.R;
|
||||
import com.tencent.qcloud.tuicore.util.SPUtils;
|
||||
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class RoomBellFeature {
|
||||
private static final String PROFILE_TUIROOMKIT = "per_profile_tuiroomkit";
|
||||
private static final String PROFILE_ROOM_BELL = "per_room_bell";
|
||||
private static final String PROFILE_MUTE_MODE = "per_mute_mode";
|
||||
|
||||
private Context mContext;
|
||||
private final MediaPlayer mMediaPlayer;
|
||||
private Handler mHandler;
|
||||
private int mRoomBellResourceId = -1;
|
||||
private String mRoomBellResourcePath;
|
||||
|
||||
public RoomBellFeature(Context context) {
|
||||
mContext = context.getApplicationContext();
|
||||
mMediaPlayer = new MediaPlayer();
|
||||
}
|
||||
|
||||
public void startDialingMusic() {
|
||||
start("", R.raw.phone_ringing);
|
||||
}
|
||||
|
||||
public void startRing() {
|
||||
if (SPUtils.getInstance(PROFILE_TUIROOMKIT).getBoolean(PROFILE_MUTE_MODE, false)) {
|
||||
return;
|
||||
}
|
||||
String path = SPUtils.getInstance(PROFILE_TUIROOMKIT).getString(PROFILE_ROOM_BELL, "");
|
||||
if (TextUtils.isEmpty(path)) {
|
||||
start("", R.raw.phone_ringing);
|
||||
} else {
|
||||
start(path, -1);
|
||||
}
|
||||
}
|
||||
|
||||
public void stopMusic() {
|
||||
stop();
|
||||
}
|
||||
|
||||
private void start(String resPath, int resId) {
|
||||
preHandler();
|
||||
if (TextUtils.isEmpty(resPath) && (-1 == resId)) {
|
||||
return;
|
||||
}
|
||||
if ((-1 != resId && (mRoomBellResourceId == resId))
|
||||
|| (!TextUtils.isEmpty(resPath) && TextUtils.equals(mRoomBellResourcePath, resPath))) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!TextUtils.isEmpty(resPath) && isUrl(resPath)) {
|
||||
return;
|
||||
}
|
||||
|
||||
AssetFileDescriptor afd0 = null;
|
||||
if (!TextUtils.isEmpty(resPath) && new File(resPath).exists()) {
|
||||
mRoomBellResourcePath = resPath;
|
||||
} else if (-1 != resId) {
|
||||
mRoomBellResourceId = resId;
|
||||
afd0 = mContext.getResources().openRawResourceFd(resId);
|
||||
}
|
||||
|
||||
final AssetFileDescriptor afd = afd0;
|
||||
mHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (mMediaPlayer.isPlaying()) {
|
||||
mMediaPlayer.stop();
|
||||
}
|
||||
mMediaPlayer.reset();
|
||||
mMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
|
||||
|
||||
try {
|
||||
if (null != afd) {
|
||||
mMediaPlayer.setDataSource(afd.getFileDescriptor(), afd.getStartOffset(), afd.getLength());
|
||||
} else if (!TextUtils.isEmpty(mRoomBellResourcePath)) {
|
||||
mMediaPlayer.setDataSource(mRoomBellResourcePath);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
mMediaPlayer.setLooping(true);
|
||||
mMediaPlayer.prepare();
|
||||
mMediaPlayer.start();
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private boolean isUrl(String url) {
|
||||
return url.startsWith("http://") || url.startsWith("https://");
|
||||
}
|
||||
|
||||
private void preHandler() {
|
||||
if (null != mHandler) {
|
||||
return;
|
||||
}
|
||||
HandlerThread thread = new HandlerThread("RoomBell");
|
||||
thread.start();
|
||||
mHandler = new Handler(thread.getLooper());
|
||||
}
|
||||
|
||||
private void stop() {
|
||||
if (null == mHandler) {
|
||||
return;
|
||||
}
|
||||
|
||||
mHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (mMediaPlayer.isPlaying()) {
|
||||
mMediaPlayer.stop();
|
||||
}
|
||||
mRoomBellResourceId = -1;
|
||||
mRoomBellResourcePath = "";
|
||||
mHandler.getLooper().quit();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
package com.tencent.cloud.tuikit.roomkit.view.bridge.chat.model;
|
||||
|
||||
import com.tencent.cloud.tuikit.roomkit.view.bridge.chat.AccessRoomConstants.RoomResult;
|
||||
|
||||
public interface IRoomCallback {
|
||||
void onCreateRoom(String roomId, RoomResult result);
|
||||
|
||||
void onEnterRoom(String roomId, RoomResult result);
|
||||
|
||||
void onExitRoom(String roomId);
|
||||
|
||||
void onDestroyRoom(String roomId);
|
||||
|
||||
void onFetchUserListComplete(String roomId);
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
package com.tencent.cloud.tuikit.roomkit.view.bridge.chat.model;
|
||||
|
||||
import com.tencent.cloud.tuikit.engine.room.TUIRoomDefine;
|
||||
import com.tencent.cloud.tuikit.roomkit.view.bridge.chat.model.observer.RoomMsgData;
|
||||
|
||||
public interface IRoomManager {
|
||||
void enableAutoShowRoomMainUi(boolean enable);
|
||||
|
||||
void createRoom(String roomId, boolean isOpenMic, boolean isOpenCamera, boolean isUseSpeaker);
|
||||
|
||||
void enterRoom(String roomId, boolean isOpenMic, boolean isOpenCamera, boolean isUseSpeaker);
|
||||
|
||||
void exitRoom();
|
||||
|
||||
void destroyRoom();
|
||||
|
||||
void changeUserRole(String userId, TUIRoomDefine.Role role, TUIRoomDefine.ActionCallback callback);
|
||||
|
||||
void inviteOtherMembersToJoin(RoomMsgData roomMsgData, TUIRoomDefine.LoginUserInfo inviteUser);
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
package com.tencent.cloud.tuikit.roomkit.view.bridge.chat.model.manager;
|
||||
|
||||
import static com.tencent.cloud.tuikit.roomkit.view.bridge.chat.AccessRoomConstants.DATA_VERSION;
|
||||
import static com.tencent.cloud.tuikit.roomkit.view.bridge.chat.AccessRoomConstants.ROOM_INVITE_SINGLING;
|
||||
|
||||
import com.tencent.cloud.tuikit.engine.room.TUIRoomDefine;
|
||||
import com.tencent.cloud.tuikit.roomkit.view.bridge.chat.model.observer.RoomMsgData;
|
||||
|
||||
public class InviteJoinData {
|
||||
public String platform = "Android";
|
||||
public int version = DATA_VERSION;
|
||||
public String businessID = ROOM_INVITE_SINGLING;
|
||||
public String roomId = "";
|
||||
public String extInfo = "";
|
||||
public MyRoomData data;
|
||||
|
||||
|
||||
public InviteJoinData(RoomMsgData roomMsgData, TUIRoomDefine.LoginUserInfo inviter) {
|
||||
roomId = roomMsgData.getRoomId();
|
||||
data = new MyRoomData(roomMsgData, inviter);
|
||||
}
|
||||
|
||||
public class MyRoomData {
|
||||
public RoomMsgData roomInfo;
|
||||
public TUIRoomDefine.LoginUserInfo inviter;
|
||||
|
||||
public MyRoomData(RoomMsgData roomMsgData, TUIRoomDefine.LoginUserInfo inviter) {
|
||||
this.roomInfo = roomMsgData;
|
||||
this.inviter = inviter;
|
||||
}
|
||||
}
|
||||
}
|
||||
+81
@@ -0,0 +1,81 @@
|
||||
package com.tencent.cloud.tuikit.roomkit.view.bridge.chat.model.manager;
|
||||
|
||||
import static com.tencent.cloud.tuikit.roomkit.view.bridge.chat.AccessRoomConstants.KEY_INVITE_DATA;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.tencent.cloud.tuikit.engine.common.TUICommonDefine;
|
||||
import com.tencent.cloud.tuikit.engine.room.TUIRoomDefine;
|
||||
import com.tencent.cloud.tuikit.roomkit.TUIRoomKit;
|
||||
import com.tencent.cloud.tuikit.roomkit.view.bridge.chat.model.IRoomManager;
|
||||
import com.tencent.cloud.tuikit.roomkit.view.bridge.chat.model.observer.RoomMsgData;
|
||||
import com.tencent.cloud.tuikit.roomkit.view.bridge.chat.view.InviteToJoinRoomActivity;
|
||||
import com.tencent.cloud.tuikit.roomkit.manager.ConferenceController;
|
||||
import com.tencent.qcloud.tuicore.TUIConfig;
|
||||
import com.tencent.qcloud.tuicore.TUILogin;
|
||||
|
||||
public class RoomManagerImpl implements IRoomManager {
|
||||
private TUIRoomKit mRoomKit;
|
||||
|
||||
public RoomManagerImpl() {
|
||||
mRoomKit = TUIRoomKit.createInstance();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enableAutoShowRoomMainUi(boolean enable) {
|
||||
ConferenceController.sharedInstance(TUILogin.getAppContext()).enableAutoShowRoomMainUi(enable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createRoom(String roomId, boolean isOpenMic, boolean isOpenCamera, boolean isUseSpeaker) {
|
||||
TUIRoomDefine.RoomInfo engineRoomInfo = new TUIRoomDefine.RoomInfo();
|
||||
engineRoomInfo.roomId = roomId;
|
||||
mRoomKit.createRoom(engineRoomInfo, new TUIRoomDefine.ActionCallback() {
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
mRoomKit.enterRoom(roomId, isOpenMic, isOpenCamera, isUseSpeaker, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(TUICommonDefine.Error error, String message) {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enterRoom(String roomId, boolean isOpenMic, boolean isOpenCamera, boolean isUseSpeaker) {
|
||||
mRoomKit.enterRoom(roomId, isOpenMic, isOpenCamera, isUseSpeaker, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exitRoom() {
|
||||
ConferenceController.sharedInstance().exitRoom();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroyRoom() {
|
||||
ConferenceController.sharedInstance().destroyRoom(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void changeUserRole(String userId, TUIRoomDefine.Role role, TUIRoomDefine.ActionCallback callback) {
|
||||
ConferenceController.sharedInstance().changeUserRole(userId, role, callback);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void inviteOtherMembersToJoin(RoomMsgData roomMsgData, TUIRoomDefine.LoginUserInfo inviteUser) {
|
||||
InviteJoinData data = new InviteJoinData(roomMsgData, inviteUser);
|
||||
Gson gson = new Gson();
|
||||
String content = gson.toJson(data);
|
||||
Context context = TUIConfig.getAppContext();
|
||||
if (context == null) {
|
||||
return;
|
||||
}
|
||||
Intent intent = new Intent(context, InviteToJoinRoomActivity.class);
|
||||
intent.putExtra(KEY_INVITE_DATA, content);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
context.startActivity(intent);
|
||||
}
|
||||
}
|
||||
+247
@@ -0,0 +1,247 @@
|
||||
package com.tencent.cloud.tuikit.roomkit.view.bridge.chat.model.manager;
|
||||
|
||||
import static com.tencent.cloud.tuikit.roomkit.view.bridge.chat.AccessRoomConstants.MSG_MAX_SHOW_MEMBER_COUNT;
|
||||
import static com.tencent.cloud.tuikit.roomkit.manager.eventcenter.ConferenceEventCenter.RoomKitUIEvent.SEND_IM_MSG_COMPLETE;
|
||||
|
||||
import android.os.Handler;
|
||||
import android.os.HandlerThread;
|
||||
import android.os.Looper;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.tencent.cloud.tuikit.roomkit.view.bridge.chat.view.RoomMessageBean;
|
||||
import com.tencent.cloud.tuikit.roomkit.view.bridge.chat.model.observer.RoomMsgData;
|
||||
import com.tencent.cloud.tuikit.roomkit.manager.eventcenter.ConferenceEventCenter;
|
||||
import com.tencent.imsdk.v2.V2TIMCompleteCallback;
|
||||
import com.tencent.imsdk.v2.V2TIMCustomElem;
|
||||
import com.tencent.imsdk.v2.V2TIMManager;
|
||||
import com.tencent.imsdk.v2.V2TIMMessage;
|
||||
import com.tencent.imsdk.v2.V2TIMValueCallback;
|
||||
import com.tencent.qcloud.tuicore.TUILogin;
|
||||
import com.tencent.qcloud.tuikit.timcommon.bean.TUIMessageBean;
|
||||
import com.tencent.qcloud.tuikit.timcommon.component.interfaces.IUIKitCallback;
|
||||
import com.tencent.qcloud.tuikit.timcommon.interfaces.ChatInputMoreListener;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class RoomMsgManager {
|
||||
private static final String TAG = "RoomMsgManager";
|
||||
|
||||
private static final long WAIT_TIME_S = 10L;
|
||||
|
||||
private V2TIMMessage mIMMsg;
|
||||
private Handler mWorkHandler;
|
||||
private Handler mMainHandler;
|
||||
|
||||
private CountDownLatch mSendMsgLatch;
|
||||
private CountDownLatch mModifyMsgLatch;
|
||||
private CountDownLatch mFindMsgLatch;
|
||||
|
||||
private static WeakReference<ChatInputMoreListener> mChatInputMoreListenerRef;
|
||||
|
||||
public static void setChatInputMoreListenerRef(WeakReference<ChatInputMoreListener> ref) {
|
||||
mChatInputMoreListenerRef = ref;
|
||||
}
|
||||
|
||||
public RoomMsgManager() {
|
||||
Log.d(TAG, "new");
|
||||
HandlerThread handlerThread = new HandlerThread("RoomMsgManager-Thread");
|
||||
handlerThread.start();
|
||||
mWorkHandler = new Handler(handlerThread.getLooper());
|
||||
mMainHandler = new Handler(Looper.getMainLooper());
|
||||
}
|
||||
|
||||
public void destroyRoomMsgManager() {
|
||||
if (mWorkHandler != null) {
|
||||
Log.d(TAG, "destroy");
|
||||
mWorkHandler.getLooper().quitSafely();
|
||||
mWorkHandler = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void sendGroupRoomMessage(RoomMsgData roomMsgData) {
|
||||
if (mWorkHandler == null) {
|
||||
Log.w(TAG, "sendGroupRoomMessage mWorkHandler is null");
|
||||
return;
|
||||
}
|
||||
mWorkHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
sendGroupRoomMessageInternal(roomMsgData);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void sendGroupRoomMessageInternal(RoomMsgData roomMsgData) {
|
||||
Log.d(TAG,
|
||||
"sendGroupRoomMessage roomId=" + roomMsgData.getRoomId() + " messageId=" + roomMsgData.getMessageId());
|
||||
if (mChatInputMoreListenerRef == null) {
|
||||
Log.e(TAG, "");
|
||||
return;
|
||||
}
|
||||
final ChatInputMoreListener chatInputMoreListener = mChatInputMoreListenerRef.get();
|
||||
if (chatInputMoreListener == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
mIMMsg = V2TIMManager.getMessageManager().createCustomMessage(codeRoomMsgData(roomMsgData));
|
||||
mIMMsg.setNeedReadReceipt(true);
|
||||
|
||||
RoomMessageBean roomMessageBean = new RoomMessageBean();
|
||||
roomMessageBean.setV2TIMMessage(mIMMsg);
|
||||
Log.d(TAG, "sendMessage thread=" + Thread.currentThread().getName());
|
||||
mSendMsgLatch = new CountDownLatch(1);
|
||||
chatInputMoreListener.sendMessage(roomMessageBean, new IUIKitCallback<TUIMessageBean>() {
|
||||
@Override
|
||||
public void onSuccess(TUIMessageBean data) {
|
||||
Log.d(TAG, "sendMessage onSuccess thread=" + Thread.currentThread().getName());
|
||||
roomMsgData.setGroupId(data.getGroupId());
|
||||
roomMsgData.setMessageId(data.getV2TIMMessage().getMsgID());
|
||||
mSendMsgLatch.countDown();
|
||||
mMainHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ConferenceEventCenter.getInstance().notifyUIEvent(SEND_IM_MSG_COMPLETE, null);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String module, int errCode, String errMsg) {
|
||||
Log.e(TAG, "sendMessage onError module=" + module + " errCode=" + errCode + " errMsg=" + errMsg);
|
||||
mSendMsgLatch.countDown();
|
||||
mMainHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ConferenceEventCenter.getInstance().notifyUIEvent(SEND_IM_MSG_COMPLETE, null);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(int errCode, String errMsg, TUIMessageBean data) {
|
||||
Log.e(TAG, "sendMessage onError errCode=" + errCode + " errMsg=" + errMsg + " data=" + data);
|
||||
mSendMsgLatch.countDown();
|
||||
mMainHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ConferenceEventCenter.getInstance().notifyUIEvent(SEND_IM_MSG_COMPLETE, null);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
try {
|
||||
mSendMsgLatch.await(WAIT_TIME_S, TimeUnit.SECONDS);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void updateGroupRoomMessage(RoomMsgData msgData) {
|
||||
updateGroupRoomMessage(msgData, false);
|
||||
}
|
||||
|
||||
public void updateGroupRoomMessage(RoomMsgData msgData, boolean isForceUpdate) {
|
||||
if (mWorkHandler == null) {
|
||||
Log.w(TAG, "updateGroupRoomMessage mWorkHandler is null");
|
||||
return;
|
||||
}
|
||||
if (isNeedIgnoreMessage(msgData) && !isForceUpdate) {
|
||||
Log.e(TAG, "updateGroupRoomMessageInternal needIgnoreMessage");
|
||||
return;
|
||||
}
|
||||
Log.d(TAG, "updateGroupRoomMessage roomId=" + msgData.getRoomId() + " messageId=" + msgData.getMessageId());
|
||||
final RoomMsgData data = msgData.copy();
|
||||
mWorkHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
updateGroupRoomMessageInternal(data);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void waitUntilFindMessage(String messageId) {
|
||||
List<String> list = new ArrayList<>(1);
|
||||
list.add(messageId);
|
||||
mFindMsgLatch = new CountDownLatch(1);
|
||||
V2TIMManager.getMessageManager().findMessages(list, new V2TIMValueCallback<List<V2TIMMessage>>() {
|
||||
@Override
|
||||
public void onSuccess(List<V2TIMMessage> v2TIMMessages) {
|
||||
Log.d(TAG, "findMessages onSuccess");
|
||||
if (v2TIMMessages != null && !v2TIMMessages.isEmpty()) {
|
||||
mIMMsg = v2TIMMessages.get(0);
|
||||
}
|
||||
mFindMsgLatch.countDown();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(int i, String s) {
|
||||
Log.e(TAG, "findMessages onError i=" + i + " s=" + s);
|
||||
mFindMsgLatch.countDown();
|
||||
}
|
||||
});
|
||||
try {
|
||||
mFindMsgLatch.await(WAIT_TIME_S, TimeUnit.SECONDS);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void updateGroupRoomMessageInternal(RoomMsgData data) {
|
||||
Log.d(TAG, "updateGroupRoomMessageInternal roomId=" + data.getRoomId() + " messageId=" + data.getMessageId());
|
||||
if (mIMMsg == null) {
|
||||
waitUntilFindMessage(data.getMessageId());
|
||||
}
|
||||
final V2TIMMessage imMsg = mIMMsg;
|
||||
if (imMsg == null) {
|
||||
Log.e(TAG, "updateGroupRoomMessageInternal imMsg is null");
|
||||
return;
|
||||
}
|
||||
V2TIMCustomElem customElem = imMsg.getCustomElem();
|
||||
customElem.setData(codeRoomMsgData(data));
|
||||
|
||||
mModifyMsgLatch = new CountDownLatch(1);
|
||||
V2TIMManager.getMessageManager().modifyMessage(imMsg, new V2TIMCompleteCallback<V2TIMMessage>() {
|
||||
@Override
|
||||
public void onComplete(int i, String s, V2TIMMessage v2TIMMessage) {
|
||||
Log.d(TAG, "updateGroupRoomMessageInternal modifyMessage onComplete i=" + i + " s=" + s);
|
||||
mIMMsg = v2TIMMessage;
|
||||
mModifyMsgLatch.countDown();
|
||||
}
|
||||
});
|
||||
|
||||
try {
|
||||
mModifyMsgLatch.await(WAIT_TIME_S, TimeUnit.SECONDS);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private byte[] codeRoomMsgData(RoomMsgData data) {
|
||||
Gson gson = new Gson();
|
||||
final RoomMsgData tmpData;
|
||||
if (data.getUserList().size() > MSG_MAX_SHOW_MEMBER_COUNT) {
|
||||
tmpData = data.copy();
|
||||
tmpData.getUserList().clear();
|
||||
for (int i = 0; i < MSG_MAX_SHOW_MEMBER_COUNT; i++) {
|
||||
tmpData.getUserList().add(data.getUserList().get(i));
|
||||
}
|
||||
} else {
|
||||
tmpData = data;
|
||||
}
|
||||
tmpData.setMemberCount(data.getUserList().size());
|
||||
String content = gson.toJson(data);
|
||||
byte[] codeData = content.getBytes(StandardCharsets.UTF_8);
|
||||
return codeData;
|
||||
}
|
||||
|
||||
private boolean isNeedIgnoreMessage(RoomMsgData data) {
|
||||
return !TextUtils.equals(TUILogin.getUserId(), data.getRoomManagerId());
|
||||
}
|
||||
}
|
||||
+98
@@ -0,0 +1,98 @@
|
||||
package com.tencent.cloud.tuikit.roomkit.view.bridge.chat.model.observer;
|
||||
|
||||
import com.tencent.cloud.tuikit.roomkit.view.bridge.chat.AccessRoomConstants;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class RoomMsgData {
|
||||
private int version = AccessRoomConstants.DATA_VERSION;
|
||||
private String businessID = AccessRoomConstants.BUSINESS_ID_ROOM_MESSAGE;
|
||||
private String groupId = "";
|
||||
private String messageId = "";
|
||||
private String roomId = "";
|
||||
private String owner = "";
|
||||
private String ownerName = "";
|
||||
private AccessRoomConstants.RoomState roomState = AccessRoomConstants.RoomState.destroyed;
|
||||
private int memberCount = 0;
|
||||
private List<RoomMsgUserEntity> userList = new ArrayList<>();
|
||||
|
||||
public String getGroupId() {
|
||||
return groupId;
|
||||
}
|
||||
|
||||
public void setGroupId(String groupId) {
|
||||
this.groupId = groupId;
|
||||
}
|
||||
|
||||
public String getMessageId() {
|
||||
return messageId;
|
||||
}
|
||||
|
||||
public void setMessageId(String messageId) {
|
||||
this.messageId = messageId;
|
||||
}
|
||||
|
||||
public String getRoomId() {
|
||||
return roomId;
|
||||
}
|
||||
|
||||
public void setRoomId(String roomId) {
|
||||
this.roomId = roomId;
|
||||
}
|
||||
|
||||
public String getRoomManagerId() {
|
||||
return owner;
|
||||
}
|
||||
|
||||
public void setRoomManagerId(String roomManagerId) {
|
||||
this.owner = roomManagerId;
|
||||
}
|
||||
|
||||
public String getRoomManagerName() {
|
||||
return ownerName;
|
||||
}
|
||||
|
||||
public void setRoomManagerName(String roomManagerName) {
|
||||
this.ownerName = roomManagerName;
|
||||
}
|
||||
|
||||
public AccessRoomConstants.RoomState getRoomState() {
|
||||
return roomState;
|
||||
}
|
||||
|
||||
public void setRoomState(AccessRoomConstants.RoomState roomState) {
|
||||
this.roomState = roomState;
|
||||
}
|
||||
|
||||
public int getMemberCount() {
|
||||
return memberCount;
|
||||
}
|
||||
|
||||
public void setMemberCount(int memberCount) {
|
||||
this.memberCount = memberCount;
|
||||
}
|
||||
|
||||
public List<RoomMsgUserEntity> getUserList() {
|
||||
return userList;
|
||||
}
|
||||
|
||||
public void setUserList(List<RoomMsgUserEntity> userList) {
|
||||
this.userList = userList;
|
||||
}
|
||||
|
||||
public RoomMsgData copy() {
|
||||
RoomMsgData data = new RoomMsgData();
|
||||
data.groupId = groupId;
|
||||
data.messageId = messageId;
|
||||
data.businessID = businessID;
|
||||
data.roomId = roomId;
|
||||
data.owner = owner;
|
||||
data.ownerName = ownerName;
|
||||
data.roomState = roomState;
|
||||
for (int i = 0; i < userList.size(); i++) {
|
||||
data.userList.add(userList.get(i));
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
package com.tencent.cloud.tuikit.roomkit.view.bridge.chat.model.observer;
|
||||
|
||||
public class RoomMsgUserEntity {
|
||||
private String userId;
|
||||
private String nickName;
|
||||
private String faceUrl;
|
||||
|
||||
public RoomMsgUserEntity(String userId, String nickName, String faceUrl) {
|
||||
setUserId(userId);
|
||||
setNickName(nickName);
|
||||
setFaceUrl(faceUrl);
|
||||
}
|
||||
|
||||
public String getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(String userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public String getNickName() {
|
||||
return nickName;
|
||||
}
|
||||
|
||||
public void setNickName(String nickName) {
|
||||
this.nickName = nickName;
|
||||
}
|
||||
|
||||
public String getFaceUrl() {
|
||||
return faceUrl;
|
||||
}
|
||||
|
||||
public void setFaceUrl(String faceUrl) {
|
||||
this.faceUrl = faceUrl;
|
||||
}
|
||||
}
|
||||
+257
@@ -0,0 +1,257 @@
|
||||
package com.tencent.cloud.tuikit.roomkit.view.bridge.chat.model.observer;
|
||||
|
||||
import static com.tencent.cloud.tuikit.engine.room.TUIRoomDefine.Role.ROOM_OWNER;
|
||||
import static com.tencent.cloud.tuikit.roomkit.manager.constant.ConferenceConstant.KEY_ERROR;
|
||||
import static com.tencent.cloud.tuikit.roomkit.manager.eventcenter.ConferenceEventCenter.RoomEngineEvent.LOCAL_USER_CREATE_ROOM;
|
||||
import static com.tencent.cloud.tuikit.roomkit.manager.eventcenter.ConferenceEventCenter.RoomEngineEvent.LOCAL_USER_DESTROY_ROOM;
|
||||
import static com.tencent.cloud.tuikit.roomkit.manager.eventcenter.ConferenceEventCenter.RoomEngineEvent.LOCAL_USER_ENTER_ROOM;
|
||||
import static com.tencent.cloud.tuikit.roomkit.manager.eventcenter.ConferenceEventCenter.RoomEngineEvent.LOCAL_USER_EXIT_ROOM;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import com.tencent.cloud.tuikit.engine.common.TUICommonDefine;
|
||||
import com.tencent.cloud.tuikit.engine.room.TUIRoomDefine;
|
||||
import com.tencent.cloud.tuikit.engine.room.TUIRoomObserver;
|
||||
import com.tencent.cloud.tuikit.roomkit.view.bridge.chat.AccessRoomConstants;
|
||||
import com.tencent.cloud.tuikit.roomkit.view.bridge.chat.model.IRoomCallback;
|
||||
import com.tencent.cloud.tuikit.roomkit.view.bridge.chat.model.manager.RoomMsgManager;
|
||||
import com.tencent.cloud.tuikit.roomkit.manager.eventcenter.ConferenceEventCenter;
|
||||
import com.tencent.cloud.tuikit.roomkit.manager.ConferenceController;
|
||||
import com.tencent.qcloud.tuicore.TUILogin;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class RoomObserver extends TUIRoomObserver implements ConferenceEventCenter.RoomEngineEventResponder {
|
||||
private static final String TAG = "RoomObserver";
|
||||
private RoomMsgManager mRoomMsgManager;
|
||||
private IRoomCallback mRoomCallback;
|
||||
|
||||
private RoomMsgData mRoomMsgData;
|
||||
|
||||
public RoomObserver(IRoomCallback callback) {
|
||||
mRoomCallback = callback;
|
||||
mRoomMsgManager = new RoomMsgManager();
|
||||
}
|
||||
|
||||
public void destroyRoomObserver() {
|
||||
mRoomMsgManager.destroyRoomMsgManager();
|
||||
}
|
||||
|
||||
public void initMsgData(String roomId) {
|
||||
mRoomMsgData = new RoomMsgData();
|
||||
mRoomMsgData.setRoomId(roomId);
|
||||
mRoomMsgData.setRoomManagerId(TUILogin.getUserId());
|
||||
mRoomMsgData.setRoomManagerName(TUILogin.getNickName());
|
||||
mRoomMsgData.setRoomState(AccessRoomConstants.RoomState.creating);
|
||||
mRoomMsgManager.sendGroupRoomMessage(mRoomMsgData);
|
||||
}
|
||||
|
||||
public void setMsgData(RoomMsgData roomMsgData) {
|
||||
mRoomMsgData = roomMsgData;
|
||||
}
|
||||
|
||||
public RoomMsgData getRoomMsgData() {
|
||||
return mRoomMsgData;
|
||||
}
|
||||
|
||||
public void registerObserver() {
|
||||
ConferenceController.sharedInstance(TUILogin.getAppContext()).getRoomEngine().addObserver(this);
|
||||
ConferenceEventCenter.getInstance().subscribeEngine(LOCAL_USER_CREATE_ROOM, this);
|
||||
ConferenceEventCenter.getInstance().subscribeEngine(LOCAL_USER_ENTER_ROOM, this);
|
||||
ConferenceEventCenter.getInstance().subscribeEngine(LOCAL_USER_EXIT_ROOM, this);
|
||||
ConferenceEventCenter.getInstance().subscribeEngine(LOCAL_USER_DESTROY_ROOM, this);
|
||||
}
|
||||
|
||||
public void unregisterObserver() {
|
||||
ConferenceController.sharedInstance(TUILogin.getAppContext()).getRoomEngine().removeObserver(this);
|
||||
ConferenceEventCenter.getInstance().unsubscribeEngine(LOCAL_USER_CREATE_ROOM, this);
|
||||
ConferenceEventCenter.getInstance().unsubscribeEngine(LOCAL_USER_ENTER_ROOM, this);
|
||||
ConferenceEventCenter.getInstance().unsubscribeEngine(LOCAL_USER_EXIT_ROOM, this);
|
||||
ConferenceEventCenter.getInstance().unsubscribeEngine(LOCAL_USER_DESTROY_ROOM, this);
|
||||
}
|
||||
|
||||
public boolean isRoomOwner() {
|
||||
if (mRoomMsgData == null) {
|
||||
return false;
|
||||
}
|
||||
String selfId = TUILogin.getUserId();
|
||||
return selfId.equals(mRoomMsgData.getRoomManagerId());
|
||||
}
|
||||
|
||||
public RoomMsgUserEntity getRoomOwnerVolunteer() {
|
||||
if (mRoomMsgData == null) {
|
||||
return null;
|
||||
}
|
||||
String selfId = TUILogin.getUserId();
|
||||
for (RoomMsgUserEntity item : mRoomMsgData.getUserList()) {
|
||||
if (item.getUserId().equals(selfId)) {
|
||||
continue;
|
||||
}
|
||||
return item;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private long mNextSequence = 0L;
|
||||
|
||||
private void getUserList() {
|
||||
Log.d(TAG, "getUserList");
|
||||
mRoomMsgData.getUserList().clear();
|
||||
ConferenceController.sharedInstance(TUILogin.getAppContext()).getRoomEngine()
|
||||
.getUserList(mNextSequence, new TUIRoomDefine.GetUserListCallback() {
|
||||
@Override
|
||||
public void onSuccess(TUIRoomDefine.UserListResult userListResult) {
|
||||
Log.d(TAG, "getUserList onSuccess nextSequence=" + userListResult.nextSequence);
|
||||
mNextSequence = userListResult.nextSequence;
|
||||
addNewFreeUsers(userListResult.userInfoList);
|
||||
if (mNextSequence != 0) {
|
||||
getUserList();
|
||||
} else {
|
||||
mRoomMsgManager.updateGroupRoomMessage(mRoomMsgData);
|
||||
mRoomCallback.onFetchUserListComplete(mRoomMsgData.getRoomId());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(TUICommonDefine.Error error, String s) {
|
||||
Log.d(TAG, "getUserList onError error=" + error + " s=" + s);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void addNewFreeUsers(List<TUIRoomDefine.UserInfo> userInfoList) {
|
||||
for (TUIRoomDefine.UserInfo item : userInfoList) {
|
||||
if (addUser(item)) {
|
||||
mRoomMsgManager.updateGroupRoomMessage(mRoomMsgData);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void updateMsgForRoomStateChanged(AccessRoomConstants.RoomState state) {
|
||||
mRoomMsgData.setRoomState(state);
|
||||
mRoomMsgManager.updateGroupRoomMessage(mRoomMsgData, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUserInfoChanged(TUIRoomDefine.UserInfo userInfo, List<TUIRoomDefine.UserInfoModifyFlag> modifyFlag) {
|
||||
super.onUserInfoChanged(userInfo, modifyFlag);
|
||||
if (mRoomMsgData == null) {
|
||||
return;
|
||||
}
|
||||
Log.d(TAG, "onUserInfoChanged userId=" + userInfo.userId + " userRole=" + userInfo.userRole);
|
||||
if (userInfo.userRole == ROOM_OWNER) {
|
||||
mRoomMsgData.setRoomManagerId(userInfo.userId);
|
||||
mRoomMsgData.setRoomManagerName(TextUtils.isEmpty(userInfo.nameCard) ? userInfo.userName : userInfo.nameCard);
|
||||
mRoomMsgManager.updateGroupRoomMessage(mRoomMsgData);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRemoteUserEnterRoom(String roomId, TUIRoomDefine.UserInfo userInfo) {
|
||||
super.onRemoteUserEnterRoom(roomId, userInfo);
|
||||
Log.d(TAG, "onRemoteUserEnterRoom roomId=" + roomId + " userName=" + userInfo.userName + " userId="
|
||||
+ userInfo.userId);
|
||||
if (mRoomMsgData == null) {
|
||||
return;
|
||||
}
|
||||
if (addUser(userInfo)) {
|
||||
mRoomMsgManager.updateGroupRoomMessage(mRoomMsgData);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRemoteUserLeaveRoom(String roomId, TUIRoomDefine.UserInfo userInfo) {
|
||||
super.onRemoteUserLeaveRoom(roomId, userInfo);
|
||||
if (mRoomMsgData == null) {
|
||||
return;
|
||||
}
|
||||
Log.d(TAG, "onRemoteUserLeaveRoom roomId=" + roomId + " userName=" + userInfo.userName + " userId="
|
||||
+ userInfo.userId);
|
||||
for (RoomMsgUserEntity item : mRoomMsgData.getUserList()) {
|
||||
if (item.getUserId().equals(userInfo.userId)) {
|
||||
mRoomMsgData.getUserList().remove(item);
|
||||
break;
|
||||
}
|
||||
}
|
||||
mRoomMsgManager.updateGroupRoomMessage(mRoomMsgData);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEngineEvent(ConferenceEventCenter.RoomEngineEvent event, Map<String, Object> params) {
|
||||
Log.d(TAG, "onEngineEvent event=" + event);
|
||||
switch (event) {
|
||||
case LOCAL_USER_CREATE_ROOM:
|
||||
handleLocalUserCreateRoom(params);
|
||||
break;
|
||||
|
||||
case LOCAL_USER_ENTER_ROOM:
|
||||
handleLocalUserEnterRoom(params);
|
||||
break;
|
||||
|
||||
case LOCAL_USER_EXIT_ROOM:
|
||||
handleLocalUserExitRoom();
|
||||
break;
|
||||
|
||||
case LOCAL_USER_DESTROY_ROOM:
|
||||
handleLocalUserDestroyRoom(params);
|
||||
break;
|
||||
|
||||
default:
|
||||
Log.w(TAG, "onEngineEvent un handle event : " + event);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void handleLocalUserCreateRoom(Map<String, Object> params) {
|
||||
AccessRoomConstants.RoomResult result =
|
||||
params.get(KEY_ERROR) == TUICommonDefine.Error.SUCCESS ? AccessRoomConstants.RoomResult.SUCCESS :
|
||||
AccessRoomConstants.RoomResult.FAILED;
|
||||
Log.d(TAG, "handleLocalUserCreateRoom result=" + result);
|
||||
if (result == AccessRoomConstants.RoomResult.SUCCESS) {
|
||||
mRoomMsgData.setRoomState(AccessRoomConstants.RoomState.created);
|
||||
mRoomMsgManager.updateGroupRoomMessage(mRoomMsgData);
|
||||
} else {
|
||||
updateMsgForRoomStateChanged(AccessRoomConstants.RoomState.destroyed);
|
||||
}
|
||||
mRoomCallback.onCreateRoom(mRoomMsgData.getRoomId(), result);
|
||||
}
|
||||
|
||||
private void handleLocalUserEnterRoom(Map<String, Object> params) {
|
||||
AccessRoomConstants.RoomResult result =
|
||||
params.get(KEY_ERROR) == TUICommonDefine.Error.SUCCESS ? AccessRoomConstants.RoomResult.SUCCESS :
|
||||
AccessRoomConstants.RoomResult.FAILED;
|
||||
Log.d(TAG, "handleLocalUserEnterRoom result=" + result);
|
||||
if (result == AccessRoomConstants.RoomResult.SUCCESS) {
|
||||
getUserList();
|
||||
} else {
|
||||
updateMsgForRoomStateChanged(AccessRoomConstants.RoomState.destroyed);
|
||||
}
|
||||
mRoomCallback.onEnterRoom(mRoomMsgData.getRoomId(), result);
|
||||
}
|
||||
|
||||
private void handleLocalUserExitRoom() {
|
||||
Log.d(TAG, "handleLocalUserExitRoom");
|
||||
mRoomCallback.onExitRoom(mRoomMsgData.getRoomId());
|
||||
}
|
||||
|
||||
private void handleLocalUserDestroyRoom(Map<String, Object> params) {
|
||||
AccessRoomConstants.RoomResult result =
|
||||
params.get(KEY_ERROR) == TUICommonDefine.Error.SUCCESS ? AccessRoomConstants.RoomResult.SUCCESS :
|
||||
AccessRoomConstants.RoomResult.FAILED;
|
||||
Log.d(TAG, "handleLocalUserDestroyRoom result=" + result);
|
||||
updateMsgForRoomStateChanged(AccessRoomConstants.RoomState.destroyed);
|
||||
mRoomCallback.onDestroyRoom(mRoomMsgData.getRoomId());
|
||||
}
|
||||
|
||||
private boolean addUser(TUIRoomDefine.UserInfo user) {
|
||||
for (RoomMsgUserEntity item : mRoomMsgData.getUserList()) {
|
||||
if (TextUtils.equals(item.getUserId(), user.userId)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
mRoomMsgData.getUserList().add(new RoomMsgUserEntity(user.userId, user.userName, user.avatarUrl));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
package com.tencent.cloud.tuikit.roomkit.view.bridge.chat.presenter;
|
||||
|
||||
import com.tencent.cloud.tuikit.roomkit.view.bridge.chat.model.observer.RoomMsgData;
|
||||
|
||||
public abstract class RoomPresenter {
|
||||
|
||||
public static RoomPresenter getInstance() {
|
||||
return RoomPresenterImpl.getInstance();
|
||||
}
|
||||
|
||||
public abstract void createRoom();
|
||||
|
||||
public abstract void enterRoom(RoomMsgData roomMsgData);
|
||||
|
||||
public abstract void inviteOtherMembersToJoin(RoomMsgData roomMsgData);
|
||||
}
|
||||
+379
@@ -0,0 +1,379 @@
|
||||
package com.tencent.cloud.tuikit.roomkit.view.bridge.chat.presenter;
|
||||
|
||||
import static com.tencent.cloud.tuikit.roomkit.view.bridge.chat.AccessRoomConstants.SelfRoomStatus.JOINED_ROOM;
|
||||
import static com.tencent.cloud.tuikit.roomkit.view.bridge.chat.AccessRoomConstants.SelfRoomStatus.JOINING_ROOM;
|
||||
import static com.tencent.cloud.tuikit.roomkit.view.bridge.chat.AccessRoomConstants.SelfRoomStatus.LEAVING_ROOM;
|
||||
import static com.tencent.cloud.tuikit.roomkit.view.bridge.chat.AccessRoomConstants.SelfRoomStatus.NO_IN_ROOM;
|
||||
import static com.tencent.cloud.tuikit.roomkit.manager.eventcenter.ConferenceEventCenter.RoomKitUIEvent.SEND_IM_MSG_COMPLETE;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import com.tencent.cloud.tuikit.engine.common.TUICommonDefine;
|
||||
import com.tencent.cloud.tuikit.engine.room.TUIRoomDefine;
|
||||
import com.tencent.cloud.tuikit.roomkit.view.bridge.chat.model.manager.RoomManagerImpl;
|
||||
import com.tencent.cloud.tuikit.roomkit.view.bridge.chat.AccessRoomConstants;
|
||||
import com.tencent.cloud.tuikit.roomkit.view.bridge.chat.model.IRoomCallback;
|
||||
import com.tencent.cloud.tuikit.roomkit.view.bridge.chat.model.IRoomManager;
|
||||
import com.tencent.cloud.tuikit.roomkit.view.bridge.chat.model.observer.RoomMsgData;
|
||||
import com.tencent.cloud.tuikit.roomkit.view.bridge.chat.model.observer.RoomMsgUserEntity;
|
||||
import com.tencent.cloud.tuikit.roomkit.view.bridge.chat.model.observer.RoomObserver;
|
||||
import com.tencent.cloud.tuikit.roomkit.common.utils.BusinessSceneUtil;
|
||||
import com.tencent.cloud.tuikit.roomkit.common.utils.RoomSpUtil;
|
||||
import com.tencent.cloud.tuikit.roomkit.manager.eventcenter.ConferenceEventCenter;
|
||||
import com.tencent.cloud.tuikit.roomkit.manager.ConferenceController;
|
||||
import com.tencent.cloud.tuikit.roomkit.common.utils.FetchRoomId;
|
||||
import com.tencent.cloud.tuikit.roomkit.view.main.RoomMainActivity;
|
||||
import com.tencent.qcloud.tuicore.TUILogin;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
public class RoomPresenterImpl extends RoomPresenter implements IRoomCallback, ConferenceEventCenter.RoomKitUIEventResponder {
|
||||
private static final String TAG = "RoomPresenterImpl";
|
||||
|
||||
private static RoomPresenterImpl sRoomPresenter;
|
||||
|
||||
private static final long WAIT_TIME_S = 30L;
|
||||
private IRoomManager mRoomManager;
|
||||
private RoomObserver mRoomObserver;
|
||||
|
||||
private RoomTaskStoreHouse mRoomTaskStoreHouse;
|
||||
private AccessRoomConstants.SelfRoomStatus mSelfRoomStatus = NO_IN_ROOM;
|
||||
private final TUIRoomDefine.LoginUserInfo mSelfInfo;
|
||||
|
||||
private CountDownLatch mLeaveRoomLatch;
|
||||
private CountDownLatch mJoinRoomLatch;
|
||||
private CountDownLatch mSendMsgLatch;
|
||||
private CountDownLatch mGiveUpRoomManagerLatch;
|
||||
private AtomicBoolean mIsProcess = new AtomicBoolean(false);
|
||||
|
||||
private RoomPresenterImpl() {
|
||||
addObserver();
|
||||
mRoomManager = new RoomManagerImpl();
|
||||
mRoomTaskStoreHouse = new RoomTaskStoreHouse();
|
||||
mSelfInfo = new TUIRoomDefine.LoginUserInfo();
|
||||
mSelfInfo.userId = TUILogin.getUserId();
|
||||
mSelfInfo.userName = TUILogin.getNickName();
|
||||
mSelfInfo.avatarUrl = TUILogin.getFaceUrl();
|
||||
ConferenceEventCenter.getInstance().subscribeUIEvent(SEND_IM_MSG_COMPLETE, this);
|
||||
}
|
||||
|
||||
public static final RoomPresenterImpl getInstance() {
|
||||
if (sRoomPresenter != null) {
|
||||
return sRoomPresenter;
|
||||
}
|
||||
synchronized (RoomPresenterImpl.class) {
|
||||
if (sRoomPresenter != null) {
|
||||
return sRoomPresenter;
|
||||
}
|
||||
Log.d(TAG, "RoomPresenterImpl new");
|
||||
sRoomPresenter = new RoomPresenterImpl();
|
||||
return sRoomPresenter;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createRoom() {
|
||||
Log.d(TAG, "createRoom mSelfRoomStatus=" + mSelfRoomStatus);
|
||||
BusinessSceneUtil.setChatAccessRoom(true);
|
||||
mRoomTaskStoreHouse.postTask(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
processCreateRoom();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void processCreateRoom() {
|
||||
if (mSelfRoomStatus == JOINING_ROOM || mSelfRoomStatus == LEAVING_ROOM) {
|
||||
Log.w(TAG, "processCreateRoom in mSelfRoomStatus=" + mSelfRoomStatus);
|
||||
return;
|
||||
}
|
||||
if (mSelfRoomStatus == NO_IN_ROOM) {
|
||||
waitUntilCreateRoom();
|
||||
return;
|
||||
}
|
||||
mIsProcess.set(true);
|
||||
waitUntilExitPreRoom();
|
||||
waitUntilCreateRoom();
|
||||
mIsProcess.set(false);
|
||||
}
|
||||
|
||||
private void waitUntilExitPreRoom() {
|
||||
waitUntilGiveUpRoomOwner();
|
||||
Log.d(TAG, "waitUntilExitPreRoom");
|
||||
if (mRoomObserver.isRoomOwner()) {
|
||||
waitUntilDestroyRoom();
|
||||
} else {
|
||||
waitUntilExitRoom();
|
||||
}
|
||||
}
|
||||
|
||||
private void waitUntilExitRoom() {
|
||||
if (mRoomObserver.isRoomOwner()) {
|
||||
return;
|
||||
}
|
||||
Log.d(TAG, "waitUntilExitRoom thread=" + Thread.currentThread().getName());
|
||||
mLeaveRoomLatch = new CountDownLatch(1);
|
||||
mRoomManager.exitRoom();
|
||||
try {
|
||||
mLeaveRoomLatch.await(WAIT_TIME_S, TimeUnit.SECONDS);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
Log.d(TAG, "waitUntilExitRoom end");
|
||||
}
|
||||
|
||||
private void waitUntilDestroyRoom() {
|
||||
if (!mRoomObserver.isRoomOwner()) {
|
||||
return;
|
||||
}
|
||||
Log.d(TAG, "waitUntilDestroyRoom thread=" + Thread.currentThread().getName());
|
||||
mLeaveRoomLatch = new CountDownLatch(1);
|
||||
mRoomManager.destroyRoom();
|
||||
try {
|
||||
mLeaveRoomLatch.await(WAIT_TIME_S, TimeUnit.SECONDS);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
Log.d(TAG, "waitUntilDestroyRoom end");
|
||||
}
|
||||
|
||||
private void waitUntilGiveUpRoomOwner() {
|
||||
if (!mRoomObserver.isRoomOwner()) {
|
||||
return;
|
||||
}
|
||||
RoomMsgUserEntity roomManagerVolunteer = mRoomObserver.getRoomOwnerVolunteer();
|
||||
if (roomManagerVolunteer == null) {
|
||||
return;
|
||||
}
|
||||
Log.d(TAG, "waitUntilGiveUpRoomOwner thread name=" + Thread.currentThread().getName());
|
||||
mGiveUpRoomManagerLatch = new CountDownLatch(1);
|
||||
makeUserRoomOwner(roomManagerVolunteer.getUserId(), new TUIRoomDefine.ActionCallback() {
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
Log.d(TAG, "waitUntilGiveUpRoomOwner onSuccess thread name=" + Thread.currentThread().getName());
|
||||
mRoomObserver.getRoomMsgData().setRoomManagerId(roomManagerVolunteer.getUserId());
|
||||
mGiveUpRoomManagerLatch.countDown();
|
||||
ConferenceController.sharedInstance(TUILogin.getAppContext()).getConferenceState().userModel.changeRole(
|
||||
TUIRoomDefine.Role.GENERAL_USER);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(TUICommonDefine.Error error, String message) {
|
||||
Log.e(TAG, "waitUntilGiveUpRoomOwner onError error=" + error + " message=" + message);
|
||||
mGiveUpRoomManagerLatch.countDown();
|
||||
}
|
||||
});
|
||||
try {
|
||||
mGiveUpRoomManagerLatch.await(WAIT_TIME_S, TimeUnit.SECONDS);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void waitUntilCreateRoom() {
|
||||
mSelfRoomStatus = JOINING_ROOM;
|
||||
FetchRoomId.fetch(new FetchRoomId.GetRoomIdCallback() {
|
||||
@Override
|
||||
public void onGetRoomId(String roomId) {
|
||||
mRoomTaskStoreHouse.postTask(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
addObserver();
|
||||
mSendMsgLatch = new CountDownLatch(1);
|
||||
mRoomObserver.initMsgData(roomId);
|
||||
try {
|
||||
mSendMsgLatch.await(WAIT_TIME_S, TimeUnit.SECONDS);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
mJoinRoomLatch = new CountDownLatch(1);
|
||||
Log.d(TAG, "waitUntilCreateRoom start roomId=" + roomId);
|
||||
ConferenceController.sharedInstance().getConferenceState().setMainActivityClass(RoomMainActivity.class);
|
||||
mRoomManager.enableAutoShowRoomMainUi(false);
|
||||
boolean isOpenVideo = RoomSpUtil.getVideoSwitchFromSp();
|
||||
boolean isOpenAudio = RoomSpUtil.getAudioSwitchFromSp();
|
||||
boolean isUseSpeaker = true;
|
||||
mRoomManager.createRoom(roomId, isOpenAudio, isOpenVideo, isUseSpeaker);
|
||||
try {
|
||||
mJoinRoomLatch.await(WAIT_TIME_S, TimeUnit.SECONDS);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
mRoomManager.enableAutoShowRoomMainUi(true);
|
||||
Log.d(TAG, "waitUntilCreateRoom end");
|
||||
mSelfRoomStatus = JOINED_ROOM;
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void addObserver() {
|
||||
if (mRoomObserver == null) {
|
||||
Log.d(TAG, "addObserver");
|
||||
mRoomObserver = new RoomObserver(this);
|
||||
mRoomObserver.registerObserver();
|
||||
}
|
||||
}
|
||||
|
||||
private void removeObserver() {
|
||||
if (mRoomObserver != null) {
|
||||
Log.d(TAG, "removeObserver");
|
||||
mRoomObserver.unregisterObserver();
|
||||
mRoomObserver.destroyRoomObserver();
|
||||
mRoomObserver = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enterRoom(RoomMsgData roomMsgData) {
|
||||
Log.d(TAG, "enterRoom roomId=" + roomMsgData.getRoomId() + " messageId=" + roomMsgData.getMessageId());
|
||||
BusinessSceneUtil.setChatAccessRoom(true);
|
||||
mRoomTaskStoreHouse.postTask(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
processEnterRoom(roomMsgData);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void processEnterRoom(RoomMsgData roomMsgData) {
|
||||
Log.d(TAG, "processEnterRoom");
|
||||
if (mSelfRoomStatus == JOINING_ROOM || mSelfRoomStatus == LEAVING_ROOM) {
|
||||
Log.w(TAG, "processEnterRoom in mSelfRoomStatus=" + mSelfRoomStatus);
|
||||
return;
|
||||
}
|
||||
if (mSelfRoomStatus == NO_IN_ROOM) {
|
||||
waitUntilEnterRoom(roomMsgData);
|
||||
return;
|
||||
}
|
||||
if (isInRoom(roomMsgData)) {
|
||||
Log.d(TAG, "processEnterRoom raiseActivity");
|
||||
ConferenceController.sharedInstance(TUILogin.getAppContext()).exitFloatWindow();
|
||||
return;
|
||||
}
|
||||
mIsProcess.set(true);
|
||||
waitUntilExitPreRoom();
|
||||
waitUntilEnterRoom(roomMsgData);
|
||||
mIsProcess.set(false);
|
||||
}
|
||||
|
||||
private void waitUntilEnterRoom(RoomMsgData roomMsgData) {
|
||||
Log.d(TAG, "waitUntilEnterRoom");
|
||||
addObserver();
|
||||
mRoomObserver.setMsgData(roomMsgData);
|
||||
mJoinRoomLatch = new CountDownLatch(1);
|
||||
mSelfRoomStatus = JOINING_ROOM;
|
||||
Log.d(TAG, "waitUntilEnterRoom start");
|
||||
String roomId = roomMsgData.getRoomId();
|
||||
boolean isOpenVideo = RoomSpUtil.getVideoSwitchFromSp();
|
||||
boolean isOpenAudio = RoomSpUtil.getAudioSwitchFromSp();
|
||||
boolean isUseSpeaker = true;
|
||||
mRoomManager.enterRoom(roomId, isOpenAudio, isOpenVideo, isUseSpeaker);
|
||||
try {
|
||||
mJoinRoomLatch.await(WAIT_TIME_S, TimeUnit.SECONDS);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
Log.d(TAG, "waitUntilEnterRoom end");
|
||||
mSelfRoomStatus = JOINED_ROOM;
|
||||
}
|
||||
|
||||
private boolean isInRoom(RoomMsgData roomMsgData) {
|
||||
if (mSelfInfo.userId.equals(roomMsgData.getRoomManagerId())) {
|
||||
return true;
|
||||
}
|
||||
for (RoomMsgUserEntity item : roomMsgData.getUserList()) {
|
||||
if (mSelfInfo.userId.equals(item.getUserId())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void inviteOtherMembersToJoin(RoomMsgData roomMsgData) {
|
||||
mRoomTaskStoreHouse.postTask(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
mRoomManager.inviteOtherMembersToJoin(roomMsgData, mSelfInfo);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreateRoom(String roomId, AccessRoomConstants.RoomResult result) {
|
||||
Log.d(TAG, "onCreateRoom");
|
||||
if (result == AccessRoomConstants.RoomResult.FAILED) {
|
||||
mJoinRoomLatch.countDown();
|
||||
destroyInstance();
|
||||
return;
|
||||
}
|
||||
ConferenceController.sharedInstance(TUILogin.getAppContext()).enterFloatWindow();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnterRoom(String roomId, AccessRoomConstants.RoomResult result) {
|
||||
Log.d(TAG, "onEnterRoom");
|
||||
BusinessSceneUtil.setCurRoomId(roomId);
|
||||
if (result == AccessRoomConstants.RoomResult.FAILED) {
|
||||
mJoinRoomLatch.countDown();
|
||||
destroyInstance();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFetchUserListComplete(String roomId) {
|
||||
Log.d(TAG, "onFetchUserListComplete");
|
||||
mJoinRoomLatch.countDown();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onExitRoom(String roomId) {
|
||||
Log.d(TAG, "onExitRoom mIsProcess=" + mIsProcess.get());
|
||||
BusinessSceneUtil.setCurRoomId(null);
|
||||
if (mIsProcess.get()) {
|
||||
mLeaveRoomLatch.countDown();
|
||||
return;
|
||||
}
|
||||
destroyInstance();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyRoom(String roomId) {
|
||||
Log.d(TAG, "onDestroyRoom mIsProcess=" + mIsProcess.get());
|
||||
BusinessSceneUtil.setCurRoomId(null);
|
||||
if (mIsProcess.get()) {
|
||||
mLeaveRoomLatch.countDown();
|
||||
return;
|
||||
}
|
||||
destroyInstance();
|
||||
}
|
||||
|
||||
private void destroyInstance() {
|
||||
Log.d(TAG, "destroyInstance");
|
||||
mSelfRoomStatus = NO_IN_ROOM;
|
||||
removeObserver();
|
||||
sRoomPresenter = null;
|
||||
mRoomTaskStoreHouse.destroyRoomTaskStoreHouse();
|
||||
BusinessSceneUtil.setChatAccessRoom(false);
|
||||
ConferenceEventCenter.getInstance().unsubscribeUIEvent(SEND_IM_MSG_COMPLETE, this);
|
||||
}
|
||||
|
||||
private void makeUserRoomOwner(String userId, TUIRoomDefine.ActionCallback callback) {
|
||||
mRoomManager.changeUserRole(userId, TUIRoomDefine.Role.ROOM_OWNER, callback);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNotifyUIEvent(String key, Map<String, Object> params) {
|
||||
Log.d(TAG, "onNotifyUIEvent key=" + key);
|
||||
if (TextUtils.equals(key, SEND_IM_MSG_COMPLETE) && mSendMsgLatch != null) {
|
||||
mSendMsgLatch.countDown();
|
||||
}
|
||||
}
|
||||
}
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
package com.tencent.cloud.tuikit.roomkit.view.bridge.chat.presenter;
|
||||
|
||||
import android.os.Handler;
|
||||
import android.os.HandlerThread;
|
||||
import android.util.Log;
|
||||
|
||||
public class RoomTaskStoreHouse {
|
||||
private static final String TAG = "RoomTaskStoreHouse";
|
||||
|
||||
private Handler mWorkHandler;
|
||||
|
||||
public RoomTaskStoreHouse() {
|
||||
Log.d(TAG, "new");
|
||||
HandlerThread handlerThread = new HandlerThread("RoomTaskStoreHouse-Thread");
|
||||
handlerThread.start();
|
||||
mWorkHandler = new Handler(handlerThread.getLooper());
|
||||
}
|
||||
|
||||
public void postTask(Runnable task) {
|
||||
if (mWorkHandler == null) {
|
||||
Log.w(TAG, "postTask mWorkHandler is null");
|
||||
return;
|
||||
}
|
||||
mWorkHandler.removeCallbacksAndMessages(null);
|
||||
mWorkHandler.post(task);
|
||||
}
|
||||
|
||||
public void destroyRoomTaskStoreHouse() {
|
||||
Log.d(TAG, "destroyRoomTaskStoreHouse : " + mWorkHandler);
|
||||
if (mWorkHandler != null) {
|
||||
mWorkHandler.removeCallbacksAndMessages(null);
|
||||
mWorkHandler.getLooper().quitSafely();
|
||||
mWorkHandler = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
+67
@@ -0,0 +1,67 @@
|
||||
package com.tencent.cloud.tuikit.roomkit.view.bridge.chat.view;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.Switch;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.tencent.cloud.tuikit.roomkit.R;
|
||||
import com.tencent.cloud.tuikit.roomkit.common.utils.RoomSpUtil;
|
||||
import com.tencent.qcloud.tuikit.timcommon.component.TitleBarLayout;
|
||||
import com.tencent.qcloud.tuikit.timcommon.component.activities.BaseLightActivity;
|
||||
import com.tencent.qcloud.tuikit.timcommon.component.interfaces.ITitleBarLayout;
|
||||
|
||||
public class Chat2RoomExtensionSettingsActivity extends BaseLightActivity {
|
||||
private static final String TAG = "C2RSettingsActivity";
|
||||
|
||||
private TitleBarLayout mTitleBarLayout;
|
||||
private Switch mMicrophoneSwitch;
|
||||
private Switch mCameraSwitch;
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
Log.d(TAG, "onCreate");
|
||||
setContentView(R.layout.tuiroomkit_room_setting_layout);
|
||||
initTitleBar();
|
||||
initSettingsView();
|
||||
}
|
||||
|
||||
private void initTitleBar() {
|
||||
mTitleBarLayout = findViewById(R.id.tuiroomkit_chat_settings_top_bar);
|
||||
mTitleBarLayout.setTitle(getResources().getString(R.string.tuiroomkit_chat_access_room_extension_settings),
|
||||
ITitleBarLayout.Position.MIDDLE);
|
||||
mTitleBarLayout.getLeftGroup().setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
|
||||
mTitleBarLayout.getRightIcon().setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
private void initSettingsView() {
|
||||
mMicrophoneSwitch = findViewById(R.id.tuiroomkit_chat_settings_microphone);
|
||||
mCameraSwitch = findViewById(R.id.tuiroomkit_chat_settings_camera);
|
||||
|
||||
mMicrophoneSwitch.setChecked(RoomSpUtil.getAudioSwitchFromSp());
|
||||
mCameraSwitch.setChecked(RoomSpUtil.getVideoSwitchFromSp());
|
||||
|
||||
mMicrophoneSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
RoomSpUtil.saveAudioSwitchToSp(isChecked);
|
||||
}
|
||||
});
|
||||
mCameraSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
RoomSpUtil.saveVideoSwitchToSp(isChecked);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
+139
@@ -0,0 +1,139 @@
|
||||
package com.tencent.cloud.tuikit.roomkit.view.bridge.chat.view;
|
||||
|
||||
import static com.tencent.cloud.tuikit.roomkit.view.bridge.chat.AccessRoomConstants.KEY_INVITE_DATA;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonSyntaxException;
|
||||
import com.tencent.cloud.tuikit.roomkit.view.bridge.chat.model.manager.InviteJoinData;
|
||||
import com.tencent.cloud.tuikit.roomkit.view.bridge.chat.model.observer.RoomMsgUserEntity;
|
||||
import com.tencent.imsdk.v2.V2TIMCallback;
|
||||
import com.tencent.imsdk.v2.V2TIMManager;
|
||||
import com.tencent.qcloud.tuicore.TUIConstants;
|
||||
import com.tencent.qcloud.tuicore.TUICore;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class InviteToJoinRoomActivity extends AppCompatActivity {
|
||||
private static final String TAG = "InviteToJoinRoomAy";
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
Log.d(TAG, "onCreate");
|
||||
InviteJoinData inviteJoinData = parseData();
|
||||
if (inviteJoinData == null) {
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
|
||||
Bundle param = new Bundle();
|
||||
param.putString(TUIConstants.TUIContact.StartActivity.GroupMemberSelect.GROUP_ID,
|
||||
inviteJoinData.data.roomInfo.getGroupId());
|
||||
param.putStringArrayList(TUIConstants.TUIContact.StartActivity.GroupMemberSelect.SELECTED_LIST,
|
||||
getSelectedList(inviteJoinData));
|
||||
TUICore.startActivityForResult(this, "StartGroupMemberSelectActivity", param, result -> {
|
||||
if (result.getData() == null) {
|
||||
Log.w(TAG, "StartGroupMemberSelectActivity result is null");
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
List<String> userIds = (List<String>) result.getData()
|
||||
.getSerializableExtra(TUIConstants.TUIContact.StartActivity.GroupMemberSelect.DATA_LIST);
|
||||
inviteToJoinRoom(inviteJoinData, userIds);
|
||||
});
|
||||
}
|
||||
|
||||
private ArrayList<String> getSelectedList(InviteJoinData inviteJoinData) {
|
||||
ArrayList<String> selectedList = new ArrayList<>();
|
||||
if (inviteJoinData == null || inviteJoinData.data == null || inviteJoinData.data.roomInfo == null
|
||||
|| inviteJoinData.data.roomInfo.getUserList() == null) {
|
||||
return selectedList;
|
||||
}
|
||||
List<RoomMsgUserEntity> userList = inviteJoinData.data.roomInfo.getUserList();
|
||||
for (RoomMsgUserEntity item : userList) {
|
||||
selectedList.add(item.getUserId());
|
||||
}
|
||||
return selectedList;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
Log.d(TAG, "onStart");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
Log.d(TAG, "onResume");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
Log.d(TAG, "onPause");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
super.onStop();
|
||||
Log.d(TAG, "onStop");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
Log.d(TAG, "onDestroy");
|
||||
}
|
||||
|
||||
private InviteJoinData parseData() {
|
||||
Intent intent = getIntent();
|
||||
if (intent == null) {
|
||||
Log.e(TAG, "intent is null");
|
||||
return null;
|
||||
}
|
||||
String content = intent.getStringExtra(KEY_INVITE_DATA);
|
||||
if (TextUtils.isEmpty(content)) {
|
||||
Log.e(TAG, "content is null");
|
||||
return null;
|
||||
}
|
||||
Gson gson = new Gson();
|
||||
InviteJoinData inviteJoinData = null;
|
||||
try {
|
||||
inviteJoinData = gson.fromJson(content, InviteJoinData.class);
|
||||
} catch (JsonSyntaxException e) {
|
||||
Log.e(TAG, "parseData JsonSyntaxException");
|
||||
e.printStackTrace();
|
||||
}
|
||||
return inviteJoinData;
|
||||
}
|
||||
|
||||
private void inviteToJoinRoom(InviteJoinData inviteJoinData, List<String> invitedList) {
|
||||
Gson gson = new Gson();
|
||||
String inviteData = gson.toJson(inviteJoinData);
|
||||
V2TIMManager.getSignalingManager()
|
||||
.inviteInGroup(inviteJoinData.data.roomInfo.getGroupId(), invitedList, inviteData, true, 0,
|
||||
new V2TIMCallback() {
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
Log.d(TAG, "inviteInGroup onSuccess");
|
||||
finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(int errorCode, String errorMsg) {
|
||||
Log.e(TAG, "inviteInGroup onError errorCode=" + errorCode + " errorMsg=" + errorMsg);
|
||||
finish();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
+127
@@ -0,0 +1,127 @@
|
||||
package com.tencent.cloud.tuikit.roomkit.view.bridge.chat.view;
|
||||
|
||||
import static com.tencent.cloud.tuikit.roomkit.view.bridge.chat.AccessRoomConstants.KEY_INVITE_DATA;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.constraintlayout.utils.widget.ImageFilterButton;
|
||||
import androidx.constraintlayout.utils.widget.ImageFilterView;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonSyntaxException;
|
||||
import com.tencent.cloud.tuikit.engine.room.TUIRoomDefine;
|
||||
import com.tencent.cloud.tuikit.roomkit.R;
|
||||
import com.tencent.cloud.tuikit.roomkit.view.bridge.chat.extensions.RoomBellFeature;
|
||||
import com.tencent.cloud.tuikit.roomkit.view.bridge.chat.model.manager.InviteJoinData;
|
||||
import com.tencent.cloud.tuikit.roomkit.view.bridge.chat.presenter.RoomPresenter;
|
||||
import com.tencent.cloud.tuikit.roomkit.common.utils.ImageLoader;
|
||||
import com.tencent.qcloud.tuicore.TUILogin;
|
||||
|
||||
public class InvitedToJoinRoomActivity extends AppCompatActivity {
|
||||
private static final String TAG = "InvitedToJoinRoomAy";
|
||||
|
||||
private RoomBellFeature mRingBell;
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
Log.d(TAG, "onCreate");
|
||||
InviteJoinData inviteJoinData = parseData();
|
||||
if (inviteJoinData == null || inviteJoinData.data == null || inviteJoinData.data.inviter == null
|
||||
|| inviteJoinData.data.roomInfo == null) {
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
setContentView(R.layout.tuiroomkit_room_invited_layout);
|
||||
initView(inviteJoinData);
|
||||
mRingBell = new RoomBellFeature(this.getApplicationContext());
|
||||
mRingBell.startDialingMusic();
|
||||
}
|
||||
|
||||
private void initView(InviteJoinData inviteJoinData) {
|
||||
ImageFilterView inviterFaceIv = findViewById(R.id.tuiroomkit_invite_user_face_iv);
|
||||
TUIRoomDefine.LoginUserInfo inviter = inviteJoinData.data.inviter;
|
||||
ImageLoader.loadImage(TUILogin.getAppContext(), inviterFaceIv, inviter.avatarUrl,
|
||||
R.drawable.tuiroomkit_head);
|
||||
TextView inviterNameTv = findViewById(R.id.tuiroomkit_invite_user_name_tv);
|
||||
inviterNameTv.setText(inviter.userName);
|
||||
ImageFilterButton acceptBtn = findViewById(R.id.tuiroomkit_room_accept_invite_btn);
|
||||
acceptBtn.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Log.d(TAG, "acceptBtn onClick");
|
||||
RoomPresenter.getInstance().enterRoom(inviteJoinData.data.roomInfo);
|
||||
finish();
|
||||
}
|
||||
});
|
||||
ImageFilterButton rejectBtn = findViewById(R.id.tuiroomkit_room_reject_invite_btn);
|
||||
rejectBtn.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Log.d(TAG, "rejectBtn onClick");
|
||||
finish();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private InviteJoinData parseData() {
|
||||
Intent intent = getIntent();
|
||||
if (intent == null) {
|
||||
Log.e(TAG, "intent is null");
|
||||
return null;
|
||||
}
|
||||
String content = intent.getStringExtra(KEY_INVITE_DATA);
|
||||
if (TextUtils.isEmpty(content)) {
|
||||
Log.e(TAG, "content is null");
|
||||
return null;
|
||||
}
|
||||
Gson gson = new Gson();
|
||||
InviteJoinData inviteJoinData = null;
|
||||
try {
|
||||
inviteJoinData = gson.fromJson(content, InviteJoinData.class);
|
||||
} catch (JsonSyntaxException e) {
|
||||
Log.e(TAG, "parseData JsonSyntaxException");
|
||||
e.printStackTrace();
|
||||
}
|
||||
return inviteJoinData;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
Log.d(TAG, "onStart");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
Log.d(TAG, "onResume");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
Log.d(TAG, "onPause");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
super.onStop();
|
||||
Log.d(TAG, "onStop");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
Log.d(TAG, "onDestroy");
|
||||
mRingBell.stopMusic();
|
||||
mRingBell = null;
|
||||
}
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
package com.tencent.cloud.tuikit.roomkit.view.bridge.chat.view;
|
||||
|
||||
import com.tencent.cloud.tuikit.roomkit.R;
|
||||
import com.tencent.cloud.tuikit.roomkit.view.bridge.chat.presenter.RoomPresenter;
|
||||
import com.tencent.cloud.tuikit.roomkit.common.utils.BusinessSceneUtil;
|
||||
import com.tencent.cloud.tuikit.roomkit.view.basic.RoomToast;
|
||||
import com.tencent.qcloud.tuicore.TUILogin;
|
||||
import com.tencent.qcloud.tuicore.interfaces.TUIExtensionEventListener;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class RoomClickListener extends TUIExtensionEventListener {
|
||||
@Override
|
||||
public void onClicked(Map<String, Object> param) {
|
||||
if (BusinessSceneUtil.canJoinRoom()) {
|
||||
RoomPresenter.getInstance().createRoom();
|
||||
} else {
|
||||
RoomToast.toastLongMessage(
|
||||
TUILogin.getAppContext().getResources().getString(R.string.tuiroomkit_can_not_join_room_tip));
|
||||
}
|
||||
}
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
package com.tencent.cloud.tuikit.roomkit.view.bridge.chat.view;
|
||||
|
||||
import com.tencent.cloud.tuikit.roomkit.R;
|
||||
import com.tencent.imsdk.v2.V2TIMMessage;
|
||||
import com.tencent.qcloud.tuicore.TUILogin;
|
||||
import com.tencent.qcloud.tuikit.timcommon.bean.TUIMessageBean;
|
||||
|
||||
public class RoomMessageBean extends TUIMessageBean {
|
||||
public String mDisPlayStr;
|
||||
|
||||
@Override
|
||||
public String onGetDisplayString() {
|
||||
return mDisPlayStr;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onProcessMessage(V2TIMMessage v2TIMMessage) {
|
||||
mDisPlayStr = v2TIMMessage.getNickName() + TUILogin.getAppContext()
|
||||
.getString(R.string.tuiroomkit_room_msg_display_suffix);
|
||||
}
|
||||
}
|
||||
+257
@@ -0,0 +1,257 @@
|
||||
package com.tencent.cloud.tuikit.roomkit.view.bridge.chat.view;
|
||||
|
||||
import static com.tencent.cloud.tuikit.roomkit.view.bridge.chat.AccessRoomConstants.MSG_MAX_SHOW_MEMBER_COUNT;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.constraintlayout.utils.widget.ImageFilterButton;
|
||||
import androidx.constraintlayout.utils.widget.ImageFilterView;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonSyntaxException;
|
||||
import com.tencent.cloud.tuikit.roomkit.R;
|
||||
import com.tencent.cloud.tuikit.roomkit.view.bridge.chat.AccessRoomConstants;
|
||||
import com.tencent.cloud.tuikit.roomkit.view.bridge.chat.model.observer.RoomMsgData;
|
||||
import com.tencent.cloud.tuikit.roomkit.view.bridge.chat.model.observer.RoomMsgUserEntity;
|
||||
import com.tencent.cloud.tuikit.roomkit.view.bridge.chat.presenter.RoomPresenter;
|
||||
import com.tencent.cloud.tuikit.roomkit.common.utils.BusinessSceneUtil;
|
||||
import com.tencent.cloud.tuikit.roomkit.common.utils.ImageLoader;
|
||||
import com.tencent.cloud.tuikit.roomkit.view.basic.RoomToast;
|
||||
import com.tencent.imsdk.v2.V2TIMCustomElem;
|
||||
import com.tencent.imsdk.v2.V2TIMMessage;
|
||||
import com.tencent.qcloud.tuicore.TUILogin;
|
||||
import com.tencent.qcloud.tuikit.timcommon.bean.TUIMessageBean;
|
||||
import com.tencent.qcloud.tuikit.timcommon.classicui.widget.message.MessageContentHolder;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.List;
|
||||
|
||||
public class RoomMessageHolder extends MessageContentHolder {
|
||||
private static final String TAG = "RoomMessageHolder";
|
||||
|
||||
private ImageView mTitleIconIv;
|
||||
private TextView mTitleTv;
|
||||
private TextView mManagerTv;
|
||||
|
||||
private ImageFilterView[] mUserListFaceView;
|
||||
private TextView mMoreMemberTv;
|
||||
private ImageFilterButton mInviteBtn;
|
||||
|
||||
private TextView mRoomStateTv;
|
||||
private ProgressBar mRoomCreatingPb;
|
||||
private TextView mJoinedMembersTv;
|
||||
private TextView mJoinBtn;
|
||||
private ImageFilterButton mFullJoinBtn;
|
||||
|
||||
private RoomMsgData mRoomMsgData;
|
||||
|
||||
public RoomMessageHolder(View itemView) {
|
||||
super(itemView);
|
||||
|
||||
mTitleIconIv = itemView.findViewById(R.id.tuiroomkit_room_msg_title_icon_iv);
|
||||
mTitleTv = itemView.findViewById(R.id.tuiroomkit_room_msg_title_tv);
|
||||
mManagerTv = itemView.findViewById(R.id.tuiroomkit_room_msg_manager_tv);
|
||||
|
||||
mUserListFaceView = new ImageFilterView[]{
|
||||
itemView.findViewById(R.id.tuiroomkit_room_msg_joined_first_iv),
|
||||
itemView.findViewById(R.id.tuiroomkit_room_msg_joined_second_iv),
|
||||
itemView.findViewById(R.id.tuiroomkit_room_msg_joined_third_iv),
|
||||
itemView.findViewById(R.id.tuiroomkit_room_msg_joined_fourth_iv),
|
||||
itemView.findViewById(R.id.tuiroomkit_room_msg_joined_fifth_iv)};
|
||||
|
||||
mMoreMemberTv = itemView.findViewById(R.id.tuiroomkit_room_msg_joined_more_tv);
|
||||
mInviteBtn = itemView.findViewById(R.id.tuiroomkit_room_msg_invite_btn);
|
||||
mInviteBtn.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (mRoomMsgData == null) {
|
||||
Log.e(TAG, "mInviteBtn onTouch mRoomMsgData is null");
|
||||
return;
|
||||
}
|
||||
Log.d(TAG, "mInviteBtn onTouch userId=" + TUILogin.getUserId() + " userName=" + TUILogin.getNickName());
|
||||
RoomPresenter.getInstance().inviteOtherMembersToJoin(mRoomMsgData);
|
||||
}
|
||||
});
|
||||
|
||||
mRoomStateTv = itemView.findViewById(R.id.tuiroomkit_room_msg_room_state_tv);
|
||||
mRoomCreatingPb = itemView.findViewById(R.id.tuiroomkit_room_msg_creating_pb);
|
||||
mJoinedMembersTv = itemView.findViewById(R.id.tuiroomkit_room_msg_joined_members_tv);
|
||||
mJoinBtn = itemView.findViewById(R.id.tuiroomkit_room_msg_join_btn);
|
||||
mFullJoinBtn = itemView.findViewById(R.id.tuiroomkit_room_msg_full_join_btn);
|
||||
mFullJoinBtn.setOnClickListener(v -> {
|
||||
if (mRoomMsgData == null) {
|
||||
Log.e(TAG, "mFullJoinBtn onClick mRoomMsgData is null");
|
||||
return;
|
||||
}
|
||||
Log.d(TAG, "mFullJoinBtn onclick userId=" + TUILogin.getUserId() + " userName=" + TUILogin.getNickName());
|
||||
if (BusinessSceneUtil.canJoinRoom()) {
|
||||
RoomPresenter.getInstance().enterRoom(mRoomMsgData);
|
||||
} else {
|
||||
RoomToast.toastLongMessage(
|
||||
TUILogin.getAppContext().getResources().getString(R.string.tuiroomkit_can_not_join_room_tip));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getVariableLayout() {
|
||||
return R.layout.tuiroomkit_room_msg_layout;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void layoutVariableViews(TUIMessageBean msg, int position) {
|
||||
msgArea.setBackgroundResource(android.R.color.transparent);
|
||||
if (!parseMessage(msg)) {
|
||||
return;
|
||||
}
|
||||
updateMessageView();
|
||||
}
|
||||
|
||||
private void updateMessageView() {
|
||||
if (mRoomMsgData == null) {
|
||||
Log.w(TAG, "updateMessageView mRoomMsgData is null");
|
||||
return;
|
||||
}
|
||||
updateRoomStateView(mRoomMsgData);
|
||||
updateRoomManagerView(mRoomMsgData);
|
||||
updateJoinedMembersView(mRoomMsgData);
|
||||
updateInviteView(mRoomMsgData);
|
||||
updateRoomMsgBottomView(mRoomMsgData);
|
||||
}
|
||||
|
||||
private void updateRoomStateView(RoomMsgData roomMsgData) {
|
||||
AccessRoomConstants.RoomState roomState = roomMsgData.getRoomState();
|
||||
switch (roomState) {
|
||||
case creating:
|
||||
mTitleIconIv.setBackgroundResource(R.drawable.tuiroomkit_room_msg_icon_creating);
|
||||
mTitleTv.setText(R.string.tuiroomkit_room_msg_meeting);
|
||||
mTitleTv.setTextColor(
|
||||
TUILogin.getAppContext().getResources().getColor(R.color.tuiroomkit_room_msg_title_creating));
|
||||
break;
|
||||
|
||||
case created:
|
||||
mTitleIconIv.setBackgroundResource(R.drawable.tuiroomkit_room_msg_icon_during);
|
||||
mTitleTv.setText(R.string.tuiroomkit_room_msg_meeting_in_progress);
|
||||
mTitleTv.setTextColor(
|
||||
TUILogin.getAppContext().getResources().getColor(R.color.tuiroomkit_room_msg_title_created));
|
||||
break;
|
||||
|
||||
default:
|
||||
mTitleIconIv.setBackgroundResource(R.drawable.tuiroomkit_room_msg_icon_destroyed);
|
||||
mTitleTv.setText(R.string.tuiroomkit_room_msg_meeting);
|
||||
mTitleTv.setTextColor(
|
||||
TUILogin.getAppContext().getResources().getColor(R.color.tuiroomkit_room_msg_title_destroyed));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void updateRoomManagerView(RoomMsgData roomMsgData) {
|
||||
String roomManagerName = roomMsgData.getRoomManagerName();
|
||||
mManagerTv.setText(roomManagerName + TUILogin.getAppContext().getResources()
|
||||
.getString(R.string.tuiroomkit_room_msg_display_suffix));
|
||||
}
|
||||
|
||||
private void updateJoinedMembersView(RoomMsgData roomMsgData) {
|
||||
List<RoomMsgUserEntity> users = roomMsgData.getUserList();
|
||||
for (int i = 0; i < MSG_MAX_SHOW_MEMBER_COUNT; i++) {
|
||||
if (i < users.size()) {
|
||||
mUserListFaceView[i].setVisibility(View.VISIBLE);
|
||||
ImageLoader.loadImage(TUILogin.getAppContext(), mUserListFaceView[i], users.get(i).getFaceUrl(),
|
||||
R.drawable.tuiroomkit_head);
|
||||
continue;
|
||||
}
|
||||
mUserListFaceView[i].setVisibility(View.GONE);
|
||||
}
|
||||
mMoreMemberTv.setVisibility(
|
||||
roomMsgData.getMemberCount() > MSG_MAX_SHOW_MEMBER_COUNT ? View.VISIBLE : View.GONE);
|
||||
}
|
||||
|
||||
private void updateInviteView(RoomMsgData roomMsgData) {
|
||||
String roomManagerId = roomMsgData.getRoomManagerId();
|
||||
mInviteBtn.setVisibility(TUILogin.getUserId().equals(roomManagerId) ? View.VISIBLE : View.GONE);
|
||||
AccessRoomConstants.RoomState roomState = roomMsgData.getRoomState();
|
||||
mInviteBtn.setEnabled(roomState != AccessRoomConstants.RoomState.creating
|
||||
&& roomState != AccessRoomConstants.RoomState.destroyed);
|
||||
}
|
||||
|
||||
private void updateRoomMsgBottomView(RoomMsgData roomMsgData) {
|
||||
AccessRoomConstants.RoomState roomState = roomMsgData.getRoomState();
|
||||
if (roomState == AccessRoomConstants.RoomState.creating) {
|
||||
mRoomStateTv.setVisibility(View.VISIBLE);
|
||||
mRoomCreatingPb.setVisibility(View.VISIBLE);
|
||||
mJoinedMembersTv.setVisibility(View.GONE);
|
||||
mJoinBtn.setVisibility(View.GONE);
|
||||
mFullJoinBtn.setEnabled(false);
|
||||
mRoomStateTv.setText(R.string.tuiroomkit_chat_access_room_creating);
|
||||
return;
|
||||
}
|
||||
if (roomState == AccessRoomConstants.RoomState.destroyed) {
|
||||
mRoomStateTv.setVisibility(View.VISIBLE);
|
||||
mRoomCreatingPb.setVisibility(View.GONE);
|
||||
mJoinedMembersTv.setVisibility(View.GONE);
|
||||
mJoinBtn.setVisibility(View.GONE);
|
||||
mFullJoinBtn.setEnabled(false);
|
||||
mRoomStateTv.setText(R.string.tuiroomkit_chat_access_room_ended);
|
||||
return;
|
||||
}
|
||||
mRoomStateTv.setVisibility(View.GONE);
|
||||
mRoomCreatingPb.setVisibility(View.GONE);
|
||||
mJoinedMembersTv.setVisibility(View.VISIBLE);
|
||||
mJoinBtn.setVisibility(View.VISIBLE);
|
||||
mFullJoinBtn.setEnabled(true);
|
||||
|
||||
mJoinedMembersTv.setText(mRoomMsgData.getMemberCount() > 1 ?
|
||||
mRoomMsgData.getMemberCount() + TUILogin.getAppContext().getResources()
|
||||
.getString(R.string.tuiroomkit_room_msg_members_has_joined) :
|
||||
TUILogin.getAppContext().getResources().getString(R.string.tuiroomkit_room_msg_waiting_for_members));
|
||||
|
||||
boolean isJoined = BusinessSceneUtil.isInTheRoom(mRoomMsgData.getRoomId());
|
||||
mJoinBtn.setText(TUILogin.getAppContext().getResources()
|
||||
.getString(isJoined ? R.string.tuiroomkit_room_msg_joined : R.string.tuiroomkit_room_msg_join));
|
||||
mJoinBtn.setTextColor(TUILogin.getAppContext().getResources().getColor(
|
||||
isJoined ? R.color.tuiroomkit_room_msg_btn_text_color_joined :
|
||||
R.color.tuiroomkit_room_msg_btn_text_color_join));
|
||||
mJoinBtn.setBackground(TUILogin.getAppContext().getResources().getDrawable(
|
||||
isJoined ? R.drawable.tuiroomkit_room_msg_btn_joined : R.drawable.tuiroomkit_room_msg_btn_join));
|
||||
}
|
||||
|
||||
private boolean parseMessage(TUIMessageBean msg) {
|
||||
V2TIMMessage v2TIMMessage = msg.getV2TIMMessage();
|
||||
if (v2TIMMessage == null) {
|
||||
Log.w(TAG, "parseMessage v2TIMMessage is null");
|
||||
return false;
|
||||
}
|
||||
|
||||
V2TIMCustomElem elem = v2TIMMessage.getCustomElem();
|
||||
if (elem == null) {
|
||||
Log.w(TAG, "parseMessage elem is null");
|
||||
return false;
|
||||
}
|
||||
byte[] data = elem.getData();
|
||||
if (data == null) {
|
||||
Log.w(TAG, "parseMessage data is null");
|
||||
return false;
|
||||
}
|
||||
String content = new String(data, StandardCharsets.UTF_8);
|
||||
if (TextUtils.isEmpty(content)) {
|
||||
Log.w(TAG, "parseMessage content is null");
|
||||
return false;
|
||||
}
|
||||
|
||||
Gson gson = new Gson();
|
||||
Log.d(TAG, "parseMessage content = " + content);
|
||||
try {
|
||||
mRoomMsgData = gson.fromJson(content, RoomMsgData.class);
|
||||
} catch (JsonSyntaxException e) {
|
||||
Log.e(TAG, "parseMessage : JsonSyntaxException");
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
return mRoomMsgData.getUserList() != null || mRoomMsgData.getRoomState() != null;
|
||||
}
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
package com.tencent.cloud.tuikit.roomkit.view.create;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import com.tencent.cloud.tuikit.roomkit.R;
|
||||
import com.tencent.qcloud.tuicore.interfaces.TUICallback;
|
||||
|
||||
public class CreateConferenceActivity extends AppCompatActivity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.tuiroomkit_activity_create_room);
|
||||
CreateConferenceView createRoomView = new CreateConferenceView(this);
|
||||
ViewGroup root = findViewById(R.id.ll_root_create_room);
|
||||
root.addView(createRoomView);
|
||||
createRoomView.setFinishCallback(new TUICallback() {
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(int errorCode, String errorMessage) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
}
|
||||
}
|
||||
+143
@@ -0,0 +1,143 @@
|
||||
package com.tencent.cloud.tuikit.roomkit.view.create;
|
||||
|
||||
import android.content.Context;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
|
||||
import com.tencent.cloud.tuikit.engine.common.TUICommonDefine;
|
||||
import com.tencent.cloud.tuikit.engine.room.TUIRoomDefine;
|
||||
import com.tencent.cloud.tuikit.roomkit.ConferenceDefine;
|
||||
import com.tencent.cloud.tuikit.roomkit.ConferenceSession;
|
||||
import com.tencent.cloud.tuikit.roomkit.R;
|
||||
import com.tencent.cloud.tuikit.roomkit.common.utils.FetchRoomId;
|
||||
import com.tencent.cloud.tuikit.roomkit.view.basic.RoomToast;
|
||||
import com.tencent.cloud.tuikit.roomkit.view.basic.SwitchSettingItem;
|
||||
import com.tencent.qcloud.tuicore.TUILogin;
|
||||
import com.tencent.qcloud.tuicore.interfaces.TUICallback;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class CreateConferenceView extends RelativeLayout
|
||||
implements View.OnClickListener {
|
||||
private Context mContext;
|
||||
private Toolbar mToolbar;
|
||||
private TextView mTextCreateRoom;
|
||||
private TextView mTextUserName;
|
||||
private TextView mTextRoomType;
|
||||
private LinearLayout mLayoutSettingContainer;
|
||||
private RoomTypeSelectView mRoomTypeDialog;
|
||||
private CreateConferenceViewModel mViewModel;
|
||||
|
||||
private TUICallback mFinishCallback;
|
||||
|
||||
private String mRoomId;
|
||||
|
||||
private final ConferenceDefine.ConferenceObserver mConferenceObserver = new ConferenceDefine.ConferenceObserver() {
|
||||
@Override
|
||||
public void onConferenceStarted(TUIRoomDefine.RoomInfo roomInfo, TUICommonDefine.Error error, String message) {
|
||||
if (error == TUICommonDefine.Error.SUCCESS) {
|
||||
return;
|
||||
}
|
||||
RoomToast.toastLongMessage("error=" + error + " message=" + message);
|
||||
mTextCreateRoom.setClickable(true);
|
||||
mRoomId = null;
|
||||
initData();
|
||||
}
|
||||
};
|
||||
|
||||
public CreateConferenceView(Context context) {
|
||||
super(context);
|
||||
View.inflate(context, R.layout.tuiroomkit_view_create_room, this);
|
||||
mContext = context;
|
||||
mViewModel = new CreateConferenceViewModel(mContext);
|
||||
initView();
|
||||
initData();
|
||||
}
|
||||
|
||||
public void setFinishCallback(TUICallback finishCallback) {
|
||||
mFinishCallback = finishCallback;
|
||||
}
|
||||
|
||||
private void initData() {
|
||||
String userName = TUILogin.getNickName();
|
||||
mTextUserName.setText(userName);
|
||||
FetchRoomId.fetch(new FetchRoomId.GetRoomIdCallback() {
|
||||
@Override
|
||||
public void onGetRoomId(String roomId) {
|
||||
mRoomId = roomId;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
mToolbar = findViewById(R.id.toolbar);
|
||||
mTextCreateRoom = findViewById(R.id.tv_create);
|
||||
mTextUserName = findViewById(R.id.tv_user_name);
|
||||
mTextRoomType = findViewById(R.id.tv_room_type);
|
||||
mLayoutSettingContainer = findViewById(R.id.ll_setting_container);
|
||||
mRoomTypeDialog = new RoomTypeSelectView(mContext);
|
||||
mRoomTypeDialog.setSeatEnableCallback(new RoomTypeSelectView.SeatEnableCallback() {
|
||||
@Override
|
||||
public void onSeatEnableChanged(boolean enable) {
|
||||
mViewModel.setSeatEnable(enable);
|
||||
int resId = enable ? R.string.tuiroomkit_room_raise_hand : R.string.tuiroomkit_room_free_speech;
|
||||
mTextRoomType.setText(resId);
|
||||
}
|
||||
});
|
||||
|
||||
mTextRoomType.setOnClickListener(this);
|
||||
mTextCreateRoom.setOnClickListener(this);
|
||||
mToolbar.setNavigationOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (mFinishCallback != null) {
|
||||
mFinishCallback.onSuccess();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
ArrayList<SwitchSettingItem> settingItemList = mViewModel.createSwitchSettingItemList();
|
||||
int size = settingItemList.size();
|
||||
for (int i = 0; i < size; i++) {
|
||||
SwitchSettingItem item = settingItemList.get(i);
|
||||
if (i == size - 1) {
|
||||
item.hideBottomLine();
|
||||
}
|
||||
mLayoutSettingContainer.addView(item.getView());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onAttachedToWindow() {
|
||||
super.onAttachedToWindow();
|
||||
ConferenceSession.sharedInstance().addObserver(mConferenceObserver);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow();
|
||||
ConferenceSession.sharedInstance().removeObserver(mConferenceObserver);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (view.getId() == R.id.tv_room_type) {
|
||||
if (mRoomTypeDialog == null) {
|
||||
mRoomTypeDialog = new RoomTypeSelectView(mContext);
|
||||
}
|
||||
mRoomTypeDialog.show();
|
||||
} else if (view.getId() == R.id.tv_create) {
|
||||
if (TextUtils.isEmpty(mRoomId)) {
|
||||
RoomToast.toastShortMessage(mContext.getString(R.string.tuiroomkit_tip_creating_room_id));
|
||||
return;
|
||||
}
|
||||
mViewModel.createRoom(mRoomId);
|
||||
mFinishCallback.onSuccess();
|
||||
}
|
||||
}
|
||||
}
|
||||
+99
@@ -0,0 +1,99 @@
|
||||
package com.tencent.cloud.tuikit.roomkit.view.create;
|
||||
|
||||
import static com.tencent.cloud.tuikit.roomkit.ConferenceDefine.KEY_START_CONFERENCE_PARAMS;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
||||
import com.tencent.cloud.tuikit.roomkit.ConferenceDefine;
|
||||
import com.tencent.cloud.tuikit.roomkit.ConferenceMainActivity;
|
||||
import com.tencent.cloud.tuikit.roomkit.R;
|
||||
import com.tencent.cloud.tuikit.roomkit.view.basic.BaseSettingItem;
|
||||
import com.tencent.cloud.tuikit.roomkit.view.basic.SwitchSettingItem;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class CreateConferenceViewModel {
|
||||
private static final String TAG = "CreateRoomViewModel";
|
||||
|
||||
private Context mContext;
|
||||
|
||||
private boolean mIsOpenVideo = true;
|
||||
private boolean mIsOpenAudio = true;
|
||||
private boolean mIsUseSpeaker = true;
|
||||
|
||||
private boolean mIsSeatEnabled;
|
||||
|
||||
public CreateConferenceViewModel(Context context) {
|
||||
mContext = context;
|
||||
}
|
||||
|
||||
public void setSeatEnable(boolean enable) {
|
||||
mIsSeatEnabled = enable;
|
||||
}
|
||||
|
||||
public void createRoom(String conferenceId) {
|
||||
ConferenceDefine.StartConferenceParams params = new ConferenceDefine.StartConferenceParams(conferenceId);
|
||||
params.isSeatEnabled = mIsSeatEnabled;
|
||||
params.isOpenMicrophone = mIsOpenAudio;
|
||||
params.isOpenCamera = mIsOpenVideo;
|
||||
params.isOpenSpeaker = mIsUseSpeaker;
|
||||
Intent intent = new Intent(mContext, ConferenceMainActivity.class);
|
||||
intent.putExtra(KEY_START_CONFERENCE_PARAMS, params);
|
||||
mContext.startActivity(intent);
|
||||
}
|
||||
|
||||
private String truncateString(String string) {
|
||||
int length = string.getBytes(StandardCharsets.UTF_8).length;
|
||||
if (length <= 30) {
|
||||
return string;
|
||||
} else {
|
||||
int byteLen = 0;
|
||||
StringBuilder result = new StringBuilder();
|
||||
for (char c : string.toCharArray()) {
|
||||
byteLen += String.valueOf(c).getBytes(StandardCharsets.UTF_8).length;
|
||||
if (byteLen > 30) {
|
||||
break;
|
||||
}
|
||||
result.append(c);
|
||||
}
|
||||
return result.toString();
|
||||
}
|
||||
}
|
||||
|
||||
public ArrayList<SwitchSettingItem> createSwitchSettingItemList() {
|
||||
BaseSettingItem.ItemText audioItemText =
|
||||
new BaseSettingItem.ItemText(mContext.getString(R.string.tuiroomkit_turn_on_audio), "");
|
||||
SwitchSettingItem audioItem = new SwitchSettingItem(mContext, audioItemText, new SwitchSettingItem.Listener() {
|
||||
@Override
|
||||
public void onSwitchChecked(boolean isChecked) {
|
||||
mIsOpenAudio = isChecked;
|
||||
}
|
||||
}).setCheck(mIsOpenAudio);
|
||||
ArrayList<SwitchSettingItem> settingItemList = new ArrayList<>();
|
||||
settingItemList.add(audioItem);
|
||||
|
||||
BaseSettingItem.ItemText speakerItemText =
|
||||
new BaseSettingItem.ItemText(mContext.getString(R.string.tuiroomkit_turn_on_speaker), "");
|
||||
SwitchSettingItem speakerItem =
|
||||
new SwitchSettingItem(mContext, speakerItemText, new SwitchSettingItem.Listener() {
|
||||
@Override
|
||||
public void onSwitchChecked(boolean isChecked) {
|
||||
mIsUseSpeaker = isChecked;
|
||||
}
|
||||
}).setCheck(mIsUseSpeaker);
|
||||
settingItemList.add(speakerItem);
|
||||
|
||||
BaseSettingItem.ItemText videoItemText =
|
||||
new BaseSettingItem.ItemText(mContext.getString(R.string.tuiroomkit_turn_on_video), "");
|
||||
SwitchSettingItem videoItem = new SwitchSettingItem(mContext, videoItemText, new SwitchSettingItem.Listener() {
|
||||
@Override
|
||||
public void onSwitchChecked(boolean isChecked) {
|
||||
mIsOpenVideo = isChecked;
|
||||
}
|
||||
}).setCheck(mIsOpenVideo);
|
||||
settingItemList.add(videoItem);
|
||||
return settingItemList;
|
||||
}
|
||||
}
|
||||
+62
@@ -0,0 +1,62 @@
|
||||
package com.tencent.cloud.tuikit.roomkit.view.create;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.RadioGroup;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialog;
|
||||
import com.tencent.cloud.tuikit.roomkit.R;
|
||||
|
||||
public class RoomTypeSelectView extends BottomSheetDialog implements View.OnClickListener {
|
||||
private boolean mIsSeatEnabled;
|
||||
private Button mButtonConfirm;
|
||||
private Button mButtonCancel;
|
||||
private RadioGroup mGroupRoomType;
|
||||
|
||||
private SeatEnableCallback mSeatEnableCallback;
|
||||
|
||||
public interface SeatEnableCallback {
|
||||
void onSeatEnableChanged(boolean enable);
|
||||
}
|
||||
|
||||
public RoomTypeSelectView(@NonNull Context context) {
|
||||
super(context, R.style.TUIRoomDialogFragmentTheme);
|
||||
setContentView(R.layout.tuiroomkit_view_room_type_select);
|
||||
initView();
|
||||
}
|
||||
|
||||
public void setSeatEnableCallback(SeatEnableCallback callback) {
|
||||
mSeatEnableCallback = callback;
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
mButtonCancel = findViewById(R.id.btn_cancel);
|
||||
mButtonConfirm = findViewById(R.id.btn_confirm);
|
||||
mGroupRoomType = findViewById(R.id.rg_room_type);
|
||||
|
||||
mButtonCancel.setOnClickListener(this);
|
||||
mButtonConfirm.setOnClickListener(this);
|
||||
|
||||
mGroupRoomType.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(RadioGroup group, int checkedId) {
|
||||
mIsSeatEnabled = checkedId == R.id.rb_raise_hand;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (v.getId() == R.id.btn_cancel) {
|
||||
dismiss();
|
||||
} else if (v.getId() == R.id.btn_confirm) {
|
||||
if (mSeatEnableCallback != null) {
|
||||
mSeatEnableCallback.onSeatEnableChanged(mIsSeatEnabled);
|
||||
}
|
||||
dismiss();
|
||||
}
|
||||
}
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
package com.tencent.cloud.tuikit.roomkit.view.join;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import com.tencent.cloud.tuikit.roomkit.R;
|
||||
|
||||
public class EnterConferenceActivity extends AppCompatActivity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.tuiroomkit_activity_enter_room);
|
||||
EnterConferenceView enterRoomView = new EnterConferenceView(this);
|
||||
ViewGroup root = findViewById(R.id.ll_root_enter_room);
|
||||
root.addView(enterRoomView);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
}
|
||||
}
|
||||
+129
@@ -0,0 +1,129 @@
|
||||
package com.tencent.cloud.tuikit.roomkit.view.join;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.text.Editable;
|
||||
import android.text.TextUtils;
|
||||
import android.text.TextWatcher;
|
||||
import android.view.View;
|
||||
import android.widget.EditText;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
|
||||
import com.tencent.cloud.tuikit.engine.common.TUICommonDefine;
|
||||
import com.tencent.cloud.tuikit.engine.room.TUIRoomDefine;
|
||||
import com.tencent.cloud.tuikit.roomkit.ConferenceDefine;
|
||||
import com.tencent.cloud.tuikit.roomkit.ConferenceSession;
|
||||
import com.tencent.cloud.tuikit.roomkit.R;
|
||||
import com.tencent.cloud.tuikit.roomkit.view.basic.RoomToast;
|
||||
import com.tencent.cloud.tuikit.roomkit.view.basic.SwitchSettingItem;
|
||||
import com.tencent.qcloud.tuicore.TUILogin;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class EnterConferenceView extends RelativeLayout {
|
||||
|
||||
private Context mContext;
|
||||
private Toolbar mToolbar;
|
||||
private TextView mTextEnterRoom;
|
||||
private TextView mTextUserName;
|
||||
private EditText mTextRoomId;
|
||||
private LinearLayout mSettingContainer;
|
||||
private EnterConferenceViewModel mViewModel;
|
||||
|
||||
private final ConferenceDefine.ConferenceObserver mConferenceObserver = new ConferenceDefine.ConferenceObserver() {
|
||||
@Override
|
||||
public void onConferenceJoined(TUIRoomDefine.RoomInfo roomInfo, TUICommonDefine.Error error, String message) {
|
||||
if (error != TUICommonDefine.Error.SUCCESS) {
|
||||
mTextEnterRoom.setClickable(true);
|
||||
return;
|
||||
}
|
||||
finishActivity();
|
||||
}
|
||||
};
|
||||
|
||||
public EnterConferenceView(Context context) {
|
||||
super(context);
|
||||
View.inflate(context, R.layout.tuiroomkit_view_enter_room, this);
|
||||
mContext = context;
|
||||
mViewModel = new EnterConferenceViewModel(mContext);
|
||||
initView();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onAttachedToWindow() {
|
||||
super.onAttachedToWindow();
|
||||
ConferenceSession.sharedInstance().addObserver(mConferenceObserver);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow();
|
||||
ConferenceSession.sharedInstance().removeObserver(mConferenceObserver);
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
mToolbar = findViewById(R.id.toolbar);
|
||||
mTextRoomId = findViewById(R.id.et_room_id);
|
||||
mTextEnterRoom = findViewById(R.id.tv_enter);
|
||||
mSettingContainer = findViewById(R.id.ll_setting_container);
|
||||
mTextUserName = findViewById(R.id.tv_user_name);
|
||||
|
||||
mTextEnterRoom.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
String roomId = mTextRoomId.getText().toString();
|
||||
if (TextUtils.isEmpty(roomId)) {
|
||||
RoomToast.toastLongMessageCenter(mContext.getString(R.string.tuiroomkit_conference_name_empty));
|
||||
return;
|
||||
}
|
||||
mViewModel.enterRoom(roomId);
|
||||
}
|
||||
});
|
||||
mToolbar.setNavigationOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
finishActivity();
|
||||
}
|
||||
});
|
||||
mTextRoomId.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
mTextEnterRoom.setEnabled(!TextUtils.isEmpty(mTextRoomId.getText().toString()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
ArrayList<SwitchSettingItem> settingItemList = mViewModel.createSwitchSettingItemList();
|
||||
int size = settingItemList.size();
|
||||
for (int i = 0; i < size; i++) {
|
||||
SwitchSettingItem item = settingItemList.get(i);
|
||||
if (i == size - 1) {
|
||||
item.hideBottomLine();
|
||||
}
|
||||
mSettingContainer.addView(item.getView());
|
||||
}
|
||||
|
||||
mTextUserName.setText(TUILogin.getNickName());
|
||||
}
|
||||
|
||||
private void finishActivity() {
|
||||
if (!(mContext instanceof Activity)) {
|
||||
return;
|
||||
}
|
||||
Activity activity = (Activity) mContext;
|
||||
activity.finish();
|
||||
}
|
||||
}
|
||||
+77
@@ -0,0 +1,77 @@
|
||||
package com.tencent.cloud.tuikit.roomkit.view.join;
|
||||
|
||||
import static com.tencent.cloud.tuikit.roomkit.ConferenceDefine.KEY_JOIN_CONFERENCE_PARAMS;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.tencent.cloud.tuikit.roomkit.ConferenceDefine;
|
||||
import com.tencent.cloud.tuikit.roomkit.ConferenceMainActivity;
|
||||
import com.tencent.cloud.tuikit.roomkit.R;
|
||||
import com.tencent.cloud.tuikit.roomkit.view.basic.BaseSettingItem;
|
||||
import com.tencent.cloud.tuikit.roomkit.view.basic.SwitchSettingItem;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class EnterConferenceViewModel {
|
||||
private Context mContext;
|
||||
|
||||
private boolean mIsOpenVideo = true;
|
||||
private boolean mIsOpenAudio = true;
|
||||
private boolean mIsUseSpeaker = true;
|
||||
|
||||
public EnterConferenceViewModel(Context context) {
|
||||
mContext = context;
|
||||
}
|
||||
|
||||
public void enterRoom(String roomId) {
|
||||
if (TextUtils.isEmpty(roomId)) {
|
||||
return;
|
||||
}
|
||||
ConferenceDefine.JoinConferenceParams params = new ConferenceDefine.JoinConferenceParams(roomId);
|
||||
params.isOpenMicrophone = mIsOpenAudio;
|
||||
params.isOpenCamera = mIsOpenVideo;
|
||||
params.isOpenSpeaker = mIsUseSpeaker;
|
||||
Intent intent = new Intent(mContext, ConferenceMainActivity.class);
|
||||
intent.putExtra(KEY_JOIN_CONFERENCE_PARAMS, params);
|
||||
mContext.startActivity(intent);
|
||||
}
|
||||
|
||||
public ArrayList<SwitchSettingItem> createSwitchSettingItemList() {
|
||||
BaseSettingItem.ItemText audioItemText = new BaseSettingItem
|
||||
.ItemText(mContext.getString(R.string.tuiroomkit_turn_on_audio), "");
|
||||
SwitchSettingItem audioItem = new SwitchSettingItem(mContext, audioItemText,
|
||||
new SwitchSettingItem.Listener() {
|
||||
@Override
|
||||
public void onSwitchChecked(boolean isChecked) {
|
||||
mIsOpenAudio = isChecked;
|
||||
}
|
||||
}).setCheck(mIsOpenAudio);
|
||||
ArrayList<SwitchSettingItem> settingItemList = new ArrayList<>();
|
||||
settingItemList.add(audioItem);
|
||||
|
||||
BaseSettingItem.ItemText speakerItemText = new BaseSettingItem
|
||||
.ItemText(mContext.getString(R.string.tuiroomkit_turn_on_speaker), "");
|
||||
SwitchSettingItem speakerItem = new SwitchSettingItem(mContext, speakerItemText,
|
||||
new SwitchSettingItem.Listener() {
|
||||
@Override
|
||||
public void onSwitchChecked(boolean isChecked) {
|
||||
mIsUseSpeaker = isChecked;
|
||||
}
|
||||
}).setCheck(mIsUseSpeaker);
|
||||
settingItemList.add(speakerItem);
|
||||
|
||||
BaseSettingItem.ItemText videoItemText =
|
||||
new BaseSettingItem.ItemText(mContext.getString(R.string.tuiroomkit_turn_on_video), "");
|
||||
SwitchSettingItem videoItem = new SwitchSettingItem(mContext, videoItemText,
|
||||
new SwitchSettingItem.Listener() {
|
||||
@Override
|
||||
public void onSwitchChecked(boolean isChecked) {
|
||||
mIsOpenVideo = isChecked;
|
||||
}
|
||||
}).setCheck(mIsOpenVideo);
|
||||
settingItemList.add(videoItem);
|
||||
return settingItemList;
|
||||
}
|
||||
}
|
||||
+382
@@ -0,0 +1,382 @@
|
||||
package com.tencent.cloud.tuikit.roomkit.view.main;
|
||||
|
||||
import static com.tencent.cloud.tuikit.engine.common.TUICommonDefine.Error.SUCCESS;
|
||||
import static com.tencent.cloud.tuikit.roomkit.manager.eventcenter.ConferenceEventCenter.RoomKitUIEvent.ENTER_PIP_MODE;
|
||||
import static com.tencent.cloud.tuikit.roomkit.manager.eventcenter.ConferenceEventConstant.KEY_CONFERENCE;
|
||||
import static com.tencent.cloud.tuikit.roomkit.manager.eventcenter.ConferenceEventConstant.KEY_CONFERENCE_ERROR;
|
||||
import static com.tencent.cloud.tuikit.roomkit.manager.eventcenter.ConferenceEventConstant.KEY_CONFERENCE_INFO;
|
||||
import static com.tencent.cloud.tuikit.roomkit.manager.eventcenter.ConferenceEventConstant.KEY_CONFERENCE_JOINED;
|
||||
import static com.tencent.cloud.tuikit.roomkit.manager.eventcenter.ConferenceEventConstant.KEY_CONFERENCE_MESSAGE;
|
||||
import static com.tencent.cloud.tuikit.roomkit.manager.eventcenter.ConferenceEventConstant.KEY_CONFERENCE_STARTED;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AppOpsManager;
|
||||
import android.app.PictureInPictureParams;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Configuration;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.util.Rational;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import androidx.activity.OnBackPressedCallback;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.RequiresApi;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
|
||||
import com.tencent.cloud.tuikit.engine.common.TUICommonDefine;
|
||||
import com.tencent.cloud.tuikit.engine.room.TUIRoomDefine;
|
||||
import com.tencent.cloud.tuikit.roomkit.ConferenceDefine;
|
||||
import com.tencent.cloud.tuikit.roomkit.R;
|
||||
import com.tencent.cloud.tuikit.roomkit.view.basic.RoomToast;
|
||||
import com.tencent.cloud.tuikit.roomkit.manager.eventcenter.ConferenceEventCenter;
|
||||
import com.tencent.cloud.tuikit.roomkit.manager.ConferenceController;
|
||||
import com.tencent.cloud.tuikit.roomkit.view.main.floatwindow.videoplaying.RoomVideoFloatView;
|
||||
import com.tencent.cloud.tuikit.roomkit.view.schedule.scheduleinfo.EnterConferencePasswordView;
|
||||
import com.tencent.qcloud.tuicore.ServiceInitializer;
|
||||
import com.tencent.qcloud.tuicore.TUICore;
|
||||
import com.tencent.qcloud.tuicore.util.TUIBuild;
|
||||
import com.trtc.tuikit.common.system.ContextProvider;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class ConferenceMainFragment extends Fragment implements ConferenceEventCenter.RoomKitUIEventResponder {
|
||||
private static final String TAG = "ConferenceMainFm";
|
||||
|
||||
private FragmentActivity mActivity;
|
||||
private OnBackPressedCallback mBackPressedCallback;
|
||||
private final ConferenceMainViewModel mViewModel = new ConferenceMainViewModel(this);
|
||||
private EnterConferencePasswordView mPasswordPopView;
|
||||
|
||||
private ViewGroup mRootViewGroup;
|
||||
private RoomVideoFloatView mPipFloatView;
|
||||
private ConferenceMainView mConferenceMainView;
|
||||
private PictureInPictureParams.Builder mPictureInPictureParamsBuilder;
|
||||
|
||||
public void startConference(ConferenceDefine.StartConferenceParams startConferenceParams) {
|
||||
if (ConferenceController.sharedInstance().getRoomController().isInRoom()) {
|
||||
Log.d(TAG, "startConference already in room");
|
||||
RoomToast.toastLongMessage(ServiceInitializer.getAppContext().getString(R.string.tuiroomkit_room_msg_joined));
|
||||
return;
|
||||
}
|
||||
mViewModel.startConference(startConferenceParams, new ConferenceMainViewModel.GetConferenceInfoCallback() {
|
||||
@Override
|
||||
public void onSuccess(TUIRoomDefine.RoomInfo roomInfo) {
|
||||
Map<String, Object> param = new HashMap<>(3);
|
||||
param.put(KEY_CONFERENCE_INFO, roomInfo);
|
||||
param.put(KEY_CONFERENCE_ERROR, SUCCESS);
|
||||
param.put(KEY_CONFERENCE_MESSAGE, "");
|
||||
TUICore.notifyEvent(KEY_CONFERENCE, KEY_CONFERENCE_STARTED, param);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(TUIRoomDefine.RoomInfo roomInfo, TUICommonDefine.Error error, String message) {
|
||||
onDismiss();
|
||||
Map<String, Object> param = new HashMap<>(3);
|
||||
param.put(KEY_CONFERENCE_INFO, roomInfo);
|
||||
param.put(KEY_CONFERENCE_ERROR, error);
|
||||
param.put(KEY_CONFERENCE_MESSAGE, transErrorMessage(error, message));
|
||||
TUICore.notifyEvent(KEY_CONFERENCE, KEY_CONFERENCE_STARTED, param);
|
||||
showErrorToast(error);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void joinConference(ConferenceDefine.JoinConferenceParams joinConferenceParams) {
|
||||
if (ConferenceController.sharedInstance().getRoomController().isInRoom()) {
|
||||
Log.d(TAG, "joinConference already in room");
|
||||
RoomToast.toastLongMessage(ServiceInitializer.getAppContext().getString(R.string.tuiroomkit_room_msg_joined));
|
||||
return;
|
||||
}
|
||||
mViewModel.joinConference(joinConferenceParams, new ConferenceMainViewModel.GetConferenceInfoCallback() {
|
||||
@Override
|
||||
public void onSuccess(TUIRoomDefine.RoomInfo roomInfo) {
|
||||
Map<String, Object> param = new HashMap<>(3);
|
||||
param.put(KEY_CONFERENCE_INFO, roomInfo);
|
||||
param.put(KEY_CONFERENCE_ERROR, SUCCESS);
|
||||
param.put(KEY_CONFERENCE_MESSAGE, "");
|
||||
TUICore.notifyEvent(KEY_CONFERENCE, KEY_CONFERENCE_JOINED, param);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(TUIRoomDefine.RoomInfo roomInfo, TUICommonDefine.Error error, String message) {
|
||||
if (error == TUICommonDefine.Error.NEED_PASSWORD) {
|
||||
popEnterPasswordView(joinConferenceParams);
|
||||
} else {
|
||||
Map<String, Object> param = new HashMap<>(3);
|
||||
param.put(KEY_CONFERENCE_INFO, roomInfo);
|
||||
param.put(KEY_CONFERENCE_ERROR, error);
|
||||
param.put(KEY_CONFERENCE_MESSAGE, transErrorMessage(error, message));
|
||||
TUICore.notifyEvent(KEY_CONFERENCE, KEY_CONFERENCE_JOINED, param);
|
||||
showErrorToast(error);
|
||||
onDismiss();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void popEnterPasswordView(ConferenceDefine.JoinConferenceParams joinConferenceParams) {
|
||||
mPasswordPopView = new EnterConferencePasswordView();
|
||||
mPasswordPopView.showDialog(mActivity, null);
|
||||
mPasswordPopView.setCallback(new EnterConferencePasswordView.PasswordPopViewCallback() {
|
||||
@Override
|
||||
public void onCancel() {
|
||||
mActivity.finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConfirm(String password) {
|
||||
if (TextUtils.isEmpty(password)) {
|
||||
RoomToast.toastShortMessageCenter(getContext().getString(R.string.tuiroomkit_password_is_empty));
|
||||
return;
|
||||
}
|
||||
mPasswordPopView.enableJoinRoomButton(false);
|
||||
enterEncryptRoom(joinConferenceParams, password);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void enterEncryptRoom(ConferenceDefine.JoinConferenceParams joinConferenceParams, String password) {
|
||||
mViewModel.joinEncryptRoom(joinConferenceParams, password, new ConferenceMainViewModel.GetConferenceInfoCallback() {
|
||||
@Override
|
||||
public void onSuccess(TUIRoomDefine.RoomInfo roomInfo) {
|
||||
Map<String, Object> param = new HashMap<>(3);
|
||||
param.put(KEY_CONFERENCE_INFO, roomInfo);
|
||||
param.put(KEY_CONFERENCE_ERROR, SUCCESS);
|
||||
param.put(KEY_CONFERENCE_MESSAGE, "");
|
||||
TUICore.notifyEvent(KEY_CONFERENCE, KEY_CONFERENCE_JOINED, param);
|
||||
mPasswordPopView.dismiss();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(TUIRoomDefine.RoomInfo roomInfo, TUICommonDefine.Error error, String message) {
|
||||
if (error == TUICommonDefine.Error.WRONG_PASSWORD) {
|
||||
mPasswordPopView.enableJoinRoomButton(true);
|
||||
RoomToast.toastShortMessageCenter(getContext().getString(R.string.tuiroomkit_room_password_error));
|
||||
} else {
|
||||
Map<String, Object> param = new HashMap<>(3);
|
||||
param.put(KEY_CONFERENCE_INFO, roomInfo);
|
||||
param.put(KEY_CONFERENCE_ERROR, error);
|
||||
param.put(KEY_CONFERENCE_MESSAGE, transErrorMessage(error, message));
|
||||
TUICore.notifyEvent(KEY_CONFERENCE, KEY_CONFERENCE_JOINED, param);
|
||||
showErrorToast(error);
|
||||
onDismiss();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
|
||||
@Nullable Bundle savedInstanceState) {
|
||||
super.onCreateView(inflater, container, savedInstanceState);
|
||||
Log.d(TAG, "onCreateView : " + this);
|
||||
View view = inflater.inflate(R.layout.tuiroomkit_fragment_main_conference, container, false);
|
||||
|
||||
Activity activity = getActivity();
|
||||
if (!(activity instanceof FragmentActivity)) {
|
||||
Log.e(TAG, "A FragmentActivity or its subclass should be used to add the ConferenceMainFragment");
|
||||
return view;
|
||||
}
|
||||
mActivity = (FragmentActivity) activity;
|
||||
cacheCurrentActivity();
|
||||
|
||||
interceptBackPressed();
|
||||
keepScreenOn(true);
|
||||
ConferenceEventCenter.getInstance().subscribeUIEvent(ENTER_PIP_MODE, this);
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
mViewModel.init();
|
||||
mRootViewGroup = (ViewGroup) view;
|
||||
mConferenceMainView = new ConferenceMainView(getContext());
|
||||
mRootViewGroup.addView(mConferenceMainView);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
Log.d(TAG, "onDestroyView : " + this);
|
||||
release();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConfigurationChanged(@NonNull Configuration newConfig) {
|
||||
super.onConfigurationChanged(newConfig);
|
||||
Window window = requireActivity().getWindow();
|
||||
if (Configuration.ORIENTATION_PORTRAIT == newConfig.orientation) {
|
||||
window.clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||
} else {
|
||||
window.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||
}
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.O)
|
||||
void enterPipMode() {
|
||||
if (TUIBuild.getVersionInt() < Build.VERSION_CODES.O) {
|
||||
return;
|
||||
}
|
||||
|
||||
AppOpsManager appOps = (AppOpsManager) getContext().getSystemService(Context.APP_OPS_SERVICE);
|
||||
if (AppOpsManager.MODE_ALLOWED != appOps.checkOpNoThrow(AppOpsManager.OPSTR_PICTURE_IN_PICTURE, getContext().getApplicationInfo().uid, getContext().getPackageName())) {
|
||||
getContext().startActivity(new Intent("android.settings.PICTURE_IN_PICTURE_SETTINGS", Uri.parse("package:" + getContext().getPackageName())));
|
||||
return;
|
||||
}
|
||||
|
||||
if (mPictureInPictureParamsBuilder == null) {
|
||||
mPictureInPictureParamsBuilder = new PictureInPictureParams.Builder();
|
||||
}
|
||||
|
||||
int floatViewWidth =
|
||||
getResources().getDimensionPixelSize(R.dimen.tuiroomkit_room_video_float_view_width);
|
||||
int floatViewHeight =
|
||||
getResources().getDimensionPixelSize(R.dimen.tuiroomkit_room_video_float_view_height);
|
||||
|
||||
Rational aspectRatio = new Rational(floatViewWidth, floatViewHeight);
|
||||
mPictureInPictureParamsBuilder.setActions(new ArrayList<>());
|
||||
mPictureInPictureParamsBuilder.setAspectRatio(aspectRatio).build();
|
||||
|
||||
mActivity.enterPictureInPictureMode(mPictureInPictureParamsBuilder.build());
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.O)
|
||||
@Override
|
||||
public void onNotifyUIEvent(String key, Map<String, Object> params) {
|
||||
if (ENTER_PIP_MODE.equals(key)) {
|
||||
enterPipMode();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPictureInPictureModeChanged(boolean isInPictureInPictureMode) {
|
||||
super.onPictureInPictureModeChanged(isInPictureInPictureMode);
|
||||
ConferenceController.sharedInstance().getViewState().isInPictureInPictureMode.set(isInPictureInPictureMode);
|
||||
if (isInPictureInPictureMode) {
|
||||
mConferenceMainView.setVisibility(View.GONE);
|
||||
mPipFloatView = new RoomVideoFloatView(ContextProvider.getApplicationContext());
|
||||
mRootViewGroup.addView(mPipFloatView);
|
||||
mPipFloatView.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
mRootViewGroup.removeView(mPipFloatView);
|
||||
mConferenceMainView.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
public void onDismiss() {
|
||||
mActivity.finish();
|
||||
release();
|
||||
}
|
||||
|
||||
private void keepScreenOn(boolean keep) {
|
||||
Window window = getActivity().getWindow();
|
||||
if (keep) {
|
||||
window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
||||
} else {
|
||||
window.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
||||
}
|
||||
}
|
||||
|
||||
private void cacheCurrentActivity() {
|
||||
Activity activity = getActivity();
|
||||
if (activity == null) {
|
||||
Log.e(TAG, "cacheCurrentActivity activity is null");
|
||||
return;
|
||||
}
|
||||
mViewModel.cacheCurrentActivity(activity);
|
||||
}
|
||||
|
||||
private void interceptBackPressed() {
|
||||
mBackPressedCallback = new OnBackPressedCallback(true) {
|
||||
@Override
|
||||
public void handleOnBackPressed() {
|
||||
Log.e(TAG, "handleOnBackPressed");
|
||||
ConferenceEventCenter.getInstance().notifyUIEvent(ConferenceEventCenter.RoomKitUIEvent.SHOW_EXIT_ROOM_VIEW, null);
|
||||
}
|
||||
};
|
||||
requireActivity().getOnBackPressedDispatcher().addCallback(mBackPressedCallback);
|
||||
}
|
||||
|
||||
private void release() {
|
||||
if (mBackPressedCallback == null) {
|
||||
return;
|
||||
}
|
||||
Log.d(TAG, "release");
|
||||
mViewModel.release();
|
||||
mBackPressedCallback.remove();
|
||||
mBackPressedCallback = null;
|
||||
mActivity = null;
|
||||
mRootViewGroup.removeView(mPipFloatView);
|
||||
keepScreenOn(false);
|
||||
ConferenceEventCenter.getInstance().unsubscribeUIEvent(ENTER_PIP_MODE, this);
|
||||
}
|
||||
|
||||
private String transErrorMessage(TUICommonDefine.Error error, String message) {
|
||||
String errorMessage = "";
|
||||
switch (error) {
|
||||
case ROOM_ID_NOT_EXIST:
|
||||
errorMessage = getString(R.string.tuiroomkit_room_not_exit);
|
||||
break;
|
||||
case ROOM_ID_OCCUPIED:
|
||||
errorMessage = getString(R.string.tuiroomkit_room_id_is_occupied);
|
||||
break;
|
||||
case ROOM_USER_FULL:
|
||||
errorMessage = getString(R.string.tuiroomkit_room_is_full);
|
||||
break;
|
||||
case ROOM_NAME_INVALID:
|
||||
errorMessage = getString(R.string.tuiroomkit_room_name_is_invalid);
|
||||
break;
|
||||
case OPERATION_INVALID_BEFORE_ENTER_ROOM:
|
||||
errorMessage = getString(R.string.tuiroomkit_use_function_need_enter_room);
|
||||
break;
|
||||
case OPERATION_NOT_SUPPORTED_IN_CURRENT_ROOM_TYPE:
|
||||
errorMessage = getString(R.string.tuiroomkit_is_not_supported_in_room_type);
|
||||
break;
|
||||
case ALREADY_IN_OTHER_ROOM:
|
||||
errorMessage = getString(R.string.tuiroomkit_already_in_another_room);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (!TextUtils.isEmpty(errorMessage)) {
|
||||
Log.e(TAG, errorMessage);
|
||||
return errorMessage;
|
||||
}
|
||||
return message;
|
||||
}
|
||||
|
||||
private void showErrorToast(TUICommonDefine.Error error) {
|
||||
String errorMessage = "";
|
||||
switch (error) {
|
||||
case ROOM_ID_NOT_EXIST:
|
||||
errorMessage = getString(R.string.tuiroomkit_room_not_exit);
|
||||
break;
|
||||
case ROOM_ID_OCCUPIED:
|
||||
errorMessage = getString(R.string.tuiroomkit_room_id_is_occupied);
|
||||
break;
|
||||
case ROOM_USER_FULL:
|
||||
errorMessage = getString(R.string.tuiroomkit_room_is_full);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (!TextUtils.isEmpty(errorMessage)) {
|
||||
RoomToast.toastLongMessageCenter(errorMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
+777
@@ -0,0 +1,777 @@
|
||||
package com.tencent.cloud.tuikit.roomkit.view.main;
|
||||
|
||||
import static com.tencent.cloud.tuikit.engine.common.TUICommonDefine.Error.ALL_SEAT_OCCUPIED;
|
||||
import static com.tencent.cloud.tuikit.roomkit.manager.eventcenter.ConferenceEventCenter.RoomKitUIEvent.DISMISS_MAIN_ACTIVITY;
|
||||
import static com.tencent.cloud.tuikit.roomkit.manager.eventcenter.ConferenceEventCenter.RoomKitUIEvent.START_LOGIN;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.res.Configuration;
|
||||
import android.graphics.PixelFormat;
|
||||
import android.os.Build;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.text.TextUtils;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewParent;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.Button;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.tencent.cloud.tuikit.engine.common.TUICommonDefine;
|
||||
import com.tencent.cloud.tuikit.engine.room.TUIRoomDefine;
|
||||
import com.tencent.cloud.tuikit.roomkit.ConferenceDefine;
|
||||
import com.tencent.cloud.tuikit.roomkit.R;
|
||||
import com.tencent.cloud.tuikit.roomkit.view.basic.RoomToast;
|
||||
import com.tencent.cloud.tuikit.roomkit.manager.eventcenter.ConferenceEventCenter;
|
||||
import com.tencent.cloud.tuikit.roomkit.manager.eventcenter.ConferenceEventConstant;
|
||||
import com.tencent.cloud.tuikit.roomkit.impl.ConferenceSessionImpl;
|
||||
import com.tencent.cloud.tuikit.roomkit.state.ConferenceState;
|
||||
import com.tencent.cloud.tuikit.roomkit.state.UserState;
|
||||
import com.tencent.cloud.tuikit.roomkit.state.ViewState;
|
||||
import com.tencent.cloud.tuikit.roomkit.manager.ConferenceController;
|
||||
import com.tencent.cloud.tuikit.roomkit.view.main.bottomnavigationbar.BottomLayout;
|
||||
import com.tencent.cloud.tuikit.roomkit.view.main.exitroom.ExitRoomDialog;
|
||||
import com.tencent.cloud.tuikit.roomkit.view.main.invite.InviteDialog;
|
||||
import com.tencent.cloud.tuikit.roomkit.view.main.screensharecontrol.MoreFunctionDialog;
|
||||
import com.tencent.cloud.tuikit.roomkit.view.main.roominfo.RoomInfoDialog;
|
||||
import com.tencent.cloud.tuikit.roomkit.view.main.share.ShareRoomDialog;
|
||||
import com.tencent.cloud.tuikit.roomkit.view.main.floatchat.FloatChatView;
|
||||
import com.tencent.cloud.tuikit.roomkit.view.main.floatchat.service.IFindNameCardService;
|
||||
import com.tencent.cloud.tuikit.roomkit.view.main.localaudioindicator.LocalAudioToggleView;
|
||||
import com.tencent.cloud.tuikit.roomkit.view.main.mediasettings.MediaSettingPanel;
|
||||
import com.tencent.cloud.tuikit.roomkit.view.main.raisehandcontrolpanel.RaiseHandApplicationListPanel;
|
||||
import com.tencent.cloud.tuikit.roomkit.view.main.speechtotext.SpeechToTextSubtitleView;
|
||||
import com.tencent.cloud.tuikit.roomkit.view.main.topnavigationbar.TopView;
|
||||
import com.tencent.cloud.tuikit.roomkit.view.main.transferownercontrolpanel.TransferMasterPanel;
|
||||
import com.tencent.cloud.tuikit.roomkit.view.main.usercontrolpanel.UserListPanel;
|
||||
import com.tencent.cloud.tuikit.roomkit.view.main.watermark.TextWaterMarkView;
|
||||
import com.tencent.cloud.tuikit.roomkit.view.main.videoseat.TUIVideoSeatView;
|
||||
import com.tencent.cloud.tuikit.roomkit.view.basic.BaseDialogFragment;
|
||||
import com.tencent.cloud.tuikit.roomkit.view.basic.ConfirmDialog;
|
||||
import com.tencent.cloud.tuikit.roomkit.view.main.qrcode.QRCodeView;
|
||||
import com.tencent.cloud.tuikit.roomkit.view.basic.TipToast;
|
||||
import com.tencent.cloud.tuikit.roomkit.view.schedule.selectscheduleparticipant.ConferenceParticipants;
|
||||
import com.tencent.cloud.tuikit.roomkit.view.schedule.selectscheduleparticipant.ParticipantSelector;
|
||||
import com.trtc.tuikit.common.livedata.LiveListObserver;
|
||||
import com.trtc.tuikit.common.livedata.Observer;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class ConferenceMainView extends RelativeLayout implements IFindNameCardService {
|
||||
private static final String TAG = "ConferenceMainView";
|
||||
|
||||
private static final int CLICK_ACTION_MAX_MOVE_DISTANCE = 8;
|
||||
|
||||
private static final int ROOM_BARS_DISMISS_DELAY_MS = 3 * 1000;
|
||||
private static final int ROOM_BARS_FIRST_SHOW_TIME_MS = 6 * 1000;
|
||||
private static final int CONFIRM_DIALOG_AUTO_DISMISS_SECONDS = 5;
|
||||
|
||||
private Context mContext;
|
||||
private View mFloatingWindow;
|
||||
private TUIVideoSeatView mVideoSeatView;
|
||||
private FloatChatView mFloatChatView;
|
||||
private SpeechToTextSubtitleView mSpeechToTextSubtitleView;
|
||||
private Button mBtnStopScreenShare;
|
||||
private FrameLayout mLayoutTopView;
|
||||
private FrameLayout mLayoutVideoSeat;
|
||||
private FrameLayout mLayoutLocalAudio;
|
||||
private FrameLayout mLayoutFloatChatView;
|
||||
private FrameLayout mLayoutSpeechToTextSubtitle;
|
||||
private View mLayoutScreenCaptureGroup;
|
||||
private FrameLayout mLayoutBottomView;
|
||||
private BottomLayout mBottomLayout;
|
||||
private RoomMainViewModel mViewModel;
|
||||
|
||||
private final ParticipantSelector mParticipantSelector = new ParticipantSelector();
|
||||
|
||||
private Handler mMainHandler = new Handler(Looper.getMainLooper());
|
||||
|
||||
private boolean mIsBarsFirstShow = true;
|
||||
private boolean mIsBarsShowed = true;
|
||||
private boolean mIsBottomViewExpanded = false;
|
||||
|
||||
private OnClickListener mStopCaptureListener;
|
||||
private boolean mIsClickAction;
|
||||
private float mTouchDownPointX;
|
||||
private float mTouchDownPointY;
|
||||
|
||||
private final Observer<String> mRoomIdObserver = this::updateRoomId;
|
||||
private final Observer<Boolean> mAISubtitleObserver = this::updateSubtitleView;
|
||||
private final Observer<Boolean> misInPictureInPictureMode = this::updatePipModeVideoView;
|
||||
|
||||
private final LiveListObserver<String> mDisableSendMessageObserver = new LiveListObserver<String>() {
|
||||
@Override
|
||||
public void onItemInserted(int position, String userId) {
|
||||
mViewModel.showLocalDisabledSendMessageToast(userId, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemRemoved(int position, String userId) {
|
||||
mViewModel.showLocalDisabledSendMessageToast(userId, false);
|
||||
}
|
||||
};
|
||||
|
||||
public ConferenceMainView(Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
|
||||
public ConferenceMainView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
init(context);
|
||||
cacheConferenceActivity(context);
|
||||
}
|
||||
|
||||
public void toastForGeneralToManager() {
|
||||
TipToast.build()
|
||||
.setDuration(Toast.LENGTH_LONG)
|
||||
.setMessage(mContext.getString(R.string.tuiroomkit_have_become_manager))
|
||||
.show(mContext);
|
||||
}
|
||||
|
||||
public void toastForManagerToGeneral() {
|
||||
TipToast.build()
|
||||
.setDuration(Toast.LENGTH_LONG)
|
||||
.setMessage(mContext.getString(R.string.tuiroomkit_have_been_cancel_manager))
|
||||
.show(mContext);
|
||||
}
|
||||
|
||||
public void toastForToOwner() {
|
||||
TipToast.build()
|
||||
.setDuration(Toast.LENGTH_LONG)
|
||||
.setMessage(mContext.getString(R.string.tuiroomkit_toast_become_to_owner))
|
||||
.show(mContext);
|
||||
}
|
||||
|
||||
public void showRequestDialog(Map<String, Object> params) {
|
||||
if (params == null) {
|
||||
return;
|
||||
}
|
||||
TUIRoomDefine.Request request = (TUIRoomDefine.Request) params.get(ConferenceEventConstant.KEY_REQUEST);
|
||||
TUIRoomDefine.Role role = (TUIRoomDefine.Role) params.get(ConferenceEventConstant.KEY_ROLE);
|
||||
String userRole = mContext.getString(role == TUIRoomDefine.Role.ROOM_OWNER ? R.string.tuiroomkit_role_owner :
|
||||
R.string.tuiroomkit_role_manager);
|
||||
switch (request.requestAction) {
|
||||
case REQUEST_TO_OPEN_REMOTE_CAMERA:
|
||||
showInvitedOpenCamera(request, userRole);
|
||||
break;
|
||||
|
||||
case REQUEST_TO_OPEN_REMOTE_MICROPHONE:
|
||||
showInvitedOpenMic(request, userRole);
|
||||
break;
|
||||
|
||||
case REQUEST_REMOTE_USER_ON_SEAT:
|
||||
showInvitedTakeSeatDialog(request, userRole);
|
||||
break;
|
||||
|
||||
default:
|
||||
Log.e(TAG, "showRequestDialog un handle action : " + request.requestAction);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void showInvitedOpenCamera(TUIRoomDefine.Request request, String userRole) {
|
||||
BaseDialogFragment.build().setTitle(mContext.getString(R.string.tuiroomkit_request_open_camera, userRole))
|
||||
.setNegativeName(mContext.getString(R.string.tuiroomkit_refuse))
|
||||
.setPositiveName(mContext.getString(R.string.tuiroomkit_agree))
|
||||
.setNegativeListener(new BaseDialogFragment.ClickListener() {
|
||||
@Override
|
||||
public void onClick() {
|
||||
ConferenceController.sharedInstance()
|
||||
.responseRemoteRequest(request.requestAction, request.requestId, false, null);
|
||||
}
|
||||
}).setPositiveListener(new BaseDialogFragment.ClickListener() {
|
||||
@Override
|
||||
public void onClick() {
|
||||
ConferenceController.sharedInstance()
|
||||
.responseRemoteRequest(request.requestAction, request.requestId, true, null);
|
||||
}
|
||||
}).showDialog(mContext, "REQUEST_TO_OPEN_REMOTE_CAMERA");
|
||||
}
|
||||
|
||||
private void showInvitedOpenMic(TUIRoomDefine.Request request, String userRole) {
|
||||
BaseDialogFragment.build().setTitle(mContext.getString(R.string.tuiroomkit_request_open_microphone, userRole))
|
||||
.setNegativeName(mContext.getString(R.string.tuiroomkit_refuse))
|
||||
.setPositiveName(mContext.getString(R.string.tuiroomkit_agree))
|
||||
.setNegativeListener(new BaseDialogFragment.ClickListener() {
|
||||
@Override
|
||||
public void onClick() {
|
||||
ConferenceController.sharedInstance()
|
||||
.responseRemoteRequest(request.requestAction, request.requestId, false, null);
|
||||
}
|
||||
}).setPositiveListener(new BaseDialogFragment.ClickListener() {
|
||||
@Override
|
||||
public void onClick() {
|
||||
ConferenceController.sharedInstance()
|
||||
.responseRemoteRequest(request.requestAction, request.requestId, true, null);
|
||||
}
|
||||
}).showDialog(mContext, "REQUEST_TO_OPEN_REMOTE_MICROPHONE");
|
||||
}
|
||||
|
||||
private void showInvitedTakeSeatDialog(TUIRoomDefine.Request request, String userRole) {
|
||||
BaseDialogFragment.build().setTitle(mContext.getString(R.string.tuiroomkit_receive_invitation_title, userRole))
|
||||
.setContent(mContext.getString(R.string.tuiroomkit_receive_invitation_content))
|
||||
.setNegativeName(mContext.getString(R.string.tuiroomkit_refuse))
|
||||
.setPositiveName(mContext.getString(R.string.tuiroomkit_agree_on_stage))
|
||||
.setNegativeListener(new BaseDialogFragment.ClickListener() {
|
||||
@Override
|
||||
public void onClick() {
|
||||
ConferenceController.sharedInstance()
|
||||
.responseRemoteRequest(request.requestAction, request.requestId, false, null);
|
||||
}
|
||||
}).setPositiveListener(new BaseDialogFragment.ClickListener() {
|
||||
@Override
|
||||
public void onClick() {
|
||||
ConferenceController.sharedInstance()
|
||||
.responseRemoteRequest(request.requestAction, request.requestId, true,
|
||||
new TUIRoomDefine.ActionCallback() {
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
Log.d(TAG, "responseRemoteRequest takeSeat onSuccess");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(TUICommonDefine.Error error, String message) {
|
||||
Log.e(TAG, "responseRemoteRequest takeSeat onError error=" + error
|
||||
+ " message=" + message);
|
||||
if (ALL_SEAT_OCCUPIED == error) {
|
||||
RoomToast.toastShortMessageCenter(
|
||||
mContext.getString(R.string.tuiroomkit_stage_full_of_general));
|
||||
} else {
|
||||
RoomToast.toastShortMessageCenter(mContext.getString(
|
||||
R.string.tuiroomkit_invited_take_seat_time_out));
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}).showDialog(mContext, "REQUEST_REMOTE_USER_ON_SEAT");
|
||||
}
|
||||
|
||||
private void init(Context context) {
|
||||
mContext = context;
|
||||
mViewModel = new RoomMainViewModel(mContext, this);
|
||||
mVideoSeatView = new TUIVideoSeatView(mContext);
|
||||
mSpeechToTextSubtitleView = new SpeechToTextSubtitleView(mContext);
|
||||
mVideoSeatView.setViewClickListener(this::onClick);
|
||||
initView();
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
removeAllViews();
|
||||
addView(LayoutInflater.from(mContext)
|
||||
.inflate(R.layout.tuiroomkit_view_room_main,
|
||||
this, false));
|
||||
|
||||
mLayoutTopView = findViewById(R.id.tuiroomit_top_view_container);
|
||||
mLayoutTopView.addView(new TopView(mContext));
|
||||
|
||||
mLayoutVideoSeat = findViewById(R.id.tuiroomkit_video_seat_container);
|
||||
if (!ConferenceController.sharedInstance().getViewState().isInPictureInPictureMode.get()) {
|
||||
ViewParent parent = mVideoSeatView.getParent();
|
||||
if (parent instanceof ViewGroup) {
|
||||
((ViewGroup) parent).removeView(mVideoSeatView);
|
||||
}
|
||||
mLayoutVideoSeat.addView(mVideoSeatView);
|
||||
}
|
||||
if (ConferenceSessionImpl.sharedInstance().mIsEnableWaterMark) {
|
||||
TextWaterMarkView textWaterMarkView = new TextWaterMarkView(mContext);
|
||||
textWaterMarkView.setText(mViewModel.getWaterMakText());
|
||||
mLayoutVideoSeat.addView(textWaterMarkView);
|
||||
}
|
||||
mLayoutFloatChatView = findViewById(R.id.tuiroomkit_float_chat_view_container);
|
||||
initScreenCaptureView();
|
||||
initFloatChatView();
|
||||
initSpeechToTextSubtitleView();
|
||||
|
||||
mBottomLayout = new BottomLayout(mContext);
|
||||
mBottomLayout.setExpandStateListener(this::onExpandStateChanged);
|
||||
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(
|
||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT
|
||||
);
|
||||
mBottomLayout.setLayoutParams(layoutParams);
|
||||
mLayoutBottomView = findViewById(R.id.tuiroomkit_bottom_view_container);
|
||||
mLayoutBottomView.addView(mBottomLayout);
|
||||
|
||||
mLayoutLocalAudio = findViewById(R.id.tuiroomit_local_audio_container);
|
||||
mLayoutLocalAudio.addView(new LocalAudioToggleView(mContext));
|
||||
|
||||
if (ConferenceController.sharedInstance().getConferenceState().videoModel.isScreenSharing()) {
|
||||
onScreenShareStarted();
|
||||
}
|
||||
updateSubtitleView(ConferenceController.sharedInstance().getViewState().isSpeechToTextSubTitleShowing.get());
|
||||
showRoomBars();
|
||||
if (mIsBottomViewExpanded) {
|
||||
mBottomLayout.expandView();
|
||||
}
|
||||
}
|
||||
|
||||
private void initScreenCaptureView() {
|
||||
mLayoutScreenCaptureGroup = findViewById(R.id.tuiroomkit_group_screen_capture);
|
||||
mLayoutScreenCaptureGroup.setOnClickListener(this::onClick);
|
||||
mBtnStopScreenShare = findViewById(R.id.tuiroomkit_btn_stop_screen_capture);
|
||||
mStopCaptureListener = v -> mViewModel.stopScreenCapture();
|
||||
}
|
||||
|
||||
private void updatePipModeVideoView(boolean isPipMode) {
|
||||
if (ConferenceController.sharedInstance().getViewState().floatWindowType != ViewState.FloatWindowType.PICTURE_IN_PICTURE) {
|
||||
return;
|
||||
}
|
||||
if (isPipMode) {
|
||||
mLayoutVideoSeat.removeView(mVideoSeatView);
|
||||
mVideoSeatView.destroy();
|
||||
} else {
|
||||
if (mVideoSeatView != null) {
|
||||
mLayoutVideoSeat.removeView(mVideoSeatView);
|
||||
mVideoSeatView.destroy();
|
||||
}
|
||||
mVideoSeatView = new TUIVideoSeatView(mContext);
|
||||
mVideoSeatView.setViewClickListener(this::onClick);
|
||||
mLayoutVideoSeat.addView(mVideoSeatView);
|
||||
}
|
||||
}
|
||||
|
||||
public void stopScreenShare() {
|
||||
mBottomLayout.stopScreenShare();
|
||||
}
|
||||
|
||||
public void showAlertUserLiveTips() {
|
||||
try {
|
||||
Class clz = Class.forName("com.tencent.liteav.privacy.util.RTCubeAppLegalUtils");
|
||||
Method method = clz.getDeclaredMethod("showAlertUserLiveTips", Context.class);
|
||||
method.invoke(null, mContext);
|
||||
} catch (Exception e) {
|
||||
Log.i(TAG, "showAlertUserLiveTips fail");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onConfigurationChanged(Configuration newConfig) {
|
||||
super.onConfigurationChanged(newConfig);
|
||||
initView();
|
||||
mViewModel.notifyConfigChange(newConfig);
|
||||
mViewModel.setCameraResolutionMode(newConfig);
|
||||
ConferenceController.sharedInstance().getViewController().updateScreenOrientation(newConfig);
|
||||
}
|
||||
|
||||
public void showMediaSettingsPanel() {
|
||||
MediaSettingPanel mediaSettingPanel = new MediaSettingPanel(mContext);
|
||||
mediaSettingPanel.show();
|
||||
}
|
||||
|
||||
public void showRoomInfo() {
|
||||
RoomInfoDialog roomInfoView = new RoomInfoDialog(mContext);
|
||||
roomInfoView.show();
|
||||
}
|
||||
|
||||
public void showUserList() {
|
||||
UserListPanel userListView = new UserListPanel(mContext);
|
||||
userListView.show();
|
||||
}
|
||||
|
||||
public void showMemberInvitePanel() {
|
||||
InviteDialog inviteView = new InviteDialog(mContext);
|
||||
inviteView.show();
|
||||
}
|
||||
|
||||
public void showMoreFunctionPanel() {
|
||||
MoreFunctionDialog moreFunctionView = new MoreFunctionDialog(mContext);
|
||||
moreFunctionView.show();
|
||||
}
|
||||
|
||||
public void showShareRoomPanel() {
|
||||
ShareRoomDialog shareRoomDialog = new ShareRoomDialog(mContext);
|
||||
shareRoomDialog.show();
|
||||
}
|
||||
|
||||
public void showSelectAttendeeView() {
|
||||
mParticipantSelector.startParticipantSelect(mContext, getParticipants(), new ParticipantSelector.ParticipantSelectCallback() {
|
||||
@Override
|
||||
public void onParticipantSelected(List<UserState.UserInfo> participants) {
|
||||
if (participants == null || participants.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
ConferenceController.sharedInstance().getInvitationController().inviteUsers(participants, null);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private ConferenceParticipants getParticipants() {
|
||||
ConferenceParticipants participants = new ConferenceParticipants();
|
||||
for (UserState.UserInfo userInfo : ConferenceController.sharedInstance().getUserState().allUsers.getList()) {
|
||||
ConferenceDefine.User user = new ConferenceDefine.User();
|
||||
user.id = userInfo.userId;
|
||||
user.name = userInfo.userName;
|
||||
user.avatarUrl = userInfo.avatarUrl;
|
||||
participants.unSelectableList.add(user);
|
||||
}
|
||||
return participants;
|
||||
}
|
||||
|
||||
public void showApplyList() {
|
||||
RaiseHandApplicationListPanel raiseHandApplicationListView = new RaiseHandApplicationListPanel(mContext);
|
||||
raiseHandApplicationListView.show();
|
||||
}
|
||||
|
||||
public void showQRCodeView(String url) {
|
||||
QRCodeView qrCodeView = new QRCodeView(mContext, url);
|
||||
qrCodeView.show();
|
||||
}
|
||||
|
||||
public void showExitRoomDialog() {
|
||||
ExitRoomDialog exitRoomDialog = new ExitRoomDialog(mContext);
|
||||
exitRoomDialog.show();
|
||||
}
|
||||
|
||||
public void showTransferMasterView() {
|
||||
TransferMasterPanel transferMasterView = new TransferMasterPanel(mContext);
|
||||
transferMasterView.show();
|
||||
}
|
||||
|
||||
public void recountBarShowTime() {
|
||||
showRoomBars();
|
||||
}
|
||||
|
||||
public void showLeavedRoomConfirmDialog(String message) {
|
||||
final ConfirmDialog confirmDialog = new ConfirmDialog(mContext);
|
||||
confirmDialog.setAutoConfirmSeconds(CONFIRM_DIALOG_AUTO_DISMISS_SECONDS);
|
||||
confirmDialog.setCancelable(true);
|
||||
confirmDialog.setMessage(message);
|
||||
if (confirmDialog.isShowing()) {
|
||||
confirmDialog.dismiss();
|
||||
return;
|
||||
}
|
||||
confirmDialog.setPositiveText(mContext.getString(R.string.tuiroomkit_dialog_ok));
|
||||
confirmDialog.setPositiveClickListener(new ConfirmDialog.PositiveClickListener() {
|
||||
@Override
|
||||
public void onClick() {
|
||||
confirmDialog.dismiss();
|
||||
ConferenceEventCenter.getInstance().notifyUIEvent(DISMISS_MAIN_ACTIVITY, null);
|
||||
}
|
||||
});
|
||||
confirmDialog.show();
|
||||
}
|
||||
|
||||
public void showKickedOffLineDialog() {
|
||||
final ConfirmDialog confirmDialog = new ConfirmDialog(mContext);
|
||||
confirmDialog.setAutoConfirmSeconds(CONFIRM_DIALOG_AUTO_DISMISS_SECONDS);
|
||||
confirmDialog.setCancelable(true);
|
||||
confirmDialog.setMessage(mContext.getString(R.string.tuiroomkit_kicked_off_line));
|
||||
confirmDialog.setPositiveText(mContext.getString(R.string.tuiroomkit_dialog_ok));
|
||||
confirmDialog.setPositiveClickListener(new ConfirmDialog.PositiveClickListener() {
|
||||
@Override
|
||||
public void onClick() {
|
||||
confirmDialog.dismiss();
|
||||
ConferenceEventCenter.getInstance().notifyUIEvent(DISMISS_MAIN_ACTIVITY, null);
|
||||
ConferenceEventCenter.getInstance().notifyUIEvent(START_LOGIN, null);
|
||||
}
|
||||
});
|
||||
confirmDialog.show();
|
||||
}
|
||||
|
||||
public void showLogoutDialog() {
|
||||
BaseDialogFragment.build()
|
||||
.setTitle(mContext.getString(R.string.tuiroomkit_dialog_logout_title))
|
||||
.hideNegativeView()
|
||||
.setPositiveName(mContext.getString(R.string.tuiroomkit_confirm))
|
||||
.setPositiveListener(new BaseDialogFragment.ClickListener() {
|
||||
@Override
|
||||
public void onClick() {
|
||||
ConferenceEventCenter.getInstance().notifyUIEvent(DISMISS_MAIN_ACTIVITY, null);
|
||||
ConferenceEventCenter.getInstance().notifyUIEvent(START_LOGIN, null);
|
||||
}
|
||||
})
|
||||
.showDialog(mContext, "showLogoutDialog");
|
||||
}
|
||||
|
||||
public void showSingleConfirmDialog(String message) {
|
||||
final ConfirmDialog confirmDialog = new ConfirmDialog(mContext);
|
||||
confirmDialog.setCancelable(true);
|
||||
confirmDialog.setMessage(message);
|
||||
if (confirmDialog.isShowing()) {
|
||||
confirmDialog.dismiss();
|
||||
return;
|
||||
}
|
||||
confirmDialog.setPositiveText(mContext.getString(R.string.tuiroomkit_dialog_ok));
|
||||
confirmDialog.setPositiveClickListener(new ConfirmDialog.PositiveClickListener() {
|
||||
@Override
|
||||
public void onClick() {
|
||||
confirmDialog.dismiss();
|
||||
}
|
||||
});
|
||||
confirmDialog.show();
|
||||
}
|
||||
|
||||
public void isShowFloatChat(boolean enable) {
|
||||
mFloatChatView.isShow(enable);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onAttachedToWindow() {
|
||||
super.onAttachedToWindow();
|
||||
Configuration curConfig = mContext.getResources().getConfiguration();
|
||||
ConferenceController.sharedInstance().getViewController().updateScreenOrientation(curConfig);
|
||||
ConferenceController.sharedInstance().getRoomState().roomId.observe(mRoomIdObserver);
|
||||
ConferenceController.sharedInstance().getViewState().isSpeechToTextSubTitleShowing.observe(mAISubtitleObserver);
|
||||
ConferenceController.sharedInstance().getViewState().isInPictureInPictureMode.observe(misInPictureInPictureMode);
|
||||
ConferenceController.sharedInstance().getUserState().disableMessageUsers.observe(mDisableSendMessageObserver);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow();
|
||||
hideFloatingWindow();
|
||||
mViewModel.destroy();
|
||||
if (mVideoSeatView != null) {
|
||||
mVideoSeatView.destroy();
|
||||
}
|
||||
if (mFloatChatView != null) {
|
||||
mFloatChatView.destroy();
|
||||
}
|
||||
mMainHandler.removeCallbacksAndMessages(null);
|
||||
ConferenceController.sharedInstance().getRoomState().roomId.removeObserver(mRoomIdObserver);
|
||||
ConferenceController.sharedInstance().getViewState().isSpeechToTextSubTitleShowing.removeObserver(mAISubtitleObserver);
|
||||
ConferenceController.sharedInstance().getViewState().isInPictureInPictureMode.removeObserver(misInPictureInPictureMode);
|
||||
ConferenceController.sharedInstance().getUserState().disableMessageUsers.removeObserver(mDisableSendMessageObserver);
|
||||
}
|
||||
|
||||
private void updateRoomId(String roomId) {
|
||||
if (TextUtils.isEmpty(roomId)) {
|
||||
return;
|
||||
}
|
||||
mFloatChatView = new FloatChatView(mContext, roomId);
|
||||
initFloatChatView();
|
||||
}
|
||||
|
||||
private void updateSubtitleView(boolean isShowSubtitle) {
|
||||
mLayoutFloatChatView.setVisibility(isShowSubtitle ? INVISIBLE : VISIBLE);
|
||||
mLayoutSpeechToTextSubtitle.setVisibility(isShowSubtitle ? VISIBLE : INVISIBLE);
|
||||
}
|
||||
|
||||
public void showShareStoppedByAdminDialog() {
|
||||
BaseDialogFragment.build()
|
||||
.setTitle(mContext.getString(R.string.tuiroomkit_share_screen_stopped))
|
||||
.hideNegativeView().setPositiveName(mContext.getString(R.string.tuiroomkit_i_see))
|
||||
.setContent(mContext.getString(R.string.tuiroomkit_disable_general_share_by_admin_dialog_hint))
|
||||
.showDialog(mContext, null);
|
||||
}
|
||||
|
||||
private void initFloatChatView() {
|
||||
if (mFloatChatView == null) {
|
||||
return;
|
||||
}
|
||||
ViewParent floatChatViewParent = mFloatChatView.getParent();
|
||||
if (floatChatViewParent instanceof ViewGroup) {
|
||||
((ViewGroup) floatChatViewParent).removeView(mFloatChatView);
|
||||
}
|
||||
mFloatChatView.isShow(mViewModel.isFloatChatEnable());
|
||||
mLayoutFloatChatView.addView(mFloatChatView);
|
||||
mFloatChatView.setFindUserNameCardService(this);
|
||||
}
|
||||
|
||||
private void initSpeechToTextSubtitleView() {
|
||||
mLayoutSpeechToTextSubtitle = findViewById(R.id.tuiroomkit_speech_to_text_subtitle_container);
|
||||
ViewParent parent = mSpeechToTextSubtitleView.getParent();
|
||||
if (parent instanceof ViewGroup) {
|
||||
((ViewGroup) parent).removeView(mSpeechToTextSubtitleView);
|
||||
}
|
||||
mLayoutSpeechToTextSubtitle.addView(mSpeechToTextSubtitleView);
|
||||
}
|
||||
|
||||
public void onScreenShareStarted() {
|
||||
mLayoutScreenCaptureGroup.setVisibility(View.VISIBLE);
|
||||
|
||||
if (mFloatingWindow == null) {
|
||||
LayoutInflater inflater = LayoutInflater.from(getContext());
|
||||
mFloatingWindow = inflater.inflate(R.layout.tuiroomkit_screen_capture_floating_window, null, false);
|
||||
showFloatingWindow();
|
||||
}
|
||||
}
|
||||
|
||||
public void onScreenShareStopped() {
|
||||
hideFloatingWindow();
|
||||
mLayoutScreenCaptureGroup.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
private void showFloatingWindow() {
|
||||
if (mFloatingWindow == null) {
|
||||
return;
|
||||
}
|
||||
WindowManager windowManager =
|
||||
(WindowManager) mFloatingWindow.getContext().getSystemService(Context.WINDOW_SERVICE);
|
||||
if (windowManager == null) {
|
||||
return;
|
||||
}
|
||||
int type = WindowManager.LayoutParams.TYPE_TOAST;
|
||||
if (Build.VERSION.SDK_INT >= 26) {
|
||||
type = WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY;
|
||||
} else if (Build.VERSION.SDK_INT > Build.VERSION_CODES.N) {
|
||||
type = WindowManager.LayoutParams.TYPE_PHONE;
|
||||
}
|
||||
WindowManager.LayoutParams layoutParams = new WindowManager.LayoutParams(type);
|
||||
layoutParams.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;
|
||||
layoutParams.flags |= WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH;
|
||||
layoutParams.width = WindowManager.LayoutParams.WRAP_CONTENT;
|
||||
layoutParams.height = WindowManager.LayoutParams.WRAP_CONTENT;
|
||||
layoutParams.format = PixelFormat.TRANSLUCENT;
|
||||
layoutParams.gravity = Gravity.END;
|
||||
windowManager.addView(mFloatingWindow, layoutParams);
|
||||
}
|
||||
|
||||
private void hideFloatingWindow() {
|
||||
if (mFloatingWindow == null) {
|
||||
return;
|
||||
}
|
||||
WindowManager windowManager =
|
||||
(WindowManager) mFloatingWindow.getContext().getSystemService(Context.WINDOW_SERVICE);
|
||||
if (windowManager != null) {
|
||||
windowManager.removeViewImmediate(mFloatingWindow);
|
||||
}
|
||||
mFloatingWindow = null;
|
||||
}
|
||||
|
||||
public void onCameraMuted(boolean muted) {
|
||||
if (muted) {
|
||||
RoomToast.toastShortMessageCenter(mContext.getString(R.string.tuiroomkit_mute_video_by_master));
|
||||
} else {
|
||||
RoomToast.toastShortMessageCenter(mContext.getString(R.string.tuiroomkit_un_mute_video_by_master));
|
||||
}
|
||||
}
|
||||
|
||||
public void onMicrophoneMuted(boolean muted) {
|
||||
if (muted) {
|
||||
RoomToast.toastShortMessageCenter(mContext.getString(R.string.tuiroomkit_mute_audio_by_master));
|
||||
} else {
|
||||
RoomToast.toastShortMessageCenter(mContext.getString(R.string.tuiroomkit_un_mute_audio_by_master));
|
||||
}
|
||||
}
|
||||
|
||||
public void onExpandStateChanged(boolean isExpanded) {
|
||||
mIsBottomViewExpanded = isExpanded;
|
||||
showRoomBars();
|
||||
}
|
||||
|
||||
public void onClick(View v) {
|
||||
if (mIsBottomViewExpanded) {
|
||||
return;
|
||||
}
|
||||
if (mIsBarsShowed) {
|
||||
hideRoomBars();
|
||||
} else {
|
||||
showRoomBars();
|
||||
}
|
||||
}
|
||||
|
||||
private void showRoomBars() {
|
||||
mIsBarsShowed = true;
|
||||
mLayoutLocalAudio.setVisibility(INVISIBLE);
|
||||
mLayoutTopView.setVisibility(VISIBLE);
|
||||
mLayoutBottomView.setVisibility(VISIBLE);
|
||||
mMainHandler.removeCallbacksAndMessages(null);
|
||||
if (mIsBottomViewExpanded) {
|
||||
return;
|
||||
}
|
||||
int showTime = ROOM_BARS_DISMISS_DELAY_MS;
|
||||
if (mIsBarsFirstShow) {
|
||||
mIsBarsFirstShow = false;
|
||||
showTime = ROOM_BARS_FIRST_SHOW_TIME_MS;
|
||||
}
|
||||
mMainHandler.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
hideRoomBars();
|
||||
}
|
||||
}, showTime);
|
||||
}
|
||||
|
||||
private void hideRoomBars() {
|
||||
mIsBarsShowed = false;
|
||||
mLayoutTopView.setVisibility(INVISIBLE);
|
||||
mLayoutBottomView.setVisibility(INVISIBLE);
|
||||
mLayoutLocalAudio.setVisibility(VISIBLE);
|
||||
mMainHandler.removeCallbacksAndMessages(null);
|
||||
}
|
||||
|
||||
|
||||
private void cacheConferenceActivity(Context context) {
|
||||
if (!(context instanceof Activity)) {
|
||||
Log.e(TAG, "cacheConferenceActivity context is not instance of Activity");
|
||||
return;
|
||||
}
|
||||
Activity activity = (Activity) context;
|
||||
ConferenceState store = ConferenceController.sharedInstance().getConferenceState();
|
||||
store.setMainActivityClass(activity.getClass());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean dispatchTouchEvent(MotionEvent ev) {
|
||||
performClickEventFromTouch(ev);
|
||||
return super.dispatchTouchEvent(ev);
|
||||
}
|
||||
|
||||
private void performClickEventFromTouch(MotionEvent event) {
|
||||
switch (event.getAction()) {
|
||||
case MotionEvent.ACTION_DOWN:
|
||||
mTouchDownPointX = event.getX();
|
||||
mTouchDownPointY = event.getY();
|
||||
mIsClickAction = true;
|
||||
break;
|
||||
|
||||
case MotionEvent.ACTION_MOVE:
|
||||
float xDistance = Math.abs(event.getX() - mTouchDownPointX);
|
||||
float yDistance = Math.abs(event.getY() - mTouchDownPointY);
|
||||
if (xDistance >= CLICK_ACTION_MAX_MOVE_DISTANCE || yDistance >= CLICK_ACTION_MAX_MOVE_DISTANCE) {
|
||||
mIsClickAction = false;
|
||||
}
|
||||
break;
|
||||
|
||||
case MotionEvent.ACTION_UP:
|
||||
if (mIsClickAction) {
|
||||
clickStopCaptureBtn(event);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void clickStopCaptureBtn(MotionEvent event) {
|
||||
if (!canReceivePointerEvents(mLayoutScreenCaptureGroup) || !canReceivePointerEvents(mBtnStopScreenShare)
|
||||
|| !isEventInsideView(mBtnStopScreenShare, event.getX(), event.getY())) {
|
||||
return;
|
||||
}
|
||||
mStopCaptureListener.onClick(mBtnStopScreenShare);
|
||||
}
|
||||
|
||||
private boolean canReceivePointerEvents(View view) {
|
||||
return view.getVisibility() == VISIBLE || view.getAnimation() != null;
|
||||
}
|
||||
|
||||
private boolean isEventInsideView(View view, float x, float y) {
|
||||
int[] location = new int[2];
|
||||
view.getLocationOnScreen(location);
|
||||
int viewX = location[0];
|
||||
int viewY = location[1];
|
||||
int viewWidth = view.getWidth();
|
||||
int viewHeight = view.getHeight();
|
||||
return x >= viewX && x <= (viewX + viewWidth) && y >= viewY && y <= (viewY + viewHeight);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String findUserNameCard(String userId) {
|
||||
return mViewModel.getUserNameCard(userId);
|
||||
}
|
||||
}
|
||||
+153
@@ -0,0 +1,153 @@
|
||||
package com.tencent.cloud.tuikit.roomkit.view.main;
|
||||
|
||||
import static com.tencent.cloud.tuikit.roomkit.manager.eventcenter.ConferenceEventCenter.RoomEngineEvent.LOCAL_USER_DESTROY_ROOM;
|
||||
import static com.tencent.cloud.tuikit.roomkit.manager.eventcenter.ConferenceEventCenter.RoomEngineEvent.LOCAL_USER_EXIT_ROOM;
|
||||
import static com.tencent.cloud.tuikit.roomkit.manager.eventcenter.ConferenceEventCenter.RoomKitUIEvent.DISMISS_MAIN_ACTIVITY;
|
||||
import static com.tencent.cloud.tuikit.roomkit.manager.eventcenter.ConferenceEventCenter.RoomKitUIEvent.ENTER_FLOAT_WINDOW;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.tencent.cloud.tuikit.engine.common.TUICommonDefine;
|
||||
import com.tencent.cloud.tuikit.engine.room.TUIRoomDefine;
|
||||
import com.tencent.cloud.tuikit.roomkit.ConferenceDefine;
|
||||
import com.tencent.cloud.tuikit.roomkit.manager.eventcenter.ConferenceEventCenter;
|
||||
import com.tencent.cloud.tuikit.roomkit.state.ConferenceState;
|
||||
import com.tencent.cloud.tuikit.roomkit.manager.ConferenceController;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class ConferenceMainViewModel implements ConferenceEventCenter.RoomEngineEventResponder, ConferenceEventCenter.RoomKitUIEventResponder {
|
||||
private static final String TAG = "ConferenceMainViewModel";
|
||||
|
||||
private final ConferenceMainFragment mFragment;
|
||||
|
||||
public interface GetConferenceInfoCallback {
|
||||
public void onSuccess(TUIRoomDefine.RoomInfo roomInfo);
|
||||
|
||||
public void onError(TUIRoomDefine.RoomInfo roomInfo, TUICommonDefine.Error error, String message);
|
||||
}
|
||||
|
||||
public ConferenceMainViewModel(ConferenceMainFragment fragment) {
|
||||
Log.d(TAG, "new : " + this);
|
||||
mFragment = fragment;
|
||||
}
|
||||
|
||||
public void init() {
|
||||
Log.d(TAG, "init : " + this);
|
||||
subscribeEvent();
|
||||
}
|
||||
|
||||
public void release() {
|
||||
Log.d(TAG, "release : " + this);
|
||||
unSubscribeEvent();
|
||||
}
|
||||
|
||||
public void startConference(ConferenceDefine.StartConferenceParams params, @NonNull GetConferenceInfoCallback callback) {
|
||||
TUIRoomDefine.RoomInfo roomInfo = new TUIRoomDefine.RoomInfo();
|
||||
roomInfo.roomId = params.roomId;
|
||||
roomInfo.isMicrophoneDisableForAllUser = params.isMicrophoneDisableForAllUser;
|
||||
roomInfo.isCameraDisableForAllUser = params.isCameraDisableForAllUser;
|
||||
roomInfo.isSeatEnabled = params.isSeatEnabled;
|
||||
roomInfo.seatMode = TUIRoomDefine.SeatMode.APPLY_TO_TAKE;
|
||||
roomInfo.password = params.password;
|
||||
roomInfo.name = params.name;
|
||||
|
||||
ConferenceController controller = ConferenceController.sharedInstance();
|
||||
controller.createRoom(roomInfo, new TUIRoomDefine.ActionCallback() {
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
controller.enterRoom(roomInfo.roomId, params.isOpenMicrophone, params.isOpenCamera, params.isOpenSpeaker, new TUIRoomDefine.GetRoomInfoCallback() {
|
||||
@Override
|
||||
public void onSuccess(TUIRoomDefine.RoomInfo engineRoomInfo) {
|
||||
callback.onSuccess(engineRoomInfo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(TUICommonDefine.Error error, String message) {
|
||||
callback.onError(roomInfo, error, message);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(TUICommonDefine.Error error, String message) {
|
||||
callback.onError(roomInfo, error, message);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void joinConference(ConferenceDefine.JoinConferenceParams params, @NonNull GetConferenceInfoCallback callback) {
|
||||
ConferenceController.sharedInstance().enterRoom(params.roomId, params.isOpenMicrophone, params.isOpenCamera, params.isOpenSpeaker, new TUIRoomDefine.GetRoomInfoCallback() {
|
||||
@Override
|
||||
public void onSuccess(TUIRoomDefine.RoomInfo engineRoomInfo) {
|
||||
callback.onSuccess(engineRoomInfo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(TUICommonDefine.Error error, String message) {
|
||||
TUIRoomDefine.RoomInfo roomInfo = new TUIRoomDefine.RoomInfo();
|
||||
roomInfo.roomId = params.roomId;
|
||||
callback.onError(roomInfo, error, message);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void joinEncryptRoom(ConferenceDefine.JoinConferenceParams params, String password, @NonNull GetConferenceInfoCallback callback) {
|
||||
ConferenceController.sharedInstance().enterEncryptRoom(params.roomId, params.isOpenMicrophone, params.isOpenCamera, params.isOpenSpeaker, password, new TUIRoomDefine.GetRoomInfoCallback() {
|
||||
@Override
|
||||
public void onSuccess(TUIRoomDefine.RoomInfo engineRoomInfo) {
|
||||
callback.onSuccess(engineRoomInfo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(TUICommonDefine.Error error, String message) {
|
||||
TUIRoomDefine.RoomInfo roomInfo = new TUIRoomDefine.RoomInfo();
|
||||
roomInfo.roomId = params.roomId;
|
||||
callback.onError(roomInfo, error, message);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void cacheCurrentActivity(Activity activity) {
|
||||
ConferenceState store = ConferenceController.sharedInstance().getConferenceState();
|
||||
store.setMainActivityClass(activity.getClass());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNotifyUIEvent(String key, Map<String, Object> params) {
|
||||
Log.d(TAG, "onNotifyUIEvent key=" + key);
|
||||
if (ENTER_FLOAT_WINDOW.equals(key) || DISMISS_MAIN_ACTIVITY.equals(key)) {
|
||||
mFragment.onDismiss();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEngineEvent(ConferenceEventCenter.RoomEngineEvent event, Map<String, Object> params) {
|
||||
Log.d(TAG, "onEngineEvent event=" + event);
|
||||
if (event != LOCAL_USER_EXIT_ROOM && event != LOCAL_USER_DESTROY_ROOM) {
|
||||
return;
|
||||
}
|
||||
mFragment.onDismiss();
|
||||
}
|
||||
|
||||
private void subscribeEvent() {
|
||||
ConferenceEventCenter eventCenter = ConferenceEventCenter.getInstance();
|
||||
eventCenter.subscribeEngine(LOCAL_USER_DESTROY_ROOM, this);
|
||||
eventCenter.subscribeEngine(LOCAL_USER_EXIT_ROOM, this);
|
||||
|
||||
eventCenter.subscribeUIEvent(ENTER_FLOAT_WINDOW, this);
|
||||
eventCenter.subscribeUIEvent(DISMISS_MAIN_ACTIVITY, this);
|
||||
}
|
||||
|
||||
private void unSubscribeEvent() {
|
||||
ConferenceEventCenter eventCenter = ConferenceEventCenter.getInstance();
|
||||
eventCenter.unsubscribeEngine(LOCAL_USER_DESTROY_ROOM, this);
|
||||
eventCenter.unsubscribeEngine(LOCAL_USER_EXIT_ROOM, this);
|
||||
|
||||
eventCenter.unsubscribeUIEvent(ENTER_FLOAT_WINDOW, this);
|
||||
eventCenter.unsubscribeUIEvent(DISMISS_MAIN_ACTIVITY, this);
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user