diff --git a/app/src/main/java/org/thoughtcrime/securesms/components/webrtc/CallParticipantsLayout.java b/app/src/main/java/org/thoughtcrime/securesms/components/webrtc/CallParticipantsLayout.java index dfeb82d538..ff8086d5d3 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/components/webrtc/CallParticipantsLayout.java +++ b/app/src/main/java/org/thoughtcrime/securesms/components/webrtc/CallParticipantsLayout.java @@ -34,7 +34,7 @@ public class CallParticipantsLayout extends FlexboxLayout { private CallParticipant focusedParticipant = null; private boolean shouldRenderInPip; private boolean isPortrait; - private boolean isIncomingRing; + private boolean hideAvatar; private int navBarBottomInset; private LayoutStrategy layoutStrategy; @@ -54,7 +54,7 @@ public class CallParticipantsLayout extends FlexboxLayout { @NonNull CallParticipant focusedParticipant, boolean shouldRenderInPip, boolean isPortrait, - boolean isIncomingRing, + boolean hideAvatar, int navBarBottomInset, @NonNull LayoutStrategy layoutStrategy) { @@ -62,7 +62,7 @@ public class CallParticipantsLayout extends FlexboxLayout { this.focusedParticipant = focusedParticipant; this.shouldRenderInPip = shouldRenderInPip; this.isPortrait = isPortrait; - this.isIncomingRing = isIncomingRing; + this.hideAvatar = hideAvatar; this.navBarBottomInset = navBarBottomInset; this.layoutStrategy = layoutStrategy; @@ -134,7 +134,7 @@ public class CallParticipantsLayout extends FlexboxLayout { callParticipantView.setBottomInset(navBarBottomInset); } - if (isIncomingRing) { + if (hideAvatar) { callParticipantView.hideAvatar(); } else { callParticipantView.showAvatar(); diff --git a/app/src/main/java/org/thoughtcrime/securesms/components/webrtc/CallParticipantsState.kt b/app/src/main/java/org/thoughtcrime/securesms/components/webrtc/CallParticipantsState.kt index 8f2544dd40..a516d63534 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/components/webrtc/CallParticipantsState.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/components/webrtc/CallParticipantsState.kt @@ -49,7 +49,7 @@ data class CallParticipantsState( val allRemoteParticipants: List = remoteParticipants.allParticipants val isFolded: Boolean = foldableState.isFolded val isLargeVideoGroup: Boolean = allRemoteParticipants.size > SMALL_GROUP_MAX && !isInPipMode && !isFolded - val isIncomingRing: Boolean = callState == WebRtcViewModel.State.CALL_INCOMING + val hideAvatar: Boolean = callState.isIncomingOrHandledElsewhere val raisedHands: List get() { diff --git a/app/src/main/java/org/thoughtcrime/securesms/components/webrtc/WebRtcCallParticipantsPage.java b/app/src/main/java/org/thoughtcrime/securesms/components/webrtc/WebRtcCallParticipantsPage.java index eba951c4b9..af82bfd15d 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/components/webrtc/WebRtcCallParticipantsPage.java +++ b/app/src/main/java/org/thoughtcrime/securesms/components/webrtc/WebRtcCallParticipantsPage.java @@ -16,7 +16,7 @@ class WebRtcCallParticipantsPage { private final boolean isRenderInPip; private final boolean isPortrait; private final boolean isLandscapeEnabled; - private final boolean isIncomingRing; + private final boolean hideAvatar; private final int navBarBottomInset; static WebRtcCallParticipantsPage forMultipleParticipants(@NonNull List callParticipants, @@ -24,10 +24,10 @@ class WebRtcCallParticipantsPage { boolean isRenderInPip, boolean isPortrait, boolean isLandscapeEnabled, - boolean isIncomingRing, + boolean hideAvatar, int navBarBottomInset) { - return new WebRtcCallParticipantsPage(callParticipants, focusedParticipant, false, isRenderInPip, isPortrait, isLandscapeEnabled, isIncomingRing, navBarBottomInset); + return new WebRtcCallParticipantsPage(callParticipants, focusedParticipant, false, isRenderInPip, isPortrait, isLandscapeEnabled, hideAvatar, navBarBottomInset); } static WebRtcCallParticipantsPage forSingleParticipant(@NonNull CallParticipant singleParticipant, @@ -44,7 +44,7 @@ class WebRtcCallParticipantsPage { boolean isRenderInPip, boolean isPortrait, boolean isLandscapeEnabled, - boolean isIncomingRing, + boolean hideAvatar, int navBarBottomInset) { this.callParticipants = callParticipants; @@ -53,7 +53,7 @@ class WebRtcCallParticipantsPage { this.isRenderInPip = isRenderInPip; this.isPortrait = isPortrait; this.isLandscapeEnabled = isLandscapeEnabled; - this.isIncomingRing = isIncomingRing; + this.hideAvatar = hideAvatar; this.navBarBottomInset = navBarBottomInset; } @@ -77,8 +77,8 @@ class WebRtcCallParticipantsPage { return isPortrait; } - public boolean isIncomingRing() { - return isIncomingRing; + public boolean shouldHideAvatar() { + return hideAvatar; } public int getNavBarBottomInset() { @@ -98,7 +98,7 @@ class WebRtcCallParticipantsPage { isRenderInPip == that.isRenderInPip && isPortrait == that.isPortrait && isLandscapeEnabled == that.isLandscapeEnabled && - isIncomingRing == that.isIncomingRing && + hideAvatar == that.hideAvatar && callParticipants.equals(that.callParticipants) && focusedParticipant.equals(that.focusedParticipant) && navBarBottomInset == that.navBarBottomInset; @@ -106,6 +106,6 @@ class WebRtcCallParticipantsPage { @Override public int hashCode() { - return Objects.hash(callParticipants, focusedParticipant, isSpeaker, isRenderInPip, isPortrait, isLandscapeEnabled, isIncomingRing, navBarBottomInset); + return Objects.hash(callParticipants, focusedParticipant, isSpeaker, isRenderInPip, isPortrait, isLandscapeEnabled, hideAvatar, navBarBottomInset); } } diff --git a/app/src/main/java/org/thoughtcrime/securesms/components/webrtc/WebRtcCallParticipantsPagerAdapter.java b/app/src/main/java/org/thoughtcrime/securesms/components/webrtc/WebRtcCallParticipantsPagerAdapter.java index 7412511261..05bf93bdfc 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/components/webrtc/WebRtcCallParticipantsPagerAdapter.java +++ b/app/src/main/java/org/thoughtcrime/securesms/components/webrtc/WebRtcCallParticipantsPagerAdapter.java @@ -86,7 +86,7 @@ class WebRtcCallParticipantsPagerAdapter extends ListAdapter pages = new ArrayList<>(2); if (!state.getGridParticipants().isEmpty()) { - pages.add(WebRtcCallParticipantsPage.forMultipleParticipants(state.getGridParticipants(), state.getFocusedParticipant(), state.isInPipMode(), isPortrait, isLandscapeEnabled, state.isIncomingRing(), navBarBottomInset)); + pages.add(WebRtcCallParticipantsPage.forMultipleParticipants(state.getGridParticipants(), state.getFocusedParticipant(), state.isInPipMode(), isPortrait, isLandscapeEnabled, state.getHideAvatar(), navBarBottomInset)); } if (state.getFocusedParticipant() != CallParticipant.EMPTY && state.getAllRemoteParticipants().size() > 1) { diff --git a/app/src/main/java/org/thoughtcrime/securesms/components/webrtc/WebRtcCallViewModel.java b/app/src/main/java/org/thoughtcrime/securesms/components/webrtc/WebRtcCallViewModel.java index 3170e6824e..a180777503 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/components/webrtc/WebRtcCallViewModel.java +++ b/app/src/main/java/org/thoughtcrime/securesms/components/webrtc/WebRtcCallViewModel.java @@ -416,6 +416,8 @@ public class WebRtcCallViewModel extends ViewModel { case CALL_ACCEPTED_ELSEWHERE: case CALL_DECLINED_ELSEWHERE: case CALL_ONGOING_ELSEWHERE: + callState = WebRtcControls.CallState.HANDLED_ELSEWHERE; + break; case CALL_NEEDS_PERMISSION: case CALL_BUSY: case CALL_DISCONNECTED: diff --git a/app/src/main/java/org/thoughtcrime/securesms/components/webrtc/WebRtcControls.java b/app/src/main/java/org/thoughtcrime/securesms/components/webrtc/WebRtcControls.java index 518b66b520..7559176cb0 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/components/webrtc/WebRtcControls.java +++ b/app/src/main/java/org/thoughtcrime/securesms/components/webrtc/WebRtcControls.java @@ -105,7 +105,7 @@ public final class WebRtcControls { * This is only true at the very start of a call and will then never be true again */ public boolean hideControlsSheetInitially() { - return displayIncomingCallButtons() || callState == CallState.NONE; + return displayIncomingCallButtons() || callState == CallState.NONE || isHandledElsewhere(); } public boolean displayErrorControls() { @@ -263,6 +263,10 @@ public final class WebRtcControls { return callState == CallState.INCOMING; } + private boolean isHandledElsewhere() { + return callState == CallState.HANDLED_ELSEWHERE; + } + private boolean isAtLeastOutgoing() { return callState.isAtLeast(CallState.OUTGOING); } @@ -284,6 +288,7 @@ public final class WebRtcControls { public enum CallState { NONE, ERROR, + HANDLED_ELSEWHERE, PRE_JOIN, RECONNECTING, INCOMING, diff --git a/app/src/main/java/org/thoughtcrime/securesms/events/WebRtcViewModel.kt b/app/src/main/java/org/thoughtcrime/securesms/events/WebRtcViewModel.kt index 433bc66663..58e5559b6f 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/events/WebRtcViewModel.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/events/WebRtcViewModel.kt @@ -51,6 +51,9 @@ class WebRtcViewModel(state: WebRtcServiceState) { val inOngoingCall: Boolean get() = this == CALL_INCOMING || this == CALL_OUTGOING || this == CALL_CONNECTED || this == CALL_RINGING || this == CALL_RECONNECTING + + val isIncomingOrHandledElsewhere + get() = this == CALL_INCOMING || this == CALL_ACCEPTED_ELSEWHERE || this == CALL_DECLINED_ELSEWHERE || this == CALL_ONGOING_ELSEWHERE } enum class GroupCallState {