Skip to content

Commit

Permalink
some small changes/fixes related to PR (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
polymorphicshade committed Jan 27, 2024
1 parent 2f8e863 commit 797661a
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 15 deletions.
28 changes: 18 additions & 10 deletions app/src/main/java/org/schabi/newpipe/player/Player.java
Original file line number Diff line number Diff line change
Expand Up @@ -954,16 +954,17 @@ public boolean isProgressLoopRunning() {
}

public void triggerProgressUpdate() {
triggerProgressUpdate(false, false, false);
triggerProgressUpdate(false, false, false, false);
}

public void triggerProgressUpdate(final boolean isRewind) {
triggerProgressUpdate(isRewind, false, false);
triggerProgressUpdate(isRewind, false, false, false);
}

private void triggerProgressUpdate(final boolean isRewind,
final boolean isGracedRewind,
final boolean bypassSecondaryMode) {
final boolean bypassSecondaryMode,
final boolean isUnSkip) {
if (exoPlayerIsNull()) {
return;
}
Expand All @@ -976,13 +977,14 @@ private void triggerProgressUpdate(final boolean isRewind,
simpleExoPlayer.getBufferedPercentage());

triggerCheckForSponsorBlockSegments(currentProgress, isRewind,
isGracedRewind, bypassSecondaryMode);
isGracedRewind, bypassSecondaryMode, isUnSkip);
}

private void triggerCheckForSponsorBlockSegments(final int currentProgress,
final boolean isRewind,
final boolean isGracedRewind,
final boolean bypassSecondaryMode) {
final boolean bypassSecondaryMode,
final boolean isUnSkip) {
if (sponsorBlockMode != SponsorBlockMode.ENABLED || !isPrepared) {
return;
}
Expand Down Expand Up @@ -1056,8 +1058,14 @@ private void triggerCheckForSponsorBlockSegments(final int currentProgress,
simpleExoPlayer.setSeekParameters(seekParams);
lastSegment = sponsorBlockSegment;

if (prefs.getBoolean(
context.getString(R.string.sponsor_block_notifications_key), false)) {
if (isUnSkip) {
return;
}

final boolean canShowNotifications = prefs.getBoolean(
context.getString(R.string.sponsor_block_notifications_key), false);

if (canShowNotifications) {
final String toastText =
SponsorBlockHelper.convertCategoryToSkipMessage(
context, sponsorBlockSegment.category);
Expand Down Expand Up @@ -1355,12 +1363,12 @@ public void toggleShuffleModeEnabled() {
}

public void toggleUnskip() {
triggerProgressUpdate(true, true, true);
triggerProgressUpdate(true, true, true, true);
}

public void toggleSkip() {
autoSkipGracePeriod = false;
triggerProgressUpdate(false, true, true);
triggerProgressUpdate(false, true, true, false);
}
//endregion

Expand Down Expand Up @@ -1869,7 +1877,7 @@ public void fastRewind() {
seekBy(-retrieveSeekDurationFromPreferences(this));
if (prefs.getBoolean(
context.getString(R.string.sponsor_block_graced_rewind_key), false)) {
triggerProgressUpdate(true, true, false);
triggerProgressUpdate(true, true, false, false);
return;
}

Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/layout/player.xml
Original file line number Diff line number Diff line change
Expand Up @@ -760,6 +760,7 @@

<RelativeLayout
android:id="@+id/unskipButton"
android:visibility="gone"
android:clickable="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/values/settings_keys.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1506,8 +1506,8 @@
<string name="sponsor_block_category_pending_key" translatable="false">sponsor_block_category_pending_key</string>
<string name="sponsor_block_category_pending_color_key" translatable="false">sponsor_block_category_pending_color_key</string>
<string name="sponsor_block_clear_whitelist_key" translatable="false">sponsor_block_clear_whitelist</string>
<string name="sponsor_block_graced_rewind_key" translatable="false">sponsor_block_skip</string>
<string name="sponsor_block_show_manual_skip_key" translatable="false">sponsor_block_skip</string>
<string name="sponsor_block_graced_rewind_key" translatable="false">sponsor_block_graced_rewind</string>
<string name="sponsor_block_show_manual_skip_key" translatable="false">sponsor_block_show_manual_skip</string>

<string-array name="sponsor_block_category_sponsor_modes_key">
<item>@string/sponsor_block_skip_mode_enabled</item>
Expand Down
6 changes: 3 additions & 3 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -934,11 +934,11 @@
<string name="sponsor_block_skip_mode_manual">Manual</string>
<string name="sponsor_block_skip_mode_highlight">Highlight Only</string>
<string name="sponsor_block_graced_rewind_title">Rewind pauses skipping</string>
<string name="sponsor_block_graced_rewind_summary">Rewinding the video back into automatically skipped segments will pause segment skipping until the segment ends.</string>
<string name="sponsor_block_graced_rewind_summary">Rewinding the video back to automatically-skipped segments will pause skipping until the segment ends.</string>
<string name="sponsor_block_manual_unskip_button">Un-skip</string>
<string name="sponsor_block_manual_skip_button">Skip</string>
<string name="sponsor_block_show_manual_skip_title">Shows Manual Buttons.</string>
<string name="sponsor_block_show_manual_skip_summary">Shows buttons on-screen to manually skip/unskip segments. It is recommended to enable this when configuring SponsorBlock Categories to use Manual Skipping.</string>
<string name="sponsor_block_show_manual_skip_title">Show manual buttons</string>
<string name="sponsor_block_show_manual_skip_summary">Show buttons on-screen to manually skip/unskip segments. Enabling this is recommended when configuring SponsorBlock Categories to be skipped manually.</string>
<!-- ReturnYouTubeDislike -->
<string name="return_youtube_dislike_home_page_title">View Website</string>
<string name="return_youtube_dislike_home_page_summary">View the official ReturnYouTubeDislike website.</string>
Expand Down

0 comments on commit 797661a

Please sign in to comment.