From ab2681640a729ed5b134375d4d0c2ef0e767562e Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Fri, 17 Apr 2020 11:44:20 +0200 Subject: [PATCH] allow pip during connecting --- .../conversations/ui/RtpSessionActivity.java | 17 ++++++++++++++++- src/main/res/layout/activity_rtp_session.xml | 12 +++++++++++- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/ui/RtpSessionActivity.java b/src/main/java/eu/siacs/conversations/ui/RtpSessionActivity.java index b1beee945..4b71a86fc 100644 --- a/src/main/java/eu/siacs/conversations/ui/RtpSessionActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/RtpSessionActivity.java @@ -299,7 +299,11 @@ public class RtpSessionActivity extends XmppActivity implements XmppConnectionSe private boolean shouldBePictureInPicture() { try { final JingleRtpConnection rtpConnection = requireRtpConnection(); - return rtpConnection.getMedia().contains(Media.VIDEO) && rtpConnection.getEndUserState() == RtpEndUserState.CONNECTED; + return rtpConnection.getMedia().contains(Media.VIDEO) && Arrays.asList( + RtpEndUserState.ACCEPTING_CALL, + RtpEndUserState.CONNECTING, + RtpEndUserState.CONNECTED + ).contains(rtpConnection.getEndUserState()); } catch (IllegalStateException e) { return false; } @@ -546,8 +550,10 @@ public class RtpSessionActivity extends XmppActivity implements XmppConnectionSe binding.pipPlaceholder.setVisibility(View.VISIBLE); if (state == RtpEndUserState.APPLICATION_ERROR || state == RtpEndUserState.CONNECTIVITY_ERROR) { binding.pipWarning.setVisibility(View.VISIBLE); + binding.pipWaiting.setVisibility(View.GONE); } else { binding.pipWarning.setVisibility(View.GONE); + binding.pipWaiting.setVisibility(View.GONE); } } else { binding.appBarLayout.setVisibility(View.VISIBLE); @@ -556,6 +562,15 @@ public class RtpSessionActivity extends XmppActivity implements XmppConnectionSe getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); return; } + if (isPictureInPicture() && (state == RtpEndUserState.CONNECTING || state == RtpEndUserState.ACCEPTING_CALL)) { + binding.localVideo.setVisibility(View.GONE); + binding.remoteVideo.setVisibility(View.GONE); + binding.appBarLayout.setVisibility(View.GONE); + binding.pipPlaceholder.setVisibility(View.VISIBLE); + binding.pipWarning.setVisibility(View.GONE); + binding.pipWaiting.setVisibility(View.VISIBLE); + return; + } final Optional localVideoTrack = requireRtpConnection().geLocalVideoTrack(); if (localVideoTrack.isPresent() && !isPictureInPicture()) { ensureSurfaceViewRendererIsSetup(binding.localVideo); diff --git a/src/main/res/layout/activity_rtp_session.xml b/src/main/res/layout/activity_rtp_session.xml index 25b5f3a12..ef549aebd 100644 --- a/src/main/res/layout/activity_rtp_session.xml +++ b/src/main/res/layout/activity_rtp_session.xml @@ -17,11 +17,21 @@ android:orientation="horizontal" android:visibility="gone"> + + + android:src="@drawable/ic_warning_white_48dp" + android:visibility="gone" />