Apply proper rules for foldable aspect scaling in landscape and tabletop modes.

fork-5.53.8
Alex Hart 2021-08-04 10:57:21 -03:00 zatwierdzone przez GitHub
rodzic d43f044eb4
commit c6c4988583
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
3 zmienionych plików z 28 dodań i 5 usunięć

Wyświetl plik

@ -105,6 +105,10 @@ public class CallParticipantView extends ConstraintLayout {
renderer.setScalingType(scalingType);
}
void setScalingType(@NonNull RendererCommon.ScalingType scalingTypeMatchOrientation, @NonNull RendererCommon.ScalingType scalingTypeMismatchOrientation) {
renderer.setScalingType(scalingTypeMatchOrientation, scalingTypeMismatchOrientation);
}
void setCallParticipant(@NonNull CallParticipant participant) {
boolean participantChanged = recipientId == null || !recipientId.equals(participant.getRecipient().getId());
recipientId = participant.getRecipient().getId();

Wyświetl plik

@ -115,11 +115,7 @@ public class CallParticipantsLayout extends FlexboxLayout {
callParticipantView.setCallParticipant(participant);
callParticipantView.setRenderInPip(shouldRenderInPip);
if (participant.isScreenSharing()) {
callParticipantView.setScalingType(RendererCommon.ScalingType.SCALE_ASPECT_FIT);
} else {
callParticipantView.setScalingType(isPortrait || count < 3 ? RendererCommon.ScalingType.SCALE_ASPECT_FILL : RendererCommon.ScalingType.SCALE_ASPECT_BALANCED);
}
layoutStrategy.setChildScaling(participant, callParticipantView, isPortrait, count);
if (count > 1) {
view.setPadding(MULTIPLE_PARTICIPANT_SPACING, MULTIPLE_PARTICIPANT_SPACING, MULTIPLE_PARTICIPANT_SPACING, MULTIPLE_PARTICIPANT_SPACING);
@ -150,6 +146,11 @@ public class CallParticipantsLayout extends FlexboxLayout {
public interface LayoutStrategy {
int getFlexDirection();
void setChildScaling(@NonNull CallParticipant callParticipant,
@NonNull CallParticipantView callParticipantView,
boolean isPortrait,
int childCount);
void setChildLayoutParams(@NonNull View child, int childPosition, int childCount);
}
}

Wyświetl plik

@ -3,12 +3,22 @@ package org.thoughtcrime.securesms.components.webrtc
import android.view.View
import com.google.android.flexbox.FlexDirection
import com.google.android.flexbox.FlexboxLayout
import org.thoughtcrime.securesms.events.CallParticipant
import org.webrtc.RendererCommon
object CallParticipantsLayoutStrategies {
private object Portrait : CallParticipantsLayout.LayoutStrategy {
override fun getFlexDirection(): Int = FlexDirection.ROW
override fun setChildScaling(callParticipant: CallParticipant, callParticipantView: CallParticipantView, isPortrait: Boolean, childCount: Int) {
if (callParticipant.isScreenSharing) {
callParticipantView.setScalingType(RendererCommon.ScalingType.SCALE_ASPECT_FIT)
} else {
callParticipantView.setScalingType(if (isPortrait || childCount < 3) RendererCommon.ScalingType.SCALE_ASPECT_FILL else RendererCommon.ScalingType.SCALE_ASPECT_BALANCED)
}
}
override fun setChildLayoutParams(child: View, childPosition: Int, childCount: Int) {
val params = child.layoutParams as FlexboxLayout.LayoutParams
if (childCount < 3) {
@ -27,6 +37,14 @@ object CallParticipantsLayoutStrategies {
private object Landscape : CallParticipantsLayout.LayoutStrategy {
override fun getFlexDirection() = FlexDirection.COLUMN
override fun setChildScaling(callParticipant: CallParticipant, callParticipantView: CallParticipantView, isPortrait: Boolean, childCount: Int) {
if (callParticipant.isScreenSharing) {
callParticipantView.setScalingType(RendererCommon.ScalingType.SCALE_ASPECT_FIT)
} else {
callParticipantView.setScalingType(RendererCommon.ScalingType.SCALE_ASPECT_FILL, RendererCommon.ScalingType.SCALE_ASPECT_BALANCED)
}
}
override fun setChildLayoutParams(child: View, childPosition: Int, childCount: Int) {
val params = child.layoutParams as FlexboxLayout.LayoutParams
if (childCount < 4) {