Fix self-PIP boundaries in calls.

This commit is contained in:
Cody Henthorne 2023-12-12 12:56:54 -05:00
parent 632aeed00b
commit b646e69b6b
4 changed files with 18 additions and 29 deletions

View file

@ -991,16 +991,6 @@ public class WebRtcCallActivity extends BaseActivity implements SafetyNumberChan
controlsAndInfo.toggleControls(); controlsAndInfo.toggleControls();
} }
@Override
public void showSystemUI() {
fullscreenHelper.showSystemUI();
}
@Override
public void hideSystemUI() {
fullscreenHelper.hideSystemUI();
}
@Override @Override
public void onAudioOutputChanged(@NonNull WebRtcAudioOutput audioOutput) { public void onAudioOutputChanged(@NonNull WebRtcAudioOutput audioOutput) {
maybeDisplaySpeakerphonePopup(audioOutput); maybeDisplaySpeakerphonePopup(audioOutput);

View file

@ -34,7 +34,7 @@ public class PictureInPictureGestureHelper extends GestureDetector.SimpleOnGestu
private int pipWidth; private int pipWidth;
private int pipHeight; private int pipHeight;
private int activePointerId = MotionEvent.INVALID_POINTER_ID; private int activePointerId = MotionEvent.INVALID_POINTER_ID;
private float lastTouchX; private float lastTouchX;
private float lastTouchY; private float lastTouchY;
private int extraPaddingTop; private int extraPaddingTop;
@ -45,7 +45,9 @@ public class PictureInPictureGestureHelper extends GestureDetector.SimpleOnGestu
private int maximumFlingVelocity; private int maximumFlingVelocity;
private boolean isLockedToBottomEnd; private boolean isLockedToBottomEnd;
private Interpolator interpolator; private Interpolator interpolator;
private Corner currentCornerPosition = Corner.BOTTOM_RIGHT; private Corner currentCornerPosition = Corner.BOTTOM_RIGHT;
private int previousTopBoundary = -1;
private int previousBottomBoundary = -1;
@SuppressLint("ClickableViewAccessibility") @SuppressLint("ClickableViewAccessibility")
public static PictureInPictureGestureHelper applyTo(@NonNull View child) { public static PictureInPictureGestureHelper applyTo(@NonNull View child) {
@ -109,12 +111,12 @@ public class PictureInPictureGestureHelper extends GestureDetector.SimpleOnGestu
this.interpolator = ADJUST_INTERPOLATOR; this.interpolator = ADJUST_INTERPOLATOR;
} }
public void clearVerticalBoundaries() {
setTopVerticalBoundary(parent.getTop());
setBottomVerticalBoundary(parent.getMeasuredHeight() + parent.getTop());
}
public void setTopVerticalBoundary(int topBoundary) { public void setTopVerticalBoundary(int topBoundary) {
if (topBoundary == previousTopBoundary) {
return;
}
previousTopBoundary = topBoundary;
extraPaddingTop = topBoundary - parent.getTop(); extraPaddingTop = topBoundary - parent.getTop();
ViewGroup.MarginLayoutParams layoutParams = (ViewGroup.MarginLayoutParams) child.getLayoutParams(); ViewGroup.MarginLayoutParams layoutParams = (ViewGroup.MarginLayoutParams) child.getLayoutParams();
@ -123,6 +125,11 @@ public class PictureInPictureGestureHelper extends GestureDetector.SimpleOnGestu
} }
public void setBottomVerticalBoundary(int bottomBoundary) { public void setBottomVerticalBoundary(int bottomBoundary) {
if (bottomBoundary == previousBottomBoundary) {
return;
}
previousBottomBoundary = bottomBoundary;
extraPaddingBottom = parent.getMeasuredHeight() + parent.getTop() - bottomBoundary; extraPaddingBottom = parent.getMeasuredHeight() + parent.getTop() - bottomBoundary;
ViewGroup.MarginLayoutParams layoutParams = (ViewGroup.MarginLayoutParams) child.getLayoutParams(); ViewGroup.MarginLayoutParams layoutParams = (ViewGroup.MarginLayoutParams) child.getLayoutParams();

View file

@ -379,15 +379,9 @@ public class WebRtcCallView extends InsetAwareConstraintLayout {
@Override @Override
public void onWindowSystemUiVisibilityChanged(int visible) { public void onWindowSystemUiVisibilityChanged(int visible) {
if ((visible & SYSTEM_UI_FLAG_HIDE_NAVIGATION) == 0) { if ((visible & SYSTEM_UI_FLAG_HIDE_NAVIGATION) == 0) {
if (controls.adjustForFold()) { pictureInPictureGestureHelper.setTopVerticalBoundary(collapsedToolbar.getBottom());
pictureInPictureGestureHelper.clearVerticalBoundaries();
pictureInPictureGestureHelper.setTopVerticalBoundary(getPipBarrier().getTop());
} else {
pictureInPictureGestureHelper.setTopVerticalBoundary(getPipBarrier().getBottom());
pictureInPictureGestureHelper.setBottomVerticalBoundary(findViewById(R.id.call_controls_info_parent).getTop());
}
} else { } else {
pictureInPictureGestureHelper.clearVerticalBoundaries(); pictureInPictureGestureHelper.setTopVerticalBoundary(getStatusBarGuideline().getBottom());
} }
} }
@ -961,8 +955,6 @@ public class WebRtcCallView extends InsetAwareConstraintLayout {
public interface ControlsListener { public interface ControlsListener {
void onStartCall(boolean isVideoCall); void onStartCall(boolean isVideoCall);
void onCancelStartCall(); void onCancelStartCall();
void showSystemUI();
void hideSystemUI();
void onAudioOutputChanged(@NonNull WebRtcAudioOutput audioOutput); void onAudioOutputChanged(@NonNull WebRtcAudioOutput audioOutput);
@RequiresApi(31) @RequiresApi(31)
void onAudioOutputChanged31(@NonNull WebRtcAudioDevice audioOutput); void onAudioOutputChanged31(@NonNull WebRtcAudioDevice audioOutput);

View file

@ -104,8 +104,8 @@ class ControlsAndInfoController(
behavior.state = BottomSheetBehavior.STATE_HIDDEN behavior.state = BottomSheetBehavior.STATE_HIDDEN
BottomSheetBehaviorHack.setNestedScrollingChild(behavior, callInfoComposeView) BottomSheetBehaviorHack.setNestedScrollingChild(behavior, callInfoComposeView)
coordinator.addOnLayoutChangeListener { _, _, top, _, bottom, _, _, _, _ -> coordinator.addOnLayoutChangeListener { _, _, _, _, _, _, _, _, _ ->
val guidelineTop = max(frame.top, (bottom - top) - behavior.peekHeight) val guidelineTop = max(frame.top, coordinator.height - behavior.peekHeight)
webRtcCallView.post { webRtcCallView.onControlTopChanged(guidelineTop) } webRtcCallView.post { webRtcCallView.onControlTopChanged(guidelineTop) }
} }