communicate: one capability-driven call screen for every line
- Commit
0e4debfea7c2e809c088e384e989ab1194e33baf- Author
- vayun-mathur <[email protected]>
- When
- 2026-08-23 01:19 UTC (3 months ago)
- Parents
a772504
Diff
communicate/src/main/java/com/vayunmathur/communicate/MainActivity.kt
diff --git a/communicate/src/main/java/com/vayunmathur/communicate/MainActivity.kt b/communicate/src/main/java/com/vayunmathur/communicate/MainActivity.ktindex b1c1ec00e1..eff1a7f4ec 100644--- a/communicate/src/main/java/com/vayunmathur/communicate/MainActivity.kt+++ b/communicate/src/main/java/com/vayunmathur/communicate/MainActivity.kt@@ -28,6 +28,7 @@ import com.vayunmathur.library.util.rememberNavBackStack import com.vayunmathur.communicate.data.CommunicateLine import com.vayunmathur.communicate.data.googlevoice.GoogleVoiceSession import com.vayunmathur.communicate.data.googlevoice.call.CallPhase+import com.vayunmathur.communicate.data.googlevoice.call.GoogleVoiceCallBridge import com.vayunmathur.communicate.data.googlevoice.call.GoogleVoiceCallManager import com.vayunmathur.communicate.telephony.GoogleVoiceSyncService import com.vayunmathur.communicate.telephony.GoogleVoiceTelecom@@ -40,7 +41,6 @@ import com.vayunmathur.communicate.data.call.InAppCallPhase import com.vayunmathur.communicate.data.call.InAppCallRegistry import com.vayunmathur.communicate.data.whatsapp.call.WhatsAppCallBridge import com.vayunmathur.communicate.telephony.InAppCallTelecom-import com.vayunmathur.communicate.ui.call.CallScreen import com.vayunmathur.communicate.ui.call.InAppCallScreen import com.vayunmathur.communicate.ui.googlevoice.GoogleVoiceSignInScreen import com.vayunmathur.communicate.ui.whatsapp.WhatsAppRegistrationScreen@@ -107,7 +107,6 @@ private fun CommunicateApp() { val waSignedIn by waSession.signedInFlow.collectAsState(initial = false) val sigSession = remember { SignalLineSession.get(context) } val sigSignedIn by sigSession.signedInFlow.collectAsState(initial = false)- val callState by GoogleVoiceCallManager.state.collectAsState() val inAppCallState by InAppCallRegistry.state.collectAsState() // Own the WhatsApp always-on receive state via its foreground sync service (dev-only).@@ -126,6 +125,8 @@ private fun CommunicateApp() { LaunchedEffect(gvSignedIn) { GoogleVoiceCallManager.init(context) GoogleVoiceCallManager.onIncomingCall = { from -> GoogleVoiceTelecom.addIncoming(context, from) }+ // Projects Google Voice call state onto the shared call screen.+ GoogleVoiceCallBridge.ensureStarted() if (gvSignedIn) { val number = session.phoneNumber() ?: context.getString(R.string.account_google_voice) GoogleVoiceTelecom.registerPhoneAccount(context, number)@@ -215,12 +216,9 @@ private fun CommunicateApp() { } } - // In-app call UI overlays everything while a Google Voice VoIP call is in progress.- if (callState.phase != CallPhase.Idle) {- CallScreen(onClose = { GoogleVoiceCallManager.clearEnded() })- } else if (inAppCallState.phase != InAppCallPhase.Idle) {- // WhatsApp and Signal share one screen. Google Voice wins a tie: it is a Telecom-owned call that- // was already on screen.+ // One call screen for every in-app line. Google Voice, WhatsApp and Signal all publish into+ // InAppCallRegistry, and the screen renders whatever the active line supports.+ if (inAppCallState.phase != InAppCallPhase.Idle) { InAppCallScreen(onClose = { InAppCallRegistry.clearEnded() }) } }
communicate/src/main/java/com/vayunmathur/communicate/data/call/InAppCall.kt
diff --git a/communicate/src/main/java/com/vayunmathur/communicate/data/call/InAppCall.kt b/communicate/src/main/java/com/vayunmathur/communicate/data/call/InAppCall.ktindex b2c7f64d91..2614c942a1 100644--- a/communicate/src/main/java/com/vayunmathur/communicate/data/call/InAppCall.kt+++ b/communicate/src/main/java/com/vayunmathur/communicate/data/call/InAppCall.kt@@ -5,6 +5,26 @@ import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.asStateFlow +/**+ * What the line behind the active call can actually do.+ *+ * The call screen is shared across lines, so it renders from this rather than branching on the line:+ * Google Voice has a DTMF keypad but no video, WhatsApp and Signal have video but no keypad. A control the+ * line cannot honour is simply not shown, instead of being present and doing nothing.+ */+data class CallCapabilities(+ val mute: Boolean = true,+ val speaker: Boolean = true,+ val video: Boolean = false,+ val dtmf: Boolean = false,+) {+ companion object {+ val AudioOnly = CallCapabilities()+ val AudioAndVideo = CallCapabilities(video = true)+ val AudioAndKeypad = CallCapabilities(dtmf = true)+ }+}+ /** Phases an in-app VoIP call moves through, shared by every line that isn't handled by the SIM. */ enum class InAppCallPhase { Idle, Outgoing, Incoming, Connecting, Active, Ended } @@ -22,6 +42,7 @@ data class InAppCallState( val peerId: String = "", val peerName: String = "", val isVideo: Boolean = false,+ val capabilities: CallCapabilities = CallCapabilities.AudioOnly, /** Whether the peer is currently sending video, which is independent of whether we are. */ val remoteVideoEnabled: Boolean = false, /** Whether our own camera is on. */@@ -57,6 +78,14 @@ interface InAppCallConnectionBridge { fun onCallEnded() } +/**+ * Tone dialling, for lines that carry a call to the PSTN. Separate from [InAppCallController] because only+ * Google Voice can act on it.+ */+interface InAppCallDtmfController {+ fun sendDtmf(digit: String)+}+ /** * Video capability, separate from [InAppCallController] because not every line has it and the shared screen * should only offer the control when something can act on it.@@ -92,13 +121,21 @@ object InAppCallRegistry { @Volatile var videoController: InAppCallVideoController? = null + /** Set only by lines that can send tones. */+ @Volatile+ var dtmfController: InAppCallDtmfController? = null+ /** Set by the Telecom ConnectionService so state changes can be reflected into the system UI. */ @Volatile var connection: InAppCallConnectionBridge? = null - fun bind(line: CommunicateLine, controller: InAppCallController) {+ fun bind(+ line: CommunicateLine,+ controller: InAppCallController,+ capabilities: CallCapabilities = CallCapabilities.AudioOnly,+ ) { this.controller = controller- _state.value = _state.value.copy(line = line)+ _state.value = _state.value.copy(line = line, capabilities = capabilities) } /** Called by a line when its call starts, so the UI can appear before any media is up. */@@ -108,6 +145,7 @@ object InAppCallRegistry { peerName: String, isVideo: Boolean, incoming: Boolean,+ capabilities: CallCapabilities = _state.value.capabilities, ) { android.util.Log.i(TAG, "call starting: line=$line incoming=$incoming video=$isVideo peer=$peerId") _state.value = InAppCallState(@@ -116,6 +154,7 @@ object InAppCallRegistry { peerId = peerId, peerName = peerName.ifBlank { peerId }, isVideo = isVideo,+ capabilities = capabilities, ) } @@ -175,12 +214,17 @@ object InAppCallRegistry { videoController?.flipCamera() } + fun sendDtmf(digit: String) {+ dtmfController?.sendDtmf(digit)+ }+ /** Called by the UI once a terminal state has been shown, returning to Idle. */ fun clearEnded() { if (_state.value.phase == InAppCallPhase.Ended) { _state.value = InAppCallState() controller = null videoController = null+ dtmfController = null connection = null } }
communicate/src/main/java/com/vayunmathur/communicate/data/googlevoice/call/GoogleVoiceCallBridge.kt
diff --git a/communicate/src/main/java/com/vayunmathur/communicate/data/googlevoice/call/GoogleVoiceCallBridge.kt b/communicate/src/main/java/com/vayunmathur/communicate/data/googlevoice/call/GoogleVoiceCallBridge.ktnew file mode 100644index 0000000000..7f6da1249c--- /dev/null+++ b/communicate/src/main/java/com/vayunmathur/communicate/data/googlevoice/call/GoogleVoiceCallBridge.kt@@ -0,0 +1,81 @@+package com.vayunmathur.communicate.data.googlevoice.call++import com.vayunmathur.communicate.data.CommunicateLine+import com.vayunmathur.communicate.data.call.CallCapabilities+import com.vayunmathur.communicate.data.call.InAppCallController+import com.vayunmathur.communicate.data.call.InAppCallDtmfController+import com.vayunmathur.communicate.data.call.InAppCallPhase+import com.vayunmathur.communicate.data.call.InAppCallRegistry+import kotlinx.coroutines.CoroutineScope+import kotlinx.coroutines.Dispatchers+import kotlinx.coroutines.SupervisorJob+import kotlinx.coroutines.launch+import java.util.concurrent.atomic.AtomicBoolean++/**+ * Mirrors [GoogleVoiceCallManager] into the shared [InAppCallRegistry] so one call screen serves every line.+ *+ * An observer rather than a change inside the manager: Google Voice calling already works end to end,+ * including its own Telecom account, and this only projects the state it already publishes. Google Voice+ * keeps its own `ConnectionService`, so nothing here touches Telecom.+ */+object GoogleVoiceCallBridge {+ private val started = AtomicBoolean(false)+ private val scope = CoroutineScope(SupervisorJob() + Dispatchers.Main.immediate)++ /** Idempotent; safe to call from the activity and from the sync service. */+ fun ensureStarted() {+ if (!started.compareAndSet(false, true)) return+ scope.launch {+ var lastPhase: CallPhase? = null+ GoogleVoiceCallManager.state.collect { state ->+ if (state.phase != lastPhase) {+ val previous = lastPhase+ lastPhase = state.phase+ when (state.phase) {+ CallPhase.Dialing -> start(state, incoming = false)+ CallPhase.Incoming -> start(state, incoming = true)+ // Google Voice reports Ringing for the far end alerting on an outgoing call.+ CallPhase.Ringing -> InAppCallRegistry.onPhase(InAppCallPhase.Outgoing)+ CallPhase.Active -> InAppCallRegistry.onPhase(InAppCallPhase.Active)+ CallPhase.Ended -> InAppCallRegistry.onEnded(null)+ CallPhase.Idle -> if (previous != null) InAppCallRegistry.clearEnded()+ }+ }+ if (state.phase != CallPhase.Idle) {+ InAppCallRegistry.onMuted(state.muted)+ InAppCallRegistry.onSpeaker(state.speaker)+ }+ }+ }+ }++ private fun start(state: CallState, incoming: Boolean) {+ InAppCallRegistry.bind(CommunicateLine.GoogleVoice, controller, CallCapabilities.AudioAndKeypad)+ InAppCallRegistry.dtmfController = dtmf+ InAppCallRegistry.onCallStarting(+ line = CommunicateLine.GoogleVoice,+ peerId = state.remoteNumber,+ peerName = state.remoteNumber,+ isVideo = false,+ incoming = incoming,+ capabilities = CallCapabilities.AudioAndKeypad,+ )+ }++ private val controller = object : InAppCallController {+ override fun answer() = GoogleVoiceCallManager.answer()++ override fun reject() = GoogleVoiceCallManager.reject()++ override fun hangup() = GoogleVoiceCallManager.hangup()++ override fun setMuted(muted: Boolean) = GoogleVoiceCallManager.setMuted(muted)++ override fun setSpeaker(on: Boolean) = GoogleVoiceCallManager.setSpeaker(on)+ }++ private val dtmf = object : InAppCallDtmfController {+ override fun sendDtmf(digit: String) = GoogleVoiceCallManager.sendDtmf(digit)+ }+}
communicate/src/main/java/com/vayunmathur/communicate/data/signal/SignalClient.kt
diff --git a/communicate/src/main/java/com/vayunmathur/communicate/data/signal/SignalClient.kt b/communicate/src/main/java/com/vayunmathur/communicate/data/signal/SignalClient.ktindex 088f06edfd..10b2a61a08 100644--- a/communicate/src/main/java/com/vayunmathur/communicate/data/signal/SignalClient.kt+++ b/communicate/src/main/java/com/vayunmathur/communicate/data/signal/SignalClient.kt@@ -5,6 +5,7 @@ import android.util.Base64 as AndroidBase64 import android.util.Log import com.vayunmathur.communicate.data.signal.e2e.SignalE2E import com.vayunmathur.communicate.data.CommunicateLine+import com.vayunmathur.communicate.data.call.CallCapabilities import com.vayunmathur.communicate.data.call.InAppCallController import com.vayunmathur.communicate.data.call.InAppCallPhase import com.vayunmathur.communicate.data.call.InAppCallRegistry@@ -1396,7 +1397,11 @@ object SignalClient { ) { val current = InAppCallRegistry.state.value if (current.phase == InAppCallPhase.Idle && state != SignalCallManager.CallState.Ended) {- InAppCallRegistry.bind(CommunicateLine.Signal, signalCallController)+ InAppCallRegistry.bind(+ CommunicateLine.Signal,+ signalCallController,+ CallCapabilities.AudioAndVideo,+ ) InAppCallRegistry.videoController = signalVideoController InAppCallRegistry.onCallStarting( line = CommunicateLine.Signal,@@ -1406,6 +1411,7 @@ object SignalClient { // RingRTC reports Ringing for both directions; an inbound call already has an offer // recorded, which is how we tell them apart. incoming = pendingIncomingCallAci == aci,+ capabilities = CallCapabilities.AudioAndVideo, ) } when (state) {
communicate/src/main/java/com/vayunmathur/communicate/data/whatsapp/call/WhatsAppCallBridge.kt
diff --git a/communicate/src/main/java/com/vayunmathur/communicate/data/whatsapp/call/WhatsAppCallBridge.kt b/communicate/src/main/java/com/vayunmathur/communicate/data/whatsapp/call/WhatsAppCallBridge.ktindex 3ad0b91d1e..f06614b321 100644--- a/communicate/src/main/java/com/vayunmathur/communicate/data/whatsapp/call/WhatsAppCallBridge.kt+++ b/communicate/src/main/java/com/vayunmathur/communicate/data/whatsapp/call/WhatsAppCallBridge.kt@@ -2,6 +2,7 @@ package com.vayunmathur.communicate.data.whatsapp.call import android.content.Context import com.vayunmathur.communicate.data.CommunicateLine+import com.vayunmathur.communicate.data.call.CallCapabilities import com.vayunmathur.communicate.data.call.InAppCallController import com.vayunmathur.communicate.data.call.InAppCallPhase import com.vayunmathur.communicate.data.call.InAppCallRegistry@@ -35,24 +36,34 @@ object WhatsAppCallBridge { when (state.phase) { WhatsAppCallPhase.Outgoing -> {- InAppCallRegistry.bind(CommunicateLine.WhatsApp, controller)+ InAppCallRegistry.bind(+ CommunicateLine.WhatsApp,+ controller,+ CallCapabilities.AudioAndVideo,+ ) InAppCallRegistry.onCallStarting( line = CommunicateLine.WhatsApp, peerId = state.peerJid, peerName = state.peerName.ifBlank { state.peerJid }, isVideo = state.isVideo, incoming = false,+ capabilities = CallCapabilities.AudioAndVideo, ) InAppCallTelecom.addOutgoing(appContext, state.peerJid) } WhatsAppCallPhase.Incoming -> {- InAppCallRegistry.bind(CommunicateLine.WhatsApp, controller)+ InAppCallRegistry.bind(+ CommunicateLine.WhatsApp,+ controller,+ CallCapabilities.AudioAndVideo,+ ) InAppCallRegistry.onCallStarting( line = CommunicateLine.WhatsApp, peerId = state.peerJid, peerName = state.peerName.ifBlank { state.peerJid }, isVideo = state.isVideo, incoming = true,+ capabilities = CallCapabilities.AudioAndVideo, ) InAppCallTelecom.addIncoming(appContext, state.peerJid) }
communicate/src/main/java/com/vayunmathur/communicate/ui/call/CallScreen.kt
diff --git a/communicate/src/main/java/com/vayunmathur/communicate/ui/call/CallScreen.kt b/communicate/src/main/java/com/vayunmathur/communicate/ui/call/CallScreen.ktdeleted file mode 100644index 30e32aea13..0000000000--- a/communicate/src/main/java/com/vayunmathur/communicate/ui/call/CallScreen.kt+++ /dev/null@@ -1,183 +0,0 @@-package com.vayunmathur.communicate.ui.call--import androidx.compose.foundation.layout.Arrangement-import androidx.compose.foundation.layout.Box-import androidx.compose.foundation.layout.Column-import androidx.compose.foundation.layout.Row-import androidx.compose.foundation.layout.Spacer-import androidx.compose.foundation.layout.fillMaxSize-import androidx.compose.foundation.layout.fillMaxWidth-import androidx.compose.foundation.layout.padding-import androidx.compose.foundation.layout.size-import androidx.compose.runtime.Composable-import androidx.compose.runtime.LaunchedEffect-import androidx.compose.runtime.collectAsState-import androidx.compose.runtime.getValue-import androidx.compose.runtime.mutableStateOf-import androidx.compose.runtime.remember-import androidx.compose.runtime.setValue-import androidx.compose.ui.Alignment-import androidx.compose.ui.Modifier-import androidx.compose.ui.res.stringResource-import androidx.compose.ui.text.font.FontWeight-import androidx.compose.ui.unit.dp-import com.vayunmathur.communicate.R-import com.vayunmathur.communicate.data.googlevoice.call.CallPhase-import com.vayunmathur.communicate.data.googlevoice.call.GoogleVoiceCallManager-import com.vayunmathur.library.ui.FilledIconButton-import com.vayunmathur.library.ui.IconBackspace-import com.vayunmathur.library.ui.IconCall-import com.vayunmathur.library.ui.IconClose-import com.vayunmathur.library.ui.IconMic-import com.vayunmathur.library.ui.IconMicOff-import com.vayunmathur.library.ui.IconVolumeUp-import com.vayunmathur.library.ui.MaterialTheme-import com.vayunmathur.library.ui.Surface-import com.vayunmathur.library.ui.Text-import com.vayunmathur.library.ui.TextButton--/**- * Full-screen in-app UI for an active/ringing/incoming Google Voice VoIP call. Reads the- * [GoogleVoiceCallManager] state flow and drives its mute / speaker / DTMF / answer / hangup- * controls. Rendered as an overlay by the app when a call is in progress.- */-@Composable-fun CallScreen(onClose: () -> Unit) {- val state by GoogleVoiceCallManager.state.collectAsState()- var showKeypad by remember { mutableStateOf(false) }-- LaunchedEffect(state.phase) {- if (state.phase == CallPhase.Ended || state.phase == CallPhase.Idle) {- GoogleVoiceCallManager.clearEnded()- onClose()- }- }-- Surface(modifier = Modifier.fillMaxSize(), color = MaterialTheme.colorScheme.surface) {- Column(- modifier = Modifier- .fillMaxSize()- .padding(24.dp),- horizontalAlignment = Alignment.CenterHorizontally,- ) {- Spacer(Modifier.size(48.dp))- Text(- state.remoteNumber.ifBlank { stringResource(R.string.account_google_voice) },- style = MaterialTheme.typography.headlineMedium,- fontWeight = FontWeight.SemiBold,- )- Spacer(Modifier.size(8.dp))- Text(- phaseLabel(state.phase),- style = MaterialTheme.typography.bodyLarge,- color = MaterialTheme.colorScheme.onSurfaceVariant,- )-- Spacer(Modifier.weight(1f))-- if (showKeypad) {- DtmfKeypad(- onDigit = { GoogleVoiceCallManager.sendDtmf(it) },- onClose = { showKeypad = false },- )- Spacer(Modifier.size(16.dp))- }-- if (state.phase == CallPhase.Incoming) {- Row(- modifier = Modifier.fillMaxWidth(),- horizontalArrangement = Arrangement.SpaceEvenly,- ) {- CallControl(label = stringResource(R.string.call_decline), destructive = true, onClick = {- GoogleVoiceCallManager.reject()- }) { IconClose() }- CallControl(label = stringResource(R.string.call_answer), onClick = {- GoogleVoiceCallManager.answer()- }) { IconCall() }- }- } else {- Row(- modifier = Modifier.fillMaxWidth(),- horizontalArrangement = Arrangement.SpaceEvenly,- ) {- CallControl(- label = if (state.muted) stringResource(R.string.call_unmute) else stringResource(R.string.call_mute),- onClick = { GoogleVoiceCallManager.setMuted(!state.muted) },- ) { if (state.muted) IconMicOff() else IconMic() }- CallControl(label = stringResource(R.string.call_speaker), onClick = {- GoogleVoiceCallManager.setSpeaker(!state.speaker)- }) { IconVolumeUp() }- CallControl(label = stringResource(R.string.call_keypad), onClick = {- showKeypad = !showKeypad- }) { IconBackspace() }- }- Spacer(Modifier.size(24.dp))- CallControl(label = stringResource(R.string.call_end), destructive = true, onClick = {- GoogleVoiceCallManager.hangup()- }) { IconClose() }- }- Spacer(Modifier.size(24.dp))- }- }-}--@Composable-private fun CallControl(- label: String,- destructive: Boolean = false,- onClick: () -> Unit,- icon: @Composable () -> Unit,-) {- Column(horizontalAlignment = Alignment.CenterHorizontally) {- FilledIconButton(onClick = onClick, modifier = Modifier.size(64.dp)) { icon() }- Spacer(Modifier.size(4.dp))- Text(- label,- style = MaterialTheme.typography.labelSmall,- color = if (destructive) MaterialTheme.colorScheme.error else MaterialTheme.colorScheme.onSurface,- )- }-}--@Composable-private fun DtmfKeypad(onDigit: (String) -> Unit, onClose: () -> Unit) {- val keys = listOf(- listOf("1", "2", "3"),- listOf("4", "5", "6"),- listOf("7", "8", "9"),- listOf("*", "0", "#"),- )- Column(- modifier = Modifier.fillMaxWidth(),- horizontalAlignment = Alignment.CenterHorizontally,- verticalArrangement = Arrangement.spacedBy(6.dp),- ) {- keys.forEach { row ->- Row(horizontalArrangement = Arrangement.spacedBy(24.dp)) {- row.forEach { digit ->- Surface(- onClick = { onDigit(digit) },- shape = androidx.compose.foundation.shape.CircleShape,- color = MaterialTheme.colorScheme.surfaceVariant,- modifier = Modifier.size(56.dp),- ) {- Box(contentAlignment = Alignment.Center) {- Text(digit, style = MaterialTheme.typography.titleLarge)- }- }- }- }- }- TextButton(onClick = onClose) { Text(stringResource(R.string.call_keypad)) }- }-}--@Composable-private fun phaseLabel(phase: CallPhase): String = when (phase) {- CallPhase.Idle -> stringResource(R.string.call_state_idle)- CallPhase.Dialing -> stringResource(R.string.call_state_dialing)- CallPhase.Ringing -> stringResource(R.string.call_state_ringing)- CallPhase.Active -> stringResource(R.string.call_state_active)- CallPhase.Incoming -> stringResource(R.string.call_state_incoming)- CallPhase.Ended -> stringResource(R.string.call_state_ended)-}
communicate/src/main/java/com/vayunmathur/communicate/ui/call/InAppCallScreen.kt
diff --git a/communicate/src/main/java/com/vayunmathur/communicate/ui/call/InAppCallScreen.kt b/communicate/src/main/java/com/vayunmathur/communicate/ui/call/InAppCallScreen.ktindex be297c736d..08bed120fa 100644--- a/communicate/src/main/java/com/vayunmathur/communicate/ui/call/InAppCallScreen.kt+++ b/communicate/src/main/java/com/vayunmathur/communicate/ui/call/InAppCallScreen.kt@@ -1,5 +1,6 @@ package com.vayunmathur.communicate.ui.call +import androidx.compose.foundation.background import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column@@ -10,115 +11,363 @@ import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size+import androidx.compose.foundation.layout.statusBarsPadding+import androidx.compose.foundation.layout.width+import androidx.compose.foundation.shape.CircleShape+import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.collectAsState import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableLongStateOf+import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier+import androidx.compose.ui.draw.clip+import androidx.compose.ui.graphics.Color import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.unit.dp import androidx.compose.ui.viewinterop.AndroidView import com.vayunmathur.communicate.R import com.vayunmathur.communicate.data.CommunicateLine+import com.vayunmathur.communicate.data.call.CallCapabilities import com.vayunmathur.communicate.data.call.InAppCallPhase import com.vayunmathur.communicate.data.call.InAppCallRegistry-import com.vayunmathur.library.ui.FilledIconButton+import com.vayunmathur.communicate.data.call.InAppCallState+import com.vayunmathur.communicate.ui.initialsFor import com.vayunmathur.library.ui.IconCall+import com.vayunmathur.library.ui.IconCallEnd import com.vayunmathur.library.ui.IconCameraOff import com.vayunmathur.library.ui.IconClose+import com.vayunmathur.library.ui.IconDialpad import com.vayunmathur.library.ui.IconFlipCamera import com.vayunmathur.library.ui.IconMic import com.vayunmathur.library.ui.IconMicOff import com.vayunmathur.library.ui.IconVideoCamera import com.vayunmathur.library.ui.IconVolumeUp import com.vayunmathur.library.ui.MaterialTheme+import com.vayunmathur.library.ui.Spacing import com.vayunmathur.library.ui.Surface import com.vayunmathur.library.ui.Text+import com.vayunmathur.library.ui.scrim import kotlinx.coroutines.delay import org.webrtc.RendererCommon import org.webrtc.SurfaceViewRenderer /**- * Full-screen UI for an in-app WhatsApp or Signal call, driven by [InAppCallRegistry].+ * The call screen for every in-app line — Google Voice, WhatsApp and Signal. *- * One screen for both lines: the phases and controls are identical, and only the label differs. Google- * Voice keeps its own screen because it has DTMF and a different phase model.+ * One screen rather than one per line, driven by [CallCapabilities]: Google Voice offers a keypad and no+ * camera, the other two the reverse, and a control the line cannot honour is not drawn at all. That keeps+ * the layout honest — nothing on screen is inert.+ *+ * Hierarchy comes from size and colour rather than from a row of identical buttons: the peer is a large+ * monogram, the primary action (answer / hang up) is a bigger coloured circle, and secondary toggles are+ * smaller and tonal. */ @Composable fun InAppCallScreen(onClose: () -> Unit) { val state by InAppCallRegistry.state.collectAsState()+ var showKeypad by remember { mutableStateOf(false) } - // A terminal state is shown briefly so the outcome is visible, then dismissed.+ // A terminal state is held briefly so the outcome is readable, then dismissed. LaunchedEffect(state.phase) {- if (state.phase == InAppCallPhase.Ended) {- delay(1500)- InAppCallRegistry.clearEnded()- onClose()- } else if (state.phase == InAppCallPhase.Idle) {- onClose()+ when (state.phase) {+ InAppCallPhase.Ended -> {+ delay(1500)+ InAppCallRegistry.clearEnded()+ onClose()+ }+ InAppCallPhase.Idle -> onClose()+ else -> Unit } } + val videoActive = state.remoteVideoEnabled || state.localVideoEnabled+ Surface(modifier = Modifier.fillMaxSize(), color = MaterialTheme.colorScheme.surface) { Box(modifier = Modifier.fillMaxSize()) {- // Video fills the screen behind the controls when either side has a camera on.- if (state.remoteVideoEnabled || state.localVideoEnabled) {- CallVideo(- showRemote = state.remoteVideoEnabled,- showLocal = state.localVideoEnabled,- )+ if (videoActive) {+ CallVideo(showRemote = state.remoteVideoEnabled, showLocal = state.localVideoEnabled)+ // Keeps the name and controls legible over arbitrary video.+ Box(modifier = Modifier.fillMaxSize().scrim { 0.35f }) }+ Column( modifier = Modifier .fillMaxSize()- .padding(24.dp),+ .statusBarsPadding()+ .padding(horizontal = Spacing.xl, vertical = Spacing.lg), horizontalAlignment = Alignment.CenterHorizontally, ) {- Spacer(Modifier.height(48.dp))- Text(- state.peerName,- style = MaterialTheme.typography.headlineSmall,- fontWeight = FontWeight.SemiBold,- )- Spacer(Modifier.height(8.dp))- Text(- phaseLabel(state.phase, state.line, state.endReason),- style = MaterialTheme.typography.bodyMedium,- color = MaterialTheme.colorScheme.onSurfaceVariant,- )- if (state.phase == InAppCallPhase.Active && state.connectedAtMs > 0L) {- Spacer(Modifier.height(4.dp))- CallDuration(state.connectedAtMs)- }+ Spacer(Modifier.height(Spacing.xxl))+ CallHeader(state = state, showMonogram = !videoActive) Spacer(Modifier.weight(1f)) + if (showKeypad && state.capabilities.dtmf) {+ DtmfKeypad(onDigit = { InAppCallRegistry.sendDtmf(it) })+ Spacer(Modifier.height(Spacing.lg))+ }+ when (state.phase) { InAppCallPhase.Incoming -> IncomingControls() InAppCallPhase.Ended -> Unit- else -> InCallControls(- muted = state.muted,- video = state.localVideoEnabled,- canVideo = InAppCallRegistry.videoController != null,+ else -> OngoingControls(+ state = state,+ keypadShown = showKeypad,+ onToggleKeypad = { showKeypad = !showKeypad }, ) }- Spacer(Modifier.height(32.dp))+ Spacer(Modifier.height(Spacing.xl)) } } } } +/** Peer identity and call status. The monogram is dropped when video occupies the screen. */+@Composable+private fun CallHeader(state: InAppCallState, showMonogram: Boolean) {+ if (showMonogram) {+ Box(+ modifier = Modifier+ .size(132.dp)+ .clip(CircleShape)+ .background(MaterialTheme.colorScheme.primaryContainer),+ contentAlignment = Alignment.Center,+ ) {+ Text(+ initialsFor(state.peerName),+ style = MaterialTheme.typography.displaySmall,+ color = MaterialTheme.colorScheme.onPrimaryContainer,+ fontWeight = FontWeight.SemiBold,+ )+ }+ Spacer(Modifier.height(Spacing.xl))+ }+ Text(+ state.peerName,+ style = MaterialTheme.typography.headlineMedium,+ fontWeight = FontWeight.SemiBold,+ )+ Spacer(Modifier.height(Spacing.sm))+ Text(+ callStatusText(state),+ style = MaterialTheme.typography.bodyLarge,+ color = MaterialTheme.colorScheme.onSurfaceVariant,+ )+ if (state.phase == InAppCallPhase.Active && state.connectedAtMs > 0L) {+ Spacer(Modifier.height(Spacing.xs))+ CallDuration(state.connectedAtMs)+ }+}++/** Ticks once a second, so only this subtree recomposes as the call runs. */+@Composable+private fun CallDuration(connectedAtMs: Long) {+ var elapsed by remember(connectedAtMs) { mutableLongStateOf(0L) }+ LaunchedEffect(connectedAtMs) {+ while (true) {+ elapsed = (System.currentTimeMillis() - connectedAtMs).coerceAtLeast(0L) / 1000+ delay(1000)+ }+ }+ Text(+ "%d:%02d".format(elapsed / 60, elapsed % 60),+ style = MaterialTheme.typography.bodyMedium,+ color = MaterialTheme.colorScheme.onSurfaceVariant,+ )+}++/** Decline and answer, weighted equally but coloured oppositely so they cannot be confused. */+@Composable+private fun IncomingControls() {+ Row(+ modifier = Modifier.fillMaxWidth(),+ horizontalArrangement = Arrangement.SpaceEvenly,+ ) {+ CallAction(+ label = stringResource(R.string.call_decline),+ container = MaterialTheme.colorScheme.error,+ content = MaterialTheme.colorScheme.onError,+ size = PRIMARY_ACTION,+ onClick = { InAppCallRegistry.reject() },+ ) { IconCallEnd(tint = it) }+ CallAction(+ label = stringResource(R.string.call_answer),+ container = MaterialTheme.colorScheme.primary,+ content = MaterialTheme.colorScheme.onPrimary,+ size = PRIMARY_ACTION,+ onClick = { InAppCallRegistry.answer() },+ ) { IconCall(tint = it) }+ }+}+ /**- * Renders the call's video.- *- * The renderers share the decoder's EGL context and are attached to the line's sinks for as long as they- * are composed, then detached — a renderer that outlives its composition would be handed frames after- * release.+ * In-call controls, drawn from [CallCapabilities]: only what the line supports appears. Hang up is the+ * largest and the only destructive colour, so it reads as the primary action.+ */+@Composable+private fun OngoingControls(+ state: InAppCallState,+ keypadShown: Boolean,+ onToggleKeypad: () -> Unit,+) {+ val caps = state.capabilities+ Column(horizontalAlignment = Alignment.CenterHorizontally) {+ Row(+ modifier = Modifier.fillMaxWidth(),+ horizontalArrangement = Arrangement.SpaceEvenly,+ ) {+ if (caps.mute) {+ CallToggle(+ label = stringResource(R.string.call_mute),+ active = state.muted,+ onClick = { InAppCallRegistry.toggleMuted() },+ ) { tint -> if (state.muted) IconMicOff(tint = tint) else IconMic(tint = tint) }+ }+ if (caps.speaker) {+ CallToggle(+ label = stringResource(R.string.call_speaker),+ active = state.speaker,+ onClick = { InAppCallRegistry.toggleSpeaker() },+ ) { tint -> IconVolumeUp(tint = tint) }+ }+ if (caps.video) {+ CallToggle(+ label = stringResource(R.string.call_video),+ active = state.localVideoEnabled,+ onClick = { InAppCallRegistry.toggleVideo() },+ ) { tint ->+ if (state.localVideoEnabled) IconVideoCamera(tint = tint) else IconCameraOff(tint = tint)+ }+ }+ if (caps.video && state.localVideoEnabled) {+ CallToggle(+ label = stringResource(R.string.call_flip_camera),+ active = false,+ onClick = { InAppCallRegistry.flipCamera() },+ ) { tint -> IconFlipCamera(tint = tint) }+ }+ if (caps.dtmf) {+ CallToggle(+ label = stringResource(R.string.call_keypad),+ active = keypadShown,+ onClick = onToggleKeypad,+ ) { tint -> IconDialpad(tint = tint) }+ }+ }+ Spacer(Modifier.height(Spacing.xl))+ CallAction(+ label = stringResource(R.string.call_end),+ container = MaterialTheme.colorScheme.error,+ content = MaterialTheme.colorScheme.onError,+ size = PRIMARY_ACTION,+ onClick = { InAppCallRegistry.hangup() },+ ) { IconCallEnd(tint = it) }+ }+}++/** A large, colour-carrying circular action. The library's FilledIconButton takes no colours. */+@Composable+private fun CallAction(+ label: String,+ container: Color,+ content: Color,+ size: Int,+ onClick: () -> Unit,+ icon: @Composable (Color) -> Unit,+) {+ Column(horizontalAlignment = Alignment.CenterHorizontally) {+ Surface(+ onClick = onClick,+ shape = CircleShape,+ color = container,+ contentColor = content,+ modifier = Modifier.size(size.dp),+ ) {+ Box(contentAlignment = Alignment.Center) { icon(content) }+ }+ Spacer(Modifier.height(Spacing.xs))+ Text(label, style = MaterialTheme.typography.labelSmall)+ }+}++/** A secondary toggle. Filled when on, tonal when off, so state is visible without reading the icon. */+@Composable+private fun CallToggle(+ label: String,+ active: Boolean,+ onClick: () -> Unit,+ icon: @Composable (Color) -> Unit,+) {+ val container = if (active) {+ MaterialTheme.colorScheme.primary+ } else {+ MaterialTheme.colorScheme.surfaceVariant+ }+ val content = if (active) {+ MaterialTheme.colorScheme.onPrimary+ } else {+ MaterialTheme.colorScheme.onSurfaceVariant+ }+ Column(horizontalAlignment = Alignment.CenterHorizontally) {+ Surface(+ onClick = onClick,+ shape = CircleShape,+ color = container,+ contentColor = content,+ modifier = Modifier.size(SECONDARY_ACTION.dp),+ ) {+ Box(contentAlignment = Alignment.Center) { icon(content) }+ }+ Spacer(Modifier.height(Spacing.xs))+ Text(+ label,+ style = MaterialTheme.typography.labelSmall,+ color = MaterialTheme.colorScheme.onSurfaceVariant,+ )+ }+}++/** Tone dialling, for lines that reach the PSTN. */+@Composable+private fun DtmfKeypad(onDigit: (String) -> Unit) {+ val rows = listOf(+ listOf("1", "2", "3"),+ listOf("4", "5", "6"),+ listOf("7", "8", "9"),+ listOf("*", "0", "#"),+ )+ Column(+ horizontalAlignment = Alignment.CenterHorizontally,+ verticalArrangement = Arrangement.spacedBy(Spacing.sm),+ ) {+ rows.forEach { row ->+ Row(horizontalArrangement = Arrangement.spacedBy(Spacing.xl)) {+ row.forEach { digit ->+ Surface(+ onClick = { onDigit(digit) },+ shape = CircleShape,+ color = MaterialTheme.colorScheme.surfaceVariant,+ modifier = Modifier.size(56.dp),+ ) {+ Box(contentAlignment = Alignment.Center) {+ Text(digit, style = MaterialTheme.typography.titleLarge)+ }+ }+ }+ }+ }+ }+}++/**+ * Renders the call's video. Renderers share the decoder's EGL context and are detached on release, since a+ * renderer handed frames after release crashes the decoder thread. */ @Composable private fun CallVideo(showRemote: Boolean, showLocal: Boolean) {@@ -152,10 +401,13 @@ private fun CallVideo(showRemote: Boolean, showLocal: Boolean) { setMirror(true) } },+ // Bottom end, clear of the status bar and the header text. modifier = Modifier- .align(Alignment.TopEnd)- .padding(16.dp)- .size(width = 108.dp, height = 144.dp),+ .align(Alignment.BottomEnd)+ .padding(end = Spacing.lg, bottom = 220.dp)+ .width(104.dp)+ .height(140.dp)+ .clip(RoundedCornerShape(Spacing.md)), onRelease = { renderer -> renderer.release() }, update = { renderer -> controller.attachRenderers(local = renderer, remote = null) }, )@@ -163,73 +415,15 @@ private fun CallVideo(showRemote: Boolean, showLocal: Boolean) { } } -/** Ticks once a second so the readout advances without recomposing the whole screen on every frame. */-@Composable-private fun CallDuration(connectedAtMs: Long) {- var elapsed by remember(connectedAtMs) { mutableLongStateOf(0L) }- LaunchedEffect(connectedAtMs) {- while (true) {- elapsed = (System.currentTimeMillis() - connectedAtMs).coerceAtLeast(0L) / 1000- delay(1000)- }- }- val minutes = elapsed / 60- val seconds = elapsed % 60- Text(- "%d:%02d".format(minutes, seconds),- style = MaterialTheme.typography.bodyMedium,- color = MaterialTheme.colorScheme.onSurfaceVariant,- )-}--@Composable-private fun IncomingControls() {- Row(- modifier = Modifier.fillMaxWidth(),- horizontalArrangement = Arrangement.SpaceEvenly,- ) {- CallActionButton(onClick = { InAppCallRegistry.reject() }) { IconClose() }- CallActionButton(onClick = { InAppCallRegistry.answer() }) { IconCall() }- }-}--@Composable-private fun InCallControls(muted: Boolean, video: Boolean, canVideo: Boolean) {- Row(- modifier = Modifier.fillMaxWidth(),- horizontalArrangement = Arrangement.SpaceEvenly,- ) {- CallActionButton(onClick = { InAppCallRegistry.toggleMuted() }) {- if (muted) IconMicOff() else IconMic()- }- CallActionButton(onClick = { InAppCallRegistry.toggleSpeaker() }) { IconVolumeUp() }- if (canVideo) {- CallActionButton(onClick = { InAppCallRegistry.toggleVideo() }) {- if (video) IconCameraOff() else IconVideoCamera()- }- if (video) {- CallActionButton(onClick = { InAppCallRegistry.flipCamera() }) { IconFlipCamera() }- }- }- CallActionButton(onClick = { InAppCallRegistry.hangup() }) { IconClose() }- }-}- @Composable-private fun CallActionButton(onClick: () -> Unit, icon: @Composable () -> Unit) {- Box {- FilledIconButton(onClick = onClick, modifier = Modifier.size(64.dp)) { icon() }- }-}--@Composable-private fun phaseLabel(phase: InAppCallPhase, line: CommunicateLine?, endReason: String?): String {- val lineName = when (line) {+private fun callStatusText(state: InAppCallState): String {+ val lineName = when (state.line) { CommunicateLine.Signal -> stringResource(R.string.account_signal) CommunicateLine.WhatsApp -> stringResource(R.string.account_whatsapp)+ CommunicateLine.GoogleVoice -> stringResource(R.string.account_google_voice) else -> "" }- return when (phase) {+ return when (state.phase) { InAppCallPhase.Outgoing -> stringResource(R.string.call_state_dialing) InAppCallPhase.Incoming -> if (lineName.isBlank()) { stringResource(R.string.call_state_incoming_generic)@@ -237,9 +431,13 @@ private fun phaseLabel(phase: InAppCallPhase, line: CommunicateLine?, endReason: "${stringResource(R.string.call_state_incoming_generic)} - $lineName" } InAppCallPhase.Connecting -> stringResource(R.string.call_state_connecting)+ // Once connected the duration carries the status, so name the line instead. InAppCallPhase.Active -> lineName- InAppCallPhase.Ended -> endReason?.takeIf { it.isNotBlank() }+ InAppCallPhase.Ended -> state.endReason?.takeIf { it.isNotBlank() } ?: stringResource(R.string.call_state_ended) InAppCallPhase.Idle -> "" } }++private const val PRIMARY_ACTION = 72+private const val SECONDARY_ACTION = 56
communicate/src/main/java/com/vayunmathur/communicate/ui/whatsapp/WhatsAppCallScreen.kt
diff --git a/communicate/src/main/java/com/vayunmathur/communicate/ui/whatsapp/WhatsAppCallScreen.kt b/communicate/src/main/java/com/vayunmathur/communicate/ui/whatsapp/WhatsAppCallScreen.ktdeleted file mode 100644index b54b73ef24..0000000000--- a/communicate/src/main/java/com/vayunmathur/communicate/ui/whatsapp/WhatsAppCallScreen.kt+++ /dev/null@@ -1,174 +0,0 @@-package com.vayunmathur.communicate.ui.whatsapp--import androidx.compose.foundation.layout.Arrangement-import androidx.compose.foundation.layout.Box-import androidx.compose.foundation.layout.Column-import androidx.compose.foundation.layout.Row-import androidx.compose.foundation.layout.Spacer-import androidx.compose.foundation.layout.fillMaxSize-import androidx.compose.foundation.layout.fillMaxWidth-import androidx.compose.foundation.layout.height-import androidx.compose.foundation.layout.padding-import androidx.compose.foundation.layout.size-import androidx.compose.foundation.layout.width-import androidx.compose.runtime.Composable-import androidx.compose.runtime.DisposableEffect-import androidx.compose.runtime.LaunchedEffect-import androidx.compose.runtime.collectAsState-import androidx.compose.runtime.getValue-import androidx.compose.runtime.mutableStateOf-import androidx.compose.runtime.remember-import androidx.compose.ui.Alignment-import androidx.compose.ui.Modifier-import androidx.compose.ui.text.font.FontWeight-import androidx.compose.ui.unit.dp-import androidx.compose.ui.viewinterop.AndroidView-import com.vayunmathur.communicate.data.whatsapp.call.WhatsAppCallManager-import com.vayunmathur.communicate.data.whatsapp.call.WhatsAppCallPhase-import com.vayunmathur.library.ui.FilledIconButton-import com.vayunmathur.library.ui.IconCall-import com.vayunmathur.library.ui.IconClose-import com.vayunmathur.library.ui.IconMic-import com.vayunmathur.library.ui.IconMicOff-import com.vayunmathur.library.ui.IconVolumeUp-import com.vayunmathur.library.ui.MaterialTheme-import com.vayunmathur.library.ui.Surface-import com.vayunmathur.library.ui.Text-import org.webrtc.SurfaceViewRenderer--/**- * Full-screen in-app UI for a ringing / incoming / active WhatsApp call (Phase D 3e). Reads the- * [WhatsAppCallManager] state flow and drives answer / decline / mute / speaker / hangup. Rendered- * as an overlay by the app while a call is in progress. Mirrors `ui/call/CallScreen`.- *- * Video render surfaces (local/remote `SurfaceViewRenderer`) are wired via- * [WhatsAppCallManager.attachVideoRenderers]; remote-track rendering is best-effort in this dev- * scaffolding (client-to-client only).- */-@Composable-fun WhatsAppCallScreen(onClose: () -> Unit) {- val state by WhatsAppCallManager.state.collectAsState()-- LaunchedEffect(state.phase) {- if (state.phase == WhatsAppCallPhase.Ended || state.phase == WhatsAppCallPhase.Idle) {- WhatsAppCallManager.clearEnded()- onClose()- }- }-- Surface(modifier = Modifier.fillMaxSize(), color = MaterialTheme.colorScheme.surface) {- Column(- modifier = Modifier- .fillMaxSize()- .padding(24.dp),- horizontalAlignment = Alignment.CenterHorizontally,- verticalArrangement = Arrangement.SpaceBetween,- ) {- Column(horizontalAlignment = Alignment.CenterHorizontally) {- Spacer(Modifier.size(48.dp))- Text(- text = state.peerName.ifEmpty { state.peerJid.substringBefore("@") },- style = MaterialTheme.typography.headlineMedium,- fontWeight = FontWeight.SemiBold,- )- Spacer(Modifier.size(8.dp))- Text(- text = phaseLabel(state.phase, state.isVideo),- style = MaterialTheme.typography.bodyLarge,- color = MaterialTheme.colorScheme.onSurface,- )- if (state.isVideo && state.phase != WhatsAppCallPhase.Incoming) {- Spacer(Modifier.size(16.dp))- VideoSurfaces()- }- }-- when (state.phase) {- WhatsAppCallPhase.Incoming -> IncomingControls()- else -> InCallControls(muted = state.muted, speaker = state.speaker, video = state.isVideo)- }- }- }-}--@Composable-private fun VideoSurfaces() {- val remote = remember { mutableStateOf<SurfaceViewRenderer?>(null) }- val local = remember { mutableStateOf<SurfaceViewRenderer?>(null) }-- DisposableEffect(Unit) {- onDispose { WhatsAppCallManager.attachVideoRenderers(null, null) }- }- LaunchedEffect(remote.value, local.value) {- if (remote.value != null || local.value != null) {- WhatsAppCallManager.attachVideoRenderers(local.value, remote.value)- }- }-- Box(modifier = Modifier.fillMaxWidth().height(320.dp)) {- AndroidView(- factory = { ctx -> SurfaceViewRenderer(ctx).also { remote.value = it } },- modifier = Modifier.fillMaxSize(),- )- AndroidView(- factory = { ctx -> SurfaceViewRenderer(ctx).also { local.value = it } },- modifier = Modifier- .align(Alignment.BottomEnd)- .padding(8.dp)- .width(96.dp)- .height(128.dp),- )- }-}--@Composable-private fun IncomingControls() {- Row(- modifier = Modifier- .fillMaxWidth()- .padding(bottom = 32.dp),- horizontalArrangement = Arrangement.SpaceEvenly,- ) {- FilledIconButton(onClick = { WhatsAppCallManager.reject() }, modifier = Modifier.size(64.dp)) { IconClose() }- FilledIconButton(onClick = { WhatsAppCallManager.answer() }, modifier = Modifier.size(64.dp)) { IconCall() }- }-}--@Composable-private fun InCallControls(muted: Boolean, speaker: Boolean, video: Boolean) {- Column(horizontalAlignment = Alignment.CenterHorizontally) {- Row(- modifier = Modifier- .fillMaxWidth()- .padding(bottom = 16.dp),- horizontalArrangement = Arrangement.SpaceEvenly,- ) {- FilledIconButton(onClick = { WhatsAppCallManager.setMuted(!muted) }, modifier = Modifier.size(64.dp)) {- if (muted) IconMicOff() else IconMic()- }- FilledIconButton(onClick = { WhatsAppCallManager.setSpeaker(!speaker) }, modifier = Modifier.size(64.dp)) {- IconVolumeUp()- }- if (video) {- FilledIconButton(onClick = { WhatsAppCallManager.switchCamera() }, modifier = Modifier.size(64.dp)) {- IconCall()- }- }- }- Box(modifier = Modifier.padding(bottom = 32.dp)) {- FilledIconButton(onClick = { WhatsAppCallManager.hangup() }, modifier = Modifier.size(64.dp)) { IconClose() }- }- }-}--private fun phaseLabel(phase: WhatsAppCallPhase, video: Boolean): String {- val kind = if (video) "Video call" else "Voice call"- return when (phase) {- WhatsAppCallPhase.Outgoing -> "Calling…"- WhatsAppCallPhase.Incoming -> "Incoming $kind"- WhatsAppCallPhase.Connecting -> "Connecting…"- WhatsAppCallPhase.Active -> kind- WhatsAppCallPhase.Ended -> "Call ended"- WhatsAppCallPhase.Idle -> ""- }-}
communicate/src/main/res/values/strings.xml
diff --git a/communicate/src/main/res/values/strings.xml b/communicate/src/main/res/values/strings.xmlindex f3eea77bff..93fc6db79c 100644--- a/communicate/src/main/res/values/strings.xml+++ b/communicate/src/main/res/values/strings.xml@@ -116,6 +116,8 @@ <!-- Shared by the WhatsApp and Signal call UI; call_state_incoming is Google Voice specific. --> <string name="call_state_connecting">Connecting…</string> <string name="call_state_incoming_generic">Incoming call</string>+ <string name="call_video">Video</string>+ <string name="call_flip_camera">Flip</string> <string name="account_whatsapp">WhatsApp</string> <string name="inapp_ongoing_call">Ongoing call</string> <string name="inapp_call_channel_name">Calls</string>
library/e2ee-p2p/build.gradle.kts
diff --git a/library/e2ee-p2p/build.gradle.kts b/library/e2ee-p2p/build.gradle.ktsindex 3f4d525ad7..dde155c04d 100644--- a/library/e2ee-p2p/build.gradle.kts+++ b/library/e2ee-p2p/build.gradle.kts@@ -19,7 +19,9 @@ androidComponents { // Native post-quantum crypto (Rust: fips203 ML-KEM-768 + fips204 ML-DSA-65). // See library/e2ee-p2p/src/main/rust/. Replaces Bouncy Castle; keys cross as DER, // byte-compatible with the previously-deployed BC encoding.-rustNativeLib("e2ee_pqc", "e2ee-pqc")+// armeabi-v7a as well as arm64: :cast:tv runs on 32-bit-userspace Google TV hardware+// and links this .so. Phone apps filter it back out via their arm64-only abiFilters.+rustNativeLib("e2ee_pqc", "e2ee-pqc", extraAbis = listOf(ABI_ARMV7)) dependencies { implementation(libs.cryptography.core)
library/ui/src/main/java/com/vayunmathur/library/ui/Icons.kt
diff --git a/library/ui/src/main/java/com/vayunmathur/library/ui/Icons.kt b/library/ui/src/main/java/com/vayunmathur/library/ui/Icons.ktindex c27e1cab62..8e93ef5718 100644--- a/library/ui/src/main/java/com/vayunmathur/library/ui/Icons.kt+++ b/library/ui/src/main/java/com/vayunmathur/library/ui/Icons.kt@@ -2,6 +2,8 @@ package com.vayunmathur.library.ui import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.AcUnit+import androidx.compose.material.icons.filled.CallEnd+import androidx.compose.material.icons.filled.Dialpad import androidx.compose.material.icons.filled.HealthAndSafety import androidx.compose.material.icons.filled.Medication import androidx.compose.material.icons.filled.MonitorHeart@@ -667,6 +669,14 @@ fun IconStarBorder(modifier: Modifier = Modifier, tint: Color = LocalContentColo fun IconCall(modifier: Modifier = Modifier, tint: Color = LocalContentColor.current) = AppIcon(Icons.Filled.Call, "Call", modifier, tint) +@Composable+fun IconCallEnd(modifier: Modifier = Modifier, tint: Color = LocalContentColor.current) =+ AppIcon(Icons.Filled.CallEnd, "End call", modifier, tint)++@Composable+fun IconDialpad(modifier: Modifier = Modifier, tint: Color = LocalContentColor.current) =+ AppIcon(Icons.Filled.Dialpad, "Keypad", modifier, tint)+ @Composable fun IconChat(modifier: Modifier = Modifier, tint: Color = LocalContentColor.current) = AppIcon(Icons.AutoMirrored.Filled.Chat, "Chat", modifier, tint)