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.
This commit is contained in:
OxygenCobalt 2022-06-08 09:33:14 -06:00
parent a6c321cfa5
commit 7d4b953019
No known key found for this signature in database
GPG key ID: 37DBE3621FE9AD47

View file

@ -21,6 +21,7 @@ import android.os.Bundle
import android.view.LayoutInflater import android.view.LayoutInflater
import androidx.core.view.updatePadding import androidx.core.view.updatePadding
import androidx.fragment.app.activityViewModels import androidx.fragment.app.activityViewModels
import kotlin.math.max
import org.oxycblt.auxio.R import org.oxycblt.auxio.R
import org.oxycblt.auxio.databinding.FragmentPlaybackBarBinding import org.oxycblt.auxio.databinding.FragmentPlaybackBarBinding
import org.oxycblt.auxio.music.Song 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.ui.ViewBindingFragment
import org.oxycblt.auxio.util.getColorStateListSafe import org.oxycblt.auxio.util.getColorStateListSafe
import org.oxycblt.auxio.util.launch import org.oxycblt.auxio.util.launch
import org.oxycblt.auxio.util.systemBarInsetsCompat
import org.oxycblt.auxio.util.systemGestureInsetsCompat import org.oxycblt.auxio.util.systemGestureInsetsCompat
import org.oxycblt.auxio.util.textSafe import org.oxycblt.auxio.util.textSafe
@ -58,10 +60,12 @@ class PlaybackBarFragment : ViewBindingFragment<FragmentPlaybackBarBinding>() {
setOnApplyWindowInsetsListener { view, insets -> setOnApplyWindowInsetsListener { view, insets ->
// Since we swipe up this view, we need to make sure it does not collide with // 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 // any gesture events. So, apply the system gesture insets if present as long
// only default to the system bar insets when there are no other options. // as they are *larger* than the bar insets. This is to resolve issues where
val gesturePadding = insets.systemGestureInsetsCompat // the gesture insets are not sane on OEM devices.
view.updatePadding(bottom = gesturePadding.bottom) val bars = insets.systemBarInsetsCompat
val gestures = insets.systemGestureInsetsCompat
view.updatePadding(bottom = max(bars.bottom, gestures.bottom))
insets insets
} }
} }