From bc29f40d6940f0bea180d7cb948350202193d48d Mon Sep 17 00:00:00 2001 From: Jared Fantaye Date: Thu, 9 Feb 2023 21:18:21 +0100 Subject: [PATCH] Implemented the suggested changes --- .../newpipe/database/feed/dao/FeedDAO.kt | 2 +- .../schabi/newpipe/local/feed/FeedFragment.kt | 17 ++++++------- .../newpipe/local/feed/FeedViewModel.kt | 24 +++++++------------ .../local/history/HistoryRecordManager.java | 2 +- app/src/main/res/values/strings.xml | 6 ++--- 5 files changed, 21 insertions(+), 30 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/database/feed/dao/FeedDAO.kt b/app/src/main/java/org/schabi/newpipe/database/feed/dao/FeedDAO.kt index 42a248ca5..6947f66af 100644 --- a/app/src/main/java/org/schabi/newpipe/database/feed/dao/FeedDAO.kt +++ b/app/src/main/java/org/schabi/newpipe/database/feed/dao/FeedDAO.kt @@ -74,7 +74,7 @@ abstract class FeedDAO { OR (sst.progress_time <= ${StreamStateEntity.PLAYBACK_SAVE_THRESHOLD_START_MILLISECONDS} AND sst.progress_time <= s.duration * 1000 / 4) OR (sst.progress_time >= s.duration * 1000 - ${StreamStateEntity.PLAYBACK_FINISHED_END_MILLISECONDS} - OR sst.progress_time >= s.duration * 1000 * 3 / 4) + AND sst.progress_time >= s.duration * 1000 * 3 / 4) ) AND ( :uploadDateBefore IS NULL diff --git a/app/src/main/java/org/schabi/newpipe/local/feed/FeedFragment.kt b/app/src/main/java/org/schabi/newpipe/local/feed/FeedFragment.kt index d2c361662..3ca3bd320 100644 --- a/app/src/main/java/org/schabi/newpipe/local/feed/FeedFragment.kt +++ b/app/src/main/java/org/schabi/newpipe/local/feed/FeedFragment.kt @@ -259,7 +259,7 @@ class FeedFragment : BaseStateFragment() { getString(R.string.feed_show_upcoming) ) - val checkedDialogItems = booleanArrayOf(!showPlayedItems, !showPartiallyPlayedItems, !showFutureItems) + val checkedDialogItems = booleanArrayOf(showPlayedItems, showPartiallyPlayedItems, showFutureItems) val builder = AlertDialog.Builder(context!!) builder.setTitle(R.string.feed_hide_streams_title) @@ -268,17 +268,14 @@ class FeedFragment : BaseStateFragment() { } builder.setPositiveButton(R.string.ok) { _, _ -> - showPlayedItems = !checkedDialogItems[0] - viewModel.setShowPlayedItems(showPlayedItems) - viewModel.saveShowPlayedItemsToPreferences(showPlayedItems) + showPlayedItems = checkedDialogItems[0] + viewModel.setSaveShowPlayedItems(showPlayedItems) - showPartiallyPlayedItems = !checkedDialogItems[1] - viewModel.setShowPartiallyPlayedItems(showPartiallyPlayedItems) - viewModel.saveShowPartiallyPlayedItemsToPreferences(showPartiallyPlayedItems) + showPartiallyPlayedItems = checkedDialogItems[1] + viewModel.setSaveShowPartiallyPlayedItems(showPartiallyPlayedItems) - showFutureItems = !checkedDialogItems[2] - viewModel.setShowFutureItems(showFutureItems) - viewModel.saveShowFutureItemsToPreferences(showFutureItems) + showFutureItems = checkedDialogItems[2] + viewModel.setSaveShowFutureItems(showFutureItems) } builder.setNegativeButton(R.string.cancel, null) diff --git a/app/src/main/java/org/schabi/newpipe/local/feed/FeedViewModel.kt b/app/src/main/java/org/schabi/newpipe/local/feed/FeedViewModel.kt index 2e85a65cb..015b72160 100644 --- a/app/src/main/java/org/schabi/newpipe/local/feed/FeedViewModel.kt +++ b/app/src/main/java/org/schabi/newpipe/local/feed/FeedViewModel.kt @@ -31,9 +31,9 @@ import java.util.concurrent.TimeUnit class FeedViewModel( private val application: Application, groupId: Long = FeedGroupEntity.GROUP_ALL_ID, - initialShowPlayedItems: Boolean = true, - initialShowPartiallyPlayedItems: Boolean = true, - initialShowFutureItems: Boolean = true + initialShowPlayedItems: Boolean, + initialShowPartiallyPlayedItems: Boolean, + initialShowFutureItems: Boolean ) : ViewModel() { private val feedDatabaseManager = FeedDatabaseManager(application) @@ -119,39 +119,33 @@ class FeedViewModel( val t4: OffsetDateTime? ) - fun setShowPlayedItems(showPlayedItems: Boolean) { + fun setSaveShowPlayedItems(showPlayedItems: Boolean) { this.showPlayedItems.onNext(showPlayedItems) - } - - fun saveShowPlayedItemsToPreferences(showPlayedItems: Boolean) = PreferenceManager.getDefaultSharedPreferences(application).edit { this.putBoolean(application.getString(R.string.feed_show_watched_items_key), showPlayedItems) this.apply() } + } fun getShowPlayedItemsFromPreferences() = getShowPlayedItemsFromPreferences(application) - fun setShowPartiallyPlayedItems(showPartiallyPlayedItems: Boolean) { + fun setSaveShowPartiallyPlayedItems(showPartiallyPlayedItems: Boolean) { this.showPartiallyPlayedItems.onNext(showPartiallyPlayedItems) - } - - fun saveShowPartiallyPlayedItemsToPreferences(showPartiallyPlayedItems: Boolean) = PreferenceManager.getDefaultSharedPreferences(application).edit { this.putBoolean(application.getString(R.string.feed_show_partially_watched_items_key), showPartiallyPlayedItems) this.apply() } + } fun getShowPartiallyPlayedItemsFromPreferences() = getShowPartiallyPlayedItemsFromPreferences(application) - fun setShowFutureItems(showFutureItems: Boolean) { + fun setSaveShowFutureItems(showFutureItems: Boolean) { this.showFutureItems.onNext(showFutureItems) - } - - fun saveShowFutureItemsToPreferences(showFutureItems: Boolean) = PreferenceManager.getDefaultSharedPreferences(application).edit { this.putBoolean(application.getString(R.string.feed_show_future_items_key), showFutureItems) this.apply() } + } fun getShowFutureItemsFromPreferences() = getShowFutureItemsFromPreferences(application) diff --git a/app/src/main/java/org/schabi/newpipe/local/history/HistoryRecordManager.java b/app/src/main/java/org/schabi/newpipe/local/history/HistoryRecordManager.java index 340b22278..ed3cf548f 100644 --- a/app/src/main/java/org/schabi/newpipe/local/history/HistoryRecordManager.java +++ b/app/src/main/java/org/schabi/newpipe/local/history/HistoryRecordManager.java @@ -87,7 +87,7 @@ public class HistoryRecordManager { * Marks a stream item as watched such that it is hidden from the feed if watched videos are * hidden. Adds a history entry and updates the stream progress to 100%. * - * @see FeedViewModel#setShowPlayedItems + * @see FeedViewModel#setSaveShowPlayedItems * @param info the item to mark as watched * @return a Maybe containing the ID of the item if successful */ diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index e01d3ed72..ee388ce13 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -691,7 +691,7 @@ \nYouTube is an example of a service that offers this fast method with its RSS feed. \n \nSo the choice boils down to what you prefer: speed or precise information. - Hide the following streams + Show the following streams Show/Hide streams This content is not yet supported by NewPipe.\n\nIt will hopefully be supported in a future version. Channel\'s avatar thumbnail @@ -760,8 +760,8 @@ Unknown quality Show future items Hide future items - Fully Watched - Partially Watched + Fully watched + Partially watched Upcoming Sort \ No newline at end of file