fix buttons after watching Shorts

Fixes #36
This commit is contained in:
caneleex 2021-06-14 19:12:51 +02:00
parent f329ac46e5
commit 57b9c3fa3b
2 changed files with 28 additions and 0 deletions

View File

@ -0,0 +1,8 @@
package fi.razerman.youtube.Helpers;
import android.view.ViewGroup;
public class XSwipeHelper {
// Implementation in another repo
public static ViewGroup nextGenWatchLayout;
}

View File

@ -11,6 +11,8 @@ import com.google.android.apps.youtube.app.YouTubeTikTokRoot_Application;
import java.lang.ref.WeakReference;
import fi.razerman.youtube.Helpers.XSwipeHelper;
import static fi.razerman.youtube.XGlobals.debug;
public class SponsorBlockView {
@ -145,11 +147,29 @@ public class SponsorBlockView {
}
private static void bringLayoutToFront() {
checkLayout();
inlineSponsorOverlay.bringToFront();
inlineSponsorOverlay.requestLayout();
inlineSponsorOverlay.invalidate();
}
private static void checkLayout() {
if (inlineSponsorOverlay.getHeight() == 0) {
View layout = XSwipeHelper.nextGenWatchLayout.findViewById(getIdentifier("player_overlays", "id"));
if (layout != null) {
initialize(layout);
if (debug){
Log.d("XGlobals", "player_overlays refreshed for SB");
}
}
else if (debug){
Log.d("XGlobals", "player_overlays was not found for SB");
}
}
}
private static int getIdentifier(String name, String defType) {
Context context = YouTubeTikTokRoot_Application.getAppContext();
return context.getResources().getIdentifier(name, defType, context.getPackageName());