Skip to content

feat(SponsorBlock): Add undo automatic skip button #5145

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

NomanMohammadOfficial
Copy link

@NomanMohammadOfficial NomanMohammadOfficial commented Jun 8, 2025

This PR introduces an 'undo automatic skip' feature for SponsorBlock.

Changes include:

  • Storing information about the last automatically skipped segment in SegmentPlaybackController.java.
  • Adding a new undoLastAutoSkip() method to allow seeking back to the start of the skipped segment.
  • Creating a new drawable resource (revanced_sb_undo.xml) for the undo button icon.
  • Integrating the undo button into the revanced_sb_skip_sponsor_button.xml layout.
  • Wiring up the undo button's click listener in SkipSponsorButton.java.
  • Managing the visibility of the undo button in SponsorBlockViewController.java.

@@ -99,6 +99,10 @@ public class SegmentPlaybackController {
@Nullable
private static String timeWithoutSegments;

@Nullable
private static SponsorSegment lastAutoSkippedSegment;
private static long lastAutoSkippedSegmentStartTime;
Copy link
Contributor

Choose a reason for hiding this comment

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

There's no need for a long field, when lastAutoSkippedSegment already has the start time.

@@ -545,6 +551,9 @@ private static void skipSegment(@NonNull SponsorSegment segmentToSkip, boolean u

final boolean videoIsPaused = VideoState.getCurrent() == VideoState.PAUSED;
if (!userManuallySkipped) {
lastAutoSkippedSegment = segmentToSkip;
lastAutoSkippedSegmentStartTime = segmentToSkip.start;
SponsorBlockViewController.showUndoSkipButton(); // Show undo button after auto skip
Copy link
Contributor

Choose a reason for hiding this comment

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

This functionality should be a setting, and should be default off since the only default auto skip is sponsors (which most users never want to watch, and thus an undo button is unnecessary on screen clutter).

@@ -35,6 +35,8 @@ public class SkipSponsorButton extends FrameLayout {
private static final boolean highContrast = false;
private final LinearLayout skipSponsorBtnContainer;
private final TextView skipSponsorTextView;
private final ImageView skipSponsorButtonIcon; // Existing field, but adding it here for clarity in diff
Copy link
Contributor

Choose a reason for hiding this comment

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

If the field isn't used then there's no reason to have it.

// Clear the stored segment after successful undo
lastAutoSkippedSegment = null;
lastAutoSkippedSegmentStartTime = 0;
SponsorBlockViewController.hideUndoSkipButton(); // Will implement this next
Copy link
Contributor

Choose a reason for hiding this comment

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

Where is the undo button set hidden? Does it remain on screen all the time until the next segment? This should hide itself similar to the auto hiding skip button.

@LisoUseInAIKyrios LisoUseInAIKyrios changed the base branch from main to dev June 8, 2025 14:12
android:viewportHeight="24">
<path
android:fillColor="#FFFFFF"
android:pathData="M12.5 8c-2.65 0-5.05.99-6.9 2.6L2 7v6h6l-2.91-2.91c1.17-1.17 2.71-1.9 4.41-1.9 3.31 0 6 2.69 6 6s-2.69 6-6 6c-1.66 0-3.1-.69-4.18-1.82L7.2 16.2c.75.75 1.79 1.22 2.8 1.34V19c-2.02-.22-3.8-.95-5.18-2.08L2 19v-6h6l-2.91 2.91c1.17 1.17 2.71 1.9 4.41 1.9 3.31 0 6-2.69 6-6s-2.69-6-6-6z" />
Copy link
Contributor

Choose a reason for hiding this comment

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

Add a screenshot of what this looks like in app.

@LisoUseInAIKyrios
Copy link
Contributor

@Nuckyz Nuckyz changed the title feat(sponsorblock): add undo automatic skip button feat(SponsorBlock): add undo automatic skip button Jun 8, 2025
@Nuckyz Nuckyz changed the title feat(SponsorBlock): add undo automatic skip button feat(SponsorBlock): Add undo automatic skip button Jun 8, 2025
@LisoUseInAIKyrios LisoUseInAIKyrios marked this pull request as draft June 9, 2025 22:52
@NomanMohammadOfficial NomanMohammadOfficial closed this by deleting the head repository Jun 20, 2025
@LisoUseInAIKyrios
Copy link
Contributor

@NomanMohammadOfficial remove the linked issue from this unfinished and abandoned pull request. Because you deleted the repo now only you can unlink the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat(YouTube - SponsorBlock): Undo automatic skip
2 participants