mirror of
https://github.com/revanced/revanced-integrations.git
synced 2024-11-11 06:29:29 +01:00
fix SB and voting buttons overlapping YouTube icons
This commit is contained in:
parent
ce87d8ac0e
commit
ad7bdf0fb8
@ -95,7 +95,7 @@ public class PlayerController {
|
||||
Log.i(TAG, String.format("onCreate called with object %s on thread %s", o.toString(), Thread.currentThread().toString()));
|
||||
|
||||
try {
|
||||
setMillisecondMethod = o.getClass().getMethod("replaceMeWithsetMillisecondMethod", Long.TYPE);
|
||||
setMillisecondMethod = o.getClass().getMethod("t", Long.TYPE);
|
||||
setMillisecondMethod.setAccessible(true);
|
||||
|
||||
lastKnownVideoTime = 0;
|
||||
@ -198,6 +198,12 @@ public class PlayerController {
|
||||
if (millis <= 0) return;
|
||||
//findAndSkipSegment(false);
|
||||
|
||||
if (millis == currentVideoLength) {
|
||||
SponsorBlockUtils.hideShieldButton();
|
||||
SponsorBlockUtils.hideVoteButton();
|
||||
return;
|
||||
}
|
||||
|
||||
SponsorSegment[] segments = sponsorSegmentsOfCurrentVideo;
|
||||
if (segments == null || segments.length == 0) return;
|
||||
|
||||
@ -274,6 +280,10 @@ public class PlayerController {
|
||||
setCurrentVideoTime(millis);
|
||||
}
|
||||
|
||||
public static long getCurrentVideoLength() {
|
||||
return currentVideoLength;
|
||||
}
|
||||
|
||||
public static long getLastKnownVideoTime() {
|
||||
return lastKnownVideoTime;
|
||||
}
|
||||
|
@ -14,6 +14,8 @@ import com.google.android.apps.youtube.app.YouTubeTikTokRoot_Application;
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
import static fi.razerman.youtube.XGlobals.debug;
|
||||
import static pl.jakubweg.PlayerController.getCurrentVideoLength;
|
||||
import static pl.jakubweg.PlayerController.getLastKnownVideoTime;
|
||||
|
||||
public class ShieldButton {
|
||||
static String TAG = "SHIELD";
|
||||
@ -79,6 +81,9 @@ public class ShieldButton {
|
||||
if (_youtubeControlsLayout == null || iView == null) return;
|
||||
|
||||
if (visible && shouldBeShown()) {
|
||||
if (getLastKnownVideoTime() == getCurrentVideoLength()) {
|
||||
return;
|
||||
}
|
||||
if (debug) {
|
||||
Log.d(TAG, "Fading in");
|
||||
}
|
||||
|
@ -158,10 +158,6 @@ public abstract class SponsorBlockUtils {
|
||||
new Thread(submitRunnable).start();
|
||||
}
|
||||
};
|
||||
private static boolean isShieldShown = false;
|
||||
private static boolean isVoteShown = false;
|
||||
private static WeakReference<ImageView> sponsorBlockBtn = new WeakReference<>(null);
|
||||
private static WeakReference<ImageView> votingBtn = new WeakReference<>(null);
|
||||
private static String messageToToast = "";
|
||||
private static EditByHandSaveDialogListener editByHandSaveDialogListener = new EditByHandSaveDialogListener();
|
||||
private static final DialogInterface.OnClickListener editByHandDialogListener = new DialogInterface.OnClickListener() {
|
||||
@ -300,9 +296,7 @@ public abstract class SponsorBlockUtils {
|
||||
}
|
||||
|
||||
public static void showShieldButton() {
|
||||
if (isShieldShown) return;
|
||||
isShieldShown = true;
|
||||
View i = sponsorBlockBtn.get();
|
||||
View i = ShieldButton._shieldBtn.get();
|
||||
if (i == null) return;
|
||||
i.setVisibility(VISIBLE);
|
||||
i.bringToFront();
|
||||
@ -311,17 +305,13 @@ public abstract class SponsorBlockUtils {
|
||||
}
|
||||
|
||||
public static void hideShieldButton() {
|
||||
if (!isShieldShown) return;
|
||||
isShieldShown = false;
|
||||
View i = sponsorBlockBtn.get();
|
||||
View i = ShieldButton._shieldBtn.get();
|
||||
if (i != null)
|
||||
i.setVisibility(GONE);
|
||||
}
|
||||
|
||||
public static void showVoteButton() {
|
||||
if (isVoteShown) return;
|
||||
isVoteShown = true;
|
||||
View i = votingBtn.get();
|
||||
View i = VotingButton._votingButton.get();
|
||||
if (i == null) return;
|
||||
i.setVisibility(VISIBLE);
|
||||
i.bringToFront();
|
||||
@ -330,9 +320,7 @@ public abstract class SponsorBlockUtils {
|
||||
}
|
||||
|
||||
public static void hideVoteButton() {
|
||||
if (!isVoteShown) return;
|
||||
isVoteShown = false;
|
||||
View i = votingBtn.get();
|
||||
View i = VotingButton._votingButton.get();
|
||||
if (i != null)
|
||||
i.setVisibility(GONE);
|
||||
}
|
||||
@ -445,7 +433,7 @@ public abstract class SponsorBlockUtils {
|
||||
if (v.getId() != shareBtnId || !/*SponsorBlockSettings.isAddNewSegmentEnabled*/false) return;
|
||||
// if (VERBOSE)
|
||||
// Log.d(TAG, "VISIBILITY CHANGED of view " + v);
|
||||
ImageView sponsorBtn = sponsorBlockBtn.get();
|
||||
ImageView sponsorBtn = ShieldButton._shieldBtn.get();
|
||||
if (sponsorBtn != null) {
|
||||
sponsorBtn.setVisibility(v.getVisibility());
|
||||
}
|
||||
|
@ -14,6 +14,8 @@ import com.google.android.apps.youtube.app.YouTubeTikTokRoot_Application;
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
import static fi.razerman.youtube.XGlobals.debug;
|
||||
import static pl.jakubweg.PlayerController.getCurrentVideoLength;
|
||||
import static pl.jakubweg.PlayerController.getLastKnownVideoTime;
|
||||
|
||||
public class VotingButton {
|
||||
static String TAG = "VOTING";
|
||||
@ -79,6 +81,9 @@ public class VotingButton {
|
||||
if (_youtubeControlsLayout == null || iView == null) return;
|
||||
|
||||
if (visible && shouldBeShown()) {
|
||||
if (getLastKnownVideoTime() == getCurrentVideoLength()) {
|
||||
return;
|
||||
}
|
||||
if (debug) {
|
||||
Log.d(TAG, "Fading in");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user