add pref for background feed loading

This commit is contained in:
Bnyro 2022-09-18 19:13:51 +02:00
parent bd83d7d10a
commit e32758d17d
5 changed files with 29 additions and 1 deletions

View File

@ -19,6 +19,7 @@ object PreferenceKeys {
const val AUTO_ROTATION = "auto_rotation"
const val BREAK_REMINDER_TOGGLE = "break_reminder_toggle"
const val BREAK_REMINDER = "break_reminder"
const val SAVE_FEED = "save_feed"
/**
* Appearance

View File

@ -39,6 +39,11 @@ class SubscriptionsFragment : BaseFragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
val loadFeedInBackground = PreferenceHelper.getBoolean(
PreferenceKeys.SAVE_FEED,
false
)
binding.subRefresh.isEnabled = true
binding.subProgress.visibility = View.VISIBLE
@ -50,7 +55,10 @@ class SubscriptionsFragment : BaseFragment() {
binding.subFeed.layoutManager = GridLayoutManager(view.context, grid.toInt())
if (viewModel.videoFeed.value == null) viewModel.fetchFeed()
if (viewModel.videoFeed.value == null || !loadFeedInBackground) {
viewModel.videoFeed.value = null
viewModel.fetchFeed()
}
// listen for error responses
viewModel.errorResponse.observe(viewLifecycleOwner) {

View File

@ -0,0 +1,11 @@
<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/black"
android:fillType="evenOdd"
android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM18,12c0,3.31 -2.69,6 -6,6s-6,-2.69 -6,-6h2c0,2.21 1.79,4 4,4s4,-1.79 4,-4 -1.79,-4 -4,-4v3L8,7l4,-4v3c3.31,0 6,2.69 6,6z" />
</vector>

View File

@ -327,6 +327,8 @@
<string name="local_subscriptions">Local subscriptions</string>
<string name="preferences">Preferences</string>
<string name="backup_customInstances">Custom Instances</string>
<string name="save_feed">Load feed in background</string>
<string name="save_feed_summary">Load the subscription feed in the background and prevent it from being auto-refreshed.</string>
<!-- Notification channel strings -->
<string name="download_channel_name">Download Service</string>

View File

@ -30,6 +30,12 @@
app:key="new_videos_badge"
app:title="@string/new_videos_badge" />
<SwitchPreferenceCompat
android:icon="@drawable/ic_loading"
android:summary="@string/save_feed_summary"
app:key="save_feed"
app:title="@string/save_feed" />
</PreferenceCategory>
<PreferenceCategory app:title="@string/preferences">