临时群
This commit is contained in:
parent
d4801dd02c
commit
1da8168558
|
|
@ -286,12 +286,12 @@ public class CallBackResolution {
|
||||||
}
|
}
|
||||||
} else if (code == 2) {
|
} else if (code == 2) {
|
||||||
// 呼叫失败 → 关闭临时呼叫页面
|
// 呼叫失败 → 关闭临时呼叫页面
|
||||||
if (com.stand.standapp.TempCallActivity.isOpen()) {
|
// if (com.stand.standapp.TempCallActivity.isOpen()) {
|
||||||
com.stand.standapp.TempCallActivity.closeWithMessage("呼叫失败");
|
// com.stand.standapp.TempCallActivity.closeWithMessage("呼叫失败");
|
||||||
} else if (com.stand.standapp.TempCallActivity.isMinimizedState()) {
|
// } else if (com.stand.standapp.TempCallActivity.isMinimizedState()) {
|
||||||
// 最小化状态下收到失败消息,清除状态并通知前端
|
// // 最小化状态下收到失败消息,清除状态并通知前端
|
||||||
com.stand.standapp.TempCallActivity.clearMinimizedState();
|
// com.stand.standapp.TempCallActivity.clearMinimizedState();
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -186,8 +186,11 @@ class LoginActivity : AppCompatActivity() {
|
||||||
|
|
||||||
// 3. 初始化打印机 (异步)
|
// 3. 初始化打印机 (异步)
|
||||||
PrinterManager.init(this@LoginActivity)
|
PrinterManager.init(this@LoginActivity)
|
||||||
|
|
||||||
// 4. 启动 MainActivity,传递登录模式和数据
|
// 4. 检查是否有临时群组,有则打开临时呼叫页面
|
||||||
|
checkTempGroup(username, data)
|
||||||
|
|
||||||
|
// 5. 启动 MainActivity,传递登录模式和数据
|
||||||
val intent = Intent(this@LoginActivity, MainActivity::class.java)
|
val intent = Intent(this@LoginActivity, MainActivity::class.java)
|
||||||
intent.putExtra("official_mode", officialMode)
|
intent.putExtra("official_mode", officialMode)
|
||||||
intent.putExtra("login_data", loginData)
|
intent.putExtra("login_data", loginData)
|
||||||
|
|
@ -266,4 +269,57 @@ class LoginActivity : AppCompatActivity() {
|
||||||
.setNegativeButton("取消", null)
|
.setNegativeButton("取消", null)
|
||||||
.show()
|
.show()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun checkTempGroup(account: String, loginData: org.json.JSONObject?) {
|
||||||
|
val accessToken = loginData?.optString("access_token", "") ?: return
|
||||||
|
if (accessToken.isEmpty()) return
|
||||||
|
|
||||||
|
val serverUrl = AppConfig.getServerUrl(this)
|
||||||
|
val url = "$serverUrl/api/external/ptt/user/groups?account=$account"
|
||||||
|
|
||||||
|
val request = Request.Builder()
|
||||||
|
.url(url)
|
||||||
|
.addHeader("Authorization", "Bearer $accessToken")
|
||||||
|
.get()
|
||||||
|
.build()
|
||||||
|
|
||||||
|
client.newCall(request).enqueue(object : Callback {
|
||||||
|
override fun onFailure(call: Call, e: IOException) {
|
||||||
|
Timber.tag("TempGroup").w(e, "检查临时群组失败")
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onResponse(call: Call, response: Response) {
|
||||||
|
try {
|
||||||
|
val body = response.body?.string() ?: return
|
||||||
|
val json = JSONObject(body)
|
||||||
|
val dataObj = json.optJSONObject("data")
|
||||||
|
val list = dataObj?.optJSONArray("data") ?: return
|
||||||
|
|
||||||
|
for (i in 0 until list.length()) {
|
||||||
|
val group = list.optJSONObject(i) ?: continue
|
||||||
|
val gtype = group.optString("gtype", "")
|
||||||
|
if (gtype == "2") {
|
||||||
|
val gname = group.optString("gname", "临时群组")
|
||||||
|
Timber.tag("TempGroup").d("发现临时群组: $gname")
|
||||||
|
// 打开临时呼叫页面
|
||||||
|
val intent = android.content.Intent(
|
||||||
|
this@LoginActivity,
|
||||||
|
TempCallActivity::class.java
|
||||||
|
)
|
||||||
|
intent.putExtra("group_name", gname)
|
||||||
|
intent.addFlags(
|
||||||
|
android.content.Intent.FLAG_ACTIVITY_NEW_TASK or
|
||||||
|
android.content.Intent.FLAG_ACTIVITY_MULTIPLE_TASK or
|
||||||
|
android.content.Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS
|
||||||
|
)
|
||||||
|
startActivity(intent)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (e: Exception) {
|
||||||
|
Timber.tag("TempGroup").e(e, "解析临时群组响应失败")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -75,7 +75,7 @@
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginBottom="15dp"
|
android:layout_marginBottom="15dp"
|
||||||
android:text="测试账号 锋: test004 助力农: test005 kui: test006 密码: 123456 必须,不然用不了ptt(或者2个后台都要加)"
|
android:text="测试账号 test010 test011 密码: 123456 必须,不然用不了ptt(2个后台都要加账号才能用)"
|
||||||
android:textColor="#CCFFFFFF"
|
android:textColor="#CCFFFFFF"
|
||||||
android:textSize="14sp" />
|
android:textSize="14sp" />
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue