mirror of
https://github.com/revanced/revanced-patches
synced 2025-02-13 04:36:49 +01:00
add min duration option
This commit is contained in:
parent
7bbd97ee40
commit
da0ef6b098
@ -3,6 +3,7 @@ package pl.jakubweg;
|
||||
import static pl.jakubweg.SponsorBlockSettings.DefaultBehaviour;
|
||||
import static pl.jakubweg.SponsorBlockSettings.PREFERENCES_KEY_ADJUST_NEW_SEGMENT_STEP;
|
||||
import static pl.jakubweg.SponsorBlockSettings.PREFERENCES_KEY_COUNT_SKIPS;
|
||||
import static pl.jakubweg.SponsorBlockSettings.PREFERENCES_KEY_MIN_DURATION;
|
||||
import static pl.jakubweg.SponsorBlockSettings.PREFERENCES_KEY_NEW_SEGMENT_ENABLED;
|
||||
import static pl.jakubweg.SponsorBlockSettings.PREFERENCES_KEY_SHOW_TIME_WITHOUT_SEGMENTS;
|
||||
import static pl.jakubweg.SponsorBlockSettings.PREFERENCES_KEY_SHOW_TOAST_WHEN_SKIP;
|
||||
@ -12,6 +13,7 @@ import static pl.jakubweg.SponsorBlockSettings.PREFERENCES_KEY_VOTING_ENABLED;
|
||||
import static pl.jakubweg.SponsorBlockSettings.PREFERENCES_NAME;
|
||||
import static pl.jakubweg.SponsorBlockSettings.adjustNewSegmentMillis;
|
||||
import static pl.jakubweg.SponsorBlockSettings.countSkips;
|
||||
import static pl.jakubweg.SponsorBlockSettings.minDuration;
|
||||
import static pl.jakubweg.SponsorBlockSettings.setSeenGuidelines;
|
||||
import static pl.jakubweg.SponsorBlockSettings.showTimeWithoutSegments;
|
||||
import static pl.jakubweg.SponsorBlockSettings.showToastWhenSkippedAutomatically;
|
||||
@ -290,7 +292,7 @@ public class SponsorBlockPreferenceFragment extends PreferenceFragment implement
|
||||
|
||||
{
|
||||
EditTextPreference preference = new EditTextPreference(context);
|
||||
preference.getEditText().setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_SIGNED);
|
||||
preference.getEditText().setInputType(InputType.TYPE_CLASS_NUMBER);
|
||||
preference.setTitle(str("general_adjusting"));
|
||||
preference.setSummary(str("general_adjusting_sum"));
|
||||
preference.setKey(PREFERENCES_KEY_ADJUST_NEW_SEGMENT_STEP);
|
||||
@ -299,6 +301,17 @@ public class SponsorBlockPreferenceFragment extends PreferenceFragment implement
|
||||
preferencesToDisableWhenSBDisabled.add(preference);
|
||||
}
|
||||
|
||||
{
|
||||
EditTextPreference preference = new EditTextPreference(context);
|
||||
preference.getEditText().setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL);
|
||||
preference.setTitle(str("general_min_duration"));
|
||||
preference.setSummary(str("general_min_duration_sum"));
|
||||
preference.setKey(PREFERENCES_KEY_MIN_DURATION);
|
||||
preference.setDefaultValue(String.valueOf(minDuration));
|
||||
screen.addPreference(preference);
|
||||
preferencesToDisableWhenSBDisabled.add(preference);
|
||||
}
|
||||
|
||||
{
|
||||
Preference preference = new EditTextPreference(context);
|
||||
preference.setTitle(str("general_uuid"));
|
||||
|
@ -22,6 +22,7 @@ public class SponsorBlockSettings {
|
||||
public static final String PREFERENCES_KEY_COUNT_SKIPS = "count-skips";
|
||||
public static final String PREFERENCES_KEY_UUID = "uuid";
|
||||
public static final String PREFERENCES_KEY_ADJUST_NEW_SEGMENT_STEP = "new-segment-step-accuracy";
|
||||
public static final String PREFERENCES_KEY_MIN_DURATION = "sb-min-duration";
|
||||
public static final String PREFERENCES_KEY_SPONSOR_BLOCK_ENABLED = "sb-enabled";
|
||||
public static final String PREFERENCES_KEY_SEEN_GUIDELINES = "sb-seen-gl";
|
||||
public static final String PREFERENCES_KEY_NEW_SEGMENT_ENABLED = "sb-new-segment-enabled";
|
||||
@ -41,6 +42,7 @@ public class SponsorBlockSettings {
|
||||
public static boolean countSkips = true;
|
||||
public static boolean showTimeWithoutSegments = true;
|
||||
public static int adjustNewSegmentMillis = 150;
|
||||
public static float minDuration = 0f;
|
||||
public static String uuid = "<invalid>";
|
||||
public static String sponsorBlockUrlCategories = "[]";
|
||||
public static int skippedSegments;
|
||||
@ -132,6 +134,10 @@ public class SponsorBlockSettings {
|
||||
if (tmp1 != null)
|
||||
adjustNewSegmentMillis = Integer.parseInt(tmp1);
|
||||
|
||||
String minTmp = preferences.getString(PREFERENCES_KEY_MIN_DURATION, null);
|
||||
if (minTmp != null)
|
||||
minDuration = Float.parseFloat(minTmp);
|
||||
|
||||
countSkips = preferences.getBoolean(PREFERENCES_KEY_COUNT_SKIPS, countSkips);
|
||||
showTimeWithoutSegments = preferences.getBoolean(PREFERENCES_KEY_SHOW_TIME_WITHOUT_SEGMENTS, showTimeWithoutSegments);
|
||||
|
||||
|
@ -12,12 +12,14 @@ import static pl.jakubweg.SponsorBlockPreferenceFragment.FORMATTER;
|
||||
import static pl.jakubweg.SponsorBlockPreferenceFragment.SAVED_TEMPLATE;
|
||||
import static pl.jakubweg.SponsorBlockSettings.PREFERENCES_KEY_CATEGORY_COLOR_SUFFIX;
|
||||
import static pl.jakubweg.SponsorBlockSettings.PREFERENCES_KEY_COUNT_SKIPS;
|
||||
import static pl.jakubweg.SponsorBlockSettings.PREFERENCES_KEY_MIN_DURATION;
|
||||
import static pl.jakubweg.SponsorBlockSettings.PREFERENCES_KEY_SHOW_TIME_WITHOUT_SEGMENTS;
|
||||
import static pl.jakubweg.SponsorBlockSettings.PREFERENCES_KEY_SHOW_TOAST_WHEN_SKIP;
|
||||
import static pl.jakubweg.SponsorBlockSettings.PREFERENCES_KEY_UUID;
|
||||
import static pl.jakubweg.SponsorBlockSettings.countSkips;
|
||||
import static pl.jakubweg.SponsorBlockSettings.getPreferences;
|
||||
import static pl.jakubweg.SponsorBlockSettings.isSponsorBlockEnabled;
|
||||
import static pl.jakubweg.SponsorBlockSettings.minDuration;
|
||||
import static pl.jakubweg.SponsorBlockSettings.showTimeWithoutSegments;
|
||||
import static pl.jakubweg.SponsorBlockSettings.showToastWhenSkippedAutomatically;
|
||||
import static pl.jakubweg.SponsorBlockSettings.skippedSegments;
|
||||
@ -588,6 +590,7 @@ public abstract class SponsorBlockUtils {
|
||||
editor.putBoolean(PREFERENCES_KEY_SHOW_TOAST_WHEN_SKIP, !settingsJson.getBoolean("dontShowNotice"));
|
||||
editor.putBoolean(PREFERENCES_KEY_SHOW_TIME_WITHOUT_SEGMENTS, settingsJson.getBoolean("showTimeWithSkips"));
|
||||
editor.putBoolean(PREFERENCES_KEY_COUNT_SKIPS, settingsJson.getBoolean("trackViewCount"));
|
||||
editor.putString(PREFERENCES_KEY_MIN_DURATION, settingsJson.getString("minDuration"));
|
||||
editor.putString(PREFERENCES_KEY_UUID, settingsJson.getString("userID"));
|
||||
editor.apply();
|
||||
|
||||
@ -624,6 +627,7 @@ public abstract class SponsorBlockUtils {
|
||||
json.put("dontShowNotice", !showToastWhenSkippedAutomatically);
|
||||
json.put("barTypes", barTypesObject);
|
||||
json.put("showTimeWithSkips", showTimeWithoutSegments);
|
||||
json.put("minDuration", minDuration);
|
||||
json.put("trackViewCount", countSkips);
|
||||
json.put("categorySelections", categorySelectionsArray);
|
||||
json.put("userID", uuid);
|
||||
|
@ -49,6 +49,11 @@ public class SBRequester {
|
||||
JSONArray segment = obj.getJSONArray("segment");
|
||||
long start = (long) (segment.getDouble(0) * 1000);
|
||||
long end = (long) (segment.getDouble(1) * 1000);
|
||||
|
||||
long minDuration = (long) (SponsorBlockSettings.minDuration * 1000);
|
||||
if ((end - start) < minDuration)
|
||||
continue;
|
||||
|
||||
String category = obj.getString("category");
|
||||
String uuid = obj.getString("UUID");
|
||||
|
||||
@ -58,8 +63,10 @@ public class SBRequester {
|
||||
segments.add(sponsorSegment);
|
||||
}
|
||||
}
|
||||
videoHasSegments = true;
|
||||
timeWithoutSegments = SponsorBlockUtils.getTimeWithoutSegments(segments.toArray(new SponsorSegment[0]));
|
||||
if (!segments.isEmpty()) {
|
||||
videoHasSegments = true;
|
||||
timeWithoutSegments = SponsorBlockUtils.getTimeWithoutSegments(segments.toArray(new SponsorSegment[0]));
|
||||
}
|
||||
}
|
||||
connection.disconnect();
|
||||
}
|
||||
|
@ -151,6 +151,8 @@
|
||||
<string name="general_skipcount_sum">This lets SponsorBlock leaderboard system know how much time people have saved. The extension sends a message to the server each time you skip a segment</string>
|
||||
<string name="general_adjusting">Adjusting new segment step</string>
|
||||
<string name="general_adjusting_sum">This is the number of milliseconds you can move when you use the time adjustment buttons while adding new segment</string>
|
||||
<string name="general_min_duration">Minimum segment duration</string>
|
||||
<string name="general_min_duration_sum">Segments shorter than the set value (in seconds) will not be skipped or show in the player</string>
|
||||
<string name="general_uuid">Your unique user id</string>
|
||||
<string name="general_uuid_sum">This should be kept private. This is like a password and should not be shared with anyone. If someone has this, they can impersonate you</string>
|
||||
<string name="settings_ie">Import/Export settings</string>
|
||||
|
Loading…
x
Reference in New Issue
Block a user