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;
}
SponsorBlockUtils.showShieldButton(); // skipping from end to the video will show the buttons again
SponsorBlockUtils.showVoteButton();
SponsorSegment[] segments = sponsorSegmentsOfCurrentVideo;
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;
}

View File

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

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 || i.isShown() || !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 || i.isShown() || !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;
}