Skip to content

Commit

Permalink
main: band-aid bottom sheets flipping out pre-30
Browse files Browse the repository at this point in the history
Caused by busted legacy window insets behavior biting me again.
  • Loading branch information
OxygenCobalt committed Jan 15, 2025
1 parent c9d4b01 commit b0b55b5
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 13 deletions.
28 changes: 28 additions & 0 deletions app/src/main/java/org/oxycblt/auxio/ui/EatInsetsFrameLayout.kt
Original file line number Diff line number Diff line change
@@ -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
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}
}

8 changes: 4 additions & 4 deletions app/src/main/res/layout-w720dp/fragment_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
android:background="?attr/colorSurface">


<FrameLayout
<org.oxycblt.auxio.ui.EatInsetsFrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="org.oxycblt.auxio.ui.BottomSheetContentBehavior">
Expand All @@ -23,7 +23,7 @@
tools:layout="@layout/fragment_home" />


<org.oxycblt.auxio.home.EdgeFrameLayout
<org.oxycblt.auxio.ui.EdgeFrameLayout
android:id="@+id/main_fab_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
Expand Down Expand Up @@ -55,9 +55,9 @@
android:contentDescription="@string/lbl_shuffle"
android:src="@drawable/ic_shuffle_off_24" />

</org.oxycblt.auxio.home.EdgeFrameLayout>
</org.oxycblt.auxio.ui.EdgeFrameLayout>

</FrameLayout>
</org.oxycblt.auxio.ui.EatInsetsFrameLayout>


<View
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/layout/fragment_home_list.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
tools:listitem="@layout/item_song" />


<org.oxycblt.auxio.home.EdgeFrameLayout
<org.oxycblt.auxio.ui.EdgeFrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">

Expand Down Expand Up @@ -53,5 +53,5 @@

</LinearLayout>

</org.oxycblt.auxio.home.EdgeFrameLayout>
</org.oxycblt.auxio.ui.EdgeFrameLayout>
</FrameLayout>
8 changes: 4 additions & 4 deletions app/src/main/res/layout/fragment_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
android:background="?attr/colorSurface"
android:transitionGroup="true">

<FrameLayout
<org.oxycblt.auxio.ui.EatInsetsFrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="org.oxycblt.auxio.ui.BottomSheetContentBehavior">
Expand All @@ -28,7 +28,7 @@
android:layout_height="match_parent"
android:visibility="invisible" />

<org.oxycblt.auxio.home.EdgeFrameLayout
<org.oxycblt.auxio.ui.EdgeFrameLayout
android:id="@+id/main_fab_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
Expand Down Expand Up @@ -60,9 +60,9 @@
android:contentDescription="@string/lbl_shuffle"
android:src="@drawable/ic_shuffle_off_24" />

</org.oxycblt.auxio.home.EdgeFrameLayout>
</org.oxycblt.auxio.ui.EdgeFrameLayout>

</FrameLayout>
</org.oxycblt.auxio.ui.EatInsetsFrameLayout>

<View
android:id="@+id/main_sheet_scrim"
Expand Down
2 changes: 1 addition & 1 deletion media
Submodule media updated 1398 files

0 comments on commit b0b55b5

Please sign in to comment.