临时群调整

This commit is contained in:
fengge 2026-07-22 10:56:03 +08:00
parent f7def3a7f6
commit d570ecb57f
2 changed files with 120 additions and 117 deletions

View File

@ -277,26 +277,29 @@ public class CallBackResolution {
// 处理临时呼叫页面逻辑 // 处理临时呼叫页面逻辑
if (code == 1) { if (code == 1) {
try { com.stand.standapp.MainActivity.executeJs("onTempCallStateChanged('created')");
android.content.Context context = com.stand.standapp.MyApplication.getAppInstance(); // try {
String account = com.stand.standapp.AppConfig.getSavedUsername(context); // android.content.Context context = com.stand.standapp.MyApplication.getAppInstance();
String token = com.stand.standapp.AppConfig.getAccessToken(context); // String account = com.stand.standapp.AppConfig.getSavedUsername(context);
String tempGroupName = "临时会话"; // String token = com.stand.standapp.AppConfig.getAccessToken(context);
if (tempTxt.startsWith("临时呼叫") && tempTxt.length() > "临时呼叫".length()) { // String tempGroupName = "临时会话";
tempGroupName = tempTxt.substring("临时呼叫".length()); // if (tempTxt.startsWith("临时呼叫") && tempTxt.length() > "临时呼叫".length()) {
} // tempGroupName = tempTxt.substring("临时呼叫".length());
com.stand.standapp.TempCallActivity.checkAndHandleTempGroup(context, account, token, tempGroupName); // }
} catch (Exception e) { // com.stand.standapp.TempCallActivity.checkAndHandleTempGroup(context, account, token, tempGroupName);
Timber.tag(TAG).e(e, "Failed to check initiator status and handle TempCallActivity"); // } catch (Exception e) {
} // Timber.tag(TAG).e(e, "Failed to check initiator status and handle TempCallActivity");
// }
} else if (code == 0) { } else if (code == 0) {
// 退出临时呼叫 关闭临时呼叫页面 // 退出临时呼叫 关闭临时呼叫页面
if (com.stand.standapp.TempCallActivity.isOpen()) { com.stand.standapp.MainActivity.executeJs("onTempCallStateChanged('destroyed')");
com.stand.standapp.TempCallActivity.closeWithMessage("临时呼叫已结束"); com.stand.standapp.MainActivity.executeJs("if(window.endPullGroupLock){ window.endPullGroupLock(); }");
} else if (com.stand.standapp.TempCallActivity.isMinimizedState()) { // if (com.stand.standapp.TempCallActivity.isOpen()) {
// 最小化状态下收到结束消息清除状态并通知前端 // com.stand.standapp.TempCallActivity.closeWithMessage("临时呼叫已结束");
com.stand.standapp.TempCallActivity.clearMinimizedState(); // } else if (com.stand.standapp.TempCallActivity.isMinimizedState()) {
} // // 最小化状态下收到结束消息清除状态并通知前端
// com.stand.standapp.TempCallActivity.clearMinimizedState();
// }
} else if (code == 2) { } else if (code == 2) {
// 呼叫失败 关闭临时呼叫页面 // 呼叫失败 关闭临时呼叫页面
// if (com.stand.standapp.TempCallActivity.isOpen()) { // if (com.stand.standapp.TempCallActivity.isOpen()) {

View File

@ -97,105 +97,105 @@ class TempCallActivity : AppCompatActivity() {
groupNameFromCall: String? = null, groupNameFromCall: String? = null,
targetGid: String? = null targetGid: String? = null
) { ) {
if (token.isEmpty()) { // if (token.isEmpty()) {
Timber.tag("TempGroupCheck").w("token is empty, skip check") // Timber.tag("TempGroupCheck").w("token is empty, skip check")
return // return
} // }
//
val serverUrl = AppConfig.getServerUrl(context) // val serverUrl = AppConfig.getServerUrl(context)
val url = "$serverUrl/api/vid-pull-record/my-list" // val url = "$serverUrl/api/vid-pull-record/my-list"
//
val request = okhttp3.Request.Builder() // val request = okhttp3.Request.Builder()
.url(url) // .url(url)
.addHeader("Authorization", "Bearer $token") // .addHeader("Authorization", "Bearer $token")
.get() // .get()
.build() // .build()
//
com.stand.standapp.net.NetworkModule.defaultClient.newCall(request).enqueue(object : okhttp3.Callback { // com.stand.standapp.net.NetworkModule.defaultClient.newCall(request).enqueue(object : okhttp3.Callback {
override fun onFailure(call: okhttp3.Call, e: java.io.IOException) { // override fun onFailure(call: okhttp3.Call, e: java.io.IOException) {
Timber.tag("TempGroupCheck").e(e, "获取拉动记录失败") // Timber.tag("TempGroupCheck").e(e, "获取拉动记录失败")
if (groupNameFromCall != null) { // if (groupNameFromCall != null) {
startTempCallActivity(context, groupNameFromCall, targetGid ?: "") // startTempCallActivity(context, groupNameFromCall, targetGid ?: "")
} // }
} // }
//
override fun onResponse(call: okhttp3.Call, response: okhttp3.Response) { // override fun onResponse(call: okhttp3.Call, response: okhttp3.Response) {
try { // try {
val body = response.body?.string() ?: return // val body = response.body?.string() ?: return
val json = org.json.JSONObject(body) // val json = org.json.JSONObject(body)
if (json.optInt("code", -1) == 0) { // if (json.optInt("code", -1) == 0) {
val dataArray = json.optJSONArray("data") // val dataArray = json.optJSONArray("data")
var matchedRecord: org.json.JSONObject? = null // var matchedRecord: org.json.JSONObject? = null
//
if (dataArray != null && dataArray.length() > 0) { // if (dataArray != null && dataArray.length() > 0) {
// 1. 如果指定了 GID优先按 GID 匹配 // // 1. 如果指定了 GID优先按 GID 匹配
if (targetGid != null && targetGid.isNotEmpty()) { // if (targetGid != null && targetGid.isNotEmpty()) {
for (i in 0 until dataArray.length()) { // for (i in 0 until dataArray.length()) {
val record = dataArray.optJSONObject(i) ?: continue // val record = dataArray.optJSONObject(i) ?: continue
val pocGid = record.optString("pocGid", "") // val pocGid = record.optString("pocGid", "")
if (pocGid == targetGid) { // if (pocGid == targetGid) {
matchedRecord = record // matchedRecord = record
break // break
} // }
} // }
} // }
//
// 2. 如果未指定 GID 或未匹配到,且有传入的呼叫群组名称,按名称匹配 // // 2. 如果未指定 GID 或未匹配到,且有传入的呼叫群组名称,按名称匹配
if (matchedRecord == null && groupNameFromCall != null && groupNameFromCall.isNotEmpty() && groupNameFromCall != "临时会话") { // if (matchedRecord == null && groupNameFromCall != null && groupNameFromCall.isNotEmpty() && groupNameFromCall != "临时会话") {
for (i in 0 until dataArray.length()) { // for (i in 0 until dataArray.length()) {
val record = dataArray.optJSONObject(i) ?: continue // val record = dataArray.optJSONObject(i) ?: continue
val pullTitle = record.optString("pullTitle", "") // val pullTitle = record.optString("pullTitle", "")
if (pullTitle.contains(groupNameFromCall) || groupNameFromCall.contains(pullTitle)) { // if (pullTitle.contains(groupNameFromCall) || groupNameFromCall.contains(pullTitle)) {
matchedRecord = record // matchedRecord = record
break // break
} // }
} // }
} // }
//
// 3. 如果仍未匹配到,默认使用最新的一条记录 // // 3. 如果仍未匹配到,默认使用最新的一条记录
if (matchedRecord == null) { // if (matchedRecord == null) {
matchedRecord = dataArray.optJSONObject(0) // matchedRecord = dataArray.optJSONObject(0)
} // }
} // }
//
if (matchedRecord != null) { // if (matchedRecord != null) {
val pocGid = matchedRecord.optString("pocGid", "") // val pocGid = matchedRecord.optString("pocGid", "")
val pullTitle = matchedRecord.optString("pullTitle", "临时会话") // val pullTitle = matchedRecord.optString("pullTitle", "临时会话")
val createBy = matchedRecord.optString("createBy", "") // val createBy = matchedRecord.optString("createBy", "")
val currentUserId = AppConfig.getSavedUserId(context) // val currentUserId = AppConfig.getSavedUserId(context)
//
val isInitiator = currentUserId.isNotEmpty() && currentUserId == createBy // val isInitiator = currentUserId.isNotEmpty() && currentUserId == createBy
Timber.tag("TempGroupCheck").d("匹配拉动记录成功: title=$pullTitle, pocGid=$pocGid, createBy=$createBy, isInitiator=$isInitiator") // Timber.tag("TempGroupCheck").d("匹配拉动记录成功: title=$pullTitle, pocGid=$pocGid, createBy=$createBy, isInitiator=$isInitiator")
//
if (isInitiator) { // if (isInitiator) {
isMinimized = true // isMinimized = true
currentTempGroupId = pocGid // currentTempGroupId = pocGid
currentGroupName = pullTitle // currentGroupName = pullTitle
MainActivity.executeJs("onTempCallStateChanged('minimized')") // MainActivity.executeJs("onTempCallStateChanged('minimized')")
if (pocGid.isNotEmpty()) { // if (pocGid.isNotEmpty()) {
MainActivity.executeJs("if(window.startPullGroupLock){ window.startPullGroupLock('$pocGid'); }") // MainActivity.executeJs("if(window.startPullGroupLock){ window.startPullGroupLock('$pocGid'); }")
} // }
} else { // } else {
startTempCallActivity(context, pullTitle, pocGid) // startTempCallActivity(context, pullTitle, pocGid)
} // }
} else { // } else {
if (groupNameFromCall != null) { // if (groupNameFromCall != null) {
startTempCallActivity(context, groupNameFromCall, targetGid ?: "") // startTempCallActivity(context, groupNameFromCall, targetGid ?: "")
} // }
} // }
} else { // } else {
if (groupNameFromCall != null) { // if (groupNameFromCall != null) {
startTempCallActivity(context, groupNameFromCall, targetGid ?: "") // startTempCallActivity(context, groupNameFromCall, targetGid ?: "")
} // }
} // }
} catch (e: Exception) { // } catch (e: Exception) {
Timber.tag("TempGroupCheck").e(e, "解析拉动记录响应失败") // Timber.tag("TempGroupCheck").e(e, "解析拉动记录响应失败")
if (groupNameFromCall != null) { // if (groupNameFromCall != null) {
startTempCallActivity(context, groupNameFromCall, targetGid ?: "") // startTempCallActivity(context, groupNameFromCall, targetGid ?: "")
} // }
} // }
} // }
}) // })
} }
@JvmStatic @JvmStatic