From 7d4b9530198cb95bb5a9c4f0417c3e569aa6caac Mon Sep 17 00:00:00 2001 From: OxygenCobalt Date: Wed, 8 Jun 2022 09:33:14 -0600 Subject: [PATCH] playback: pick larger inset out of bar/gesture On the playback par, pick the larger inset out of the system bar insets or system gesture insets. This is to fix an issue where android just does not provide correct gesture insets on Android 12L, and [maybe???] fix what is going on in #149. --- .../oxycblt/auxio/playback/PlaybackBarFragment.kt | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/org/oxycblt/auxio/playback/PlaybackBarFragment.kt b/app/src/main/java/org/oxycblt/auxio/playback/PlaybackBarFragment.kt index c41ddd811..363bb235e 100644 --- a/app/src/main/java/org/oxycblt/auxio/playback/PlaybackBarFragment.kt +++ b/app/src/main/java/org/oxycblt/auxio/playback/PlaybackBarFragment.kt @@ -21,6 +21,7 @@ import android.os.Bundle import android.view.LayoutInflater import androidx.core.view.updatePadding import androidx.fragment.app.activityViewModels +import kotlin.math.max import org.oxycblt.auxio.R import org.oxycblt.auxio.databinding.FragmentPlaybackBarBinding import org.oxycblt.auxio.music.Song @@ -29,6 +30,7 @@ import org.oxycblt.auxio.ui.NavigationViewModel import org.oxycblt.auxio.ui.ViewBindingFragment import org.oxycblt.auxio.util.getColorStateListSafe import org.oxycblt.auxio.util.launch +import org.oxycblt.auxio.util.systemBarInsetsCompat import org.oxycblt.auxio.util.systemGestureInsetsCompat import org.oxycblt.auxio.util.textSafe @@ -58,10 +60,12 @@ class PlaybackBarFragment : ViewBindingFragment() { setOnApplyWindowInsetsListener { view, insets -> // Since we swipe up this view, we need to make sure it does not collide with - // any gesture events. So, apply the system gesture insets if present and then - // only default to the system bar insets when there are no other options. - val gesturePadding = insets.systemGestureInsetsCompat - view.updatePadding(bottom = gesturePadding.bottom) + // any gesture events. So, apply the system gesture insets if present as long + // as they are *larger* than the bar insets. This is to resolve issues where + // the gesture insets are not sane on OEM devices. + val bars = insets.systemBarInsetsCompat + val gestures = insets.systemGestureInsetsCompat + view.updatePadding(bottom = max(bars.bottom, gestures.bottom)) insets } }