mirror of
https://github.com/TeamNewPipe/NewPipe.git
synced 2024-11-22 02:53:09 +01:00
Merge pull request #7160 from nschulzke/mark-as-watched-everywhere
Enable Mark as Watched in all the other playlist fragments.
This commit is contained in:
commit
9e44053e22
@ -378,6 +378,13 @@ public abstract class BaseListFragment<I, N> extends BaseStateFragment<I>
|
|||||||
if (KoreUtils.shouldShowPlayWithKodi(context, item.getServiceId())) {
|
if (KoreUtils.shouldShowPlayWithKodi(context, item.getServiceId())) {
|
||||||
entries.add(StreamDialogEntry.play_with_kodi);
|
entries.add(StreamDialogEntry.play_with_kodi);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// show "mark as watched" only when watch history is enabled
|
||||||
|
if (StreamDialogEntry.shouldAddMarkAsWatched(item.getStreamType(), context)) {
|
||||||
|
entries.add(
|
||||||
|
StreamDialogEntry.mark_as_watched
|
||||||
|
);
|
||||||
|
}
|
||||||
if (!isNullOrEmpty(item.getUploaderUrl())) {
|
if (!isNullOrEmpty(item.getUploaderUrl())) {
|
||||||
entries.add(StreamDialogEntry.show_channel_details);
|
entries.add(StreamDialogEntry.show_channel_details);
|
||||||
}
|
}
|
||||||
|
@ -176,6 +176,12 @@ public class PlaylistFragment extends BaseListInfoFragment<PlaylistInfo> {
|
|||||||
entries.add(StreamDialogEntry.play_with_kodi);
|
entries.add(StreamDialogEntry.play_with_kodi);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// show "mark as watched" only when watch history is enabled
|
||||||
|
if (StreamDialogEntry.shouldAddMarkAsWatched(item.getStreamType(), context)) {
|
||||||
|
entries.add(
|
||||||
|
StreamDialogEntry.mark_as_watched
|
||||||
|
);
|
||||||
|
}
|
||||||
if (!isNullOrEmpty(item.getUploaderUrl())) {
|
if (!isNullOrEmpty(item.getUploaderUrl())) {
|
||||||
entries.add(StreamDialogEntry.show_channel_details);
|
entries.add(StreamDialogEntry.show_channel_details);
|
||||||
}
|
}
|
||||||
|
@ -357,13 +357,7 @@ class FeedFragment : BaseStateFragment<FeedState>() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// show "mark as watched" only when watch history is enabled
|
// show "mark as watched" only when watch history is enabled
|
||||||
val isWatchHistoryEnabled = PreferenceManager
|
if (StreamDialogEntry.shouldAddMarkAsWatched(item.streamType, context)) {
|
||||||
.getDefaultSharedPreferences(context)
|
|
||||||
.getBoolean(getString(R.string.enable_watch_history_key), false)
|
|
||||||
if (item.streamType != StreamType.AUDIO_LIVE_STREAM &&
|
|
||||||
item.streamType != StreamType.LIVE_STREAM &&
|
|
||||||
isWatchHistoryEnabled
|
|
||||||
) {
|
|
||||||
entries.add(
|
entries.add(
|
||||||
StreamDialogEntry.mark_as_watched
|
StreamDialogEntry.mark_as_watched
|
||||||
)
|
)
|
||||||
|
@ -120,19 +120,11 @@ public class HistoryRecordManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Update the stream progress to the full duration of the video
|
// Update the stream progress to the full duration of the video
|
||||||
final List<StreamStateEntity> states = streamStateTable.getState(streamId)
|
final StreamStateEntity entity = new StreamStateEntity(
|
||||||
.blockingFirst();
|
streamId,
|
||||||
if (!states.isEmpty()) {
|
duration * 1000
|
||||||
final StreamStateEntity entity = states.get(0);
|
);
|
||||||
entity.setProgressMillis(duration * 1000);
|
streamStateTable.upsert(entity);
|
||||||
streamStateTable.update(entity);
|
|
||||||
} else {
|
|
||||||
final StreamStateEntity entity = new StreamStateEntity(
|
|
||||||
streamId,
|
|
||||||
duration * 1000
|
|
||||||
);
|
|
||||||
streamStateTable.insert(entity);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add a history entry
|
// Add a history entry
|
||||||
final StreamHistoryEntity latestEntry = streamHistoryTable.getLatestEntry(streamId);
|
final StreamHistoryEntity latestEntry = streamHistoryTable.getLatestEntry(streamId);
|
||||||
|
@ -366,6 +366,16 @@ public class StatisticsPlaylistFragment
|
|||||||
if (KoreUtils.shouldShowPlayWithKodi(context, infoItem.getServiceId())) {
|
if (KoreUtils.shouldShowPlayWithKodi(context, infoItem.getServiceId())) {
|
||||||
entries.add(StreamDialogEntry.play_with_kodi);
|
entries.add(StreamDialogEntry.play_with_kodi);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// show "mark as watched" only when watch history is enabled
|
||||||
|
if (StreamDialogEntry.shouldAddMarkAsWatched(
|
||||||
|
item.getStreamEntity().getStreamType(),
|
||||||
|
context
|
||||||
|
)) {
|
||||||
|
entries.add(
|
||||||
|
StreamDialogEntry.mark_as_watched
|
||||||
|
);
|
||||||
|
}
|
||||||
entries.add(StreamDialogEntry.show_channel_details);
|
entries.add(StreamDialogEntry.show_channel_details);
|
||||||
|
|
||||||
StreamDialogEntry.setEnabledEntries(entries);
|
StreamDialogEntry.setEnabledEntries(entries);
|
||||||
|
@ -782,6 +782,16 @@ public class LocalPlaylistFragment extends BaseLocalListFragment<List<PlaylistSt
|
|||||||
if (KoreUtils.shouldShowPlayWithKodi(context, infoItem.getServiceId())) {
|
if (KoreUtils.shouldShowPlayWithKodi(context, infoItem.getServiceId())) {
|
||||||
entries.add(StreamDialogEntry.play_with_kodi);
|
entries.add(StreamDialogEntry.play_with_kodi);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// show "mark as watched" only when watch history is enabled
|
||||||
|
if (StreamDialogEntry.shouldAddMarkAsWatched(
|
||||||
|
item.getStreamEntity().getStreamType(),
|
||||||
|
context
|
||||||
|
)) {
|
||||||
|
entries.add(
|
||||||
|
StreamDialogEntry.mark_as_watched
|
||||||
|
);
|
||||||
|
}
|
||||||
entries.add(StreamDialogEntry.show_channel_details);
|
entries.add(StreamDialogEntry.show_channel_details);
|
||||||
|
|
||||||
StreamDialogEntry.setEnabledEntries(entries);
|
StreamDialogEntry.setEnabledEntries(entries);
|
||||||
|
@ -5,11 +5,13 @@ import android.net.Uri;
|
|||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
|
import androidx.preference.PreferenceManager;
|
||||||
|
|
||||||
import org.schabi.newpipe.NewPipeDatabase;
|
import org.schabi.newpipe.NewPipeDatabase;
|
||||||
import org.schabi.newpipe.R;
|
import org.schabi.newpipe.R;
|
||||||
import org.schabi.newpipe.database.stream.model.StreamEntity;
|
import org.schabi.newpipe.database.stream.model.StreamEntity;
|
||||||
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
|
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
|
||||||
|
import org.schabi.newpipe.extractor.stream.StreamType;
|
||||||
import org.schabi.newpipe.local.dialog.PlaylistAppendDialog;
|
import org.schabi.newpipe.local.dialog.PlaylistAppendDialog;
|
||||||
import org.schabi.newpipe.local.dialog.PlaylistDialog;
|
import org.schabi.newpipe.local.dialog.PlaylistDialog;
|
||||||
import org.schabi.newpipe.local.history.HistoryRecordManager;
|
import org.schabi.newpipe.local.history.HistoryRecordManager;
|
||||||
@ -194,6 +196,16 @@ public enum StreamDialogEntry {
|
|||||||
void onClick(Fragment fragment, StreamInfoItem infoItem);
|
void onClick(Fragment fragment, StreamInfoItem infoItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean shouldAddMarkAsWatched(final StreamType streamType,
|
||||||
|
final Context context) {
|
||||||
|
final boolean isWatchHistoryEnabled = PreferenceManager
|
||||||
|
.getDefaultSharedPreferences(context)
|
||||||
|
.getBoolean(context.getString(R.string.enable_watch_history_key), false);
|
||||||
|
return streamType != StreamType.AUDIO_LIVE_STREAM
|
||||||
|
&& streamType != StreamType.LIVE_STREAM
|
||||||
|
&& isWatchHistoryEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////
|
/////////////////////////////////////////////
|
||||||
// private method to open channel fragment //
|
// private method to open channel fragment //
|
||||||
/////////////////////////////////////////////
|
/////////////////////////////////////////////
|
||||||
|
Loading…
Reference in New Issue
Block a user