srctree

Robin Linden parent c071efd7 410a39ed
Block starting multiple calls at once via the call notifications

This will be rewritten to hide the accept button, but even then Androidtends to delay replacing notifications, so this is a good safeguard.

inlinesplit
atox/src/main/kotlin/ActionReceiver.kt added: 17, removed: 2, total 15
@@ -20,7 +20,9 @@ import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import ltd.evilcorp.atox.ui.NotificationHelper
import ltd.evilcorp.core.vo.Contact
import ltd.evilcorp.core.vo.UserStatus
import ltd.evilcorp.domain.feature.CallManager
import ltd.evilcorp.domain.feature.CallState
import ltd.evilcorp.domain.feature.ChatManager
import ltd.evilcorp.domain.feature.ContactManager
import ltd.evilcorp.domain.tox.PublicKey
@@ -75,6 +77,18 @@ class ActionReceiver : BroadcastReceiver() {
}
}
 
if (callManager.inCall.value is CallState.InCall) {
withContext(Dispatchers.Main) {
Toast.makeText(
context,
context.getString(R.string.error_simultaneous_calls),
Toast.LENGTH_LONG
).show()
notificationHelper.showPendingCallNotification(UserStatus.Busy, contact)
}
return@launch
}
 
try {
callManager.startCall(pk)
notificationHelper.showOngoingCallNotification(contact)
 
atox/src/main/res/values/strings.xml added: 17, removed: 2, total 15
@@ -150,6 +150,7 @@
 
<string name="call">Call</string>
<string name="microphone_control">Microphone control</string>
<string name="error_simultaneous_calls">You can\'t be in multiple calls at the same time right now</string>
<string name="end_call">End call</string>
<string name="calls">Calls</string>
<string name="ongoing_call">Ongoing call</string>