Open element call widget directly if it is the only widget.
This commit is contained in:
parent
9090e37a0f
commit
cf4d2ed6f7
@ -86,4 +86,6 @@ sealed class RoomDetailViewEvents : VectorViewEvents {
|
||||
object RoomReplacementStarted : RoomDetailViewEvents()
|
||||
|
||||
data class ChangeLocationIndicator(val isVisible: Boolean) : RoomDetailViewEvents()
|
||||
|
||||
object OpenElementCallWidget : RoomDetailViewEvents()
|
||||
}
|
||||
|
||||
@ -100,6 +100,8 @@ data class RoomDetailViewState(
|
||||
// It can differs for a short period of time on the JitsiState as its computed async.
|
||||
fun hasActiveJitsiWidget() = activeRoomWidgets()?.any { it.type == WidgetType.Jitsi && it.isActive }.orFalse()
|
||||
|
||||
fun hasActiveElementCallWidget() = activeRoomWidgets()?.any { it.type == WidgetType.ElementCall && it.isActive }.orFalse()
|
||||
|
||||
fun isDm() = asyncRoomSummary()?.isDirect == true
|
||||
|
||||
fun isThreadTimeline() = rootThreadEventId != null
|
||||
|
||||
@ -495,6 +495,7 @@ class TimelineFragment @Inject constructor(
|
||||
is RoomDetailViewEvents.DisplayAndAcceptCall -> acceptIncomingCall(it)
|
||||
RoomDetailViewEvents.RoomReplacementStarted -> handleRoomReplacement()
|
||||
is RoomDetailViewEvents.ChangeLocationIndicator -> handleChangeLocationIndicator(it)
|
||||
RoomDetailViewEvents.OpenElementCallWidget -> handleOpenElementCallWidget()
|
||||
}
|
||||
}
|
||||
|
||||
@ -1099,7 +1100,17 @@ class TimelineFragment @Inject constructor(
|
||||
val matrixAppsMenuItem = menu.findItem(R.id.open_matrix_apps)
|
||||
val widgetsCount = state.activeRoomWidgets.invoke()?.size ?: 0
|
||||
val hasOnlyJitsiWidget = widgetsCount == 1 && state.hasActiveJitsiWidget()
|
||||
if (widgetsCount == 0 || hasOnlyJitsiWidget) {
|
||||
val hasOnlyElementCallWidget = widgetsCount == 1 && state.hasActiveElementCallWidget()
|
||||
if (hasOnlyElementCallWidget) {
|
||||
val actionView = matrixAppsMenuItem.actionView
|
||||
actionView.findViewById<TextView>(R.id.cart_badge).isVisible = false
|
||||
actionView
|
||||
.findViewById<ImageView>(R.id.action_view_icon_image)
|
||||
.apply {
|
||||
setImageResource(R.drawable.ic_phone)
|
||||
setColorFilter(ThemeUtils.getColor(requireContext(), R.attr.colorPrimary))
|
||||
}
|
||||
} else if (widgetsCount == 0 || hasOnlyJitsiWidget) {
|
||||
// icon should be default color no badge
|
||||
val actionView = matrixAppsMenuItem.actionView
|
||||
actionView
|
||||
@ -2638,6 +2649,15 @@ class TimelineFragment @Inject constructor(
|
||||
.show(childFragmentManager, "ROOM_WIDGETS_BOTTOM_SHEET")
|
||||
}
|
||||
|
||||
private fun handleOpenElementCallWidget() = withState(timelineViewModel) { state ->
|
||||
state
|
||||
.activeRoomWidgets()
|
||||
?.find { it.type == WidgetType.ElementCall }
|
||||
?.also { widget ->
|
||||
navigator.openRoomWidget(requireContext(), state.roomId, widget)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onTapToReturnToCall() {
|
||||
callManager.getCurrentCall()?.let { call ->
|
||||
VectorCallActivity.newIntent(
|
||||
|
||||
@ -576,7 +576,10 @@ class TimelineViewModel @AssistedInject constructor(
|
||||
}
|
||||
|
||||
private fun handleManageIntegrations() = withState { state ->
|
||||
if (state.activeRoomWidgets().isNullOrEmpty()) {
|
||||
val isOnlyElementCallWidget = state.activeRoomWidgets()?.size == 1 && state.hasActiveElementCallWidget()
|
||||
if (isOnlyElementCallWidget) {
|
||||
_viewEvents.post(RoomDetailViewEvents.OpenElementCallWidget)
|
||||
} else if (state.activeRoomWidgets().isNullOrEmpty()) {
|
||||
// Directly open integration manager screen
|
||||
handleOpenIntegrationManager()
|
||||
} else {
|
||||
|
||||
@ -58,6 +58,8 @@ fun WebView.setupForWidget(activity: Activity, eventListener: WebEventListener)
|
||||
|
||||
settings.displayZoomControls = false
|
||||
|
||||
settings.mediaPlaybackRequiresUserGesture = false
|
||||
|
||||
// Permission requests
|
||||
webChromeClient = object : WebChromeClient() {
|
||||
override fun onPermissionRequest(request: PermissionRequest) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user