界面状态
This commit is contained in:
parent
4d12f780ea
commit
97276904ff
|
|
@ -158,8 +158,11 @@
|
|||
<div class="ws-card ptt-card">
|
||||
<div style="display: flex; align-items: center; justify-content: space-between;">
|
||||
<strong style="color: #047857;">PTT 业务功能测试</strong>
|
||||
<div style="display: flex; gap: 5px;">
|
||||
<span id="ptt-talk-status" class="ws-status" style="background: #e2e8f0; color: #64748b; display: none;">通话中</span>
|
||||
<span id="ptt-status-tag" class="ws-status ws-disconnected">PTT 未登录</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="ws-input-group" style="margin-top: 10px;">
|
||||
<div style="display: flex; gap: 8px;">
|
||||
|
|
@ -636,6 +639,25 @@
|
|||
pttResult.insertBefore(item, pttResult.firstChild);
|
||||
}
|
||||
|
||||
// 更新 PTT 通话状态 (由 Android 原生同步调用)
|
||||
window.updatePttTalkStatus = function(isTalking) {
|
||||
var statusNode = document.getElementById('ptt-talk-status');
|
||||
if (isTalking) {
|
||||
statusNode.style.display = 'inline-block';
|
||||
statusNode.style.background = '#fee2e2';
|
||||
statusNode.style.color = '#ef4444';
|
||||
statusNode.innerText = '● 正在通话';
|
||||
|
||||
// 如果 UI 按钮还没更新,强制更新一次
|
||||
pttBtn.style.background = "#b91c1c";
|
||||
pttBtn.innerText = "正在通话...";
|
||||
} else {
|
||||
statusNode.style.display = 'none';
|
||||
pttBtn.style.background = "#ef4444";
|
||||
pttBtn.innerText = "长按对讲 (PTT)";
|
||||
}
|
||||
};
|
||||
|
||||
// PTT 登录成功回调 (由 Android 调用)
|
||||
function onPttLoginSuccess() {
|
||||
pttStatusTag.innerText = "PTT 已登录";
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ class AndroidInterface(private val activity: MainActivity) {
|
|||
lastSpeakTime = System.currentTimeMillis()
|
||||
SendAtUtil.speakPlay()
|
||||
Timber.tag("PTT").d("Speak Play")
|
||||
MainActivity.executeJs("updatePttTalkStatus(true)")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -60,6 +61,7 @@ class AndroidInterface(private val activity: MainActivity) {
|
|||
isSpeaking = false
|
||||
SendAtUtil.speakRelease()
|
||||
Timber.tag("PTT").d("Real Speak Release")
|
||||
MainActivity.executeJs("updatePttTalkStatus(false)")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -71,7 +71,10 @@ object GpioManager {
|
|||
lastSpeakTime = System.currentTimeMillis()
|
||||
com.example.kingway.ptt.SendAtUtil.speakPlay()
|
||||
Timber.tag("GPIO").d("PTT Speak Play (Hardware)")
|
||||
// 统一使用 updatePttTalkStatus 更新 UI
|
||||
MainActivity.executeJs("updatePttTalkStatus(true)")
|
||||
}
|
||||
|
||||
} else {
|
||||
// 硬件松开 PTT
|
||||
if (isSpeaking) {
|
||||
|
|
@ -97,6 +100,8 @@ object GpioManager {
|
|||
isSpeaking = false
|
||||
com.example.kingway.ptt.SendAtUtil.speakRelease()
|
||||
Timber.tag("GPIO").d("PTT Speak Release (Hardware)")
|
||||
// 统一使用 updatePttTalkStatus 更新 UI
|
||||
MainActivity.executeJs("updatePttTalkStatus(false)")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue