Skip to content

Commit 8c296ca

Browse files
committed
- Changed Text to "Hide Watched"
- Implemented isFinished in StreamStatisticsEntry.kt
1 parent c8fb724 commit 8c296ca

File tree

4 files changed

+20
-4
lines changed

4 files changed

+20
-4
lines changed

app/src/main/java/org/schabi/newpipe/database/stream/StreamStatisticsEntry.kt

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,14 @@ package org.schabi.newpipe.database.stream
99
import androidx.room.ColumnInfo
1010
import androidx.room.Embedded
1111
import androidx.room.Ignore
12-
import java.time.OffsetDateTime
1312
import org.schabi.newpipe.database.LocalItem
1413
import org.schabi.newpipe.database.history.model.StreamHistoryEntity
1514
import org.schabi.newpipe.database.stream.model.StreamEntity
15+
import org.schabi.newpipe.database.stream.model.StreamStateEntity.Companion.PLAYBACK_FINISHED_END_MILLISECONDS
1616
import org.schabi.newpipe.database.stream.model.StreamStateEntity.Companion.STREAM_PROGRESS_MILLIS
1717
import org.schabi.newpipe.extractor.stream.StreamInfoItem
1818
import org.schabi.newpipe.util.image.ImageStrategy
19+
import java.time.OffsetDateTime
1920

2021
data class StreamStatisticsEntry(
2122
@Embedded
@@ -52,6 +53,20 @@ data class StreamStatisticsEntry(
5253
}
5354
}
5455

56+
/**
57+
* The video will be considered as finished, if the time left is less than
58+
* [PLAYBACK_FINISHED_END_MILLISECONDS] and the progress is at least 3/4 of the video length.
59+
* The state will be saved anyway, so that it can be shown under stream info items, but the
60+
* player will not resume if a state is considered as finished. Finished streams are also the
61+
* ones that can be filtered out in the feed fragment.
62+
* @return whether the stream is finished or not
63+
*/
64+
fun isFinished(): Boolean {
65+
val durationInSeconds = streamEntity.duration
66+
return progressMillis >= durationInSeconds * 1000 - PLAYBACK_FINISHED_END_MILLISECONDS &&
67+
progressMillis >= durationInSeconds * 1000 * 3 / 4
68+
}
69+
5570
companion object {
5671
const val STREAM_LATEST_DATE = "latestAccess"
5772
const val STREAM_WATCH_COUNT = "watchCount"

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ private List<StreamStatisticsEntry> processResult(final List<StreamStatisticsEnt
8383
// Filter Fully Watched
8484
if (!includeFullyWatched) {
8585
return results.stream()
86-
.filter(e -> e.getStreamEntity().getDuration() != e.getProgressMillis() / 1000)
86+
.filter(e -> !e.isFinished())
8787
.toList();
8888
}
8989

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
<LinearLayout
99
android:layout_width="match_parent"
1010
android:layout_height="wrap_content"
11+
android:baselineAligned="false"
1112
android:orientation="horizontal">
1213

1314
<RelativeLayout
@@ -66,7 +67,7 @@
6667
android:layout_height="50dp"
6768
android:layout_toEndOf="@id/fullyWatchedFilterButtonCheckBox"
6869
android:gravity="start|center_vertical"
69-
android:text="@string/title_fully_watched"
70+
android:text="@string/title_hide_watched"
7071
android:textSize="15sp"
7172
android:textStyle="bold" />
7273
</RelativeLayout>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -880,5 +880,5 @@
880880
<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>
881881
<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>
882882
<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>
883-
<string name="title_fully_watched">Fully Watched</string>
883+
<string name="title_hide_watched">Hide Watched</string>
884884
</resources>

0 commit comments

Comments
 (0)