Skip to content

Commit 3e7cd92

Browse files
committed
Option to hide fully watched videos from History page #13260
1 parent 52a9b60 commit 3e7cd92

3 files changed

Lines changed: 83 additions & 30 deletions

File tree

app/src/main/java/org/schabi/newpipe/local/history/StatisticsPlaylistFragment.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ public class StatisticsPlaylistFragment
5757
@State
5858
Parcelable itemsListState;
5959
private StatisticSortMode sortMode = StatisticSortMode.LAST_PLAYED;
60+
private boolean includeFullyWatched = true;
6061

6162
private StatisticPlaylistControlBinding headerBinding;
6263
private PlaylistControlBinding playlistControlBinding;
@@ -78,6 +79,14 @@ private List<StreamStatisticsEntry> processResult(final List<StreamStatisticsEnt
7879
return null;
7980
}
8081
Collections.sort(results, comparator.reversed());
82+
83+
// Filter Fully Watched
84+
if (!includeFullyWatched) {
85+
return results.stream()
86+
.filter(e -> e.getStreamEntity().getDuration() != e.getProgressMillis() / 1000)
87+
.toList();
88+
}
89+
8190
return results;
8291
}
8392

@@ -277,6 +286,8 @@ public void handleResult(@NonNull final List<StreamStatisticsEntry> result) {
277286
PlayButtonHelper.initPlaylistControlClickListener(activity, playlistControlBinding, this);
278287

279288
headerBinding.sortButton.setOnClickListener(view -> toggleSortMode());
289+
headerBinding.fullyWatchedFilterButtonCheckBox
290+
.setOnClickListener(view -> toggleIncludeFullyWatched());
280291

281292
hideLoading();
282293
}
@@ -313,6 +324,11 @@ private void toggleSortMode() {
313324
startLoading(true);
314325
}
315326

327+
private void toggleIncludeFullyWatched() {
328+
includeFullyWatched = !includeFullyWatched;
329+
startLoading(true);
330+
}
331+
316332
private PlayQueue getPlayQueueStartingAt(final StreamStatisticsEntry infoItem) {
317333
return getPlayQueue(Math.max(itemListAdapter.getItemsList().indexOf(infoItem), 0));
318334
}

app/src/main/res/layout/statistic_playlist_control.xml

Lines changed: 66 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -5,37 +5,73 @@
55
android:layout_height="wrap_content"
66
android:orientation="vertical">
77

8-
<RelativeLayout
9-
android:id="@+id/sortButton"
10-
android:layout_width="wrap_content"
8+
<LinearLayout
9+
android:layout_width="match_parent"
1110
android:layout_height="wrap_content"
12-
android:background="?attr/selectableItemBackground"
13-
android:clickable="true"
14-
android:focusable="true">
15-
16-
<ImageView
17-
android:id="@+id/sortButtonIcon"
18-
android:layout_width="48dp"
19-
android:layout_height="28dp"
20-
android:layout_alignParentLeft="true"
21-
android:layout_centerVertical="true"
22-
android:layout_marginLeft="12dp"
23-
android:layout_marginRight="12dp"
24-
android:src="@drawable/ic_filter_list"
25-
tools:ignore="ContentDescription,RtlHardcoded" />
26-
27-
<org.schabi.newpipe.views.NewPipeTextView
28-
android:id="@+id/sortButtonText"
29-
android:layout_width="match_parent"
30-
android:layout_height="50dp"
31-
android:layout_toRightOf="@id/sortButtonIcon"
32-
android:gravity="left|center"
33-
android:text="@string/title_most_played"
34-
android:textAppearance="?android:attr/textAppearanceLarge"
35-
android:textSize="15sp"
36-
android:textStyle="bold"
37-
tools:ignore="RtlHardcoded" />
38-
</RelativeLayout>
11+
android:orientation="horizontal">
12+
13+
<RelativeLayout
14+
android:id="@+id/sortButton"
15+
android:layout_width="0dp"
16+
android:layout_height="wrap_content"
17+
android:layout_weight="1"
18+
android:background="?attr/selectableItemBackground"
19+
android:clickable="true"
20+
android:focusable="true">
21+
22+
<ImageView
23+
android:id="@+id/sortButtonIcon"
24+
android:layout_width="48dp"
25+
android:layout_height="28dp"
26+
android:layout_alignParentStart="true"
27+
android:layout_centerVertical="true"
28+
android:layout_marginStart="12dp"
29+
android:layout_marginEnd="12dp"
30+
android:src="@drawable/ic_filter_list"
31+
tools:ignore="ContentDescription" />
32+
33+
<org.schabi.newpipe.views.NewPipeTextView
34+
android:id="@+id/sortButtonText"
35+
android:layout_width="wrap_content"
36+
android:layout_height="50dp"
37+
android:layout_toEndOf="@id/sortButtonIcon"
38+
android:gravity="start|center_vertical"
39+
android:text="@string/title_most_played"
40+
android:textSize="15sp"
41+
android:textStyle="bold" />
42+
</RelativeLayout>
43+
44+
<RelativeLayout
45+
android:id="@+id/fullyWatchedFilterButton"
46+
android:layout_width="0dp"
47+
android:layout_height="wrap_content"
48+
android:layout_weight="1"
49+
android:background="?attr/selectableItemBackground"
50+
android:clickable="true"
51+
android:focusable="true">
52+
53+
<CheckBox
54+
android:id="@+id/fullyWatchedFilterButtonCheckBox"
55+
android:layout_width="wrap_content"
56+
android:layout_height="wrap_content"
57+
android:layout_alignParentStart="true"
58+
android:layout_centerVertical="true"
59+
android:layout_marginStart="12dp"
60+
android:layout_marginEnd="12dp"
61+
android:checked="true"/>
62+
63+
<org.schabi.newpipe.views.NewPipeTextView
64+
android:id="@+id/fullyWatchedFilterButtonText"
65+
android:layout_width="wrap_content"
66+
android:layout_height="50dp"
67+
android:layout_toEndOf="@id/fullyWatchedFilterButtonCheckBox"
68+
android:gravity="start|center_vertical"
69+
android:text="@string/title_fully_watched"
70+
android:textSize="15sp"
71+
android:textStyle="bold" />
72+
</RelativeLayout>
73+
74+
</LinearLayout>
3975

4076
<include
4177
android:id="@+id/playlist_control"

app/src/main/res/values/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -882,4 +882,5 @@
882882
<string name="youtube_player_http_403">HTTP error 403 received from server while playing, likely caused by an IP ban or streaming URL deobfuscation issues</string>
883883
<string name="sign_in_confirm_not_bot_error">%1$s refused to provide data, asking for a login to confirm the requester is not a bot.\n\nYour IP might have been temporarily banned by %1$s, you can wait some time or switch to a different IP (for example by turning on/off a VPN, or by switching from WiFi to mobile data).</string>
884884
<string name="unsupported_content_in_country">This content is not available for the currently selected content country.\n\nChange your selection from \"Settings > Content > Default content country\".</string>
885+
<string name="title_fully_watched">Fully Watched</string>
885886
</resources>

0 commit comments

Comments
 (0)