fix a lot of unintended button behaviors

This commit is contained in:
caneleex 2021-04-29 15:03:23 +02:00
parent ac46231f24
commit f57c5e1ee0
5 changed files with 13 additions and 12 deletions

View File

@ -204,6 +204,9 @@ public class PlayerController {
return; return;
} }
SponsorBlockUtils.showShieldButton(); // skipping from end to the video will show the buttons again
SponsorBlockUtils.showVoteButton();
SponsorSegment[] segments = sponsorSegmentsOfCurrentVideo; SponsorSegment[] segments = sponsorSegmentsOfCurrentVideo;
if (segments == null || segments.length == 0) return; if (segments == null || segments.length == 0) return;

View File

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

View File

@ -83,25 +83,23 @@ public class SponsorBlockSettings {
if (!isSponsorBlockEnabled) { if (!isSponsorBlockEnabled) {
SkipSegmentView.hide(); SkipSegmentView.hide();
NewSegmentHelperLayout.hide(); NewSegmentHelperLayout.hide();
SponsorBlockUtils.hideShieldButton(); ShieldButton.changeVisibilityImmediate(false);
VotingButton.changeVisibilityImmediate(false);
PlayerController.sponsorSegmentsOfCurrentVideo = null; PlayerController.sponsorSegmentsOfCurrentVideo = null;
} else if (/*isAddNewSegmentEnabled*/false) { } else if (/*isAddNewSegmentEnabled*/false) {
SponsorBlockUtils.showShieldButton(); SponsorBlockUtils.showShieldButton();
} }
isAddNewSegmentEnabled = preferences.getBoolean(PREFERENCES_KEY_NEW_SEGMENT_ENABLED, isAddNewSegmentEnabled); isAddNewSegmentEnabled = preferences.getBoolean(PREFERENCES_KEY_NEW_SEGMENT_ENABLED, isAddNewSegmentEnabled);
if (!/*isAddNewSegmentEnabled*/false) { if (!isAddNewSegmentEnabled) {
NewSegmentHelperLayout.hide(); NewSegmentHelperLayout.hide();
SponsorBlockUtils.hideShieldButton(); ShieldButton.changeVisibilityImmediate(false);
} else { } else {
SponsorBlockUtils.showShieldButton(); ShieldButton.changeVisibilityImmediate(true);
} }
isVotingEnabled = preferences.getBoolean(PREFERENCES_KEY_VOTING_ENABLED, isVotingEnabled); isVotingEnabled = preferences.getBoolean(PREFERENCES_KEY_VOTING_ENABLED, isVotingEnabled);
if (!isVotingEnabled) VotingButton.changeVisibilityImmediate(isVotingEnabled);
SponsorBlockUtils.hideVoteButton();
else
SponsorBlockUtils.showVoteButton();
SegmentBehaviour[] possibleBehaviours = SegmentBehaviour.values(); SegmentBehaviour[] possibleBehaviours = SegmentBehaviour.values();
final ArrayList<String> enabledCategories = new ArrayList<>(possibleBehaviours.length); final ArrayList<String> enabledCategories = new ArrayList<>(possibleBehaviours.length);

View File

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

View File

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