diff --git a/CHANGELOG.md b/CHANGELOG.md index 45e89cb9e..f363b1ae7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ - Items should no longer be indicated as playing if the currently playing song is not contained within it - Fixed blurry playing indicator in album/artist/genre/playlist items +- Fixed incorrect songs being displayed when adding albums to the end of the queue ## 3.1.0 diff --git a/app/src/main/java/org/oxycblt/auxio/image/CoverView.kt b/app/src/main/java/org/oxycblt/auxio/image/CoverView.kt index b08ca6951..63f773cf9 100644 --- a/app/src/main/java/org/oxycblt/auxio/image/CoverView.kt +++ b/app/src/main/java/org/oxycblt/auxio/image/CoverView.kt @@ -89,7 +89,7 @@ constructor(context: Context, attrs: AttributeSet? = null, @AttrRes defStyleAttr private val selectionBadge: ImageView? @DimenRes private val iconSizeRes: Int? - @DimenRes private val cornerRadiusRes: Int + @DimenRes private val cornerRadiusRes: Int? private var fadeAnimator: ValueAnimator? = null private val indicatorMatrix = Matrix() @@ -103,7 +103,12 @@ constructor(context: Context, attrs: AttributeSet? = null, @AttrRes defStyleAttr val sizing = styledAttrs.getIntOrThrow(R.styleable.CoverView_sizing) iconSizeRes = SIZING_ICON_SIZE[sizing] - cornerRadiusRes = SIZING_CORNER_RADII[sizing] + cornerRadiusRes = + if (uiSettings.roundMode) { + SIZING_CORNER_RADII[sizing] + } else { + null + } val playbackIndicatorEnabled = styledAttrs.getBoolean(R.styleable.CoverView_enablePlaybackIndicator, true) @@ -162,7 +167,7 @@ constructor(context: Context, attrs: AttributeSet? = null, @AttrRes defStyleAttr background = MaterialShapeDrawable().apply { fillColor = context.getColorCompat(R.color.sel_cover_bg) - setCornerSize(context.getDimen(cornerRadiusRes)) + setCornerSize(cornerRadiusRes?.let(context::getDimen) ?: 0f) } } } @@ -220,6 +225,11 @@ constructor(context: Context, attrs: AttributeSet? = null, @AttrRes defStyleAttr invalidateSelectionIndicatorAlpha(selectionBadge ?: return) } + override fun setEnabled(enabled: Boolean) { + super.setEnabled(enabled) + invalidateRootAlpha() + } + override fun setSelected(selected: Boolean) { super.setSelected(selected) invalidateRootAlpha() @@ -249,7 +259,7 @@ constructor(context: Context, attrs: AttributeSet? = null, @AttrRes defStyleAttr } private fun invalidateRootAlpha() { - alpha = if (isSelected || isEnabled) 1f else 0.5f + alpha = if (isEnabled || isSelected) 1f else 0.5f } private fun invalidatePlaybackIndicatorAlpha(playbackIndicator: PlaybackIndicator) { @@ -370,7 +380,8 @@ constructor(context: Context, attrs: AttributeSet? = null, @AttrRes defStyleAttr ImageRequest.Builder(context) .data(songs) .error(StyledDrawable(context, context.getDrawableCompat(errorRes), iconSizeRes)) - .transformations(RoundedCornersTransformation(context.getDimen(cornerRadiusRes))) + .transformations( + RoundedCornersTransformation(cornerRadiusRes?.let(context::getDimen) ?: 0f)) .target(image) .build() // Dispose of any previous image request and load a new image. diff --git a/app/src/main/java/org/oxycblt/auxio/playback/queue/Queue.kt b/app/src/main/java/org/oxycblt/auxio/playback/queue/Queue.kt index ed864e675..554d37258 100644 --- a/app/src/main/java/org/oxycblt/auxio/playback/queue/Queue.kt +++ b/app/src/main/java/org/oxycblt/auxio/playback/queue/Queue.kt @@ -234,6 +234,7 @@ class EditableQueue : Queue { */ fun addToQueue(songs: List): Queue.Change { logD("Adding ${songs.size} songs to the back of the queue") + val point = orderedMapping.size val heapIndices = songs.map(::addSongToHeap) // Can simple append the new songs to the end of both mappings. orderedMapping.addAll(heapIndices) @@ -242,8 +243,7 @@ class EditableQueue : Queue { shuffledMapping.addAll(heapIndices) } check() - return Queue.Change( - Queue.Change.Type.MAPPING, UpdateInstructions.Add(index + 1, songs.size)) + return Queue.Change(Queue.Change.Type.MAPPING, UpdateInstructions.Add(point, songs.size)) } /** diff --git a/app/src/main/java/org/oxycblt/auxio/playback/queue/QueueFragment.kt b/app/src/main/java/org/oxycblt/auxio/playback/queue/QueueFragment.kt index 8e75abf36..2db007971 100644 --- a/app/src/main/java/org/oxycblt/auxio/playback/queue/QueueFragment.kt +++ b/app/src/main/java/org/oxycblt/auxio/playback/queue/QueueFragment.kt @@ -105,9 +105,7 @@ class QueueFragment : ViewBindingFragment(), EditClickList private fun updateQueue(queue: List, index: Int, isPlaying: Boolean) { val binding = requireBinding() - // Replace or diff the queue depending on the type of change it is. queueAdapter.update(queue, queueModel.queueInstructions.consume()) - // Update position in list (and thus past/future items) queueAdapter.setPosition(index, isPlaying) // If requested, scroll to a new item (occurs when the index moves)