ui: fix stuck sheet when playback ends

Fix an issue where the playback sheet will suddenly become "stuck" when
playback ends, preventing back navigation or playing new tracks.

This is, once again, caused by bottom sheet insanity. It does not
expose the target state of a sheet at all when it's settling, making
Auxio believe that it has to repeatedly "fix" the state of a hiding
playback sheet and leading to those aforementioned issues.

Fix this by band-aiding it with yet a n o t h e r bottom sheet behavior
extension that exposes the target state. This will be eventually be
used in the whole bottom sheet flow, as it allows me to abort
in-progress sheet transitions, but I'm not going to rock the boat like
this in a patch release. Probably 3.2.0.

Resolves #464.
This commit is contained in:
Alexander Capehart 2023-06-02 14:25:56 -06:00
parent 4581532928
commit e39d4d879c
No known key found for this signature in database
GPG key ID: 37DBE3621FE9AD47
3 changed files with 24 additions and 7 deletions

View file

@ -21,6 +21,8 @@ within it
- Fixed incorrect songs being displayed when adding albums to the end of the queue
- Fixed freezing occuring when scrolling through large music libraries
- Fixed app not responding once music loading completes for large libraries
- Fixed crash when the last song of the queue gets removed while playing
- Fixed playback UI not re-appearing after playback ends
#### What's Changed
- Android Lollipop and Marshmallow support have been dropped

View file

@ -1336,6 +1336,19 @@ public class BackportBottomSheetBehavior<V extends View> extends CoordinatorLayo
return state;
}
/**
* Gets the target state of the bottom sheet if currently attempting to settle, or the current
* state otherwise.
* @return One of {@link #STATE_EXPANDED}, {@link #STATE_HALF_EXPANDED}, {@link #STATE_COLLAPSED},
* or {@link #STATE_DRAGGING}
*/
public int getTargetState() {
if (state != STATE_SETTLING) {
return state;
}
return stateSettlingTracker.targetState;
}
void setStateInternal(@State int state) {
if (this.state == state) {
return;

View file

@ -160,7 +160,7 @@ class MainFragment :
fillColor = context.getAttrColorCompat(MR.attr.colorSurface)
elevation = context.getDimen(R.dimen.elevation_normal)
}
// Apply bar insets for the queue's RecyclerView to usee.
// Apply bar insets for the queue's RecyclerView to use.
setOnApplyWindowInsetsListener { v, insets ->
v.updatePadding(top = insets.systemBarInsetsCompat.top)
insets
@ -436,7 +436,7 @@ class MainFragment :
val binding = requireBinding()
val playbackSheetBehavior =
binding.playbackSheet.coordinatorLayoutBehavior as PlaybackBottomSheetBehavior
if (playbackSheetBehavior.state == BackportBottomSheetBehavior.STATE_HIDDEN) {
if (playbackSheetBehavior.targetState == BackportBottomSheetBehavior.STATE_HIDDEN) {
logD("Unhiding and enabling playback sheet")
val queueSheetBehavior =
binding.queueSheet.coordinatorLayoutBehavior as QueueBottomSheetBehavior?
@ -454,7 +454,7 @@ class MainFragment :
val binding = requireBinding()
val playbackSheetBehavior =
binding.playbackSheet.coordinatorLayoutBehavior as PlaybackBottomSheetBehavior
if (playbackSheetBehavior.state != BackportBottomSheetBehavior.STATE_HIDDEN) {
if (playbackSheetBehavior.targetState != BackportBottomSheetBehavior.STATE_HIDDEN) {
val queueSheetBehavior =
binding.queueSheet.coordinatorLayoutBehavior as QueueBottomSheetBehavior?
@ -473,6 +473,8 @@ class MainFragment :
}
}
// TODO: Use targetState more
private class SheetBackPressedCallback(
private val playbackSheetBehavior: PlaybackBottomSheetBehavior<*>,
private val queueSheetBehavior: QueueBottomSheetBehavior<*>?
@ -499,13 +501,13 @@ class MainFragment :
}
private fun playbackSheetShown() =
playbackSheetBehavior.state != BackportBottomSheetBehavior.STATE_COLLAPSED &&
playbackSheetBehavior.state != BackportBottomSheetBehavior.STATE_HIDDEN
playbackSheetBehavior.targetState != BackportBottomSheetBehavior.STATE_COLLAPSED &&
playbackSheetBehavior.targetState != BackportBottomSheetBehavior.STATE_HIDDEN
private fun queueSheetShown() =
queueSheetBehavior != null &&
queueSheetBehavior.state != BackportBottomSheetBehavior.STATE_COLLAPSED &&
playbackSheetBehavior.state == BackportBottomSheetBehavior.STATE_EXPANDED
playbackSheetBehavior.state == BackportBottomSheetBehavior.STATE_EXPANDED &&
queueSheetBehavior.targetState != BackportBottomSheetBehavior.STATE_COLLAPSED
}
private class DetailBackPressedCallback(private val detailModel: DetailViewModel) :