mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-04-29 00:10:32 +05:30
add shuffle and clear to playing queue
This commit is contained in:
parent
75ffce292c
commit
7837ce1c60
@ -7,20 +7,20 @@ import android.view.ViewGroup
|
|||||||
import androidx.recyclerview.widget.ItemTouchHelper
|
import androidx.recyclerview.widget.ItemTouchHelper
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import com.github.libretube.databinding.BottomSheetBinding
|
import com.github.libretube.databinding.QueueBottomSheetBinding
|
||||||
import com.github.libretube.ui.adapters.PlayingQueueAdapter
|
import com.github.libretube.ui.adapters.PlayingQueueAdapter
|
||||||
import com.github.libretube.util.PlayingQueue
|
import com.github.libretube.util.PlayingQueue
|
||||||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
|
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
|
||||||
|
|
||||||
class PlayingQueueSheet : BottomSheetDialogFragment() {
|
class PlayingQueueSheet : BottomSheetDialogFragment() {
|
||||||
private lateinit var binding: BottomSheetBinding
|
private lateinit var binding: QueueBottomSheetBinding
|
||||||
|
|
||||||
override fun onCreateView(
|
override fun onCreateView(
|
||||||
inflater: LayoutInflater,
|
inflater: LayoutInflater,
|
||||||
container: ViewGroup?,
|
container: ViewGroup?,
|
||||||
savedInstanceState: Bundle?
|
savedInstanceState: Bundle?
|
||||||
): View {
|
): View {
|
||||||
binding = BottomSheetBinding.inflate(layoutInflater)
|
binding = QueueBottomSheetBinding.inflate(layoutInflater)
|
||||||
return binding.root
|
return binding.root
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -31,6 +31,21 @@ class PlayingQueueSheet : BottomSheetDialogFragment() {
|
|||||||
val adapter = PlayingQueueAdapter()
|
val adapter = PlayingQueueAdapter()
|
||||||
binding.optionsRecycler.adapter = adapter
|
binding.optionsRecycler.adapter = adapter
|
||||||
|
|
||||||
|
binding.shuffle.setOnClickListener {
|
||||||
|
val streams = PlayingQueue.getStreams()
|
||||||
|
streams.subList(PlayingQueue.currentIndex(), PlayingQueue.size()).shuffle()
|
||||||
|
adapter.notifyItemRangeChanged(0, PlayingQueue.size())
|
||||||
|
}
|
||||||
|
|
||||||
|
binding.clear.setOnClickListener {
|
||||||
|
val streams = PlayingQueue.getStreams()
|
||||||
|
streams.subList(PlayingQueue.currentIndex(), PlayingQueue.size()).clear()
|
||||||
|
}
|
||||||
|
|
||||||
|
binding.bottomControls.setOnClickListener {
|
||||||
|
dialog?.dismiss()
|
||||||
|
}
|
||||||
|
|
||||||
val callback = object : ItemTouchHelper.SimpleCallback(
|
val callback = object : ItemTouchHelper.SimpleCallback(
|
||||||
ItemTouchHelper.UP or ItemTouchHelper.DOWN,
|
ItemTouchHelper.UP or ItemTouchHelper.DOWN,
|
||||||
ItemTouchHelper.LEFT
|
ItemTouchHelper.LEFT
|
||||||
|
10
app/src/main/res/drawable/ic_shuffle.xml
Normal file
10
app/src/main/res/drawable/ic_shuffle.xml
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:tint="#000000"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24">
|
||||||
|
<path
|
||||||
|
android:fillColor="@android:color/white"
|
||||||
|
android:pathData="M10.59,9.17L5.41,4 4,5.41l5.17,5.17 1.42,-1.41zM14.5,4l2.04,2.04L4,18.59 5.41,20 17.96,7.46 20,9.5L20,4h-5.5zM14.83,13.41l-1.41,1.41 3.13,3.13L14.5,20L20,20v-5.5l-2.04,2.04 -3.13,-3.13z" />
|
||||||
|
</vector>
|
66
app/src/main/res/layout/queue_bottom_sheet.xml
Normal file
66
app/src/main/res/layout/queue_bottom_sheet.xml
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<FrameLayout
|
||||||
|
android:id="@+id/standard_bottom_sheet"
|
||||||
|
style="@style/Widget.Material3.BottomSheet"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:paddingBottom="20dp"
|
||||||
|
app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<!-- Drag handle for accessibility -->
|
||||||
|
<com.google.android.material.bottomsheet.BottomSheetDragHandleView
|
||||||
|
android:id="@+id/drag_handle"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content" />
|
||||||
|
|
||||||
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
|
android:id="@+id/options_recycler"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/bottom_controls"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="@drawable/rounded_ripple"
|
||||||
|
android:padding="10dp">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/shuffle"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="?attr/selectableItemBackgroundBorderless"
|
||||||
|
android:src="@drawable/ic_shuffle" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginHorizontal="10dp"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:rotation="180"
|
||||||
|
android:src="@drawable/ic_arrow_down" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/clear"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="?attr/selectableItemBackgroundBorderless"
|
||||||
|
android:src="@drawable/ic_close" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</FrameLayout>
|
||||||
|
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
Loading…
x
Reference in New Issue
Block a user