From 7d81ed11508e32dbd9c9bbdd01a1ecb0da68b888 Mon Sep 17 00:00:00 2001 From: Cody Henthorne Date: Wed, 20 Mar 2024 15:50:36 -0400 Subject: [PATCH] Fix call controls disappearing when returning from system pip. --- .../webrtc/controls/ControlsAndInfoController.kt | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/org/thoughtcrime/securesms/components/webrtc/controls/ControlsAndInfoController.kt b/app/src/main/java/org/thoughtcrime/securesms/components/webrtc/controls/ControlsAndInfoController.kt index 0bb0225e25..4a3fed6ee7 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/components/webrtc/controls/ControlsAndInfoController.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/components/webrtc/controls/ControlsAndInfoController.kt @@ -97,7 +97,7 @@ class ControlsAndInfoController( private val handler: Handler? get() = webRtcCallView.handler - private var previousCallControlHeight = 0 + private var previousCallControlHeightData = HeightData() private var controlPeakHeight = 0 private var controlState: WebRtcControls = WebRtcControls.NONE @@ -152,8 +152,9 @@ class ControlsAndInfoController( } callControls.viewTreeObserver.addOnGlobalLayoutListener { - if (callControls.height > 0 && callControls.height != previousCallControlHeight) { - previousCallControlHeight = callControls.height + if (callControls.height > 0 && previousCallControlHeightData.hasChanged(callControls.height, coordinator.height)) { + previousCallControlHeightData = HeightData(callControls.height, coordinator.height) + controlPeakHeight = callControls.height + callControls.y.toInt() behavior.peekHeight = controlPeakHeight frame.minimumHeight = coordinator.height / 2 @@ -456,6 +457,15 @@ class ControlsAndInfoController( displayEndCall() != previousState.displayEndCall() } + private data class HeightData( + val controlHeight: Int = 0, + val coordinatorHeight: Int = 0 + ) { + fun hasChanged(controlHeight: Int, coordinatorHeight: Int): Boolean { + return controlHeight != this.controlHeight || coordinatorHeight != this.coordinatorHeight + } + } + interface BottomSheetVisibilityListener { fun onShown() fun onHidden()