Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 49a27b27 authored by Fabián Kozynski's avatar Fabián Kozynski
Browse files

Prevent duplicate config change in ComposeView

Only dispatch the config change to the children view if something has
actually changed. This helps because FrameLayoutTouchPassthrough may be
getting duplicate config changes (one from the view hierarchy and one
from FragmentHostManager).

Test: manual, perform config changes.
Fixes: 434389035
Flag: EXEMPT bugfix
Change-Id: If9c46d131e9af09fcfcbb4f62da3c2927435233c
parent 2d834f7b
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -1196,6 +1196,8 @@ private class FrameLayoutTouchPassthrough(
    private val isInBottomReservedArea: (Float, Float) -> Boolean,
) : FrameLayout(context) {

    private val lastConfig = Configuration(context.resources.configuration)

    init {
        repeatWhenAttached {
            repeatOnLifecycle(Lifecycle.State.STARTED) {
@@ -1336,6 +1338,12 @@ private class FrameLayoutTouchPassthrough(
        return super.onTouchEvent(event)
    }

    override fun dispatchConfigurationChanged(newConfig: Configuration) {
        if (lastConfig.updateFrom(newConfig) != 0) {
            super.dispatchConfigurationChanged(newConfig)
        }
    }

    override fun onInterceptTouchEvent(ev: MotionEvent): Boolean {
        // If there's a touch on this view and we can scroll down, we don't want to be intercepted
        val action = ev.actionMasked