mirror of
https://github.com/element-hq/element-android
synced 2024-11-28 13:38:49 +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
|
||||
|
||||
interface MxCallDetail {
|
||||
val sessionId: String
|
||||
val callId: String
|
||||
val isOutgoing: Boolean
|
||||
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.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,
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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),
|
||||
|
|
|
@ -339,9 +339,9 @@ class RoomDetailFragment @Inject constructor(
|
|||
}
|
||||
when (mode) {
|
||||
is SendMode.REGULAR -> renderRegularMode(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.REPLY -> renderSpecialMode(mode.timelineEvent, R.drawable.ic_reply, R.string.reply, 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.REPLY -> renderSpecialMode(mode.timelineEvent, R.drawable.ic_reply, R.string.reply, mode.text)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -351,33 +351,33 @@ class RoomDetailFragment @Inject constructor(
|
|||
|
||||
roomDetailViewModel.observeViewEvents {
|
||||
when (it) {
|
||||
is RoomDetailViewEvents.Failure -> showErrorInSnackbar(it.throwable)
|
||||
is RoomDetailViewEvents.OnNewTimelineEvents -> scrollOnNewMessageCallback.addNewTimelineEventIds(it.eventIds)
|
||||
is RoomDetailViewEvents.ActionSuccess -> displayRoomDetailActionSuccess(it)
|
||||
is RoomDetailViewEvents.ActionFailure -> displayRoomDetailActionFailure(it)
|
||||
is RoomDetailViewEvents.ShowMessage -> showSnackWithMessage(it.message, Snackbar.LENGTH_LONG)
|
||||
is RoomDetailViewEvents.NavigateToEvent -> navigateToEvent(it)
|
||||
is RoomDetailViewEvents.FileTooBigError -> displayFileTooBigError(it)
|
||||
is RoomDetailViewEvents.DownloadFileState -> handleDownloadFileState(it)
|
||||
is RoomDetailViewEvents.JoinRoomCommandSuccess -> handleJoinedToAnotherRoom(it)
|
||||
is RoomDetailViewEvents.SendMessageResult -> renderSendMessageResult(it)
|
||||
is RoomDetailViewEvents.ShowE2EErrorMessage -> displayE2eError(it.withHeldCode)
|
||||
RoomDetailViewEvents.DisplayPromptForIntegrationManager -> displayPromptForIntegrationManager()
|
||||
is RoomDetailViewEvents.OpenStickerPicker -> openStickerPicker(it)
|
||||
is RoomDetailViewEvents.Failure -> showErrorInSnackbar(it.throwable)
|
||||
is RoomDetailViewEvents.OnNewTimelineEvents -> scrollOnNewMessageCallback.addNewTimelineEventIds(it.eventIds)
|
||||
is RoomDetailViewEvents.ActionSuccess -> displayRoomDetailActionSuccess(it)
|
||||
is RoomDetailViewEvents.ActionFailure -> displayRoomDetailActionFailure(it)
|
||||
is RoomDetailViewEvents.ShowMessage -> showSnackWithMessage(it.message, Snackbar.LENGTH_LONG)
|
||||
is RoomDetailViewEvents.NavigateToEvent -> navigateToEvent(it)
|
||||
is RoomDetailViewEvents.FileTooBigError -> displayFileTooBigError(it)
|
||||
is RoomDetailViewEvents.DownloadFileState -> handleDownloadFileState(it)
|
||||
is RoomDetailViewEvents.JoinRoomCommandSuccess -> handleJoinedToAnotherRoom(it)
|
||||
is RoomDetailViewEvents.SendMessageResult -> renderSendMessageResult(it)
|
||||
is RoomDetailViewEvents.ShowE2EErrorMessage -> displayE2eError(it.withHeldCode)
|
||||
RoomDetailViewEvents.DisplayPromptForIntegrationManager -> displayPromptForIntegrationManager()
|
||||
is RoomDetailViewEvents.OpenStickerPicker -> openStickerPicker(it)
|
||||
is RoomDetailViewEvents.DisplayEnableIntegrationsWarning -> displayDisabledIntegrationDialog()
|
||||
is RoomDetailViewEvents.OpenIntegrationManager -> openIntegrationManager()
|
||||
is RoomDetailViewEvents.OpenFile -> startOpenFileIntent(it)
|
||||
RoomDetailViewEvents.OpenActiveWidgetBottomSheet -> onViewWidgetsClicked()
|
||||
is RoomDetailViewEvents.ShowInfoOkDialog -> showDialogWithMessage(it.message)
|
||||
is RoomDetailViewEvents.JoinJitsiConference -> joinJitsiRoom(it.widget, it.withVideo)
|
||||
RoomDetailViewEvents.ShowWaitingView -> vectorBaseActivity.showWaitingView()
|
||||
RoomDetailViewEvents.HideWaitingView -> vectorBaseActivity.hideWaitingView()
|
||||
is RoomDetailViewEvents.RequestNativeWidgetPermission -> requestNativeWidgetPermission(it)
|
||||
is RoomDetailViewEvents.OpenRoom -> handleOpenRoom(it)
|
||||
RoomDetailViewEvents.OpenInvitePeople -> navigator.openInviteUsersToRoom(requireContext(), roomDetailArgs.roomId)
|
||||
RoomDetailViewEvents.OpenSetRoomAvatarDialog -> galleryOrCameraDialogHelper.show()
|
||||
RoomDetailViewEvents.OpenRoomSettings -> handleOpenRoomSettings()
|
||||
is RoomDetailViewEvents.ShowRoomAvatarFullScreen -> it.matrixItem?.let { item ->
|
||||
is RoomDetailViewEvents.OpenIntegrationManager -> openIntegrationManager()
|
||||
is RoomDetailViewEvents.OpenFile -> startOpenFileIntent(it)
|
||||
RoomDetailViewEvents.OpenActiveWidgetBottomSheet -> onViewWidgetsClicked()
|
||||
is RoomDetailViewEvents.ShowInfoOkDialog -> showDialogWithMessage(it.message)
|
||||
is RoomDetailViewEvents.JoinJitsiConference -> joinJitsiRoom(it.widget, it.withVideo)
|
||||
RoomDetailViewEvents.ShowWaitingView -> vectorBaseActivity.showWaitingView()
|
||||
RoomDetailViewEvents.HideWaitingView -> vectorBaseActivity.hideWaitingView()
|
||||
is RoomDetailViewEvents.RequestNativeWidgetPermission -> requestNativeWidgetPermission(it)
|
||||
is RoomDetailViewEvents.OpenRoom -> handleOpenRoom(it)
|
||||
RoomDetailViewEvents.OpenInvitePeople -> navigator.openInviteUsersToRoom(requireContext(), roomDetailArgs.roomId)
|
||||
RoomDetailViewEvents.OpenSetRoomAvatarDialog -> galleryOrCameraDialogHelper.show()
|
||||
RoomDetailViewEvents.OpenRoomSettings -> handleOpenRoomSettings()
|
||||
is RoomDetailViewEvents.ShowRoomAvatarFullScreen -> it.matrixItem?.let { item ->
|
||||
navigator.openBigImageViewer(requireActivity(), it.view, item)
|
||||
}
|
||||
}.exhaustive
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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,7 +100,9 @@ class PopupAlertManager @Inject constructor() {
|
|||
if (currentAlerter != null) {
|
||||
weakCurrentActivity?.get()?.let {
|
||||
Alerter.clearCurrent(it)
|
||||
setLightStatusBar()
|
||||
if (currentAlerter?.isLight == false) {
|
||||
setLightStatusBar()
|
||||
}
|
||||
}
|
||||
}
|
||||
weakCurrentActivity = WeakReference(activity)
|
||||
|
@ -195,8 +196,9 @@ class PopupAlertManager @Inject constructor() {
|
|||
}
|
||||
|
||||
private fun showAlert(alert: VectorAlert, activity: Activity, animate: Boolean = true) {
|
||||
clearLightStatusBar()
|
||||
|
||||
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
|
||||
setLightStatusBar()
|
||||
|
||||
if (currentAlerter?.isLight == false) {
|
||||
setLightStatusBar()
|
||||
}
|
||||
currentAlerter = null
|
||||
Handler(Looper.getMainLooper()).postDelayed({
|
||||
displayNextIfPossible()
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue