mirror of
https://github.com/oxen-io/session-android.git
synced 2025-08-25 17:37:57 +00:00
Display PiP in Group Calls even if local video is disabled.
This commit is contained in:
@@ -16,7 +16,6 @@ import org.thoughtcrime.securesms.R;
|
|||||||
import org.thoughtcrime.securesms.components.AvatarImageView;
|
import org.thoughtcrime.securesms.components.AvatarImageView;
|
||||||
import org.thoughtcrime.securesms.contacts.avatars.ContactPhoto;
|
import org.thoughtcrime.securesms.contacts.avatars.ContactPhoto;
|
||||||
import org.thoughtcrime.securesms.contacts.avatars.FallbackContactPhoto;
|
import org.thoughtcrime.securesms.contacts.avatars.FallbackContactPhoto;
|
||||||
import org.thoughtcrime.securesms.contacts.avatars.ProfileContactPhoto;
|
|
||||||
import org.thoughtcrime.securesms.contacts.avatars.ResourceContactPhoto;
|
import org.thoughtcrime.securesms.contacts.avatars.ResourceContactPhoto;
|
||||||
import org.thoughtcrime.securesms.events.CallParticipant;
|
import org.thoughtcrime.securesms.events.CallParticipant;
|
||||||
import org.thoughtcrime.securesms.mms.GlideApp;
|
import org.thoughtcrime.securesms.mms.GlideApp;
|
||||||
@@ -24,6 +23,7 @@ import org.thoughtcrime.securesms.recipients.Recipient;
|
|||||||
import org.thoughtcrime.securesms.recipients.RecipientId;
|
import org.thoughtcrime.securesms.recipients.RecipientId;
|
||||||
import org.thoughtcrime.securesms.util.AvatarUtil;
|
import org.thoughtcrime.securesms.util.AvatarUtil;
|
||||||
import org.thoughtcrime.securesms.util.ViewUtil;
|
import org.thoughtcrime.securesms.util.ViewUtil;
|
||||||
|
import org.webrtc.RendererCommon;
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
@@ -70,6 +70,14 @@ public class CallParticipantView extends ConstraintLayout {
|
|||||||
useLargeAvatar();
|
useLargeAvatar();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setMirror(boolean mirror) {
|
||||||
|
renderer.setMirror(mirror);
|
||||||
|
}
|
||||||
|
|
||||||
|
void setScalingType(@NonNull RendererCommon.ScalingType scalingType) {
|
||||||
|
renderer.setScalingType(scalingType);
|
||||||
|
}
|
||||||
|
|
||||||
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();
|
||||||
@@ -137,6 +145,11 @@ public class CallParticipantView extends ConstraintLayout {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static final class FallbackPhotoProvider extends Recipient.FallbackPhotoProvider {
|
private static final class FallbackPhotoProvider extends Recipient.FallbackPhotoProvider {
|
||||||
|
@Override
|
||||||
|
public @NonNull FallbackContactPhoto getPhotoForLocalNumber() {
|
||||||
|
return super.getPhotoForRecipientWithoutName();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NonNull FallbackContactPhoto getPhotoForRecipientWithoutName() {
|
public @NonNull FallbackContactPhoto getPhotoForRecipientWithoutName() {
|
||||||
ResourceContactPhoto photo = new ResourceContactPhoto(R.drawable.ic_profile_outline_120);
|
ResourceContactPhoto photo = new ResourceContactPhoto(R.drawable.ic_profile_outline_120);
|
||||||
|
@@ -167,6 +167,7 @@ public final class CallParticipantsState {
|
|||||||
WebRtcLocalRenderState localRenderState = determineLocalRenderMode(webRtcViewModel.getLocalParticipant(),
|
WebRtcLocalRenderState localRenderState = determineLocalRenderMode(webRtcViewModel.getLocalParticipant(),
|
||||||
oldState.isInPipMode,
|
oldState.isInPipMode,
|
||||||
newShowVideoForOutgoing,
|
newShowVideoForOutgoing,
|
||||||
|
webRtcViewModel.getGroupState().isNotIdle(),
|
||||||
webRtcViewModel.getState(),
|
webRtcViewModel.getState(),
|
||||||
webRtcViewModel.getRemoteParticipants().size(),
|
webRtcViewModel.getRemoteParticipants().size(),
|
||||||
oldState.isViewingFocusedParticipant);
|
oldState.isViewingFocusedParticipant);
|
||||||
@@ -191,6 +192,7 @@ public final class CallParticipantsState {
|
|||||||
WebRtcLocalRenderState localRenderState = determineLocalRenderMode(oldState.localParticipant,
|
WebRtcLocalRenderState localRenderState = determineLocalRenderMode(oldState.localParticipant,
|
||||||
isInPip,
|
isInPip,
|
||||||
oldState.showVideoForOutgoing,
|
oldState.showVideoForOutgoing,
|
||||||
|
oldState.getGroupCallState().isNotIdle(),
|
||||||
oldState.callState,
|
oldState.callState,
|
||||||
oldState.getAllRemoteParticipants().size(),
|
oldState.getAllRemoteParticipants().size(),
|
||||||
oldState.isViewingFocusedParticipant);
|
oldState.isViewingFocusedParticipant);
|
||||||
@@ -214,6 +216,7 @@ public final class CallParticipantsState {
|
|||||||
WebRtcLocalRenderState localRenderState = determineLocalRenderMode(oldState.localParticipant,
|
WebRtcLocalRenderState localRenderState = determineLocalRenderMode(oldState.localParticipant,
|
||||||
oldState.isInPipMode,
|
oldState.isInPipMode,
|
||||||
oldState.showVideoForOutgoing,
|
oldState.showVideoForOutgoing,
|
||||||
|
oldState.getGroupCallState().isNotIdle(),
|
||||||
oldState.callState,
|
oldState.callState,
|
||||||
oldState.getAllRemoteParticipants().size(),
|
oldState.getAllRemoteParticipants().size(),
|
||||||
selectedPage == SelectedPage.FOCUSED);
|
selectedPage == SelectedPage.FOCUSED);
|
||||||
@@ -232,11 +235,12 @@ public final class CallParticipantsState {
|
|||||||
private static @NonNull WebRtcLocalRenderState determineLocalRenderMode(@NonNull CallParticipant localParticipant,
|
private static @NonNull WebRtcLocalRenderState determineLocalRenderMode(@NonNull CallParticipant localParticipant,
|
||||||
boolean isInPip,
|
boolean isInPip,
|
||||||
boolean showVideoForOutgoing,
|
boolean showVideoForOutgoing,
|
||||||
|
boolean isNonIdleGroupCall,
|
||||||
@NonNull WebRtcViewModel.State callState,
|
@NonNull WebRtcViewModel.State callState,
|
||||||
int numberOfRemoteParticipants,
|
int numberOfRemoteParticipants,
|
||||||
boolean isViewingFocusedParticipant)
|
boolean isViewingFocusedParticipant)
|
||||||
{
|
{
|
||||||
boolean displayLocal = !isInPip && localParticipant.isVideoEnabled();
|
boolean displayLocal = isNonIdleGroupCall || (!isInPip && localParticipant.isVideoEnabled());
|
||||||
WebRtcLocalRenderState localRenderState = WebRtcLocalRenderState.GONE;
|
WebRtcLocalRenderState localRenderState = WebRtcLocalRenderState.GONE;
|
||||||
|
|
||||||
if (displayLocal || showVideoForOutgoing) {
|
if (displayLocal || showVideoForOutgoing) {
|
||||||
|
@@ -69,7 +69,7 @@ public class WebRtcCallView extends FrameLayout {
|
|||||||
private AccessibleToggleButton videoToggle;
|
private AccessibleToggleButton videoToggle;
|
||||||
private AccessibleToggleButton micToggle;
|
private AccessibleToggleButton micToggle;
|
||||||
private ViewGroup smallLocalRenderFrame;
|
private ViewGroup smallLocalRenderFrame;
|
||||||
private TextureViewRenderer smallLocalRender;
|
private CallParticipantView smallLocalRender;
|
||||||
private View largeLocalRenderFrame;
|
private View largeLocalRenderFrame;
|
||||||
private TextureViewRenderer largeLocalRender;
|
private TextureViewRenderer largeLocalRender;
|
||||||
private View largeLocalRenderNoVideo;
|
private View largeLocalRenderNoVideo;
|
||||||
@@ -287,38 +287,33 @@ public class WebRtcCallView extends FrameLayout {
|
|||||||
largeLocalRender.setScalingType(RendererCommon.ScalingType.SCALE_ASPECT_FILL);
|
largeLocalRender.setScalingType(RendererCommon.ScalingType.SCALE_ASPECT_FILL);
|
||||||
|
|
||||||
if (localCallParticipant.getVideoSink().getEglBase() != null) {
|
if (localCallParticipant.getVideoSink().getEglBase() != null) {
|
||||||
smallLocalRender.init(localCallParticipant.getVideoSink().getEglBase());
|
|
||||||
largeLocalRender.init(localCallParticipant.getVideoSink().getEglBase());
|
largeLocalRender.init(localCallParticipant.getVideoSink().getEglBase());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
smallLocalRender.setCallParticipant(localCallParticipant);
|
||||||
|
smallLocalRender.setRenderInPip(true);
|
||||||
|
videoToggle.setChecked(localCallParticipant.isVideoEnabled(), false);
|
||||||
|
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case GONE:
|
case GONE:
|
||||||
largeLocalRender.attachBroadcastVideoSink(null);
|
largeLocalRender.attachBroadcastVideoSink(null);
|
||||||
largeLocalRenderFrame.setVisibility(View.GONE);
|
largeLocalRenderFrame.setVisibility(View.GONE);
|
||||||
smallLocalRender.attachBroadcastVideoSink(null);
|
|
||||||
smallLocalRenderFrame.setVisibility(View.GONE);
|
smallLocalRenderFrame.setVisibility(View.GONE);
|
||||||
|
|
||||||
videoToggle.setChecked(false, false);
|
|
||||||
break;
|
break;
|
||||||
case SMALL_RECTANGLE:
|
case SMALL_RECTANGLE:
|
||||||
smallLocalRenderFrame.setVisibility(View.VISIBLE);
|
smallLocalRenderFrame.setVisibility(View.VISIBLE);
|
||||||
smallLocalRender.attachBroadcastVideoSink(localCallParticipant.getVideoSink());
|
|
||||||
animatePipToLargeRectangle();
|
animatePipToLargeRectangle();
|
||||||
|
|
||||||
largeLocalRender.attachBroadcastVideoSink(null);
|
largeLocalRender.attachBroadcastVideoSink(null);
|
||||||
largeLocalRenderFrame.setVisibility(View.GONE);
|
largeLocalRenderFrame.setVisibility(View.GONE);
|
||||||
|
|
||||||
videoToggle.setChecked(true, false);
|
|
||||||
break;
|
break;
|
||||||
case SMALLER_RECTANGLE:
|
case SMALLER_RECTANGLE:
|
||||||
smallLocalRenderFrame.setVisibility(View.VISIBLE);
|
smallLocalRenderFrame.setVisibility(View.VISIBLE);
|
||||||
smallLocalRender.attachBroadcastVideoSink(localCallParticipant.getVideoSink());
|
|
||||||
animatePipToSmallRectangle();
|
animatePipToSmallRectangle();
|
||||||
|
|
||||||
largeLocalRender.attachBroadcastVideoSink(null);
|
largeLocalRender.attachBroadcastVideoSink(null);
|
||||||
largeLocalRenderFrame.setVisibility(View.GONE);
|
largeLocalRenderFrame.setVisibility(View.GONE);
|
||||||
|
|
||||||
videoToggle.setChecked(true, false);
|
|
||||||
break;
|
break;
|
||||||
case LARGE:
|
case LARGE:
|
||||||
largeLocalRender.attachBroadcastVideoSink(localCallParticipant.getVideoSink());
|
largeLocalRender.attachBroadcastVideoSink(localCallParticipant.getVideoSink());
|
||||||
@@ -327,10 +322,7 @@ public class WebRtcCallView extends FrameLayout {
|
|||||||
largeLocalRenderNoVideo.setVisibility(View.GONE);
|
largeLocalRenderNoVideo.setVisibility(View.GONE);
|
||||||
largeLocalRenderNoVideoAvatar.setVisibility(View.GONE);
|
largeLocalRenderNoVideoAvatar.setVisibility(View.GONE);
|
||||||
|
|
||||||
smallLocalRender.attachBroadcastVideoSink(null);
|
|
||||||
smallLocalRenderFrame.setVisibility(View.GONE);
|
smallLocalRenderFrame.setVisibility(View.GONE);
|
||||||
|
|
||||||
videoToggle.setChecked(true, false);
|
|
||||||
break;
|
break;
|
||||||
case LARGE_NO_VIDEO:
|
case LARGE_NO_VIDEO:
|
||||||
largeLocalRender.attachBroadcastVideoSink(null);
|
largeLocalRender.attachBroadcastVideoSink(null);
|
||||||
@@ -345,10 +337,7 @@ public class WebRtcCallView extends FrameLayout {
|
|||||||
.diskCacheStrategy(DiskCacheStrategy.ALL)
|
.diskCacheStrategy(DiskCacheStrategy.ALL)
|
||||||
.into(largeLocalRenderNoVideoAvatar);
|
.into(largeLocalRenderNoVideoAvatar);
|
||||||
|
|
||||||
smallLocalRender.attachBroadcastVideoSink(null);
|
|
||||||
smallLocalRenderFrame.setVisibility(View.GONE);
|
smallLocalRenderFrame.setVisibility(View.GONE);
|
||||||
|
|
||||||
videoToggle.setChecked(false, false);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -57,7 +57,6 @@ import org.thoughtcrime.securesms.util.FutureTaskListener;
|
|||||||
import org.thoughtcrime.securesms.util.ListenableFutureTask;
|
import org.thoughtcrime.securesms.util.ListenableFutureTask;
|
||||||
import org.thoughtcrime.securesms.util.TelephonyUtil;
|
import org.thoughtcrime.securesms.util.TelephonyUtil;
|
||||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||||
import org.thoughtcrime.securesms.util.Util;
|
|
||||||
import org.thoughtcrime.securesms.util.concurrent.SignalExecutors;
|
import org.thoughtcrime.securesms.util.concurrent.SignalExecutors;
|
||||||
import org.thoughtcrime.securesms.webrtc.CallNotificationBuilder;
|
import org.thoughtcrime.securesms.webrtc.CallNotificationBuilder;
|
||||||
import org.thoughtcrime.securesms.webrtc.UncaughtExceptionHandlerManager;
|
import org.thoughtcrime.securesms.webrtc.UncaughtExceptionHandlerManager;
|
||||||
|
@@ -103,8 +103,9 @@
|
|||||||
tools:background="@color/red"
|
tools:background="@color/red"
|
||||||
tools:visibility="visible">
|
tools:visibility="visible">
|
||||||
|
|
||||||
<org.thoughtcrime.securesms.components.webrtc.TextureViewRenderer
|
<include
|
||||||
android:id="@+id/call_screen_small_local_renderer"
|
android:id="@+id/call_screen_small_local_renderer"
|
||||||
|
layout="@layout/call_participant_item"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent" />
|
android:layout_height="match_parent" />
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user