From 8d189aba5799d4a27fcd128beccc3d0d1e9e370f Mon Sep 17 00:00:00 2001 From: caneleex Date: Fri, 23 Jul 2021 17:10:56 +0200 Subject: [PATCH] add setting --- .../pl/jakubweg/SponsorBlockPreferenceFragment.java | 12 ++++++++++++ .../main/java/pl/jakubweg/SponsorBlockSettings.java | 4 +++- app/src/main/res/values/strings.xml | 2 ++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/pl/jakubweg/SponsorBlockPreferenceFragment.java b/app/src/main/java/pl/jakubweg/SponsorBlockPreferenceFragment.java index fb3f667e..879800e8 100644 --- a/app/src/main/java/pl/jakubweg/SponsorBlockPreferenceFragment.java +++ b/app/src/main/java/pl/jakubweg/SponsorBlockPreferenceFragment.java @@ -24,6 +24,7 @@ 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_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; import static pl.jakubweg.SponsorBlockSettings.PREFERENCES_KEY_SPONSOR_BLOCK_ENABLED; import static pl.jakubweg.SponsorBlockSettings.PREFERENCES_KEY_UUID; @@ -32,6 +33,7 @@ import static pl.jakubweg.SponsorBlockSettings.PREFERENCES_NAME; import static pl.jakubweg.SponsorBlockSettings.adjustNewSegmentMillis; import static pl.jakubweg.SponsorBlockSettings.countSkips; import static pl.jakubweg.SponsorBlockSettings.setSeenGuidelines; +import static pl.jakubweg.SponsorBlockSettings.showTimeWithoutSegments; import static pl.jakubweg.SponsorBlockSettings.showToastWhenSkippedAutomatically; import static pl.jakubweg.SponsorBlockSettings.uuid; import static pl.jakubweg.StringRef.str; @@ -247,6 +249,16 @@ public class SponsorBlockPreferenceFragment extends PreferenceFragment implement screen.addPreference(preference); } + { + Preference preference = new SwitchPreference(context); + preference.setTitle(str("general_ime_without_sb")); + preference.setSummary(str("general_time_without_sb_sum")); + preference.setKey(PREFERENCES_KEY_SHOW_TIME_WITHOUT_SEGMENTS); + preference.setDefaultValue(showTimeWithoutSegments); + preferencesToDisableWhenSBDisabled.add(preference); + screen.addPreference(preference); + } + { EditTextPreference preference = new EditTextPreference(context); preference.getEditText().setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_SIGNED); diff --git a/app/src/main/java/pl/jakubweg/SponsorBlockSettings.java b/app/src/main/java/pl/jakubweg/SponsorBlockSettings.java index 770b1797..f5e9a9de 100644 --- a/app/src/main/java/pl/jakubweg/SponsorBlockSettings.java +++ b/app/src/main/java/pl/jakubweg/SponsorBlockSettings.java @@ -28,7 +28,7 @@ public class SponsorBlockSettings { public static final String sponsorBlockSkipSegmentsUrl = "https://sponsor.ajay.app/api/skipSegments"; public static final String sponsorBlockViewedUrl = "https://sponsor.ajay.app/api/viewedVideoSponsorTime"; public static final String sponsorBlockVoteUrl = "https://sponsor.ajay.app/api/voteOnSponsorTime"; - + public static final String PREFERENCES_KEY_SHOW_TIME_WITHOUT_SEGMENTS = "sb-length-without-segments"; public static final SegmentBehaviour DefaultBehaviour = SegmentBehaviour.SkipAutomatically; @@ -38,6 +38,7 @@ public class SponsorBlockSettings { public static boolean isVotingEnabled = true; public static boolean showToastWhenSkippedAutomatically = true; public static boolean countSkips = true; + public static boolean showTimeWithoutSegments = true; public static int adjustNewSegmentMillis = 150; public static String uuid = ""; private static String sponsorBlockUrlCategories = "[]"; @@ -140,6 +141,7 @@ public class SponsorBlockSettings { adjustNewSegmentMillis = Integer.parseInt(tmp1); countSkips = preferences.getBoolean(PREFERENCES_KEY_COUNT_SKIPS, countSkips); + showTimeWithoutSegments = preferences.getBoolean(PREFERENCES_KEY_SHOW_TIME_WITHOUT_SEGMENTS, showTimeWithoutSegments); uuid = preferences.getString(PREFERENCES_KEY_UUID, null); if (uuid == null) { diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 7b1d5fed..d9d3991b 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -151,6 +151,8 @@ Click to see an example toast Skip count tracking 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. + Show time without segments + This time appears in brackets next to the current time. This shows the total video duration minus any segments. Adjusting new segment step This is the number of milliseconds you can move when you use the time adjustment buttons while adding new segment Your unique user id