mirror of
https://github.com/revanced/revanced-integrations.git
synced 2024-12-03 17:22:54 +01:00
refactor: remove reduntant check for shorts_playing
(#150)
This commit is contained in:
parent
04bbe259cb
commit
73b40595c4
@ -108,7 +108,6 @@ public enum SettingsEnum {
|
||||
SB_SHOW_BROWSER_BUTTON("sb-browser-button", false, SharedPrefHelper.SharedPrefNames.SPONSOR_BLOCK, ReturnType.BOOLEAN),
|
||||
SB_API_URL("sb-api-url", "https://sponsor.ajay.app/api/", SharedPrefHelper.SharedPrefNames.SPONSOR_BLOCK, ReturnType.STRING);
|
||||
|
||||
public static boolean shorts_playing = false;
|
||||
private final String path;
|
||||
private final Object defaultValue;
|
||||
private final SharedPrefHelper.SharedPrefNames sharedPref;
|
||||
|
@ -49,6 +49,8 @@ public class PlayerController {
|
||||
private static float sponsorBarThickness = 2f;
|
||||
private static TimerTask skipSponsorTask = null;
|
||||
|
||||
public static boolean shorts_playing = false;
|
||||
|
||||
public static String getCurrentVideoId() {
|
||||
return currentVideoId;
|
||||
}
|
||||
@ -87,9 +89,6 @@ public class PlayerController {
|
||||
* Called when creating some kind of youtube internal player controlled, every time when new video starts to play
|
||||
*/
|
||||
public static void onCreate(final Object o) {
|
||||
if (SettingsEnum.shorts_playing) return;
|
||||
|
||||
// "Plugin.printStackTrace();
|
||||
|
||||
if (o == null) {
|
||||
LogHelper.printException(PlayerController.class, "onCreate called with null object");
|
||||
@ -117,8 +116,9 @@ public class PlayerController {
|
||||
public static void executeDownloadSegments(String videoId) {
|
||||
videoHasSegments = false;
|
||||
timeWithoutSegments = "";
|
||||
if (Whitelist.isChannelSBWhitelisted())
|
||||
if (Whitelist.isChannelSBWhitelisted() || shorts_playing) {
|
||||
return;
|
||||
}
|
||||
SponsorSegment[] segments = SBRequester.getSegments(videoId);
|
||||
Arrays.sort(segments);
|
||||
|
||||
@ -134,8 +134,6 @@ public class PlayerController {
|
||||
* Called when it's time to update the UI with new second, about once per second, only when playing, also in background
|
||||
*/
|
||||
public static void setCurrentVideoTime(long millis) {
|
||||
if (SettingsEnum.shorts_playing) return;
|
||||
|
||||
LogHelper.debug(PlayerController.class, "setCurrentVideoTime: current video time: " + millis);
|
||||
VideoInformation.lastKnownVideoTime = millis;
|
||||
if (!SettingsEnum.SB_ENABLED.getBoolean()) return;
|
||||
@ -220,8 +218,6 @@ 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 (SettingsEnum.shorts_playing) return;
|
||||
|
||||
if ((millis < lastKnownVideoTime && lastKnownVideoTime >= currentVideoLength) || millis == 0) {
|
||||
SponsorBlockUtils.showShieldButton(); // skipping from end to the video will show the buttons again
|
||||
SponsorBlockUtils.showVoteButton();
|
||||
@ -245,16 +241,12 @@ public class PlayerController {
|
||||
* Called before onDraw method on time bar object, sets video length in millis
|
||||
*/
|
||||
public static void setVideoLength(final long length) {
|
||||
if (SettingsEnum.shorts_playing) return;
|
||||
|
||||
LogHelper.debug(PlayerController.class, "setVideoLength: length=" + length);
|
||||
currentVideoLength = length;
|
||||
}
|
||||
|
||||
|
||||
public static void setSponsorBarAbsoluteLeft(final Rect rect) {
|
||||
if (SettingsEnum.shorts_playing) return;
|
||||
|
||||
setSponsorBarAbsoluteLeft(rect.left);
|
||||
}
|
||||
|
||||
@ -265,8 +257,6 @@ public class PlayerController {
|
||||
}
|
||||
|
||||
public static void setSponsorBarRect(final Object self) {
|
||||
if (SettingsEnum.shorts_playing || self == null) return;
|
||||
|
||||
try {
|
||||
Field field = self.getClass().getDeclaredField("replaceMeWithsetSponsorBarRect");
|
||||
field.setAccessible(true);
|
||||
@ -281,8 +271,6 @@ public class PlayerController {
|
||||
}
|
||||
|
||||
public static void setSponsorBarAbsoluteRight(final Rect rect) {
|
||||
if (SettingsEnum.shorts_playing) return;
|
||||
|
||||
setSponsorBarAbsoluteRight(rect.right);
|
||||
}
|
||||
|
||||
@ -293,8 +281,6 @@ public class PlayerController {
|
||||
}
|
||||
|
||||
public static void setSponsorBarThickness(final int thickness) {
|
||||
if (SettingsEnum.shorts_playing) return;
|
||||
|
||||
setSponsorBarThickness((float) thickness);
|
||||
}
|
||||
|
||||
@ -312,8 +298,6 @@ public class PlayerController {
|
||||
|
||||
|
||||
public static void addSkipSponsorView15(final View view) {
|
||||
if (SettingsEnum.shorts_playing) return;
|
||||
|
||||
playerActivity = new WeakReference<>((Activity) view.getContext());
|
||||
LogHelper.debug(PlayerController.class, "addSkipSponsorView15: view=" + view.toString());
|
||||
|
||||
@ -339,8 +323,6 @@ public class PlayerController {
|
||||
* Called when it's time to draw time bar
|
||||
*/
|
||||
public static void drawSponsorTimeBars(final Canvas canvas, final float posY) {
|
||||
if (SettingsEnum.shorts_playing) return;
|
||||
|
||||
if (sponsorBarThickness < 0.1) return;
|
||||
if (sponsorSegmentsOfCurrentVideo == null) return;
|
||||
|
||||
|
@ -28,8 +28,6 @@ public class ShieldButton {
|
||||
static boolean isShowing;
|
||||
|
||||
public static void initialize(Object viewStub) {
|
||||
if (SettingsEnum.shorts_playing) return;
|
||||
|
||||
try {
|
||||
LogHelper.debug(ShieldButton.class, "initializing shield button");
|
||||
|
||||
@ -64,14 +62,10 @@ public class ShieldButton {
|
||||
}
|
||||
|
||||
public static void changeVisibilityNegatedImmediate(boolean visible) {
|
||||
if (SettingsEnum.shorts_playing) return;
|
||||
|
||||
changeVisibility(!visible, true);
|
||||
}
|
||||
|
||||
public static void changeVisibility(boolean visible) {
|
||||
if (SettingsEnum.shorts_playing) return;
|
||||
|
||||
changeVisibility(visible, false);
|
||||
}
|
||||
|
||||
|
@ -403,8 +403,6 @@ public abstract class SponsorBlockUtils {
|
||||
}
|
||||
|
||||
public static String appendTimeWithoutSegments(String totalTime) {
|
||||
if (SettingsEnum.shorts_playing) return totalTime;
|
||||
|
||||
if (videoHasSegments && (SettingsEnum.SB_ENABLED.getBoolean() && SettingsEnum.SB_SHOW_TIME_WITHOUT_SEGMENTS.getBoolean()) && !TextUtils.isEmpty(totalTime) && getCurrentVideoLength() > 1) {
|
||||
if (timeWithoutSegments.isEmpty()) {
|
||||
timeWithoutSegments = getTimeWithoutSegments(sponsorSegmentsOfCurrentVideo);
|
||||
|
@ -27,8 +27,6 @@ public class VotingButton {
|
||||
static boolean isShowing;
|
||||
|
||||
public static void initialize(Object viewStub) {
|
||||
if (SettingsEnum.shorts_playing) return;
|
||||
|
||||
try {
|
||||
LogHelper.debug(VotingButton.class, "initializing voting button");
|
||||
_youtubeControlsLayout = (RelativeLayout) viewStub;
|
||||
@ -62,14 +60,10 @@ public class VotingButton {
|
||||
}
|
||||
|
||||
public static void changeVisibilityNegatedImmediate(boolean visible) {
|
||||
if (SettingsEnum.shorts_playing) return;
|
||||
|
||||
changeVisibility(!visible, true);
|
||||
}
|
||||
|
||||
public static void changeVisibility(boolean visible) {
|
||||
if (SettingsEnum.shorts_playing) return;
|
||||
|
||||
changeVisibility(visible, false);
|
||||
}
|
||||
|
||||
|
@ -23,8 +23,6 @@ public class SponsorBlockView {
|
||||
static boolean shouldShowOnPlayerType = true;
|
||||
|
||||
public static void initialize(Object viewGroup) {
|
||||
if (SettingsEnum.shorts_playing) return;
|
||||
|
||||
try {
|
||||
LogHelper.debug(SponsorBlockView.class, "initializing");
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
package app.revanced.integrations.videoplayer;
|
||||
|
||||
import app.revanced.integrations.settings.SettingsEnum;
|
||||
import app.revanced.integrations.utils.LogHelper;
|
||||
|
||||
public class VideoInformation {
|
||||
@ -15,8 +14,6 @@ public class VideoInformation {
|
||||
|
||||
// Call hook in the YT code when the video changes
|
||||
public static void setCurrentVideoId(final String videoId) {
|
||||
if (SettingsEnum.shorts_playing) return;
|
||||
|
||||
if (videoId == null) {
|
||||
LogHelper.debug(VideoInformation.class, "setCurrentVideoId - new id was null - currentVideoId was" + currentVideoId);
|
||||
clearInformation(true);
|
||||
|
Loading…
Reference in New Issue
Block a user