VoIP: clean after Benoit review

This commit is contained in:
ganfra 2020-12-10 17:56:22 +01:00
parent fe3c080991
commit e4cabe9aa8
8 changed files with 48 additions and 47 deletions

View file

@ -22,7 +22,6 @@ import org.matrix.android.sdk.api.session.room.model.call.SdpType
import org.matrix.android.sdk.api.util.Optional
interface MxCallDetail {
val sessionId: String
val callId: String
val isOutgoing: Boolean
val roomId: String

View file

@ -20,7 +20,6 @@ import org.matrix.android.sdk.api.session.call.MxCall
import org.matrix.android.sdk.api.session.room.model.call.CallInviteContent
import org.matrix.android.sdk.api.util.Optional
import org.matrix.android.sdk.internal.di.DeviceId
import org.matrix.android.sdk.internal.di.SessionId
import org.matrix.android.sdk.internal.di.UserId
import org.matrix.android.sdk.internal.session.call.model.MxCallImpl
import org.matrix.android.sdk.internal.session.room.send.LocalEchoEventFactory
@ -30,7 +29,6 @@ import java.util.UUID
import javax.inject.Inject
internal class MxCallFactory @Inject constructor(
@SessionId private val sessionId: String,
@DeviceId private val deviceId: String?,
private val localEchoEventFactory: LocalEchoEventFactory,
private val eventSenderProcessor: EventSenderProcessor,
@ -40,7 +38,6 @@ internal class MxCallFactory @Inject constructor(
fun createIncomingCall(roomId: String, opponentUserId: String, content: CallInviteContent): MxCall? {
if (content.callId == null) return null
return MxCallImpl(
sessionId = sessionId,
callId = content.callId,
isOutgoing = false,
roomId = roomId,
@ -58,7 +55,6 @@ internal class MxCallFactory @Inject constructor(
fun createOutgoingCall(roomId: String, opponentUserId: String, isVideoCall: Boolean): MxCall {
return MxCallImpl(
sessionId = sessionId,
callId = UUID.randomUUID().toString(),
isOutgoing = true,
roomId = roomId,

View file

@ -40,7 +40,6 @@ import org.matrix.android.sdk.internal.session.room.send.LocalEchoEventFactory
import timber.log.Timber
internal class MxCallImpl(
override val sessionId: String,
override val callId: String,
override val isOutgoing: Boolean,
override val roomId: String,

View file

@ -63,7 +63,7 @@ class IncomingVerificationRequestHandler @Inject constructor(
is VerificationTxState.OnStarted -> {
// Add a notification for every incoming request
val user = session?.getUser(tx.otherUserId)
val name = user?.displayName ?: tx.otherUserId
val name = user?.getBestName() ?: tx.otherUserId
val alert = VerificationVectorAlert(
uid,
context.getString(R.string.sas_incoming_request_notif_title),
@ -122,7 +122,7 @@ class IncomingVerificationRequestHandler @Inject constructor(
// For incoming request we should prompt (if not in activity where this request apply)
if (pr.isIncoming) {
val user = session?.getUser(pr.otherUserId)
val name = user?.displayName ?: pr.otherUserId
val name = user?.getBestName() ?: pr.otherUserId
val alert = VerificationVectorAlert(
uniqueIdForVerificationRequest(pr),

View file

@ -32,6 +32,7 @@ class IncomingCallAlert(uid: String,
override val layoutRes = R.layout.alerter_incoming_call_layout
override var colorAttribute: Int? = R.attr.riotx_alerter_background
override val dismissOnClick: Boolean = false
override val isLight: Boolean = true
class ViewBinder(private val matrixItem: MatrixItem?,
private val avatarRenderer: AvatarRenderer,

View file

@ -22,7 +22,6 @@ import android.os.Handler
import android.os.Looper
import android.view.View
import com.tapadoo.alerter.Alerter
import com.tapadoo.alerter.OnHideAlertListener
import im.vector.app.R
import im.vector.app.core.platform.VectorBaseActivity
import im.vector.app.core.utils.isAnimationDisabled
@ -101,9 +100,11 @@ class PopupAlertManager @Inject constructor() {
if (currentAlerter != null) {
weakCurrentActivity?.get()?.let {
Alerter.clearCurrent(it)
if (currentAlerter?.isLight == false) {
setLightStatusBar()
}
}
}
weakCurrentActivity = WeakReference(activity)
if (!shouldBeDisplayedIn(currentAlerter, activity)) {
return
@ -195,8 +196,9 @@ class PopupAlertManager @Inject constructor() {
}
private fun showAlert(alert: VectorAlert, activity: Activity, animate: Boolean = true) {
if (!alert.isLight) {
clearLightStatusBar()
}
val noAnimation = !animate || isAnimationDisabled(activity)
alert.weakCurrentActivity = WeakReference(activity)
@ -218,7 +220,7 @@ class PopupAlertManager @Inject constructor() {
setIcon(it)
}
alert.actions.forEach { action ->
addButton(action.title, R.style.AlerterButton, View.OnClickListener {
addButton(action.title, R.style.AlerterButton) {
if (action.autoClose) {
currentIsDismissed()
Alerter.hide()
@ -228,7 +230,7 @@ class PopupAlertManager @Inject constructor() {
} catch (e: java.lang.Exception) {
Timber.e("## failed to perform action")
}
})
}
}
setOnClickListener { _ ->
alert.contentAction?.let {
@ -244,7 +246,7 @@ class PopupAlertManager @Inject constructor() {
}
}
}
.setOnHideListener(OnHideAlertListener {
.setOnHideListener {
// called when dismissed on swipe
try {
alert.dismissedAction?.run()
@ -252,7 +254,7 @@ class PopupAlertManager @Inject constructor() {
Timber.e("## failed to perform action")
}
currentIsDismissed()
})
}
.enableSwipeToDismiss()
.enableInfiniteDuration(true)
.apply {
@ -270,8 +272,9 @@ class PopupAlertManager @Inject constructor() {
private fun currentIsDismissed() {
// current alert has been hidden
if (currentAlerter?.isLight == false) {
setLightStatusBar()
}
currentAlerter = null
Handler(Looper.getMainLooper()).postDelayed({
displayNextIfPossible()

View file

@ -33,6 +33,7 @@ interface VectorAlert {
val iconId: Int?
val priority: Int
val dismissOnClick: Boolean
val isLight: Boolean
val shouldBeDisplayedIn: ((Activity) -> Boolean)
data class Button(val title: String, val action: Runnable, val autoClose: Boolean)
@ -99,6 +100,8 @@ open class DefaultVectorAlert(
override val priority: Int = 0
override val isLight: Boolean = false
@ColorRes
override var colorRes: Int? = null