mirror of
https://github.com/revanced/revanced-integrations.git
synced 2025-01-07 10:35: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() {
|
static boolean shouldBeShown() {
|
||||||
return SponsorBlockSettings.isSponsorBlockEnabled && SponsorBlockSettings.isAddNewSegmentEnabled;
|
return SponsorBlockUtils.isSettingEnabled(SponsorBlockSettings.isAddNewSegmentEnabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
//region Helpers
|
//region Helpers
|
||||||
|
@ -40,6 +40,8 @@ import static pl.jakubweg.PlayerController.getLastKnownVideoTime;
|
|||||||
import static pl.jakubweg.PlayerController.sponsorSegmentsOfCurrentVideo;
|
import static pl.jakubweg.PlayerController.sponsorSegmentsOfCurrentVideo;
|
||||||
import static pl.jakubweg.SponsorBlockPreferenceFragment.FORMATTER;
|
import static pl.jakubweg.SponsorBlockPreferenceFragment.FORMATTER;
|
||||||
import static pl.jakubweg.SponsorBlockPreferenceFragment.SAVED_TEMPLATE;
|
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.skippedSegments;
|
||||||
import static pl.jakubweg.SponsorBlockSettings.skippedTime;
|
import static pl.jakubweg.SponsorBlockSettings.skippedTime;
|
||||||
import static pl.jakubweg.StringRef.str;
|
import static pl.jakubweg.StringRef.str;
|
||||||
@ -395,18 +397,22 @@ public abstract class SponsorBlockUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static String appendTimeWithoutSegments(String totalTime) {
|
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 + timeWithoutSegments;
|
||||||
}
|
}
|
||||||
|
|
||||||
return totalTime;
|
return totalTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getTimeWithoutSegments(List<SponsorSegment> sponsorSegmentsOfCurrentVideo) {
|
public static String getTimeWithoutSegments(SponsorSegment[] sponsorSegmentsOfCurrentVideo) {
|
||||||
if (!SponsorBlockSettings.isSponsorBlockEnabled || !SponsorBlockSettings.showTimeWithoutSegments || sponsorSegmentsOfCurrentVideo == null) {
|
long currentVideoLength = PlayerController.getCurrentVideoLength();
|
||||||
|
if (!isSettingEnabled(showTimeWithoutSegments) || sponsorSegmentsOfCurrentVideo == null || currentVideoLength == 1) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
long timeWithoutSegments = PlayerController.getCurrentVideoLength() + 500; // YouTube:tm:
|
long timeWithoutSegments = currentVideoLength + 500; // YouTube:tm:
|
||||||
for (SponsorSegment segment : sponsorSegmentsOfCurrentVideo) {
|
for (SponsorSegment segment : sponsorSegmentsOfCurrentVideo) {
|
||||||
timeWithoutSegments -= segment.end - segment.start;
|
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 {
|
public enum VoteOption {
|
||||||
UPVOTE(str("vote_upvote")),
|
UPVOTE(str("vote_upvote")),
|
||||||
DOWNVOTE(str("vote_downvote")),
|
DOWNVOTE(str("vote_downvote")),
|
||||||
|
@ -102,7 +102,7 @@ public class VotingButton {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static boolean shouldBeShown() {
|
static boolean shouldBeShown() {
|
||||||
return SponsorBlockSettings.isVotingEnabled && SponsorBlockSettings.isSponsorBlockEnabled;
|
return SponsorBlockUtils.isSettingEnabled(SponsorBlockSettings.isVotingEnabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
//region Helpers
|
//region Helpers
|
||||||
|
@ -43,29 +43,25 @@ public class Requester {
|
|||||||
videoHasSegments = false;
|
videoHasSegments = false;
|
||||||
timeWithoutSegments = "";
|
timeWithoutSegments = "";
|
||||||
|
|
||||||
switch (responseCode) {
|
if (responseCode == 200) {
|
||||||
case 200:
|
JSONArray responseArray = new JSONArray(parseJson(connection));
|
||||||
JSONArray responseArray = new JSONArray(parseJson(connection));
|
int length = responseArray.length();
|
||||||
int length = responseArray.length();
|
for (int i = 0; i < length; i++) {
|
||||||
for (int i = 0; i < length; i++) {
|
JSONObject obj = ((JSONObject) responseArray.get(i));
|
||||||
JSONObject obj = ((JSONObject) responseArray.get(i));
|
JSONArray segment = obj.getJSONArray("segment");
|
||||||
JSONArray segment = obj.getJSONArray("segment");
|
long start = (long) (segment.getDouble(0) * 1000);
|
||||||
long start = (long) (segment.getDouble(0) * 1000);
|
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");
|
|
||||||
|
|
||||||
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);
|
||||||
segments.add(sponsorSegment);
|
segments.add(sponsorSegment);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
videoHasSegments = true;
|
}
|
||||||
timeWithoutSegments = SponsorBlockUtils.getTimeWithoutSegments(segments);
|
videoHasSegments = true;
|
||||||
break;
|
timeWithoutSegments = SponsorBlockUtils.getTimeWithoutSegments(segments.toArray(new SponsorSegment[0]));
|
||||||
case 404:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
connection.disconnect();
|
connection.disconnect();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user