0
0
Fork 0
mirror of https://github.com/YTVanced/Integrations synced 2024-11-30 15:13:03 +00:00

fix SB and voting buttons overlapping YouTube icons

This commit is contained in:
caneleex 2021-04-28 22:39:23 +02:00
parent 0aa753efd1
commit c382f2a530
4 changed files with 26 additions and 18 deletions

View file

@ -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())); Log.i(TAG, String.format("onCreate called with object %s on thread %s", o.toString(), Thread.currentThread().toString()));
try { try {
setMillisecondMethod = o.getClass().getMethod("replaceMeWithsetMillisecondMethod", Long.TYPE); setMillisecondMethod = o.getClass().getMethod("t", Long.TYPE);
setMillisecondMethod.setAccessible(true); setMillisecondMethod.setAccessible(true);
lastKnownVideoTime = 0; lastKnownVideoTime = 0;
@ -198,6 +198,12 @@ public class PlayerController {
if (millis <= 0) return; if (millis <= 0) return;
//findAndSkipSegment(false); //findAndSkipSegment(false);
if (millis == currentVideoLength) {
SponsorBlockUtils.hideShieldButton();
SponsorBlockUtils.hideVoteButton();
return;
}
SponsorSegment[] segments = sponsorSegmentsOfCurrentVideo; SponsorSegment[] segments = sponsorSegmentsOfCurrentVideo;
if (segments == null || segments.length == 0) return; if (segments == null || segments.length == 0) return;
@ -274,6 +280,10 @@ public class PlayerController {
setCurrentVideoTime(millis); setCurrentVideoTime(millis);
} }
public static long getCurrentVideoLength() {
return currentVideoLength;
}
public static long getLastKnownVideoTime() { public static long getLastKnownVideoTime() {
return lastKnownVideoTime; return lastKnownVideoTime;
} }

View file

@ -14,6 +14,8 @@ import com.google.android.apps.youtube.app.YouTubeTikTokRoot_Application;
import java.lang.ref.WeakReference; import java.lang.ref.WeakReference;
import static fi.razerman.youtube.XGlobals.debug; import static fi.razerman.youtube.XGlobals.debug;
import static pl.jakubweg.PlayerController.getCurrentVideoLength;
import static pl.jakubweg.PlayerController.getLastKnownVideoTime;
public class ShieldButton { public class ShieldButton {
static String TAG = "SHIELD"; static String TAG = "SHIELD";
@ -79,6 +81,9 @@ public class ShieldButton {
if (_youtubeControlsLayout == null || iView == null) return; if (_youtubeControlsLayout == null || iView == null) return;
if (visible && shouldBeShown()) { if (visible && shouldBeShown()) {
if (getLastKnownVideoTime() == getCurrentVideoLength()) {
return;
}
if (debug) { if (debug) {
Log.d(TAG, "Fading in"); Log.d(TAG, "Fading in");
} }

View file

@ -158,10 +158,6 @@ public abstract class SponsorBlockUtils {
new Thread(submitRunnable).start(); 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 String messageToToast = "";
private static EditByHandSaveDialogListener editByHandSaveDialogListener = new EditByHandSaveDialogListener(); private static EditByHandSaveDialogListener editByHandSaveDialogListener = new EditByHandSaveDialogListener();
private static final DialogInterface.OnClickListener editByHandDialogListener = new DialogInterface.OnClickListener() { private static final DialogInterface.OnClickListener editByHandDialogListener = new DialogInterface.OnClickListener() {
@ -300,9 +296,7 @@ public abstract class SponsorBlockUtils {
} }
public static void showShieldButton() { public static void showShieldButton() {
if (isShieldShown) return; View i = ShieldButton._shieldBtn.get();
isShieldShown = true;
View i = sponsorBlockBtn.get();
if (i == null) return; if (i == null) return;
i.setVisibility(VISIBLE); i.setVisibility(VISIBLE);
i.bringToFront(); i.bringToFront();
@ -311,17 +305,13 @@ public abstract class SponsorBlockUtils {
} }
public static void hideShieldButton() { public static void hideShieldButton() {
if (!isShieldShown) return; View i = ShieldButton._shieldBtn.get();
isShieldShown = false;
View i = sponsorBlockBtn.get();
if (i != null) if (i != null)
i.setVisibility(GONE); i.setVisibility(GONE);
} }
public static void showVoteButton() { public static void showVoteButton() {
if (isVoteShown) return; View i = VotingButton._votingButton.get();
isVoteShown = true;
View i = votingBtn.get();
if (i == null) return; if (i == null) return;
i.setVisibility(VISIBLE); i.setVisibility(VISIBLE);
i.bringToFront(); i.bringToFront();
@ -330,9 +320,7 @@ public abstract class SponsorBlockUtils {
} }
public static void hideVoteButton() { public static void hideVoteButton() {
if (!isVoteShown) return; View i = VotingButton._votingButton.get();
isVoteShown = false;
View i = votingBtn.get();
if (i != null) if (i != null)
i.setVisibility(GONE); i.setVisibility(GONE);
} }
@ -445,7 +433,7 @@ public abstract class SponsorBlockUtils {
if (v.getId() != shareBtnId || !/*SponsorBlockSettings.isAddNewSegmentEnabled*/false) return; if (v.getId() != shareBtnId || !/*SponsorBlockSettings.isAddNewSegmentEnabled*/false) return;
// if (VERBOSE) // if (VERBOSE)
// Log.d(TAG, "VISIBILITY CHANGED of view " + v); // Log.d(TAG, "VISIBILITY CHANGED of view " + v);
ImageView sponsorBtn = sponsorBlockBtn.get(); ImageView sponsorBtn = ShieldButton._shieldBtn.get();
if (sponsorBtn != null) { if (sponsorBtn != null) {
sponsorBtn.setVisibility(v.getVisibility()); sponsorBtn.setVisibility(v.getVisibility());
} }

View file

@ -14,6 +14,8 @@ import com.google.android.apps.youtube.app.YouTubeTikTokRoot_Application;
import java.lang.ref.WeakReference; import java.lang.ref.WeakReference;
import static fi.razerman.youtube.XGlobals.debug; import static fi.razerman.youtube.XGlobals.debug;
import static pl.jakubweg.PlayerController.getCurrentVideoLength;
import static pl.jakubweg.PlayerController.getLastKnownVideoTime;
public class VotingButton { public class VotingButton {
static String TAG = "VOTING"; static String TAG = "VOTING";
@ -79,6 +81,9 @@ public class VotingButton {
if (_youtubeControlsLayout == null || iView == null) return; if (_youtubeControlsLayout == null || iView == null) return;
if (visible && shouldBeShown()) { if (visible && shouldBeShown()) {
if (getLastKnownVideoTime() == getCurrentVideoLength()) {
return;
}
if (debug) { if (debug) {
Log.d(TAG, "Fading in"); Log.d(TAG, "Fading in");
} }