kopia lustrzana https://github.com/ryukoposting/Signal-Android
Apply proper rules for foldable aspect scaling in landscape and tabletop modes.
rodzic
d43f044eb4
commit
c6c4988583
|
@ -105,6 +105,10 @@ public class CallParticipantView extends ConstraintLayout {
|
||||||
renderer.setScalingType(scalingType);
|
renderer.setScalingType(scalingType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setScalingType(@NonNull RendererCommon.ScalingType scalingTypeMatchOrientation, @NonNull RendererCommon.ScalingType scalingTypeMismatchOrientation) {
|
||||||
|
renderer.setScalingType(scalingTypeMatchOrientation, scalingTypeMismatchOrientation);
|
||||||
|
}
|
||||||
|
|
||||||
void setCallParticipant(@NonNull CallParticipant participant) {
|
void setCallParticipant(@NonNull CallParticipant participant) {
|
||||||
boolean participantChanged = recipientId == null || !recipientId.equals(participant.getRecipient().getId());
|
boolean participantChanged = recipientId == null || !recipientId.equals(participant.getRecipient().getId());
|
||||||
recipientId = participant.getRecipient().getId();
|
recipientId = participant.getRecipient().getId();
|
||||||
|
|
|
@ -115,11 +115,7 @@ public class CallParticipantsLayout extends FlexboxLayout {
|
||||||
|
|
||||||
callParticipantView.setCallParticipant(participant);
|
callParticipantView.setCallParticipant(participant);
|
||||||
callParticipantView.setRenderInPip(shouldRenderInPip);
|
callParticipantView.setRenderInPip(shouldRenderInPip);
|
||||||
if (participant.isScreenSharing()) {
|
layoutStrategy.setChildScaling(participant, callParticipantView, isPortrait, count);
|
||||||
callParticipantView.setScalingType(RendererCommon.ScalingType.SCALE_ASPECT_FIT);
|
|
||||||
} else {
|
|
||||||
callParticipantView.setScalingType(isPortrait || count < 3 ? RendererCommon.ScalingType.SCALE_ASPECT_FILL : RendererCommon.ScalingType.SCALE_ASPECT_BALANCED);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (count > 1) {
|
if (count > 1) {
|
||||||
view.setPadding(MULTIPLE_PARTICIPANT_SPACING, MULTIPLE_PARTICIPANT_SPACING, MULTIPLE_PARTICIPANT_SPACING, MULTIPLE_PARTICIPANT_SPACING);
|
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 {
|
public interface LayoutStrategy {
|
||||||
int getFlexDirection();
|
int getFlexDirection();
|
||||||
|
|
||||||
|
void setChildScaling(@NonNull CallParticipant callParticipant,
|
||||||
|
@NonNull CallParticipantView callParticipantView,
|
||||||
|
boolean isPortrait,
|
||||||
|
int childCount);
|
||||||
|
|
||||||
void setChildLayoutParams(@NonNull View child, int childPosition, int childCount);
|
void setChildLayoutParams(@NonNull View child, int childPosition, int childCount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,12 +3,22 @@ package org.thoughtcrime.securesms.components.webrtc
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import com.google.android.flexbox.FlexDirection
|
import com.google.android.flexbox.FlexDirection
|
||||||
import com.google.android.flexbox.FlexboxLayout
|
import com.google.android.flexbox.FlexboxLayout
|
||||||
|
import org.thoughtcrime.securesms.events.CallParticipant
|
||||||
|
import org.webrtc.RendererCommon
|
||||||
|
|
||||||
object CallParticipantsLayoutStrategies {
|
object CallParticipantsLayoutStrategies {
|
||||||
|
|
||||||
private object Portrait : CallParticipantsLayout.LayoutStrategy {
|
private object Portrait : CallParticipantsLayout.LayoutStrategy {
|
||||||
override fun getFlexDirection(): Int = FlexDirection.ROW
|
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) {
|
override fun setChildLayoutParams(child: View, childPosition: Int, childCount: Int) {
|
||||||
val params = child.layoutParams as FlexboxLayout.LayoutParams
|
val params = child.layoutParams as FlexboxLayout.LayoutParams
|
||||||
if (childCount < 3) {
|
if (childCount < 3) {
|
||||||
|
@ -27,6 +37,14 @@ object CallParticipantsLayoutStrategies {
|
||||||
private object Landscape : CallParticipantsLayout.LayoutStrategy {
|
private object Landscape : CallParticipantsLayout.LayoutStrategy {
|
||||||
override fun getFlexDirection() = FlexDirection.COLUMN
|
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) {
|
override fun setChildLayoutParams(child: View, childPosition: Int, childCount: Int) {
|
||||||
val params = child.layoutParams as FlexboxLayout.LayoutParams
|
val params = child.layoutParams as FlexboxLayout.LayoutParams
|
||||||
if (childCount < 4) {
|
if (childCount < 4) {
|
||||||
|
|
Ładowanie…
Reference in New Issue