mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2025-03-16 19:28:54 +03:00
VoIP: show in-notif only when necessary
This commit is contained in:
parent
edf4841371
commit
92fe70c15c
4 changed files with 22 additions and 5 deletions
|
@ -24,12 +24,15 @@ import android.support.v4.media.session.MediaSessionCompat
|
|||
import android.view.KeyEvent
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.media.session.MediaButtonReceiver
|
||||
import com.airbnb.mvrx.MvRx
|
||||
import im.vector.app.core.extensions.vectorComponent
|
||||
import im.vector.app.features.call.CallArgs
|
||||
import im.vector.app.features.call.VectorCallActivity
|
||||
import im.vector.app.features.call.telecom.CallConnection
|
||||
import im.vector.app.features.call.webrtc.WebRtcCall
|
||||
import im.vector.app.features.call.webrtc.WebRtcCallManager
|
||||
import im.vector.app.features.home.AvatarRenderer
|
||||
import im.vector.app.features.home.room.detail.RoomDetailActivity
|
||||
import im.vector.app.features.notifications.NotificationUtils
|
||||
import im.vector.app.features.popup.IncomingCallAlert
|
||||
import im.vector.app.features.popup.PopupAlertManager
|
||||
|
@ -169,7 +172,15 @@ class CallService : VectorService(), WiredHeadsetStateReceiver.HeadsetEventListe
|
|||
Timber.v("displayIncomingCallNotification : display the dedicated notification")
|
||||
if (!fromBg) {
|
||||
// Show in-app notification if app is in foreground.
|
||||
val incomingCallAlert = IncomingCallAlert(INCOMING_CALL_ALERT_UID).apply {
|
||||
val incomingCallAlert = IncomingCallAlert(INCOMING_CALL_ALERT_UID,
|
||||
shouldBeDisplayedIn = { activity ->
|
||||
if (activity is RoomDetailActivity) {
|
||||
call.roomId != activity.currentRoomId
|
||||
} else if(activity is VectorCallActivity) {
|
||||
activity.intent.getParcelableExtra<CallArgs>(MvRx.KEY_ARG)?.callId != call.callId
|
||||
} else true
|
||||
}
|
||||
).apply {
|
||||
viewBinder = IncomingCallAlert.ViewBinder(
|
||||
matrixItem = opponentMatrixItem,
|
||||
avatarRenderer = avatarRenderer,
|
||||
|
|
|
@ -32,6 +32,7 @@ class IncomingCallAlert(uid: String,
|
|||
override val priority = PopupAlertManager.INCOMING_CALL_PRIORITY
|
||||
override val layoutRes = R.layout.alerter_incoming_call_layout
|
||||
override var colorAttribute: Int? = R.attr.riotx_alerter_background
|
||||
override val dismissOnClick: Boolean = false
|
||||
|
||||
class ViewBinder(private val matrixItem: MatrixItem?,
|
||||
private val avatarRenderer: AvatarRenderer,
|
||||
|
|
|
@ -230,17 +230,19 @@ class PopupAlertManager @Inject constructor() {
|
|||
}
|
||||
})
|
||||
}
|
||||
setOnClickListener(View.OnClickListener { _ ->
|
||||
setOnClickListener { _ ->
|
||||
alert.contentAction?.let {
|
||||
currentIsDismissed()
|
||||
Alerter.hide()
|
||||
if (alert.dismissOnClick) {
|
||||
currentIsDismissed()
|
||||
Alerter.hide()
|
||||
}
|
||||
try {
|
||||
it.run()
|
||||
} catch (e: java.lang.Exception) {
|
||||
Timber.e("## failed to perform action")
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
.setOnHideListener(OnHideAlertListener {
|
||||
// called when dismissed on swipe
|
||||
|
|
|
@ -35,6 +35,7 @@ interface VectorAlert {
|
|||
val description: String
|
||||
val iconId: Int?
|
||||
val priority: Int
|
||||
val dismissOnClick: Boolean
|
||||
val shouldBeDisplayedIn: ((Activity) -> Boolean)
|
||||
|
||||
data class Button(val title: String, val action: Runnable, val autoClose: Boolean)
|
||||
|
@ -99,6 +100,8 @@ open class DefaultVectorAlert(
|
|||
@LayoutRes
|
||||
override val layoutRes = R.layout.alerter_alert_default_layout
|
||||
|
||||
override val dismissOnClick: Boolean = true
|
||||
|
||||
override val priority: Int = 0
|
||||
|
||||
@ColorRes
|
||||
|
|
Loading…
Add table
Reference in a new issue