mirror of
https://github.com/revanced/revanced-integrations.git
synced 2025-01-08 11:05:49 +01:00
highlight locked segments in the vote menu
This commit is contained in:
parent
739d58d5ae
commit
27c6fa88ab
@ -72,6 +72,7 @@ public abstract class SponsorBlockUtils {
|
|||||||
public static boolean videoHasSegments = false;
|
public static boolean videoHasSegments = false;
|
||||||
public static String timeWithoutSegments = "";
|
public static String timeWithoutSegments = "";
|
||||||
private static final int sponsorBtnId = 1234;
|
private static final int sponsorBtnId = 1234;
|
||||||
|
private static final String LOCKED_COLOR = "#FFC83D";
|
||||||
public static final View.OnClickListener sponsorBlockBtnListener = v -> {
|
public static final View.OnClickListener sponsorBlockBtnListener = v -> {
|
||||||
if (debug) {
|
if (debug) {
|
||||||
Log.d(TAG, "Shield button clicked");
|
Log.d(TAG, "Shield button clicked");
|
||||||
@ -212,10 +213,17 @@ public abstract class SponsorBlockUtils {
|
|||||||
final SponsorSegment segment = sponsorSegmentsOfCurrentVideo[which];
|
final SponsorSegment segment = sponsorSegmentsOfCurrentVideo[which];
|
||||||
|
|
||||||
final VoteOption[] voteOptions = VoteOption.values();
|
final VoteOption[] voteOptions = VoteOption.values();
|
||||||
String[] items = new String[voteOptions.length];
|
CharSequence[] items = new CharSequence[voteOptions.length];
|
||||||
|
|
||||||
for (int i = 0; i < voteOptions.length; i++) {
|
for (int i = 0; i < voteOptions.length; i++) {
|
||||||
items[i] = voteOptions[i].title;
|
VoteOption voteOption = voteOptions[i];
|
||||||
|
String title = voteOption.title;
|
||||||
|
if (segment.isLocked && voteOption.shouldHighlight) {
|
||||||
|
items[i] = Html.fromHtml(String.format("<font color=\"%s\">%s</font>", LOCKED_COLOR, title));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
items[i] = title;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
new AlertDialog.Builder(context)
|
new AlertDialog.Builder(context)
|
||||||
@ -416,7 +424,7 @@ public abstract class SponsorBlockUtils {
|
|||||||
final SponsorSegment[] segments = original == null ? new SponsorSegment[1] : Arrays.copyOf(original, original.length + 1);
|
final SponsorSegment[] segments = original == null ? new SponsorSegment[1] : Arrays.copyOf(original, original.length + 1);
|
||||||
|
|
||||||
segments[segments.length - 1] = new SponsorSegment(newSponsorSegmentStartMillis, newSponsorSegmentEndMillis,
|
segments[segments.length - 1] = new SponsorSegment(newSponsorSegmentStartMillis, newSponsorSegmentEndMillis,
|
||||||
SponsorBlockSettings.SegmentInfo.UNSUBMITTED, null);
|
SponsorBlockSettings.SegmentInfo.UNSUBMITTED, null, false);
|
||||||
|
|
||||||
Arrays.sort(segments);
|
Arrays.sort(segments);
|
||||||
sponsorSegmentsOfCurrentVideo = segments;
|
sponsorSegmentsOfCurrentVideo = segments;
|
||||||
@ -651,14 +659,17 @@ public abstract class SponsorBlockUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public enum VoteOption {
|
public enum VoteOption {
|
||||||
UPVOTE(str("vote_upvote")),
|
UPVOTE(str("vote_upvote"), false),
|
||||||
DOWNVOTE(str("vote_downvote")),
|
DOWNVOTE(str("vote_downvote"), true),
|
||||||
CATEGORY_CHANGE(str("vote_category"));
|
CATEGORY_CHANGE(str("vote_category"), true);
|
||||||
|
|
||||||
public final String title;
|
public final String title;
|
||||||
|
public final boolean shouldHighlight;
|
||||||
|
|
||||||
VoteOption(String title) {
|
|
||||||
|
VoteOption(String title, boolean shouldHighlight) {
|
||||||
this.title = title;
|
this.title = title;
|
||||||
|
this.shouldHighlight = shouldHighlight;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,12 +7,14 @@ public class SponsorSegment implements Comparable<SponsorSegment> {
|
|||||||
public final long end;
|
public final long end;
|
||||||
public final SponsorBlockSettings.SegmentInfo category;
|
public final SponsorBlockSettings.SegmentInfo category;
|
||||||
public final String UUID;
|
public final String UUID;
|
||||||
|
public final boolean isLocked;
|
||||||
|
|
||||||
public SponsorSegment(long start, long end, SponsorBlockSettings.SegmentInfo category, String UUID) {
|
public SponsorSegment(long start, long end, SponsorBlockSettings.SegmentInfo category, String UUID, boolean isLocked) {
|
||||||
this.start = start;
|
this.start = start;
|
||||||
this.end = end;
|
this.end = end;
|
||||||
this.category = category;
|
this.category = category;
|
||||||
this.UUID = UUID;
|
this.UUID = UUID;
|
||||||
|
this.isLocked = isLocked;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -21,6 +23,7 @@ public class SponsorSegment implements Comparable<SponsorSegment> {
|
|||||||
"start=" + start +
|
"start=" + start +
|
||||||
", end=" + end +
|
", end=" + end +
|
||||||
", category='" + category + '\'' +
|
", category='" + category + '\'' +
|
||||||
|
", locked=" + isLocked +
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,10 +54,11 @@ public class Requester {
|
|||||||
long end = (long) (segment.getDouble(1) * 1000);
|
long end = (long) (segment.getDouble(1) * 1000);
|
||||||
String category = obj.getString("category");
|
String category = obj.getString("category");
|
||||||
String uuid = obj.getString("UUID");
|
String uuid = obj.getString("UUID");
|
||||||
|
boolean locked = obj.getInt("locked") == 1;
|
||||||
|
|
||||||
SponsorBlockSettings.SegmentInfo segmentCategory = SponsorBlockSettings.SegmentInfo.byCategoryKey(category);
|
SponsorBlockSettings.SegmentInfo segmentCategory = SponsorBlockSettings.SegmentInfo.byCategoryKey(category);
|
||||||
if (segmentCategory != null && segmentCategory.behaviour.showOnTimeBar) {
|
if (segmentCategory != null && segmentCategory.behaviour.showOnTimeBar) {
|
||||||
SponsorSegment sponsorSegment = new SponsorSegment(start, end, segmentCategory, uuid);
|
SponsorSegment sponsorSegment = new SponsorSegment(start, end, segmentCategory, uuid, locked);
|
||||||
segments.add(sponsorSegment);
|
segments.add(sponsorSegment);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user