Merge pull request #31 from caneleex/patch/buttons-behavior

fix a lot of unintended button behaviors
This commit is contained in:
KevinX8 2021-04-29 22:24:48 +01:00 committed by GitHub
commit 740b33e6aa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 10 additions and 5 deletions

View File

@ -272,6 +272,10 @@ public class PlayerController {
* Called very high frequency (once every about 100ms), also in background. It sometimes triggers when a video is paused (couple times in the row with the same value)
*/
public static void setCurrentVideoTimeHighPrecision(final long millis) {
if ((millis < lastKnownVideoTime && lastKnownVideoTime >= currentVideoLength) || millis == 0) {
SponsorBlockUtils.showShieldButton(); // skipping from end to the video will show the buttons again
SponsorBlockUtils.showVoteButton();
}
if (lastKnownVideoTime > 0) {
lastKnownVideoTime = millis;
VideoInformation.lastKnownVideoTime = lastKnownVideoTime;

View File

@ -103,7 +103,7 @@ public class ShieldButton {
}
}
private static boolean shouldBeShown() {
static boolean shouldBeShown() {
return SponsorBlockSettings.isSponsorBlockEnabled && SponsorBlockSettings.isAddNewSegmentEnabled;
}

View File

@ -84,13 +84,14 @@ public class SponsorBlockSettings {
SkipSegmentView.hide();
NewSegmentHelperLayout.hide();
SponsorBlockUtils.hideShieldButton();
SponsorBlockUtils.hideVoteButton();
PlayerController.sponsorSegmentsOfCurrentVideo = null;
} else if (/*isAddNewSegmentEnabled*/false) {
SponsorBlockUtils.showShieldButton();
}
isAddNewSegmentEnabled = preferences.getBoolean(PREFERENCES_KEY_NEW_SEGMENT_ENABLED, isAddNewSegmentEnabled);
if (!/*isAddNewSegmentEnabled*/false) {
if (!isAddNewSegmentEnabled) {
NewSegmentHelperLayout.hide();
SponsorBlockUtils.hideShieldButton();
} else {

View File

@ -296,7 +296,7 @@ public abstract class SponsorBlockUtils {
public static void showShieldButton() {
View i = ShieldButton._shieldBtn.get();
if (i == null) return;
if (i == null || !ShieldButton.shouldBeShown()) return;
i.setVisibility(VISIBLE);
i.bringToFront();
i.requestLayout();
@ -311,7 +311,7 @@ public abstract class SponsorBlockUtils {
public static void showVoteButton() {
View i = VotingButton._votingButton.get();
if (i == null) return;
if (i == null || !VotingButton.shouldBeShown()) return;
i.setVisibility(VISIBLE);
i.bringToFront();
i.requestLayout();

View File

@ -103,7 +103,7 @@ public class VotingButton {
}
}
private static boolean shouldBeShown() {
static boolean shouldBeShown() {
return SponsorBlockSettings.isVotingEnabled && SponsorBlockSettings.isSponsorBlockEnabled;
}