Fixed bug: Sponsor segments drawn wrongly when video has chapters and changed orientation

This commit is contained in:
jakweg 2020-08-24 20:10:03 +02:00
parent 4a411e1c98
commit 814d7e3f86
2 changed files with 18 additions and 5 deletions

View File

@ -19,9 +19,9 @@ import java.util.TimerTask;
@SuppressLint({"LongLogTag"}) @SuppressLint({"LongLogTag"})
public class PlayerController { public class PlayerController {
public static final String TAG = "jakubweg.PlayerController"; public static final String TAG = "jakubweg.PlayerController";
public static final boolean VERBOSE = false; public static final boolean VERBOSE = true;
@SuppressWarnings("PointlessBooleanExpression") @SuppressWarnings("PointlessBooleanExpression")
public static final boolean VERBOSE_DRAW_OPTIONS = false && VERBOSE; public static final boolean VERBOSE_DRAW_OPTIONS = true && VERBOSE;
private static final Timer sponsorTimer = new Timer("sponsor-skip-timer"); private static final Timer sponsorTimer = new Timer("sponsor-skip-timer");
public static WeakReference<Activity> playerActivity = new WeakReference<>(null); public static WeakReference<Activity> playerActivity = new WeakReference<>(null);
@ -297,6 +297,18 @@ public class PlayerController {
sponsorBarLeft = left; sponsorBarLeft = left;
} }
public static void setSponsorBarRect(final Object self) {
try {
Rect rect = ((Rect) self.getClass().getField("e").get(self));
if (rect != null) {
setSponsorBarAbsoluteLeft(rect.left);
setSponsorBarAbsoluteRight(rect.right);
}
} catch (IllegalAccessException | NoSuchFieldException e) {
e.printStackTrace();
}
}
public static void setSponsorBarAbsoluteRight(final Rect rect) { public static void setSponsorBarAbsoluteRight(final Rect rect) {
setSponsorBarAbsoluteRight(rect.right); setSponsorBarAbsoluteRight(rect.right);
} }
@ -313,8 +325,8 @@ public class PlayerController {
} }
public static void setSponsorBarThickness(final float thickness) { public static void setSponsorBarThickness(final float thickness) {
if (VERBOSE_DRAW_OPTIONS) // if (VERBOSE_DRAW_OPTIONS)
Log.d(TAG, String.format("setSponsorBarThickness: thickness=%.2f", thickness)); // Log.d(TAG, String.format("setSponsorBarThickness: thickness=%.2f", thickness));
sponsorBarThickness = thickness; sponsorBarThickness = thickness;
} }

View File

@ -37,9 +37,10 @@ public class SponsorBlockSettings {
public static int adjustNewSegmentMillis = 150; public static int adjustNewSegmentMillis = 150;
public static String uuid = "<invalid>"; public static String uuid = "<invalid>";
public static File cacheDirectory; public static File cacheDirectory;
static Context context;
private static String sponsorBlockUrlCategories = "[]"; private static String sponsorBlockUrlCategories = "[]";
static Context context;
public SponsorBlockSettings(Context context) { public SponsorBlockSettings(Context context) {
SponsorBlockSettings.context = context; SponsorBlockSettings.context = context;
} }