Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ public class StatisticsPlaylistFragment
@State
Parcelable itemsListState;
private StatisticSortMode sortMode = StatisticSortMode.LAST_PLAYED;
private boolean includeFullyWatched = true;

private StatisticPlaylistControlBinding headerBinding;
private PlaylistControlBinding playlistControlBinding;
Expand All @@ -78,6 +79,14 @@ private List<StreamStatisticsEntry> processResult(final List<StreamStatisticsEnt
return null;
}
Collections.sort(results, comparator.reversed());

// Filter Fully Watched
if (!includeFullyWatched) {
return results.stream()
.filter(e -> e.getStreamEntity().getDuration() != e.getProgressMillis() / 1000)
.toList();
}

Comment on lines +84 to +89
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a note: there is StreamStateEntity.isFinished but it is another entity. Method uses StreamStatisticsEntry

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh okay.. I didn't know that.. Will refactor the code..

return results;
}

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

headerBinding.sortButton.setOnClickListener(view -> toggleSortMode());
headerBinding.fullyWatchedFilterButtonCheckBox
.setOnClickListener(view -> toggleIncludeFullyWatched());

hideLoading();
}
Expand Down Expand Up @@ -313,6 +324,11 @@ private void toggleSortMode() {
startLoading(true);
}

private void toggleIncludeFullyWatched() {
includeFullyWatched = !includeFullyWatched;
startLoading(true);
}

private PlayQueue getPlayQueueStartingAt(final StreamStatisticsEntry infoItem) {
return getPlayQueue(Math.max(itemListAdapter.getItemsList().indexOf(infoItem), 0));
}
Expand Down
96 changes: 66 additions & 30 deletions app/src/main/res/layout/statistic_playlist_control.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,37 +5,73 @@
android:layout_height="wrap_content"
android:orientation="vertical">

<RelativeLayout
android:id="@+id/sortButton"
android:layout_width="wrap_content"
<LinearLayout
android:layout_width="match_parent"
Comment on lines +8 to +9
Copy link
Copy Markdown

@ghost ghost Feb 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it necessary to add new LinearLayout (especially taking into account nested views performance considerations)? I am not sure but it seems to me that you could just expand existing RelativeLayout (?)

(It is not a "suggestion" because I am not fully sure by myself)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well actually the onclick listener for toggle sortMode is defined for the entire RelativeLayout.. hence why I did that..!

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. Not sure why comment didn't appear before 🤔.

Makes sense. But you could do like done in settings_notification_action.xml#notificationActionClickableArea but I am not sure it is the way to go so wait until real reviewer will come...

android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground"
android:clickable="true"
android:focusable="true">

<ImageView
android:id="@+id/sortButtonIcon"
android:layout_width="48dp"
android:layout_height="28dp"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:src="@drawable/ic_filter_list"
tools:ignore="ContentDescription,RtlHardcoded" />

<org.schabi.newpipe.views.NewPipeTextView
android:id="@+id/sortButtonText"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_toRightOf="@id/sortButtonIcon"
android:gravity="left|center"
android:text="@string/title_most_played"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="15sp"
android:textStyle="bold"
tools:ignore="RtlHardcoded" />
</RelativeLayout>
android:orientation="horizontal">

<RelativeLayout
android:id="@+id/sortButton"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="?attr/selectableItemBackground"
android:clickable="true"
android:focusable="true">

<ImageView
android:id="@+id/sortButtonIcon"
android:layout_width="48dp"
android:layout_height="28dp"
android:layout_alignParentStart="true"
android:layout_centerVertical="true"
android:layout_marginStart="12dp"
android:layout_marginEnd="12dp"
android:src="@drawable/ic_filter_list"
tools:ignore="ContentDescription" />

<org.schabi.newpipe.views.NewPipeTextView
android:id="@+id/sortButtonText"
android:layout_width="wrap_content"
android:layout_height="50dp"
android:layout_toEndOf="@id/sortButtonIcon"
android:gravity="start|center_vertical"
android:text="@string/title_most_played"
android:textSize="15sp"
android:textStyle="bold" />
</RelativeLayout>

<RelativeLayout
android:id="@+id/fullyWatchedFilterButton"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="?attr/selectableItemBackground"
android:clickable="true"
android:focusable="true">

<CheckBox
android:id="@+id/fullyWatchedFilterButtonCheckBox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_centerVertical="true"
android:layout_marginStart="12dp"
android:layout_marginEnd="12dp"
android:checked="true"/>

<org.schabi.newpipe.views.NewPipeTextView
android:id="@+id/fullyWatchedFilterButtonText"
android:layout_width="wrap_content"
android:layout_height="50dp"
android:layout_toEndOf="@id/fullyWatchedFilterButtonCheckBox"
android:gravity="start|center_vertical"
android:text="@string/title_fully_watched"
android:textSize="15sp"
android:textStyle="bold" />
</RelativeLayout>

</LinearLayout>

<include
android:id="@+id/playlist_control"
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -882,4 +882,5 @@
<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>
<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>
<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>
<string name="title_fully_watched">Fully Watched</string>
</resources>