main: band-aid bottom sheets flipping out pre-30

Caused by busted legacy window insets behavior biting me again.
This commit is contained in:
Alexander Capehart
2025-01-15 11:39:59 -07:00
parent c9d4b01f9f
commit b0b55b5069
6 changed files with 41 additions and 13 deletions
@@ -0,0 +1,28 @@
package org.oxycblt.auxio.ui
import android.content.Context
import android.util.AttributeSet
import android.view.WindowInsets
import android.widget.FrameLayout
import androidx.annotation.AttrRes
/**
* A [FrameLayout] that works around the pre-Android 10 behavior of propagating
* mutated insets to sibling views. Wrap this around views that to isolate
* mutated window insets.
*
* @author Alexander Capehart (OxygenCobalt)
*/
class EatInsetsFrameLayout
@JvmOverloads
constructor(context: Context, attrs: AttributeSet? = null, @AttrRes defStyleAttr: Int = 0) :
FrameLayout(context, attrs, defStyleAttr) {
init {
clipToPadding = false
}
override fun dispatchApplyWindowInsets(insets: WindowInsets): WindowInsets {
super.dispatchApplyWindowInsets(insets)
return insets
}
}
@@ -16,7 +16,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package org.oxycblt.auxio.home
package org.oxycblt.auxio.ui
import android.content.Context
import android.util.AttributeSet
@@ -40,8 +40,8 @@ constructor(context: Context, attrs: AttributeSet? = null, @AttrRes defStyleAttr
}
override fun onApplyWindowInsets(insets: WindowInsets): WindowInsets {
// Prevent excessive layouts by using translation instead of padding.
updatePadding(bottom = insets.systemBarInsetsCompat.bottom)
return insets
}
}