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:
parent
a6c321cfa5
commit
7d4b953019
1 changed files with 8 additions and 4 deletions
|
@ -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<FragmentPlaybackBarBinding>() {
|
|||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue