mirror of
https://github.com/revanced/revanced-integrations.git
synced 2025-01-05 17:45:49 +01:00
hopefully fix corrupted string
This commit is contained in:
parent
c6306b66d0
commit
8980480236
@ -102,7 +102,7 @@ public class ShieldButton {
|
||||
}
|
||||
|
||||
static boolean shouldBeShown() {
|
||||
return SponsorBlockSettings.isSponsorBlockEnabled && SponsorBlockSettings.isAddNewSegmentEnabled;
|
||||
return SponsorBlockUtils.isSettingEnabled(SponsorBlockSettings.isAddNewSegmentEnabled);
|
||||
}
|
||||
|
||||
//region Helpers
|
||||
|
@ -40,6 +40,8 @@ import static pl.jakubweg.PlayerController.getLastKnownVideoTime;
|
||||
import static pl.jakubweg.PlayerController.sponsorSegmentsOfCurrentVideo;
|
||||
import static pl.jakubweg.SponsorBlockPreferenceFragment.FORMATTER;
|
||||
import static pl.jakubweg.SponsorBlockPreferenceFragment.SAVED_TEMPLATE;
|
||||
import static pl.jakubweg.SponsorBlockSettings.isSponsorBlockEnabled;
|
||||
import static pl.jakubweg.SponsorBlockSettings.showTimeWithoutSegments;
|
||||
import static pl.jakubweg.SponsorBlockSettings.skippedSegments;
|
||||
import static pl.jakubweg.SponsorBlockSettings.skippedTime;
|
||||
import static pl.jakubweg.StringRef.str;
|
||||
@ -395,18 +397,22 @@ public abstract class SponsorBlockUtils {
|
||||
}
|
||||
|
||||
public static String appendTimeWithoutSegments(String totalTime) {
|
||||
if (videoHasSegments && SponsorBlockSettings.showTimeWithoutSegments && !TextUtils.isEmpty(totalTime)) {
|
||||
if (videoHasSegments && isSettingEnabled(showTimeWithoutSegments) && !TextUtils.isEmpty(totalTime)) {
|
||||
if (timeWithoutSegments.isEmpty()) {
|
||||
timeWithoutSegments = getTimeWithoutSegments(sponsorSegmentsOfCurrentVideo);
|
||||
}
|
||||
return totalTime + timeWithoutSegments;
|
||||
}
|
||||
|
||||
return totalTime;
|
||||
}
|
||||
|
||||
public static String getTimeWithoutSegments(List<SponsorSegment> sponsorSegmentsOfCurrentVideo) {
|
||||
if (!SponsorBlockSettings.isSponsorBlockEnabled || !SponsorBlockSettings.showTimeWithoutSegments || sponsorSegmentsOfCurrentVideo == null) {
|
||||
public static String getTimeWithoutSegments(SponsorSegment[] sponsorSegmentsOfCurrentVideo) {
|
||||
long currentVideoLength = PlayerController.getCurrentVideoLength();
|
||||
if (!isSettingEnabled(showTimeWithoutSegments) || sponsorSegmentsOfCurrentVideo == null || currentVideoLength == 1) {
|
||||
return "";
|
||||
}
|
||||
long timeWithoutSegments = PlayerController.getCurrentVideoLength() + 500; // YouTube:tm:
|
||||
long timeWithoutSegments = currentVideoLength + 500; // YouTube:tm:
|
||||
for (SponsorSegment segment : sponsorSegmentsOfCurrentVideo) {
|
||||
timeWithoutSegments -= segment.end - segment.start;
|
||||
}
|
||||
@ -499,6 +505,10 @@ public abstract class SponsorBlockUtils {
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isSettingEnabled(boolean setting) {
|
||||
return isSponsorBlockEnabled && setting;
|
||||
}
|
||||
|
||||
public enum VoteOption {
|
||||
UPVOTE(str("vote_upvote")),
|
||||
DOWNVOTE(str("vote_downvote")),
|
||||
|
@ -102,7 +102,7 @@ public class VotingButton {
|
||||
}
|
||||
|
||||
static boolean shouldBeShown() {
|
||||
return SponsorBlockSettings.isVotingEnabled && SponsorBlockSettings.isSponsorBlockEnabled;
|
||||
return SponsorBlockUtils.isSettingEnabled(SponsorBlockSettings.isVotingEnabled);
|
||||
}
|
||||
|
||||
//region Helpers
|
||||
|
@ -43,29 +43,25 @@ public class Requester {
|
||||
videoHasSegments = false;
|
||||
timeWithoutSegments = "";
|
||||
|
||||
switch (responseCode) {
|
||||
case 200:
|
||||
JSONArray responseArray = new JSONArray(parseJson(connection));
|
||||
int length = responseArray.length();
|
||||
for (int i = 0; i < length; i++) {
|
||||
JSONObject obj = ((JSONObject) responseArray.get(i));
|
||||
JSONArray segment = obj.getJSONArray("segment");
|
||||
long start = (long) (segment.getDouble(0) * 1000);
|
||||
long end = (long) (segment.getDouble(1) * 1000);
|
||||
String category = obj.getString("category");
|
||||
String uuid = obj.getString("UUID");
|
||||
if (responseCode == 200) {
|
||||
JSONArray responseArray = new JSONArray(parseJson(connection));
|
||||
int length = responseArray.length();
|
||||
for (int i = 0; i < length; i++) {
|
||||
JSONObject obj = ((JSONObject) responseArray.get(i));
|
||||
JSONArray segment = obj.getJSONArray("segment");
|
||||
long start = (long) (segment.getDouble(0) * 1000);
|
||||
long end = (long) (segment.getDouble(1) * 1000);
|
||||
String category = obj.getString("category");
|
||||
String uuid = obj.getString("UUID");
|
||||
|
||||
SponsorBlockSettings.SegmentInfo segmentCategory = SponsorBlockSettings.SegmentInfo.byCategoryKey(category);
|
||||
if (segmentCategory != null && segmentCategory.behaviour.showOnTimeBar) {
|
||||
SponsorSegment sponsorSegment = new SponsorSegment(start, end, segmentCategory, uuid);
|
||||
segments.add(sponsorSegment);
|
||||
}
|
||||
SponsorBlockSettings.SegmentInfo segmentCategory = SponsorBlockSettings.SegmentInfo.byCategoryKey(category);
|
||||
if (segmentCategory != null && segmentCategory.behaviour.showOnTimeBar) {
|
||||
SponsorSegment sponsorSegment = new SponsorSegment(start, end, segmentCategory, uuid);
|
||||
segments.add(sponsorSegment);
|
||||
}
|
||||
videoHasSegments = true;
|
||||
timeWithoutSegments = SponsorBlockUtils.getTimeWithoutSegments(segments);
|
||||
break;
|
||||
case 404:
|
||||
break;
|
||||
}
|
||||
videoHasSegments = true;
|
||||
timeWithoutSegments = SponsorBlockUtils.getTimeWithoutSegments(segments.toArray(new SponsorSegment[0]));
|
||||
}
|
||||
connection.disconnect();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user