1
mirror of https://github.com/revanced/revanced-integrations synced 2024-11-16 22:50:31 +01:00

Merge pull request #30 from caneleex/patch/buttons

fix SB and voting buttons overlapping YouTube icons
This commit is contained in:
KevinX8 2021-04-28 21:51:30 +01:00 committed by GitHub
commit 974c2733a8
4 changed files with 25 additions and 17 deletions

View File

@ -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;
}

View File

@ -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");
}

View File

@ -157,10 +157,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() {
@ -299,9 +295,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();
@ -310,17 +304,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();
@ -329,9 +319,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);
}
@ -450,7 +438,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());
}

View File

@ -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");
}