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 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

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.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,

View file

@ -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,

View file

@ -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),

View file

@ -339,9 +339,9 @@ class RoomDetailFragment @Inject constructor(
} }
when (mode) { when (mode) {
is SendMode.REGULAR -> renderRegularMode(mode.text) is SendMode.REGULAR -> renderRegularMode(mode.text)
is SendMode.EDIT -> renderSpecialMode(mode.timelineEvent, R.drawable.ic_edit, R.string.edit, mode.text) is SendMode.EDIT -> renderSpecialMode(mode.timelineEvent, R.drawable.ic_edit, R.string.edit, mode.text)
is SendMode.QUOTE -> renderSpecialMode(mode.timelineEvent, R.drawable.ic_quote, R.string.quote, mode.text) is SendMode.QUOTE -> renderSpecialMode(mode.timelineEvent, R.drawable.ic_quote, R.string.quote, mode.text)
is SendMode.REPLY -> renderSpecialMode(mode.timelineEvent, R.drawable.ic_reply, R.string.reply, mode.text) is SendMode.REPLY -> renderSpecialMode(mode.timelineEvent, R.drawable.ic_reply, R.string.reply, mode.text)
} }
} }
@ -351,33 +351,33 @@ class RoomDetailFragment @Inject constructor(
roomDetailViewModel.observeViewEvents { roomDetailViewModel.observeViewEvents {
when (it) { when (it) {
is RoomDetailViewEvents.Failure -> showErrorInSnackbar(it.throwable) is RoomDetailViewEvents.Failure -> showErrorInSnackbar(it.throwable)
is RoomDetailViewEvents.OnNewTimelineEvents -> scrollOnNewMessageCallback.addNewTimelineEventIds(it.eventIds) is RoomDetailViewEvents.OnNewTimelineEvents -> scrollOnNewMessageCallback.addNewTimelineEventIds(it.eventIds)
is RoomDetailViewEvents.ActionSuccess -> displayRoomDetailActionSuccess(it) is RoomDetailViewEvents.ActionSuccess -> displayRoomDetailActionSuccess(it)
is RoomDetailViewEvents.ActionFailure -> displayRoomDetailActionFailure(it) is RoomDetailViewEvents.ActionFailure -> displayRoomDetailActionFailure(it)
is RoomDetailViewEvents.ShowMessage -> showSnackWithMessage(it.message, Snackbar.LENGTH_LONG) is RoomDetailViewEvents.ShowMessage -> showSnackWithMessage(it.message, Snackbar.LENGTH_LONG)
is RoomDetailViewEvents.NavigateToEvent -> navigateToEvent(it) is RoomDetailViewEvents.NavigateToEvent -> navigateToEvent(it)
is RoomDetailViewEvents.FileTooBigError -> displayFileTooBigError(it) is RoomDetailViewEvents.FileTooBigError -> displayFileTooBigError(it)
is RoomDetailViewEvents.DownloadFileState -> handleDownloadFileState(it) is RoomDetailViewEvents.DownloadFileState -> handleDownloadFileState(it)
is RoomDetailViewEvents.JoinRoomCommandSuccess -> handleJoinedToAnotherRoom(it) is RoomDetailViewEvents.JoinRoomCommandSuccess -> handleJoinedToAnotherRoom(it)
is RoomDetailViewEvents.SendMessageResult -> renderSendMessageResult(it) is RoomDetailViewEvents.SendMessageResult -> renderSendMessageResult(it)
is RoomDetailViewEvents.ShowE2EErrorMessage -> displayE2eError(it.withHeldCode) is RoomDetailViewEvents.ShowE2EErrorMessage -> displayE2eError(it.withHeldCode)
RoomDetailViewEvents.DisplayPromptForIntegrationManager -> displayPromptForIntegrationManager() RoomDetailViewEvents.DisplayPromptForIntegrationManager -> displayPromptForIntegrationManager()
is RoomDetailViewEvents.OpenStickerPicker -> openStickerPicker(it) is RoomDetailViewEvents.OpenStickerPicker -> openStickerPicker(it)
is RoomDetailViewEvents.DisplayEnableIntegrationsWarning -> displayDisabledIntegrationDialog() is RoomDetailViewEvents.DisplayEnableIntegrationsWarning -> displayDisabledIntegrationDialog()
is RoomDetailViewEvents.OpenIntegrationManager -> openIntegrationManager() is RoomDetailViewEvents.OpenIntegrationManager -> openIntegrationManager()
is RoomDetailViewEvents.OpenFile -> startOpenFileIntent(it) is RoomDetailViewEvents.OpenFile -> startOpenFileIntent(it)
RoomDetailViewEvents.OpenActiveWidgetBottomSheet -> onViewWidgetsClicked() RoomDetailViewEvents.OpenActiveWidgetBottomSheet -> onViewWidgetsClicked()
is RoomDetailViewEvents.ShowInfoOkDialog -> showDialogWithMessage(it.message) is RoomDetailViewEvents.ShowInfoOkDialog -> showDialogWithMessage(it.message)
is RoomDetailViewEvents.JoinJitsiConference -> joinJitsiRoom(it.widget, it.withVideo) is RoomDetailViewEvents.JoinJitsiConference -> joinJitsiRoom(it.widget, it.withVideo)
RoomDetailViewEvents.ShowWaitingView -> vectorBaseActivity.showWaitingView() RoomDetailViewEvents.ShowWaitingView -> vectorBaseActivity.showWaitingView()
RoomDetailViewEvents.HideWaitingView -> vectorBaseActivity.hideWaitingView() RoomDetailViewEvents.HideWaitingView -> vectorBaseActivity.hideWaitingView()
is RoomDetailViewEvents.RequestNativeWidgetPermission -> requestNativeWidgetPermission(it) is RoomDetailViewEvents.RequestNativeWidgetPermission -> requestNativeWidgetPermission(it)
is RoomDetailViewEvents.OpenRoom -> handleOpenRoom(it) is RoomDetailViewEvents.OpenRoom -> handleOpenRoom(it)
RoomDetailViewEvents.OpenInvitePeople -> navigator.openInviteUsersToRoom(requireContext(), roomDetailArgs.roomId) RoomDetailViewEvents.OpenInvitePeople -> navigator.openInviteUsersToRoom(requireContext(), roomDetailArgs.roomId)
RoomDetailViewEvents.OpenSetRoomAvatarDialog -> galleryOrCameraDialogHelper.show() RoomDetailViewEvents.OpenSetRoomAvatarDialog -> galleryOrCameraDialogHelper.show()
RoomDetailViewEvents.OpenRoomSettings -> handleOpenRoomSettings() RoomDetailViewEvents.OpenRoomSettings -> handleOpenRoomSettings()
is RoomDetailViewEvents.ShowRoomAvatarFullScreen -> it.matrixItem?.let { item -> is RoomDetailViewEvents.ShowRoomAvatarFullScreen -> it.matrixItem?.let { item ->
navigator.openBigImageViewer(requireActivity(), it.view, item) navigator.openBigImageViewer(requireActivity(), it.view, item)
} }
}.exhaustive }.exhaustive

View file

@ -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,

View file

@ -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,7 +100,9 @@ class PopupAlertManager @Inject constructor() {
if (currentAlerter != null) { if (currentAlerter != null) {
weakCurrentActivity?.get()?.let { weakCurrentActivity?.get()?.let {
Alerter.clearCurrent(it) Alerter.clearCurrent(it)
setLightStatusBar() if (currentAlerter?.isLight == false) {
setLightStatusBar()
}
} }
} }
weakCurrentActivity = WeakReference(activity) weakCurrentActivity = WeakReference(activity)
@ -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) {
clearLightStatusBar() if (!alert.isLight) {
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
setLightStatusBar() if (currentAlerter?.isLight == false) {
setLightStatusBar()
}
currentAlerter = null currentAlerter = null
Handler(Looper.getMainLooper()).postDelayed({ Handler(Looper.getMainLooper()).postDelayed({
displayNextIfPossible() displayNextIfPossible()

View file

@ -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