mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-24 02:15:46 +03:00
VoIP: clean after Benoit review
This commit is contained in:
parent
fe3c080991
commit
e4cabe9aa8
8 changed files with 48 additions and 47 deletions
|
@ -22,7 +22,6 @@ import org.matrix.android.sdk.api.session.room.model.call.SdpType
|
||||||
import org.matrix.android.sdk.api.util.Optional
|
import org.matrix.android.sdk.api.util.Optional
|
||||||
|
|
||||||
interface MxCallDetail {
|
interface MxCallDetail {
|
||||||
val sessionId: String
|
|
||||||
val callId: String
|
val callId: String
|
||||||
val isOutgoing: Boolean
|
val isOutgoing: Boolean
|
||||||
val roomId: String
|
val roomId: String
|
||||||
|
|
|
@ -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.session.room.model.call.CallInviteContent
|
||||||
import org.matrix.android.sdk.api.util.Optional
|
import org.matrix.android.sdk.api.util.Optional
|
||||||
import org.matrix.android.sdk.internal.di.DeviceId
|
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.di.UserId
|
||||||
import org.matrix.android.sdk.internal.session.call.model.MxCallImpl
|
import org.matrix.android.sdk.internal.session.call.model.MxCallImpl
|
||||||
import org.matrix.android.sdk.internal.session.room.send.LocalEchoEventFactory
|
import org.matrix.android.sdk.internal.session.room.send.LocalEchoEventFactory
|
||||||
|
@ -30,7 +29,6 @@ import java.util.UUID
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
internal class MxCallFactory @Inject constructor(
|
internal class MxCallFactory @Inject constructor(
|
||||||
@SessionId private val sessionId: String,
|
|
||||||
@DeviceId private val deviceId: String?,
|
@DeviceId private val deviceId: String?,
|
||||||
private val localEchoEventFactory: LocalEchoEventFactory,
|
private val localEchoEventFactory: LocalEchoEventFactory,
|
||||||
private val eventSenderProcessor: EventSenderProcessor,
|
private val eventSenderProcessor: EventSenderProcessor,
|
||||||
|
@ -40,7 +38,6 @@ internal class MxCallFactory @Inject constructor(
|
||||||
fun createIncomingCall(roomId: String, opponentUserId: String, content: CallInviteContent): MxCall? {
|
fun createIncomingCall(roomId: String, opponentUserId: String, content: CallInviteContent): MxCall? {
|
||||||
if (content.callId == null) return null
|
if (content.callId == null) return null
|
||||||
return MxCallImpl(
|
return MxCallImpl(
|
||||||
sessionId = sessionId,
|
|
||||||
callId = content.callId,
|
callId = content.callId,
|
||||||
isOutgoing = false,
|
isOutgoing = false,
|
||||||
roomId = roomId,
|
roomId = roomId,
|
||||||
|
@ -58,7 +55,6 @@ internal class MxCallFactory @Inject constructor(
|
||||||
|
|
||||||
fun createOutgoingCall(roomId: String, opponentUserId: String, isVideoCall: Boolean): MxCall {
|
fun createOutgoingCall(roomId: String, opponentUserId: String, isVideoCall: Boolean): MxCall {
|
||||||
return MxCallImpl(
|
return MxCallImpl(
|
||||||
sessionId = sessionId,
|
|
||||||
callId = UUID.randomUUID().toString(),
|
callId = UUID.randomUUID().toString(),
|
||||||
isOutgoing = true,
|
isOutgoing = true,
|
||||||
roomId = roomId,
|
roomId = roomId,
|
||||||
|
|
|
@ -40,7 +40,6 @@ import org.matrix.android.sdk.internal.session.room.send.LocalEchoEventFactory
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
|
|
||||||
internal class MxCallImpl(
|
internal class MxCallImpl(
|
||||||
override val sessionId: String,
|
|
||||||
override val callId: String,
|
override val callId: String,
|
||||||
override val isOutgoing: Boolean,
|
override val isOutgoing: Boolean,
|
||||||
override val roomId: String,
|
override val roomId: String,
|
||||||
|
|
|
@ -63,7 +63,7 @@ class IncomingVerificationRequestHandler @Inject constructor(
|
||||||
is VerificationTxState.OnStarted -> {
|
is VerificationTxState.OnStarted -> {
|
||||||
// Add a notification for every incoming request
|
// Add a notification for every incoming request
|
||||||
val user = session?.getUser(tx.otherUserId)
|
val user = session?.getUser(tx.otherUserId)
|
||||||
val name = user?.displayName ?: tx.otherUserId
|
val name = user?.getBestName() ?: tx.otherUserId
|
||||||
val alert = VerificationVectorAlert(
|
val alert = VerificationVectorAlert(
|
||||||
uid,
|
uid,
|
||||||
context.getString(R.string.sas_incoming_request_notif_title),
|
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)
|
// For incoming request we should prompt (if not in activity where this request apply)
|
||||||
if (pr.isIncoming) {
|
if (pr.isIncoming) {
|
||||||
val user = session?.getUser(pr.otherUserId)
|
val user = session?.getUser(pr.otherUserId)
|
||||||
val name = user?.displayName ?: pr.otherUserId
|
val name = user?.getBestName() ?: pr.otherUserId
|
||||||
|
|
||||||
val alert = VerificationVectorAlert(
|
val alert = VerificationVectorAlert(
|
||||||
uniqueIdForVerificationRequest(pr),
|
uniqueIdForVerificationRequest(pr),
|
||||||
|
|
|
@ -32,6 +32,7 @@ class IncomingCallAlert(uid: String,
|
||||||
override val layoutRes = R.layout.alerter_incoming_call_layout
|
override val layoutRes = R.layout.alerter_incoming_call_layout
|
||||||
override var colorAttribute: Int? = R.attr.riotx_alerter_background
|
override var colorAttribute: Int? = R.attr.riotx_alerter_background
|
||||||
override val dismissOnClick: Boolean = false
|
override val dismissOnClick: Boolean = false
|
||||||
|
override val isLight: Boolean = true
|
||||||
|
|
||||||
class ViewBinder(private val matrixItem: MatrixItem?,
|
class ViewBinder(private val matrixItem: MatrixItem?,
|
||||||
private val avatarRenderer: AvatarRenderer,
|
private val avatarRenderer: AvatarRenderer,
|
||||||
|
|
|
@ -22,7 +22,6 @@ import android.os.Handler
|
||||||
import android.os.Looper
|
import android.os.Looper
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import com.tapadoo.alerter.Alerter
|
import com.tapadoo.alerter.Alerter
|
||||||
import com.tapadoo.alerter.OnHideAlertListener
|
|
||||||
import im.vector.app.R
|
import im.vector.app.R
|
||||||
import im.vector.app.core.platform.VectorBaseActivity
|
import im.vector.app.core.platform.VectorBaseActivity
|
||||||
import im.vector.app.core.utils.isAnimationDisabled
|
import im.vector.app.core.utils.isAnimationDisabled
|
||||||
|
@ -101,9 +100,11 @@ class PopupAlertManager @Inject constructor() {
|
||||||
if (currentAlerter != null) {
|
if (currentAlerter != null) {
|
||||||
weakCurrentActivity?.get()?.let {
|
weakCurrentActivity?.get()?.let {
|
||||||
Alerter.clearCurrent(it)
|
Alerter.clearCurrent(it)
|
||||||
|
if (currentAlerter?.isLight == false) {
|
||||||
setLightStatusBar()
|
setLightStatusBar()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
weakCurrentActivity = WeakReference(activity)
|
weakCurrentActivity = WeakReference(activity)
|
||||||
if (!shouldBeDisplayedIn(currentAlerter, activity)) {
|
if (!shouldBeDisplayedIn(currentAlerter, activity)) {
|
||||||
return
|
return
|
||||||
|
@ -195,8 +196,9 @@ class PopupAlertManager @Inject constructor() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun showAlert(alert: VectorAlert, activity: Activity, animate: Boolean = true) {
|
private fun showAlert(alert: VectorAlert, activity: Activity, animate: Boolean = true) {
|
||||||
|
if (!alert.isLight) {
|
||||||
clearLightStatusBar()
|
clearLightStatusBar()
|
||||||
|
}
|
||||||
val noAnimation = !animate || isAnimationDisabled(activity)
|
val noAnimation = !animate || isAnimationDisabled(activity)
|
||||||
|
|
||||||
alert.weakCurrentActivity = WeakReference(activity)
|
alert.weakCurrentActivity = WeakReference(activity)
|
||||||
|
@ -218,7 +220,7 @@ class PopupAlertManager @Inject constructor() {
|
||||||
setIcon(it)
|
setIcon(it)
|
||||||
}
|
}
|
||||||
alert.actions.forEach { action ->
|
alert.actions.forEach { action ->
|
||||||
addButton(action.title, R.style.AlerterButton, View.OnClickListener {
|
addButton(action.title, R.style.AlerterButton) {
|
||||||
if (action.autoClose) {
|
if (action.autoClose) {
|
||||||
currentIsDismissed()
|
currentIsDismissed()
|
||||||
Alerter.hide()
|
Alerter.hide()
|
||||||
|
@ -228,7 +230,7 @@ class PopupAlertManager @Inject constructor() {
|
||||||
} catch (e: java.lang.Exception) {
|
} catch (e: java.lang.Exception) {
|
||||||
Timber.e("## failed to perform action")
|
Timber.e("## failed to perform action")
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
}
|
}
|
||||||
setOnClickListener { _ ->
|
setOnClickListener { _ ->
|
||||||
alert.contentAction?.let {
|
alert.contentAction?.let {
|
||||||
|
@ -244,7 +246,7 @@ class PopupAlertManager @Inject constructor() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.setOnHideListener(OnHideAlertListener {
|
.setOnHideListener {
|
||||||
// called when dismissed on swipe
|
// called when dismissed on swipe
|
||||||
try {
|
try {
|
||||||
alert.dismissedAction?.run()
|
alert.dismissedAction?.run()
|
||||||
|
@ -252,7 +254,7 @@ class PopupAlertManager @Inject constructor() {
|
||||||
Timber.e("## failed to perform action")
|
Timber.e("## failed to perform action")
|
||||||
}
|
}
|
||||||
currentIsDismissed()
|
currentIsDismissed()
|
||||||
})
|
}
|
||||||
.enableSwipeToDismiss()
|
.enableSwipeToDismiss()
|
||||||
.enableInfiniteDuration(true)
|
.enableInfiniteDuration(true)
|
||||||
.apply {
|
.apply {
|
||||||
|
@ -270,8 +272,9 @@ class PopupAlertManager @Inject constructor() {
|
||||||
|
|
||||||
private fun currentIsDismissed() {
|
private fun currentIsDismissed() {
|
||||||
// current alert has been hidden
|
// current alert has been hidden
|
||||||
|
if (currentAlerter?.isLight == false) {
|
||||||
setLightStatusBar()
|
setLightStatusBar()
|
||||||
|
}
|
||||||
currentAlerter = null
|
currentAlerter = null
|
||||||
Handler(Looper.getMainLooper()).postDelayed({
|
Handler(Looper.getMainLooper()).postDelayed({
|
||||||
displayNextIfPossible()
|
displayNextIfPossible()
|
||||||
|
|
|
@ -33,6 +33,7 @@ interface VectorAlert {
|
||||||
val iconId: Int?
|
val iconId: Int?
|
||||||
val priority: Int
|
val priority: Int
|
||||||
val dismissOnClick: Boolean
|
val dismissOnClick: Boolean
|
||||||
|
val isLight: Boolean
|
||||||
val shouldBeDisplayedIn: ((Activity) -> Boolean)
|
val shouldBeDisplayedIn: ((Activity) -> Boolean)
|
||||||
|
|
||||||
data class Button(val title: String, val action: Runnable, val autoClose: 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 priority: Int = 0
|
||||||
|
|
||||||
|
override val isLight: Boolean = false
|
||||||
|
|
||||||
@ColorRes
|
@ColorRes
|
||||||
override var colorRes: Int? = null
|
override var colorRes: Int? = null
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue