Ensure landscape operation is only enabled on foldable displays.

This commit is contained in:
Alex Hart
2021-08-02 09:55:58 -03:00
committed by Greyson Parrelli
parent 922d0d7203
commit 52978b1b42
5 changed files with 41 additions and 37 deletions

View File

@@ -43,8 +43,8 @@ object CallParticipantsLayoutStrategies {
}
@JvmStatic
fun getStrategy(isPortrait: Boolean): CallParticipantsLayout.LayoutStrategy {
return if (isPortrait) {
fun getStrategy(isPortrait: Boolean, isLandscapeEnabled: Boolean): CallParticipantsLayout.LayoutStrategy {
return if (isPortrait || !isLandscapeEnabled) {
Portrait
} else {
Landscape

View File

@@ -15,33 +15,38 @@ class WebRtcCallParticipantsPage {
private final boolean isSpeaker;
private final boolean isRenderInPip;
private final boolean isPortrait;
private final boolean isLandscapeEnabled;
static WebRtcCallParticipantsPage forMultipleParticipants(@NonNull List<CallParticipant> callParticipants,
@NonNull CallParticipant focusedParticipant,
boolean isRenderInPip,
boolean isPortrait)
boolean isPortrait,
boolean isLandscapeEnabled)
{
return new WebRtcCallParticipantsPage(callParticipants, focusedParticipant, false, isRenderInPip, isPortrait);
return new WebRtcCallParticipantsPage(callParticipants, focusedParticipant, false, isRenderInPip, isPortrait, isLandscapeEnabled);
}
static WebRtcCallParticipantsPage forSingleParticipant(@NonNull CallParticipant singleParticipant,
boolean isRenderInPip,
boolean isPortrait)
boolean isPortrait,
boolean isLandscapeEnabled)
{
return new WebRtcCallParticipantsPage(Collections.singletonList(singleParticipant), singleParticipant, true, isRenderInPip, isPortrait);
return new WebRtcCallParticipantsPage(Collections.singletonList(singleParticipant), singleParticipant, true, isRenderInPip, isPortrait, isLandscapeEnabled);
}
private WebRtcCallParticipantsPage(@NonNull List<CallParticipant> callParticipants,
@NonNull CallParticipant focusedParticipant,
boolean isSpeaker,
boolean isRenderInPip,
boolean isPortrait)
boolean isPortrait,
boolean isLandscapeEnabled)
{
this.callParticipants = callParticipants;
this.focusedParticipant = focusedParticipant;
this.isSpeaker = isSpeaker;
this.isRenderInPip = isRenderInPip;
this.isPortrait = isPortrait;
this.isLandscapeEnabled = isLandscapeEnabled;
}
public @NonNull List<CallParticipant> getCallParticipants() {
@@ -65,7 +70,7 @@ class WebRtcCallParticipantsPage {
}
public @NonNull CallParticipantsLayout.LayoutStrategy getLayoutStrategy() {
return CallParticipantsLayoutStrategies.getStrategy(isPortrait);
return CallParticipantsLayoutStrategies.getStrategy(isPortrait, isLandscapeEnabled);
}
@Override

View File

@@ -49,6 +49,7 @@ import org.thoughtcrime.securesms.util.ServiceUtil;
import org.thoughtcrime.securesms.util.SetUtil;
import org.thoughtcrime.securesms.util.ViewUtil;
import org.thoughtcrime.securesms.util.views.Stub;
import org.thoughtcrime.securesms.webrtc.CallParticipantsViewState;
import org.webrtc.RendererCommon;
import org.whispersystems.signalservice.api.messages.calls.HangupMessage;
@@ -318,15 +319,18 @@ public class WebRtcCallView extends ConstraintLayout {
micToggle.setChecked(isMicEnabled, false);
}
public void updateCallParticipants(@NonNull CallParticipantsState state, boolean isPortrait) {
List<WebRtcCallParticipantsPage> pages = new ArrayList<>(2);
public void updateCallParticipants(@NonNull CallParticipantsViewState callParticipantsViewState) {
CallParticipantsState state = callParticipantsViewState.getCallParticipantsState();
boolean isPortrait = callParticipantsViewState.isPortrait();
boolean isLandscapeEnabled = callParticipantsViewState.isLandscapeEnabled();
List<WebRtcCallParticipantsPage> pages = new ArrayList<>(2);
if (!state.getGridParticipants().isEmpty()) {
pages.add(WebRtcCallParticipantsPage.forMultipleParticipants(state.getGridParticipants(), state.getFocusedParticipant(), state.isInPipMode(), isPortrait));
pages.add(WebRtcCallParticipantsPage.forMultipleParticipants(state.getGridParticipants(), state.getFocusedParticipant(), state.isInPipMode(), isPortrait, isLandscapeEnabled));
}
if (state.getFocusedParticipant() != CallParticipant.EMPTY && state.getAllRemoteParticipants().size() > 1) {
pages.add(WebRtcCallParticipantsPage.forSingleParticipant(state.getFocusedParticipant(), state.isInPipMode(), isPortrait));
pages.add(WebRtcCallParticipantsPage.forSingleParticipant(state.getFocusedParticipant(), state.isInPipMode(), isPortrait, isLandscapeEnabled));
}
if ((state.getGroupCallState().isNotIdle() && state.getRemoteDevicesCount().orElse(0) > 0) || state.getGroupCallState().isConnected()) {