srctree

Robin Linden parent 66825e0f 8c3e61ed
Don't play sound from call notification if user is busy

inlinesplit
atox/src/main/kotlin/tox/EventListenerCallbacks.kt added: 6, removed: 4, total 2
@@ -175,7 +175,7 @@ class EventListenerCallbacks @Inject constructor(
Log.e(TAG, "call ${pk.fingerprint()} $audioEnabled $videoEnabled")
scope.launch {
val contact = tryGetContact(pk, "Call") ?: return@launch
notificationHelper.showPendingCallNotification(contact)
notificationHelper.showPendingCallNotification(tox.getStatus(), contact)
callManager.addPendingCall(contact)
}
}
 
atox/src/main/kotlin/ui/NotificationHelper.kt added: 6, removed: 4, total 2
@@ -39,6 +39,7 @@ import ltd.evilcorp.atox.R
import ltd.evilcorp.atox.ui.chat.CONTACT_PUBLIC_KEY
import ltd.evilcorp.core.vo.Contact
import ltd.evilcorp.core.vo.FriendRequest
import ltd.evilcorp.core.vo.UserStatus
import ltd.evilcorp.domain.tox.PublicKey
 
private const val MESSAGE = "aTox messages"
@@ -239,7 +240,7 @@ class NotificationHelper @Inject constructor(
notifier.notify(contact.publicKey.hashCode() + CALL.hashCode(), notificationBuilder.build())
}
 
fun showPendingCallNotification(c: Contact) {
fun showPendingCallNotification(status: UserStatus, c: Contact) {
val notification = NotificationCompat.Builder(context, CALL)
.setCategory(NotificationCompat.CATEGORY_CALL)
.setSmallIcon(android.R.drawable.ic_menu_call)
@@ -296,6 +297,7 @@ class NotificationHelper @Inject constructor(
)
)
.setSound(RingtoneManager.getActualDefaultRingtoneUri(context, RingtoneManager.TYPE_RINGTONE))
.setSilent(status == UserStatus.Busy)
.build()
.apply {
flags = flags.or(NotificationCompat.FLAG_INSISTENT)