mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-13 22:00:30 +05:30
playlist sorting option
This commit is contained in:
parent
8337f0e289
commit
c75ec150fe
@ -29,13 +29,13 @@ object PreferenceKeys {
|
||||
const val PURE_THEME = "pure_theme"
|
||||
const val ACCENT_COLOR = "accent_color"
|
||||
const val GRID_COLUMNS = "grid"
|
||||
const val DEFAULT_TAB = "default_tab"
|
||||
const val LABEL_VISIBILITY = "label_visibility"
|
||||
const val APP_ICON = "icon_change"
|
||||
const val LEGACY_SUBSCRIPTIONS = "legacy_subscriptions"
|
||||
const val LEGACY_SUBSCRIPTIONS_COLUMNS = "legacy_subscriptions_columns"
|
||||
const val ALTERNATIVE_TRENDING_LAYOUT = "trending_layout"
|
||||
const val NEW_VIDEOS_BADGE = "new_videos_badge"
|
||||
const val PLAYLISTS_ORDER = "playlists_order"
|
||||
|
||||
/**
|
||||
* Instance
|
||||
|
@ -7,7 +7,6 @@ import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.Toast
|
||||
import android.widget.Toast.makeText
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
|
@ -97,7 +97,7 @@ class LibraryFragment : BaseFragment() {
|
||||
fun fetchPlaylists() {
|
||||
binding.playlistRefresh.isRefreshing = true
|
||||
lifecycleScope.launchWhenCreated {
|
||||
val response = try {
|
||||
var playlists = try {
|
||||
RetrofitInstance.authApi.playlists(token)
|
||||
} catch (e: IOException) {
|
||||
println(e)
|
||||
@ -111,11 +111,24 @@ class LibraryFragment : BaseFragment() {
|
||||
} finally {
|
||||
binding.playlistRefresh.isRefreshing = false
|
||||
}
|
||||
if (response.isNotEmpty()) {
|
||||
if (playlists.isNotEmpty()) {
|
||||
binding.loginOrRegister.visibility = View.GONE
|
||||
|
||||
playlists = when (
|
||||
PreferenceHelper.getString(
|
||||
PreferenceKeys.PLAYLISTS_ORDER,
|
||||
"recent"
|
||||
)
|
||||
) {
|
||||
"recent" -> playlists
|
||||
"recent_reversed" -> playlists.reversed()
|
||||
"name" -> playlists.sortedBy { it.name }
|
||||
"name_reversed" -> playlists.sortedBy { it.name }.reversed()
|
||||
else -> playlists
|
||||
}
|
||||
|
||||
val playlistsAdapter = PlaylistsAdapter(
|
||||
response.toMutableList(),
|
||||
playlists.toMutableList(),
|
||||
childFragmentManager,
|
||||
requireActivity()
|
||||
)
|
||||
|
@ -10,7 +10,6 @@ import com.github.libretube.ui.activities.SettingsActivity
|
||||
import com.github.libretube.ui.base.BasePreferenceFragment
|
||||
import com.github.libretube.util.LocaleHelper
|
||||
import com.github.libretube.util.PreferenceHelper
|
||||
import java.util.*
|
||||
|
||||
class PlayerSettings : BasePreferenceFragment() {
|
||||
|
||||
|
10
app/src/main/res/drawable/ic_filter.xml
Normal file
10
app/src/main/res/drawable/ic_filter.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="?attr/colorControlNormal"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M10,18h4v-2h-4v2zM3,6v2h18L21,6L3,6zM6,13h12v-2L6,11v2z" />
|
||||
</vector>
|
@ -1,8 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
@ -16,8 +16,8 @@
|
||||
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
style="@style/CustomDialogTextInputLayout"
|
||||
app:passwordToggleEnabled="true"
|
||||
android:hint="@string/password">
|
||||
android:hint="@string/password"
|
||||
app:passwordToggleEnabled="true">
|
||||
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
android:id="@+id/delete_password"
|
||||
|
@ -15,8 +15,8 @@
|
||||
android:textSize="20sp" />
|
||||
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="5dp"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:hint="@string/filename">
|
||||
|
@ -1,8 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
@ -27,8 +27,8 @@
|
||||
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
style="@style/CustomDialogTextInputLayout"
|
||||
app:passwordToggleEnabled="true"
|
||||
android:hint="@string/password">
|
||||
android:hint="@string/password"
|
||||
app:passwordToggleEnabled="true">
|
||||
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
android:id="@+id/password"
|
||||
|
@ -18,14 +18,14 @@
|
||||
|
||||
<item
|
||||
android:id="@+id/downloadsFragment"
|
||||
android:enabled="false"
|
||||
android:icon="@drawable/ic_download_filled"
|
||||
android:title="@string/downloads"
|
||||
android:enabled="false" />
|
||||
android:title="@string/downloads" />
|
||||
|
||||
<item
|
||||
android:id="@+id/watchHistoryFragment"
|
||||
android:enabled="false"
|
||||
android:icon="@drawable/ic_history_filled"
|
||||
android:title="@string/history"
|
||||
android:enabled="false" />
|
||||
android:title="@string/history" />
|
||||
|
||||
</menu>
|
@ -93,7 +93,8 @@
|
||||
<item name="colorSecondary">@color/yellow_md_theme_dark_secondary</item>
|
||||
<item name="colorOnSecondary">@color/yellow_md_theme_dark_onSecondary</item>
|
||||
<item name="colorSecondaryContainer">@color/yellow_md_theme_dark_secondaryContainer</item>
|
||||
<item name="colorOnSecondaryContainer">@color/yellow_md_theme_dark_onSecondaryContainer</item>
|
||||
<item name="colorOnSecondaryContainer">@color/yellow_md_theme_dark_onSecondaryContainer
|
||||
</item>
|
||||
<item name="colorTertiary">@color/yellow_md_theme_dark_tertiary</item>
|
||||
<item name="colorOnTertiary">@color/yellow_md_theme_dark_onTertiary</item>
|
||||
<item name="colorTertiaryContainer">@color/yellow_md_theme_dark_tertiaryContainer</item>
|
||||
@ -124,7 +125,8 @@
|
||||
<item name="colorSecondary">@color/green_md_theme_dark_secondary</item>
|
||||
<item name="colorOnSecondary">@color/green_md_theme_dark_onSecondary</item>
|
||||
<item name="colorSecondaryContainer">@color/green_md_theme_dark_secondaryContainer</item>
|
||||
<item name="colorOnSecondaryContainer">@color/green_md_theme_dark_onSecondaryContainer</item>
|
||||
<item name="colorOnSecondaryContainer">@color/green_md_theme_dark_onSecondaryContainer
|
||||
</item>
|
||||
<item name="colorTertiary">@color/green_md_theme_dark_tertiary</item>
|
||||
<item name="colorOnTertiary">@color/green_md_theme_dark_onTertiary</item>
|
||||
<item name="colorTertiaryContainer">@color/green_md_theme_dark_tertiaryContainer</item>
|
||||
@ -155,7 +157,8 @@
|
||||
<item name="colorSecondary">@color/purple_md_theme_dark_secondary</item>
|
||||
<item name="colorOnSecondary">@color/purple_md_theme_dark_onSecondary</item>
|
||||
<item name="colorSecondaryContainer">@color/purple_md_theme_dark_secondaryContainer</item>
|
||||
<item name="colorOnSecondaryContainer">@color/purple_md_theme_dark_onSecondaryContainer</item>
|
||||
<item name="colorOnSecondaryContainer">@color/purple_md_theme_dark_onSecondaryContainer
|
||||
</item>
|
||||
<item name="colorTertiary">@color/purple_md_theme_dark_tertiary</item>
|
||||
<item name="colorOnTertiary">@color/purple_md_theme_dark_onTertiary</item>
|
||||
<item name="colorTertiaryContainer">@color/purple_md_theme_dark_tertiaryContainer</item>
|
||||
|
@ -421,4 +421,18 @@
|
||||
<item>default</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="playlistSortingOptions">
|
||||
<item>@string/recentlyUpdated</item>
|
||||
<item>@string/recentlyUpdatedReversed</item>
|
||||
<item>@string/playlistName</item>
|
||||
<item>@string/playlistNameReversed</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="playlistSortingOptionsValues">
|
||||
<item>recent</item>
|
||||
<item>recent_reversed</item>
|
||||
<item>name</item>
|
||||
<item>name_reversed</item>
|
||||
</string-array>
|
||||
|
||||
</resources>
|
@ -340,6 +340,10 @@
|
||||
<string name="playback_pitch">Pitch</string>
|
||||
<string name="filename">Filename</string>
|
||||
<string name="invalid_filename">Invalid filename!</string>
|
||||
<string name="playlists_order">Playlists order</string>
|
||||
<string name="playlistNameReversed">Playlist name (reversed)</string>
|
||||
<string name="recentlyUpdated">Recently updated</string>
|
||||
<string name="recentlyUpdatedReversed">Recently updated (reversed)</string>
|
||||
|
||||
<!-- Notification channel strings -->
|
||||
<string name="download_channel_name">Download Service</string>
|
||||
|
@ -62,7 +62,8 @@
|
||||
<item name="colorSecondary">@color/blue_md_theme_light_secondary</item>
|
||||
<item name="colorOnSecondary">@color/blue_md_theme_light_onSecondary</item>
|
||||
<item name="colorSecondaryContainer">@color/blue_md_theme_light_secondaryContainer</item>
|
||||
<item name="colorOnSecondaryContainer">@color/blue_md_theme_light_onSecondaryContainer</item>
|
||||
<item name="colorOnSecondaryContainer">@color/blue_md_theme_light_onSecondaryContainer
|
||||
</item>
|
||||
<item name="colorTertiary">@color/blue_md_theme_light_tertiary</item>
|
||||
<item name="colorOnTertiary">@color/blue_md_theme_light_onTertiary</item>
|
||||
<item name="colorTertiaryContainer">@color/blue_md_theme_light_tertiaryContainer</item>
|
||||
@ -93,11 +94,13 @@
|
||||
<item name="colorSecondary">@color/yellow_md_theme_light_secondary</item>
|
||||
<item name="colorOnSecondary">@color/yellow_md_theme_light_onSecondary</item>
|
||||
<item name="colorSecondaryContainer">@color/yellow_md_theme_light_secondaryContainer</item>
|
||||
<item name="colorOnSecondaryContainer">@color/yellow_md_theme_light_onSecondaryContainer</item>
|
||||
<item name="colorOnSecondaryContainer">@color/yellow_md_theme_light_onSecondaryContainer
|
||||
</item>
|
||||
<item name="colorTertiary">@color/yellow_md_theme_light_tertiary</item>
|
||||
<item name="colorOnTertiary">@color/yellow_md_theme_light_onTertiary</item>
|
||||
<item name="colorTertiaryContainer">@color/yellow_md_theme_light_tertiaryContainer</item>
|
||||
<item name="colorOnTertiaryContainer">@color/yellow_md_theme_light_onTertiaryContainer</item>
|
||||
<item name="colorOnTertiaryContainer">@color/yellow_md_theme_light_onTertiaryContainer
|
||||
</item>
|
||||
<item name="colorError">@color/yellow_md_theme_light_error</item>
|
||||
<item name="colorErrorContainer">@color/yellow_md_theme_light_errorContainer</item>
|
||||
<item name="colorOnError">@color/yellow_md_theme_light_onError</item>
|
||||
@ -124,7 +127,8 @@
|
||||
<item name="colorSecondary">@color/green_md_theme_light_secondary</item>
|
||||
<item name="colorOnSecondary">@color/green_md_theme_light_onSecondary</item>
|
||||
<item name="colorSecondaryContainer">@color/green_md_theme_light_secondaryContainer</item>
|
||||
<item name="colorOnSecondaryContainer">@color/green_md_theme_light_onSecondaryContainer</item>
|
||||
<item name="colorOnSecondaryContainer">@color/green_md_theme_light_onSecondaryContainer
|
||||
</item>
|
||||
<item name="colorTertiary">@color/green_md_theme_light_tertiary</item>
|
||||
<item name="colorOnTertiary">@color/green_md_theme_light_onTertiary</item>
|
||||
<item name="colorTertiaryContainer">@color/green_md_theme_light_tertiaryContainer</item>
|
||||
@ -155,11 +159,13 @@
|
||||
<item name="colorSecondary">@color/purple_md_theme_light_secondary</item>
|
||||
<item name="colorOnSecondary">@color/purple_md_theme_light_onSecondary</item>
|
||||
<item name="colorSecondaryContainer">@color/purple_md_theme_light_secondaryContainer</item>
|
||||
<item name="colorOnSecondaryContainer">@color/purple_md_theme_light_onSecondaryContainer</item>
|
||||
<item name="colorOnSecondaryContainer">@color/purple_md_theme_light_onSecondaryContainer
|
||||
</item>
|
||||
<item name="colorTertiary">@color/purple_md_theme_light_tertiary</item>
|
||||
<item name="colorOnTertiary">@color/purple_md_theme_light_onTertiary</item>
|
||||
<item name="colorTertiaryContainer">@color/purple_md_theme_light_tertiaryContainer</item>
|
||||
<item name="colorOnTertiaryContainer">@color/purple_md_theme_light_onTertiaryContainer</item>
|
||||
<item name="colorOnTertiaryContainer">@color/purple_md_theme_light_onTertiaryContainer
|
||||
</item>
|
||||
<item name="colorError">@color/purple_md_theme_light_error</item>
|
||||
<item name="colorErrorContainer">@color/purple_md_theme_light_errorContainer</item>
|
||||
<item name="colorOnError">@color/purple_md_theme_light_onError</item>
|
||||
|
@ -71,4 +71,16 @@
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory app:title="@string/misc">
|
||||
|
||||
<ListPreference
|
||||
android:defaultValue="recent"
|
||||
android:entries="@array/playlistSortingOptions"
|
||||
android:entryValues="@array/playlistSortingOptionsValues"
|
||||
android:icon="@drawable/ic_filter"
|
||||
app:key="playlists_order"
|
||||
app:title="@string/playlists_order" />
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
</PreferenceScreen>
|
Loading…
Reference in New Issue
Block a user