From 18d9c0adf0a0d6bf5b9241255be6c6c62669839c Mon Sep 17 00:00:00 2001 From: Alexander Capehart Date: Wed, 12 Jul 2023 09:59:53 -0600 Subject: [PATCH] ui: further tweak bottom sheet Switch back to the default MDC-provided animations, just without the ugly alpha change, and fix any auxillary issues that come with that. --- .../playback/system/MediaSessionComponent.kt | 2 +- .../ViewBindingBottomSheetDialogFragment.kt | 30 +++++++------------ .../main/res/anim/bottom_sheet_slide_in.xml | 24 +++------------ .../main/res/anim/bottom_sheet_slide_out.xml | 13 ++++---- 4 files changed, 22 insertions(+), 47 deletions(-) diff --git a/app/src/main/java/org/oxycblt/auxio/playback/system/MediaSessionComponent.kt b/app/src/main/java/org/oxycblt/auxio/playback/system/MediaSessionComponent.kt index 369675f17..d3e7b8cda 100644 --- a/app/src/main/java/org/oxycblt/auxio/playback/system/MediaSessionComponent.kt +++ b/app/src/main/java/org/oxycblt/auxio/playback/system/MediaSessionComponent.kt @@ -339,7 +339,7 @@ constructor( object : BitmapProvider.Target { override fun onCompleted(bitmap: Bitmap?) { this@MediaSessionComponent.logD( - "Bitmap loaded, applying media " + "session and posting notification") + "Bitmap loaded, applying media session and posting notification") builder.putBitmap(MediaMetadataCompat.METADATA_KEY_ART, bitmap) builder.putBitmap(MediaMetadataCompat.METADATA_KEY_ALBUM_ART, bitmap) val metadata = builder.build() diff --git a/app/src/main/java/org/oxycblt/auxio/ui/ViewBindingBottomSheetDialogFragment.kt b/app/src/main/java/org/oxycblt/auxio/ui/ViewBindingBottomSheetDialogFragment.kt index 99be86b6f..5729f2b43 100644 --- a/app/src/main/java/org/oxycblt/auxio/ui/ViewBindingBottomSheetDialogFragment.kt +++ b/app/src/main/java/org/oxycblt/auxio/ui/ViewBindingBottomSheetDialogFragment.kt @@ -36,6 +36,9 @@ import org.oxycblt.auxio.util.unlikelyToBeNull * A lifecycle-aware [DialogFragment] that automatically manages the [ViewBinding] lifecycle as a * [BottomSheetDialogFragment]. * + * TODO: Debug why menu RecyclerView believes it can scroll more than it actually can in + * landscape. + * * @author Alexander Capehart (OxygenCobalt) */ abstract class ViewBindingBottomSheetDialogFragment : @@ -43,7 +46,7 @@ abstract class ViewBindingBottomSheetDialogFragment : private var _binding: VB? = null override fun onCreateDialog(savedInstanceState: Bundle?): BottomSheetDialog = - RealAnimationBottomSheetDialog(requireContext(), theme) + TweakedBottomSheetDialog(requireContext(), theme) /** * Inflate the [ViewBinding] during [onCreateView]. @@ -107,32 +110,21 @@ abstract class ViewBindingBottomSheetDialogFragment : logD("Fragment destroyed") } - private inner class RealAnimationBottomSheetDialog + private inner class TweakedBottomSheetDialog @JvmOverloads constructor(context: Context, @StyleRes theme: Int = 0) : BottomSheetDialog(context, theme) { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - // The dialog already supplies an implementation for dismissing with the normal - // bottom sheet sliding, which is odd. It works well save the scrim not actually - // activating until the sheet is out of view, but that is tolerated for now. - // TODO: Replace with custom impl that runs the scrim animation and bottom sheet - // animation in parallel. Might just switch back to the stock animation if I can - // eliminate the opacity. - dismissWithAnimation = true + // Collapsed state is bugged in phone landscape mode and shows only 10% of the dialog. + // Just disable it and go directly from expanded -> hidden. + behavior.skipCollapsed = true } override fun onStart() { super.onStart() - // We have to manually trigger a hidden -> expanded transition when the dialog - // is initially opened. Hence, we set the state to hidden now and then as soon - // as we're drawing updating it to expanded. - behavior.state = BottomSheetBehavior.STATE_HIDDEN - requireView().post { behavior.state = BottomSheetBehavior.STATE_EXPANDED } - } - - override fun dismiss() { - super.dismiss() - behavior.state = BottomSheetBehavior.STATE_HIDDEN + // Manually trigger an expanded transition to make window insets actually apply to + // the dialog on the first layout pass. I don't know why this works. + behavior.state = BottomSheetBehavior.STATE_EXPANDED } } } diff --git a/app/src/main/res/anim/bottom_sheet_slide_in.xml b/app/src/main/res/anim/bottom_sheet_slide_in.xml index b2aa8afdb..4e7bad17f 100644 --- a/app/src/main/res/anim/bottom_sheet_slide_in.xml +++ b/app/src/main/res/anim/bottom_sheet_slide_in.xml @@ -1,25 +1,9 @@ - - - - + + diff --git a/app/src/main/res/anim/bottom_sheet_slide_out.xml b/app/src/main/res/anim/bottom_sheet_slide_out.xml index b8ade7731..59507b878 100644 --- a/app/src/main/res/anim/bottom_sheet_slide_out.xml +++ b/app/src/main/res/anim/bottom_sheet_slide_out.xml @@ -1,10 +1,9 @@ - - - - + android:interpolator="@interpolator/m3_sys_motion_easing_emphasized"> + +