From 0476299570d9a9ee099a0187e0a081dc0364ba6f Mon Sep 17 00:00:00 2001 From: Joey Peter Date: Tue, 5 Jul 2022 22:31:13 +0200 Subject: [PATCH] refactor: move settings to SettingsEnum (#49) --- .../integrations/adremover/AdRemoverAPI.java | 101 +----------- .../adremover/LithoAdRemoval.java | 143 +++++------------ .../patches/FensterSwipePatch.java | 12 +- .../patches/HideCreateButtonPatch.java | 11 +- .../patches/HideShortsButtonPatch.java | 10 +- .../integrations/ryd/RYDSettings.java | 7 - .../integrations/ryd/Registration.java | 32 +--- .../ryd/ReturnYouTubeDislikes.java | 12 +- .../app/revanced/integrations/ryd/Voting.java | 7 +- .../integrations/ryd/dialog/Dialogs.java | 22 +-- .../integrations/settings/SettingsEnum.java | 151 +++++++++++++----- .../settingsmenu/RYDSettingsFragment.java | 11 +- .../ReVancedSettingsFragment.java | 36 +---- .../SponsorBlockSettingsFragment.java | 86 ++++------ .../sponsorblock/PlayerController.java | 17 +- .../sponsorblock/ShieldButton.java | 4 +- .../sponsorblock/SponsorBlockSettings.java | 84 ++-------- .../sponsorblock/SponsorBlockUtils.java | 90 ++++------- .../sponsorblock/VotingButton.java | 3 +- .../sponsorblock/dialog/Dialogs.java | 19 +-- .../objects/EditTextListPreference.java | 2 +- .../player/ui/NewSegmentLayout.java | 5 +- .../player/ui/SBBrowserButton.java | 3 +- .../player/ui/SlimButtonContainer.java | 14 +- .../sponsorblock/requests/SBRequester.java | 26 ++- .../integrations/utils/LogHelper.java | 8 +- .../integrations/utils/ReVancedUtils.java | 31 ++-- .../videosettings/VideoQuality.java | 6 +- .../videoplayer/videosettings/VideoSpeed.java | 19 +-- app/src/main/res/values/strings.xml | 24 ++- app/src/main/res/xml/revanced_prefs.xml | 92 +++++------ 31 files changed, 407 insertions(+), 681 deletions(-) delete mode 100644 app/src/main/java/app/revanced/integrations/ryd/RYDSettings.java diff --git a/app/src/main/java/app/revanced/integrations/adremover/AdRemoverAPI.java b/app/src/main/java/app/revanced/integrations/adremover/AdRemoverAPI.java index 8a2812df..619f0ed3 100644 --- a/app/src/main/java/app/revanced/integrations/adremover/AdRemoverAPI.java +++ b/app/src/main/java/app/revanced/integrations/adremover/AdRemoverAPI.java @@ -12,9 +12,6 @@ import app.revanced.integrations.patches.HideShortsButtonPatch; import app.revanced.integrations.settings.SettingsEnum; import app.revanced.integrations.utils.LogHelper; -/** - * API Class that provides the logic to the Patch classes. All methods in here should be protected/private and only be accessed from a Patch class. - */ public class AdRemoverAPI { /** @@ -22,6 +19,7 @@ public class AdRemoverAPI { * * @param view */ + //ToDo: refactor this public static void HideViewWithLayout1dp(View view) { if (view instanceof LinearLayout) { LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(1, 1); @@ -43,101 +41,4 @@ public class AdRemoverAPI { } } - /** - * Removes the Create button - * - * @param view - */ - public static void hideCreateButton(View view) { - String message = SettingsEnum.CREATE_BUTTON_SHOWN_BOOLEAN.getBoolean() ? "Create button: Shown" : "Create button: Hidden"; - LogHelper.debug(AdRemoverAPI.class, message); - if (SettingsEnum.CREATE_BUTTON_SHOWN_BOOLEAN.getBoolean()) { - view.setVisibility(View.VISIBLE); - } else { - view.setVisibility(View.GONE); - } - } - - /** - * Removes the shorts button - * - * @param view - */ - public static void hideShortsButton(View view) { - if (HideShortsButtonPatch.lastPivotTab != null && HideShortsButtonPatch.lastPivotTab.name() == "TAB_SHORTS") { - String message = SettingsEnum.SHORTS_BUTTON_SHOWN_BOOLEAN.getBoolean() ? "Shorts button: shown" : "Shorts button: hidden"; - LogHelper.debug(AdRemoverAPI.class, message); - if (!SettingsEnum.SHORTS_BUTTON_SHOWN_BOOLEAN.getBoolean()) { - view.setVisibility(View.GONE); - } - } - } - - /* - private static void inspectComponentHost(Object item) { - StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace(); - if (stackTraceElements.length <= 3) { - LogHelper.debug("Litho", "Couldn't locate the method called from."); - } else { - String sb = "Called from method: " + - stackTraceElements[3].toString() + "\n"; - LogHelper.debug("Litho", sb); - } - if (item == null) { - LogHelper.debug("Litho", "Item is null."); - } else if (item.getClass().getSimpleName().contains("cwl")) { - LogHelper.debug("Litho", "Item is a cwl item."); - LogHelper.debug("Litho", getViewHierarchy((ViewGroup) item)); - } else { - LogHelper.debug("Litho", "Item is not a cwl item."); - } - } - - private static String getViewHierarchy(ViewGroup v) { - StringBuffer buf = new StringBuffer(); - printViews(v, buf, 0); - return buf.toString(); - } - - private static String printViews(ViewGroup v, StringBuffer buf, int level) { - int childCount = v.getChildCount(); - v.getId(); - indent(buf, level); - buf.append(v.getClass().getName()); - buf.append(" children:"); - buf.append(childCount); - buf.append(" id:").append(v.getId()); - buf.append("\n"); - for (int i = 0; i < childCount; i++) { - View child = v.getChildAt(i); - if (child instanceof ViewGroup) { - printViews((ViewGroup) child, buf, level + 1); - } else { - indent(buf, level + 1); - buf.append(child.getClass().getName()); - buf.append(" id:").append(child.getId()); - buf.append("\n"); - } - } - return buf.toString(); - } - - private static void indent(StringBuffer buf, int level) { - for (int i = 0; i < level; i++) { - buf.append(" "); - } - } - - private static void recursiveLoopChildren(ViewGroup parent) { - for (int i = 0; i < parent.getChildCount(); i++) { - View child = parent.getChildAt(i); - if (child instanceof ViewGroup) { - recursiveLoopChildren((ViewGroup) child); - child.setVisibility(View.GONE); - } else if (child != null) { - child.setVisibility(View.GONE); - } - } - }*/ - } diff --git a/app/src/main/java/app/revanced/integrations/adremover/LithoAdRemoval.java b/app/src/main/java/app/revanced/integrations/adremover/LithoAdRemoval.java index 9a8a3652..8fac55b8 100644 --- a/app/src/main/java/app/revanced/integrations/adremover/LithoAdRemoval.java +++ b/app/src/main/java/app/revanced/integrations/adremover/LithoAdRemoval.java @@ -16,87 +16,25 @@ import app.revanced.integrations.utils.ReVancedUtils; import app.revanced.integrations.utils.SharedPrefHelper; public class LithoAdRemoval { - private static boolean getBoolean(String key, boolean _default) { - return SharedPrefHelper.getBoolean(Objects.requireNonNull(ReVancedUtils.getContext()), SharedPrefHelper.SharedPrefNames.YOUTUBE, key, _default); - } - - private static boolean isCommunityGuidelines() { - return getBoolean("experimental_community_guidelines", true); - } - - private static boolean isExperimentalAdRemoval() { - return getBoolean("experimental_ad_removal", true); - } - - private static boolean isExperimentalCommentsRemoval() { - return getBoolean("experimental_comments", false); - } - - private static boolean isExperimentalCommunityPostRemoval() { - return getBoolean("experimental_community_posts", false); - } - - private static boolean isExperimentalCompactBannerRemoval() { - return getBoolean("experimental_compact_banner", false); - } - - private static boolean isExperimentalEmergencyBoxRemoval() { - return getBoolean("experimental_emergency_box", true); - } - - private static boolean isExperimentalInfoPanelRemoval() { - return getBoolean("experimental_info_panel", true); - } - - private static boolean isExperimentalMedicalPanelRemoval() { - return getBoolean("experimental_medical_panel", true); - } - - private static boolean isExperimentalMerchandiseRemoval() { - return getBoolean("experimental_merchandise", true); - } - - private static boolean isExperimentalMovieRemoval() { - return getBoolean("experimental_movie", true); - } - - private static boolean isExperimentalPaidContentRemoval() { - return getBoolean("experimental_paid_content", true); - } - - private static boolean isExperimentalSuggestedForYou() { - return getBoolean("experimental_suggested_for_you", true); - } - - private static boolean isInFeedSurvey() { - return getBoolean("experimental_in_feed_survey", false); - } - - private static boolean isShortsShelf() { - return getBoolean("experimental_shorts_shelf", true); - } @RequiresApi(api = Build.VERSION_CODES.N) public static boolean containsAd(String value, ByteBuffer buffer) { - try { - if (!(isExperimentalAdRemoval() || - isExperimentalMerchandiseRemoval() || - isExperimentalPaidContentRemoval() || isExperimentalCommunityPostRemoval() || - isExperimentalMovieRemoval() || - isExperimentalCompactBannerRemoval() || - isExperimentalCommentsRemoval() || - isInFeedSurvey() || - isShortsShelf() || - isCommunityGuidelines()) || - value == null || - value.isEmpty() - ) { - return false; + boolean enabled = false; + for (SettingsEnum setting : SettingsEnum.getAdRemovalSettings()) { + if (setting.getBoolean()) { + enabled = true; + break; } + } + + try { + if (value == null || value.isEmpty() || !enabled) return false; + LogHelper.printException(LithoAdRemoval.class, "Searching for AD: " + value); + List blockList = new ArrayList<>(); List bufferBlockList = new ArrayList<>(); - if (isExperimentalAdRemoval()) { + if (SettingsEnum.ADREMOVER_AD_REMOVAL_BOOLEAN.getBoolean()) { blockList.add("_ad"); blockList.add("ad_badge"); blockList.add("ads_video_with_context"); @@ -105,58 +43,65 @@ public class LithoAdRemoval { blockList.add("shelf_header"); blockList.add("text_search_ad_with_description_first"); blockList.add("watch_metadata_app_promo"); - + bufferBlockList.add("ad_cpn"); } - if (isExperimentalSuggestedForYou()) { + if (SettingsEnum.ADREMOVER_SUGGESTED_FOR_YOU_REMOVAL_BOOLEAN.getBoolean()) { bufferBlockList.add("watch-vrecH"); } - if (isExperimentalMovieRemoval()) { + if (SettingsEnum.ADREMOVER_MOVIE_REMOVAL_BOOLEAN.getBoolean()) { blockList.add("compact_movie"); blockList.add("horizontal_movie_shelf"); blockList.add("movie_and_show_upsell_card"); - + bufferBlockList.add("YouTube Movies"); } if (containsAny(value, "home_video_with_context", "related_video_with_context") && - bufferBlockList.stream().anyMatch(StandardCharsets.UTF_8.decode(buffer).toString()::contains) + bufferBlockList.stream().anyMatch(StandardCharsets.UTF_8.decode(buffer).toString()::contains) ) return true; - if (isExperimentalCommentsRemoval()) { + if (SettingsEnum.ADREMOVER_COMMENTS_REMOVAL_BOOLEAN.getBoolean()) { blockList.add("comments_composite_entry_point"); } - if (isCommunityGuidelines()) { + if (SettingsEnum.ADREMOVER_COMMUNITY_GUIDELINES_BOOLEAN.getBoolean()) { blockList.add("community_guidelines"); } - if (isExperimentalCompactBannerRemoval()) { + if (SettingsEnum.ADREMOVER_COMPACT_BANNER_REMOVAL_BOOLEAN.getBoolean()) { blockList.add("compact_banner"); } - if (isExperimentalEmergencyBoxRemoval()) { + if (SettingsEnum.ADREMOVER_EMERGENCY_BOX_REMOVAL_BOOLEAN.getBoolean()) { blockList.add("emergency_onebox"); } - if (isInFeedSurvey()) { + if (SettingsEnum.ADREMOVER_FEED_SURVEY_REMOVAL_BOOLEAN.getBoolean()) { blockList.add("in_feed_survey"); } - if (isExperimentalMedicalPanelRemoval()) { + if (SettingsEnum.ADREMOVER_MEDICAL_PANEL_REMOVAL_BOOLEAN.getBoolean()) { blockList.add("medical_panel"); } - if (isExperimentalPaidContentRemoval()) { + if (SettingsEnum.ADREMOVER_PAID_CONTECT_REMOVAL_BOOLEAN.getBoolean()) { blockList.add("paid_content_overlay"); } - if (isExperimentalCommunityPostRemoval()) { + if (SettingsEnum.ADREMOVER_COMMUNITY_POSTS_REMOVAL_BOOLEAN.getBoolean()) { blockList.add("post_base_wrapper"); } - if (isExperimentalMerchandiseRemoval()) { + if (SettingsEnum.ADREMOVER_MERCHANDISE_REMOVAL_BOOLEAN.getBoolean()) { blockList.add("product_carousel"); } - if (isShortsShelf()) { + if (SettingsEnum.ADREMOVER_SHORTS_SHELF_BOOLEAN.getBoolean()) { blockList.add("shorts_shelf"); } - if (isExperimentalInfoPanelRemoval()) { + if (SettingsEnum.ADREMOVER_INFO_PANEL_REMOVAL_BOOLEAN.getBoolean()) { blockList.add("publisher_transparency_panel"); blockList.add("single_item_information_panel"); } - + if (SettingsEnum.ADREMOVER_HIDE_SUGGESTIONS_BOOLEAN.getBoolean()) { + blockList.add("horizontal_video_shelf"); + } + if (SettingsEnum.ADREMOVER_HIDE_LATEST_POSTS_BOOLEAN.getBoolean()) { + blockList.add("post_shelf"); + } + + if (containsAny(value, "home_video_with_context", "related_video_with_context", @@ -169,19 +114,19 @@ public class LithoAdRemoval { )) return false; if (blockList.stream().anyMatch(value::contains)) { - LogHelper.debug(LithoAdRemoval.class, value); + LogHelper.debug(LithoAdRemoval.class, "Blocking ad: " + value); return true; } - if (!SettingsEnum.DEBUG_BOOLEAN.getBoolean()) return false; - if (value.contains("related_video_with_context")) { - LogHelper.debug(LithoAdRemoval.class, value + " | " + bytesToHex(buffer.array())); - return false; + if (SettingsEnum.DEBUG_BOOLEAN.getBoolean()) { + if (value.contains("related_video_with_context")) { + LogHelper.debug(LithoAdRemoval.class, value + " | " + bytesToHex(buffer.array())); + return false; + } + LogHelper.debug(LithoAdRemoval.class, value + " returns false."); } - LogHelper.debug(LithoAdRemoval.class, value); return false; - } catch ( - Exception ex) { + } catch (Exception ex) { LogHelper.printException(LithoAdRemoval.class, ex.getMessage(), ex); return false; } diff --git a/app/src/main/java/app/revanced/integrations/patches/FensterSwipePatch.java b/app/src/main/java/app/revanced/integrations/patches/FensterSwipePatch.java index 1d22d57a..431496f0 100644 --- a/app/src/main/java/app/revanced/integrations/patches/FensterSwipePatch.java +++ b/app/src/main/java/app/revanced/integrations/patches/FensterSwipePatch.java @@ -5,8 +5,6 @@ import android.app.Activity; import android.view.MotionEvent; import android.view.ViewGroup; -import androidx.annotation.Nullable; - import app.revanced.integrations.fenster.WatchWhilePlayerType; import app.revanced.integrations.fenster.controllers.FensterController; import app.revanced.integrations.utils.LogHelper; @@ -32,7 +30,7 @@ public final class FensterSwipePatch { * @param thisRef reference to the WatchWhileActivity instance * @smali Lapp/revanced/integrations/patches/FensterSwipePatch;->WatchWhileActivity_onStartHookEX(Ljava/lang/Object;)V */ - public static void WatchWhileActivity_onStartHookEX(@Nullable Object thisRef) { + public static void WatchWhileActivity_onStartHookEX(Object thisRef) { if (thisRef == null) return; if (thisRef instanceof Activity) { FENSTER.initializeController((Activity) thisRef); @@ -45,7 +43,7 @@ public final class FensterSwipePatch { * @param thisRef reference to the PlayerOverlays instance * @smali Lapp/revanced/integrations/patches/FensterSwipePatch;->YouTubePlayerOverlaysLayout_onFinishInflateHookEX(Ljava/lang/Object;)V */ - public static void YouTubePlayerOverlaysLayout_onFinishInflateHookEX(@Nullable Object thisRef) { + public static void YouTubePlayerOverlaysLayout_onFinishInflateHookEX(Object thisRef) { if (thisRef == null) return; if (thisRef instanceof ViewGroup) { FENSTER.initializeOverlay((ViewGroup) thisRef); @@ -58,7 +56,7 @@ public final class FensterSwipePatch { * @param type the new player type * @smali Lapp/revanced/integrations/patches/FensterSwipePatch;->YouTubePlayerOverlaysLayout_updatePlayerTypeHookEX(Ljava/lang/Object;)V */ - public static void YouTubePlayerOverlaysLayout_updatePlayerTypeHookEX(@Nullable Object type) { + public static void YouTubePlayerOverlaysLayout_updatePlayerTypeHookEX(Object type) { if (type == null) return; // disable processing events if not watching fullscreen video @@ -75,7 +73,7 @@ public final class FensterSwipePatch { * @return was the event consumed by the hook? * @smali Lapp/revanced/integrations/patches/FensterSwipePatch;->NextGenWatchLayout_onTouchEventHookEX(Ljava/lang/Object;Ljava/lang/Object;)Z */ - public static boolean NextGenWatchLayout_onTouchEventHookEX(@Nullable Object thisRef, @Nullable Object motionEvent) { + public static boolean NextGenWatchLayout_onTouchEventHookEX(Object thisRef, Object motionEvent) { if (motionEvent == null) return false; if (motionEvent instanceof MotionEvent) { return FENSTER.onTouchEvent((MotionEvent) motionEvent); @@ -92,7 +90,7 @@ public final class FensterSwipePatch { * @return was the event consumed by the hook? * @smali Lapp/revanced/integrations/patches/FensterSwipePatch;->NextGenWatchLayout_onInterceptTouchEventHookEX(Ljava/lang/Object;Ljava/lang/Object;)Z */ - public static boolean NextGenWatchLayout_onInterceptTouchEventHookEX(@Nullable Object thisRef, @Nullable Object motionEvent) { + public static boolean NextGenWatchLayout_onInterceptTouchEventHookEX(Object thisRef, Object motionEvent) { if (motionEvent == null) return false; if (motionEvent instanceof MotionEvent) { return FENSTER.onTouchEvent((MotionEvent) motionEvent); diff --git a/app/src/main/java/app/revanced/integrations/patches/HideCreateButtonPatch.java b/app/src/main/java/app/revanced/integrations/patches/HideCreateButtonPatch.java index 9cf438f8..999178c9 100644 --- a/app/src/main/java/app/revanced/integrations/patches/HideCreateButtonPatch.java +++ b/app/src/main/java/app/revanced/integrations/patches/HideCreateButtonPatch.java @@ -3,12 +3,19 @@ package app.revanced.integrations.patches; import android.view.View; import app.revanced.integrations.adremover.AdRemoverAPI; +import app.revanced.integrations.settings.SettingsEnum; +import app.revanced.integrations.utils.LogHelper; public class HideCreateButtonPatch { - //Todo: Switch BooleanPreferences to Settings class //Used by app.revanced.patches.youtube.layout.createbutton.patch.CreateButtonRemoverPatch public static void hideCreateButton(View view) { - AdRemoverAPI.hideCreateButton(view); + String message = SettingsEnum.CREATE_BUTTON_SHOWN_BOOLEAN.getBoolean() ? "Create button: Shown" : "Create button: Hidden"; + LogHelper.debug(HideCreateButtonPatch.class, message); + if (SettingsEnum.CREATE_BUTTON_SHOWN_BOOLEAN.getBoolean()) { + view.setVisibility(View.VISIBLE); + } else { + view.setVisibility(View.GONE); + } } } diff --git a/app/src/main/java/app/revanced/integrations/patches/HideShortsButtonPatch.java b/app/src/main/java/app/revanced/integrations/patches/HideShortsButtonPatch.java index c91723bb..573cc647 100644 --- a/app/src/main/java/app/revanced/integrations/patches/HideShortsButtonPatch.java +++ b/app/src/main/java/app/revanced/integrations/patches/HideShortsButtonPatch.java @@ -4,13 +4,21 @@ package app.revanced.integrations.patches; import android.view.View; import app.revanced.integrations.adremover.AdRemoverAPI; +import app.revanced.integrations.settings.SettingsEnum; +import app.revanced.integrations.utils.LogHelper; public class HideShortsButtonPatch { //Todo: Switch BooleanPreferences to Settings class //Used by app.revanced.patches.youtube.layout.shorts.button.patch.ShortsButtonRemoverPatch public static void hideShortsButton(View view) { - AdRemoverAPI.hideShortsButton(view); + if (lastPivotTab != null && lastPivotTab.name() == "TAB_SHORTS") { + String message = SettingsEnum.SHORTS_BUTTON_SHOWN_BOOLEAN.getBoolean() ? "Shorts button: shown" : "Shorts button: hidden"; + LogHelper.debug(HideShortsButtonPatch.class, message); + if (!SettingsEnum.SHORTS_BUTTON_SHOWN_BOOLEAN.getBoolean()) { + view.setVisibility(View.GONE); + } + } } //Needed for the ShortsButtonRemoverPatch diff --git a/app/src/main/java/app/revanced/integrations/ryd/RYDSettings.java b/app/src/main/java/app/revanced/integrations/ryd/RYDSettings.java deleted file mode 100644 index cc6a1e7f..00000000 --- a/app/src/main/java/app/revanced/integrations/ryd/RYDSettings.java +++ /dev/null @@ -1,7 +0,0 @@ -package app.revanced.integrations.ryd; - -public class RYDSettings { - public static final String PREFERENCES_KEY_USERID = "userId"; - public static final String PREFERENCES_KEY_RYD_ENABLED = "ryd-enabled"; - public static final String PREFERENCES_KEY_RYD_HINT_SHOWN = "ryd_hint_shown"; -} diff --git a/app/src/main/java/app/revanced/integrations/ryd/Registration.java b/app/src/main/java/app/revanced/integrations/ryd/Registration.java index fdd9f61c..0724aa4c 100644 --- a/app/src/main/java/app/revanced/integrations/ryd/Registration.java +++ b/app/src/main/java/app/revanced/integrations/ryd/Registration.java @@ -1,40 +1,28 @@ package app.revanced.integrations.ryd; -import android.content.Context; import android.util.Base64; import java.security.MessageDigest; import java.security.SecureRandom; +import app.revanced.integrations.settings.SettingsEnum; import app.revanced.integrations.utils.LogHelper; import app.revanced.integrations.ryd.requests.RYDRequester; -import app.revanced.integrations.utils.SharedPrefHelper; public class Registration { - private String userId; - private Context context; - - public Registration(Context context) { - this.context = context; - } // https://stackoverflow.com/a/157202 private final String AB = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; private SecureRandom rnd = new SecureRandom(); + private String userId; public String getUserId() { return userId != null ? userId : fetchUserId(); } public void saveUserId(String userId) { - try { - if (this.context == null) - throw new Exception("Unable to save userId because context was null"); - SharedPrefHelper.saveString(context, SharedPrefHelper.SharedPrefNames.RYD, RYDSettings.PREFERENCES_KEY_USERID, userId); - } catch (Exception ex) { - LogHelper.printException(Registration.class, "Unable to save the userId in shared preferences", ex); - } + SettingsEnum.RYD_USER_ID_STRING.saveValue(userId); } public static String solvePuzzle(String challenge, int difficulty) { @@ -81,17 +69,9 @@ public class Registration { } private String fetchUserId() { - try { - if (this.context == null) - throw new Exception("Unable to fetch userId because context was null"); - - this.userId = SharedPrefHelper.getString(context, SharedPrefHelper.SharedPrefNames.RYD, RYDSettings.PREFERENCES_KEY_USERID, null); - - if (this.userId == null) { - this.userId = register(); - } - } catch (Exception ex) { - LogHelper.printException(Registration.class, "Unable to fetch the userId from shared preferences", ex); + this.userId = SettingsEnum.RYD_USER_ID_STRING.getString(); + if (this.userId == null) { + this.userId = register(); } return this.userId; diff --git a/app/src/main/java/app/revanced/integrations/ryd/ReturnYouTubeDislikes.java b/app/src/main/java/app/revanced/integrations/ryd/ReturnYouTubeDislikes.java index 574a1fa4..a58f4329 100644 --- a/app/src/main/java/app/revanced/integrations/ryd/ReturnYouTubeDislikes.java +++ b/app/src/main/java/app/revanced/integrations/ryd/ReturnYouTubeDislikes.java @@ -2,7 +2,6 @@ package app.revanced.integrations.ryd; import static app.revanced.integrations.sponsorblock.player.VideoInformation.currentVideoId; import static app.revanced.integrations.sponsorblock.player.VideoInformation.dislikeCount; -import static app.revanced.integrations.ryd.RYDSettings.PREFERENCES_KEY_RYD_ENABLED; import static app.revanced.integrations.utils.ReVancedUtils.getIdentifier; import android.content.Context; @@ -15,6 +14,7 @@ import android.widget.TextView; import java.util.Locale; import java.util.Objects; +import app.revanced.integrations.settings.SettingsEnum; import app.revanced.integrations.utils.LogHelper; import app.revanced.integrations.ryd.requests.RYDRequester; import app.revanced.integrations.utils.ReVancedUtils; @@ -34,10 +34,10 @@ public class ReturnYouTubeDislikes { static { Context context = ReVancedUtils.getContext(); - isEnabled = SharedPrefHelper.getBoolean(Objects.requireNonNull(context), SharedPrefHelper.SharedPrefNames.RYD, PREFERENCES_KEY_RYD_ENABLED, false); + isEnabled = SettingsEnum.RYD_ENABLED_BOOLEAN.getBoolean(); if (isEnabled) { - registration = new Registration(context); - voting = new Voting(context, registration); + registration = new Registration(); + voting = new Voting(registration); } Locale locale = context.getResources().getConfiguration().locale; @@ -53,10 +53,10 @@ public class ReturnYouTubeDislikes { public static void onEnabledChange(boolean enabled) { isEnabled = enabled; if (registration == null) { - registration = new Registration(ReVancedUtils.getContext()); + registration = new Registration(); } if (voting == null) { - voting = new Voting(ReVancedUtils.getContext(), registration); + voting = new Voting(registration); } } diff --git a/app/src/main/java/app/revanced/integrations/ryd/Voting.java b/app/src/main/java/app/revanced/integrations/ryd/Voting.java index 880cccd5..834c5c9e 100644 --- a/app/src/main/java/app/revanced/integrations/ryd/Voting.java +++ b/app/src/main/java/app/revanced/integrations/ryd/Voting.java @@ -1,17 +1,12 @@ package app.revanced.integrations.ryd; -import android.content.Context; - - import app.revanced.integrations.utils.LogHelper; import app.revanced.integrations.ryd.requests.RYDRequester; public class Voting { private Registration registration; - private Context context; - public Voting(Context context, Registration registration) { - this.context = context; + public Voting(Registration registration) { this.registration = registration; } diff --git a/app/src/main/java/app/revanced/integrations/ryd/dialog/Dialogs.java b/app/src/main/java/app/revanced/integrations/ryd/dialog/Dialogs.java index 37883a3a..d75581dd 100644 --- a/app/src/main/java/app/revanced/integrations/ryd/dialog/Dialogs.java +++ b/app/src/main/java/app/revanced/integrations/ryd/dialog/Dialogs.java @@ -1,21 +1,16 @@ package app.revanced.integrations.ryd.dialog; -import static app.revanced.integrations.ryd.RYDSettings.PREFERENCES_KEY_RYD_ENABLED; -import static app.revanced.integrations.ryd.RYDSettings.PREFERENCES_KEY_RYD_HINT_SHOWN; -import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.PREFERENCES_KEY_SPONSOR_BLOCK_ENABLED; -import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.PREFERENCES_KEY_SPONSOR_BLOCK_HINT_SHOWN; import static app.revanced.integrations.sponsorblock.StringRef.str; import android.app.Activity; import android.app.AlertDialog; -import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.graphics.LightingColorFilter; import android.net.Uri; import android.os.Build; -import app.revanced.integrations.utils.SharedPrefHelper; +import app.revanced.integrations.settings.SettingsEnum; import app.revanced.integrations.utils.ReVancedUtils; public class Dialogs { @@ -25,15 +20,14 @@ public class Dialogs { } private static void rydFirstRun(Activity activity) { - Context context = ReVancedUtils.getContext(); - boolean enabled = SharedPrefHelper.getBoolean(context, SharedPrefHelper.SharedPrefNames.RYD, PREFERENCES_KEY_RYD_ENABLED, false); - boolean hintShown = SharedPrefHelper.getBoolean(context, SharedPrefHelper.SharedPrefNames.RYD, PREFERENCES_KEY_RYD_HINT_SHOWN, false); + boolean enabled = SettingsEnum.RYD_ENABLED_BOOLEAN.getBoolean(); + boolean hintShown = SettingsEnum.RYD_HINT_SHOWN_BOOLEAN.getBoolean(); // If RYD is enabled or hint has been shown, exit if (enabled || hintShown) { // If RYD is enabled but hint hasn't been shown, mark it as shown if (enabled && !hintShown) { - SharedPrefHelper.saveBoolean(context, SharedPrefHelper.SharedPrefNames.RYD, PREFERENCES_KEY_RYD_HINT_SHOWN, true); + SettingsEnum.RYD_HINT_SHOWN_BOOLEAN.saveValue(true); } return; } @@ -50,15 +44,15 @@ public class Dialogs { builder.setMessage(str("revanced_ryd_firstrun")); builder.setPositiveButton(str("revanced_enable"), (dialog, id) -> { - SharedPrefHelper.saveBoolean(context, SharedPrefHelper.SharedPrefNames.RYD, PREFERENCES_KEY_RYD_HINT_SHOWN, true); - SharedPrefHelper.saveBoolean(context, SharedPrefHelper.SharedPrefNames.RYD, PREFERENCES_KEY_RYD_ENABLED, true); + SettingsEnum.RYD_HINT_SHOWN_BOOLEAN.saveValue(true); + SettingsEnum.RYD_ENABLED_BOOLEAN.saveValue(true); dialog.dismiss(); }); builder.setNegativeButton(str("revanced_disable"), (dialog, id) -> { - SharedPrefHelper.saveBoolean(context, SharedPrefHelper.SharedPrefNames.RYD, PREFERENCES_KEY_RYD_HINT_SHOWN, true); - SharedPrefHelper.saveBoolean(context, SharedPrefHelper.SharedPrefNames.RYD, PREFERENCES_KEY_RYD_ENABLED, false); + SettingsEnum.RYD_HINT_SHOWN_BOOLEAN.saveValue(true); + SettingsEnum.RYD_ENABLED_BOOLEAN.saveValue(false); dialog.dismiss(); }); diff --git a/app/src/main/java/app/revanced/integrations/settings/SettingsEnum.java b/app/src/main/java/app/revanced/integrations/settings/SettingsEnum.java index aa3679f8..810d5222 100644 --- a/app/src/main/java/app/revanced/integrations/settings/SettingsEnum.java +++ b/app/src/main/java/app/revanced/integrations/settings/SettingsEnum.java @@ -2,52 +2,107 @@ package app.revanced.integrations.settings; import android.content.Context; +import java.util.ArrayList; +import java.util.List; + import app.revanced.integrations.utils.LogHelper; import app.revanced.integrations.utils.ReVancedUtils; import app.revanced.integrations.utils.SharedPrefHelper; public enum SettingsEnum { - DEBUG_BOOLEAN("debug_revanced_enabled", false), - MANUFACTURER_OVERRIDE_STRING("override_manufacturer", null), - MODEL_OVERRIDE_STRING("override_model", null), - CODEC_OVERRIDE_BOOLEAN("revanced_vp9_enabled", true), - PREFERRED_RESOLUTION_WIFI_INTEGER("pref_video_quality_wifi", -2), - PREFERRED_RESOLUTION_MOBILE_INTEGER("pref_video_quality_mobile", -2), - PREFERRED_VIDEO_SPEED_FLOAT("pref_video_speed", -2.0f), - PREFERRED_MINIMIZED_VIDEO_PREVIEW_INTEGER("pref_minimized_video_preview", -2), - PREFERRED_AUTO_REPEAT_BOOLEAN("pref_auto_repeat", true), - HOME_ADS_SHOWN_BOOLEAN("home_ads_enabled", false), - VIDEO_ADS_SHOWN_BOOLEAN("video_ads_enabled", false), - REEL_BUTTON_SHOWN_BOOLEAN("reel_button_enabled", false), - SHORTS_BUTTON_SHOWN_BOOLEAN("shorts_button_enabled", false), - CAST_BUTTON_SHOWN_BOOLEAN("cast_button_enabled", false), + //Codec Override + CODEC_OVERRIDE_BOOLEAN("revanced_override_codec_enabled", true), + MANUFACTURER_OVERRIDE_STRING("revanced_override_codec_manufacturer", null), + MODEL_OVERRIDE_STRING("revanced_override_codec_model", null), + + //Video Settings + OLD_STYLE_QUALITY_SETTINGS_BOOLEAN("revanced_use_old_style_quality_settings", true), + OVERRIDE_RESOLUTION_TO_MAX_BOOLEAN("revanced_override_resolution_max", false), + PREFERRED_RESOLUTION_WIFI_INTEGER("revanced_pref_video_quality_wifi", -2), + PREFERRED_RESOLUTION_MOBILE_INTEGER("revanced_pref_video_quality_mobile", -2), + PREFERRED_VIDEO_SPEED_FLOAT("revanced_pref_video_speed", -2.0f), + + //Whitelist Settings + ENABLE_WHITELIST_BOOLEAN("revanced_whitelist_ads_enabled", false), + + //Ad settings + HOME_ADS_SHOWN_BOOLEAN("revanced_home_ads_enabled", false), + VIDEO_ADS_SHOWN_BOOLEAN("revanced_video_ads_enabled", false), + ADREMOVER_AD_REMOVAL_BOOLEAN("revanced_adremover_ad_removal", true), + ADREMOVER_MERCHANDISE_REMOVAL_BOOLEAN("revanced_adremover_merchandise", true), + ADREMOVER_COMMUNITY_POSTS_REMOVAL_BOOLEAN("revanced_adremover_community_posts_removal", false), + ADREMOVER_COMPACT_BANNER_REMOVAL_BOOLEAN("revanced_adremover_compact_banner_removal", true), + ADREMOVER_COMMENTS_REMOVAL_BOOLEAN("revanced_adremover_comments_removal", false), + ADREMOVER_MOVIE_REMOVAL_BOOLEAN("revanced_adremover_movie", true), + ADREMOVER_FEED_SURVEY_REMOVAL_BOOLEAN("revanced_adremover_feed_survey", true), + ADREMOVER_SHORTS_SHELF_BOOLEAN("revanced_adremover_shorts_shelf", true), + ADREMOVER_COMMUNITY_GUIDELINES_BOOLEAN("revanced_adremover_community_guidelines", true), + //ToDo: These Settings have to be added to revanced_prefs.xml + ADREMOVER_EMERGENCY_BOX_REMOVAL_BOOLEAN("revanced_adremover_emergency_box_removal", true), + ADREMOVER_INFO_PANEL_REMOVAL_BOOLEAN("revanced_adremover_info_panel", true), + ADREMOVER_MEDICAL_PANEL_REMOVAL_BOOLEAN("revanced_adremover_medical_panel", true), + ADREMOVER_PAID_CONTECT_REMOVAL_BOOLEAN("revanced_adremover_paid_content", true), + ADREMOVER_SUGGESTED_FOR_YOU_REMOVAL_BOOLEAN("revanced_adremover_suggested", true), + ADREMOVER_HIDE_SUGGESTIONS_BOOLEAN("revanced_adremover_hide_suggestions", true), + ADREMOVER_HIDE_LATEST_POSTS_BOOLEAN("revanced_adremover_hide_latest_posts", true), + + //Layout settings + REEL_BUTTON_SHOWN_BOOLEAN("revanced_reel_button_enabled", false), + INFO_CARDS_SHOWN_BOOLEAN("revanced_info_cards_enabled", false), + BRANDING_SHOWN_BOOLEAN("revanced_branding_watermark_enabled", false), + CAST_BUTTON_SHOWN_BOOLEAN("revanced_cast_button_enabled", false), + USE_TABLET_MINIPLAYER_BOOLEAN("revanced_tablet_miniplayer", false), CREATE_BUTTON_SHOWN_BOOLEAN("revanced_create_button_enabled", false), - INFO_CARDS_SHOWN_BOOLEAN("info_cards_enabled", false), - BRANDING_SHOWN_BOOLEAN("branding_watermark_enabled", false), - USE_TABLET_MINIPLAYER_BOOLEAN("tablet_miniplayer", false), USE_NEW_ACTIONBAR_BOOLEAN("revanced_new_actionbar", false), - USE_DARK_THEME_BOOLEAN("app_theme_dark", false), - USE_HDR_BRIGHTNESS_BOOLEAN("pref_hdr_autobrightness", true), - ENABLE_SWIPE_BRIGHTNESS_BOOLEAN("pref_xfenster_brightness", true), - ENABLE_SWIPE_VOLUME_BOOLEAN("pref_xfenster_volume", true), + SHORTS_BUTTON_SHOWN_BOOLEAN("revanced_shorts_button_enabled", false), - @Deprecated - SWIPE_THRESHOLD_INTEGER("pref_xfenster_swipe_threshold", 30), - @Deprecated - SWIPE_PADDING_TOP_INTEGER("pref_xfenster_swipe_padding_top", 50), - @Deprecated - SWIPE_USE_TABLET_MODE("pref_xfenster_tablet", false), - - MAX_BUFFER_INTEGER("pref_max_buffer_ms", 120000), - PLAYBACK_MAX_BUFFER_INTEGER("pref_buffer_for_playback_ms", 2500), - MAX_PLAYBACK_BUFFER_AFTER_REBUFFER_INTEGER("pref_buffer_for_playback_after_rebuffer_ms", 5000), - OLD_STYLE_QUALITY_SETTINGS_BOOLEAN("old_style_quality_settings", true), + //Misc. Settings + AUTOREPEAT_BUTTON_SHOWN_BOOLEAN("revanced_pref_auto_repeat_button", false), + PREFERRED_AUTO_REPEAT_BOOLEAN("revanced_pref_auto_repeat", true), + USE_HDR_BRIGHTNESS_BOOLEAN("revanced_pref_hdr_autobrightness", true), TAP_SEEKING_ENABLED_BOOLEAN("revanced_enable_tap_seeking", true), - ; + + //Swipe controls + ENABLE_SWIPE_BRIGHTNESS_BOOLEAN("revanced_enable_swipe_brightness", true), + ENABLE_SWIPE_VOLUME_BOOLEAN("revanced_enable_swipe_volume", true), + + //Buffer Settings + MAX_BUFFER_INTEGER("revanced_pref_max_buffer_ms", 120000), + PLAYBACK_MAX_BUFFER_INTEGER("revanced_pref_buffer_for_playback_ms", 2500), + MAX_PLAYBACK_BUFFER_AFTER_REBUFFER_INTEGER("revanced_pref_buffer_for_playback_after_rebuffer_ms", 5000), + + //ReVanced General Settings + DEBUG_BOOLEAN("revanced_debug_enabled", true), + USE_DARK_THEME_BOOLEAN("app_theme_dark", false), + + //RYD Settings + RYD_USER_ID_STRING("ryd_userId", null, SharedPrefHelper.SharedPrefNames.RYD), + RYD_ENABLED_BOOLEAN("ryd_enabled", true, SharedPrefHelper.SharedPrefNames.RYD), + RYD_HINT_SHOWN_BOOLEAN("ryd_hint_shown", false, SharedPrefHelper.SharedPrefNames.RYD), + + //SponsorBlock Settings + SB_ENABLED_BOOLEAN("sb-enabled", true, SharedPrefHelper.SharedPrefNames.SPONSOR_BLOCK), + SB_SHOW_TOAST_WHEN_SKIP_BOOLEAN("show-toast", true, SharedPrefHelper.SharedPrefNames.SPONSOR_BLOCK), + SB_COUNT_SKIPS_BOOLEAN("count-skips", true, SharedPrefHelper.SharedPrefNames.SPONSOR_BLOCK), + SB_UUID_STRING("uuid", null, SharedPrefHelper.SharedPrefNames.SPONSOR_BLOCK), + SB_ADJUST_NEW_SEGMENT_STEP_INTEGER("new-segment-step-accuracy", 150, SharedPrefHelper.SharedPrefNames.SPONSOR_BLOCK), + SB_MIN_DURATION_FLOAT("sb-min-duration", 0F, SharedPrefHelper.SharedPrefNames.SPONSOR_BLOCK), + SB_SPONSOR_BLOCK_HINT_SHOWN_BOOLEAN("sb_hint_shown", false, SharedPrefHelper.SharedPrefNames.SPONSOR_BLOCK), + SB_SEEN_GUIDELINES_BOOLEAN("sb-seen-gl", false, SharedPrefHelper.SharedPrefNames.SPONSOR_BLOCK), + SB_NEW_SEGMENT_ENABLED_BOOLEAN("sb-new-segment-enabled", false, SharedPrefHelper.SharedPrefNames.SPONSOR_BLOCK), + SB_VOTING_ENABLED_BOOLEAN("sb-voting-enabled", true, SharedPrefHelper.SharedPrefNames.SPONSOR_BLOCK), + SB_SKIPPED_SEGMENTS_INTEGER("sb-skipped-segments", 0, SharedPrefHelper.SharedPrefNames.SPONSOR_BLOCK), + SB_SKIPPED_SEGMENTS_TIME_LONG("sb-skipped-segments-time", 0L, SharedPrefHelper.SharedPrefNames.SPONSOR_BLOCK), + SB_SHOW_TIME_WITHOUT_SEGMENTS_BOOLEAN("sb-length-without-segments", true, SharedPrefHelper.SharedPrefNames.SPONSOR_BLOCK), + SB_IS_VIP_BOOLEAN("sb-is-vip", false, SharedPrefHelper.SharedPrefNames.SPONSOR_BLOCK), + SB_LAST_VIP_CHECK_LONG("sb-last-vip-check", 0L, SharedPrefHelper.SharedPrefNames.SPONSOR_BLOCK), + SB_SHOW_BROWSER_BUTTON_BOOLEAN("sb-browser-button", false, SharedPrefHelper.SharedPrefNames.SPONSOR_BLOCK), + SB_API_URL_STRING("sb-api-url", "https://sponsor.ajay.app/api/", SharedPrefHelper.SharedPrefNames.SPONSOR_BLOCK); private final String path; private final Object defaultValue; + private final SharedPrefHelper.SharedPrefNames sharedPref; private Object value = null; private static boolean loaded = false; @@ -55,6 +110,13 @@ public enum SettingsEnum { SettingsEnum(String path, Object defaultValue) { this.path = path; this.defaultValue = defaultValue; + this.sharedPref = SharedPrefHelper.SharedPrefNames.YOUTUBE; + } + + SettingsEnum(String path, Object defaultValue, SharedPrefHelper.SharedPrefNames prefName) { + this.path = path; + this.defaultValue = defaultValue; + this.sharedPref = prefName; } public static void loadSettings() { @@ -91,6 +153,16 @@ public enum SettingsEnum { return loaded; } + public static List getAdRemovalSettings() { + List list = new ArrayList<>(); + for (SettingsEnum var : SettingsEnum.values()) { + if (var.toString().startsWith("ADREMOVER")) { + list.add(var); + } + } + return list; + } + public void setValue(Object newValue) { this.value = newValue; } @@ -100,15 +172,15 @@ public enum SettingsEnum { Context context = ReVancedUtils.getContext(); if (context != null) { if (name().endsWith("BOOLEAN")) { - SharedPrefHelper.saveBoolean(context, SharedPrefHelper.SharedPrefNames.YOUTUBE, getPath(), (Boolean) newValue); + SharedPrefHelper.saveBoolean(context, sharedPref, getPath(), (Boolean) newValue); } else if (name().endsWith("INTEGER")) { - SharedPrefHelper.saveInt(context, SharedPrefHelper.SharedPrefNames.YOUTUBE, getPath(), (int) newValue); + SharedPrefHelper.saveInt(context, sharedPref, getPath(), (int) newValue); } else if (name().endsWith("STRING")) { - SharedPrefHelper.saveString(context, SharedPrefHelper.SharedPrefNames.YOUTUBE, getPath(), (String) newValue); + SharedPrefHelper.saveString(context, sharedPref, getPath(), (String) newValue); } else if (name().endsWith("LONG")) { - SharedPrefHelper.saveLong(context, SharedPrefHelper.SharedPrefNames.YOUTUBE, getPath(), (Long) newValue); + SharedPrefHelper.saveLong(context, sharedPref, getPath(), (Long) newValue); } else if (name().endsWith(("FLOAT"))) { - SharedPrefHelper.saveFloat(context, SharedPrefHelper.SharedPrefNames.YOUTUBE, getPath(), (Float) newValue); + SharedPrefHelper.saveFloat(context, sharedPref, getPath(), (Float) newValue); } else { LogHelper.printException(SettingsEnum.class, "Setting does not end with a valid Type. Name is: " + name()); } @@ -133,7 +205,8 @@ public enum SettingsEnum { public boolean getBoolean() { SettingsEnum.loadSettings(); - //LogHelper.debug("SettingsEnum", "Variable " + name() + " is " + value); + if (this != DEBUG_BOOLEAN) + LogHelper.debug(SettingsEnum.class, "Variable " + name() + " is " + value); return (Boolean) value; } diff --git a/app/src/main/java/app/revanced/integrations/settingsmenu/RYDSettingsFragment.java b/app/src/main/java/app/revanced/integrations/settingsmenu/RYDSettingsFragment.java index 3eedf60e..d8e5fc7a 100644 --- a/app/src/main/java/app/revanced/integrations/settingsmenu/RYDSettingsFragment.java +++ b/app/src/main/java/app/revanced/integrations/settingsmenu/RYDSettingsFragment.java @@ -1,7 +1,5 @@ package app.revanced.integrations.settingsmenu; -import static app.revanced.integrations.ryd.RYDSettings.PREFERENCES_KEY_RYD_ENABLED; -import static app.revanced.integrations.ryd.RYDSettings.PREFERENCES_KEY_RYD_HINT_SHOWN; import static app.revanced.integrations.sponsorblock.StringRef.str; import android.app.Activity; @@ -16,7 +14,6 @@ import android.preference.PreferenceScreen; import android.preference.SwitchPreference; import app.revanced.integrations.ryd.ReturnYouTubeDislikes; -import app.revanced.integrations.settings.Settings; import app.revanced.integrations.settings.SettingsEnum; import app.revanced.integrations.utils.SharedPrefHelper; @@ -35,9 +32,9 @@ public class RYDSettingsFragment extends PreferenceFragment { { SwitchPreference preference = new SwitchPreference(context); preferenceScreen.addPreference(preference); - preference.setKey(PREFERENCES_KEY_RYD_ENABLED); + preference.setKey(SettingsEnum.RYD_ENABLED_BOOLEAN.getPath()); preference.setDefaultValue(false); - preference.setChecked(SharedPrefHelper.getBoolean(context, SharedPrefHelper.SharedPrefNames.RYD, PREFERENCES_KEY_RYD_ENABLED)); + preference.setChecked(SettingsEnum.RYD_ENABLED_BOOLEAN.getBoolean()); preference.setTitle(str("revanced_ryd_title")); preference.setSummary(str("revanced_ryd_summary")); preference.setOnPreferenceChangeListener((pref, newValue) -> { @@ -51,9 +48,9 @@ public class RYDSettingsFragment extends PreferenceFragment { if (SettingsEnum.DEBUG_BOOLEAN.getBoolean()) { SwitchPreference preference = new SwitchPreference(context); preferenceScreen.addPreference(preference); - preference.setKey(PREFERENCES_KEY_RYD_HINT_SHOWN); + preference.setKey(SettingsEnum.RYD_HINT_SHOWN_BOOLEAN.getPath()); preference.setDefaultValue(false); - preference.setChecked(SharedPrefHelper.getBoolean(context, SharedPrefHelper.SharedPrefNames.RYD, PREFERENCES_KEY_RYD_HINT_SHOWN)); + preference.setChecked(SettingsEnum.RYD_HINT_SHOWN_BOOLEAN.getBoolean()); preference.setTitle("Hint debug"); preference.setSummary("Debug toggle for clearing the hint shown preference"); preference.setOnPreferenceChangeListener((pref, newValue) -> true); diff --git a/app/src/main/java/app/revanced/integrations/settingsmenu/ReVancedSettingsFragment.java b/app/src/main/java/app/revanced/integrations/settingsmenu/ReVancedSettingsFragment.java index dd032abb..3fab1f4f 100644 --- a/app/src/main/java/app/revanced/integrations/settingsmenu/ReVancedSettingsFragment.java +++ b/app/src/main/java/app/revanced/integrations/settingsmenu/ReVancedSettingsFragment.java @@ -8,6 +8,7 @@ import android.app.PendingIntent; import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; +import android.os.Build; import android.os.Bundle; import android.os.Process; import android.preference.EditTextPreference; @@ -52,8 +53,6 @@ public class ReVancedSettingsFragment extends PreferenceFragment { private final CharSequence[] videoQualityEntries = {"Auto", "144p", "240p", "360p", "480p", "720p", "1080p", "1440p", "2160p"}; private final CharSequence[] videoQualityentryValues = {"-2", "144", "240", "360", "480", "720", "1080", "1440", "2160"}; - private final CharSequence[] minimizedVideoEntries = {"Auto", "Video only", "Video with controls"}; - private final CharSequence[] minimizedVideoentryValues = {"-2", "0", "1"}; private final CharSequence[] videoSpeedEntries = {"Auto", "0.25x", "0.5x", "0.75x", "Normal", "1.25x", "1.5x", "1.75x", "2x", "3x", "4x", "5x"}; private final CharSequence[] videoSpeedentryValues = {"-2", "0.25", "0.5", "0.75", "1.0", "1.25", "1.5", "1.75", "2.0", "3.0", "4.0", "5.0"}; private final CharSequence[] buttonLocationEntries = {"None", "In player", "Under player", "Both"}; @@ -119,14 +118,6 @@ public class ReVancedSettingsFragment extends PreferenceFragment { if (ReVancedUtils.getContext() != null && settingsInitialized) { rebootDialog(getActivity()); } - } else if (str.equals(SettingsEnum.PREFERRED_MINIMIZED_VIDEO_PREVIEW_INTEGER.getPath())) { - ListPreference listPreference = (ListPreference) layoutSettingsPreferenceScreen.findPreference(str); - int index = SettingsEnum.PREFERRED_MINIMIZED_VIDEO_PREVIEW_INTEGER.getInt(); - listPreference.setDefaultValue(SettingsEnum.PREFERRED_MINIMIZED_VIDEO_PREVIEW_INTEGER.getDefaultValue()); - listPreference.setSummary(minimizedVideoEntries[listPreference.findIndexOfValue(String.valueOf(index))]); - if (ReVancedUtils.getContext() != null && settingsInitialized) { - rebootDialog(getActivity()); - } } else if (str.equals(SettingsEnum.CODEC_OVERRIDE_BOOLEAN.getPath())) { SettingsEnum.CODEC_OVERRIDE_BOOLEAN.setValue(((SwitchPreference) findPreference(str)).isChecked()); if (ReVancedUtils.getContext() != null && settingsInitialized) { @@ -198,7 +189,6 @@ public class ReVancedSettingsFragment extends PreferenceFragment { addPreferencesFromResource(identifier); String stringByName = ReVancedUtils.getStringByName(getActivity(), "quality_auto"); this.videoQualityEntries[0] = stringByName; - this.minimizedVideoEntries[0] = stringByName; this.videoSpeedEntries[0] = stringByName; String stringByName2 = ReVancedUtils.getStringByName(getActivity(), "pref_subtitles_scale_normal"); if (stringByName2.equals("")) { @@ -206,8 +196,6 @@ public class ReVancedSettingsFragment extends PreferenceFragment { } else { this.videoSpeedEntries[4] = stringByName2; } - this.minimizedVideoEntries[1] = ReVancedUtils.getStringByName(getActivity(), "revanced_miniplayer_style_video"); - this.minimizedVideoEntries[2] = ReVancedUtils.getStringByName(getActivity(), "revanced_miniplayer_style_video_controls"); SharedPreferences sharedPreferences = getPreferenceManager().getSharedPreferences(); this.sharedPreferences = sharedPreferences; this.settingsInitialized = sharedPreferences.getBoolean("revanced_initialized", false); @@ -256,12 +244,12 @@ public class ReVancedSettingsFragment extends PreferenceFragment { Preference findPreference = findPreference("pref_about_field"); this.codecDefault.setOnPreferenceClickListener(preference -> { - ReVancedSettingsFragment.this.ChangeCodec(preference); + ReVancedSettingsFragment.this.changeCodec(); return false; }); this.codecVP9.setOnPreferenceClickListener(preference -> { - ReVancedSettingsFragment.this.ChangeCodec(preference); + ReVancedSettingsFragment.this.changeCodec(); return false; }); @@ -298,16 +286,6 @@ public class ReVancedSettingsFragment extends PreferenceFragment { listPreference.setSummary(this.videoQualityEntries[listPreference.findIndexOfValue(string)]); } - protected void setMinimizedListPreferenceData(ListPreference listPreference) { - listPreference.setEntries(this.minimizedVideoEntries); - listPreference.setEntryValues(this.minimizedVideoentryValues); - String string = this.sharedPreferences.getString("pref_minimized_video_preview", "-2"); - if (listPreference.getValue() == null) { - listPreference.setValue(string); - } - listPreference.setSummary(this.minimizedVideoEntries[listPreference.findIndexOfValue(string)]); - } - protected void setSpeedListPreferenceData(ListPreference listPreference) { listPreference.setEntries(this.videoSpeedEntries); listPreference.setEntryValues(this.videoSpeedentryValues); @@ -340,14 +318,16 @@ public class ReVancedSettingsFragment extends PreferenceFragment { return PACKAGE_NAME; } - private void ChangeCodec(Preference preference) { + private void changeCodec() { String manufacturer = null; String model = null; - String key = preference.getKey(); - if (key.equals("pref_vp9_override")) { + if (SettingsEnum.CODEC_OVERRIDE_BOOLEAN.getBoolean()) { manufacturer = "samsung"; model = "SM-G920F"; + } else { + manufacturer = Build.MANUFACTURER; + model = Build.MODEL; } SettingsEnum.MANUFACTURER_OVERRIDE_STRING.saveValue(manufacturer); diff --git a/app/src/main/java/app/revanced/integrations/settingsmenu/SponsorBlockSettingsFragment.java b/app/src/main/java/app/revanced/integrations/settingsmenu/SponsorBlockSettingsFragment.java index 63b91f41..6b6cc807 100644 --- a/app/src/main/java/app/revanced/integrations/settingsmenu/SponsorBlockSettingsFragment.java +++ b/app/src/main/java/app/revanced/integrations/settingsmenu/SponsorBlockSettingsFragment.java @@ -1,25 +1,5 @@ package app.revanced.integrations.settingsmenu; -import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.DEFAULT_API_URL; -import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.PREFERENCES_KEY_ADJUST_NEW_SEGMENT_STEP; -import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.PREFERENCES_KEY_API_URL; -import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.PREFERENCES_KEY_BROWSER_BUTTON; -import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.PREFERENCES_KEY_COUNT_SKIPS; -import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.PREFERENCES_KEY_MIN_DURATION; -import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.PREFERENCES_KEY_NEW_SEGMENT_ENABLED; -import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.PREFERENCES_KEY_SHOW_TIME_WITHOUT_SEGMENTS; -import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.PREFERENCES_KEY_SHOW_TOAST_WHEN_SKIP; -import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.PREFERENCES_KEY_SPONSOR_BLOCK_ENABLED; -import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.PREFERENCES_KEY_SPONSOR_BLOCK_HINT_SHOWN; -import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.PREFERENCES_KEY_UUID; -import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.PREFERENCES_KEY_VOTING_ENABLED; -import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.adjustNewSegmentMillis; -import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.countSkips; -import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.minDuration; -import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.setSeenGuidelines; -import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.showTimeWithoutSegments; -import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.showToastWhenSkippedAutomatically; -import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.uuid; import static app.revanced.integrations.sponsorblock.StringRef.str; import android.app.Activity; @@ -56,7 +36,6 @@ import app.revanced.integrations.utils.SharedPrefHelper; import app.revanced.integrations.sponsorblock.objects.EditTextListPreference; import app.revanced.integrations.sponsorblock.requests.SBRequester; -@SuppressWarnings({"unused", "deprecation"}) // injected public class SponsorBlockSettingsFragment extends PreferenceFragment implements SharedPreferences.OnSharedPreferenceChangeListener { public static final DecimalFormat FORMATTER = new DecimalFormat("#,###,###"); public static final String SAVED_TEMPLATE = "%dh %.1f %s"; @@ -80,9 +59,9 @@ public class SponsorBlockSettingsFragment extends PreferenceFragment implements { SwitchPreference preference = new SwitchPreference(context); preferenceScreen.addPreference(preference); - preference.setKey(PREFERENCES_KEY_SPONSOR_BLOCK_ENABLED); - preference.setDefaultValue(SponsorBlockSettings.isSponsorBlockEnabled); - preference.setChecked(SponsorBlockSettings.isSponsorBlockEnabled); + preference.setKey(SettingsEnum.SB_ENABLED_BOOLEAN.getPath()); + preference.setDefaultValue(SettingsEnum.SB_ENABLED_BOOLEAN.getDefaultValue()); + preference.setChecked(SettingsEnum.SB_ENABLED_BOOLEAN.getBoolean()); preference.setTitle(str("enable_sb")); preference.setSummary(str("enable_sb_sum")); preference.setOnPreferenceChangeListener((preference1, newValue) -> { @@ -96,9 +75,9 @@ public class SponsorBlockSettingsFragment extends PreferenceFragment implements if (SettingsEnum.DEBUG_BOOLEAN.getBoolean()) { SwitchPreference preference = new SwitchPreference(context); preferenceScreen.addPreference(preference); - preference.setKey(PREFERENCES_KEY_SPONSOR_BLOCK_HINT_SHOWN); + preference.setKey(SettingsEnum.SB_SPONSOR_BLOCK_HINT_SHOWN_BOOLEAN.getPath()); preference.setDefaultValue(false); - preference.setChecked(SharedPrefHelper.getBoolean(context, SharedPrefHelper.SharedPrefNames.SPONSOR_BLOCK, PREFERENCES_KEY_SPONSOR_BLOCK_HINT_SHOWN)); + preference.setChecked(SettingsEnum.SB_SPONSOR_BLOCK_HINT_SHOWN_BOOLEAN.getBoolean()); preference.setTitle("Hint debug"); preference.setSummary("Debug toggle for clearing the hint shown preference"); preference.setOnPreferenceChangeListener((pref, newValue) -> true); @@ -107,15 +86,15 @@ public class SponsorBlockSettingsFragment extends PreferenceFragment implements { SwitchPreference preference = new SwitchPreference(context); preferenceScreen.addPreference(preference); - preference.setKey(PREFERENCES_KEY_NEW_SEGMENT_ENABLED); - preference.setDefaultValue(SponsorBlockSettings.isAddNewSegmentEnabled); - preference.setChecked(SponsorBlockSettings.isAddNewSegmentEnabled); + preference.setKey(SettingsEnum.SB_NEW_SEGMENT_ENABLED_BOOLEAN.getPath()); + preference.setDefaultValue(SettingsEnum.SB_NEW_SEGMENT_ENABLED_BOOLEAN.getBoolean()); + preference.setChecked(SettingsEnum.SB_NEW_SEGMENT_ENABLED_BOOLEAN.getBoolean()); preference.setTitle(str("enable_segmadding")); preference.setSummary(str("enable_segmadding_sum")); preferencesToDisableWhenSBDisabled.add(preference); preference.setOnPreferenceChangeListener((preference12, o) -> { final boolean value = (Boolean) o; - if (value && !SponsorBlockSettings.seenGuidelinesPopup) { + if (value && !SettingsEnum.SB_SEEN_GUIDELINES_BOOLEAN.getBoolean()) { new AlertDialog.Builder(preference12.getContext()) .setTitle(str("sb_guidelines_popup_title")) .setMessage(str("sb_guidelines_popup_content")) @@ -132,9 +111,9 @@ public class SponsorBlockSettingsFragment extends PreferenceFragment implements preferenceScreen.addPreference(preference); preference.setTitle(str("enable_voting")); preference.setSummary(str("enable_voting_sum")); - preference.setKey(PREFERENCES_KEY_VOTING_ENABLED); - preference.setDefaultValue(SponsorBlockSettings.isVotingEnabled); - preference.setChecked(SponsorBlockSettings.isVotingEnabled); + preference.setKey(SettingsEnum.SB_VOTING_ENABLED_BOOLEAN.getPath()); + preference.setDefaultValue(SettingsEnum.SB_VOTING_ENABLED_BOOLEAN.getBoolean()); + preference.setChecked(SettingsEnum.SB_VOTING_ENABLED_BOOLEAN.getBoolean()); preferencesToDisableWhenSBDisabled.add(preference); } @@ -143,21 +122,21 @@ public class SponsorBlockSettingsFragment extends PreferenceFragment implements addStatsCategory(context, preferenceScreen); addAboutCategory(context, preferenceScreen); - enableCategoriesIfNeeded(SponsorBlockSettings.isSponsorBlockEnabled); + enableCategoriesIfNeeded(SettingsEnum.SB_ENABLED_BOOLEAN.getBoolean()); } private void openGuidelines() { final Context context = getActivity(); - setSeenGuidelines(context); + SettingsEnum.SB_SEEN_GUIDELINES_BOOLEAN.saveValue(true); Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse("https://wiki.sponsor.ajay.app/w/Guidelines")); context.startActivity(intent); } - private void enableCategoriesIfNeeded(boolean enabled) { + private void enableCategoriesIfNeeded(boolean value) { for (Preference preference : preferencesToDisableWhenSBDisabled) - preference.setEnabled(enabled); + preference.setEnabled(value); } @Override @@ -264,8 +243,8 @@ public class SponsorBlockSettingsFragment extends PreferenceFragment implements Preference preference = new SwitchPreference(context); preference.setTitle(str("general_skiptoast")); preference.setSummary(str("general_skiptoast_sum")); - preference.setKey(PREFERENCES_KEY_SHOW_TOAST_WHEN_SKIP); - preference.setDefaultValue(showToastWhenSkippedAutomatically); + preference.setKey(SettingsEnum.SB_SHOW_TOAST_WHEN_SKIP_BOOLEAN.getPath()); + preference.setDefaultValue(SettingsEnum.SB_SHOW_TOAST_WHEN_SKIP_BOOLEAN.getBoolean()); preference.setOnPreferenceClickListener(preference12 -> { Toast.makeText(preference12.getContext(), str("skipped_sponsor"), Toast.LENGTH_SHORT).show(); return false; @@ -278,8 +257,8 @@ public class SponsorBlockSettingsFragment extends PreferenceFragment implements Preference preference = new SwitchPreference(context); preference.setTitle(str("general_skipcount")); preference.setSummary(str("general_skipcount_sum")); - preference.setKey(PREFERENCES_KEY_COUNT_SKIPS); - preference.setDefaultValue(countSkips); + preference.setKey(SettingsEnum.SB_COUNT_SKIPS_BOOLEAN.getPath()); + preference.setDefaultValue(SettingsEnum.SB_COUNT_SKIPS_BOOLEAN.getBoolean()); preferencesToDisableWhenSBDisabled.add(preference); screen.addPreference(preference); } @@ -288,8 +267,8 @@ public class SponsorBlockSettingsFragment extends PreferenceFragment implements Preference preference = new SwitchPreference(context); preference.setTitle(str("general_time_without_sb")); preference.setSummary(str("general_time_without_sb_sum")); - preference.setKey(PREFERENCES_KEY_SHOW_TIME_WITHOUT_SEGMENTS); - preference.setDefaultValue(showTimeWithoutSegments); + preference.setKey(SettingsEnum.SB_SHOW_TIME_WITHOUT_SEGMENTS_BOOLEAN.getPath()); + preference.setDefaultValue(SettingsEnum.SB_SHOW_TIME_WITHOUT_SEGMENTS_BOOLEAN.getBoolean()); preferencesToDisableWhenSBDisabled.add(preference); screen.addPreference(preference); } @@ -307,7 +286,8 @@ public class SponsorBlockSettingsFragment extends PreferenceFragment implements Preference preference = new SwitchPreference(context); preference.setTitle(str("general_browser_button")); preference.setSummary(str("general_browser_button_sum")); - preference.setKey(PREFERENCES_KEY_BROWSER_BUTTON); + preference.setKey(SettingsEnum.SB_SHOW_BROWSER_BUTTON_BOOLEAN.getPath()); + preference.setDefaultValue(SettingsEnum.SB_SHOW_BROWSER_BUTTON_BOOLEAN.getBoolean()); preferencesToDisableWhenSBDisabled.add(preference); screen.addPreference(preference); } @@ -317,8 +297,8 @@ public class SponsorBlockSettingsFragment extends PreferenceFragment implements 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); - preference.setDefaultValue(String.valueOf(adjustNewSegmentMillis)); + preference.setKey(SettingsEnum.SB_ADJUST_NEW_SEGMENT_STEP_INTEGER.getPath()); + preference.setDefaultValue(SettingsEnum.SB_ADJUST_NEW_SEGMENT_STEP_INTEGER.getInt()); screen.addPreference(preference); preferencesToDisableWhenSBDisabled.add(preference); } @@ -328,8 +308,8 @@ public class SponsorBlockSettingsFragment extends PreferenceFragment implements 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)); + preference.setKey(SettingsEnum.SB_MIN_DURATION_FLOAT.getPath()); + preference.setDefaultValue(SettingsEnum.SB_MIN_DURATION_FLOAT.getFloat()); screen.addPreference(preference); preferencesToDisableWhenSBDisabled.add(preference); } @@ -338,8 +318,8 @@ public class SponsorBlockSettingsFragment extends PreferenceFragment implements Preference preference = new EditTextPreference(context); preference.setTitle(str("general_uuid")); preference.setSummary(str("general_uuid_sum")); - preference.setKey(PREFERENCES_KEY_UUID); - preference.setDefaultValue(uuid); + preference.setKey(SettingsEnum.SB_UUID_STRING.getPath()); + preference.setDefaultValue(SettingsEnum.SB_UUID_STRING.getString()); screen.addPreference(preference); preferencesToDisableWhenSBDisabled.add(preference); } @@ -352,7 +332,7 @@ public class SponsorBlockSettingsFragment extends PreferenceFragment implements preference.setOnPreferenceClickListener(preference1 -> { EditText editText = new EditText(context); editText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI); - editText.setText(SponsorBlockSettings.apiUrl); + editText.setText(SettingsEnum.SB_API_URL_STRING.getString()); API_URL_CHANGE_LISTENER.setEditTextRef(editText); new AlertDialog.Builder(context) @@ -399,7 +379,7 @@ public class SponsorBlockSettingsFragment extends PreferenceFragment implements switch (which) { case DialogInterface.BUTTON_NEUTRAL: - preferences.edit().putString(PREFERENCES_KEY_API_URL, DEFAULT_API_URL).apply(); + SettingsEnum.SB_API_URL_STRING.saveValue(SettingsEnum.SB_API_URL_STRING.getDefaultValue()); Toast.makeText(applicationContext, str("api_url_reset"), Toast.LENGTH_SHORT).show(); break; case DialogInterface.BUTTON_POSITIVE: @@ -412,7 +392,7 @@ public class SponsorBlockSettingsFragment extends PreferenceFragment implements if (textAsString.isEmpty() || !Patterns.WEB_URL.matcher(textAsString).matches()) { invalidToast.show(); } else { - preferences.edit().putString(PREFERENCES_KEY_API_URL, textAsString).apply(); + SettingsEnum.SB_API_URL_STRING.saveValue(textAsString); Toast.makeText(applicationContext, str("api_url_changed"), Toast.LENGTH_SHORT).show(); } } diff --git a/app/src/main/java/app/revanced/integrations/sponsorblock/PlayerController.java b/app/src/main/java/app/revanced/integrations/sponsorblock/PlayerController.java index 73c77f99..ec5b3302 100644 --- a/app/src/main/java/app/revanced/integrations/sponsorblock/PlayerController.java +++ b/app/src/main/java/app/revanced/integrations/sponsorblock/PlayerController.java @@ -1,7 +1,5 @@ package app.revanced.integrations.sponsorblock; -import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.skippedSegments; -import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.skippedTime; import static app.revanced.integrations.sponsorblock.SponsorBlockUtils.timeWithoutSegments; import static app.revanced.integrations.sponsorblock.SponsorBlockUtils.videoHasSegments; @@ -23,6 +21,7 @@ import java.util.Arrays; import java.util.Timer; import java.util.TimerTask; +import app.revanced.integrations.settings.SettingsEnum; import app.revanced.integrations.utils.LogHelper; import app.revanced.integrations.sponsorblock.player.VideoInformation; import app.revanced.integrations.adremover.whitelist.Whitelist; @@ -65,7 +64,7 @@ public class PlayerController { Context context = ReVancedUtils.getContext(); SponsorBlockSettings.update(context); - if (!SponsorBlockSettings.isSponsorBlockEnabled) { + if (!SettingsEnum.SB_ENABLED_BOOLEAN.getBoolean()) { currentVideoId = null; return; } @@ -136,7 +135,7 @@ public class PlayerController { public static void setCurrentVideoTime(long millis) { LogHelper.debug(PlayerController.class, "setCurrentVideoTime: current video time: " + millis); VideoInformation.lastKnownVideoTime = millis; - if (!SponsorBlockSettings.isSponsorBlockEnabled) return; + if (!SettingsEnum.SB_ENABLED_BOOLEAN.getBoolean()) return; lastKnownVideoTime = millis; if (millis <= 0) return; //findAndSkipSegment(false); @@ -199,13 +198,13 @@ public class PlayerController { if (segment.category != SponsorBlockSettings.SegmentInfo.UNSUBMITTED) { Context context = ReVancedUtils.getContext(); if (context != null) { - long newSkippedTime = skippedTime + (segment.end - segment.start); - SharedPrefHelper.saveInt(context, SharedPrefHelper.SharedPrefNames.SPONSOR_BLOCK, SponsorBlockSettings.PREFERENCES_KEY_SKIPPED_SEGMENTS, skippedSegments + 1); - SharedPrefHelper.saveLong(context, SharedPrefHelper.SharedPrefNames.SPONSOR_BLOCK, SponsorBlockSettings.PREFERENCES_KEY_SKIPPED_SEGMENTS_TIME, newSkippedTime); + long newSkippedTime = SettingsEnum.SB_SKIPPED_SEGMENTS_TIME_LONG.getLong() + (segment.end - segment.start); + SettingsEnum.SB_SKIPPED_SEGMENTS_INTEGER.saveValue(SettingsEnum.SB_SKIPPED_SEGMENTS_INTEGER.getInt() + 1); + SettingsEnum.SB_SKIPPED_SEGMENTS_TIME_LONG.saveValue(newSkippedTime); } } new Thread(() -> { - if (SponsorBlockSettings.countSkips && + if (SettingsEnum.SB_COUNT_SKIPS_BOOLEAN.getBoolean() && segment.category != SponsorBlockSettings.SegmentInfo.UNSUBMITTED && millis - segment.start < 2000) { // Only skips from the start should count as a view @@ -418,7 +417,7 @@ public class PlayerController { // lastSkippedSegment = segment; LogHelper.debug(PlayerController.class, "Skipping segment: " + segment.toString()); - if (SponsorBlockSettings.showToastWhenSkippedAutomatically && !wasClicked) + if (SettingsEnum.SB_SHOW_TOAST_WHEN_SKIP_BOOLEAN.getBoolean() && !wasClicked) SkipSegmentView.notifySkipped(segment); skipToMillisecond(segment.end + 2); diff --git a/app/src/main/java/app/revanced/integrations/sponsorblock/ShieldButton.java b/app/src/main/java/app/revanced/integrations/sponsorblock/ShieldButton.java index 5ca9d8ee..79732211 100644 --- a/app/src/main/java/app/revanced/integrations/sponsorblock/ShieldButton.java +++ b/app/src/main/java/app/revanced/integrations/sponsorblock/ShieldButton.java @@ -9,10 +9,12 @@ import android.widget.ImageView; import android.widget.RelativeLayout; import java.lang.ref.WeakReference; +import java.util.Set; import static app.revanced.integrations.sponsorblock.PlayerController.getCurrentVideoLength; import static app.revanced.integrations.sponsorblock.PlayerController.getLastKnownVideoTime; +import app.revanced.integrations.settings.SettingsEnum; import app.revanced.integrations.utils.LogHelper; import app.revanced.integrations.utils.ReVancedUtils; @@ -95,7 +97,7 @@ public class ShieldButton { } static boolean shouldBeShown() { - return SponsorBlockUtils.isSettingEnabled(SponsorBlockSettings.isAddNewSegmentEnabled); + return SettingsEnum.SB_ENABLED_BOOLEAN.getBoolean() && SettingsEnum.SB_NEW_SEGMENT_ENABLED_BOOLEAN.getBoolean(); } //region Helpers diff --git a/app/src/main/java/app/revanced/integrations/sponsorblock/SponsorBlockSettings.java b/app/src/main/java/app/revanced/integrations/sponsorblock/SponsorBlockSettings.java index db16ed52..5c85ab7f 100644 --- a/app/src/main/java/app/revanced/integrations/sponsorblock/SponsorBlockSettings.java +++ b/app/src/main/java/app/revanced/integrations/sponsorblock/SponsorBlockSettings.java @@ -15,65 +15,22 @@ import java.util.HashMap; import java.util.Map; import java.util.UUID; +import app.revanced.integrations.settings.SettingsEnum; import app.revanced.integrations.utils.LogHelper; import app.revanced.integrations.utils.SharedPrefHelper; public class SponsorBlockSettings { - public static final String PREFERENCES_KEY_SHOW_TOAST_WHEN_SKIP = "show-toast"; - 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_SPONSOR_BLOCK_HINT_SHOWN = "sb_hint_shown"; - public static final String PREFERENCES_KEY_SEEN_GUIDELINES = "sb-seen-gl"; - public static final String PREFERENCES_KEY_NEW_SEGMENT_ENABLED = "sb-new-segment-enabled"; - public static final String PREFERENCES_KEY_VOTING_ENABLED = "sb-voting-enabled"; - public static final String PREFERENCES_KEY_SKIPPED_SEGMENTS = "sb-skipped-segments"; - public static final String PREFERENCES_KEY_SKIPPED_SEGMENTS_TIME = "sb-skipped-segments-time"; - public static final String PREFERENCES_KEY_SHOW_TIME_WITHOUT_SEGMENTS = "sb-length-without-segments"; - public static final String PREFERENCES_KEY_CATEGORY_COLOR_SUFFIX = "_color"; - public static final String PREFERENCES_KEY_BROWSER_BUTTON = "sb-browser-button"; - public static final String PREFERENCES_KEY_IS_VIP = "sb-is-vip"; - public static final String PREFERENCES_KEY_LAST_VIP_CHECK = "sb-last-vip-check"; - public static final String PREFERENCES_KEY_API_URL = "sb-api-url"; - + public static final String CATEGORY_COLOR_SUFFIX = "_color"; public static final SegmentBehaviour DefaultBehaviour = SegmentBehaviour.IGNORE; - public static final String DEFAULT_SERVER_URL = "https://sponsor.ajay.app"; - public static final String DEFAULT_API_URL = DEFAULT_SERVER_URL + "/api/"; - - public static boolean isSponsorBlockEnabled = false; - public static boolean seenGuidelinesPopup = false; - public static boolean isAddNewSegmentEnabled = false; - public static boolean isVotingEnabled = true; - public static boolean showToastWhenSkippedAutomatically = true; - public static boolean countSkips = true; - public static boolean showTimeWithoutSegments = true; - public static boolean vip = false; - public static long lastVipCheck = 0; - public static int adjustNewSegmentMillis = 150; - public static float minDuration = 0f; - public static String uuid = ""; - public static String apiUrl = DEFAULT_API_URL; public static String sponsorBlockUrlCategories = "[]"; - public static int skippedSegments; - public static long skippedTime; - - public static void setSeenGuidelines(Context context) { - SponsorBlockSettings.seenGuidelinesPopup = true; - SharedPrefHelper.getPreferences(context, SharedPrefHelper.SharedPrefNames.SPONSOR_BLOCK).edit().putBoolean(PREFERENCES_KEY_SEEN_GUIDELINES, true).apply(); - } public static void update(Context context) { if (context == null) return; SharedPreferences preferences = SharedPrefHelper.getPreferences(context, SharedPrefHelper.SharedPrefNames.SPONSOR_BLOCK); - isSponsorBlockEnabled = preferences.getBoolean(PREFERENCES_KEY_SPONSOR_BLOCK_ENABLED, isSponsorBlockEnabled); - seenGuidelinesPopup = preferences.getBoolean(PREFERENCES_KEY_SEEN_GUIDELINES, seenGuidelinesPopup); - - if (!isSponsorBlockEnabled) { + if (!SettingsEnum.SB_ENABLED_BOOLEAN.getBoolean()) { SkipSegmentView.hide(); NewSegmentHelperLayout.hide(); SponsorBlockUtils.hideShieldButton(); @@ -83,16 +40,15 @@ public class SponsorBlockSettings { SponsorBlockUtils.showShieldButton(); } - isAddNewSegmentEnabled = preferences.getBoolean(PREFERENCES_KEY_NEW_SEGMENT_ENABLED, isAddNewSegmentEnabled); - if (!isAddNewSegmentEnabled) { + if (!SettingsEnum.SB_NEW_SEGMENT_ENABLED_BOOLEAN.getBoolean()) { NewSegmentHelperLayout.hide(); SponsorBlockUtils.hideShieldButton(); } else { SponsorBlockUtils.showShieldButton(); } - isVotingEnabled = preferences.getBoolean(PREFERENCES_KEY_VOTING_ENABLED, isVotingEnabled); - if (!isVotingEnabled) + + if (!SettingsEnum.SB_VOTING_ENABLED_BOOLEAN.getBoolean()) SponsorBlockUtils.hideVoteButton(); else SponsorBlockUtils.showVoteButton(); @@ -100,7 +56,7 @@ public class SponsorBlockSettings { SegmentBehaviour[] possibleBehaviours = SegmentBehaviour.values(); final ArrayList enabledCategories = new ArrayList<>(possibleBehaviours.length); for (SegmentInfo segment : SegmentInfo.values()) { - String categoryColor = preferences.getString(segment.key + PREFERENCES_KEY_CATEGORY_COLOR_SUFFIX, SponsorBlockUtils.formatColorString(segment.defaultColor)); + String categoryColor = preferences.getString(segment.key + CATEGORY_COLOR_SUFFIX, SponsorBlockUtils.formatColorString(segment.defaultColor)); segment.setColor(Color.parseColor(categoryColor)); SegmentBehaviour behaviour = null; @@ -129,35 +85,13 @@ public class SponsorBlockSettings { else sponsorBlockUrlCategories = "[%22" + TextUtils.join("%22,%22", enabledCategories) + "%22]"; - skippedSegments = preferences.getInt(PREFERENCES_KEY_SKIPPED_SEGMENTS, skippedSegments); - skippedTime = preferences.getLong(PREFERENCES_KEY_SKIPPED_SEGMENTS_TIME, skippedTime); - - showToastWhenSkippedAutomatically = preferences.getBoolean(PREFERENCES_KEY_SHOW_TOAST_WHEN_SKIP, showToastWhenSkippedAutomatically); - String tmp1 = preferences.getString(PREFERENCES_KEY_ADJUST_NEW_SEGMENT_STEP, null); - 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); - vip = preferences.getBoolean(PREFERENCES_KEY_IS_VIP, false); - - String vipCheckTmp = preferences.getString(PREFERENCES_KEY_LAST_VIP_CHECK, null); - if (vipCheckTmp != null) - lastVipCheck = Long.parseLong(vipCheckTmp); - - apiUrl = preferences.getString(PREFERENCES_KEY_API_URL, DEFAULT_API_URL); - - uuid = preferences.getString(PREFERENCES_KEY_UUID, null); + String uuid = SettingsEnum.SB_UUID_STRING.getString(); if (uuid == null) { uuid = (UUID.randomUUID().toString() + UUID.randomUUID().toString() + UUID.randomUUID().toString()) .replace("-", ""); - preferences.edit().putString(PREFERENCES_KEY_UUID, uuid).apply(); + SettingsEnum.SB_UUID_STRING.saveValue(uuid); } } diff --git a/app/src/main/java/app/revanced/integrations/sponsorblock/SponsorBlockUtils.java b/app/src/main/java/app/revanced/integrations/sponsorblock/SponsorBlockUtils.java index 97ccba3d..c0d34491 100644 --- a/app/src/main/java/app/revanced/integrations/sponsorblock/SponsorBlockUtils.java +++ b/app/src/main/java/app/revanced/integrations/sponsorblock/SponsorBlockUtils.java @@ -9,28 +9,6 @@ import static app.revanced.integrations.sponsorblock.PlayerController.getLastKno import static app.revanced.integrations.sponsorblock.PlayerController.sponsorSegmentsOfCurrentVideo; import static app.revanced.integrations.settingsmenu.SponsorBlockSettingsFragment.FORMATTER; import static app.revanced.integrations.settingsmenu.SponsorBlockSettingsFragment.SAVED_TEMPLATE; -import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.DEFAULT_API_URL; -import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.DEFAULT_SERVER_URL; -import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.PREFERENCES_KEY_API_URL; -import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.PREFERENCES_KEY_CATEGORY_COLOR_SUFFIX; -import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.PREFERENCES_KEY_COUNT_SKIPS; -import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.PREFERENCES_KEY_IS_VIP; -import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.PREFERENCES_KEY_LAST_VIP_CHECK; -import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.PREFERENCES_KEY_MIN_DURATION; -import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.PREFERENCES_KEY_SHOW_TIME_WITHOUT_SEGMENTS; -import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.PREFERENCES_KEY_SHOW_TOAST_WHEN_SKIP; -import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.PREFERENCES_KEY_UUID; -import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.apiUrl; -import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.countSkips; -import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.isSponsorBlockEnabled; -import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.lastVipCheck; -import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.minDuration; -import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.showTimeWithoutSegments; -import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.showToastWhenSkippedAutomatically; -import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.skippedSegments; -import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.skippedTime; -import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.uuid; -import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.vip; import static app.revanced.integrations.sponsorblock.StringRef.str; import static app.revanced.integrations.sponsorblock.requests.SBRequester.voteForSegment; @@ -65,6 +43,8 @@ import java.util.List; import java.util.Objects; import java.util.TimeZone; +import app.revanced.integrations.settings.Settings; +import app.revanced.integrations.settings.SettingsEnum; import app.revanced.integrations.sponsorblock.player.PlayerType; import app.revanced.integrations.utils.LogHelper; import app.revanced.integrations.utils.SharedPrefHelper; @@ -222,7 +202,7 @@ public abstract class SponsorBlockUtils { for (int i = 0; i < voteOptions.length; i++) { VoteOption voteOption = voteOptions[i]; String title = voteOption.title; - if (vip && segment.isLocked && voteOption.shouldHighlight) { + if (SettingsEnum.SB_IS_VIP_BOOLEAN.getBoolean() && segment.isLocked && voteOption.shouldHighlight) { items[i] = Html.fromHtml(String.format("%s", LOCKED_COLOR, title)); } else { items[i] = title; @@ -247,7 +227,7 @@ public abstract class SponsorBlockUtils { }; private static final Runnable submitRunnable = () -> { messageToToast = null; - final String uuid = SponsorBlockSettings.uuid; + final String uuid = SettingsEnum.SB_UUID_STRING.getString(); final long start = newSponsorSegmentStartMillis; final long end = newSponsorSegmentEndMillis; final String videoId = getCurrentVideoId(); @@ -424,7 +404,7 @@ public abstract class SponsorBlockUtils { } public static String appendTimeWithoutSegments(String totalTime) { - if (videoHasSegments && isSettingEnabled(showTimeWithoutSegments) && !TextUtils.isEmpty(totalTime) && getCurrentVideoLength() > 1) { + if (videoHasSegments && (SettingsEnum.SB_ENABLED_BOOLEAN.getBoolean() && SettingsEnum.SB_SHOW_TIME_WITHOUT_SEGMENTS_BOOLEAN.getBoolean()) && !TextUtils.isEmpty(totalTime) && getCurrentVideoLength() > 1) { if (timeWithoutSegments.isEmpty()) { timeWithoutSegments = getTimeWithoutSegments(sponsorSegmentsOfCurrentVideo); } @@ -436,7 +416,7 @@ public abstract class SponsorBlockUtils { public static String getTimeWithoutSegments(SponsorSegment[] sponsorSegmentsOfCurrentVideo) { long currentVideoLength = getCurrentVideoLength(); - if (!isSettingEnabled(showTimeWithoutSegments) || sponsorSegmentsOfCurrentVideo == null || currentVideoLength <= 1) { + if (!(SettingsEnum.SB_ENABLED_BOOLEAN.getBoolean() && SettingsEnum.SB_SHOW_TIME_WITHOUT_SEGMENTS_BOOLEAN.getBoolean()) || sponsorSegmentsOfCurrentVideo == null || currentVideoLength <= 1) { return ""; } long timeWithoutSegments = currentVideoLength + 500; // YouTube:tm: @@ -516,10 +496,10 @@ public abstract class SponsorBlockUtils { { Preference preference = new Preference(context); category.addPreference(preference); - String formatted = FORMATTER.format(skippedSegments); + String formatted = FORMATTER.format(SettingsEnum.SB_SKIPPED_SEGMENTS_INTEGER.getInt()); - long hoursSaved = skippedTime / 3600000; - double minutesSaved = (skippedTime / 60000d) % 60; + long hoursSaved = SettingsEnum.SB_SKIPPED_SEGMENTS_TIME_LONG.getLong() / 3600000; + double minutesSaved = (SettingsEnum.SB_SKIPPED_SEGMENTS_TIME_LONG.getLong() / 60000d) % 60; String formattedSaved = String.format(SAVED_TEMPLATE, hoursSaved, minutesSaved, minutesStr); preference.setTitle(fromHtml(str("stats_self_saved", formatted))); @@ -543,7 +523,7 @@ public abstract class SponsorBlockUtils { JSONObject categoryObject = barTypesObject.getJSONObject(categoryKey); String color = categoryObject.getString("color"); - editor.putString(categoryKey + PREFERENCES_KEY_CATEGORY_COLOR_SUFFIX, color); + editor.putString(categoryKey + SponsorBlockSettings.CATEGORY_COLOR_SUFFIX, color); editor.putString(categoryKey, SponsorBlockSettings.SegmentBehaviour.IGNORE.key); } @@ -562,21 +542,20 @@ public abstract class SponsorBlockUtils { editor.putString(category.key, behaviour.key); } - 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.putBoolean(PREFERENCES_KEY_IS_VIP, settingsJson.getBoolean("isVip")); - editor.putString(PREFERENCES_KEY_MIN_DURATION, settingsJson.getString("minDuration")); - editor.putString(PREFERENCES_KEY_UUID, settingsJson.getString("userID")); - editor.putString(PREFERENCES_KEY_LAST_VIP_CHECK, settingsJson.getString("lastIsVipUpdate")); + SettingsEnum.SB_SHOW_TOAST_WHEN_SKIP_BOOLEAN.saveValue(!settingsJson.getBoolean("dontShowNotice")); + SettingsEnum.SB_SHOW_TIME_WITHOUT_SEGMENTS_BOOLEAN.saveValue(settingsJson.getBoolean("showTimeWithSkips")); + SettingsEnum.SB_COUNT_SKIPS_BOOLEAN.saveValue(settingsJson.getBoolean("trackViewCount")); + SettingsEnum.SB_IS_VIP_BOOLEAN.saveValue(settingsJson.getBoolean("isVip")); + SettingsEnum.SB_MIN_DURATION_FLOAT.saveValue(Float.valueOf(settingsJson.getString("minDuration"))); + SettingsEnum.SB_UUID_STRING.saveValue(settingsJson.getString("userID")); + SettingsEnum.SB_LAST_VIP_CHECK_LONG.saveValue(settingsJson.getLong("lastIsVipUpdate")); + String serverAddress = settingsJson.getString("serverAddress"); - if (serverAddress.equalsIgnoreCase(DEFAULT_SERVER_URL)) { - serverAddress = DEFAULT_API_URL; + if (serverAddress.equalsIgnoreCase("https://sponsor.ajay.app")) { + serverAddress = (String) SettingsEnum.SB_API_URL_STRING.getDefaultValue(); } - editor.putString(PREFERENCES_KEY_API_URL, serverAddress); - - editor.apply(); + SettingsEnum.SB_API_URL_STRING.saveValue(serverAddress); Toast.makeText(context, str("settings_import_successful"), Toast.LENGTH_SHORT).show(); } catch (Exception ex) { @@ -607,21 +586,16 @@ public abstract class SponsorBlockUtils { categorySelectionsArray.put(behaviorObject); } } - json.put("dontShowNotice", !showToastWhenSkippedAutomatically); + json.put("dontShowNotice", !SettingsEnum.SB_SHOW_TOAST_WHEN_SKIP_BOOLEAN.getBoolean()); json.put("barTypes", barTypesObject); - json.put("showTimeWithSkips", showTimeWithoutSegments); - json.put("minDuration", minDuration); - json.put("trackViewCount", countSkips); + json.put("showTimeWithSkips", SettingsEnum.SB_SHOW_TIME_WITHOUT_SEGMENTS_BOOLEAN.getBoolean()); + json.put("minDuration", SettingsEnum.SB_MIN_DURATION_FLOAT.getFloat()); + json.put("trackViewCount", SettingsEnum.SB_COUNT_SKIPS_BOOLEAN.getBoolean()); json.put("categorySelections", categorySelectionsArray); - json.put("userID", uuid); - json.put("isVip", vip); - json.put("lastIsVipUpdate", lastVipCheck); - - String apiAddress = apiUrl; - if (apiAddress.equalsIgnoreCase(DEFAULT_API_URL)) { - apiAddress = DEFAULT_SERVER_URL; - } - json.put("serverAddress", apiAddress); + json.put("userID", SettingsEnum.SB_UUID_STRING.getString()); + json.put("isVip", SettingsEnum.SB_IS_VIP_BOOLEAN.getBoolean()); + json.put("lastIsVipUpdate", SettingsEnum.SB_LAST_VIP_CHECK_LONG.getLong()); + json.put("serverAddress", SettingsEnum.SB_API_URL_STRING.getString()); return json.toString(); } catch (Exception ex) { @@ -631,12 +605,8 @@ public abstract class SponsorBlockUtils { } } - public static boolean isSettingEnabled(boolean setting) { - return isSponsorBlockEnabled && setting; - } - public static boolean isSBButtonEnabled(Context context, String key) { - return isSettingEnabled(SharedPrefHelper.getBoolean(context, SharedPrefHelper.SharedPrefNames.SPONSOR_BLOCK, key, false)); + return SettingsEnum.SB_ENABLED_BOOLEAN.getBoolean() && SharedPrefHelper.getBoolean(context, SharedPrefHelper.SharedPrefNames.SPONSOR_BLOCK, key, false); } public enum VoteOption { diff --git a/app/src/main/java/app/revanced/integrations/sponsorblock/VotingButton.java b/app/src/main/java/app/revanced/integrations/sponsorblock/VotingButton.java index 531072c3..3e8e7e1f 100644 --- a/app/src/main/java/app/revanced/integrations/sponsorblock/VotingButton.java +++ b/app/src/main/java/app/revanced/integrations/sponsorblock/VotingButton.java @@ -13,6 +13,7 @@ import java.lang.ref.WeakReference; import static app.revanced.integrations.sponsorblock.PlayerController.getCurrentVideoLength; import static app.revanced.integrations.sponsorblock.PlayerController.getLastKnownVideoTime; +import app.revanced.integrations.settings.SettingsEnum; import app.revanced.integrations.utils.LogHelper; import app.revanced.integrations.utils.ReVancedUtils; @@ -93,7 +94,7 @@ public class VotingButton { } static boolean shouldBeShown() { - return SponsorBlockUtils.isSettingEnabled(SponsorBlockSettings.isVotingEnabled); + return SettingsEnum.SB_ENABLED_BOOLEAN.getBoolean() && SettingsEnum.SB_VOTING_ENABLED_BOOLEAN.getBoolean(); } //region Helpers diff --git a/app/src/main/java/app/revanced/integrations/sponsorblock/dialog/Dialogs.java b/app/src/main/java/app/revanced/integrations/sponsorblock/dialog/Dialogs.java index 7bb0b131..239911e7 100644 --- a/app/src/main/java/app/revanced/integrations/sponsorblock/dialog/Dialogs.java +++ b/app/src/main/java/app/revanced/integrations/sponsorblock/dialog/Dialogs.java @@ -1,9 +1,5 @@ package app.revanced.integrations.sponsorblock.dialog; -import static app.revanced.integrations.ryd.RYDSettings.PREFERENCES_KEY_RYD_ENABLED; -import static app.revanced.integrations.ryd.RYDSettings.PREFERENCES_KEY_RYD_HINT_SHOWN; -import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.PREFERENCES_KEY_SPONSOR_BLOCK_ENABLED; -import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.PREFERENCES_KEY_SPONSOR_BLOCK_HINT_SHOWN; import static app.revanced.integrations.sponsorblock.StringRef.str; import android.app.Activity; @@ -15,6 +11,7 @@ import android.graphics.LightingColorFilter; import android.net.Uri; import android.os.Build; +import app.revanced.integrations.settings.SettingsEnum; import app.revanced.integrations.utils.ReVancedUtils; import app.revanced.integrations.utils.SharedPrefHelper; @@ -26,14 +23,14 @@ public class Dialogs { private static void sbFirstRun(Activity activity) { Context context = ReVancedUtils.getContext(); - boolean enabled = SharedPrefHelper.getBoolean(context, SharedPrefHelper.SharedPrefNames.RYD, PREFERENCES_KEY_SPONSOR_BLOCK_ENABLED, false); - boolean hintShown = SharedPrefHelper.getBoolean(context, SharedPrefHelper.SharedPrefNames.RYD, PREFERENCES_KEY_SPONSOR_BLOCK_HINT_SHOWN, false); + boolean enabled = SettingsEnum.SB_ENABLED_BOOLEAN.getBoolean(); + boolean hintShown = SettingsEnum.SB_SPONSOR_BLOCK_HINT_SHOWN_BOOLEAN.getBoolean(); // If SB is enabled or hint has been shown, exit if (enabled || hintShown) { // If SB is enabled but hint hasn't been shown, mark it as shown if (enabled && !hintShown) { - SharedPrefHelper.saveBoolean(context, SharedPrefHelper.SharedPrefNames.RYD, PREFERENCES_KEY_SPONSOR_BLOCK_HINT_SHOWN, true); + SettingsEnum.SB_SPONSOR_BLOCK_HINT_SHOWN_BOOLEAN.saveValue(true); } return; } @@ -50,15 +47,15 @@ public class Dialogs { builder.setMessage(str("vanced_sb_firstrun")); builder.setPositiveButton(str("vanced_enable"), (dialog, id) -> { - SharedPrefHelper.saveBoolean(context, SharedPrefHelper.SharedPrefNames.RYD, PREFERENCES_KEY_SPONSOR_BLOCK_HINT_SHOWN, true); - SharedPrefHelper.saveBoolean(context, SharedPrefHelper.SharedPrefNames.RYD, PREFERENCES_KEY_SPONSOR_BLOCK_ENABLED, true); + SettingsEnum.SB_SPONSOR_BLOCK_HINT_SHOWN_BOOLEAN.saveValue(true); + SettingsEnum.SB_ENABLED_BOOLEAN.saveValue(true); dialog.dismiss(); }); builder.setNegativeButton(str("vanced_disable"), (dialog, id) -> { - SharedPrefHelper.saveBoolean(context, SharedPrefHelper.SharedPrefNames.RYD, PREFERENCES_KEY_SPONSOR_BLOCK_HINT_SHOWN, true); - SharedPrefHelper.saveBoolean(context, SharedPrefHelper.SharedPrefNames.RYD, PREFERENCES_KEY_SPONSOR_BLOCK_ENABLED, false); + SettingsEnum.SB_SPONSOR_BLOCK_HINT_SHOWN_BOOLEAN.saveValue(true); + SettingsEnum.SB_ENABLED_BOOLEAN.saveValue(false); dialog.dismiss(); }); diff --git a/app/src/main/java/app/revanced/integrations/sponsorblock/objects/EditTextListPreference.java b/app/src/main/java/app/revanced/integrations/sponsorblock/objects/EditTextListPreference.java index 25a0942f..5caacfdf 100644 --- a/app/src/main/java/app/revanced/integrations/sponsorblock/objects/EditTextListPreference.java +++ b/app/src/main/java/app/revanced/integrations/sponsorblock/objects/EditTextListPreference.java @@ -115,7 +115,7 @@ public class EditTextListPreference extends ListPreference { } private String getColorPreferenceKey() { - return getKey() + SponsorBlockSettings.PREFERENCES_KEY_CATEGORY_COLOR_SUFFIX; + return getKey() + SponsorBlockSettings.CATEGORY_COLOR_SUFFIX; } private void reformatTitle() { diff --git a/app/src/main/java/app/revanced/integrations/sponsorblock/player/ui/NewSegmentLayout.java b/app/src/main/java/app/revanced/integrations/sponsorblock/player/ui/NewSegmentLayout.java index 567de5bf..d6aa5164 100644 --- a/app/src/main/java/app/revanced/integrations/sponsorblock/player/ui/NewSegmentLayout.java +++ b/app/src/main/java/app/revanced/integrations/sponsorblock/player/ui/NewSegmentLayout.java @@ -13,6 +13,7 @@ import android.widget.FrameLayout; import android.widget.ImageButton; import android.widget.LinearLayout; +import app.revanced.integrations.settings.SettingsEnum; import app.revanced.integrations.utils.LogHelper; import app.revanced.integrations.sponsorblock.NewSegmentHelperLayout; import app.revanced.integrations.sponsorblock.PlayerController; @@ -69,7 +70,7 @@ public class NewSegmentLayout extends FrameLayout { @Override public void onClick(View v) { LogHelper.debug(NewSegmentLayout.class, "Rewind button clicked"); - PlayerController.skipRelativeMilliseconds(-SponsorBlockSettings.adjustNewSegmentMillis); + PlayerController.skipRelativeMilliseconds(-SettingsEnum.SB_ADJUST_NEW_SEGMENT_STEP_INTEGER.getInt()); } }); } @@ -80,7 +81,7 @@ public class NewSegmentLayout extends FrameLayout { @Override public void onClick(View v) { LogHelper.debug(NewSegmentLayout.class, "Forward button clicked"); - PlayerController.skipRelativeMilliseconds(SponsorBlockSettings.adjustNewSegmentMillis); + PlayerController.skipRelativeMilliseconds(SettingsEnum.SB_ADJUST_NEW_SEGMENT_STEP_INTEGER.getInt()); } }); } diff --git a/app/src/main/java/app/revanced/integrations/sponsorblock/player/ui/SBBrowserButton.java b/app/src/main/java/app/revanced/integrations/sponsorblock/player/ui/SBBrowserButton.java index 02ab4bc6..299548a4 100644 --- a/app/src/main/java/app/revanced/integrations/sponsorblock/player/ui/SBBrowserButton.java +++ b/app/src/main/java/app/revanced/integrations/sponsorblock/player/ui/SBBrowserButton.java @@ -8,6 +8,7 @@ import android.net.Uri; import android.view.View; import android.view.ViewGroup; +import app.revanced.integrations.settings.SettingsEnum; import app.revanced.integrations.sponsorblock.player.VideoInformation; import app.revanced.integrations.utils.ReVancedUtils; import app.revanced.integrations.sponsorblock.SponsorBlockSettings; @@ -18,7 +19,7 @@ public class SBBrowserButton extends SlimButton { public SBBrowserButton(Context context, ViewGroup container) { super(context, container, SLIM_METADATA_BUTTON_ID, - SponsorBlockUtils.isSBButtonEnabled(context, SponsorBlockSettings.PREFERENCES_KEY_BROWSER_BUTTON)); + SponsorBlockUtils.isSBButtonEnabled(context, SettingsEnum.SB_SHOW_BROWSER_BUTTON_BOOLEAN.getPath())); initialize(); } diff --git a/app/src/main/java/app/revanced/integrations/sponsorblock/player/ui/SlimButtonContainer.java b/app/src/main/java/app/revanced/integrations/sponsorblock/player/ui/SlimButtonContainer.java index b1af35a8..7678125d 100644 --- a/app/src/main/java/app/revanced/integrations/sponsorblock/player/ui/SlimButtonContainer.java +++ b/app/src/main/java/app/revanced/integrations/sponsorblock/player/ui/SlimButtonContainer.java @@ -1,7 +1,5 @@ package app.revanced.integrations.sponsorblock.player.ui; -import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.PREFERENCES_KEY_BROWSER_BUTTON; -import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.PREFERENCES_KEY_SPONSOR_BLOCK_ENABLED; import android.content.Context; import android.content.SharedPreferences; @@ -13,10 +11,10 @@ import com.google.android.apps.youtube.app.ui.SlimMetadataScrollableButtonContai import app.revanced.integrations.adremover.whitelist.Whitelist; import app.revanced.integrations.adremover.whitelist.WhitelistType; +import app.revanced.integrations.settings.SettingsEnum; import app.revanced.integrations.utils.LogHelper; import app.revanced.integrations.utils.SharedPrefHelper; import app.revanced.integrations.utils.ReVancedUtils; -import app.revanced.integrations.sponsorblock.SponsorBlockSettings; public class SlimButtonContainer extends SlimMetadataScrollableButtonContainerLayout { @@ -78,9 +76,9 @@ public class SlimButtonContainer extends SlimMetadataScrollableButtonContainerLa copyWithTimestampButton.setVisible(ButtonVisibility.isVisibleInContainer(context, "pref_copy_video_url_timestamp_button_list")); return; } - if (PREFERENCES_KEY_SPONSOR_BLOCK_ENABLED.equals(key)) { + if (SettingsEnum.SB_ENABLED_BOOLEAN.getPath().equals(key)) { if (sbWhitelistButton != null) { - if (SponsorBlockSettings.isSponsorBlockEnabled) { + if (SettingsEnum.SB_ENABLED_BOOLEAN.getBoolean()) { toggleWhitelistButton(); } else { Whitelist.setEnabled(WhitelistType.SPONSORBLOCK, false); @@ -88,14 +86,14 @@ public class SlimButtonContainer extends SlimMetadataScrollableButtonContainerLa } } if (sbBrowserButton != null) { - if (SponsorBlockSettings.isSponsorBlockEnabled) { + if (SettingsEnum.SB_ENABLED_BOOLEAN.getBoolean()) { toggleBrowserButton(); } else { sbBrowserButton.setVisible(false); } } } - if (PREFERENCES_KEY_BROWSER_BUTTON.equals(key) && sbBrowserButton != null) { + if (SettingsEnum.SB_SHOW_BROWSER_BUTTON_BOOLEAN.getPath().equals(key) && sbBrowserButton != null) { toggleBrowserButton(); return; } @@ -131,6 +129,6 @@ public class SlimButtonContainer extends SlimMetadataScrollableButtonContainerLa } private void toggleBrowserButton() { - sbBrowserButton.setVisible(SharedPrefHelper.getBoolean(context, SharedPrefHelper.SharedPrefNames.SPONSOR_BLOCK, PREFERENCES_KEY_BROWSER_BUTTON, false)); + sbBrowserButton.setVisible(SettingsEnum.SB_SHOW_BROWSER_BUTTON_BOOLEAN.getBoolean()); } } diff --git a/app/src/main/java/app/revanced/integrations/sponsorblock/requests/SBRequester.java b/app/src/main/java/app/revanced/integrations/sponsorblock/requests/SBRequester.java index f414ca0e..55a4db5a 100644 --- a/app/src/main/java/app/revanced/integrations/sponsorblock/requests/SBRequester.java +++ b/app/src/main/java/app/revanced/integrations/sponsorblock/requests/SBRequester.java @@ -25,6 +25,7 @@ import java.util.concurrent.TimeUnit; import app.revanced.integrations.adremover.whitelist.requests.Requester; import app.revanced.integrations.adremover.whitelist.requests.Route; +import app.revanced.integrations.settings.SettingsEnum; import app.revanced.integrations.sponsorblock.PlayerController; import app.revanced.integrations.sponsorblock.SponsorBlockSettings; import app.revanced.integrations.sponsorblock.SponsorBlockUtils; @@ -56,7 +57,7 @@ public class SBRequester { long start = (long) (segment.getDouble(0) * 1000); long end = (long) (segment.getDouble(1) * 1000); - long minDuration = (long) (SponsorBlockSettings.minDuration * 1000); + long minDuration = (long) (SettingsEnum.SB_MIN_DURATION_FLOAT.getFloat() * 1000); if ((end - start) < minDuration) continue; @@ -127,7 +128,7 @@ public class SBRequester { new Thread(() -> { try { String segmentUuid = segment.UUID; - String uuid = SponsorBlockSettings.uuid; + String uuid = SettingsEnum.SB_UUID_STRING.getString(); String vote = Integer.toString(voteOption == VoteOption.UPVOTE ? 1 : 0); runOnMainThread(() -> Toast.makeText(context, str("vote_started"), Toast.LENGTH_SHORT).show()); @@ -157,14 +158,14 @@ public class SBRequester { } public static void retrieveUserStats(PreferenceCategory category, Preference loadingPreference) { - if (!SponsorBlockSettings.isSponsorBlockEnabled) { + if (!SettingsEnum.SB_ENABLED_BOOLEAN.getBoolean()) { loadingPreference.setTitle(str("stats_sb_disabled")); return; } new Thread(() -> { try { - JSONObject json = getJSONObject(SBRoutes.GET_USER_STATS, SponsorBlockSettings.uuid); + JSONObject json = getJSONObject(SBRoutes.GET_USER_STATS, SettingsEnum.SB_UUID_STRING.getString()); UserStats stats = new UserStats(json.getString("userName"), json.getDouble("minutesSaved"), json.getInt("segmentCount"), json.getInt("viewCount")); SponsorBlockUtils.addUserStats(category, loadingPreference, stats); @@ -177,7 +178,7 @@ public class SBRequester { public static void setUsername(String username, EditTextPreference preference, Runnable toastRunnable) { new Thread(() -> { try { - HttpURLConnection connection = getConnectionFromRoute(SBRoutes.CHANGE_USERNAME, SponsorBlockSettings.uuid, username); + HttpURLConnection connection = getConnectionFromRoute(SBRoutes.CHANGE_USERNAME, SettingsEnum.SB_UUID_STRING.getString(), username); int responseCode = connection.getResponseCode(); if (responseCode == 200) { @@ -199,19 +200,14 @@ public class SBRequester { public static void runVipCheck() { long now = System.currentTimeMillis(); - if (now < (SponsorBlockSettings.lastVipCheck + TimeUnit.DAYS.toMillis(3))) { + if (now < (SettingsEnum.SB_LAST_VIP_CHECK_LONG.getFloat() + TimeUnit.DAYS.toMillis(3))) { return; } try { - JSONObject json = getJSONObject(SBRoutes.IS_USER_VIP, SponsorBlockSettings.uuid); + JSONObject json = getJSONObject(SBRoutes.IS_USER_VIP, SettingsEnum.SB_UUID_STRING.getString()); boolean vip = json.getBoolean("vip"); - SponsorBlockSettings.vip = vip; - SponsorBlockSettings.lastVipCheck = now; - - SharedPreferences.Editor edit = SharedPrefHelper.getPreferences(ReVancedUtils.getContext(), SharedPrefHelper.SharedPrefNames.SPONSOR_BLOCK).edit(); - edit.putString(SponsorBlockSettings.PREFERENCES_KEY_LAST_VIP_CHECK, String.valueOf(now)); - edit.putBoolean(SponsorBlockSettings.PREFERENCES_KEY_IS_VIP, vip); - edit.apply(); + SettingsEnum.SB_IS_VIP_BOOLEAN.saveValue(vip); + SettingsEnum.SB_LAST_VIP_CHECK_LONG.saveValue(now); } catch (Exception ex) { ex.printStackTrace(); } @@ -220,7 +216,7 @@ public class SBRequester { // helpers private static HttpURLConnection getConnectionFromRoute(Route route, String... params) throws IOException { - return Requester.getConnectionFromRoute(SponsorBlockSettings.apiUrl, route, params); + return Requester.getConnectionFromRoute(SettingsEnum.SB_API_URL_STRING.getString(), route, params); } private static JSONObject getJSONObject(Route route, String... params) throws Exception { diff --git a/app/src/main/java/app/revanced/integrations/utils/LogHelper.java b/app/src/main/java/app/revanced/integrations/utils/LogHelper.java index 9fc2a4bf..0103b676 100644 --- a/app/src/main/java/app/revanced/integrations/utils/LogHelper.java +++ b/app/src/main/java/app/revanced/integrations/utils/LogHelper.java @@ -11,19 +11,19 @@ public class LogHelper { public static void debug(Class clazz, String message) { if (SettingsEnum.DEBUG_BOOLEAN.getBoolean()) { - Log.d("ReVanced: " + clazz != null ? clazz.getSimpleName() : "", message); + Log.e("ReVanced: " + (clazz != null ? clazz.getSimpleName() : ""), message); } } public static void printException(Class clazz, String message, Throwable ex) { - Log.e("ReVanced: " + clazz != null ? clazz.getName() : "", message, ex); + Log.e("ReVanced: " + (clazz != null ? clazz.getSimpleName() : ""), message, ex); } public static void printException(Class clazz, String message) { - Log.e("ReVanced: " + clazz != null ? clazz.getName() : "", message); + Log.e("ReVanced: " + (clazz != null ? clazz.getSimpleName() : ""), message); } public static void info(Class clazz, String message) { - Log.i("ReVanced: " + clazz != null ? clazz.getSimpleName() : "", message); + Log.i("ReVanced: " + (clazz != null ? clazz.getSimpleName() : ""), message); } } diff --git a/app/src/main/java/app/revanced/integrations/utils/ReVancedUtils.java b/app/src/main/java/app/revanced/integrations/utils/ReVancedUtils.java index 1ead2e8e..ae1ce798 100644 --- a/app/src/main/java/app/revanced/integrations/utils/ReVancedUtils.java +++ b/app/src/main/java/app/revanced/integrations/utils/ReVancedUtils.java @@ -12,11 +12,14 @@ import android.os.Looper; import com.google.android.apps.youtube.app.YouTubeTikTokRoot_Application; +import app.revanced.integrations.settings.SettingsEnum; import app.revanced.integrations.sponsorblock.player.PlayerType; +import app.revanced.integrations.videoplayer.videosettings.VideoSpeed; public class ReVancedUtils { private static PlayerType env; + private static boolean newVideo = false; //Used by Integrations patch public static Context context; @@ -29,6 +32,15 @@ public class ReVancedUtils { return null; } + public static void setNewVideo(boolean started) { + LogHelper.debug(ReVancedUtils.class, "New video started: " + started); + newVideo = started; + } + + public static boolean isNewVideoStarted() { + return newVideo; + } + public static String getStringByName(Context context, String name) { try { Resources res = context.getResources(); @@ -94,23 +106,4 @@ public class ReVancedUtils { return null; } } - - //Not used atm - /*public static String getManufacturer() { - String manufacturer = SettingsEnum.MANUFACTURER_OVERRIDE_STRING.getString(); - if (manufacturer == null || manufacturer.isEmpty()) { - manufacturer = Build.MANUFACTURER; - } - LogHelper.debug("Settings", "getManufacturer: " + manufacturer); - return manufacturer; - } - - public static String getModel() { - String model = SettingsEnum.MODEL_OVERRIDE_STRING.getString(); - if (model == null || model.isEmpty()) { - model = Build.MODEL; - } - LogHelper.debug("Settings", "getModel: " + model); - return model; - }*/ } \ No newline at end of file diff --git a/app/src/main/java/app/revanced/integrations/videoplayer/videosettings/VideoQuality.java b/app/src/main/java/app/revanced/integrations/videoplayer/videosettings/VideoQuality.java index 1356bd1d..5f44332b 100644 --- a/app/src/main/java/app/revanced/integrations/videoplayer/videosettings/VideoQuality.java +++ b/app/src/main/java/app/revanced/integrations/videoplayer/videosettings/VideoQuality.java @@ -16,25 +16,23 @@ import java.util.Collections; public class VideoQuality { public static final int[] videoResolutions = {0, 144, 240, 360, 480, 720, 1080, 1440, 2160}; private static Boolean userChangedQuality = false; - private static Boolean newVideo = false; public static void userChangedQuality() { userChangedQuality = true; - newVideo = false; } public static int setVideoQuality(Object[] qualities, int quality, Object qInterface) { int preferredQuality; Field[] fields; - if (!newVideo || userChangedQuality || qInterface == null) { + if (!ReVancedUtils.isNewVideoStarted() || userChangedQuality || qInterface == null) { if (SettingsEnum.DEBUG_BOOLEAN.getBoolean() && userChangedQuality) { LogHelper.debug(VideoQuality.class, "Skipping quality change because user changed it: " + quality); } userChangedQuality = false; return quality; } - newVideo = false; + ReVancedUtils.setNewVideo(false); LogHelper.debug(VideoQuality.class, "Quality: " + quality); Context context = ReVancedUtils.getContext(); if (context == null) { diff --git a/app/src/main/java/app/revanced/integrations/videoplayer/videosettings/VideoSpeed.java b/app/src/main/java/app/revanced/integrations/videoplayer/videosettings/VideoSpeed.java index 625ca126..acf25c65 100644 --- a/app/src/main/java/app/revanced/integrations/videoplayer/videosettings/VideoSpeed.java +++ b/app/src/main/java/app/revanced/integrations/videoplayer/videosettings/VideoSpeed.java @@ -4,6 +4,7 @@ package app.revanced.integrations.videoplayer.videosettings; import app.revanced.integrations.settings.SettingsEnum; import app.revanced.integrations.utils.LogHelper; import app.revanced.integrations.settings.Settings; +import app.revanced.integrations.utils.ReVancedUtils; import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; @@ -15,15 +16,14 @@ import java.util.Iterator; public class VideoSpeed { public static final float[] videoSpeeds = {0.25f, 0.5f, 0.75f, 1.0f, 1.25f, 1.5f, 1.75f, 2.0f, 3.0f, 4.0f, 5.0f}; private static Boolean userChangedSpeed = false; - private static Boolean newVideoSpeed = false; - public static int DefaultSpeed(Object[] speeds, int speed, Object qInterface) { + public static int getDefaultSpeed(Object[] speeds, int speed, Object qInterface) { int speed2; Exception e; - if (!newVideoSpeed) { + if (!ReVancedUtils.isNewVideoStarted()) { return speed; } - newVideoSpeed = false; + ReVancedUtils.setNewVideo(false); LogHelper.debug(VideoSpeed.class, "Speed: " + speed); float preferredSpeed = SettingsEnum.PREFERRED_VIDEO_SPEED_FLOAT.getFloat(); LogHelper.debug(VideoSpeed.class, "Preferred speed: " + preferredSpeed); @@ -93,25 +93,18 @@ public class VideoSpeed { public static void userChangedSpeed() { userChangedSpeed = true; - newVideoSpeed = false; - } - - - public static void NewVideoStarted() { - newVideoSpeed = true; - LogHelper.debug(VideoSpeed.class, "New video started!"); } public static float getSpeedValue(Object[] speeds, int speed) { int i = 0; - if (!newVideoSpeed || userChangedSpeed) { + if (!ReVancedUtils.isNewVideoStarted() || userChangedSpeed) { if (SettingsEnum.DEBUG_BOOLEAN.getBoolean() && userChangedSpeed) { LogHelper.debug(VideoSpeed.class, "Skipping speed change because user changed it: " + speed); } userChangedSpeed = false; return -1.0f; } - newVideoSpeed = false; + ReVancedUtils.setNewVideo(false); LogHelper.debug(VideoSpeed.class, "Speed: " + speed); float preferredSpeed = SettingsEnum.PREFERRED_VIDEO_SPEED_FLOAT.getFloat(); LogHelper.debug(VideoSpeed.class, "Preferred speed: " + preferredSpeed); diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index e615b651..700dbc0f 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1,12 +1,6 @@ - " -- xfileFIN (First creator) -- oSumAtrIX (Mods, Patcher, Support) -- TheJeterLP (Integrations) -- bogadana (Mods, Support) -- Sculas (Manager, Patcher) -- baiorett (Manager)" + " - xfileFIN (First creator) - oSumAtrIX (Patches, Patcher, Support) - TheJeterLP (Patches, Integrations) - bogadana (Patches, Support) - Sculas (Manager, Patcher) - baiorett (Manager)" About "Doesn't show auto-repeat button in the player overlay. Use the toggle below to control auto-repeat" Auto-repeat button is shown in the player overlay @@ -31,8 +25,6 @@ Default codec Tap to join ReVanced on Discord Discord server - Tap to enable hardware HDR - Samsung Galaxy S8+ Video brightness will follow your device\'s brightness on HDR landscape videos Video brightness is set to max on HDR landscape videos HDR max brightness @@ -62,8 +54,6 @@ Default: 5000" Rebuffer - Tap to enable software HDR - Google Pixel XL End screens are hidden End screens are shown End screens @@ -77,6 +67,9 @@ Wide search bar Search bar style is defined by the app Forcing wide search bar + Show shorts button + Shorts button is hidden + Shorts button is shown Dynamic player Dynamic player is defined automatically Dynamic player is forced on square and vertical videos @@ -101,13 +94,16 @@ Swipe controls for volume are enabled Swipe controls for Volume Tap to open our website - Vanced website + ReVanced website Home ADS are hidden Home ADS are shown - Home ADS (Experimental) + Home ADS + Video ADS + Video ADS are hidden + Video ADS are shown Stories are hidden Stories are shown - YouTube stories (Experimental) + YouTube stories AD settings Credits for people who have contributed Credits diff --git a/app/src/main/res/xml/revanced_prefs.xml b/app/src/main/res/xml/revanced_prefs.xml index 90424dbb..c0e40954 100644 --- a/app/src/main/res/xml/revanced_prefs.xml +++ b/app/src/main/res/xml/revanced_prefs.xml @@ -7,77 +7,73 @@ - - - - - - - - + + + + + - - - - - + + + + + - - - - - - - - - - - - + + + + + + + + + + + - - - - - - + + + + + + + - - - - - + + + + + + + + + + - - - - - + + + - + @@ -89,6 +85,6 @@ - - + + \ No newline at end of file