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.
This commit is contained in:
parent
5a5d6d53c2
commit
18d9c0adf0
4 changed files with 22 additions and 47 deletions
|
@ -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()
|
||||
|
|
|
@ -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<VB : ViewBinding> :
|
||||
|
@ -43,7 +46,7 @@ abstract class ViewBindingBottomSheetDialogFragment<VB : ViewBinding> :
|
|||
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<VB : ViewBinding> :
|
|||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,25 +1,9 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
~ Copyright (C) 2018 The Android Open Source Project
|
||||
~
|
||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||
~ you may not use this file except in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing, software
|
||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
-->
|
||||
<set xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:duration="@integer/m3_sys_motion_duration_medium4"
|
||||
android:interpolator="@interpolator/m3_sys_motion_easing_emphasized">
|
||||
|
||||
<translate
|
||||
android:fromYDelta="100%p"
|
||||
android:toYDelta="0"/>
|
||||
|
||||
<!-- Workaround for ugly default bottom sheet dialog transition -->
|
||||
<translate
|
||||
android:fromYDelta="100%p"
|
||||
android:toYDelta="0" />
|
||||
</set>
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<set xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<translate
|
||||
<set xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:duration="@integer/m3_sys_motion_duration_medium3"
|
||||
android:interpolator="@interpolator/m3_sys_motion_easing_emphasized"
|
||||
android:fromYDelta="0"
|
||||
android:toYDelta="100%p"/>
|
||||
|
||||
android:interpolator="@interpolator/m3_sys_motion_easing_emphasized">
|
||||
<!-- Workaround for ugly default bottom sheet dialog transition -->
|
||||
<translate
|
||||
android:fromYDelta="0"
|
||||
android:toYDelta="100%p" />
|
||||
</set>
|
||||
|
|
Loading…
Reference in a new issue