diff --git a/CHANGELOG.md b/CHANGELOG.md
index 16b669572..e533c92f1 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -27,6 +27,8 @@ at the cost of longer loading times
- Fixed default material theme being used before app shows up
- Fixed shuffle shortcut and file opening not working on startup on some devices
- Fixed issue where the notification position would not match if one seeked when paused
+- Fixed issue where widget covers would not load
+- Fixed issue where widget could not be sized to it's smallest form
#### What's Changed
- Play and skip icons are filled again
diff --git a/app/src/main/java/com/google/android/material/bottomsheet/NeoBottomSheetBehavior.java b/app/src/main/java/com/google/android/material/bottomsheet/NeoBottomSheetBehavior.java
index d6540abcc..66f223379 100644
--- a/app/src/main/java/com/google/android/material/bottomsheet/NeoBottomSheetBehavior.java
+++ b/app/src/main/java/com/google/android/material/bottomsheet/NeoBottomSheetBehavior.java
@@ -82,6 +82,8 @@ import java.util.Map;
*
To send useful accessibility events, set a title on bottom sheets that are windows or are
* window-like. For BottomSheetDialog use {@link BottomSheetDialog#setTitle(int)}, and for
* BottomSheetDialogFragment use {@link ViewCompat#setAccessibilityPaneTitle(View, CharSequence)}.
+ *
+ * Modified at several points by OxygenCobalt to fix insane issues.
*/
public class NeoBottomSheetBehavior extends CoordinatorLayout.Behavior {
diff --git a/app/src/main/java/org/oxycblt/auxio/playback/PlaybackSheetBehavior.kt b/app/src/main/java/org/oxycblt/auxio/playback/PlaybackSheetBehavior.kt
index 0c9ef4412..c481dc208 100644
--- a/app/src/main/java/org/oxycblt/auxio/playback/PlaybackSheetBehavior.kt
+++ b/app/src/main/java/org/oxycblt/auxio/playback/PlaybackSheetBehavior.kt
@@ -29,10 +29,21 @@ import org.oxycblt.auxio.ui.AuxioSheetBehavior
import org.oxycblt.auxio.util.systemBarInsetsCompat
import org.oxycblt.auxio.util.systemGestureInsetsCompat
+/**
+ * The coordinator layout behavior used for the playback sheet, hacking in the many fixes required
+ * to make bottom sheets like this work.
+ * @author OxygenCobalt
+ *
+ * TODO: Implement hiding because I have to
+ */
class PlaybackSheetBehavior(context: Context, attributeSet: AttributeSet?) :
AuxioSheetBehavior(context, attributeSet) {
private var lastInsets: WindowInsets? = null
+ init {
+ isHideable = true
+ }
+
// Hack around issue where the playback sheet will try to intercept nested scrolling events
// before the queue sheet.
override fun onInterceptTouchEvent(
@@ -58,13 +69,16 @@ class PlaybackSheetBehavior(context: Context, attributeSet: AttributeS
}
fun hideSafe() {
- isDraggable = false
- isHideable = true
- state = STATE_HIDDEN
+ if (state != STATE_HIDDEN) {
+ isDraggable = false
+ state = STATE_HIDDEN
+ }
}
fun unhideSafe() {
- isHideable = false
- isDraggable = true
+ if (state == STATE_HIDDEN) {
+ state = STATE_COLLAPSED
+ isDraggable = true
+ }
}
}
diff --git a/app/src/main/java/org/oxycblt/auxio/playback/queue/QueueAdapter.kt b/app/src/main/java/org/oxycblt/auxio/playback/queue/QueueAdapter.kt
index d0ca7aabb..2ac0e2007 100644
--- a/app/src/main/java/org/oxycblt/auxio/playback/queue/QueueAdapter.kt
+++ b/app/src/main/java/org/oxycblt/auxio/playback/queue/QueueAdapter.kt
@@ -58,8 +58,8 @@ private constructor(
elevation = binding.context.getDimenSafe(R.dimen.elevation_normal) * 5
}
- val isEnabled: Boolean
- get() = binding.songDragHandle.isEnabled
+ val isPrevious: Boolean
+ get() = binding.songDragHandle.alpha == 0.5f
init {
binding.body.background =
@@ -87,17 +87,11 @@ private constructor(
binding.body.setOnClickListener { listener.onClick(this) }
- if (item.previous) {
- binding.songName.alpha = 0.5f
- binding.songInfo.alpha = 0.5f
- binding.songAlbumCover.alpha = 0.5f
- binding.songDragHandle.isEnabled = false
- } else {
- binding.songName.alpha = 1f
- binding.songInfo.alpha = 1f
- binding.songAlbumCover.alpha = 1f
- binding.songDragHandle.isEnabled = true
- }
+ val alpha = if (item.previous) 0.5f else 1f
+ binding.songAlbumCover.alpha = alpha
+ binding.songName.alpha = alpha
+ binding.songInfo.alpha = alpha
+ binding.songDragHandle.alpha = alpha
// Roll our own drag handlers as the default ones suck
binding.songDragHandle.setOnTouchListener { _, motionEvent ->
diff --git a/app/src/main/java/org/oxycblt/auxio/playback/queue/QueueDragCallback.kt b/app/src/main/java/org/oxycblt/auxio/playback/queue/QueueDragCallback.kt
index 360a2a72f..95020ba7c 100644
--- a/app/src/main/java/org/oxycblt/auxio/playback/queue/QueueDragCallback.kt
+++ b/app/src/main/java/org/oxycblt/auxio/playback/queue/QueueDragCallback.kt
@@ -40,7 +40,7 @@ class QueueDragCallback(private val playbackModel: QueueViewModel) : ItemTouchHe
viewHolder: RecyclerView.ViewHolder
): Int {
val queueHolder = viewHolder as QueueSongViewHolder
- return if (queueHolder.isEnabled) {
+ return if (!queueHolder.isPrevious) {
makeFlag(
ItemTouchHelper.ACTION_STATE_DRAG, ItemTouchHelper.UP or ItemTouchHelper.DOWN) or
makeFlag(ItemTouchHelper.ACTION_STATE_SWIPE, ItemTouchHelper.START)
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 8d2b10e5a..ce24c2587 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
@@ -19,6 +19,7 @@ package org.oxycblt.auxio.playback.queue
import android.os.Bundle
import android.view.LayoutInflater
+import androidx.core.view.isInvisible
import androidx.fragment.app.Fragment
import androidx.fragment.app.activityViewModels
import androidx.recyclerview.widget.ItemTouchHelper
@@ -31,6 +32,13 @@ import org.oxycblt.auxio.util.collectImmediately
/**
* A [Fragment] that shows the queue and enables editing as well.
+ *
+ * TODO: Improve index updates
+ *
+ * TODO: Test older versions
+ *
+ * TODO: Test restoration and song loss
+ *
* @author OxygenCobalt
*/
class QueueFragment : ViewBindingFragment(), QueueItemListener {
@@ -46,6 +54,14 @@ class QueueFragment : ViewBindingFragment(), QueueItemList
binding.queueRecycler.apply {
adapter = queueAdapter
touchHelper.attachToRecyclerView(this)
+ addOnScrollListener(
+ object : RecyclerView.OnScrollListener() {
+ override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
+ binding.queueDivider.isInvisible =
+ (layoutManager as LinearLayoutManager)
+ .findFirstCompletelyVisibleItemPosition() < 1
+ }
+ })
}
// --- VIEWMODEL SETUP ----
@@ -78,11 +94,12 @@ class QueueFragment : ViewBindingFragment(), QueueItemList
if (instructions.scrollTo != null) {
val binding = requireBinding()
val lmm = binding.queueRecycler.layoutManager as LinearLayoutManager
- val indices =
- lmm.findFirstCompletelyVisibleItemPosition()..lmm
- .findLastCompletelyVisibleItemPosition()
+ val start = lmm.findFirstCompletelyVisibleItemPosition()
+ val end = lmm.findLastCompletelyVisibleItemPosition()
- if (instructions.scrollTo !in indices) {
+ if (start != RecyclerView.NO_POSITION &&
+ end != RecyclerView.NO_POSITION &&
+ instructions.scrollTo !in start..end) {
binding.queueRecycler.scrollToPosition(instructions.scrollTo)
}
}
diff --git a/app/src/main/java/org/oxycblt/auxio/playback/queue/QueueViewModel.kt b/app/src/main/java/org/oxycblt/auxio/playback/queue/QueueViewModel.kt
index abfd580a0..711d551d3 100644
--- a/app/src/main/java/org/oxycblt/auxio/playback/queue/QueueViewModel.kt
+++ b/app/src/main/java/org/oxycblt/auxio/playback/queue/QueueViewModel.kt
@@ -73,7 +73,7 @@ class QueueViewModel : ViewModel(), PlaybackStateManager.Callback {
playbackManager.moveQueueItem(adapterFrom, adapterTo)
- return false
+ return true
}
fun finishInstructions() {
diff --git a/app/src/main/java/org/oxycblt/auxio/ui/BottomSheetContentBehavior.kt b/app/src/main/java/org/oxycblt/auxio/ui/BottomSheetContentBehavior.kt
index a573bb948..fa64cdb82 100644
--- a/app/src/main/java/org/oxycblt/auxio/ui/BottomSheetContentBehavior.kt
+++ b/app/src/main/java/org/oxycblt/auxio/ui/BottomSheetContentBehavior.kt
@@ -25,7 +25,6 @@ import androidx.coordinatorlayout.widget.CoordinatorLayout
import com.google.android.material.bottomsheet.NeoBottomSheetBehavior
import kotlin.math.abs
import org.oxycblt.auxio.util.coordinatorLayoutBehavior
-import org.oxycblt.auxio.util.logD
import org.oxycblt.auxio.util.replaceSystemBarInsetsCompat
import org.oxycblt.auxio.util.systemBarInsetsCompat
@@ -61,7 +60,6 @@ class BottomSheetContentBehavior(context: Context, attributeSet: Attri
layoutContent(child)
if (!setup) {
-
child.setOnApplyWindowInsetsListener { v, insets ->
lastInsets = insets
val dep = dep ?: return@setOnApplyWindowInsetsListener insets
@@ -94,8 +92,6 @@ class BottomSheetContentBehavior(context: Context, attributeSet: Attri
}
private fun layoutContent(child: View) {
- logD("Measure")
-
child.layout(0, 0, child.measuredWidth, child.measuredHeight)
}
@@ -126,8 +122,6 @@ class BottomSheetContentBehavior(context: Context, attributeSet: Attri
child: V,
dependency: View
): Boolean {
- logD("Dependent view changed $child")
-
val behavior = dependency.coordinatorLayoutBehavior as NeoBottomSheetBehavior
val consumed = behavior.calculateConsumedByBar()
if (consumed < Int.MIN_VALUE) {
@@ -135,8 +129,6 @@ class BottomSheetContentBehavior(context: Context, attributeSet: Attri
}
if (consumed != lastConsumed) {
- logD("Dependent view changed important $child")
-
lastConsumed = consumed
val insets = lastInsets
diff --git a/app/src/main/java/org/oxycblt/auxio/widgets/WidgetComponent.kt b/app/src/main/java/org/oxycblt/auxio/widgets/WidgetComponent.kt
index 14f80720f..c86e5ad36 100644
--- a/app/src/main/java/org/oxycblt/auxio/widgets/WidgetComponent.kt
+++ b/app/src/main/java/org/oxycblt/auxio/widgets/WidgetComponent.kt
@@ -95,16 +95,14 @@ class WidgetComponent(private val context: Context) :
}
// Resize the image in a such a way that we don't hit the RemoteView size
- // limit. The limit is technically the byte-size of an RGB_8888 bitmap 1.5x
- // the screen size, but the size of a RemoteView can for some reason be 10x
- // the size of the binded bitmaps, which means we need to heavily reduce
- // our image size as to make sure we stay around an order of magnitude below
- // the memory limit. This fixed size is also needed to ensure consistent
- // outlines on rounded images.
+ // limit, which is the size of an RGB_8888 bitmap 1.5x the screen size. Note
+ // that we actually set the limit to be half the memory limit so that it's
+ // less likely for us to hit it. it to really ensure we don't hit the limit.
+ // This also creates the consistent sizes required for round bitmaps.
val metrics = context.resources.displayMetrics
val sw = metrics.widthPixels
val sh = metrics.heightPixels
- builder.size((sqrt((6f * sw * sh)) / 8f).toInt())
+ builder.size((sqrt((6f * sw * sh) / 8f)).toInt())
return if (cornerRadius > 0) {
this@WidgetComponent.logD("Loading round covers: $cornerRadius")
diff --git a/app/src/main/java/org/oxycblt/auxio/widgets/WidgetProvider.kt b/app/src/main/java/org/oxycblt/auxio/widgets/WidgetProvider.kt
index a30a6e628..d23b1cf60 100644
--- a/app/src/main/java/org/oxycblt/auxio/widgets/WidgetProvider.kt
+++ b/app/src/main/java/org/oxycblt/auxio/widgets/WidgetProvider.kt
@@ -63,7 +63,7 @@ class WidgetProvider : AppWidgetProvider() {
SizeF(180f, 272f) to createMediumWidget(context, state),
SizeF(272f, 272f) to createLargeWidget(context, state))
- AppWidgetManager.getInstance(context).applyViewsCompat(context, views)
+ AppWidgetManager.getInstance(context).updateAppWidgetCompat(context, views)
}
/*
@@ -114,7 +114,7 @@ class WidgetProvider : AppWidgetProvider() {
context.sendBroadcast(intent)
}
- private fun AppWidgetManager.applyViewsCompat(
+ private fun AppWidgetManager.updateAppWidgetCompat(
context: Context,
views: Map
) {
diff --git a/app/src/main/res/color/sel_accented_primary.xml b/app/src/main/res/color/sel_accented_primary.xml
index e72a8e2ec..824dece22 100644
--- a/app/src/main/res/color/sel_accented_primary.xml
+++ b/app/src/main/res/color/sel_accented_primary.xml
@@ -1,5 +1,6 @@
+
\ No newline at end of file
diff --git a/app/src/main/res/color/sel_accented_secondary.xml b/app/src/main/res/color/sel_accented_secondary.xml
index 105bf5c7a..6402899ee 100644
--- a/app/src/main/res/color/sel_accented_secondary.xml
+++ b/app/src/main/res/color/sel_accented_secondary.xml
@@ -1,5 +1,6 @@
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/fragment_queue.xml b/app/src/main/res/layout/fragment_queue.xml
index d1aa866cc..3cbc99e6c 100644
--- a/app/src/main/res/layout/fragment_queue.xml
+++ b/app/src/main/res/layout/fragment_queue.xml
@@ -17,6 +17,7 @@
tools:listitem="@layout/item_queue_song" />
diff --git a/app/src/main/res/layout/item_queue_song.xml b/app/src/main/res/layout/item_queue_song.xml
index 161d79f37..4dd05ada7 100644
--- a/app/src/main/res/layout/item_queue_song.xml
+++ b/app/src/main/res/layout/item_queue_song.xml
@@ -32,51 +32,51 @@
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground">
-
+
-
+
-
+
-
+