Merge pull request #3907 from Bnyro/master

Show currently applied playlist sort order
This commit is contained in:
Bnyro 2023-06-03 11:50:55 +02:00 committed by GitHub
commit cc430d9507
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 29 additions and 12 deletions

View File

@ -67,6 +67,7 @@ class PlaylistFragment : Fragment() {
PreferenceHelper.putInt(PreferenceKeys.PLAYLIST_SORT_ORDER, value) PreferenceHelper.putInt(PreferenceKeys.PLAYLIST_SORT_ORDER, value)
field = value field = value
} }
private val sortOptions by lazy { resources.getStringArray(R.array.playlistSortOptions) }
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
@ -215,13 +216,13 @@ class PlaylistFragment : Fragment() {
keepQueue = true, keepQueue = true,
) )
} }
binding.sortMenu.isGone = false binding.sortContainer.isGone = false
binding.sortMenu.setOnClickListener { binding.sortTV.text = sortOptions[selectedSortOrder]
val sortOptions = resources.getStringArray(R.array.playlistSortOptions) binding.sortContainer.setOnClickListener {
BaseBottomSheet().apply { BaseBottomSheet().apply {
setSimpleItems(sortOptions.toList()) { index -> setSimpleItems(sortOptions.toList()) { index ->
selectedSortOrder = index selectedSortOrder = index
binding.sortTV.text = sortOptions[index]
showPlaylistVideos(response) showPlaylistVideos(response)
} }
}.show(childFragmentManager) }.show(childFragmentManager)

View File

@ -55,15 +55,31 @@
android:textSize="20sp" android:textSize="20sp"
android:textStyle="bold" /> android:textStyle="bold" />
<LinearLayout
android:id="@+id/sortContainer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginEnd="8dp"
android:padding="5dp"
android:background="@drawable/rounded_ripple"
android:visibility="gone"
tools:visibility="visible">
<TextView
android:id="@+id/sortTV"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="5dp"
tools:text="@string/most_recent" />
<ImageView <ImageView
android:id="@+id/sortMenu"
android:layout_width="20dp" android:layout_width="20dp"
android:layout_height="20dp" android:layout_height="20dp"
android:layout_gravity="center" android:layout_gravity="center"
android:layout_marginEnd="10dp" android:src="@drawable/ic_sort" />
android:background="?selectableItemBackgroundBorderless"
android:src="@drawable/ic_sort" </LinearLayout>
android:visibility="gone" />
<ImageView <ImageView
android:id="@+id/optionsMenu" android:id="@+id/optionsMenu"