diff --git a/app/src/main/java/app/revanced/integrations/all/screencapture/removerestriction/RemoveScreencaptureRestrictionPatch.java b/app/src/main/java/app/revanced/integrations/all/screencapture/removerestriction/RemoveScreencaptureRestrictionPatch.java index c76d395d77..f4e4739b5f 100644 --- a/app/src/main/java/app/revanced/integrations/all/screencapture/removerestriction/RemoveScreencaptureRestrictionPatch.java +++ b/app/src/main/java/app/revanced/integrations/all/screencapture/removerestriction/RemoveScreencaptureRestrictionPatch.java @@ -5,6 +5,7 @@ import androidx.annotation.RequiresApi; +@SuppressWarnings("unused") public final class RemoveScreencaptureRestrictionPatch { // Member of AudioAttributes.Builder @RequiresApi(api = Build.VERSION_CODES.Q) diff --git a/app/src/main/java/app/revanced/integrations/all/screenshot/removerestriction/RemoveScreenshotRestrictionPatch.java b/app/src/main/java/app/revanced/integrations/all/screenshot/removerestriction/RemoveScreenshotRestrictionPatch.java index d2ebeb87be..710bb1958c 100644 --- a/app/src/main/java/app/revanced/integrations/all/screenshot/removerestriction/RemoveScreenshotRestrictionPatch.java +++ b/app/src/main/java/app/revanced/integrations/all/screenshot/removerestriction/RemoveScreenshotRestrictionPatch.java @@ -3,6 +3,7 @@ import android.view.Window; import android.view.WindowManager; +@SuppressWarnings("unused") public class RemoveScreenshotRestrictionPatch { public static void addFlags(Window window, int flags) { diff --git a/app/src/main/java/app/revanced/integrations/reddit/patches/FilterPromotedLinksPatch.java b/app/src/main/java/app/revanced/integrations/reddit/patches/FilterPromotedLinksPatch.java index de8469e2bb..6a97712e19 100644 --- a/app/src/main/java/app/revanced/integrations/reddit/patches/FilterPromotedLinksPatch.java +++ b/app/src/main/java/app/revanced/integrations/reddit/patches/FilterPromotedLinksPatch.java @@ -5,8 +5,12 @@ import java.util.ArrayList; import java.util.List; +@SuppressWarnings("unused") public final class FilterPromotedLinksPatch { + /** + * Injection point. + * * Filters list from promoted links. **/ public static List filterChildren(final Iterable links) { diff --git a/app/src/main/java/app/revanced/integrations/shared/GmsCoreSupport.java b/app/src/main/java/app/revanced/integrations/shared/GmsCoreSupport.java index cdd474a994..60a634eded 100644 --- a/app/src/main/java/app/revanced/integrations/shared/GmsCoreSupport.java +++ b/app/src/main/java/app/revanced/integrations/shared/GmsCoreSupport.java @@ -151,7 +151,11 @@ private static String getGmsCoreDownload() { } } - // Modified by a patch. Do not touch. + /** + * Modified by a patch. Do not touch. + * + * @noinspection SameReturnValue + */ private static String getGmsCoreVendorGroupId() { return "app.revanced"; } diff --git a/app/src/main/java/app/revanced/integrations/shared/Utils.java b/app/src/main/java/app/revanced/integrations/shared/Utils.java index 22ed1e0624..2254c8e1be 100644 --- a/app/src/main/java/app/revanced/integrations/shared/Utils.java +++ b/app/src/main/java/app/revanced/integrations/shared/Utils.java @@ -58,6 +58,7 @@ private Utils() { * Injection point. * * @return The manifest 'Version' entry of the patches.jar used during patching. + * @noinspection SameReturnValue */ @SuppressWarnings("SameReturnValue") public static String getPatchesReleaseVersion() { diff --git a/app/src/main/java/app/revanced/integrations/tiktok/feedfilter/AdsFilter.java b/app/src/main/java/app/revanced/integrations/tiktok/feedfilter/AdsFilter.java index c246e6226d..20a99aaeff 100644 --- a/app/src/main/java/app/revanced/integrations/tiktok/feedfilter/AdsFilter.java +++ b/app/src/main/java/app/revanced/integrations/tiktok/feedfilter/AdsFilter.java @@ -3,6 +3,7 @@ import app.revanced.integrations.tiktok.settings.Settings; import com.ss.android.ugc.aweme.feed.model.Aweme; +/** @noinspection unused*/ public class AdsFilter implements IFilter { @Override public boolean getEnabled() { diff --git a/app/src/main/java/app/revanced/integrations/tiktok/feedfilter/FeedItemsFilter.java b/app/src/main/java/app/revanced/integrations/tiktok/feedfilter/FeedItemsFilter.java index d74ea59ecc..d84bb2cafd 100644 --- a/app/src/main/java/app/revanced/integrations/tiktok/feedfilter/FeedItemsFilter.java +++ b/app/src/main/java/app/revanced/integrations/tiktok/feedfilter/FeedItemsFilter.java @@ -6,6 +6,7 @@ import java.util.Iterator; import java.util.List; +@SuppressWarnings("unused") public final class FeedItemsFilter { private static final List FILTERS = List.of( new AdsFilter(), @@ -16,6 +17,9 @@ public final class FeedItemsFilter { new LikeCountFilter() ); + /** + * Injection point. + */ public static void filter(FeedItemList feedItemList) { Iterator feedItemListIterator = feedItemList.items.iterator(); while (feedItemListIterator.hasNext()) { diff --git a/app/src/main/java/app/revanced/integrations/tiktok/feedfilter/ImageVideoFilter.java b/app/src/main/java/app/revanced/integrations/tiktok/feedfilter/ImageVideoFilter.java index 50472197e8..a0616cce39 100644 --- a/app/src/main/java/app/revanced/integrations/tiktok/feedfilter/ImageVideoFilter.java +++ b/app/src/main/java/app/revanced/integrations/tiktok/feedfilter/ImageVideoFilter.java @@ -3,6 +3,7 @@ import app.revanced.integrations.tiktok.settings.Settings; import com.ss.android.ugc.aweme.feed.model.Aweme; +@SuppressWarnings("unused") public class ImageVideoFilter implements IFilter { @Override public boolean getEnabled() { diff --git a/app/src/main/java/app/revanced/integrations/tiktok/feedfilter/LiveFilter.java b/app/src/main/java/app/revanced/integrations/tiktok/feedfilter/LiveFilter.java index bec7f11c48..27fa8b1b06 100644 --- a/app/src/main/java/app/revanced/integrations/tiktok/feedfilter/LiveFilter.java +++ b/app/src/main/java/app/revanced/integrations/tiktok/feedfilter/LiveFilter.java @@ -3,6 +3,7 @@ import app.revanced.integrations.tiktok.settings.Settings; import com.ss.android.ugc.aweme.feed.model.Aweme; +@SuppressWarnings("unused") public class LiveFilter implements IFilter { @Override public boolean getEnabled() { diff --git a/app/src/main/java/app/revanced/integrations/tiktok/settings/SettingsStatus.java b/app/src/main/java/app/revanced/integrations/tiktok/settings/SettingsStatus.java index 81c74be4b4..519a776a41 100644 --- a/app/src/main/java/app/revanced/integrations/tiktok/settings/SettingsStatus.java +++ b/app/src/main/java/app/revanced/integrations/tiktok/settings/SettingsStatus.java @@ -1,5 +1,6 @@ package app.revanced.integrations.tiktok.settings; +@SuppressWarnings("unused") public class SettingsStatus { public static boolean feedFilterEnabled = false; public static boolean downloadEnabled = false; @@ -17,6 +18,7 @@ public static void enableSimSpoof() { simSpoofEnabled = true; } + /** @noinspection EmptyMethod*/ public static void load() { } diff --git a/app/src/main/java/app/revanced/integrations/tiktok/settings/preference/ReVancedPreferenceFragment.java b/app/src/main/java/app/revanced/integrations/tiktok/settings/preference/ReVancedPreferenceFragment.java index 6635935064..4b981eca60 100644 --- a/app/src/main/java/app/revanced/integrations/tiktok/settings/preference/ReVancedPreferenceFragment.java +++ b/app/src/main/java/app/revanced/integrations/tiktok/settings/preference/ReVancedPreferenceFragment.java @@ -14,7 +14,7 @@ /** * Preference fragment for ReVanced settings */ -@SuppressWarnings("deprecation") +@SuppressWarnings({"deprecation", "unused"}) public class ReVancedPreferenceFragment extends AbstractPreferenceFragment { @Override @@ -33,6 +33,7 @@ protected void syncSettingWithPreference(@NonNull @NotNull Preference pref, } @Override + @SuppressWarnings("unused") protected void initialize() { final var context = getContext(); diff --git a/app/src/main/java/app/revanced/integrations/tiktok/settings/preference/categories/ConditionalPreferenceCategory.java b/app/src/main/java/app/revanced/integrations/tiktok/settings/preference/categories/ConditionalPreferenceCategory.java index 24eaa1e9a3..9f85c3f705 100644 --- a/app/src/main/java/app/revanced/integrations/tiktok/settings/preference/categories/ConditionalPreferenceCategory.java +++ b/app/src/main/java/app/revanced/integrations/tiktok/settings/preference/categories/ConditionalPreferenceCategory.java @@ -4,7 +4,7 @@ import android.preference.PreferenceCategory; import android.preference.PreferenceScreen; -@SuppressWarnings("deprecation") +@SuppressWarnings({"deprecation", "unused"}) public abstract class ConditionalPreferenceCategory extends PreferenceCategory { public ConditionalPreferenceCategory(Context context, PreferenceScreen screen) { super(context); diff --git a/app/src/main/java/app/revanced/integrations/tiktok/settings/preference/categories/DownloadsPreferenceCategory.java b/app/src/main/java/app/revanced/integrations/tiktok/settings/preference/categories/DownloadsPreferenceCategory.java index 8ecbfb3661..1bf0f6d602 100644 --- a/app/src/main/java/app/revanced/integrations/tiktok/settings/preference/categories/DownloadsPreferenceCategory.java +++ b/app/src/main/java/app/revanced/integrations/tiktok/settings/preference/categories/DownloadsPreferenceCategory.java @@ -7,7 +7,7 @@ import app.revanced.integrations.tiktok.settings.preference.DownloadPathPreference; import app.revanced.integrations.tiktok.settings.preference.TogglePreference; -@SuppressWarnings("deprecation") +@SuppressWarnings({"deprecation", "unused"}) public class DownloadsPreferenceCategory extends ConditionalPreferenceCategory { public DownloadsPreferenceCategory(Context context, PreferenceScreen screen) { super(context, screen); diff --git a/app/src/main/java/app/revanced/integrations/tiktok/settings/preference/categories/FeedFilterPreferenceCategory.java b/app/src/main/java/app/revanced/integrations/tiktok/settings/preference/categories/FeedFilterPreferenceCategory.java index 5bb40a2ea3..98d71855d3 100644 --- a/app/src/main/java/app/revanced/integrations/tiktok/settings/preference/categories/FeedFilterPreferenceCategory.java +++ b/app/src/main/java/app/revanced/integrations/tiktok/settings/preference/categories/FeedFilterPreferenceCategory.java @@ -7,7 +7,7 @@ import app.revanced.integrations.tiktok.settings.SettingsStatus; import app.revanced.integrations.tiktok.settings.preference.TogglePreference; -@SuppressWarnings("deprecation") +@SuppressWarnings({"deprecation", "unused"}) public class FeedFilterPreferenceCategory extends ConditionalPreferenceCategory { public FeedFilterPreferenceCategory(Context context, PreferenceScreen screen) { super(context, screen); diff --git a/app/src/main/java/app/revanced/integrations/tiktok/settings/preference/categories/IntegrationsPreferenceCategory.java b/app/src/main/java/app/revanced/integrations/tiktok/settings/preference/categories/IntegrationsPreferenceCategory.java index 96e6e892de..ec53d5f1c4 100644 --- a/app/src/main/java/app/revanced/integrations/tiktok/settings/preference/categories/IntegrationsPreferenceCategory.java +++ b/app/src/main/java/app/revanced/integrations/tiktok/settings/preference/categories/IntegrationsPreferenceCategory.java @@ -6,7 +6,7 @@ import app.revanced.integrations.shared.settings.BaseSettings; import app.revanced.integrations.tiktok.settings.preference.TogglePreference; -@SuppressWarnings("deprecation") +@SuppressWarnings({"deprecation", "unused"}) public class IntegrationsPreferenceCategory extends ConditionalPreferenceCategory { public IntegrationsPreferenceCategory(Context context, PreferenceScreen screen) { super(context, screen); diff --git a/app/src/main/java/app/revanced/integrations/tiktok/speed/PlaybackSpeedPatch.java b/app/src/main/java/app/revanced/integrations/tiktok/speed/PlaybackSpeedPatch.java index 1681ad0ca3..c5d15d788e 100644 --- a/app/src/main/java/app/revanced/integrations/tiktok/speed/PlaybackSpeedPatch.java +++ b/app/src/main/java/app/revanced/integrations/tiktok/speed/PlaybackSpeedPatch.java @@ -2,7 +2,9 @@ import app.revanced.integrations.tiktok.settings.Settings; +@SuppressWarnings("unused") public class PlaybackSpeedPatch { + public static void rememberPlaybackSpeed(float newSpeed) { Settings.REMEMBERED_SPEED.save(newSpeed); } diff --git a/app/src/main/java/app/revanced/integrations/twitch/settings/preference/CustomPreferenceCategory.java b/app/src/main/java/app/revanced/integrations/twitch/settings/preference/CustomPreferenceCategory.java index 64f0a3d811..a3238dedca 100644 --- a/app/src/main/java/app/revanced/integrations/twitch/settings/preference/CustomPreferenceCategory.java +++ b/app/src/main/java/app/revanced/integrations/twitch/settings/preference/CustomPreferenceCategory.java @@ -7,6 +7,7 @@ import android.view.View; import android.widget.TextView; +/** @noinspection unused*/ public class CustomPreferenceCategory extends PreferenceCategory { public CustomPreferenceCategory(Context context, AttributeSet attrs) { super(context, attrs); diff --git a/app/src/main/java/app/revanced/integrations/twitch/settings/preference/ReVancedPreferenceFragment.java b/app/src/main/java/app/revanced/integrations/twitch/settings/preference/ReVancedPreferenceFragment.java index 1d3cca4b2e..39fb5f0724 100644 --- a/app/src/main/java/app/revanced/integrations/twitch/settings/preference/ReVancedPreferenceFragment.java +++ b/app/src/main/java/app/revanced/integrations/twitch/settings/preference/ReVancedPreferenceFragment.java @@ -10,6 +10,7 @@ public class ReVancedPreferenceFragment extends AbstractPreferenceFragment { @Override + @SuppressWarnings("unused") protected void initialize() { super.initialize(); diff --git a/app/src/main/java/app/revanced/integrations/twitter/patches/links/OpenLinksWithAppChooserPatch.java b/app/src/main/java/app/revanced/integrations/twitter/patches/links/OpenLinksWithAppChooserPatch.java index 18ccaa7822..c2907414f6 100644 --- a/app/src/main/java/app/revanced/integrations/twitter/patches/links/OpenLinksWithAppChooserPatch.java +++ b/app/src/main/java/app/revanced/integrations/twitter/patches/links/OpenLinksWithAppChooserPatch.java @@ -4,7 +4,9 @@ import android.content.Intent; import android.util.Log; +@SuppressWarnings("unused") public final class OpenLinksWithAppChooserPatch { + public static void openWithChooser(final Context context, final Intent intent) { Log.d("ReVanced", "Opening intent with chooser: " + intent); diff --git a/app/src/main/java/app/revanced/integrations/youtube/ThemeHelper.java b/app/src/main/java/app/revanced/integrations/youtube/ThemeHelper.java index 65d29b97ea..8b0ffbfa52 100644 --- a/app/src/main/java/app/revanced/integrations/youtube/ThemeHelper.java +++ b/app/src/main/java/app/revanced/integrations/youtube/ThemeHelper.java @@ -38,6 +38,7 @@ public static void setActivityTheme(Activity activity) { /** * Injection point. + * @noinspection SameReturnValue */ @SuppressWarnings("SameReturnValue") private static String darkThemeResourceName() { @@ -58,6 +59,7 @@ public static int getDarkThemeColor() { /** * Injection point. + * @noinspection SameReturnValue */ @SuppressWarnings("SameReturnValue") private static String lightThemeResourceName() { diff --git a/app/src/main/java/app/revanced/integrations/youtube/patches/BypassURLRedirectsPatch.java b/app/src/main/java/app/revanced/integrations/youtube/patches/BypassURLRedirectsPatch.java index c49f8bbd0f..bc5ce486ef 100644 --- a/app/src/main/java/app/revanced/integrations/youtube/patches/BypassURLRedirectsPatch.java +++ b/app/src/main/java/app/revanced/integrations/youtube/patches/BypassURLRedirectsPatch.java @@ -18,7 +18,7 @@ public class BypassURLRedirectsPatch { public static Uri parseRedirectUri(String uri) { final var parsed = Uri.parse(uri); - if (Settings.BYPASS_URL_REDIRECTS.get() && parsed.getPath().equals(YOUTUBE_REDIRECT_PATH)) { + if (Settings.BYPASS_URL_REDIRECTS.get() && YOUTUBE_REDIRECT_PATH.equals(parsed.getPath())) { var query = Uri.parse(Uri.decode(parsed.getQueryParameter("q"))); Logger.printDebug(() -> "Bypassing YouTube redirect URI: " + query); diff --git a/app/src/main/java/app/revanced/integrations/youtube/patches/HDRAutoBrightnessPatch.java b/app/src/main/java/app/revanced/integrations/youtube/patches/HDRAutoBrightnessPatch.java deleted file mode 100644 index 3c6443083a..0000000000 --- a/app/src/main/java/app/revanced/integrations/youtube/patches/HDRAutoBrightnessPatch.java +++ /dev/null @@ -1,42 +0,0 @@ -package app.revanced.integrations.youtube.patches; - -import android.view.WindowManager; - -import app.revanced.integrations.youtube.settings.Settings; -import app.revanced.integrations.youtube.swipecontrols.SwipeControlsHostActivity; - -/** - * Patch class for 'hdr-auto-brightness' patch. - * - * Edit: This patch no longer does anything, as YT already uses BRIGHTNESS_OVERRIDE_NONE - * as the default brightness level. The hooked code was also removed from YT 19.09+ as well. - */ -@Deprecated -@SuppressWarnings("unused") -public class HDRAutoBrightnessPatch { - /** - * get brightness override for HDR brightness - * - * @param original brightness youtube would normally set - * @return brightness to set on HRD video - */ - public static float getHDRBrightness(float original) { - // do nothing if disabled - if (!Settings.HDR_AUTO_BRIGHTNESS.get()) { - return original; - } - - // override with brightness set by swipe-controls - // only when swipe-controls is active and has overridden the brightness - final SwipeControlsHostActivity swipeControlsHost = SwipeControlsHostActivity.getCurrentHost().get(); - if (swipeControlsHost != null - && swipeControlsHost.getScreen() != null - && swipeControlsHost.getConfig().getEnableBrightnessControl() - && !swipeControlsHost.getScreen().isDefaultBrightness()) { - return swipeControlsHost.getScreen().getRawScreenBrightness(); - } - - // otherwise, set the brightness to auto - return WindowManager.LayoutParams.BRIGHTNESS_OVERRIDE_NONE; - } -} diff --git a/app/src/main/java/app/revanced/integrations/youtube/patches/HideEmailAddressPatch.java b/app/src/main/java/app/revanced/integrations/youtube/patches/HideEmailAddressPatch.java deleted file mode 100644 index 3cbd5b1902..0000000000 --- a/app/src/main/java/app/revanced/integrations/youtube/patches/HideEmailAddressPatch.java +++ /dev/null @@ -1,17 +0,0 @@ -package app.revanced.integrations.youtube.patches; - -import app.revanced.integrations.youtube.settings.Settings; - -/** - * Patch is obsolete and will be deleted in a future release - */ -@SuppressWarnings("unused") -@Deprecated() -public class HideEmailAddressPatch { - //Used by app.revanced.patches.youtube.layout.personalinformation.patch.HideEmailAddressPatch - public static int hideEmailAddress(int originalValue) { - if (Settings.HIDE_EMAIL_ADDRESS.get()) - return 8; - return originalValue; - } -} diff --git a/app/src/main/java/app/revanced/integrations/youtube/patches/ReturnYouTubeDislikePatch.java b/app/src/main/java/app/revanced/integrations/youtube/patches/ReturnYouTubeDislikePatch.java index ec52ef076f..4b74a5ca82 100644 --- a/app/src/main/java/app/revanced/integrations/youtube/patches/ReturnYouTubeDislikePatch.java +++ b/app/src/main/java/app/revanced/integrations/youtube/patches/ReturnYouTubeDislikePatch.java @@ -91,99 +91,6 @@ private static void clearData() { // while a regular video is on screen. } - // - // 17.x non litho regular video player. - // - - /** - * Resource identifier of old UI dislike button. - */ - private static final int OLD_UI_DISLIKE_BUTTON_RESOURCE_ID - = Utils.getResourceIdentifier("dislike_button", "id"); - - /** - * Dislikes text label used by old UI. - */ - @NonNull - private static WeakReference oldUITextViewRef = new WeakReference<>(null); - - /** - * Original old UI 'Dislikes' text before patch modifications. - * Required to reset the dislikes when changing videos and RYD is not available. - * Set only once during the first load. - */ - private static Spanned oldUIOriginalSpan; - - /** - * Replacement span that contains dislike value. Used by {@link #oldUiTextWatcher}. - */ - @Nullable - private static Spanned oldUIReplacementSpan; - - /** - * Old UI dislikes can be set multiple times by YouTube. - * To prevent reverting changes made here, this listener overrides any future changes YouTube makes. - */ - private static final TextWatcher oldUiTextWatcher = new TextWatcher() { - public void beforeTextChanged(CharSequence s, int start, int count, int after) { - } - public void onTextChanged(CharSequence s, int start, int before, int count) { - } - public void afterTextChanged(Editable s) { - if (oldUIReplacementSpan == null || oldUIReplacementSpan.toString().equals(s.toString())) { - return; - } - s.replace(0, s.length(), oldUIReplacementSpan); // Causes a recursive call back into this listener - } - }; - - private static void updateOldUIDislikesTextView() { - ReturnYouTubeDislike videoData = currentVideoData; - if (videoData == null) { - return; - } - TextView oldUITextView = oldUITextViewRef.get(); - if (oldUITextView == null) { - return; - } - oldUIReplacementSpan = videoData.getDislikesSpanForRegularVideo(oldUIOriginalSpan, false, false); - if (!oldUIReplacementSpan.equals(oldUITextView.getText())) { - oldUITextView.setText(oldUIReplacementSpan); - } - } - - /** - * Injection point. Called on main thread. - * - * Used when spoofing to 16.x and 17.x versions. - */ - public static void setOldUILayoutDislikes(int buttonViewResourceId, @Nullable TextView textView) { - try { - if (!Settings.RYD_ENABLED.get() - || buttonViewResourceId != OLD_UI_DISLIKE_BUTTON_RESOURCE_ID - || textView == null) { - return; - } - Logger.printDebug(() -> "setOldUILayoutDislikes"); - - if (oldUIOriginalSpan == null) { - // Use value of the first instance, as it appears TextViews can be recycled - // and might contain dislikes previously added by the patch. - oldUIOriginalSpan = (Spanned) textView.getText(); - } - oldUITextViewRef = new WeakReference<>(textView); - // No way to check if a listener is already attached, so remove and add again. - textView.removeTextChangedListener(oldUiTextWatcher); - textView.addTextChangedListener(oldUiTextWatcher); - - updateOldUIDislikesTextView(); - - } catch (Exception ex) { - Logger.printException(() -> "setOldUILayoutDislikes failure", ex); - } - } - - // // Litho player for both regular videos and Shorts. // @@ -713,11 +620,8 @@ public static void sendVote(int vote) { if (v.value == vote) { videoData.sendVote(v); - if (isNoneHiddenOrMinimized) { - if (lastLithoShortsVideoData != null) { - lithoShortsShouldUseCurrentData = true; - } - updateOldUIDislikesTextView(); + if (isNoneHiddenOrMinimized && lastLithoShortsVideoData != null) { + lithoShortsShouldUseCurrentData = true; } return; diff --git a/app/src/main/java/app/revanced/integrations/youtube/patches/announcements/AnnouncementsPatch.java b/app/src/main/java/app/revanced/integrations/youtube/patches/announcements/AnnouncementsPatch.java index 225dc20609..40f31f2680 100644 --- a/app/src/main/java/app/revanced/integrations/youtube/patches/announcements/AnnouncementsPatch.java +++ b/app/src/main/java/app/revanced/integrations/youtube/patches/announcements/AnnouncementsPatch.java @@ -85,22 +85,6 @@ public static void showAnnouncement(final Activity context) { message = jsonString; } - // TODO: Remove this migration code after a few months. - if (!Settings.DEPRECATED_ANNOUNCEMENT_LAST_HASH.isSetToDefault()){ - final byte[] hashBytes = MessageDigest - .getInstance("SHA-256") - .digest(jsonString.getBytes(StandardCharsets.UTF_8)); - - final var hash = java.util.Base64.getEncoder().encodeToString(hashBytes); - - // Migrate to saving the id instead of the hash. - if (hash.equals(Settings.DEPRECATED_ANNOUNCEMENT_LAST_HASH.get())) { - Settings.ANNOUNCEMENT_LAST_ID.save(id); - } - - Settings.DEPRECATED_ANNOUNCEMENT_LAST_HASH.resetToDefault(); - } - // Do not show the announcement, if the last announcement id is the same as the current one. if (Settings.ANNOUNCEMENT_LAST_ID.get() == id) return; diff --git a/app/src/main/java/app/revanced/integrations/youtube/patches/components/PlaybackSpeedMenuFilterPatch.java b/app/src/main/java/app/revanced/integrations/youtube/patches/components/PlaybackSpeedMenuFilterPatch.java index 03319588d5..73c38d293a 100644 --- a/app/src/main/java/app/revanced/integrations/youtube/patches/components/PlaybackSpeedMenuFilterPatch.java +++ b/app/src/main/java/app/revanced/integrations/youtube/patches/components/PlaybackSpeedMenuFilterPatch.java @@ -7,6 +7,7 @@ /** * Abuse LithoFilter for {@link CustomPlaybackSpeedPatch}. */ +@SuppressWarnings("unused") public final class PlaybackSpeedMenuFilterPatch extends Filter { // Must be volatile or synchronized, as litho filtering runs off main thread and this field is then access from the main thread. public static volatile boolean isPlaybackSpeedMenuVisible; diff --git a/app/src/main/java/app/revanced/integrations/youtube/patches/components/ReturnYouTubeDislikeFilterPatch.java b/app/src/main/java/app/revanced/integrations/youtube/patches/components/ReturnYouTubeDislikeFilterPatch.java index 8df0d1903e..c7e128e680 100644 --- a/app/src/main/java/app/revanced/integrations/youtube/patches/components/ReturnYouTubeDislikeFilterPatch.java +++ b/app/src/main/java/app/revanced/integrations/youtube/patches/components/ReturnYouTubeDislikeFilterPatch.java @@ -26,6 +26,7 @@ * * Once a way to asynchronously update litho text is found, this strategy will no longer be needed. */ +@SuppressWarnings("unused") public final class ReturnYouTubeDislikeFilterPatch extends Filter { /** diff --git a/app/src/main/java/app/revanced/integrations/youtube/returnyoutubedislike/ReturnYouTubeDislike.java b/app/src/main/java/app/revanced/integrations/youtube/returnyoutubedislike/ReturnYouTubeDislike.java index b63d0484e0..648532be8d 100644 --- a/app/src/main/java/app/revanced/integrations/youtube/returnyoutubedislike/ReturnYouTubeDislike.java +++ b/app/src/main/java/app/revanced/integrations/youtube/returnyoutubedislike/ReturnYouTubeDislike.java @@ -66,7 +66,7 @@ public enum Vote { * Maximum amount of time to block the UI from updates while waiting for network call to complete. * * Must be less than 5 seconds, as per: - * https://developer.android.com/topic/performance/vitals/anr + * ... */ private static final long MAX_MILLISECONDS_TO_BLOCK_UI_WAITING_FOR_FETCH = 4000; diff --git a/app/src/main/java/app/revanced/integrations/youtube/returnyoutubedislike/requests/ReturnYouTubeDislikeApi.java b/app/src/main/java/app/revanced/integrations/youtube/returnyoutubedislike/requests/ReturnYouTubeDislikeApi.java index cb211ea501..8e09c2cd8e 100644 --- a/app/src/main/java/app/revanced/integrations/youtube/returnyoutubedislike/requests/ReturnYouTubeDislikeApi.java +++ b/app/src/main/java/app/revanced/integrations/youtube/returnyoutubedislike/requests/ReturnYouTubeDislikeApi.java @@ -147,6 +147,7 @@ private ReturnYouTubeDislikeApi() { */ private static void randomlyWaitIfLocallyDebugging() { final boolean DEBUG_RANDOMLY_DELAY_NETWORK_CALLS = false; // set true to debug UI + //noinspection ConstantValue if (DEBUG_RANDOMLY_DELAY_NETWORK_CALLS) { final long amountOfTimeToWaste = (long) (Math.random() * (API_GET_VOTES_TCP_TIMEOUT_MILLISECONDS + API_GET_VOTES_HTTP_TIMEOUT_MILLISECONDS)); @@ -187,6 +188,7 @@ private static boolean checkIfRateLimitInEffect(String apiEndPointName) { */ private static boolean checkIfRateLimitWasHit(int httpResponseCode) { final boolean DEBUG_RATE_LIMIT = false; // set to true, to verify rate limit works + //noinspection ConstantValue if (DEBUG_RATE_LIMIT) { final double RANDOM_RATE_LIMIT_PERCENTAGE = 0.2; // 20% chance of a triggering a rate limit if (Math.random() < RANDOM_RATE_LIMIT_PERCENTAGE) { @@ -574,7 +576,11 @@ private static String solvePuzzle(String challenge, int difficulty) { throw new IllegalStateException("Failed to solve puzzle challenge: " + challenge + " difficulty: " + difficulty); } - // https://stackoverflow.com/a/157202 + /** + * ... + * + * @noinspection SameParameterValue + */ private static String randomString(int len) { String AB = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; SecureRandom rnd = new SecureRandom(); diff --git a/app/src/main/java/app/revanced/integrations/youtube/settings/Settings.java b/app/src/main/java/app/revanced/integrations/youtube/settings/Settings.java index b95ed7f7b0..6d61ab6f49 100644 --- a/app/src/main/java/app/revanced/integrations/youtube/settings/Settings.java +++ b/app/src/main/java/app/revanced/integrations/youtube/settings/Settings.java @@ -1,6 +1,13 @@ package app.revanced.integrations.youtube.settings; -import app.revanced.integrations.shared.Logger; +import static java.lang.Boolean.FALSE; +import static java.lang.Boolean.TRUE; +import static app.revanced.integrations.shared.settings.Setting.*; +import static app.revanced.integrations.youtube.patches.MiniplayerPatch.MiniplayerType; +import static app.revanced.integrations.youtube.patches.MiniplayerPatch.MiniplayerType.MODERN_1; +import static app.revanced.integrations.youtube.patches.MiniplayerPatch.MiniplayerType.MODERN_3; +import static app.revanced.integrations.youtube.sponsorblock.objects.CategoryBehaviour.*; + import app.revanced.integrations.shared.settings.*; import app.revanced.integrations.shared.settings.preference.SharedPrefCategory; import app.revanced.integrations.youtube.patches.AlternativeThumbnailsPatch.DeArrowAvailability; @@ -8,22 +15,9 @@ import app.revanced.integrations.youtube.patches.AlternativeThumbnailsPatch.ThumbnailOption; import app.revanced.integrations.youtube.patches.AlternativeThumbnailsPatch.ThumbnailStillTime; import app.revanced.integrations.youtube.patches.spoof.ClientType; -import app.revanced.integrations.youtube.patches.spoof.SpoofAppVersionPatch; import app.revanced.integrations.youtube.patches.spoof.SpoofVideoStreamsPatch; import app.revanced.integrations.youtube.sponsorblock.SponsorBlockSettings; -import java.util.Arrays; -import java.util.HashSet; -import java.util.Set; - -import static app.revanced.integrations.shared.settings.Setting.*; -import static app.revanced.integrations.youtube.patches.MiniplayerPatch.MiniplayerType; -import static app.revanced.integrations.youtube.patches.MiniplayerPatch.MiniplayerType.MODERN_1; -import static app.revanced.integrations.youtube.patches.MiniplayerPatch.MiniplayerType.MODERN_3; -import static app.revanced.integrations.youtube.sponsorblock.objects.CategoryBehaviour.*; -import static java.lang.Boolean.FALSE; -import static java.lang.Boolean.TRUE; - @SuppressWarnings("deprecation") public class Settings extends BaseSettings { // Video @@ -35,8 +29,6 @@ public class Settings extends BaseSettings { public static final FloatSetting PLAYBACK_SPEED_DEFAULT = new FloatSetting("revanced_playback_speed_default", 1.0f); public static final StringSetting CUSTOM_PLAYBACK_SPEEDS = new StringSetting("revanced_custom_playback_speeds", "0.25\n0.5\n0.75\n0.9\n0.95\n1.0\n1.05\n1.1\n1.25\n1.5\n1.75\n2.0\n3.0\n4.0\n5.0", true); - @Deprecated // Patch is obsolete and no longer works with 19.09+ - public static final BooleanSetting HDR_AUTO_BRIGHTNESS = new BooleanSetting("revanced_hdr_auto_brightness", TRUE); // Ads public static final BooleanSetting HIDE_FULLSCREEN_ADS = new BooleanSetting("revanced_hide_fullscreen_ads", TRUE); @@ -89,7 +81,6 @@ public class Settings extends BaseSettings { public static final BooleanSetting HIDE_COMMUNITY_POSTS = new BooleanSetting("revanced_hide_community_posts", FALSE); public static final BooleanSetting HIDE_COMPACT_BANNER = new BooleanSetting("revanced_hide_compact_banner", TRUE); public static final BooleanSetting HIDE_CROWDFUNDING_BOX = new BooleanSetting("revanced_hide_crowdfunding_box", FALSE, true); - @Deprecated public static final BooleanSetting HIDE_EMAIL_ADDRESS = new BooleanSetting("revanced_hide_email_address", FALSE); public static final BooleanSetting HIDE_EMERGENCY_BOX = new BooleanSetting("revanced_hide_emergency_box", TRUE); public static final BooleanSetting HIDE_ENDSCREEN_CARDS = new BooleanSetting("revanced_hide_endscreen_cards", FALSE); public static final BooleanSetting HIDE_FEED_SURVEY = new BooleanSetting("revanced_hide_feed_survey", TRUE); @@ -104,7 +95,6 @@ public class Settings extends BaseSettings { public static final BooleanSetting HIDE_IMAGE_SHELF = new BooleanSetting("revanced_hide_image_shelf", TRUE); public static final BooleanSetting HIDE_INFO_CARDS = new BooleanSetting("revanced_hide_info_cards", FALSE); public static final BooleanSetting HIDE_JOIN_MEMBERSHIP_BUTTON = new BooleanSetting("revanced_hide_join_membership_button", TRUE); - @Deprecated public static final BooleanSetting HIDE_LOAD_MORE_BUTTON = new BooleanSetting("revanced_hide_load_more_button", TRUE); public static final BooleanSetting HIDE_SHOW_MORE_BUTTON = new BooleanSetting("revanced_hide_show_more_button", TRUE, true); public static final BooleanSetting HIDE_MEDICAL_PANELS = new BooleanSetting("revanced_hide_medical_panels", TRUE); public static final BooleanSetting HIDE_MIX_PLAYLISTS = new BooleanSetting("revanced_hide_mix_playlists", TRUE); @@ -260,8 +250,6 @@ public class Settings extends BaseSettings { public static final BooleanSetting SPOOF_VIDEO_STREAMS_IOS_FORCE_AVC = new BooleanSetting("revanced_spoof_video_streams_ios_force_avc", FALSE, true, "revanced_spoof_video_streams_ios_force_avc_user_dialog_message", new SpoofVideoStreamsPatch.ForceiOSAVCAvailability()); public static final EnumSetting SPOOF_VIDEO_STREAMS_CLIENT_TYPE = new EnumSetting<>("revanced_spoof_video_streams_client", ClientType.ANDROID_VR, true, parent(SPOOF_VIDEO_STREAMS)); - @Deprecated - public static final StringSetting DEPRECATED_ANNOUNCEMENT_LAST_HASH = new StringSetting("revanced_announcement_last_hash", ""); public static final IntegerSetting ANNOUNCEMENT_LAST_ID = new IntegerSetting("revanced_announcement_last_id", -1); public static final BooleanSetting CHECK_WATCH_HISTORY_DOMAIN_NAME = new BooleanSetting("revanced_check_watch_history_domain_name", TRUE, false, false); public static final BooleanSetting REMOVE_TRACKING_QUERY_PARAMETER = new BooleanSetting("revanced_remove_tracking_query_parameter", TRUE); @@ -274,14 +262,6 @@ public class Settings extends BaseSettings { */ public static final BooleanSetting DEBUG_PROTOBUFFER = new BooleanSetting("revanced_debug_protobuffer", FALSE, parent(BaseSettings.DEBUG)); - // Old deprecated signature spoofing - @Deprecated public static final BooleanSetting SPOOF_SIGNATURE = new BooleanSetting("revanced_spoof_signature_verification_enabled", TRUE, true, false, - "revanced_spoof_signature_verification_enabled_user_dialog_message", null); - @Deprecated public static final BooleanSetting SPOOF_SIGNATURE_IN_FEED = new BooleanSetting("revanced_spoof_signature_in_feed_enabled", FALSE, false, false, null, - parent(SPOOF_SIGNATURE)); - @Deprecated public static final BooleanSetting SPOOF_STORYBOARD_RENDERER = new BooleanSetting("revanced_spoof_storyboard", TRUE, true, false, null, - parent(SPOOF_SIGNATURE)); - // Swipe controls public static final BooleanSetting SWIPE_BRIGHTNESS = new BooleanSetting("revanced_swipe_brightness", TRUE); public static final BooleanSetting SWIPE_VOLUME = new BooleanSetting("revanced_swipe_volume", TRUE); @@ -315,8 +295,7 @@ public class Settings extends BaseSettings { * Do not use directly, instead use {@link SponsorBlockSettings} */ public static final StringSetting SB_PRIVATE_USER_ID = new StringSetting("sb_private_user_id_Do_Not_Share", ""); - @Deprecated - public static final StringSetting DEPRECATED_SB_UUID_OLD_MIGRATION_SETTING = new StringSetting("uuid", ""); // Delete sometime in 2024 + private static final StringSetting DEPRECATED_SB_UUID_OLD_MIGRATION_SETTING = new StringSetting("uuid", ""); // Delete sometime in 2025 public static final IntegerSetting SB_CREATE_NEW_SEGMENT_STEP = new IntegerSetting("sb_create_new_segment_step", 150, parent(SB_ENABLED)); public static final BooleanSetting SB_VOTING_BUTTON = new BooleanSetting("sb_voting_button", FALSE, parent(SB_ENABLED)); public static final BooleanSetting SB_CREATE_NEW_SEGMENT = new BooleanSetting("sb_create_new_segment", FALSE, parent(SB_ENABLED)); @@ -359,71 +338,15 @@ public class Settings extends BaseSettings { static { // region Migration - // Migrate settings from old Preference categories into replacement "revanced_prefs" category. - // This region must run before all other migration code. - - // The YT and RYD migration portion of this can be removed anytime, - // but the SB migration should remain until late 2024 or early 2025 - // because it migrates the SB private user id which cannot be recovered if lost. - - // Categories were previously saved without a 'sb_' key prefix, so they need an additional adjustment. - Set> sbCategories = new HashSet<>(Arrays.asList( - SB_CATEGORY_SPONSOR, - SB_CATEGORY_SPONSOR_COLOR, - SB_CATEGORY_SELF_PROMO, - SB_CATEGORY_SELF_PROMO_COLOR, - SB_CATEGORY_INTERACTION, - SB_CATEGORY_INTERACTION_COLOR, - SB_CATEGORY_HIGHLIGHT, - SB_CATEGORY_HIGHLIGHT_COLOR, - SB_CATEGORY_INTRO, - SB_CATEGORY_INTRO_COLOR, - SB_CATEGORY_OUTRO, - SB_CATEGORY_OUTRO_COLOR, - SB_CATEGORY_PREVIEW, - SB_CATEGORY_PREVIEW_COLOR, - SB_CATEGORY_FILLER, - SB_CATEGORY_FILLER_COLOR, - SB_CATEGORY_MUSIC_OFFTOPIC, - SB_CATEGORY_MUSIC_OFFTOPIC_COLOR, - SB_CATEGORY_UNSUBMITTED, - SB_CATEGORY_UNSUBMITTED_COLOR)); - - SharedPrefCategory ytPrefs = new SharedPrefCategory("youtube"); - SharedPrefCategory rydPrefs = new SharedPrefCategory("ryd"); - SharedPrefCategory sbPrefs = new SharedPrefCategory("sponsor-block"); - for (Setting setting : Setting.allLoadedSettings()) { - String key = setting.key; - if (setting.key.startsWith("sb_")) { - if (sbCategories.contains(setting)) { - key = key.substring(3); // Remove the "sb_" prefix, as old categories are saved without it. - } - migrateFromOldPreferences(sbPrefs, setting, key); - } else if (setting.key.startsWith("ryd_")) { - migrateFromOldPreferences(rydPrefs, setting, key); - } else { - migrateFromOldPreferences(ytPrefs, setting, key); - } - } - - - // Do _not_ delete this SB private user id migration property until sometime in 2024. + // Do _not_ delete this SB private user id migration property until sometime in early 2025. // This is the only setting that cannot be reconfigured if lost, // and more time should be given for users who rarely upgrade. - migrateOldSettingToNew(DEPRECATED_SB_UUID_OLD_MIGRATION_SETTING, SB_PRIVATE_USER_ID); - - - // Old spoof versions that no longer work reliably. - if (SpoofAppVersionPatch.isSpoofingToLessThan("17.33.00")) { - Logger.printInfo(() -> "Resetting spoof app version target"); - Settings.SPOOF_APP_VERSION_TARGET.resetToDefault(); - } - - - // Remove any previously saved announcement consumer (a random generated string). - Setting.preferences.removeKey("revanced_announcement_consumer"); + SharedPrefCategory sbPrefs = new SharedPrefCategory("sponsor-block"); + String key = DEPRECATED_SB_UUID_OLD_MIGRATION_SETTING.key + .substring(3); // Remove the "sb_" prefix, as old categories are saved without it. + migrateFromOldPreferences(sbPrefs, DEPRECATED_SB_UUID_OLD_MIGRATION_SETTING, key); - migrateOldSettingToNew(HIDE_LOAD_MORE_BUTTON, HIDE_SHOW_MORE_BUTTON); + migrateOldSettingToNew(DEPRECATED_SB_UUID_OLD_MIGRATION_SETTING, SB_PRIVATE_USER_ID); // endregion } diff --git a/app/src/main/java/app/revanced/integrations/youtube/settings/preference/ReVancedPreferenceFragment.java b/app/src/main/java/app/revanced/integrations/youtube/settings/preference/ReVancedPreferenceFragment.java index 58fd974633..2e4bc4c1df 100644 --- a/app/src/main/java/app/revanced/integrations/youtube/settings/preference/ReVancedPreferenceFragment.java +++ b/app/src/main/java/app/revanced/integrations/youtube/settings/preference/ReVancedPreferenceFragment.java @@ -19,6 +19,7 @@ public class ReVancedPreferenceFragment extends AbstractPreferenceFragment { @RequiresApi(api = Build.VERSION_CODES.O) + @SuppressWarnings("unused") @Override protected void initialize() { super.initialize(); diff --git a/app/src/main/java/app/revanced/integrations/youtube/shared/PlayerType.kt b/app/src/main/java/app/revanced/integrations/youtube/shared/PlayerType.kt index 7db4a3fdf5..6461c18aba 100644 --- a/app/src/main/java/app/revanced/integrations/youtube/shared/PlayerType.kt +++ b/app/src/main/java/app/revanced/integrations/youtube/shared/PlayerType.kt @@ -21,9 +21,6 @@ enum class PlayerType { /** * A regular video is minimized. - * - * When spoofing to 16.x YouTube and watching a short with a regular video in the background, - * the type can be this (and not [HIDDEN]). */ WATCH_WHILE_MINIMIZED, WATCH_WHILE_MAXIMIZED, @@ -49,7 +46,7 @@ enum class PlayerType { companion object { - private val nameToPlayerType = values().associateBy { it.name } + private val nameToPlayerType = entries.associateBy { it.name } @JvmStatic fun setFromString(enumName: String) { @@ -87,9 +84,8 @@ enum class PlayerType { * Check if the current player type is [NONE] or [HIDDEN]. * Useful to check if a short is currently playing. * - * Does not include the first moment after a short is opened when a regular video is minimized on screen, - * or while watching a short with a regular video present on a spoofed 16.x version of YouTube. - * To include those situations instead use [isNoneHiddenOrMinimized]. + * Does not include the first moment after a short is opened when a regular video is minimized on screen. + * To include that, instead use [isNoneHiddenOrMinimized]. * * @see VideoInformation */ @@ -103,9 +99,7 @@ enum class PlayerType { * * Useful to check if a Short is being played or opened. * - * Usually covers all use cases with no false positives, except if called from some hooks - * when spoofing to an old version this will return false even - * though a Short is being opened or is on screen (see [isNoneHiddenOrMinimized]). + * Usually covers all use cases with no false positives. * * @return If nothing, a Short, or a regular video is sliding off screen to a dismissed or hidden state. * @see VideoInformation diff --git a/app/src/main/java/app/revanced/integrations/youtube/shared/VideoState.kt b/app/src/main/java/app/revanced/integrations/youtube/shared/VideoState.kt index 75db347b84..893360b161 100644 --- a/app/src/main/java/app/revanced/integrations/youtube/shared/VideoState.kt +++ b/app/src/main/java/app/revanced/integrations/youtube/shared/VideoState.kt @@ -22,7 +22,7 @@ enum class VideoState { companion object { - private val nameToVideoState = values().associateBy { it.name } + private val nameToVideoState = entries.associateBy { it.name } @JvmStatic fun setFromString(enumName: String) { diff --git a/app/src/main/java/app/revanced/integrations/youtube/sponsorblock/SegmentPlaybackController.java b/app/src/main/java/app/revanced/integrations/youtube/sponsorblock/SegmentPlaybackController.java index ad02eec8b8..0b4b8890fc 100644 --- a/app/src/main/java/app/revanced/integrations/youtube/sponsorblock/SegmentPlaybackController.java +++ b/app/src/main/java/app/revanced/integrations/youtube/sponsorblock/SegmentPlaybackController.java @@ -178,6 +178,7 @@ private static void clearData() { * Injection point. * Initializes SponsorBlock when the video player starts playing a new video. */ + @SuppressWarnings("unused") public static void initialize(VideoInformation.PlaybackController ignoredPlayerController) { try { Utils.verifyOnMainThread(); diff --git a/app/src/main/java/app/revanced/integrations/youtube/sponsorblock/requests/SBRequester.java b/app/src/main/java/app/revanced/integrations/youtube/sponsorblock/requests/SBRequester.java index 9e25e9f614..c2487dbf73 100644 --- a/app/src/main/java/app/revanced/integrations/youtube/sponsorblock/requests/SBRequester.java +++ b/app/src/main/java/app/revanced/integrations/youtube/sponsorblock/requests/SBRequester.java @@ -113,6 +113,7 @@ public static SponsorSegment[] getSegments(@NonNull String videoId) { // Could benefit from: // 1) collection of YouTube videos with test segment times (verify client skip timing matches the video, verify seekbar draws correctly) // 2) unit tests (verify everything else) + //noinspection ConstantValue if (false) { segments.clear(); // Test auto-hide skip button: diff --git a/app/src/main/java/app/revanced/integrations/youtube/sponsorblock/ui/SkipSponsorButton.java b/app/src/main/java/app/revanced/integrations/youtube/sponsorblock/ui/SkipSponsorButton.java index f3b954d4f4..d98282a47a 100644 --- a/app/src/main/java/app/revanced/integrations/youtube/sponsorblock/ui/SkipSponsorButton.java +++ b/app/src/main/java/app/revanced/integrations/youtube/sponsorblock/ui/SkipSponsorButton.java @@ -92,6 +92,7 @@ protected final void dispatchDraw(Canvas canvas) { public boolean updateSkipButtonText(@NonNull SponsorSegment segment) { this.segment = segment; CharSequence newText = segment.getSkipButtonText(); + //noinspection StringEqualsCharSequence if (newText.equals(skipSponsorTextView.getText())) { return false; }