mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-14 22:30:30 +05:30
Preference to edit the home tab content
This commit is contained in:
parent
52a2cfafa9
commit
dca3eb4b5e
@ -39,6 +39,7 @@ object PreferenceKeys {
|
|||||||
const val NEW_VIDEOS_BADGE = "new_videos_badge"
|
const val NEW_VIDEOS_BADGE = "new_videos_badge"
|
||||||
const val PLAYLISTS_ORDER = "playlists_order"
|
const val PLAYLISTS_ORDER = "playlists_order"
|
||||||
const val PLAYLIST_SORT_ORDER = "playlist_sort_order"
|
const val PLAYLIST_SORT_ORDER = "playlist_sort_order"
|
||||||
|
const val HOME_TAB_CONTENT = "home_tab_content"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instance
|
* Instance
|
||||||
|
@ -77,6 +77,10 @@ object PreferenceHelper {
|
|||||||
return settings.getFloat(key, defValue)
|
return settings.getFloat(key, defValue)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun getStringSet(key: String?, defValue: Set<String>): Set<String> {
|
||||||
|
return settings.getStringSet(key, defValue).orEmpty()
|
||||||
|
}
|
||||||
|
|
||||||
fun clearPreferences() {
|
fun clearPreferences() {
|
||||||
editor.clear().apply()
|
editor.clear().apply()
|
||||||
}
|
}
|
||||||
|
@ -82,11 +82,14 @@ class HomeFragment : Fragment() {
|
|||||||
private fun fetchHomeFeed() {
|
private fun fetchHomeFeed() {
|
||||||
lifecycleScope.launch {
|
lifecycleScope.launch {
|
||||||
repeatOnLifecycle(Lifecycle.State.CREATED) {
|
repeatOnLifecycle(Lifecycle.State.CREATED) {
|
||||||
|
val defaultItems = resources.getStringArray(R.array.homeTabItemsValues)
|
||||||
|
val visibleItems = PreferenceHelper
|
||||||
|
.getStringSet(PreferenceKeys.HOME_TAB_CONTENT, defaultItems.toSet())
|
||||||
awaitAll(
|
awaitAll(
|
||||||
async { loadTrending() },
|
async { if (visibleItems.contains(TRENDING)) loadTrending() },
|
||||||
async { loadBookmarks() },
|
async { if (visibleItems.contains(BOOKMARKS)) loadBookmarks() },
|
||||||
async { loadFeed() },
|
async { if (visibleItems.contains(FEATURED)) loadFeed() },
|
||||||
async { loadPlaylists() },
|
async { if (visibleItems.contains(PLAYLISTS)) loadPlaylists() },
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -194,4 +197,12 @@ class HomeFragment : Fragment() {
|
|||||||
binding.scroll.visibility = View.VISIBLE
|
binding.scroll.visibility = View.VISIBLE
|
||||||
binding.refresh.isRefreshing = false
|
binding.refresh.isRefreshing = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
// The values of the preference entries for the home tab content
|
||||||
|
private const val FEATURED = "featured"
|
||||||
|
private const val TRENDING = "trending"
|
||||||
|
private const val BOOKMARKS = "bookmarks"
|
||||||
|
private const val PLAYLISTS = "playlists"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
10
app/src/main/res/drawable/ic_awesome.xml
Normal file
10
app/src/main/res/drawable/ic_awesome.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="?colorControlNormal"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24">
|
||||||
|
<path
|
||||||
|
android:fillColor="@android:color/white"
|
||||||
|
android:pathData="M19,9l1.25,-2.75L23,5l-2.75,-1.25L19,1l-1.25,2.75L15,5l2.75,1.25L19,9zM11.5,9.5L9,4 6.5,9.5 1,12l5.5,2.5L9,20l2.5,-5.5L17,12l-5.5,-2.5zM19,15l-1.25,2.75L15,19l2.75,1.25L19,23l1.25,-2.75L23,19l-2.75,-1.25L19,15z" />
|
||||||
|
</vector>
|
@ -408,4 +408,18 @@
|
|||||||
<item>never</item>
|
<item>never</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
|
<string-array name="homeTabItems">
|
||||||
|
<item>@string/featured</item>
|
||||||
|
<item>@string/trending</item>
|
||||||
|
<item>@string/bookmarks</item>
|
||||||
|
<item>@string/playlists</item>
|
||||||
|
</string-array>
|
||||||
|
|
||||||
|
<string-array name="homeTabItemsValues">
|
||||||
|
<item>featured</item>
|
||||||
|
<item>trending</item>
|
||||||
|
<item>bookmarks</item>
|
||||||
|
<item>playlists</item>
|
||||||
|
</string-array>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -422,6 +422,7 @@
|
|||||||
<string name="import_format_newpipe">NewPipe</string>
|
<string name="import_format_newpipe">NewPipe</string>
|
||||||
<string name="import_format_freetube">FreeTube</string>
|
<string name="import_format_freetube">FreeTube</string>
|
||||||
<string name="import_format_youtube_csv">YouTube (CSV)</string>
|
<string name="import_format_youtube_csv">YouTube (CSV)</string>
|
||||||
|
<string name="home_tab_content">Home tab content</string>
|
||||||
|
|
||||||
<!-- Notification channel strings -->
|
<!-- Notification channel strings -->
|
||||||
<string name="download_channel_name">Download Service</string>
|
<string name="download_channel_name">Download Service</string>
|
||||||
|
@ -56,6 +56,14 @@
|
|||||||
|
|
||||||
<PreferenceCategory app:title="@string/layout">
|
<PreferenceCategory app:title="@string/layout">
|
||||||
|
|
||||||
|
<MultiSelectListPreference
|
||||||
|
android:icon="@drawable/ic_awesome"
|
||||||
|
app:defaultValue="@array/homeTabItemsValues"
|
||||||
|
android:title="@string/home_tab_content"
|
||||||
|
android:key="home_tab_content"
|
||||||
|
android:entryValues="@array/homeTabItemsValues"
|
||||||
|
android:entries="@array/homeTabItems" />
|
||||||
|
|
||||||
<SwitchPreferenceCompat
|
<SwitchPreferenceCompat
|
||||||
app:defaultValue="false"
|
app:defaultValue="false"
|
||||||
app:icon="@drawable/ic_list"
|
app:icon="@drawable/ic_list"
|
||||||
|
Loading…
Reference in New Issue
Block a user