From 38f3b88395199317b434ca92f9a4ea59c59258f8 Mon Sep 17 00:00:00 2001 From: ericdecanini Date: Tue, 15 Mar 2022 15:30:02 +0100 Subject: [PATCH 1/6] Adds debug test to check roomSummary for voice call button --- .../features/home/room/detail/RoomDetailViewState.kt | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailViewState.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailViewState.kt index e2b97b0900..4b3fdc4c43 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailViewState.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailViewState.kt @@ -31,6 +31,7 @@ import org.matrix.android.sdk.api.session.sync.SyncState import org.matrix.android.sdk.api.session.threads.ThreadNotificationBadgeState import org.matrix.android.sdk.api.session.widgets.model.Widget import org.matrix.android.sdk.api.session.widgets.model.WidgetType +import timber.log.Timber sealed class UnreadState { object Unknown : UnreadState() @@ -87,7 +88,15 @@ data class RoomDetailViewState( rootThreadEventId = args.threadTimelineArgs?.rootThreadEventId ) - fun isWebRTCCallOptionAvailable() = (asyncRoomSummary.invoke()?.joinedMembersCount ?: 0) <= 2 + // TODO: Add condition here to check that room is DM-based group chat and not group room + fun isWebRTCCallOptionAvailable() = asyncRoomSummary.invoke()?.let { roomSummary -> + val joinedMembersCount = roomSummary.joinedMembersCount ?: 0 + val isDirect = roomSummary.isDirect + Timber.d("WebRTCTest roomSummary: $roomSummary") + Timber.d("WebRTCTest joined members: $joinedMembersCount") + Timber.d("WebRTCTest isDirect: $isDirect") + joinedMembersCount <= 2 + } fun isSearchAvailable() = asyncRoomSummary()?.isEncrypted == false From d74d569f4b9bdccd837272c7cb8b58e2bcd5b6e3 Mon Sep 17 00:00:00 2001 From: ericdecanini Date: Tue, 15 Mar 2022 18:15:46 +0100 Subject: [PATCH 2/6] Adds back default to true on isWebRTCCallOptionAvailable --- .../vector/app/features/home/room/detail/RoomDetailViewState.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailViewState.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailViewState.kt index 4b3fdc4c43..b05cf294cd 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailViewState.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailViewState.kt @@ -96,7 +96,7 @@ data class RoomDetailViewState( Timber.d("WebRTCTest joined members: $joinedMembersCount") Timber.d("WebRTCTest isDirect: $isDirect") joinedMembersCount <= 2 - } + } ?: true // if room summary cannot be found, assume call option should be available fun isSearchAvailable() = asyncRoomSummary()?.isEncrypted == false From 82ead4f3f5756fd7adc60405dab9f9e0db011310 Mon Sep 17 00:00:00 2001 From: ericdecanini Date: Tue, 15 Mar 2022 19:09:19 +0100 Subject: [PATCH 3/6] Replaces call option condition with isDirect --- .../features/home/room/detail/RoomDetailViewState.kt | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailViewState.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailViewState.kt index b05cf294cd..87eae1bc2d 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailViewState.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailViewState.kt @@ -88,15 +88,7 @@ data class RoomDetailViewState( rootThreadEventId = args.threadTimelineArgs?.rootThreadEventId ) - // TODO: Add condition here to check that room is DM-based group chat and not group room - fun isWebRTCCallOptionAvailable() = asyncRoomSummary.invoke()?.let { roomSummary -> - val joinedMembersCount = roomSummary.joinedMembersCount ?: 0 - val isDirect = roomSummary.isDirect - Timber.d("WebRTCTest roomSummary: $roomSummary") - Timber.d("WebRTCTest joined members: $joinedMembersCount") - Timber.d("WebRTCTest isDirect: $isDirect") - joinedMembersCount <= 2 - } ?: true // if room summary cannot be found, assume call option should be available + fun isWebRTCCallOptionAvailable() = asyncRoomSummary.invoke()?.isDirect ?: true fun isSearchAvailable() = asyncRoomSummary()?.isEncrypted == false From 5d496d5f3d3ec1302e76827b98e13034805c7c42 Mon Sep 17 00:00:00 2001 From: ericdecanini Date: Tue, 15 Mar 2022 19:16:04 +0100 Subject: [PATCH 4/6] Adds changelog file --- changelog.d/5548.bugfix | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/5548.bugfix diff --git a/changelog.d/5548.bugfix b/changelog.d/5548.bugfix new file mode 100644 index 0000000000..ccf07a7ee3 --- /dev/null +++ b/changelog.d/5548.bugfix @@ -0,0 +1 @@ +Fixes voice call button disappearing in DM rooms with more than 2 members From f722b2eb85182ea9dffbaaaf2a735c453d0ad2c8 Mon Sep 17 00:00:00 2001 From: ericdecanini Date: Tue, 15 Mar 2022 19:16:22 +0100 Subject: [PATCH 5/6] Removes unused import --- .../vector/app/features/home/room/detail/RoomDetailViewState.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailViewState.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailViewState.kt index 87eae1bc2d..84e618a8fe 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailViewState.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailViewState.kt @@ -31,7 +31,6 @@ import org.matrix.android.sdk.api.session.sync.SyncState import org.matrix.android.sdk.api.session.threads.ThreadNotificationBadgeState import org.matrix.android.sdk.api.session.widgets.model.Widget import org.matrix.android.sdk.api.session.widgets.model.WidgetType -import timber.log.Timber sealed class UnreadState { object Unknown : UnreadState() From bfd31de05ec3250a8e14c9f105491cfbd54445bb Mon Sep 17 00:00:00 2001 From: ericdecanini Date: Tue, 22 Mar 2022 17:56:07 +0100 Subject: [PATCH 6/6] Renames call option to be more agnostic --- .../app/features/call/conference/RemoveJitsiWidgetView.kt | 2 +- .../app/features/home/room/detail/RoomDetailViewState.kt | 2 +- .../app/features/home/room/detail/TimelineViewModel.kt | 6 +++--- vector/src/main/res/menu/menu_timeline.xml | 6 +++--- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/vector/src/main/java/im/vector/app/features/call/conference/RemoveJitsiWidgetView.kt b/vector/src/main/java/im/vector/app/features/call/conference/RemoveJitsiWidgetView.kt index fd7fc31e6d..e7659fb3e6 100644 --- a/vector/src/main/java/im/vector/app/features/call/conference/RemoveJitsiWidgetView.kt +++ b/vector/src/main/java/im/vector/app/features/call/conference/RemoveJitsiWidgetView.kt @@ -88,7 +88,7 @@ import org.matrix.android.sdk.api.session.room.model.Membership fun render(roomDetailViewState: RoomDetailViewState) { val summary = roomDetailViewState.asyncRoomSummary() val newState = if (summary?.membership != Membership.JOIN || - roomDetailViewState.isWebRTCCallOptionAvailable() || + roomDetailViewState.isCallOptionAvailable() || !roomDetailViewState.isAllowedToManageWidgets || roomDetailViewState.jitsiState.widgetId == null) { State.Unmount diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailViewState.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailViewState.kt index 84e618a8fe..09b5211246 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailViewState.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailViewState.kt @@ -87,7 +87,7 @@ data class RoomDetailViewState( rootThreadEventId = args.threadTimelineArgs?.rootThreadEventId ) - fun isWebRTCCallOptionAvailable() = asyncRoomSummary.invoke()?.isDirect ?: true + fun isCallOptionAvailable() = asyncRoomSummary.invoke()?.isDirect ?: true fun isSearchAvailable() = asyncRoomSummary()?.isEncrypted == false diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/TimelineViewModel.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/TimelineViewModel.kt index a9235b5699..a726aea61f 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/TimelineViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/TimelineViewModel.kt @@ -714,10 +714,10 @@ class TimelineViewModel @AssistedInject constructor( R.id.timeline_setting -> true R.id.invite -> state.canInvite R.id.open_matrix_apps -> true - R.id.voice_call -> state.isWebRTCCallOptionAvailable() - R.id.video_call -> state.isWebRTCCallOptionAvailable() || state.jitsiState.confId == null || state.jitsiState.hasJoined + R.id.voice_call -> state.isCallOptionAvailable() + R.id.video_call -> state.isCallOptionAvailable() || state.jitsiState.confId == null || state.jitsiState.hasJoined // Show Join conference button only if there is an active conf id not joined. Otherwise fallback to default video disabled. ^ - R.id.join_conference -> !state.isWebRTCCallOptionAvailable() && state.jitsiState.confId != null && !state.jitsiState.hasJoined + R.id.join_conference -> !state.isCallOptionAvailable() && state.jitsiState.confId != null && !state.jitsiState.hasJoined R.id.search -> state.isSearchAvailable() R.id.menu_timeline_thread_list -> vectorPreferences.areThreadMessagesEnabled() R.id.dev_tools -> vectorPreferences.developerMode() diff --git a/vector/src/main/res/menu/menu_timeline.xml b/vector/src/main/res/menu/menu_timeline.xml index 962c505e4e..98d1beece3 100644 --- a/vector/src/main/res/menu/menu_timeline.xml +++ b/vector/src/main/res/menu/menu_timeline.xml @@ -25,7 +25,7 @@ android:title="@string/action_video_call" android:visible="false" app:iconTint="?colorPrimary" - app:showAsAction="always" + app:showAsAction="ifRoom" tools:visible="true" />