From 12adebd4bf1cb8250f4b90f63e34dffca14ea858 Mon Sep 17 00:00:00 2001 From: Bnyro Date: Thu, 17 Nov 2022 16:25:34 +0100 Subject: [PATCH] add a reverse queue button --- .../libretube/ui/sheets/PlayingQueueSheet.kt | 8 ++++++-- app/src/main/res/drawable/ic_reverse.xml | 10 ++++++++++ .../main/res/layout/queue_bottom_sheet.xml | 20 +++++++++++++++++++ 3 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 app/src/main/res/drawable/ic_reverse.xml diff --git a/app/src/main/java/com/github/libretube/ui/sheets/PlayingQueueSheet.kt b/app/src/main/java/com/github/libretube/ui/sheets/PlayingQueueSheet.kt index 886ddf591..9982f5216 100644 --- a/app/src/main/java/com/github/libretube/ui/sheets/PlayingQueueSheet.kt +++ b/app/src/main/java/com/github/libretube/ui/sheets/PlayingQueueSheet.kt @@ -48,8 +48,7 @@ class PlayingQueueSheet : ExpandedBottomSheet() { binding.clear.setOnClickListener { val currentIndex = PlayingQueue.currentIndex() - val streams = PlayingQueue.getStreams().filterIndexed { - position, _ -> + val streams = PlayingQueue.getStreams().filterIndexed { position, _ -> position <= currentIndex } @@ -57,6 +56,11 @@ class PlayingQueueSheet : ExpandedBottomSheet() { adapter.notifyDataSetChanged() } + binding.reverse.setOnClickListener { + PlayingQueue.setStreams(PlayingQueue.getStreams().reversed()) + adapter.notifyDataSetChanged() + } + binding.bottomControls.setOnClickListener { dialog?.dismiss() } diff --git a/app/src/main/res/drawable/ic_reverse.xml b/app/src/main/res/drawable/ic_reverse.xml new file mode 100644 index 000000000..1daf24465 --- /dev/null +++ b/app/src/main/res/drawable/ic_reverse.xml @@ -0,0 +1,10 @@ + + + diff --git a/app/src/main/res/layout/queue_bottom_sheet.xml b/app/src/main/res/layout/queue_bottom_sheet.xml index e5671da4c..9d7c17904 100644 --- a/app/src/main/res/layout/queue_bottom_sheet.xml +++ b/app/src/main/res/layout/queue_bottom_sheet.xml @@ -41,10 +41,20 @@ android:id="@+id/shuffle" android:layout_width="wrap_content" android:layout_height="wrap_content" + android:layout_marginHorizontal="5dp" android:background="?attr/selectableItemBackgroundBorderless" android:padding="5dp" android:src="@drawable/ic_shuffle" /> + + + +