playback: fix disabling on playback layout
Fix my haphazard disabling implementation that I copied from umano without realizing that it would actually break everything.
This commit is contained in:
parent
cfc7352571
commit
6b54d4b783
4 changed files with 16 additions and 15 deletions
|
@ -166,7 +166,6 @@ class AlbumDetailFragment : DetailFragment() {
|
||||||
val pos = adapter.currentList.indexOfFirst { it.id == id && it is Song }
|
val pos = adapter.currentList.indexOfFirst { it.id == id && it is Song }
|
||||||
|
|
||||||
if (pos != -1) {
|
if (pos != -1) {
|
||||||
logD("IDIOT.")
|
|
||||||
binding.detailRecycler.post {
|
binding.detailRecycler.post {
|
||||||
// Make sure to increment the position to make up for the detail header
|
// Make sure to increment the position to make up for the detail header
|
||||||
binding.detailRecycler.layoutManager?.startSmoothScroll(
|
binding.detailRecycler.layoutManager?.startSmoothScroll(
|
||||||
|
|
|
@ -22,6 +22,7 @@ import android.content.Context
|
||||||
import android.util.AttributeSet
|
import android.util.AttributeSet
|
||||||
import android.view.WindowInsets
|
import android.view.WindowInsets
|
||||||
import androidx.constraintlayout.widget.ConstraintLayout
|
import androidx.constraintlayout.widget.ConstraintLayout
|
||||||
|
import androidx.core.view.postDelayed
|
||||||
import androidx.core.view.updatePadding
|
import androidx.core.view.updatePadding
|
||||||
import com.google.android.material.color.MaterialColors
|
import com.google.android.material.color.MaterialColors
|
||||||
import org.oxycblt.auxio.R
|
import org.oxycblt.auxio.R
|
||||||
|
@ -47,6 +48,12 @@ class PlaybackBarView @JvmOverloads constructor(
|
||||||
id = R.id.playback_bar
|
id = R.id.playback_bar
|
||||||
|
|
||||||
setOnLongClickListener {
|
setOnLongClickListener {
|
||||||
|
isPressed = true
|
||||||
|
|
||||||
|
postDelayed(1000) {
|
||||||
|
isPressed = false
|
||||||
|
}
|
||||||
|
|
||||||
mCallback?.onNavToItem()
|
mCallback?.onNavToItem()
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
|
@ -208,7 +208,12 @@ class PlaybackLayout @JvmOverloads constructor(
|
||||||
private fun applyState(state: PanelState) {
|
private fun applyState(state: PanelState) {
|
||||||
// Dragging events are really complex and we don't want to mess up the state
|
// Dragging events are really complex and we don't want to mess up the state
|
||||||
// while we are in one.
|
// while we are in one.
|
||||||
if (!isEnabled || state == panelState || panelState == PanelState.DRAGGING) {
|
if (state == panelState || panelState == PanelState.DRAGGING) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disallow events that aren't showing the bar when disabled
|
||||||
|
if (state != PanelState.HIDDEN && state != PanelState.COLLAPSED && !isEnabled) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -426,8 +431,7 @@ class PlaybackLayout @JvmOverloads constructor(
|
||||||
|
|
||||||
override fun onInterceptTouchEvent(ev: MotionEvent): Boolean {
|
override fun onInterceptTouchEvent(ev: MotionEvent): Boolean {
|
||||||
if (!canSlide) {
|
if (!canSlide) {
|
||||||
dragHelper.abort()
|
return super.onInterceptTouchEvent(ev)
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
val adx = abs(ev.x - initMotionX)
|
val adx = abs(ev.x - initMotionX)
|
||||||
|
@ -471,11 +475,6 @@ class PlaybackLayout @JvmOverloads constructor(
|
||||||
override fun computeScroll() {
|
override fun computeScroll() {
|
||||||
// I have no idea what this does but it seems important so I keep it around
|
// I have no idea what this does but it seems important so I keep it around
|
||||||
if (dragHelper.continueSettling(true)) {
|
if (dragHelper.continueSettling(true)) {
|
||||||
if (!isEnabled) {
|
|
||||||
dragHelper.abort()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
postInvalidateOnAnimation()
|
postInvalidateOnAnimation()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -578,11 +577,6 @@ class PlaybackLayout @JvmOverloads constructor(
|
||||||
(computePanelTopPosition(0f) - topPosition).toFloat() / panelRange
|
(computePanelTopPosition(0f) - topPosition).toFloat() / panelRange
|
||||||
|
|
||||||
private fun smoothSlideTo(offset: Float) {
|
private fun smoothSlideTo(offset: Float) {
|
||||||
if (!isEnabled) {
|
|
||||||
// Disabled, do nothing
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// Find the new top position and animate the panel to that
|
// Find the new top position and animate the panel to that
|
||||||
val panelTop = computePanelTopPosition(offset)
|
val panelTop = computePanelTopPosition(offset)
|
||||||
|
|
||||||
|
|
|
@ -37,9 +37,11 @@
|
||||||
android:id="@+id/playback_cover"
|
android:id="@+id/playback_cover"
|
||||||
style="@style/Widget.Auxio.Image.Full"
|
style="@style/Widget.Auxio.Image.Full"
|
||||||
android:layout_margin="@dimen/spacing_mid_large"
|
android:layout_margin="@dimen/spacing_mid_large"
|
||||||
|
android:layout_marginEnd="8dp"
|
||||||
android:contentDescription="@{@string/desc_album_cover(song.name)}"
|
android:contentDescription="@{@string/desc_album_cover(song.name)}"
|
||||||
app:albumArt="@{song}"
|
app:albumArt="@{song}"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toStartOf="@+id/playback_song_container"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/playback_toolbar"
|
app:layout_constraintTop_toBottomOf="@+id/playback_toolbar"
|
||||||
tools:src="@drawable/ic_album" />
|
tools:src="@drawable/ic_album" />
|
||||||
|
@ -50,7 +52,6 @@
|
||||||
android:id="@+id/playback_song_container"
|
android:id="@+id/playback_song_container"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="@dimen/spacing_mid_large"
|
|
||||||
android:layout_marginEnd="@dimen/spacing_mid_large"
|
android:layout_marginEnd="@dimen/spacing_mid_large"
|
||||||
app:layout_constraintBottom_toTopOf="@+id/playback_artist"
|
app:layout_constraintBottom_toTopOf="@+id/playback_artist"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
|
Loading…
Reference in a new issue