File tree Expand file tree Collapse file tree
app/src/main/java/org/schabi/newpipe Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -378,6 +378,19 @@ protected void showStreamDialog(final StreamInfoItem item) {
378378 if (KoreUtils .shouldShowPlayWithKodi (context , item .getServiceId ())) {
379379 entries .add (StreamDialogEntry .play_with_kodi );
380380 }
381+
382+ // show "mark as watched" only when watch history is enabled
383+ final boolean isWatchHistoryEnabled = PreferenceManager
384+ .getDefaultSharedPreferences (context )
385+ .getBoolean (getString (R .string .enable_watch_history_key ), false );
386+ if (item .getStreamType () != StreamType .AUDIO_LIVE_STREAM
387+ && item .getStreamType () != StreamType .LIVE_STREAM
388+ && isWatchHistoryEnabled
389+ ) {
390+ entries .add (
391+ StreamDialogEntry .mark_as_watched
392+ );
393+ }
381394 if (!isNullOrEmpty (item .getUploaderUrl ())) {
382395 entries .add (StreamDialogEntry .show_channel_details );
383396 }
Original file line number Diff line number Diff line change 1515import androidx .annotation .NonNull ;
1616import androidx .annotation .Nullable ;
1717import androidx .appcompat .content .res .AppCompatResources ;
18+ import androidx .preference .PreferenceManager ;
1819import androidx .viewbinding .ViewBinding ;
1920
2021import org .reactivestreams .Subscriber ;
@@ -176,6 +177,18 @@ protected void showStreamDialog(final StreamInfoItem item) {
176177 entries .add (StreamDialogEntry .play_with_kodi );
177178 }
178179
180+ // show "mark as watched" only when watch history is enabled
181+ final boolean isWatchHistoryEnabled = PreferenceManager
182+ .getDefaultSharedPreferences (context )
183+ .getBoolean (getString (R .string .enable_watch_history_key ), false );
184+ if (item .getStreamType () != StreamType .AUDIO_LIVE_STREAM
185+ && item .getStreamType () != StreamType .LIVE_STREAM
186+ && isWatchHistoryEnabled
187+ ) {
188+ entries .add (
189+ StreamDialogEntry .mark_as_watched
190+ );
191+ }
179192 if (!isNullOrEmpty (item .getUploaderUrl ())) {
180193 entries .add (StreamDialogEntry .show_channel_details );
181194 }
Original file line number Diff line number Diff line change @@ -120,19 +120,11 @@ public Maybe<Long> markAsWatched(final StreamInfoItem info) {
120120 }
121121
122122 // Update the stream progress to the full duration of the video
123- final List <StreamStateEntity > states = streamStateTable .getState (streamId )
124- .blockingFirst ();
125- if (!states .isEmpty ()) {
126- final StreamStateEntity entity = states .get (0 );
127- entity .setProgressMillis (duration * 1000 );
128- streamStateTable .update (entity );
129- } else {
130- final StreamStateEntity entity = new StreamStateEntity (
131- streamId ,
132- duration * 1000
133- );
134- streamStateTable .insert (entity );
135- }
123+ final StreamStateEntity entity = new StreamStateEntity (
124+ streamId ,
125+ duration * 1000
126+ );
127+ streamStateTable .upsert (entity );
136128
137129 // Add a history entry
138130 final StreamHistoryEntity latestEntry = streamHistoryTable .getLatestEntry (streamId );
Original file line number Diff line number Diff line change 1414
1515import androidx .annotation .NonNull ;
1616import androidx .annotation .Nullable ;
17+ import androidx .preference .PreferenceManager ;
1718import androidx .viewbinding .ViewBinding ;
1819
1920import com .google .android .material .snackbar .Snackbar ;
@@ -366,6 +367,19 @@ private void showStreamDialog(final StreamStatisticsEntry item) {
366367 if (KoreUtils .shouldShowPlayWithKodi (context , infoItem .getServiceId ())) {
367368 entries .add (StreamDialogEntry .play_with_kodi );
368369 }
370+
371+ // show "mark as watched" only when watch history is enabled
372+ final boolean isWatchHistoryEnabled = PreferenceManager
373+ .getDefaultSharedPreferences (context )
374+ .getBoolean (getString (R .string .enable_watch_history_key ), false );
375+ if (item .getStreamEntity ().getStreamType () != StreamType .AUDIO_LIVE_STREAM
376+ && item .getStreamEntity ().getStreamType () != StreamType .LIVE_STREAM
377+ && isWatchHistoryEnabled
378+ ) {
379+ entries .add (
380+ StreamDialogEntry .mark_as_watched
381+ );
382+ }
369383 entries .add (StreamDialogEntry .show_channel_details );
370384
371385 StreamDialogEntry .setEnabledEntries (entries );
Original file line number Diff line number Diff line change 1919import androidx .annotation .NonNull ;
2020import androidx .annotation .Nullable ;
2121import androidx .appcompat .app .AlertDialog ;
22+ import androidx .preference .PreferenceManager ;
2223import androidx .recyclerview .widget .ItemTouchHelper ;
2324import androidx .recyclerview .widget .RecyclerView ;
2425import androidx .viewbinding .ViewBinding ;
@@ -782,6 +783,19 @@ protected void showStreamItemDialog(final PlaylistStreamEntry item) {
782783 if (KoreUtils .shouldShowPlayWithKodi (context , infoItem .getServiceId ())) {
783784 entries .add (StreamDialogEntry .play_with_kodi );
784785 }
786+
787+ // show "mark as watched" only when watch history is enabled
788+ final boolean isWatchHistoryEnabled = PreferenceManager
789+ .getDefaultSharedPreferences (context )
790+ .getBoolean (getString (R .string .enable_watch_history_key ), false );
791+ if (item .getStreamEntity ().getStreamType () != StreamType .AUDIO_LIVE_STREAM
792+ && item .getStreamEntity ().getStreamType () != StreamType .LIVE_STREAM
793+ && isWatchHistoryEnabled
794+ ) {
795+ entries .add (
796+ StreamDialogEntry .mark_as_watched
797+ );
798+ }
785799 entries .add (StreamDialogEntry .show_channel_details );
786800
787801 StreamDialogEntry .setEnabledEntries (entries );
You can’t perform that action at this time.
0 commit comments