mirror of
https://github.com/oxen-io/session-android.git
synced 2025-06-09 02:18:34 +00:00
Finalize support for calling with system PIP.
This commit is contained in:
parent
a955bc3b9b
commit
1a895db9bd
@ -120,6 +120,7 @@
|
|||||||
android:supportsPictureInPicture="true"
|
android:supportsPictureInPicture="true"
|
||||||
android:windowSoftInputMode="stateAlwaysHidden"
|
android:windowSoftInputMode="stateAlwaysHidden"
|
||||||
android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation"
|
android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation"
|
||||||
|
android:taskAffinity=".calling"
|
||||||
android:launchMode="singleTask"/>
|
android:launchMode="singleTask"/>
|
||||||
|
|
||||||
<activity android:name=".messagerequests.CalleeMustAcceptMessageRequestActivity"
|
<activity android:name=".messagerequests.CalleeMustAcceptMessageRequestActivity"
|
||||||
|
@ -156,14 +156,13 @@ public class WebRtcCallActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onUserLeaveHint() {
|
protected void onUserLeaveHint() {
|
||||||
if (deviceSupportsPipMode()) {
|
enterPipModeIfPossible();
|
||||||
PictureInPictureParams params = new PictureInPictureParams.Builder()
|
}
|
||||||
.setAspectRatio(new Rational(16, 9))
|
|
||||||
.build();
|
|
||||||
setPictureInPictureParams(params);
|
|
||||||
|
|
||||||
//noinspection deprecation
|
@Override
|
||||||
enterPictureInPictureMode();
|
public void onBackPressed() {
|
||||||
|
if (!enterPipModeIfPossible()) {
|
||||||
|
super.onBackPressed();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -172,8 +171,19 @@ public class WebRtcCallActivity extends AppCompatActivity {
|
|||||||
viewModel.setIsInPipMode(isInPictureInPictureMode);
|
viewModel.setIsInPipMode(isInPictureInPictureMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean enterPipModeIfPossible() {
|
||||||
|
if (isSystemPipEnabledAndAvailable()) {
|
||||||
|
PictureInPictureParams params = new PictureInPictureParams.Builder()
|
||||||
|
.setAspectRatio(new Rational(9, 16))
|
||||||
|
.build();
|
||||||
|
enterPictureInPictureMode(params);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
private boolean isInPipMode() {
|
private boolean isInPipMode() {
|
||||||
return deviceSupportsPipMode() && isInPictureInPictureMode();
|
return isSystemPipEnabledAndAvailable() && isInPictureInPictureMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void processIntent(@NonNull Intent intent) {
|
private void processIntent(@NonNull Intent intent) {
|
||||||
@ -493,7 +503,7 @@ public class WebRtcCallActivity extends AppCompatActivity {
|
|||||||
.show();
|
.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean deviceSupportsPipMode() {
|
private boolean isSystemPipEnabledAndAvailable() {
|
||||||
return Build.VERSION.SDK_INT >= 26 &&
|
return Build.VERSION.SDK_INT >= 26 &&
|
||||||
FeatureFlags.callingPip() &&
|
FeatureFlags.callingPip() &&
|
||||||
getPackageManager().hasSystemFeature(PackageManager.FEATURE_PICTURE_IN_PICTURE);
|
getPackageManager().hasSystemFeature(PackageManager.FEATURE_PICTURE_IN_PICTURE);
|
||||||
|
@ -307,7 +307,10 @@ public class WebRtcCallView extends FrameLayout {
|
|||||||
Set<View> lastVisibleSet = new HashSet<>(visibleViewSet);
|
Set<View> lastVisibleSet = new HashSet<>(visibleViewSet);
|
||||||
|
|
||||||
visibleViewSet.clear();
|
visibleViewSet.clear();
|
||||||
visibleViewSet.addAll(topViews);
|
|
||||||
|
if (webRtcControls.displayTopViews()) {
|
||||||
|
visibleViewSet.addAll(topViews);
|
||||||
|
}
|
||||||
|
|
||||||
if (webRtcControls.displayIncomingCallButtons()) {
|
if (webRtcControls.displayIncomingCallButtons()) {
|
||||||
visibleViewSet.addAll(incomingCallViews);
|
visibleViewSet.addAll(incomingCallViews);
|
||||||
|
@ -180,6 +180,7 @@ public class WebRtcCallViewModel extends ViewModel {
|
|||||||
isRemoteVideoEnabled || isRemoteVideoOffer,
|
isRemoteVideoEnabled || isRemoteVideoOffer,
|
||||||
isMoreThanOneCameraAvailable,
|
isMoreThanOneCameraAvailable,
|
||||||
isBluetoothAvailable,
|
isBluetoothAvailable,
|
||||||
|
isInPipMode.getValue() == Boolean.TRUE,
|
||||||
callState,
|
callState,
|
||||||
audioOutput));
|
audioOutput));
|
||||||
}
|
}
|
||||||
@ -189,9 +190,9 @@ public class WebRtcCallViewModel extends ViewModel {
|
|||||||
else return WebRtcLocalRenderState.GONE;
|
else return WebRtcLocalRenderState.GONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
private @NonNull WebRtcControls getRealWebRtcControls(boolean neverDisplayControls, @NonNull WebRtcControls controls) {
|
private @NonNull WebRtcControls getRealWebRtcControls(boolean isInPipMode, @NonNull WebRtcControls controls) {
|
||||||
if (neverDisplayControls) return WebRtcControls.NONE;
|
if (isInPipMode) return WebRtcControls.PIP;
|
||||||
else return controls;
|
else return controls;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void startTimer() {
|
private void startTimer() {
|
||||||
|
@ -5,22 +5,25 @@ import androidx.annotation.NonNull;
|
|||||||
public final class WebRtcControls {
|
public final class WebRtcControls {
|
||||||
|
|
||||||
public static final WebRtcControls NONE = new WebRtcControls();
|
public static final WebRtcControls NONE = new WebRtcControls();
|
||||||
|
public static final WebRtcControls PIP = new WebRtcControls(false, false, false, false, true, CallState.NONE, WebRtcAudioOutput.HANDSET);
|
||||||
|
|
||||||
private final boolean isRemoteVideoEnabled;
|
private final boolean isRemoteVideoEnabled;
|
||||||
private final boolean isLocalVideoEnabled;
|
private final boolean isLocalVideoEnabled;
|
||||||
private final boolean isMoreThanOneCameraAvailable;
|
private final boolean isMoreThanOneCameraAvailable;
|
||||||
private final boolean isBluetoothAvailable;
|
private final boolean isBluetoothAvailable;
|
||||||
|
private final boolean isInPipMode;
|
||||||
private final CallState callState;
|
private final CallState callState;
|
||||||
private final WebRtcAudioOutput audioOutput;
|
private final WebRtcAudioOutput audioOutput;
|
||||||
|
|
||||||
private WebRtcControls() {
|
private WebRtcControls() {
|
||||||
this(false, false, false, false, CallState.NONE, WebRtcAudioOutput.HANDSET);
|
this(false, false, false, false, false, CallState.NONE, WebRtcAudioOutput.HANDSET);
|
||||||
}
|
}
|
||||||
|
|
||||||
WebRtcControls(boolean isLocalVideoEnabled,
|
WebRtcControls(boolean isLocalVideoEnabled,
|
||||||
boolean isRemoteVideoEnabled,
|
boolean isRemoteVideoEnabled,
|
||||||
boolean isMoreThanOneCameraAvailable,
|
boolean isMoreThanOneCameraAvailable,
|
||||||
boolean isBluetoothAvailable,
|
boolean isBluetoothAvailable,
|
||||||
|
boolean isInPipMode,
|
||||||
@NonNull CallState callState,
|
@NonNull CallState callState,
|
||||||
@NonNull WebRtcAudioOutput audioOutput)
|
@NonNull WebRtcAudioOutput audioOutput)
|
||||||
{
|
{
|
||||||
@ -28,6 +31,7 @@ public final class WebRtcControls {
|
|||||||
this.isRemoteVideoEnabled = isRemoteVideoEnabled;
|
this.isRemoteVideoEnabled = isRemoteVideoEnabled;
|
||||||
this.isBluetoothAvailable = isBluetoothAvailable;
|
this.isBluetoothAvailable = isBluetoothAvailable;
|
||||||
this.isMoreThanOneCameraAvailable = isMoreThanOneCameraAvailable;
|
this.isMoreThanOneCameraAvailable = isMoreThanOneCameraAvailable;
|
||||||
|
this.isInPipMode = isInPipMode;
|
||||||
this.callState = callState;
|
this.callState = callState;
|
||||||
this.audioOutput = audioOutput;
|
this.audioOutput = audioOutput;
|
||||||
}
|
}
|
||||||
@ -80,6 +84,10 @@ public final class WebRtcControls {
|
|||||||
return isOngoing() && !(displayAudioToggle() && displayCameraToggle());
|
return isOngoing() && !(displayAudioToggle() && displayCameraToggle());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean displayTopViews() {
|
||||||
|
return !isInPipMode;
|
||||||
|
}
|
||||||
|
|
||||||
WebRtcAudioOutput getAudioOutput() {
|
WebRtcAudioOutput getAudioOutput() {
|
||||||
return audioOutput;
|
return audioOutput;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user