From b7044016a46b8156678b53ed8800383494531cca Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Wed, 31 May 2023 21:49:12 +0000 Subject: [PATCH 01/48] chore(release): 0.110.0-dev.1 [skip ci] # [0.110.0-dev.1](https://github.com/revanced/revanced-integrations/compare/v0.109.1-dev.1...v0.110.0-dev.1) (2023-05-31) ### Features * **youtube/swipe-controls:** add option to save and restore brightness ([741dae5](https://github.com/revanced/revanced-integrations/commit/741dae5345596dfde0a553b75b37eed67b624592)) --- CHANGELOG.md | 7 +++++++ gradle.properties | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e4a493a54b..7cfef268a5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +# [0.110.0-dev.1](https://github.com/revanced/revanced-integrations/compare/v0.109.1-dev.1...v0.110.0-dev.1) (2023-05-31) + + +### Features + +* **youtube/swipe-controls:** add option to save and restore brightness ([741dae5](https://github.com/revanced/revanced-integrations/commit/741dae5345596dfde0a553b75b37eed67b624592)) + ## [0.109.1-dev.1](https://github.com/revanced/revanced-integrations/compare/v0.109.0...v0.109.1-dev.1) (2023-05-31) diff --git a/gradle.properties b/gradle.properties index a8a39ced3b..953afded04 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,3 +1,3 @@ org.gradle.jvmargs = -Xmx2048m android.useAndroidX = true -version = 0.109.1-dev.1 +version = 0.110.0-dev.1 From ac906dbef7930dde0495699213ef67ff0702649a Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Thu, 1 Jun 2023 00:12:06 +0200 Subject: [PATCH 02/48] feat(youtube/hide-ads): hide mix playlists --- .../patches/components/AdsFilter.java | 48 +++++++++++++++++-- .../integrations/settings/SettingsEnum.java | 1 + 2 files changed, 45 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/app/revanced/integrations/patches/components/AdsFilter.java b/app/src/main/java/app/revanced/integrations/patches/components/AdsFilter.java index e5e1af9032..0d860631c1 100644 --- a/app/src/main/java/app/revanced/integrations/patches/components/AdsFilter.java +++ b/app/src/main/java/app/revanced/integrations/patches/components/AdsFilter.java @@ -1,7 +1,9 @@ package app.revanced.integrations.patches.components; +import android.os.Build; import android.view.View; +import androidx.annotation.RequiresApi; import app.revanced.integrations.settings.SettingsEnum; import app.revanced.integrations.utils.LogHelper; import app.revanced.integrations.utils.ReVancedUtils; @@ -12,6 +14,13 @@ public final class AdsFilter extends Filter { private final CustomFilterGroup custom; + // region Mix playlists + private final ByteArrayAsStringFilterGroup mixPlaylists; + private final ByteArrayAsStringFilterGroup imageHosting; + + // endregion + + @RequiresApi(api = Build.VERSION_CODES.N) public AdsFilter() { exceptions = new String[]{ "home_video_with_context", @@ -183,6 +192,21 @@ public AdsFilter() { "offer_module_root" ); + // region Mix playlists + + mixPlaylists = new ByteArrayAsStringFilterGroup( + SettingsEnum.HIDE_MIX_PLAYLISTS, + "&list=", + "YouTube Music" + ); + + imageHosting = new ByteArrayAsStringFilterGroup( + SettingsEnum.HIDE_MIX_PLAYLISTS, // Unused + "ggpht.com" + ); + + // endregion + this.pathFilterGroups.addAll( generalAds, buttonedAd, @@ -222,6 +246,18 @@ public AdsFilter() { ); } + private boolean isMixPlaylistFiltered(final byte[] _protobufBufferArray) { + if (!mixPlaylists.isEnabled()) return false; + + // Two checks are required to prevent false positives. + + // First check if the current buffer potentially contains a mix playlist. + if (!mixPlaylists.check(_protobufBufferArray).isFiltered()) return false; + + // Ensure that the buffer actually contains a mix playlist. + return imageHosting.check(_protobufBufferArray).isFiltered(); + } + @Override public boolean isFiltered(final String path, final String identifier, final byte[] _protobufBufferArray) { FilterResult result; @@ -230,10 +266,14 @@ public boolean isFiltered(final String path, final String identifier, final byte result = FilterResult.CUSTOM; else if (ReVancedUtils.containsAny(path, exceptions)) result = FilterResult.EXCEPTION; - else if (pathFilterGroups.contains(path) || identifierFilterGroups.contains(identifier)) - result = FilterResult.FILTERED; - else - result = FilterResult.UNFILTERED; + else { + var filtered = + pathFilterGroups.contains(path) || // Check if the path is filtered. + identifierFilterGroups.contains(identifier) || // Check if the identifier is filtered. + isMixPlaylistFiltered(_protobufBufferArray); // Check if the buffer contains a mix playlist. + + result = filtered ? FilterResult.FILTERED : FilterResult.UNFILTERED; + } LogHelper.printDebug(() -> String.format("%s (ID: %s): %s", result.message, identifier, path)); 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 e1d53fa2d7..dfe5ba2353 100644 --- a/app/src/main/java/app/revanced/integrations/settings/SettingsEnum.java +++ b/app/src/main/java/app/revanced/integrations/settings/SettingsEnum.java @@ -85,6 +85,7 @@ public enum SettingsEnum { HIDE_WEB_SEARCH_RESULTS("revanced_hide_web_search_results", BOOLEAN, TRUE), HIDE_QUICK_ACTIONS("revanced_hide_quick_actions", BOOLEAN, FALSE), HIDE_RELATED_VIDEOS("revanced_hide_related_videos", BOOLEAN, FALSE), + HIDE_MIX_PLAYLISTS("revanced_hide_mix_playlists", BOOLEAN, TRUE), // Action buttons HIDE_LIKE_DISLIKE_BUTTON("revanced_hide_like_dislike_button", BOOLEAN, FALSE), From d792b97c0905748b5e73d03b2d205cd8ebc892da Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Wed, 31 May 2023 22:14:30 +0000 Subject: [PATCH 03/48] chore(release): 0.110.0-dev.2 [skip ci] # [0.110.0-dev.2](https://github.com/revanced/revanced-integrations/compare/v0.110.0-dev.1...v0.110.0-dev.2) (2023-05-31) ### Features * **youtube/hide-ads:** hide mix playlists ([56b856f](https://github.com/revanced/revanced-integrations/commit/56b856f6e720fb83e23602d47a33fa7a910189e8)) --- CHANGELOG.md | 7 +++++++ gradle.properties | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7cfef268a5..4584e820a2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +# [0.110.0-dev.2](https://github.com/revanced/revanced-integrations/compare/v0.110.0-dev.1...v0.110.0-dev.2) (2023-05-31) + + +### Features + +* **youtube/hide-ads:** hide mix playlists ([56b856f](https://github.com/revanced/revanced-integrations/commit/56b856f6e720fb83e23602d47a33fa7a910189e8)) + # [0.110.0-dev.1](https://github.com/revanced/revanced-integrations/compare/v0.109.1-dev.1...v0.110.0-dev.1) (2023-05-31) diff --git a/gradle.properties b/gradle.properties index 953afded04..e5103eaac8 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,3 +1,3 @@ org.gradle.jvmargs = -Xmx2048m android.useAndroidX = true -version = 0.110.0-dev.1 +version = 0.110.0-dev.2 From 1fd9c5271a1f362805f2cd33a64b309ac00e128f Mon Sep 17 00:00:00 2001 From: LisoUseInAIKyrios <118716522+LisoUseInAIKyrios@users.noreply.github.com> Date: Mon, 5 Jun 2023 22:38:41 +0400 Subject: [PATCH 04/48] renaming keys --- .../settingsmenu/ReVancedSettingActivity.java | 6 +- .../ReturnYouTubeDislikeSettingsFragment.java | 62 +++++++++---------- .../videoplayer/ExternalDownloadButton.java | 2 +- 3 files changed, 35 insertions(+), 35 deletions(-) diff --git a/app/src/main/java/app/revanced/integrations/settingsmenu/ReVancedSettingActivity.java b/app/src/main/java/app/revanced/integrations/settingsmenu/ReVancedSettingActivity.java index e7cba140cf..342f2b8fba 100644 --- a/app/src/main/java/app/revanced/integrations/settingsmenu/ReVancedSettingActivity.java +++ b/app/src/main/java/app/revanced/integrations/settingsmenu/ReVancedSettingActivity.java @@ -31,15 +31,15 @@ public static void initializeSettings(Activity licenseActivity) { String toolbarTitleResourceName; String dataString = licenseActivity.getIntent().getDataString(); switch (dataString) { - case "sponsorblock_settings": + case "sponsorblock_settings_intent": toolbarTitleResourceName = "revanced_sponsorblock_settings_title"; fragment = new SponsorBlockSettingsFragment(); break; - case "ryd_settings": + case "ryd_settings_intent": toolbarTitleResourceName = "revanced_ryd_settings_title"; fragment = new ReturnYouTubeDislikeSettingsFragment(); break; - case "revanced_settings": + case "revanced_settings_intent": toolbarTitleResourceName = "revanced_settings_title"; fragment = new ReVancedSettingsFragment(); break; diff --git a/app/src/main/java/app/revanced/integrations/settingsmenu/ReturnYouTubeDislikeSettingsFragment.java b/app/src/main/java/app/revanced/integrations/settingsmenu/ReturnYouTubeDislikeSettingsFragment.java index dadc85beb7..7ad5e26452 100644 --- a/app/src/main/java/app/revanced/integrations/settingsmenu/ReturnYouTubeDislikeSettingsFragment.java +++ b/app/src/main/java/app/revanced/integrations/settingsmenu/ReturnYouTubeDislikeSettingsFragment.java @@ -57,9 +57,9 @@ public void onCreate(Bundle savedInstanceState) { SwitchPreference enabledPreference = new SwitchPreference(context); enabledPreference.setChecked(SettingsEnum.RYD_ENABLED.getBoolean()); - enabledPreference.setTitle(str("revanced_ryd_enable_title")); - enabledPreference.setSummaryOn(str("revanced_ryd_enable_summary_on")); - enabledPreference.setSummaryOff(str("revanced_ryd_enable_summary_off")); + enabledPreference.setTitle(str("ryd_enable_title")); + enabledPreference.setSummaryOn(str("ryd_enable_summary_on")); + enabledPreference.setSummaryOff(str("ryd_enable_summary_off")); enabledPreference.setOnPreferenceChangeListener((pref, newValue) -> { final boolean rydIsEnabled = (Boolean) newValue; SettingsEnum.RYD_ENABLED.saveValue(rydIsEnabled); @@ -72,9 +72,9 @@ public void onCreate(Bundle savedInstanceState) { shortsPreference = new SwitchPreference(context); shortsPreference.setChecked(SettingsEnum.RYD_SHORTS.getBoolean()); - shortsPreference.setTitle(str("revanced_ryd_shorts_title")); - shortsPreference.setSummaryOn(str("revanced_ryd_shorts_summary_on")); - shortsPreference.setSummaryOff(str("revanced_ryd_shorts_summary_off")); + shortsPreference.setTitle(str("ryd_shorts_title")); + shortsPreference.setSummaryOn(str("ryd_shorts_summary_on")); + shortsPreference.setSummaryOff(str("ryd_shorts_summary_off")); shortsPreference.setOnPreferenceChangeListener((pref, newValue) -> { SettingsEnum.RYD_SHORTS.saveValue(newValue); updateUIState(); @@ -84,9 +84,9 @@ public void onCreate(Bundle savedInstanceState) { percentagePreference = new SwitchPreference(context); percentagePreference.setChecked(SettingsEnum.RYD_DISLIKE_PERCENTAGE.getBoolean()); - percentagePreference.setTitle(str("revanced_ryd_dislike_percentage_title")); - percentagePreference.setSummaryOn(str("revanced_ryd_dislike_percentage_summary_on")); - percentagePreference.setSummaryOff(str("revanced_ryd_dislike_percentage_summary_off")); + percentagePreference.setTitle(str("ryd_dislike_percentage_title")); + percentagePreference.setSummaryOn(str("ryd_dislike_percentage_summary_on")); + percentagePreference.setSummaryOff(str("ryd_dislike_percentage_summary_off")); percentagePreference.setOnPreferenceChangeListener((pref, newValue) -> { SettingsEnum.RYD_DISLIKE_PERCENTAGE.saveValue(newValue); ReturnYouTubeDislike.clearCache(); @@ -97,9 +97,9 @@ public void onCreate(Bundle savedInstanceState) { compactLayoutPreference = new SwitchPreference(context); compactLayoutPreference.setChecked(SettingsEnum.RYD_COMPACT_LAYOUT.getBoolean()); - compactLayoutPreference.setTitle(str("revanced_ryd_compact_layout_title")); - compactLayoutPreference.setSummaryOn(str("revanced_ryd_compact_layout_summary_on")); - compactLayoutPreference.setSummaryOff(str("revanced_ryd_compact_layout_summary_off")); + compactLayoutPreference.setTitle(str("ryd_compact_layout_title")); + compactLayoutPreference.setSummaryOn(str("ryd_compact_layout_summary_on")); + compactLayoutPreference.setSummaryOff(str("ryd_compact_layout_summary_off")); compactLayoutPreference.setOnPreferenceChangeListener((pref, newValue) -> { SettingsEnum.RYD_COMPACT_LAYOUT.saveValue(newValue); ReturnYouTubeDislike.clearCache(); @@ -126,14 +126,14 @@ public void onCreate(Bundle savedInstanceState) { // About category PreferenceCategory aboutCategory = new PreferenceCategory(context); - aboutCategory.setTitle(str("revanced_ryd_about")); + aboutCategory.setTitle(str("ryd_about")); preferenceScreen.addPreference(aboutCategory); // ReturnYouTubeDislike Website Preference aboutWebsitePreference = new Preference(context); - aboutWebsitePreference.setTitle(str("revanced_ryd_attribution_title")); - aboutWebsitePreference.setSummary(str("revanced_ryd_attribution_summary")); + aboutWebsitePreference.setTitle(str("ryd_attribution_title")); + aboutWebsitePreference.setSummary(str("ryd_attribution_summary")); aboutWebsitePreference.setOnPreferenceClickListener(pref -> { Intent i = new Intent(Intent.ACTION_VIEW); i.setData(Uri.parse("https://returnyoutubedislike.com")); @@ -149,64 +149,64 @@ public void onCreate(Bundle savedInstanceState) { preferenceScreen.addPreference(emptyCategory); PreferenceCategory statisticsCategory = new PreferenceCategory(context); - statisticsCategory.setTitle(str("revanced_ryd_statistics_category_title")); + statisticsCategory.setTitle(str("ryd_statistics_category_title")); preferenceScreen.addPreference(statisticsCategory); Preference statisticPreference; statisticPreference = new Preference(context); statisticPreference.setSelectable(false); - statisticPreference.setTitle(str("revanced_ryd_statistics_getFetchCallResponseTimeAverage_title")); + statisticPreference.setTitle(str("ryd_statistics_getFetchCallResponseTimeAverage_title")); statisticPreference.setSummary(createMillisecondStringFromNumber(ReturnYouTubeDislikeApi.getFetchCallResponseTimeAverage())); preferenceScreen.addPreference(statisticPreference); statisticPreference = new Preference(context); statisticPreference.setSelectable(false); - statisticPreference.setTitle(str("revanced_ryd_statistics_getFetchCallResponseTimeMin_title")); + statisticPreference.setTitle(str("ryd_statistics_getFetchCallResponseTimeMin_title")); statisticPreference.setSummary(createMillisecondStringFromNumber(ReturnYouTubeDislikeApi.getFetchCallResponseTimeMin())); preferenceScreen.addPreference(statisticPreference); statisticPreference = new Preference(context); statisticPreference.setSelectable(false); - statisticPreference.setTitle(str("revanced_ryd_statistics_getFetchCallResponseTimeMax_title")); + statisticPreference.setTitle(str("ryd_statistics_getFetchCallResponseTimeMax_title")); statisticPreference.setSummary(createMillisecondStringFromNumber(ReturnYouTubeDislikeApi.getFetchCallResponseTimeMax())); preferenceScreen.addPreference(statisticPreference); String fetchCallTimeWaitingLastSummary; final long fetchCallTimeWaitingLast = ReturnYouTubeDislikeApi.getFetchCallResponseTimeLast(); if (fetchCallTimeWaitingLast == ReturnYouTubeDislikeApi.FETCH_CALL_RESPONSE_TIME_VALUE_RATE_LIMIT) { - fetchCallTimeWaitingLastSummary = str("revanced_ryd_statistics_getFetchCallResponseTimeLast_rate_limit_summary"); + fetchCallTimeWaitingLastSummary = str("ryd_statistics_getFetchCallResponseTimeLast_rate_limit_summary"); } else { fetchCallTimeWaitingLastSummary = createMillisecondStringFromNumber(fetchCallTimeWaitingLast); } statisticPreference = new Preference(context); statisticPreference.setSelectable(false); - statisticPreference.setTitle(str("revanced_ryd_statistics_getFetchCallResponseTimeLast_title")); + statisticPreference.setTitle(str("ryd_statistics_getFetchCallResponseTimeLast_title")); statisticPreference.setSummary(fetchCallTimeWaitingLastSummary); preferenceScreen.addPreference(statisticPreference); statisticPreference = new Preference(context); statisticPreference.setSelectable(false); - statisticPreference.setTitle(str("revanced_ryd_statistics_getFetchCallCount_title")); + statisticPreference.setTitle(str("ryd_statistics_getFetchCallCount_title")); statisticPreference.setSummary(createSummaryText(ReturnYouTubeDislikeApi.getFetchCallCount(), - "revanced_ryd_statistics_getFetchCallCount_zero_summary", - "revanced_ryd_statistics_getFetchCallCount_non_zero_summary")); + "ryd_statistics_getFetchCallCount_zero_summary", + "ryd_statistics_getFetchCallCount_non_zero_summary")); preferenceScreen.addPreference(statisticPreference); statisticPreference = new Preference(context); statisticPreference.setSelectable(false); - statisticPreference.setTitle(str("revanced_ryd_statistics_getFetchCallNumberOfFailures_title")); + statisticPreference.setTitle(str("ryd_statistics_getFetchCallNumberOfFailures_title")); statisticPreference.setSummary(createSummaryText(ReturnYouTubeDislikeApi.getFetchCallNumberOfFailures(), - "revanced_ryd_statistics_getFetchCallNumberOfFailures_zero_summary", - "revanced_ryd_statistics_getFetchCallNumberOfFailures_non_zero_summary")); + "ryd_statistics_getFetchCallNumberOfFailures_zero_summary", + "ryd_statistics_getFetchCallNumberOfFailures_non_zero_summary")); preferenceScreen.addPreference(statisticPreference); statisticPreference = new Preference(context); statisticPreference.setSelectable(false); - statisticPreference.setTitle(str("revanced_ryd_statistics_getNumberOfRateLimitRequestsEncountered_title")); + statisticPreference.setTitle(str("ryd_statistics_getNumberOfRateLimitRequestsEncountered_title")); statisticPreference.setSummary(createSummaryText(ReturnYouTubeDislikeApi.getNumberOfRateLimitRequestsEncountered(), - "revanced_ryd_statistics_getNumberOfRateLimitRequestsEncountered_zero_summary", - "revanced_ryd_statistics_getNumberOfRateLimitRequestsEncountered_non_zero_summary")); + "ryd_statistics_getNumberOfRateLimitRequestsEncountered_zero_summary", + "ryd_statistics_getNumberOfRateLimitRequestsEncountered_non_zero_summary")); preferenceScreen.addPreference(statisticPreference); } } @@ -219,7 +219,7 @@ private static String createSummaryText(int value, String summaryStringZeroKey, } private static String createMillisecondStringFromNumber(long number) { - return String.format(str("revanced_ryd_statistics_millisecond_text"), number); + return String.format(str("ryd_statistics_millisecond_text"), number); } } diff --git a/app/src/main/java/app/revanced/integrations/videoplayer/ExternalDownloadButton.java b/app/src/main/java/app/revanced/integrations/videoplayer/ExternalDownloadButton.java index 0a2244f008..e62a323360 100644 --- a/app/src/main/java/app/revanced/integrations/videoplayer/ExternalDownloadButton.java +++ b/app/src/main/java/app/revanced/integrations/videoplayer/ExternalDownloadButton.java @@ -60,7 +60,7 @@ private static void onDownloadClick(View view) { // If the package is not installed, show the toast if (!packageEnabled) { - ReVancedUtils.showToastLong(downloaderPackageName + " " + StringRef.str("external_downloader_not_installed_warning")); + ReVancedUtils.showToastLong(downloaderPackageName + " " + StringRef.str("revanced_external_downloader_not_installed_warning")); return; } From 527ab28e9e721115812bf51eac5ed9abadb9fcf8 Mon Sep 17 00:00:00 2001 From: LisoUseInAIKyrios <118716522+LisoUseInAIKyrios@users.noreply.github.com> Date: Mon, 5 Jun 2023 23:47:33 +0400 Subject: [PATCH 05/48] sort by actual title name (works when localized too) --- .../ReVancedSettingsFragment.java | 2 + .../settingsmenu/SettingsUtils.java | 44 +++++++++++++++++++ .../ReVancedSettingsFragment.java | 8 ++++ 3 files changed, 54 insertions(+) create mode 100644 app/src/main/java/app/revanced/integrations/settingsmenu/SettingsUtils.java 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 9bbc83870e..454381d718 100644 --- a/app/src/main/java/app/revanced/integrations/settingsmenu/ReVancedSettingsFragment.java +++ b/app/src/main/java/app/revanced/integrations/settingsmenu/ReVancedSettingsFragment.java @@ -150,6 +150,8 @@ public void onActivityCreated(@Nullable Bundle savedInstanceState) { } } + SettingsUtils.sortPreferenceScreenByTitle(getPreferenceScreen()); + preferenceManager.getSharedPreferences().registerOnSharedPreferenceChangeListener(listener); } catch (Exception ex) { LogHelper.printException(() -> "onActivityCreated() failure", ex); diff --git a/app/src/main/java/app/revanced/integrations/settingsmenu/SettingsUtils.java b/app/src/main/java/app/revanced/integrations/settingsmenu/SettingsUtils.java new file mode 100644 index 0000000000..1f6307cfd7 --- /dev/null +++ b/app/src/main/java/app/revanced/integrations/settingsmenu/SettingsUtils.java @@ -0,0 +1,44 @@ +package app.revanced.integrations.settingsmenu; + +import android.preference.Preference; +import android.preference.PreferenceScreen; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +/** + * Class is used across multiple target apps. + * + * This entire class can _not_ reference {@link app.revanced.integrations.settings.SettingsEnum}, + * {@link app.revanced.integrations.utils.ReVancedUtils}, or any other code that references these. + */ +public class SettingsUtils { + + /** + * Sort the preferences by title and ignore the casing. + * + * Android Preferences are automatically sorted by title, + * but if using a localized string key it sorts on the key and not the actual title text that's used at runtime. + */ + public static void sortPreferenceScreenByTitle(PreferenceScreen screen) { + final int prefCount = screen.getPreferenceCount(); + List preferences = new ArrayList<>(prefCount); + for (int i = 0; i < prefCount; i++) { + Preference preference = screen.getPreference(i); + if (preference instanceof PreferenceScreen) { + sortPreferenceScreenByTitle((PreferenceScreen)preference); + } + preferences.add(preference); + } + Collections.sort(preferences, (pref1, pref2) -> + pref1.getTitle().toString().toLowerCase().compareTo(pref2.getTitle().toString().toLowerCase()) + ); + + int prefIndex = 0; + for (Preference pref : preferences) { + pref.setOrder(prefIndex++); + } + } + +} diff --git a/app/src/main/java/app/revanced/twitch/settingsmenu/ReVancedSettingsFragment.java b/app/src/main/java/app/revanced/twitch/settingsmenu/ReVancedSettingsFragment.java index ed76480b94..0382571d20 100644 --- a/app/src/main/java/app/revanced/twitch/settingsmenu/ReVancedSettingsFragment.java +++ b/app/src/main/java/app/revanced/twitch/settingsmenu/ReVancedSettingsFragment.java @@ -113,6 +113,14 @@ public void onCreate(Bundle bundle) { } } + @Override + public void onActivityCreated(@Nullable Bundle savedInstanceState) { + super.onActivityCreated(savedInstanceState); + + // TODO: uncomment this line, to sort the preferences by title + //SettingsUtils.sortPreferenceScreenByTitle(getPreferenceScreen()); + } + @Override public void onDestroy() { if (this.registered) { From b4c474c013010a3b374acfd7573c2b7976ec5480 Mon Sep 17 00:00:00 2001 From: LisoUseInAIKyrios <118716522+LisoUseInAIKyrios@users.noreply.github.com> Date: Tue, 6 Jun 2023 15:55:52 +0400 Subject: [PATCH 06/48] no functional changes: renamed classes --- .../revanced/tiktok/settings/SettingsEnum.java | 6 +++--- ...ava => TikTokReVancedSettingsFragment.java} | 6 +++--- ...ttingsMenu.java => TikTokSettingsMenu.java} | 10 +++++----- ...ncedUtils.java => ReVancedTikTokUtils.java} | 4 ++-- .../twitch/adblock/PurpleAdblockService.java | 4 ++-- .../revanced/twitch/adblock/TTVLolService.java | 4 ++-- .../twitch/api/RequestInterceptor.java | 12 ++++++------ .../patches/ShowDeletedMessagesPatch.java | 4 ++-- .../revanced/twitch/settings/SettingsEnum.java | 6 +++--- ...ava => ReVancedTwitchSettingsFragment.java} | 12 ++++++------ ...ingsHooks.java => TwitchSettingsHooks.java} | 18 +++++++++--------- .../app/revanced/twitch/utils/LogHelper.java | 3 +-- ...ncedUtils.java => ReVancedTwitchUtils.java} | 2 +- 13 files changed, 45 insertions(+), 46 deletions(-) rename app/src/main/java/app/revanced/tiktok/settingsmenu/{ReVancedSettingsFragment.java => TikTokReVancedSettingsFragment.java} (97%) rename app/src/main/java/app/revanced/tiktok/settingsmenu/{SettingsMenu.java => TikTokSettingsMenu.java} (81%) rename app/src/main/java/app/revanced/tiktok/utils/{ReVancedUtils.java => ReVancedTikTokUtils.java} (73%) rename app/src/main/java/app/revanced/twitch/settingsmenu/{ReVancedSettingsFragment.java => ReVancedTwitchSettingsFragment.java} (91%) rename app/src/main/java/app/revanced/twitch/settingsmenu/{SettingsHooks.java => TwitchSettingsHooks.java} (84%) rename app/src/main/java/app/revanced/twitch/utils/{ReVancedUtils.java => ReVancedTwitchUtils.java} (98%) diff --git a/app/src/main/java/app/revanced/tiktok/settings/SettingsEnum.java b/app/src/main/java/app/revanced/tiktok/settings/SettingsEnum.java index 2318c8696f..7e2c987e04 100644 --- a/app/src/main/java/app/revanced/tiktok/settings/SettingsEnum.java +++ b/app/src/main/java/app/revanced/tiktok/settings/SettingsEnum.java @@ -11,7 +11,7 @@ import androidx.annotation.NonNull; import app.revanced.tiktok.utils.LogHelper; -import app.revanced.tiktok.utils.ReVancedUtils; +import app.revanced.tiktok.utils.ReVancedTikTokUtils; public enum SettingsEnum { //TikTok Settings @@ -61,7 +61,7 @@ public enum SettingsEnum { private static void loadAllSettings() { try { - Context context = ReVancedUtils.getAppContext(); + Context context = ReVancedTikTokUtils.getAppContext(); if (context == null) { Log.e("revanced: SettingsEnum", "Context returned null! Settings NOT initialized"); return; @@ -110,7 +110,7 @@ public static void setValue(SettingsEnum setting, Object newValue) { } public void saveValue(Object newValue) { - Context context = ReVancedUtils.getAppContext(); + Context context = ReVancedTikTokUtils.getAppContext(); if (context == null) { LogHelper.printException(SettingsEnum.class, "Context on SaveValue is null!"); return; diff --git a/app/src/main/java/app/revanced/tiktok/settingsmenu/ReVancedSettingsFragment.java b/app/src/main/java/app/revanced/tiktok/settingsmenu/TikTokReVancedSettingsFragment.java similarity index 97% rename from app/src/main/java/app/revanced/tiktok/settingsmenu/ReVancedSettingsFragment.java rename to app/src/main/java/app/revanced/tiktok/settingsmenu/TikTokReVancedSettingsFragment.java index 0febb9873b..d577a45521 100644 --- a/app/src/main/java/app/revanced/tiktok/settingsmenu/ReVancedSettingsFragment.java +++ b/app/src/main/java/app/revanced/tiktok/settingsmenu/TikTokReVancedSettingsFragment.java @@ -23,9 +23,9 @@ import app.revanced.tiktok.settings.SettingsEnum; import app.revanced.tiktok.settings.SharedPrefCategory; import app.revanced.tiktok.settingsmenu.preference.DownloadPathPreference; -import app.revanced.tiktok.utils.ReVancedUtils; +import app.revanced.tiktok.utils.ReVancedTikTokUtils; -public class ReVancedSettingsFragment extends PreferenceFragment { +public class TikTokReVancedSettingsFragment extends PreferenceFragment { private boolean Registered = false; private boolean settingsInitialized = false; @@ -34,7 +34,7 @@ public class ReVancedSettingsFragment extends PreferenceFragment { for (SettingsEnum setting : SettingsEnum.values()) { if (!setting.path.equals(str)) continue; - if (ReVancedUtils.getAppContext() != null && this.settingsInitialized && setting.rebootApp) { + if (ReVancedTikTokUtils.getAppContext() != null && this.settingsInitialized && setting.rebootApp) { rebootDialog(getActivity()); } } diff --git a/app/src/main/java/app/revanced/tiktok/settingsmenu/SettingsMenu.java b/app/src/main/java/app/revanced/tiktok/settingsmenu/TikTokSettingsMenu.java similarity index 81% rename from app/src/main/java/app/revanced/tiktok/settingsmenu/SettingsMenu.java rename to app/src/main/java/app/revanced/tiktok/settingsmenu/TikTokSettingsMenu.java index 7449ed8ad1..b209c5ac31 100644 --- a/app/src/main/java/app/revanced/tiktok/settingsmenu/SettingsMenu.java +++ b/app/src/main/java/app/revanced/tiktok/settingsmenu/TikTokSettingsMenu.java @@ -10,10 +10,10 @@ import com.bytedance.ies.ugc.aweme.commercialize.compliance.personalization.AdPersonalizationActivity; import app.revanced.tiktok.utils.LogHelper; -import app.revanced.tiktok.utils.ReVancedUtils; +import app.revanced.tiktok.utils.ReVancedTikTokUtils; -public class SettingsMenu { +public class TikTokSettingsMenu { public static void initializeSettings(AdPersonalizationActivity base) { SettingsStatus.load(); LinearLayout linearLayout = new LinearLayout(base); @@ -27,18 +27,18 @@ public static void initializeSettings(AdPersonalizationActivity base) { fragment.setId(fragmentId); linearLayout.addView(fragment); base.setContentView(linearLayout); - PreferenceFragment preferenceFragment = new ReVancedSettingsFragment(); + PreferenceFragment preferenceFragment = new TikTokReVancedSettingsFragment(); base.getFragmentManager().beginTransaction().replace(fragmentId, preferenceFragment).commit(); } public static void startSettingsActivity() { - Context appContext = ReVancedUtils.getAppContext(); + Context appContext = ReVancedTikTokUtils.getAppContext(); if (appContext != null) { Intent intent = new Intent(appContext, AdPersonalizationActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); appContext.startActivity(intent); } else { - LogHelper.debug(SettingsMenu.class, "ReVancedUtils.getAppContext() return null"); + LogHelper.debug(TikTokSettingsMenu.class, "ReVancedUtils.getAppContext() return null"); } } } diff --git a/app/src/main/java/app/revanced/tiktok/utils/ReVancedUtils.java b/app/src/main/java/app/revanced/tiktok/utils/ReVancedTikTokUtils.java similarity index 73% rename from app/src/main/java/app/revanced/tiktok/utils/ReVancedUtils.java rename to app/src/main/java/app/revanced/tiktok/utils/ReVancedTikTokUtils.java index 7ac089ff5e..48227152f6 100644 --- a/app/src/main/java/app/revanced/tiktok/utils/ReVancedUtils.java +++ b/app/src/main/java/app/revanced/tiktok/utils/ReVancedTikTokUtils.java @@ -2,7 +2,7 @@ import android.content.Context; -public class ReVancedUtils { +public class ReVancedTikTokUtils { //Used by TiktokIntegrations patch public static Context context; @@ -12,7 +12,7 @@ public static Context getAppContext() { if (context != null) { return context; } - LogHelper.printException(ReVancedUtils.class, "Context is null!"); + LogHelper.printException(ReVancedTikTokUtils.class, "Context is null!"); return null; } } \ No newline at end of file diff --git a/app/src/main/java/app/revanced/twitch/adblock/PurpleAdblockService.java b/app/src/main/java/app/revanced/twitch/adblock/PurpleAdblockService.java index 5b2db973b2..964ff6a0be 100644 --- a/app/src/main/java/app/revanced/twitch/adblock/PurpleAdblockService.java +++ b/app/src/main/java/app/revanced/twitch/adblock/PurpleAdblockService.java @@ -5,7 +5,7 @@ import app.revanced.twitch.api.RetrofitClient; import app.revanced.twitch.utils.LogHelper; -import app.revanced.twitch.utils.ReVancedUtils; +import app.revanced.twitch.utils.ReVancedTwitchUtils; import okhttp3.HttpUrl; import okhttp3.Request; import okhttp3.ResponseBody; @@ -18,7 +18,7 @@ public class PurpleAdblockService implements IAdblockService { @Override public String friendlyName() { - return ReVancedUtils.getString("revanced_proxy_purpleadblock"); + return ReVancedTwitchUtils.getString("revanced_proxy_purpleadblock"); } @Override diff --git a/app/src/main/java/app/revanced/twitch/adblock/TTVLolService.java b/app/src/main/java/app/revanced/twitch/adblock/TTVLolService.java index 6aa31d823f..bd761e0cc0 100644 --- a/app/src/main/java/app/revanced/twitch/adblock/TTVLolService.java +++ b/app/src/main/java/app/revanced/twitch/adblock/TTVLolService.java @@ -4,14 +4,14 @@ import java.util.Random; import app.revanced.twitch.utils.LogHelper; -import app.revanced.twitch.utils.ReVancedUtils; +import app.revanced.twitch.utils.ReVancedTwitchUtils; import okhttp3.HttpUrl; import okhttp3.Request; public class TTVLolService implements IAdblockService { @Override public String friendlyName() { - return ReVancedUtils.getString("revanced_proxy_ttv_lol"); + return ReVancedTwitchUtils.getString("revanced_proxy_ttv_lol"); } // TTV.lol is sometimes unstable diff --git a/app/src/main/java/app/revanced/twitch/api/RequestInterceptor.java b/app/src/main/java/app/revanced/twitch/api/RequestInterceptor.java index 34cda6f6ac..2c3abce377 100644 --- a/app/src/main/java/app/revanced/twitch/api/RequestInterceptor.java +++ b/app/src/main/java/app/revanced/twitch/api/RequestInterceptor.java @@ -12,7 +12,7 @@ import app.revanced.twitch.adblock.TTVLolService; import app.revanced.twitch.settings.SettingsEnum; import app.revanced.twitch.utils.LogHelper; -import app.revanced.twitch.utils.ReVancedUtils; +import app.revanced.twitch.utils.ReVancedTwitchUtils; import okhttp3.Interceptor; import okhttp3.Response; @@ -47,7 +47,7 @@ public Response intercept(@NonNull Chain chain) throws IOException { if (!available || rewritten == null) { - ReVancedUtils.toast(String.format(ReVancedUtils.getString("revanced_embedded_ads_service_unavailable"), activeService.friendlyName()), true); + ReVancedTwitchUtils.toast(String.format(ReVancedTwitchUtils.getString("revanced_embedded_ads_service_unavailable"), activeService.friendlyName()), true); return chain.proceed(originalRequest); } @@ -75,7 +75,7 @@ public Response intercept(@NonNull Chain chain) throws IOException { } // maxAttempts exceeded; giving up on using the ad blocker - ReVancedUtils.toast(String.format(ReVancedUtils.getString("revanced_embedded_ads_service_failed"), activeService.friendlyName()), true); + ReVancedTwitchUtils.toast(String.format(ReVancedTwitchUtils.getString("revanced_embedded_ads_service_failed"), activeService.friendlyName()), true); } @@ -87,11 +87,11 @@ public Response intercept(@NonNull Chain chain) throws IOException { private void updateActiveService() { var current = SettingsEnum.BLOCK_EMBEDDED_ADS.getString(); - if (current.equals(ReVancedUtils.getString("key_revanced_proxy_ttv_lol")) && !(activeService instanceof TTVLolService)) + if (current.equals(ReVancedTwitchUtils.getString("key_revanced_proxy_ttv_lol")) && !(activeService instanceof TTVLolService)) activeService = new TTVLolService(); - else if (current.equals(ReVancedUtils.getString("key_revanced_proxy_purpleadblock")) && !(activeService instanceof PurpleAdblockService)) + else if (current.equals(ReVancedTwitchUtils.getString("key_revanced_proxy_purpleadblock")) && !(activeService instanceof PurpleAdblockService)) activeService = new PurpleAdblockService(); - else if (current.equals(ReVancedUtils.getString("key_revanced_proxy_disabled"))) + else if (current.equals(ReVancedTwitchUtils.getString("key_revanced_proxy_disabled"))) activeService = null; } } diff --git a/app/src/main/java/app/revanced/twitch/patches/ShowDeletedMessagesPatch.java b/app/src/main/java/app/revanced/twitch/patches/ShowDeletedMessagesPatch.java index 44ceb4c43a..41834c73f1 100644 --- a/app/src/main/java/app/revanced/twitch/patches/ShowDeletedMessagesPatch.java +++ b/app/src/main/java/app/revanced/twitch/patches/ShowDeletedMessagesPatch.java @@ -12,7 +12,7 @@ import java.util.Objects; import app.revanced.twitch.settings.SettingsEnum; -import app.revanced.twitch.utils.ReVancedUtils; +import app.revanced.twitch.utils.ReVancedTwitchUtils; import tv.twitch.android.shared.chat.util.ClickableUsernameSpan; public class ShowDeletedMessagesPatch { @@ -30,7 +30,7 @@ public static Spanned reformatDeletedMessage(Spanned original) { SpannableStringBuilder ssb = new SpannableStringBuilder(original); ssb.setSpan(new StrikethroughSpan(), 0, original.length(), 0); - ssb.append(" (").append(ReVancedUtils.getString("revanced_deleted_msg")).append(")"); + ssb.append(" (").append(ReVancedTwitchUtils.getString("revanced_deleted_msg")).append(")"); ssb.setSpan(new StyleSpan(Typeface.ITALIC), original.length(), ssb.length(), 0); // Gray-out username diff --git a/app/src/main/java/app/revanced/twitch/settings/SettingsEnum.java b/app/src/main/java/app/revanced/twitch/settings/SettingsEnum.java index 6e1833873e..c023a4b676 100644 --- a/app/src/main/java/app/revanced/twitch/settings/SettingsEnum.java +++ b/app/src/main/java/app/revanced/twitch/settings/SettingsEnum.java @@ -11,7 +11,7 @@ import androidx.annotation.NonNull; import app.revanced.twitch.utils.LogHelper; -import app.revanced.twitch.utils.ReVancedUtils; +import app.revanced.twitch.utils.ReVancedTwitchUtils; public enum SettingsEnum { /* Ads */ @@ -57,7 +57,7 @@ public enum SettingsEnum { } private static void loadAllSettings() { - ReVancedUtils.ifContextAttached((context -> { + ReVancedTwitchUtils.ifContextAttached((context -> { try { SharedPreferences prefs = context.getSharedPreferences(REVANCED_PREFS, Context.MODE_PRIVATE); for (SettingsEnum setting : values()) { @@ -123,7 +123,7 @@ private void setValue(Object newValue) { } public void saveValue(Object newValue) { - ReVancedUtils.ifContextAttached((context) -> { + ReVancedTwitchUtils.ifContextAttached((context) -> { SharedPreferences prefs = context.getSharedPreferences(REVANCED_PREFS, Context.MODE_PRIVATE); if (returnType == BOOLEAN) { prefs.edit().putBoolean(path, (Boolean)newValue).apply(); diff --git a/app/src/main/java/app/revanced/twitch/settingsmenu/ReVancedSettingsFragment.java b/app/src/main/java/app/revanced/twitch/settingsmenu/ReVancedTwitchSettingsFragment.java similarity index 91% rename from app/src/main/java/app/revanced/twitch/settingsmenu/ReVancedSettingsFragment.java rename to app/src/main/java/app/revanced/twitch/settingsmenu/ReVancedTwitchSettingsFragment.java index 0382571d20..5e338d1140 100644 --- a/app/src/main/java/app/revanced/twitch/settingsmenu/ReVancedSettingsFragment.java +++ b/app/src/main/java/app/revanced/twitch/settingsmenu/ReVancedTwitchSettingsFragment.java @@ -21,10 +21,10 @@ import app.revanced.twitch.settings.SettingsEnum; import app.revanced.twitch.utils.LogHelper; -import app.revanced.twitch.utils.ReVancedUtils; +import app.revanced.twitch.utils.ReVancedTwitchUtils; import tv.twitch.android.app.core.LandingActivity; -public class ReVancedSettingsFragment extends PreferenceFragment { +public class ReVancedTwitchSettingsFragment extends PreferenceFragment { private boolean registered = false; private boolean settingsInitialized = false; @@ -61,7 +61,7 @@ else if (pref instanceof ListPreference) { LogHelper.error("Setting '%s' cannot be handled!", pref); } - if (ReVancedUtils.getContext() != null && key != null && settingsInitialized && setting.rebootApp) { + if (ReVancedTwitchUtils.getContext() != null && key != null && settingsInitialized && setting.rebootApp) { rebootDialog(getActivity()); } @@ -140,9 +140,9 @@ private void reboot(Activity activity) { private void rebootDialog(final Activity activity) { new AlertDialog.Builder(activity). - setMessage(ReVancedUtils.getString("revanced_reboot_message")). - setPositiveButton(ReVancedUtils.getString("revanced_reboot"), (dialog, i) -> reboot(activity)) - .setNegativeButton(ReVancedUtils.getString("revanced_cancel"), null) + setMessage(ReVancedTwitchUtils.getString("revanced_reboot_message")). + setPositiveButton(ReVancedTwitchUtils.getString("revanced_reboot"), (dialog, i) -> reboot(activity)) + .setNegativeButton(ReVancedTwitchUtils.getString("revanced_cancel"), null) .show(); } } diff --git a/app/src/main/java/app/revanced/twitch/settingsmenu/SettingsHooks.java b/app/src/main/java/app/revanced/twitch/settingsmenu/TwitchSettingsHooks.java similarity index 84% rename from app/src/main/java/app/revanced/twitch/settingsmenu/SettingsHooks.java rename to app/src/main/java/app/revanced/twitch/settingsmenu/TwitchSettingsHooks.java index 749a188acf..d2559efd4d 100644 --- a/app/src/main/java/app/revanced/twitch/settingsmenu/SettingsHooks.java +++ b/app/src/main/java/app/revanced/twitch/settingsmenu/TwitchSettingsHooks.java @@ -1,7 +1,7 @@ package app.revanced.twitch.settingsmenu; -import static app.revanced.twitch.utils.ReVancedUtils.getIdentifier; -import static app.revanced.twitch.utils.ReVancedUtils.getStringId; +import static app.revanced.twitch.utils.ReVancedTwitchUtils.getIdentifier; +import static app.revanced.twitch.utils.ReVancedTwitchUtils.getStringId; import android.content.Intent; import android.os.Bundle; @@ -12,14 +12,14 @@ import java.util.ArrayList; import java.util.List; -import app.revanced.twitch.utils.ReVancedUtils; +import app.revanced.twitch.utils.ReVancedTwitchUtils; import app.revanced.twitch.utils.LogHelper; import tv.twitch.android.feature.settings.menu.SettingsMenuGroup; import tv.twitch.android.settings.SettingsActivity; -public class SettingsHooks { +public class TwitchSettingsHooks { private static final int REVANCED_SETTINGS_MENU_ITEM_ID = 0x7; - private static final String EXTRA_REVANCED_SETTINGS = "app.revanced.twitch.settings"; + private static final String REVANCED_TWITCH_SETTINGS_INTENT_NAME = "app.revanced.twitch.settings"; /** * Launches SettingsActivity and show ReVanced settings @@ -27,10 +27,10 @@ public class SettingsHooks { public static void startSettingsActivity() { LogHelper.debug("Launching ReVanced settings"); - ReVancedUtils.ifContextAttached((c) -> { + ReVancedTwitchUtils.ifContextAttached((c) -> { Intent intent = new Intent(c, SettingsActivity.class); Bundle bundle = new Bundle(); - bundle.putBoolean(EXTRA_REVANCED_SETTINGS, true); + bundle.putBoolean(REVANCED_TWITCH_SETTINGS_INTENT_NAME, true); intent.putExtras(bundle); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); c.startActivity(intent); @@ -90,13 +90,13 @@ public static boolean handleSettingMenuOnClick(Enum item) { * @return Returns true if the revanced settings have been requested by the user, otherwise false */ public static boolean handleSettingsCreation(AppCompatActivity base) { - if(!base.getIntent().getBooleanExtra(EXTRA_REVANCED_SETTINGS, false)) { + if(!base.getIntent().getBooleanExtra(REVANCED_TWITCH_SETTINGS_INTENT_NAME, false)) { LogHelper.debug("Revanced settings not requested"); return false; // User wants to enter another settings fragment } LogHelper.debug("ReVanced settings requested"); - ReVancedSettingsFragment fragment = new ReVancedSettingsFragment(); + ReVancedTwitchSettingsFragment fragment = new ReVancedTwitchSettingsFragment(); ActionBar supportActionBar = base.getSupportActionBar(); if(supportActionBar != null) supportActionBar.setTitle(getStringId("revanced_settings")); diff --git a/app/src/main/java/app/revanced/twitch/utils/LogHelper.java b/app/src/main/java/app/revanced/twitch/utils/LogHelper.java index 899aa20aa6..63200df672 100644 --- a/app/src/main/java/app/revanced/twitch/utils/LogHelper.java +++ b/app/src/main/java/app/revanced/twitch/utils/LogHelper.java @@ -1,7 +1,6 @@ package app.revanced.twitch.utils; import android.util.Log; -import android.widget.Toast; import app.revanced.twitch.settings.SettingsEnum; @@ -49,7 +48,7 @@ public static void printException(String message, Throwable ex) { private static void showDebugToast(String msg) { if(SettingsEnum.DEBUG_MODE.getBoolean()) { - ReVancedUtils.toast(msg, false); + ReVancedTwitchUtils.toast(msg, false); } } } diff --git a/app/src/main/java/app/revanced/twitch/utils/ReVancedUtils.java b/app/src/main/java/app/revanced/twitch/utils/ReVancedTwitchUtils.java similarity index 98% rename from app/src/main/java/app/revanced/twitch/utils/ReVancedUtils.java rename to app/src/main/java/app/revanced/twitch/utils/ReVancedTwitchUtils.java index 9e9ec9569a..bbdb0b191f 100644 --- a/app/src/main/java/app/revanced/twitch/utils/ReVancedUtils.java +++ b/app/src/main/java/app/revanced/twitch/utils/ReVancedTwitchUtils.java @@ -6,7 +6,7 @@ import android.os.Looper; import android.widget.Toast; -public class ReVancedUtils { +public class ReVancedTwitchUtils { @SuppressLint("StaticFieldLeak") public static Context context; From 56b38d3a7e126517f82695731459438b4c6a6c3f Mon Sep 17 00:00:00 2001 From: LisoUseInAIKyrios <118716522+LisoUseInAIKyrios@users.noreply.github.com> Date: Tue, 6 Jun 2023 16:05:10 +0400 Subject: [PATCH 07/48] sorting, comments --- .../revanced/integrations/settingsmenu/SettingsUtils.java | 8 ++++++-- .../settingsmenu/ReVancedTwitchSettingsFragment.java | 4 ++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/app/revanced/integrations/settingsmenu/SettingsUtils.java b/app/src/main/java/app/revanced/integrations/settingsmenu/SettingsUtils.java index 1f6307cfd7..d20371aa0f 100644 --- a/app/src/main/java/app/revanced/integrations/settingsmenu/SettingsUtils.java +++ b/app/src/main/java/app/revanced/integrations/settingsmenu/SettingsUtils.java @@ -10,8 +10,12 @@ /** * Class is used across multiple target apps. * - * This entire class can _not_ reference {@link app.revanced.integrations.settings.SettingsEnum}, - * {@link app.revanced.integrations.utils.ReVancedUtils}, or any other code that references these. + * This entire class can _not_ reference: + * {@link app.revanced.integrations.settings.SettingsEnum} + * {@link app.revanced.twitch.settings.SettingsEnum} + * {@link app.revanced.tiktok.settings.SettingsEnum} + * + * or any other code that references these app specific integration code. */ public class SettingsUtils { diff --git a/app/src/main/java/app/revanced/twitch/settingsmenu/ReVancedTwitchSettingsFragment.java b/app/src/main/java/app/revanced/twitch/settingsmenu/ReVancedTwitchSettingsFragment.java index 5e338d1140..52ef6c5c7d 100644 --- a/app/src/main/java/app/revanced/twitch/settingsmenu/ReVancedTwitchSettingsFragment.java +++ b/app/src/main/java/app/revanced/twitch/settingsmenu/ReVancedTwitchSettingsFragment.java @@ -19,6 +19,7 @@ import androidx.annotation.Nullable; +import app.revanced.integrations.settingsmenu.SettingsUtils; import app.revanced.twitch.settings.SettingsEnum; import app.revanced.twitch.utils.LogHelper; import app.revanced.twitch.utils.ReVancedTwitchUtils; @@ -117,8 +118,7 @@ public void onCreate(Bundle bundle) { public void onActivityCreated(@Nullable Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); - // TODO: uncomment this line, to sort the preferences by title - //SettingsUtils.sortPreferenceScreenByTitle(getPreferenceScreen()); + SettingsUtils.sortPreferenceScreenByTitle(getPreferenceScreen()); } @Override From 5052b6e547ec564cb5a06ae799237e86ed8f906e Mon Sep 17 00:00:00 2001 From: LisoUseInAIKyrios <118716522+LisoUseInAIKyrios@users.noreply.github.com> Date: Tue, 6 Jun 2023 19:21:08 +0400 Subject: [PATCH 08/48] adding clarity --- ...mPreferenceCategory.java => TwitchPreferenceCategory.java} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename app/src/main/java/app/revanced/twitch/settingsmenu/preference/{CustomPreferenceCategory.java => TwitchPreferenceCategory.java} (80%) diff --git a/app/src/main/java/app/revanced/twitch/settingsmenu/preference/CustomPreferenceCategory.java b/app/src/main/java/app/revanced/twitch/settingsmenu/preference/TwitchPreferenceCategory.java similarity index 80% rename from app/src/main/java/app/revanced/twitch/settingsmenu/preference/CustomPreferenceCategory.java rename to app/src/main/java/app/revanced/twitch/settingsmenu/preference/TwitchPreferenceCategory.java index ec92a50528..5f9fd381b8 100644 --- a/app/src/main/java/app/revanced/twitch/settingsmenu/preference/CustomPreferenceCategory.java +++ b/app/src/main/java/app/revanced/twitch/settingsmenu/preference/TwitchPreferenceCategory.java @@ -7,8 +7,8 @@ import android.view.View; import android.widget.TextView; -public class CustomPreferenceCategory extends PreferenceCategory { - public CustomPreferenceCategory(Context context, AttributeSet attrs) { +public class TwitchPreferenceCategory extends PreferenceCategory { + public TwitchPreferenceCategory(Context context, AttributeSet attrs) { super(context, attrs); } From bcf40d06082e95bbcd4f2415b1276e8d51231997 Mon Sep 17 00:00:00 2001 From: LisoUseInAIKyrios <118716522+LisoUseInAIKyrios@users.noreply.github.com> Date: Tue, 6 Jun 2023 19:54:26 +0400 Subject: [PATCH 09/48] logging --- .../app/revanced/tiktok/settingsmenu/TikTokSettingsMenu.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/src/main/java/app/revanced/tiktok/settingsmenu/TikTokSettingsMenu.java b/app/src/main/java/app/revanced/tiktok/settingsmenu/TikTokSettingsMenu.java index b209c5ac31..7373ecdc6c 100644 --- a/app/src/main/java/app/revanced/tiktok/settingsmenu/TikTokSettingsMenu.java +++ b/app/src/main/java/app/revanced/tiktok/settingsmenu/TikTokSettingsMenu.java @@ -12,7 +12,6 @@ import app.revanced.tiktok.utils.LogHelper; import app.revanced.tiktok.utils.ReVancedTikTokUtils; - public class TikTokSettingsMenu { public static void initializeSettings(AdPersonalizationActivity base) { SettingsStatus.load(); @@ -38,7 +37,7 @@ public static void startSettingsActivity() { intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); appContext.startActivity(intent); } else { - LogHelper.debug(TikTokSettingsMenu.class, "ReVancedUtils.getAppContext() return null"); + LogHelper.printException(TikTokSettingsMenu.class, "Context is null"); } } } From 4b98b08d22af6056eb4e738c917032f48ef14232 Mon Sep 17 00:00:00 2001 From: LisoUseInAIKyrios <118716522+LisoUseInAIKyrios@users.noreply.github.com> Date: Wed, 7 Jun 2023 17:01:02 +0400 Subject: [PATCH 10/48] fixing renamed string keys --- .../ReturnYouTubeDislike.java | 4 +-- .../requests/ReturnYouTubeDislikeApi.java | 34 +++++++++---------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/app/src/main/java/app/revanced/integrations/returnyoutubedislike/ReturnYouTubeDislike.java b/app/src/main/java/app/revanced/integrations/returnyoutubedislike/ReturnYouTubeDislike.java index fc577f5354..fc4b3b71a3 100644 --- a/app/src/main/java/app/revanced/integrations/returnyoutubedislike/ReturnYouTubeDislike.java +++ b/app/src/main/java/app/revanced/integrations/returnyoutubedislike/ReturnYouTubeDislike.java @@ -376,7 +376,7 @@ public static void sendVote(@NonNull Vote vote) { // Or shorts was loaded with regular video present, then shorts was closed, // and then user voted on the now visible original video. // Cannot send a vote, because the loaded videoId is for the wrong video. - ReVancedUtils.showToastLong(str("revanced_ryd_failure_ryd_enabled_while_playing_video_then_user_voted")); + ReVancedUtils.showToastLong(str("ryd_failure_ryd_enabled_while_playing_video_then_user_voted")); return; } @@ -484,7 +484,7 @@ private static SpannableString createDislikeSpan(@NonNull Spanned oldSpannable, // RYD data: https://returnyoutubedislikeapi.com/votes?videoId=UnrU5vxCHxw // // Change the "Likes" string to show that likes and dislikes are hidden. - String hiddenMessageString = str("revanced_ryd_video_likes_hidden_by_video_owner"); + String hiddenMessageString = str("ryd_video_likes_hidden_by_video_owner"); return newSpanUsingStylingOfAnotherSpan(oldSpannable, hiddenMessageString); } diff --git a/app/src/main/java/app/revanced/integrations/returnyoutubedislike/requests/ReturnYouTubeDislikeApi.java b/app/src/main/java/app/revanced/integrations/returnyoutubedislike/requests/ReturnYouTubeDislikeApi.java index 0965f493d0..491ddc1741 100644 --- a/app/src/main/java/app/revanced/integrations/returnyoutubedislike/requests/ReturnYouTubeDislikeApi.java +++ b/app/src/main/java/app/revanced/integrations/returnyoutubedislike/requests/ReturnYouTubeDislikeApi.java @@ -196,7 +196,7 @@ private static boolean checkIfRateLimitWasHit(int httpResponseCode) { numberOfRateLimitRequestsEncountered++; LogHelper.printDebug(() -> "API rate limit was hit. Stopping API calls for the next " + RATE_LIMIT_BACKOFF_SECONDS + " seconds"); - ReVancedUtils.showToastLong(str("revanced_ryd_failure_client_rate_limit_requested")); + ReVancedUtils.showToastLong(str("ryd_failure_client_rate_limit_requested")); return true; } return false; @@ -284,16 +284,16 @@ public static RYDVoteData fetchVotes(String videoId) { LogHelper.printDebug(() -> "Video has no like/dislikes (video is a YouTube Story?): " + videoId); return null; // do not updated connection statistics } else { - handleConnectionError(str("revanced_ryd_failure_connection_status_code", responseCode), null); + handleConnectionError(str("ryd_failure_connection_status_code", responseCode), null); } connection.disconnect(); // something went wrong, might as well disconnect } catch (SocketTimeoutException ex) { // connection timed out, response timeout, or some other network error - handleConnectionError((str("revanced_ryd_failure_connection_timeout")), ex); + handleConnectionError((str("ryd_failure_connection_timeout")), ex); } catch (IOException ex) { - handleConnectionError((str("revanced_ryd_failure_generic", ex.getMessage())), ex); + handleConnectionError((str("ryd_failure_generic", ex.getMessage())), ex); } catch (Exception ex) { // should never happen - LogHelper.printException(() -> "Failed to fetch votes", ex, str("revanced_ryd_failure_generic", ex.getMessage())); + LogHelper.printException(() -> "Failed to fetch votes", ex, str("ryd_failure_generic", ex.getMessage())); } updateStatistics(timeNetworkCallStarted, System.currentTimeMillis(), true, false); @@ -331,12 +331,12 @@ public static String registerAsNewUser() { String solution = solvePuzzle(challenge, difficulty); return confirmRegistration(userId, solution); } - handleConnectionError(str("revanced_ryd_failure_connection_status_code", responseCode), null); + handleConnectionError(str("ryd_failure_connection_status_code", responseCode), null); connection.disconnect(); } catch (SocketTimeoutException ex) { - handleConnectionError(str("revanced_ryd_failure_connection_timeout"), ex); + handleConnectionError(str("ryd_failure_connection_timeout"), ex); } catch (IOException ex) { - handleConnectionError(str("revanced_ryd_failure_generic", "registration failed"), ex); + handleConnectionError(str("ryd_failure_generic", "registration failed"), ex); } catch (Exception ex) { LogHelper.printException(() -> "Failed to register user", ex); // should never happen } @@ -378,12 +378,12 @@ private static String confirmRegistration(String userId, String solution) { final String resultLog = result == null ? "(no response)" : result; LogHelper.printInfo(() -> "Failed to confirm registration for user: " + userId + " solution: " + solution + " responseCode: " + responseCode + " responseString: " + resultLog); - handleConnectionError(str("revanced_ryd_failure_connection_status_code", responseCode), null); + handleConnectionError(str("ryd_failure_connection_status_code", responseCode), null); connection.disconnect(); // something went wrong, might as well disconnect } catch (SocketTimeoutException ex) { - handleConnectionError(str("revanced_ryd_failure_connection_timeout"), ex); + handleConnectionError(str("ryd_failure_connection_timeout"), ex); } catch (IOException ex) { - handleConnectionError(str("revanced_ryd_failure_generic", "confirm registration failed"), ex); + handleConnectionError(str("ryd_failure_generic", "confirm registration failed"), ex); } catch (Exception ex) { LogHelper.printException(() -> "Failed to confirm registration for user: " + userId + "solution: " + solution, ex); @@ -427,12 +427,12 @@ public static boolean sendVote(String videoId, String userId, ReturnYouTubeDisli } LogHelper.printInfo(() -> "Failed to send vote for video: " + videoId + " vote: " + vote + " response code was: " + responseCode); - handleConnectionError(str("revanced_ryd_failure_connection_status_code", responseCode), null); + handleConnectionError(str("ryd_failure_connection_status_code", responseCode), null); connection.disconnect(); // something went wrong, might as well disconnect } catch (SocketTimeoutException ex) { - handleConnectionError(str("revanced_ryd_failure_connection_timeout"), ex); + handleConnectionError(str("ryd_failure_connection_timeout"), ex); } catch (IOException ex) { - handleConnectionError(str("revanced_ryd_failure_generic", "send vote failed"), ex); + handleConnectionError(str("ryd_failure_generic", "send vote failed"), ex); } catch (Exception ex) { // should never happen LogHelper.printException(() -> "Failed to send vote for video: " + videoId + " vote: " + vote, ex); @@ -475,12 +475,12 @@ private static boolean confirmVote(String videoId, String userId, String solutio final String resultLog = result == null ? "(no response)" : result; LogHelper.printInfo(() -> "Failed to confirm vote for video: " + videoId + " solution: " + solution + " responseCode: " + responseCode + " responseString: " + resultLog); - handleConnectionError(str("revanced_ryd_failure_connection_status_code", responseCode), null); + handleConnectionError(str("ryd_failure_connection_status_code", responseCode), null); connection.disconnect(); // something went wrong, might as well disconnect } catch (SocketTimeoutException ex) { - handleConnectionError(str("revanced_ryd_failure_connection_timeout"), ex); + handleConnectionError(str("ryd_failure_connection_timeout"), ex); } catch (IOException ex) { - handleConnectionError(str("revanced_ryd_failure_generic", "confirm vote failed"), ex); + handleConnectionError(str("ryd_failure_generic", "confirm vote failed"), ex); } catch (Exception ex) { LogHelper.printException(() -> "Failed to confirm vote for video: " + videoId + " solution: " + solution, ex); // should never happen From 5939eda820dd721f4e2164c0e56e73166b05899c Mon Sep 17 00:00:00 2001 From: LisoUseInAIKyrios <118716522+LisoUseInAIKyrios@users.noreply.github.com> Date: Wed, 7 Jun 2023 17:06:38 +0400 Subject: [PATCH 11/48] renamed string keys --- .../java/app/revanced/integrations/patches/MicroGSupport.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/app/revanced/integrations/patches/MicroGSupport.java b/app/src/main/java/app/revanced/integrations/patches/MicroGSupport.java index ba242d3002..7d12346d9c 100644 --- a/app/src/main/java/app/revanced/integrations/patches/MicroGSupport.java +++ b/app/src/main/java/app/revanced/integrations/patches/MicroGSupport.java @@ -37,7 +37,7 @@ public static void checkAvailability() { context.getPackageManager().getPackageInfo(MICROG_PACKAGE_NAME, PackageManager.GET_ACTIVITIES); } catch (PackageManager.NameNotFoundException exception) { LogHelper.printInfo(() -> "Vanced MicroG was not found", exception); - startIntent(context, VANCED_MICROG_DOWNLOAD_LINK, str("microg_not_installed_warning")); + startIntent(context, VANCED_MICROG_DOWNLOAD_LINK, str("revanced_microg_not_installed_warning")); // Gracefully exit the app, so it does not crash. System.exit(0); @@ -47,7 +47,7 @@ public static void checkAvailability() { try (var client = context.getContentResolver().acquireContentProviderClient(VANCED_MICROG_PROVIDER)) { if (client != null) return; LogHelper.printInfo(() -> "Vanced MicroG is not running in the background"); - startIntent(context, DONT_KILL_MY_APP_LINK, str("microg_not_running_warning")); + startIntent(context, DONT_KILL_MY_APP_LINK, str("revanced_microg_not_running_warning")); } } } \ No newline at end of file From d7c18480dc73154d0503788ca17eb9b2def7f4d7 Mon Sep 17 00:00:00 2001 From: LisoUseInAIKyrios <118716522+LisoUseInAIKyrios@users.noreply.github.com> Date: Sat, 10 Jun 2023 15:45:17 +0400 Subject: [PATCH 12/48] no functional changes: renamed classes --- .../integrations/settingsmenu/ImportExportPreference.java | 6 +++--- ...ncedSettingActivity.java => YouTubeSettingActivity.java} | 4 ++-- ...edSettingsFragment.java => YouTubeSettingsFragment.java} | 2 +- ...cedSettingsFragment.java => TikTokSettingsFragment.java} | 2 +- .../revanced/tiktok/settingsmenu/TikTokSettingsMenu.java | 2 +- ...tchSettingsFragment.java => TwitchSettingsFragment.java} | 2 +- .../revanced/twitch/settingsmenu/TwitchSettingsHooks.java | 2 +- 7 files changed, 10 insertions(+), 10 deletions(-) rename app/src/main/java/app/revanced/integrations/settingsmenu/{ReVancedSettingActivity.java => YouTubeSettingActivity.java} (97%) rename app/src/main/java/app/revanced/integrations/settingsmenu/{ReVancedSettingsFragment.java => YouTubeSettingsFragment.java} (99%) rename app/src/main/java/app/revanced/tiktok/settingsmenu/{TikTokReVancedSettingsFragment.java => TikTokSettingsFragment.java} (99%) rename app/src/main/java/app/revanced/twitch/settingsmenu/{ReVancedTwitchSettingsFragment.java => TwitchSettingsFragment.java} (98%) diff --git a/app/src/main/java/app/revanced/integrations/settingsmenu/ImportExportPreference.java b/app/src/main/java/app/revanced/integrations/settingsmenu/ImportExportPreference.java index ff6397e890..40aab6a337 100644 --- a/app/src/main/java/app/revanced/integrations/settingsmenu/ImportExportPreference.java +++ b/app/src/main/java/app/revanced/integrations/settingsmenu/ImportExportPreference.java @@ -82,15 +82,15 @@ private void importSettings(String replacementSettings) { if (replacementSettings.equals(existingSettings)) { return; } - ReVancedSettingsFragment.settingImportInProgress = true; + YouTubeSettingsFragment.settingImportInProgress = true; final boolean rebootNeeded = SettingsEnum.importJSON(replacementSettings); if (rebootNeeded) { - ReVancedSettingsFragment.showRebootDialog(getContext()); + YouTubeSettingsFragment.showRebootDialog(getContext()); } } catch (Exception ex) { LogHelper.printException(() -> "importSettings failure", ex); } finally { - ReVancedSettingsFragment.settingImportInProgress = false; + YouTubeSettingsFragment.settingImportInProgress = false; } } diff --git a/app/src/main/java/app/revanced/integrations/settingsmenu/ReVancedSettingActivity.java b/app/src/main/java/app/revanced/integrations/settingsmenu/YouTubeSettingActivity.java similarity index 97% rename from app/src/main/java/app/revanced/integrations/settingsmenu/ReVancedSettingActivity.java rename to app/src/main/java/app/revanced/integrations/settingsmenu/YouTubeSettingActivity.java index 342f2b8fba..45b9cbae2b 100644 --- a/app/src/main/java/app/revanced/integrations/settingsmenu/ReVancedSettingActivity.java +++ b/app/src/main/java/app/revanced/integrations/settingsmenu/YouTubeSettingActivity.java @@ -15,7 +15,7 @@ import app.revanced.integrations.utils.LogHelper; import app.revanced.integrations.utils.ThemeHelper; -public class ReVancedSettingActivity { +public class YouTubeSettingActivity { /** * Injection point. @@ -41,7 +41,7 @@ public static void initializeSettings(Activity licenseActivity) { break; case "revanced_settings_intent": toolbarTitleResourceName = "revanced_settings_title"; - fragment = new ReVancedSettingsFragment(); + fragment = new YouTubeSettingsFragment(); break; default: LogHelper.printException(() -> "Unknown setting: " + dataString); diff --git a/app/src/main/java/app/revanced/integrations/settingsmenu/ReVancedSettingsFragment.java b/app/src/main/java/app/revanced/integrations/settingsmenu/YouTubeSettingsFragment.java similarity index 99% rename from app/src/main/java/app/revanced/integrations/settingsmenu/ReVancedSettingsFragment.java rename to app/src/main/java/app/revanced/integrations/settingsmenu/YouTubeSettingsFragment.java index 454381d718..ceab483fc0 100644 --- a/app/src/main/java/app/revanced/integrations/settingsmenu/ReVancedSettingsFragment.java +++ b/app/src/main/java/app/revanced/integrations/settingsmenu/YouTubeSettingsFragment.java @@ -30,7 +30,7 @@ import app.revanced.integrations.utils.LogHelper; import app.revanced.integrations.utils.ReVancedUtils; -public class ReVancedSettingsFragment extends PreferenceFragment { +public class YouTubeSettingsFragment extends PreferenceFragment { /** * Indicates that if a preference changes, * to apply the change from the Setting to the UI component. diff --git a/app/src/main/java/app/revanced/tiktok/settingsmenu/TikTokReVancedSettingsFragment.java b/app/src/main/java/app/revanced/tiktok/settingsmenu/TikTokSettingsFragment.java similarity index 99% rename from app/src/main/java/app/revanced/tiktok/settingsmenu/TikTokReVancedSettingsFragment.java rename to app/src/main/java/app/revanced/tiktok/settingsmenu/TikTokSettingsFragment.java index d577a45521..fae2a69e5e 100644 --- a/app/src/main/java/app/revanced/tiktok/settingsmenu/TikTokReVancedSettingsFragment.java +++ b/app/src/main/java/app/revanced/tiktok/settingsmenu/TikTokSettingsFragment.java @@ -25,7 +25,7 @@ import app.revanced.tiktok.settingsmenu.preference.DownloadPathPreference; import app.revanced.tiktok.utils.ReVancedTikTokUtils; -public class TikTokReVancedSettingsFragment extends PreferenceFragment { +public class TikTokSettingsFragment extends PreferenceFragment { private boolean Registered = false; private boolean settingsInitialized = false; diff --git a/app/src/main/java/app/revanced/tiktok/settingsmenu/TikTokSettingsMenu.java b/app/src/main/java/app/revanced/tiktok/settingsmenu/TikTokSettingsMenu.java index 7373ecdc6c..d3b6537ba7 100644 --- a/app/src/main/java/app/revanced/tiktok/settingsmenu/TikTokSettingsMenu.java +++ b/app/src/main/java/app/revanced/tiktok/settingsmenu/TikTokSettingsMenu.java @@ -26,7 +26,7 @@ public static void initializeSettings(AdPersonalizationActivity base) { fragment.setId(fragmentId); linearLayout.addView(fragment); base.setContentView(linearLayout); - PreferenceFragment preferenceFragment = new TikTokReVancedSettingsFragment(); + PreferenceFragment preferenceFragment = new TikTokSettingsFragment(); base.getFragmentManager().beginTransaction().replace(fragmentId, preferenceFragment).commit(); } diff --git a/app/src/main/java/app/revanced/twitch/settingsmenu/ReVancedTwitchSettingsFragment.java b/app/src/main/java/app/revanced/twitch/settingsmenu/TwitchSettingsFragment.java similarity index 98% rename from app/src/main/java/app/revanced/twitch/settingsmenu/ReVancedTwitchSettingsFragment.java rename to app/src/main/java/app/revanced/twitch/settingsmenu/TwitchSettingsFragment.java index 52ef6c5c7d..a346a2b42a 100644 --- a/app/src/main/java/app/revanced/twitch/settingsmenu/ReVancedTwitchSettingsFragment.java +++ b/app/src/main/java/app/revanced/twitch/settingsmenu/TwitchSettingsFragment.java @@ -25,7 +25,7 @@ import app.revanced.twitch.utils.ReVancedTwitchUtils; import tv.twitch.android.app.core.LandingActivity; -public class ReVancedTwitchSettingsFragment extends PreferenceFragment { +public class TwitchSettingsFragment extends PreferenceFragment { private boolean registered = false; private boolean settingsInitialized = false; diff --git a/app/src/main/java/app/revanced/twitch/settingsmenu/TwitchSettingsHooks.java b/app/src/main/java/app/revanced/twitch/settingsmenu/TwitchSettingsHooks.java index d2559efd4d..0ffc59a051 100644 --- a/app/src/main/java/app/revanced/twitch/settingsmenu/TwitchSettingsHooks.java +++ b/app/src/main/java/app/revanced/twitch/settingsmenu/TwitchSettingsHooks.java @@ -96,7 +96,7 @@ public static boolean handleSettingsCreation(AppCompatActivity base) { } LogHelper.debug("ReVanced settings requested"); - ReVancedTwitchSettingsFragment fragment = new ReVancedTwitchSettingsFragment(); + TwitchSettingsFragment fragment = new TwitchSettingsFragment(); ActionBar supportActionBar = base.getSupportActionBar(); if(supportActionBar != null) supportActionBar.setTitle(getStringId("revanced_settings")); From 30903f85e0824f414dd17915b0bc8e25d8b3b174 Mon Sep 17 00:00:00 2001 From: LisoUseInAIKyrios <118716522+LisoUseInAIKyrios@users.noreply.github.com> Date: Sat, 10 Jun 2023 15:50:15 +0400 Subject: [PATCH 13/48] no functional changes: renamed classes --- .../app/revanced/tiktok/settings/SettingsEnum.java | 6 +++--- .../tiktok/settingsmenu/TikTokSettingsFragment.java | 4 ++-- .../tiktok/settingsmenu/TikTokSettingsMenu.java | 4 ++-- .../{ReVancedTikTokUtils.java => TikTokUtils.java} | 4 ++-- .../twitch/adblock/PurpleAdblockService.java | 4 ++-- .../app/revanced/twitch/adblock/TTVLolService.java | 4 ++-- .../app/revanced/twitch/api/RequestInterceptor.java | 12 ++++++------ .../twitch/patches/ShowDeletedMessagesPatch.java | 4 ++-- .../app/revanced/twitch/settings/SettingsEnum.java | 6 +++--- .../twitch/settingsmenu/TwitchSettingsFragment.java | 10 +++++----- .../twitch/settingsmenu/TwitchSettingsHooks.java | 8 ++++---- .../java/app/revanced/twitch/utils/LogHelper.java | 2 +- .../{ReVancedTwitchUtils.java => TwitchUtils.java} | 2 +- 13 files changed, 35 insertions(+), 35 deletions(-) rename app/src/main/java/app/revanced/tiktok/utils/{ReVancedTikTokUtils.java => TikTokUtils.java} (73%) rename app/src/main/java/app/revanced/twitch/utils/{ReVancedTwitchUtils.java => TwitchUtils.java} (98%) diff --git a/app/src/main/java/app/revanced/tiktok/settings/SettingsEnum.java b/app/src/main/java/app/revanced/tiktok/settings/SettingsEnum.java index 7e2c987e04..1d30ed7658 100644 --- a/app/src/main/java/app/revanced/tiktok/settings/SettingsEnum.java +++ b/app/src/main/java/app/revanced/tiktok/settings/SettingsEnum.java @@ -11,7 +11,7 @@ import androidx.annotation.NonNull; import app.revanced.tiktok.utils.LogHelper; -import app.revanced.tiktok.utils.ReVancedTikTokUtils; +import app.revanced.tiktok.utils.TikTokUtils; public enum SettingsEnum { //TikTok Settings @@ -61,7 +61,7 @@ public enum SettingsEnum { private static void loadAllSettings() { try { - Context context = ReVancedTikTokUtils.getAppContext(); + Context context = TikTokUtils.getAppContext(); if (context == null) { Log.e("revanced: SettingsEnum", "Context returned null! Settings NOT initialized"); return; @@ -110,7 +110,7 @@ public static void setValue(SettingsEnum setting, Object newValue) { } public void saveValue(Object newValue) { - Context context = ReVancedTikTokUtils.getAppContext(); + Context context = TikTokUtils.getAppContext(); if (context == null) { LogHelper.printException(SettingsEnum.class, "Context on SaveValue is null!"); return; diff --git a/app/src/main/java/app/revanced/tiktok/settingsmenu/TikTokSettingsFragment.java b/app/src/main/java/app/revanced/tiktok/settingsmenu/TikTokSettingsFragment.java index fae2a69e5e..63517537af 100644 --- a/app/src/main/java/app/revanced/tiktok/settingsmenu/TikTokSettingsFragment.java +++ b/app/src/main/java/app/revanced/tiktok/settingsmenu/TikTokSettingsFragment.java @@ -23,7 +23,7 @@ import app.revanced.tiktok.settings.SettingsEnum; import app.revanced.tiktok.settings.SharedPrefCategory; import app.revanced.tiktok.settingsmenu.preference.DownloadPathPreference; -import app.revanced.tiktok.utils.ReVancedTikTokUtils; +import app.revanced.tiktok.utils.TikTokUtils; public class TikTokSettingsFragment extends PreferenceFragment { @@ -34,7 +34,7 @@ public class TikTokSettingsFragment extends PreferenceFragment { for (SettingsEnum setting : SettingsEnum.values()) { if (!setting.path.equals(str)) continue; - if (ReVancedTikTokUtils.getAppContext() != null && this.settingsInitialized && setting.rebootApp) { + if (TikTokUtils.getAppContext() != null && this.settingsInitialized && setting.rebootApp) { rebootDialog(getActivity()); } } diff --git a/app/src/main/java/app/revanced/tiktok/settingsmenu/TikTokSettingsMenu.java b/app/src/main/java/app/revanced/tiktok/settingsmenu/TikTokSettingsMenu.java index d3b6537ba7..8ff6346b79 100644 --- a/app/src/main/java/app/revanced/tiktok/settingsmenu/TikTokSettingsMenu.java +++ b/app/src/main/java/app/revanced/tiktok/settingsmenu/TikTokSettingsMenu.java @@ -10,7 +10,7 @@ import com.bytedance.ies.ugc.aweme.commercialize.compliance.personalization.AdPersonalizationActivity; import app.revanced.tiktok.utils.LogHelper; -import app.revanced.tiktok.utils.ReVancedTikTokUtils; +import app.revanced.tiktok.utils.TikTokUtils; public class TikTokSettingsMenu { public static void initializeSettings(AdPersonalizationActivity base) { @@ -31,7 +31,7 @@ public static void initializeSettings(AdPersonalizationActivity base) { } public static void startSettingsActivity() { - Context appContext = ReVancedTikTokUtils.getAppContext(); + Context appContext = TikTokUtils.getAppContext(); if (appContext != null) { Intent intent = new Intent(appContext, AdPersonalizationActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); diff --git a/app/src/main/java/app/revanced/tiktok/utils/ReVancedTikTokUtils.java b/app/src/main/java/app/revanced/tiktok/utils/TikTokUtils.java similarity index 73% rename from app/src/main/java/app/revanced/tiktok/utils/ReVancedTikTokUtils.java rename to app/src/main/java/app/revanced/tiktok/utils/TikTokUtils.java index 48227152f6..3e3423acbf 100644 --- a/app/src/main/java/app/revanced/tiktok/utils/ReVancedTikTokUtils.java +++ b/app/src/main/java/app/revanced/tiktok/utils/TikTokUtils.java @@ -2,7 +2,7 @@ import android.content.Context; -public class ReVancedTikTokUtils { +public class TikTokUtils { //Used by TiktokIntegrations patch public static Context context; @@ -12,7 +12,7 @@ public static Context getAppContext() { if (context != null) { return context; } - LogHelper.printException(ReVancedTikTokUtils.class, "Context is null!"); + LogHelper.printException(TikTokUtils.class, "Context is null!"); return null; } } \ No newline at end of file diff --git a/app/src/main/java/app/revanced/twitch/adblock/PurpleAdblockService.java b/app/src/main/java/app/revanced/twitch/adblock/PurpleAdblockService.java index 964ff6a0be..0864966bf0 100644 --- a/app/src/main/java/app/revanced/twitch/adblock/PurpleAdblockService.java +++ b/app/src/main/java/app/revanced/twitch/adblock/PurpleAdblockService.java @@ -5,7 +5,7 @@ import app.revanced.twitch.api.RetrofitClient; import app.revanced.twitch.utils.LogHelper; -import app.revanced.twitch.utils.ReVancedTwitchUtils; +import app.revanced.twitch.utils.TwitchUtils; import okhttp3.HttpUrl; import okhttp3.Request; import okhttp3.ResponseBody; @@ -18,7 +18,7 @@ public class PurpleAdblockService implements IAdblockService { @Override public String friendlyName() { - return ReVancedTwitchUtils.getString("revanced_proxy_purpleadblock"); + return TwitchUtils.getString("revanced_proxy_purpleadblock"); } @Override diff --git a/app/src/main/java/app/revanced/twitch/adblock/TTVLolService.java b/app/src/main/java/app/revanced/twitch/adblock/TTVLolService.java index bd761e0cc0..4a72aab099 100644 --- a/app/src/main/java/app/revanced/twitch/adblock/TTVLolService.java +++ b/app/src/main/java/app/revanced/twitch/adblock/TTVLolService.java @@ -4,14 +4,14 @@ import java.util.Random; import app.revanced.twitch.utils.LogHelper; -import app.revanced.twitch.utils.ReVancedTwitchUtils; +import app.revanced.twitch.utils.TwitchUtils; import okhttp3.HttpUrl; import okhttp3.Request; public class TTVLolService implements IAdblockService { @Override public String friendlyName() { - return ReVancedTwitchUtils.getString("revanced_proxy_ttv_lol"); + return TwitchUtils.getString("revanced_proxy_ttv_lol"); } // TTV.lol is sometimes unstable diff --git a/app/src/main/java/app/revanced/twitch/api/RequestInterceptor.java b/app/src/main/java/app/revanced/twitch/api/RequestInterceptor.java index 2c3abce377..80d9ae5a8d 100644 --- a/app/src/main/java/app/revanced/twitch/api/RequestInterceptor.java +++ b/app/src/main/java/app/revanced/twitch/api/RequestInterceptor.java @@ -12,7 +12,7 @@ import app.revanced.twitch.adblock.TTVLolService; import app.revanced.twitch.settings.SettingsEnum; import app.revanced.twitch.utils.LogHelper; -import app.revanced.twitch.utils.ReVancedTwitchUtils; +import app.revanced.twitch.utils.TwitchUtils; import okhttp3.Interceptor; import okhttp3.Response; @@ -47,7 +47,7 @@ public Response intercept(@NonNull Chain chain) throws IOException { if (!available || rewritten == null) { - ReVancedTwitchUtils.toast(String.format(ReVancedTwitchUtils.getString("revanced_embedded_ads_service_unavailable"), activeService.friendlyName()), true); + TwitchUtils.toast(String.format(TwitchUtils.getString("revanced_embedded_ads_service_unavailable"), activeService.friendlyName()), true); return chain.proceed(originalRequest); } @@ -75,7 +75,7 @@ public Response intercept(@NonNull Chain chain) throws IOException { } // maxAttempts exceeded; giving up on using the ad blocker - ReVancedTwitchUtils.toast(String.format(ReVancedTwitchUtils.getString("revanced_embedded_ads_service_failed"), activeService.friendlyName()), true); + TwitchUtils.toast(String.format(TwitchUtils.getString("revanced_embedded_ads_service_failed"), activeService.friendlyName()), true); } @@ -87,11 +87,11 @@ public Response intercept(@NonNull Chain chain) throws IOException { private void updateActiveService() { var current = SettingsEnum.BLOCK_EMBEDDED_ADS.getString(); - if (current.equals(ReVancedTwitchUtils.getString("key_revanced_proxy_ttv_lol")) && !(activeService instanceof TTVLolService)) + if (current.equals(TwitchUtils.getString("key_revanced_proxy_ttv_lol")) && !(activeService instanceof TTVLolService)) activeService = new TTVLolService(); - else if (current.equals(ReVancedTwitchUtils.getString("key_revanced_proxy_purpleadblock")) && !(activeService instanceof PurpleAdblockService)) + else if (current.equals(TwitchUtils.getString("key_revanced_proxy_purpleadblock")) && !(activeService instanceof PurpleAdblockService)) activeService = new PurpleAdblockService(); - else if (current.equals(ReVancedTwitchUtils.getString("key_revanced_proxy_disabled"))) + else if (current.equals(TwitchUtils.getString("key_revanced_proxy_disabled"))) activeService = null; } } diff --git a/app/src/main/java/app/revanced/twitch/patches/ShowDeletedMessagesPatch.java b/app/src/main/java/app/revanced/twitch/patches/ShowDeletedMessagesPatch.java index 41834c73f1..fcaeb17696 100644 --- a/app/src/main/java/app/revanced/twitch/patches/ShowDeletedMessagesPatch.java +++ b/app/src/main/java/app/revanced/twitch/patches/ShowDeletedMessagesPatch.java @@ -12,7 +12,7 @@ import java.util.Objects; import app.revanced.twitch.settings.SettingsEnum; -import app.revanced.twitch.utils.ReVancedTwitchUtils; +import app.revanced.twitch.utils.TwitchUtils; import tv.twitch.android.shared.chat.util.ClickableUsernameSpan; public class ShowDeletedMessagesPatch { @@ -30,7 +30,7 @@ public static Spanned reformatDeletedMessage(Spanned original) { SpannableStringBuilder ssb = new SpannableStringBuilder(original); ssb.setSpan(new StrikethroughSpan(), 0, original.length(), 0); - ssb.append(" (").append(ReVancedTwitchUtils.getString("revanced_deleted_msg")).append(")"); + ssb.append(" (").append(TwitchUtils.getString("revanced_deleted_msg")).append(")"); ssb.setSpan(new StyleSpan(Typeface.ITALIC), original.length(), ssb.length(), 0); // Gray-out username diff --git a/app/src/main/java/app/revanced/twitch/settings/SettingsEnum.java b/app/src/main/java/app/revanced/twitch/settings/SettingsEnum.java index c023a4b676..ca57cc4bc3 100644 --- a/app/src/main/java/app/revanced/twitch/settings/SettingsEnum.java +++ b/app/src/main/java/app/revanced/twitch/settings/SettingsEnum.java @@ -11,7 +11,7 @@ import androidx.annotation.NonNull; import app.revanced.twitch.utils.LogHelper; -import app.revanced.twitch.utils.ReVancedTwitchUtils; +import app.revanced.twitch.utils.TwitchUtils; public enum SettingsEnum { /* Ads */ @@ -57,7 +57,7 @@ public enum SettingsEnum { } private static void loadAllSettings() { - ReVancedTwitchUtils.ifContextAttached((context -> { + TwitchUtils.ifContextAttached((context -> { try { SharedPreferences prefs = context.getSharedPreferences(REVANCED_PREFS, Context.MODE_PRIVATE); for (SettingsEnum setting : values()) { @@ -123,7 +123,7 @@ private void setValue(Object newValue) { } public void saveValue(Object newValue) { - ReVancedTwitchUtils.ifContextAttached((context) -> { + TwitchUtils.ifContextAttached((context) -> { SharedPreferences prefs = context.getSharedPreferences(REVANCED_PREFS, Context.MODE_PRIVATE); if (returnType == BOOLEAN) { prefs.edit().putBoolean(path, (Boolean)newValue).apply(); diff --git a/app/src/main/java/app/revanced/twitch/settingsmenu/TwitchSettingsFragment.java b/app/src/main/java/app/revanced/twitch/settingsmenu/TwitchSettingsFragment.java index a346a2b42a..6290efab04 100644 --- a/app/src/main/java/app/revanced/twitch/settingsmenu/TwitchSettingsFragment.java +++ b/app/src/main/java/app/revanced/twitch/settingsmenu/TwitchSettingsFragment.java @@ -22,7 +22,7 @@ import app.revanced.integrations.settingsmenu.SettingsUtils; import app.revanced.twitch.settings.SettingsEnum; import app.revanced.twitch.utils.LogHelper; -import app.revanced.twitch.utils.ReVancedTwitchUtils; +import app.revanced.twitch.utils.TwitchUtils; import tv.twitch.android.app.core.LandingActivity; public class TwitchSettingsFragment extends PreferenceFragment { @@ -62,7 +62,7 @@ else if (pref instanceof ListPreference) { LogHelper.error("Setting '%s' cannot be handled!", pref); } - if (ReVancedTwitchUtils.getContext() != null && key != null && settingsInitialized && setting.rebootApp) { + if (TwitchUtils.getContext() != null && key != null && settingsInitialized && setting.rebootApp) { rebootDialog(getActivity()); } @@ -140,9 +140,9 @@ private void reboot(Activity activity) { private void rebootDialog(final Activity activity) { new AlertDialog.Builder(activity). - setMessage(ReVancedTwitchUtils.getString("revanced_reboot_message")). - setPositiveButton(ReVancedTwitchUtils.getString("revanced_reboot"), (dialog, i) -> reboot(activity)) - .setNegativeButton(ReVancedTwitchUtils.getString("revanced_cancel"), null) + setMessage(TwitchUtils.getString("revanced_reboot_message")). + setPositiveButton(TwitchUtils.getString("revanced_reboot"), (dialog, i) -> reboot(activity)) + .setNegativeButton(TwitchUtils.getString("revanced_cancel"), null) .show(); } } diff --git a/app/src/main/java/app/revanced/twitch/settingsmenu/TwitchSettingsHooks.java b/app/src/main/java/app/revanced/twitch/settingsmenu/TwitchSettingsHooks.java index 0ffc59a051..43c5d70cd2 100644 --- a/app/src/main/java/app/revanced/twitch/settingsmenu/TwitchSettingsHooks.java +++ b/app/src/main/java/app/revanced/twitch/settingsmenu/TwitchSettingsHooks.java @@ -1,7 +1,7 @@ package app.revanced.twitch.settingsmenu; -import static app.revanced.twitch.utils.ReVancedTwitchUtils.getIdentifier; -import static app.revanced.twitch.utils.ReVancedTwitchUtils.getStringId; +import static app.revanced.twitch.utils.TwitchUtils.getIdentifier; +import static app.revanced.twitch.utils.TwitchUtils.getStringId; import android.content.Intent; import android.os.Bundle; @@ -12,7 +12,7 @@ import java.util.ArrayList; import java.util.List; -import app.revanced.twitch.utils.ReVancedTwitchUtils; +import app.revanced.twitch.utils.TwitchUtils; import app.revanced.twitch.utils.LogHelper; import tv.twitch.android.feature.settings.menu.SettingsMenuGroup; import tv.twitch.android.settings.SettingsActivity; @@ -27,7 +27,7 @@ public class TwitchSettingsHooks { public static void startSettingsActivity() { LogHelper.debug("Launching ReVanced settings"); - ReVancedTwitchUtils.ifContextAttached((c) -> { + TwitchUtils.ifContextAttached((c) -> { Intent intent = new Intent(c, SettingsActivity.class); Bundle bundle = new Bundle(); bundle.putBoolean(REVANCED_TWITCH_SETTINGS_INTENT_NAME, true); diff --git a/app/src/main/java/app/revanced/twitch/utils/LogHelper.java b/app/src/main/java/app/revanced/twitch/utils/LogHelper.java index 63200df672..1fc6529d5c 100644 --- a/app/src/main/java/app/revanced/twitch/utils/LogHelper.java +++ b/app/src/main/java/app/revanced/twitch/utils/LogHelper.java @@ -48,7 +48,7 @@ public static void printException(String message, Throwable ex) { private static void showDebugToast(String msg) { if(SettingsEnum.DEBUG_MODE.getBoolean()) { - ReVancedTwitchUtils.toast(msg, false); + TwitchUtils.toast(msg, false); } } } diff --git a/app/src/main/java/app/revanced/twitch/utils/ReVancedTwitchUtils.java b/app/src/main/java/app/revanced/twitch/utils/TwitchUtils.java similarity index 98% rename from app/src/main/java/app/revanced/twitch/utils/ReVancedTwitchUtils.java rename to app/src/main/java/app/revanced/twitch/utils/TwitchUtils.java index bbdb0b191f..9878ca69f9 100644 --- a/app/src/main/java/app/revanced/twitch/utils/ReVancedTwitchUtils.java +++ b/app/src/main/java/app/revanced/twitch/utils/TwitchUtils.java @@ -6,7 +6,7 @@ import android.os.Looper; import android.widget.Toast; -public class ReVancedTwitchUtils { +public class TwitchUtils { @SuppressLint("StaticFieldLeak") public static Context context; From 89a2b8dfbec491b039338d22bb2cc3da96c6b1b0 Mon Sep 17 00:00:00 2001 From: LisoUseInAIKyrios <118716522+LisoUseInAIKyrios@users.noreply.github.com> Date: Sat, 10 Jun 2023 16:50:41 +0400 Subject: [PATCH 14/48] tiktok translations --- .../tiktok/settings/SettingsEnum.java | 27 +++++++++- .../settingsmenu/TikTokSettingsFragment.java | 49 +++++++++---------- .../revanced/tiktok/utils/TikTokUtils.java | 31 ++++++++++++ 3 files changed, 79 insertions(+), 28 deletions(-) diff --git a/app/src/main/java/app/revanced/tiktok/settings/SettingsEnum.java b/app/src/main/java/app/revanced/tiktok/settings/SettingsEnum.java index 1d30ed7658..af0e061d67 100644 --- a/app/src/main/java/app/revanced/tiktok/settings/SettingsEnum.java +++ b/app/src/main/java/app/revanced/tiktok/settings/SettingsEnum.java @@ -9,6 +9,7 @@ import android.util.Log; import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import app.revanced.tiktok.utils.LogHelper; import app.revanced.tiktok.utils.TikTokUtils; @@ -105,7 +106,7 @@ private void load(Context context) { * when {@link #saveValue(Object)} was intended. */ public static void setValue(SettingsEnum setting, Object newValue) { - // FIXME: this should validate the parameter matches the return type + setting.returnType.validate(newValue); setting.value = newValue; } @@ -149,6 +150,28 @@ public enum ReturnType { INTEGER, LONG, FLOAT, - STRING, + STRING; + + public void validate(@Nullable Object obj) throws IllegalArgumentException { + if (!matches(obj)) { + throw new IllegalArgumentException("'" + obj + "' does not match:" + this); + } + } + + public boolean matches(@Nullable Object obj) { + switch (this) { + case BOOLEAN: + return obj instanceof Boolean; + case INTEGER: + return obj instanceof Integer; + case LONG: + return obj instanceof Long; + case FLOAT: + return obj instanceof Float; + case STRING: + return obj instanceof String; + } + return false; + } } } diff --git a/app/src/main/java/app/revanced/tiktok/settingsmenu/TikTokSettingsFragment.java b/app/src/main/java/app/revanced/tiktok/settingsmenu/TikTokSettingsFragment.java index 63517537af..652879a826 100644 --- a/app/src/main/java/app/revanced/tiktok/settingsmenu/TikTokSettingsFragment.java +++ b/app/src/main/java/app/revanced/tiktok/settingsmenu/TikTokSettingsFragment.java @@ -54,7 +54,7 @@ public void onCreate(@Nullable Bundle savedInstanceState) { //Feed filter if (SettingsStatus.feedFilter) { PreferenceCategory feedFilter = new PreferenceCategory(context); - feedFilter.setTitle("Feed filter"); + feedFilter.setTitle(TikTokUtils.getString("revanced_tik_feed_filter_screen_title")); preferenceScreen.addPreference(feedFilter); //Remove ads toggle @@ -64,13 +64,10 @@ public void onCreate(@Nullable Bundle savedInstanceState) { preference.setKey(SettingsEnum.TIK_REMOVE_ADS.path); preference.setDefaultValue(SettingsEnum.TIK_REMOVE_ADS.defaultValue); preference.setChecked(SettingsEnum.TIK_REMOVE_ADS.getBoolean()); - preference.setTitle("Remove feed ads"); - preference.setSummary("Remove ads from feed."); + preference.setTitle(TikTokUtils.getString("revanced_tik_remove_ads_title")); + preference.setSummary(TikTokUtils.getString("revanced_tik_remove_ads_summary")); preference.setOnPreferenceChangeListener((pref, newValue) -> { - // FIXME: the value is already saved in the preferences. - // instead of saving again, simple call SettingsEnum#setValue() - final boolean value = (Boolean) newValue; - SettingsEnum.TIK_REMOVE_ADS.saveValue(value); + SettingsEnum.setValue(SettingsEnum.TIK_REMOVE_ADS, newValue); return true; }); } @@ -81,8 +78,8 @@ public void onCreate(@Nullable Bundle savedInstanceState) { preference.setKey(SettingsEnum.TIK_HIDE_LIVE.path); preference.setDefaultValue(SettingsEnum.TIK_HIDE_LIVE.defaultValue); preference.setChecked(SettingsEnum.TIK_HIDE_LIVE.getBoolean()); - preference.setTitle("Hide livestreams"); - preference.setSummary("Hide livestreams from feed."); + preference.setTitle(TikTokUtils.getString("revanced_tik_hide_live_title")); + preference.setSummary(TikTokUtils.getString("revanced_tik_hide_live_summary")); preference.setOnPreferenceChangeListener((pref, newValue) -> { final boolean value = (Boolean) newValue; SettingsEnum.TIK_HIDE_LIVE.saveValue(value); @@ -94,7 +91,7 @@ public void onCreate(@Nullable Bundle savedInstanceState) { //Download if (SettingsStatus.download) { PreferenceCategory download = new PreferenceCategory(context); - download.setTitle("Download"); + download.setTitle(TikTokUtils.getString("revanced_tik_down_screen_title")); preferenceScreen.addPreference(download); //Download path { @@ -103,7 +100,7 @@ public void onCreate(@Nullable Bundle savedInstanceState) { preference.setKey(SettingsEnum.TIK_DOWN_PATH.path); preference.setDefaultValue(SettingsEnum.TIK_DOWN_PATH.defaultValue); preference.setValue(SettingsEnum.TIK_DOWN_PATH.getString()); - preference.setTitle("Download path"); + preference.setTitle(TikTokUtils.getString("revanced_tik_down_path_title")); preference.setSummary(Environment.getExternalStorageDirectory().getPath() + "/" + preference.getValue()); preference.setOnPreferenceChangeListener((pref, newValue) -> { final String value = (String) newValue; @@ -118,7 +115,7 @@ public void onCreate(@Nullable Bundle savedInstanceState) { preference.setKey(SettingsEnum.TIK_DOWN_WATERMARK.path); preference.setDefaultValue(SettingsEnum.TIK_DOWN_WATERMARK.defaultValue); preference.setChecked(SettingsEnum.TIK_DOWN_WATERMARK.getBoolean()); - preference.setTitle("Remove watermark"); + preference.setTitle(TikTokUtils.getString("revanced_tik_down_watermark_title")); preference.setOnPreferenceChangeListener((pref, newValue) -> { final boolean value = (Boolean) newValue; SettingsEnum.TIK_DOWN_WATERMARK.saveValue(value); @@ -130,7 +127,7 @@ public void onCreate(@Nullable Bundle savedInstanceState) { // SpoofSimPatch if(SettingsStatus.simSpoof) { PreferenceCategory simSpoof = new PreferenceCategory(context); - simSpoof.setTitle("Bypass regional restriction"); + simSpoof.setTitle(TikTokUtils.getString("revanced_tik_simspoof_screen_title")); preferenceScreen.addPreference(simSpoof); //Global Switch { @@ -139,8 +136,8 @@ public void onCreate(@Nullable Bundle savedInstanceState) { preference.setKey(SettingsEnum.TIK_SIMSPOOF.path); preference.setDefaultValue(SettingsEnum.TIK_SIMSPOOF.defaultValue); preference.setChecked(SettingsEnum.TIK_SIMSPOOF.getBoolean()); - preference.setTitle("Fake sim card info"); - preference.setSummary("Bypass regional restriction by fake sim card information."); + preference.setTitle(TikTokUtils.getString("revanced_tik_simspoof_title")); + preference.setSummary(TikTokUtils.getString("revanced_tik_simspoof_summary")); preference.setOnPreferenceChangeListener((pref, newValue) -> { final boolean value = (Boolean) newValue; SettingsEnum.TIK_SIMSPOOF.saveValue(value); @@ -154,8 +151,8 @@ public void onCreate(@Nullable Bundle savedInstanceState) { preference.setKey(SettingsEnum.TIK_SIMSPOOF_ISO.path); preference.setDefaultValue(SettingsEnum.TIK_SIMSPOOF_ISO.defaultValue); preference.setText(SettingsEnum.TIK_SIMSPOOF_ISO.getString()); - preference.setTitle("Country ISO"); - preference.setSummary("us, uk, jp, ..."); + preference.setTitle(TikTokUtils.getString("revanced_tik_simspoof_iso_title")); + preference.setSummary(TikTokUtils.getString("revanced_tik_simspoof_iso_summary")); preference.setOnPreferenceChangeListener((pref, newValue) -> { final String value = (String) newValue; SettingsEnum.TIK_SIMSPOOF_ISO.saveValue(value); @@ -169,8 +166,8 @@ public void onCreate(@Nullable Bundle savedInstanceState) { preference.setKey(SettingsEnum.TIK_SIMSPOOF_MCCMNC.path); preference.setDefaultValue(SettingsEnum.TIK_SIMSPOOF_MCCMNC.defaultValue); preference.setText(SettingsEnum.TIK_SIMSPOOF_MCCMNC.getString()); - preference.setTitle("Operator mcc+mnc"); - preference.setSummary("mcc+mnc"); + preference.setTitle(TikTokUtils.getString("revanced_tik_simspoof_mccmnc_title")); + preference.setSummary(TikTokUtils.getString("revanced_tik_simspoof_mccmnc_summary")); preference.setOnPreferenceChangeListener((pref, newValue) -> { final String value = (String) newValue; SettingsEnum.TIK_SIMSPOOF_MCCMNC.saveValue(value); @@ -184,8 +181,8 @@ public void onCreate(@Nullable Bundle savedInstanceState) { preference.setKey(SettingsEnum.TIK_SIMSPOOF_OP_NAME.path); preference.setDefaultValue(SettingsEnum.TIK_SIMSPOOF_OP_NAME.defaultValue); preference.setText(SettingsEnum.TIK_SIMSPOOF_OP_NAME.getString()); - preference.setTitle("Operator name"); - preference.setSummary("Name of the operator"); + preference.setTitle(TikTokUtils.getString("revanced_tik_simspoof_op_name_title")); + preference.setSummary(TikTokUtils.getString("revanced_tik_simspoof_op_name_summary")); preference.setOnPreferenceChangeListener((pref, newValue) -> { final String value = (String) newValue; SettingsEnum.TIK_SIMSPOOF_OP_NAME.saveValue(value); @@ -205,8 +202,8 @@ public void onCreate(@Nullable Bundle savedInstanceState) { preference.setKey(SettingsEnum.TIK_DEBUG.path); preference.setDefaultValue(SettingsEnum.TIK_DEBUG.defaultValue); preference.setChecked(SettingsEnum.TIK_DEBUG.getBoolean()); - preference.setTitle("Enable debug log"); - preference.setSummary("Show integration debug log."); + preference.setTitle(TikTokUtils.getString("revanced_tik_debug_title")); + preference.setSummary(TikTokUtils.getString("revanced_tik_debug_summary")); preference.setOnPreferenceChangeListener((pref, newValue) -> { final boolean value = (Boolean) newValue; SettingsEnum.TIK_DEBUG.saveValue(value); @@ -234,9 +231,9 @@ private void reboot(Activity activity) { private void rebootDialog(final Activity activity) { new AlertDialog.Builder(activity). - setMessage("Refresh and restart"). - setPositiveButton("RESTART", (dialog, i) -> reboot(activity)) - .setNegativeButton("CANCEL", null) + setMessage(TikTokUtils.getString("revanced_tik_settings_restart_title")). + setPositiveButton(TikTokUtils.getString("revanced_tik_settings_restart_button_text"), (dialog, i) -> reboot(activity)) + .setNegativeButton(android.R.string.cancel, null) .show(); } } diff --git a/app/src/main/java/app/revanced/tiktok/utils/TikTokUtils.java b/app/src/main/java/app/revanced/tiktok/utils/TikTokUtils.java index 3e3423acbf..4207a67366 100644 --- a/app/src/main/java/app/revanced/tiktok/utils/TikTokUtils.java +++ b/app/src/main/java/app/revanced/tiktok/utils/TikTokUtils.java @@ -1,5 +1,6 @@ package app.revanced.tiktok.utils; +import android.annotation.SuppressLint; import android.content.Context; public class TikTokUtils { @@ -15,4 +16,34 @@ public static Context getAppContext() { LogHelper.printException(TikTokUtils.class, "Context is null!"); return null; } + + /** + * Get resource id safely + * @return May return 0 if resource not found or context not attached + */ + @SuppressLint("DiscouragedApi") + public static int getIdentifier(String name, String defType) { + Context context = getAppContext(); + if (context == null) { + return 0; + } + int resId = context.getResources().getIdentifier(name, defType, context.getPackageName()); + if(resId == 0) { + LogHelper.printException(TikTokUtils.class, "Resource '" + name + "' not found"); + } + return resId; + } + + public static int getStringId(String name) { + return getIdentifier(name, "string"); + } + + public static String getString(String name) { + if (context == null) { + return name; + } + return context.getString(getStringId(name)); + } + + } \ No newline at end of file From d4ab94a1d55ed172bc79b8344c89e1ae211baa7e Mon Sep 17 00:00:00 2001 From: LisoUseInAIKyrios <118716522+LisoUseInAIKyrios@users.noreply.github.com> Date: Sat, 10 Jun 2023 17:00:32 +0400 Subject: [PATCH 15/48] Revert "tiktok translations" This reverts commit 89a2b8dfbec491b039338d22bb2cc3da96c6b1b0. --- .../tiktok/settings/SettingsEnum.java | 27 +--------- .../settingsmenu/TikTokSettingsFragment.java | 49 ++++++++++--------- .../revanced/tiktok/utils/TikTokUtils.java | 31 ------------ 3 files changed, 28 insertions(+), 79 deletions(-) diff --git a/app/src/main/java/app/revanced/tiktok/settings/SettingsEnum.java b/app/src/main/java/app/revanced/tiktok/settings/SettingsEnum.java index af0e061d67..1d30ed7658 100644 --- a/app/src/main/java/app/revanced/tiktok/settings/SettingsEnum.java +++ b/app/src/main/java/app/revanced/tiktok/settings/SettingsEnum.java @@ -9,7 +9,6 @@ import android.util.Log; import androidx.annotation.NonNull; -import androidx.annotation.Nullable; import app.revanced.tiktok.utils.LogHelper; import app.revanced.tiktok.utils.TikTokUtils; @@ -106,7 +105,7 @@ private void load(Context context) { * when {@link #saveValue(Object)} was intended. */ public static void setValue(SettingsEnum setting, Object newValue) { - setting.returnType.validate(newValue); + // FIXME: this should validate the parameter matches the return type setting.value = newValue; } @@ -150,28 +149,6 @@ public enum ReturnType { INTEGER, LONG, FLOAT, - STRING; - - public void validate(@Nullable Object obj) throws IllegalArgumentException { - if (!matches(obj)) { - throw new IllegalArgumentException("'" + obj + "' does not match:" + this); - } - } - - public boolean matches(@Nullable Object obj) { - switch (this) { - case BOOLEAN: - return obj instanceof Boolean; - case INTEGER: - return obj instanceof Integer; - case LONG: - return obj instanceof Long; - case FLOAT: - return obj instanceof Float; - case STRING: - return obj instanceof String; - } - return false; - } + STRING, } } diff --git a/app/src/main/java/app/revanced/tiktok/settingsmenu/TikTokSettingsFragment.java b/app/src/main/java/app/revanced/tiktok/settingsmenu/TikTokSettingsFragment.java index 652879a826..63517537af 100644 --- a/app/src/main/java/app/revanced/tiktok/settingsmenu/TikTokSettingsFragment.java +++ b/app/src/main/java/app/revanced/tiktok/settingsmenu/TikTokSettingsFragment.java @@ -54,7 +54,7 @@ public void onCreate(@Nullable Bundle savedInstanceState) { //Feed filter if (SettingsStatus.feedFilter) { PreferenceCategory feedFilter = new PreferenceCategory(context); - feedFilter.setTitle(TikTokUtils.getString("revanced_tik_feed_filter_screen_title")); + feedFilter.setTitle("Feed filter"); preferenceScreen.addPreference(feedFilter); //Remove ads toggle @@ -64,10 +64,13 @@ public void onCreate(@Nullable Bundle savedInstanceState) { preference.setKey(SettingsEnum.TIK_REMOVE_ADS.path); preference.setDefaultValue(SettingsEnum.TIK_REMOVE_ADS.defaultValue); preference.setChecked(SettingsEnum.TIK_REMOVE_ADS.getBoolean()); - preference.setTitle(TikTokUtils.getString("revanced_tik_remove_ads_title")); - preference.setSummary(TikTokUtils.getString("revanced_tik_remove_ads_summary")); + preference.setTitle("Remove feed ads"); + preference.setSummary("Remove ads from feed."); preference.setOnPreferenceChangeListener((pref, newValue) -> { - SettingsEnum.setValue(SettingsEnum.TIK_REMOVE_ADS, newValue); + // FIXME: the value is already saved in the preferences. + // instead of saving again, simple call SettingsEnum#setValue() + final boolean value = (Boolean) newValue; + SettingsEnum.TIK_REMOVE_ADS.saveValue(value); return true; }); } @@ -78,8 +81,8 @@ public void onCreate(@Nullable Bundle savedInstanceState) { preference.setKey(SettingsEnum.TIK_HIDE_LIVE.path); preference.setDefaultValue(SettingsEnum.TIK_HIDE_LIVE.defaultValue); preference.setChecked(SettingsEnum.TIK_HIDE_LIVE.getBoolean()); - preference.setTitle(TikTokUtils.getString("revanced_tik_hide_live_title")); - preference.setSummary(TikTokUtils.getString("revanced_tik_hide_live_summary")); + preference.setTitle("Hide livestreams"); + preference.setSummary("Hide livestreams from feed."); preference.setOnPreferenceChangeListener((pref, newValue) -> { final boolean value = (Boolean) newValue; SettingsEnum.TIK_HIDE_LIVE.saveValue(value); @@ -91,7 +94,7 @@ public void onCreate(@Nullable Bundle savedInstanceState) { //Download if (SettingsStatus.download) { PreferenceCategory download = new PreferenceCategory(context); - download.setTitle(TikTokUtils.getString("revanced_tik_down_screen_title")); + download.setTitle("Download"); preferenceScreen.addPreference(download); //Download path { @@ -100,7 +103,7 @@ public void onCreate(@Nullable Bundle savedInstanceState) { preference.setKey(SettingsEnum.TIK_DOWN_PATH.path); preference.setDefaultValue(SettingsEnum.TIK_DOWN_PATH.defaultValue); preference.setValue(SettingsEnum.TIK_DOWN_PATH.getString()); - preference.setTitle(TikTokUtils.getString("revanced_tik_down_path_title")); + preference.setTitle("Download path"); preference.setSummary(Environment.getExternalStorageDirectory().getPath() + "/" + preference.getValue()); preference.setOnPreferenceChangeListener((pref, newValue) -> { final String value = (String) newValue; @@ -115,7 +118,7 @@ public void onCreate(@Nullable Bundle savedInstanceState) { preference.setKey(SettingsEnum.TIK_DOWN_WATERMARK.path); preference.setDefaultValue(SettingsEnum.TIK_DOWN_WATERMARK.defaultValue); preference.setChecked(SettingsEnum.TIK_DOWN_WATERMARK.getBoolean()); - preference.setTitle(TikTokUtils.getString("revanced_tik_down_watermark_title")); + preference.setTitle("Remove watermark"); preference.setOnPreferenceChangeListener((pref, newValue) -> { final boolean value = (Boolean) newValue; SettingsEnum.TIK_DOWN_WATERMARK.saveValue(value); @@ -127,7 +130,7 @@ public void onCreate(@Nullable Bundle savedInstanceState) { // SpoofSimPatch if(SettingsStatus.simSpoof) { PreferenceCategory simSpoof = new PreferenceCategory(context); - simSpoof.setTitle(TikTokUtils.getString("revanced_tik_simspoof_screen_title")); + simSpoof.setTitle("Bypass regional restriction"); preferenceScreen.addPreference(simSpoof); //Global Switch { @@ -136,8 +139,8 @@ public void onCreate(@Nullable Bundle savedInstanceState) { preference.setKey(SettingsEnum.TIK_SIMSPOOF.path); preference.setDefaultValue(SettingsEnum.TIK_SIMSPOOF.defaultValue); preference.setChecked(SettingsEnum.TIK_SIMSPOOF.getBoolean()); - preference.setTitle(TikTokUtils.getString("revanced_tik_simspoof_title")); - preference.setSummary(TikTokUtils.getString("revanced_tik_simspoof_summary")); + preference.setTitle("Fake sim card info"); + preference.setSummary("Bypass regional restriction by fake sim card information."); preference.setOnPreferenceChangeListener((pref, newValue) -> { final boolean value = (Boolean) newValue; SettingsEnum.TIK_SIMSPOOF.saveValue(value); @@ -151,8 +154,8 @@ public void onCreate(@Nullable Bundle savedInstanceState) { preference.setKey(SettingsEnum.TIK_SIMSPOOF_ISO.path); preference.setDefaultValue(SettingsEnum.TIK_SIMSPOOF_ISO.defaultValue); preference.setText(SettingsEnum.TIK_SIMSPOOF_ISO.getString()); - preference.setTitle(TikTokUtils.getString("revanced_tik_simspoof_iso_title")); - preference.setSummary(TikTokUtils.getString("revanced_tik_simspoof_iso_summary")); + preference.setTitle("Country ISO"); + preference.setSummary("us, uk, jp, ..."); preference.setOnPreferenceChangeListener((pref, newValue) -> { final String value = (String) newValue; SettingsEnum.TIK_SIMSPOOF_ISO.saveValue(value); @@ -166,8 +169,8 @@ public void onCreate(@Nullable Bundle savedInstanceState) { preference.setKey(SettingsEnum.TIK_SIMSPOOF_MCCMNC.path); preference.setDefaultValue(SettingsEnum.TIK_SIMSPOOF_MCCMNC.defaultValue); preference.setText(SettingsEnum.TIK_SIMSPOOF_MCCMNC.getString()); - preference.setTitle(TikTokUtils.getString("revanced_tik_simspoof_mccmnc_title")); - preference.setSummary(TikTokUtils.getString("revanced_tik_simspoof_mccmnc_summary")); + preference.setTitle("Operator mcc+mnc"); + preference.setSummary("mcc+mnc"); preference.setOnPreferenceChangeListener((pref, newValue) -> { final String value = (String) newValue; SettingsEnum.TIK_SIMSPOOF_MCCMNC.saveValue(value); @@ -181,8 +184,8 @@ public void onCreate(@Nullable Bundle savedInstanceState) { preference.setKey(SettingsEnum.TIK_SIMSPOOF_OP_NAME.path); preference.setDefaultValue(SettingsEnum.TIK_SIMSPOOF_OP_NAME.defaultValue); preference.setText(SettingsEnum.TIK_SIMSPOOF_OP_NAME.getString()); - preference.setTitle(TikTokUtils.getString("revanced_tik_simspoof_op_name_title")); - preference.setSummary(TikTokUtils.getString("revanced_tik_simspoof_op_name_summary")); + preference.setTitle("Operator name"); + preference.setSummary("Name of the operator"); preference.setOnPreferenceChangeListener((pref, newValue) -> { final String value = (String) newValue; SettingsEnum.TIK_SIMSPOOF_OP_NAME.saveValue(value); @@ -202,8 +205,8 @@ public void onCreate(@Nullable Bundle savedInstanceState) { preference.setKey(SettingsEnum.TIK_DEBUG.path); preference.setDefaultValue(SettingsEnum.TIK_DEBUG.defaultValue); preference.setChecked(SettingsEnum.TIK_DEBUG.getBoolean()); - preference.setTitle(TikTokUtils.getString("revanced_tik_debug_title")); - preference.setSummary(TikTokUtils.getString("revanced_tik_debug_summary")); + preference.setTitle("Enable debug log"); + preference.setSummary("Show integration debug log."); preference.setOnPreferenceChangeListener((pref, newValue) -> { final boolean value = (Boolean) newValue; SettingsEnum.TIK_DEBUG.saveValue(value); @@ -231,9 +234,9 @@ private void reboot(Activity activity) { private void rebootDialog(final Activity activity) { new AlertDialog.Builder(activity). - setMessage(TikTokUtils.getString("revanced_tik_settings_restart_title")). - setPositiveButton(TikTokUtils.getString("revanced_tik_settings_restart_button_text"), (dialog, i) -> reboot(activity)) - .setNegativeButton(android.R.string.cancel, null) + setMessage("Refresh and restart"). + setPositiveButton("RESTART", (dialog, i) -> reboot(activity)) + .setNegativeButton("CANCEL", null) .show(); } } diff --git a/app/src/main/java/app/revanced/tiktok/utils/TikTokUtils.java b/app/src/main/java/app/revanced/tiktok/utils/TikTokUtils.java index 4207a67366..3e3423acbf 100644 --- a/app/src/main/java/app/revanced/tiktok/utils/TikTokUtils.java +++ b/app/src/main/java/app/revanced/tiktok/utils/TikTokUtils.java @@ -1,6 +1,5 @@ package app.revanced.tiktok.utils; -import android.annotation.SuppressLint; import android.content.Context; public class TikTokUtils { @@ -16,34 +15,4 @@ public static Context getAppContext() { LogHelper.printException(TikTokUtils.class, "Context is null!"); return null; } - - /** - * Get resource id safely - * @return May return 0 if resource not found or context not attached - */ - @SuppressLint("DiscouragedApi") - public static int getIdentifier(String name, String defType) { - Context context = getAppContext(); - if (context == null) { - return 0; - } - int resId = context.getResources().getIdentifier(name, defType, context.getPackageName()); - if(resId == 0) { - LogHelper.printException(TikTokUtils.class, "Resource '" + name + "' not found"); - } - return resId; - } - - public static int getStringId(String name) { - return getIdentifier(name, "string"); - } - - public static String getString(String name) { - if (context == null) { - return name; - } - return context.getString(getStringId(name)); - } - - } \ No newline at end of file From 35e9cbf10d6afd414ea6ed616304b9d8809ddd81 Mon Sep 17 00:00:00 2001 From: LisoUseInAIKyrios <118716522+LisoUseInAIKyrios@users.noreply.github.com> Date: Thu, 15 Jun 2023 12:30:28 +0400 Subject: [PATCH 16/48] sort groups as well --- .../integrations/settingsmenu/SettingsUtils.java | 12 ++++++------ .../settingsmenu/YouTubeSettingsFragment.java | 2 +- .../twitch/settingsmenu/TwitchSettingsFragment.java | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/app/revanced/integrations/settingsmenu/SettingsUtils.java b/app/src/main/java/app/revanced/integrations/settingsmenu/SettingsUtils.java index d20371aa0f..58e654b36d 100644 --- a/app/src/main/java/app/revanced/integrations/settingsmenu/SettingsUtils.java +++ b/app/src/main/java/app/revanced/integrations/settingsmenu/SettingsUtils.java @@ -1,7 +1,7 @@ package app.revanced.integrations.settingsmenu; import android.preference.Preference; -import android.preference.PreferenceScreen; +import android.preference.PreferenceGroup; import java.util.ArrayList; import java.util.Collections; @@ -25,13 +25,13 @@ public class SettingsUtils { * Android Preferences are automatically sorted by title, * but if using a localized string key it sorts on the key and not the actual title text that's used at runtime. */ - public static void sortPreferenceScreenByTitle(PreferenceScreen screen) { - final int prefCount = screen.getPreferenceCount(); + public static void sortPreferenceGroupByTitle(PreferenceGroup group) { + final int prefCount = group.getPreferenceCount(); List preferences = new ArrayList<>(prefCount); for (int i = 0; i < prefCount; i++) { - Preference preference = screen.getPreference(i); - if (preference instanceof PreferenceScreen) { - sortPreferenceScreenByTitle((PreferenceScreen)preference); + Preference preference = group.getPreference(i); + if (preference instanceof PreferenceGroup) { + sortPreferenceGroupByTitle((PreferenceGroup)preference); } preferences.add(preference); } diff --git a/app/src/main/java/app/revanced/integrations/settingsmenu/YouTubeSettingsFragment.java b/app/src/main/java/app/revanced/integrations/settingsmenu/YouTubeSettingsFragment.java index ceab483fc0..5020a995c5 100644 --- a/app/src/main/java/app/revanced/integrations/settingsmenu/YouTubeSettingsFragment.java +++ b/app/src/main/java/app/revanced/integrations/settingsmenu/YouTubeSettingsFragment.java @@ -150,7 +150,7 @@ public void onActivityCreated(@Nullable Bundle savedInstanceState) { } } - SettingsUtils.sortPreferenceScreenByTitle(getPreferenceScreen()); + SettingsUtils.sortPreferenceGroupByTitle(getPreferenceScreen()); preferenceManager.getSharedPreferences().registerOnSharedPreferenceChangeListener(listener); } catch (Exception ex) { diff --git a/app/src/main/java/app/revanced/twitch/settingsmenu/TwitchSettingsFragment.java b/app/src/main/java/app/revanced/twitch/settingsmenu/TwitchSettingsFragment.java index 6290efab04..fb92c7b4c7 100644 --- a/app/src/main/java/app/revanced/twitch/settingsmenu/TwitchSettingsFragment.java +++ b/app/src/main/java/app/revanced/twitch/settingsmenu/TwitchSettingsFragment.java @@ -118,7 +118,7 @@ public void onCreate(Bundle bundle) { public void onActivityCreated(@Nullable Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); - SettingsUtils.sortPreferenceScreenByTitle(getPreferenceScreen()); + SettingsUtils.sortPreferenceGroupByTitle(getPreferenceScreen()); } @Override From bd3bca9e2ad5304db57b0c802e3e8bc7c8a75c95 Mon Sep 17 00:00:00 2001 From: LisoUseInAIKyrios <118716522+LisoUseInAIKyrios@users.noreply.github.com> Date: Thu, 15 Jun 2023 16:10:11 +0400 Subject: [PATCH 17/48] Android preferences are the worse. After trying many different ways to specify a fixed preference menu ordering, all were either too clunky or just did not work quite right. For now just use a fixed depth to sort to, and leave all the deeper submenus in the order the patch specifies. --- .../revanced/integrations/settingsmenu/SettingsUtils.java | 8 ++++++-- .../settingsmenu/YouTubeSettingsFragment.java | 2 +- .../twitch/settingsmenu/TwitchSettingsFragment.java | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/app/revanced/integrations/settingsmenu/SettingsUtils.java b/app/src/main/java/app/revanced/integrations/settingsmenu/SettingsUtils.java index 58e654b36d..e71abcdeb9 100644 --- a/app/src/main/java/app/revanced/integrations/settingsmenu/SettingsUtils.java +++ b/app/src/main/java/app/revanced/integrations/settingsmenu/SettingsUtils.java @@ -24,14 +24,18 @@ public class SettingsUtils { * * Android Preferences are automatically sorted by title, * but if using a localized string key it sorts on the key and not the actual title text that's used at runtime. + * + * @param menuDepthToSort Maximum menu depth to sort. Menus deep than this value will show it's preferences in the order created in patches. */ - public static void sortPreferenceGroupByTitle(PreferenceGroup group) { + public static void sortPreferenceGroupByTitle(PreferenceGroup group, int menuDepthToSort) { + if (menuDepthToSort == 0) return; + final int prefCount = group.getPreferenceCount(); List preferences = new ArrayList<>(prefCount); for (int i = 0; i < prefCount; i++) { Preference preference = group.getPreference(i); if (preference instanceof PreferenceGroup) { - sortPreferenceGroupByTitle((PreferenceGroup)preference); + sortPreferenceGroupByTitle((PreferenceGroup) preference, menuDepthToSort - 1); } preferences.add(preference); } diff --git a/app/src/main/java/app/revanced/integrations/settingsmenu/YouTubeSettingsFragment.java b/app/src/main/java/app/revanced/integrations/settingsmenu/YouTubeSettingsFragment.java index 5020a995c5..6a4373976c 100644 --- a/app/src/main/java/app/revanced/integrations/settingsmenu/YouTubeSettingsFragment.java +++ b/app/src/main/java/app/revanced/integrations/settingsmenu/YouTubeSettingsFragment.java @@ -150,7 +150,7 @@ public void onActivityCreated(@Nullable Bundle savedInstanceState) { } } - SettingsUtils.sortPreferenceGroupByTitle(getPreferenceScreen()); + SettingsUtils.sortPreferenceGroupByTitle(getPreferenceScreen(), 2); preferenceManager.getSharedPreferences().registerOnSharedPreferenceChangeListener(listener); } catch (Exception ex) { diff --git a/app/src/main/java/app/revanced/twitch/settingsmenu/TwitchSettingsFragment.java b/app/src/main/java/app/revanced/twitch/settingsmenu/TwitchSettingsFragment.java index fb92c7b4c7..b18516329a 100644 --- a/app/src/main/java/app/revanced/twitch/settingsmenu/TwitchSettingsFragment.java +++ b/app/src/main/java/app/revanced/twitch/settingsmenu/TwitchSettingsFragment.java @@ -118,7 +118,7 @@ public void onCreate(Bundle bundle) { public void onActivityCreated(@Nullable Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); - SettingsUtils.sortPreferenceGroupByTitle(getPreferenceScreen()); + SettingsUtils.sortPreferenceGroupByTitle(getPreferenceScreen(), 2); } @Override From b334eca6d9b376e44cc537d52be4a8bc088dc1ab Mon Sep 17 00:00:00 2001 From: LisoUseInAIKyrios <118716522+LisoUseInAIKyrios@users.noreply.github.com> Date: Thu, 15 Jun 2023 22:00:32 +0400 Subject: [PATCH 18/48] use a sorted map instead --- .../settingsmenu/SettingsUtils.java | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/app/revanced/integrations/settingsmenu/SettingsUtils.java b/app/src/main/java/app/revanced/integrations/settingsmenu/SettingsUtils.java index e71abcdeb9..2610f487f6 100644 --- a/app/src/main/java/app/revanced/integrations/settingsmenu/SettingsUtils.java +++ b/app/src/main/java/app/revanced/integrations/settingsmenu/SettingsUtils.java @@ -3,9 +3,8 @@ import android.preference.Preference; import android.preference.PreferenceGroup; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; +import java.util.SortedMap; +import java.util.TreeMap; /** * Class is used across multiple target apps. @@ -30,21 +29,17 @@ public class SettingsUtils { public static void sortPreferenceGroupByTitle(PreferenceGroup group, int menuDepthToSort) { if (menuDepthToSort == 0) return; - final int prefCount = group.getPreferenceCount(); - List preferences = new ArrayList<>(prefCount); - for (int i = 0; i < prefCount; i++) { + SortedMap preferences = new TreeMap<>(); + for (int i = 0, prefCount = group.getPreferenceCount(); i < prefCount; i++) { Preference preference = group.getPreference(i); if (preference instanceof PreferenceGroup) { sortPreferenceGroupByTitle((PreferenceGroup) preference, menuDepthToSort - 1); } - preferences.add(preference); + preferences.put(preference.getTitle().toString().toLowerCase(), preference); } - Collections.sort(preferences, (pref1, pref2) -> - pref1.getTitle().toString().toLowerCase().compareTo(pref2.getTitle().toString().toLowerCase()) - ); int prefIndex = 0; - for (Preference pref : preferences) { + for (Preference pref : preferences.values()) { pref.setOrder(prefIndex++); } } From 7b7ca59cde3ca293d17af61e9fd7582aa1a4f204 Mon Sep 17 00:00:00 2001 From: LisoUseInAIKyrios <118716522+LisoUseInAIKyrios@users.noreply.github.com> Date: Fri, 16 Jun 2023 01:43:24 +0400 Subject: [PATCH 19/48] use revanced prefix --- .../ReturnYouTubeDislike.java | 4 +- .../requests/ReturnYouTubeDislikeApi.java | 34 +++++----- .../ReturnYouTubeDislikeSettingsFragment.java | 68 +++++++++---------- 3 files changed, 53 insertions(+), 53 deletions(-) diff --git a/app/src/main/java/app/revanced/integrations/returnyoutubedislike/ReturnYouTubeDislike.java b/app/src/main/java/app/revanced/integrations/returnyoutubedislike/ReturnYouTubeDislike.java index fc4b3b71a3..fc577f5354 100644 --- a/app/src/main/java/app/revanced/integrations/returnyoutubedislike/ReturnYouTubeDislike.java +++ b/app/src/main/java/app/revanced/integrations/returnyoutubedislike/ReturnYouTubeDislike.java @@ -376,7 +376,7 @@ public static void sendVote(@NonNull Vote vote) { // Or shorts was loaded with regular video present, then shorts was closed, // and then user voted on the now visible original video. // Cannot send a vote, because the loaded videoId is for the wrong video. - ReVancedUtils.showToastLong(str("ryd_failure_ryd_enabled_while_playing_video_then_user_voted")); + ReVancedUtils.showToastLong(str("revanced_ryd_failure_ryd_enabled_while_playing_video_then_user_voted")); return; } @@ -484,7 +484,7 @@ private static SpannableString createDislikeSpan(@NonNull Spanned oldSpannable, // RYD data: https://returnyoutubedislikeapi.com/votes?videoId=UnrU5vxCHxw // // Change the "Likes" string to show that likes and dislikes are hidden. - String hiddenMessageString = str("ryd_video_likes_hidden_by_video_owner"); + String hiddenMessageString = str("revanced_ryd_video_likes_hidden_by_video_owner"); return newSpanUsingStylingOfAnotherSpan(oldSpannable, hiddenMessageString); } diff --git a/app/src/main/java/app/revanced/integrations/returnyoutubedislike/requests/ReturnYouTubeDislikeApi.java b/app/src/main/java/app/revanced/integrations/returnyoutubedislike/requests/ReturnYouTubeDislikeApi.java index 491ddc1741..0965f493d0 100644 --- a/app/src/main/java/app/revanced/integrations/returnyoutubedislike/requests/ReturnYouTubeDislikeApi.java +++ b/app/src/main/java/app/revanced/integrations/returnyoutubedislike/requests/ReturnYouTubeDislikeApi.java @@ -196,7 +196,7 @@ private static boolean checkIfRateLimitWasHit(int httpResponseCode) { numberOfRateLimitRequestsEncountered++; LogHelper.printDebug(() -> "API rate limit was hit. Stopping API calls for the next " + RATE_LIMIT_BACKOFF_SECONDS + " seconds"); - ReVancedUtils.showToastLong(str("ryd_failure_client_rate_limit_requested")); + ReVancedUtils.showToastLong(str("revanced_ryd_failure_client_rate_limit_requested")); return true; } return false; @@ -284,16 +284,16 @@ public static RYDVoteData fetchVotes(String videoId) { LogHelper.printDebug(() -> "Video has no like/dislikes (video is a YouTube Story?): " + videoId); return null; // do not updated connection statistics } else { - handleConnectionError(str("ryd_failure_connection_status_code", responseCode), null); + handleConnectionError(str("revanced_ryd_failure_connection_status_code", responseCode), null); } connection.disconnect(); // something went wrong, might as well disconnect } catch (SocketTimeoutException ex) { // connection timed out, response timeout, or some other network error - handleConnectionError((str("ryd_failure_connection_timeout")), ex); + handleConnectionError((str("revanced_ryd_failure_connection_timeout")), ex); } catch (IOException ex) { - handleConnectionError((str("ryd_failure_generic", ex.getMessage())), ex); + handleConnectionError((str("revanced_ryd_failure_generic", ex.getMessage())), ex); } catch (Exception ex) { // should never happen - LogHelper.printException(() -> "Failed to fetch votes", ex, str("ryd_failure_generic", ex.getMessage())); + LogHelper.printException(() -> "Failed to fetch votes", ex, str("revanced_ryd_failure_generic", ex.getMessage())); } updateStatistics(timeNetworkCallStarted, System.currentTimeMillis(), true, false); @@ -331,12 +331,12 @@ public static String registerAsNewUser() { String solution = solvePuzzle(challenge, difficulty); return confirmRegistration(userId, solution); } - handleConnectionError(str("ryd_failure_connection_status_code", responseCode), null); + handleConnectionError(str("revanced_ryd_failure_connection_status_code", responseCode), null); connection.disconnect(); } catch (SocketTimeoutException ex) { - handleConnectionError(str("ryd_failure_connection_timeout"), ex); + handleConnectionError(str("revanced_ryd_failure_connection_timeout"), ex); } catch (IOException ex) { - handleConnectionError(str("ryd_failure_generic", "registration failed"), ex); + handleConnectionError(str("revanced_ryd_failure_generic", "registration failed"), ex); } catch (Exception ex) { LogHelper.printException(() -> "Failed to register user", ex); // should never happen } @@ -378,12 +378,12 @@ private static String confirmRegistration(String userId, String solution) { final String resultLog = result == null ? "(no response)" : result; LogHelper.printInfo(() -> "Failed to confirm registration for user: " + userId + " solution: " + solution + " responseCode: " + responseCode + " responseString: " + resultLog); - handleConnectionError(str("ryd_failure_connection_status_code", responseCode), null); + handleConnectionError(str("revanced_ryd_failure_connection_status_code", responseCode), null); connection.disconnect(); // something went wrong, might as well disconnect } catch (SocketTimeoutException ex) { - handleConnectionError(str("ryd_failure_connection_timeout"), ex); + handleConnectionError(str("revanced_ryd_failure_connection_timeout"), ex); } catch (IOException ex) { - handleConnectionError(str("ryd_failure_generic", "confirm registration failed"), ex); + handleConnectionError(str("revanced_ryd_failure_generic", "confirm registration failed"), ex); } catch (Exception ex) { LogHelper.printException(() -> "Failed to confirm registration for user: " + userId + "solution: " + solution, ex); @@ -427,12 +427,12 @@ public static boolean sendVote(String videoId, String userId, ReturnYouTubeDisli } LogHelper.printInfo(() -> "Failed to send vote for video: " + videoId + " vote: " + vote + " response code was: " + responseCode); - handleConnectionError(str("ryd_failure_connection_status_code", responseCode), null); + handleConnectionError(str("revanced_ryd_failure_connection_status_code", responseCode), null); connection.disconnect(); // something went wrong, might as well disconnect } catch (SocketTimeoutException ex) { - handleConnectionError(str("ryd_failure_connection_timeout"), ex); + handleConnectionError(str("revanced_ryd_failure_connection_timeout"), ex); } catch (IOException ex) { - handleConnectionError(str("ryd_failure_generic", "send vote failed"), ex); + handleConnectionError(str("revanced_ryd_failure_generic", "send vote failed"), ex); } catch (Exception ex) { // should never happen LogHelper.printException(() -> "Failed to send vote for video: " + videoId + " vote: " + vote, ex); @@ -475,12 +475,12 @@ private static boolean confirmVote(String videoId, String userId, String solutio final String resultLog = result == null ? "(no response)" : result; LogHelper.printInfo(() -> "Failed to confirm vote for video: " + videoId + " solution: " + solution + " responseCode: " + responseCode + " responseString: " + resultLog); - handleConnectionError(str("ryd_failure_connection_status_code", responseCode), null); + handleConnectionError(str("revanced_ryd_failure_connection_status_code", responseCode), null); connection.disconnect(); // something went wrong, might as well disconnect } catch (SocketTimeoutException ex) { - handleConnectionError(str("ryd_failure_connection_timeout"), ex); + handleConnectionError(str("revanced_ryd_failure_connection_timeout"), ex); } catch (IOException ex) { - handleConnectionError(str("ryd_failure_generic", "confirm vote failed"), ex); + handleConnectionError(str("revanced_ryd_failure_generic", "confirm vote failed"), ex); } catch (Exception ex) { LogHelper.printException(() -> "Failed to confirm vote for video: " + videoId + " solution: " + solution, ex); // should never happen diff --git a/app/src/main/java/app/revanced/integrations/settingsmenu/ReturnYouTubeDislikeSettingsFragment.java b/app/src/main/java/app/revanced/integrations/settingsmenu/ReturnYouTubeDislikeSettingsFragment.java index 7ad5e26452..322f3ff299 100644 --- a/app/src/main/java/app/revanced/integrations/settingsmenu/ReturnYouTubeDislikeSettingsFragment.java +++ b/app/src/main/java/app/revanced/integrations/settingsmenu/ReturnYouTubeDislikeSettingsFragment.java @@ -57,9 +57,9 @@ public void onCreate(Bundle savedInstanceState) { SwitchPreference enabledPreference = new SwitchPreference(context); enabledPreference.setChecked(SettingsEnum.RYD_ENABLED.getBoolean()); - enabledPreference.setTitle(str("ryd_enable_title")); - enabledPreference.setSummaryOn(str("ryd_enable_summary_on")); - enabledPreference.setSummaryOff(str("ryd_enable_summary_off")); + enabledPreference.setTitle(str("revanced_ryd_enable_title")); + enabledPreference.setSummaryOn(str("revanced_ryd_enable_summary_on")); + enabledPreference.setSummaryOff(str("revanced_ryd_enable_summary_off")); enabledPreference.setOnPreferenceChangeListener((pref, newValue) -> { final boolean rydIsEnabled = (Boolean) newValue; SettingsEnum.RYD_ENABLED.saveValue(rydIsEnabled); @@ -72,9 +72,9 @@ public void onCreate(Bundle savedInstanceState) { shortsPreference = new SwitchPreference(context); shortsPreference.setChecked(SettingsEnum.RYD_SHORTS.getBoolean()); - shortsPreference.setTitle(str("ryd_shorts_title")); - shortsPreference.setSummaryOn(str("ryd_shorts_summary_on")); - shortsPreference.setSummaryOff(str("ryd_shorts_summary_off")); + shortsPreference.setTitle(str("revanced_ryd_shorts_title")); + shortsPreference.setSummaryOn(str("revanced_ryd_shorts_summary_on")); + shortsPreference.setSummaryOff(str("revanced_ryd_shorts_summary_off")); shortsPreference.setOnPreferenceChangeListener((pref, newValue) -> { SettingsEnum.RYD_SHORTS.saveValue(newValue); updateUIState(); @@ -84,9 +84,9 @@ public void onCreate(Bundle savedInstanceState) { percentagePreference = new SwitchPreference(context); percentagePreference.setChecked(SettingsEnum.RYD_DISLIKE_PERCENTAGE.getBoolean()); - percentagePreference.setTitle(str("ryd_dislike_percentage_title")); - percentagePreference.setSummaryOn(str("ryd_dislike_percentage_summary_on")); - percentagePreference.setSummaryOff(str("ryd_dislike_percentage_summary_off")); + percentagePreference.setTitle(str("revanced_ryd_dislike_percentage_title")); + percentagePreference.setSummaryOn(str("revanced_ryd_dislike_percentage_summary_on")); + percentagePreference.setSummaryOff(str("revanced_ryd_dislike_percentage_summary_off")); percentagePreference.setOnPreferenceChangeListener((pref, newValue) -> { SettingsEnum.RYD_DISLIKE_PERCENTAGE.saveValue(newValue); ReturnYouTubeDislike.clearCache(); @@ -97,9 +97,9 @@ public void onCreate(Bundle savedInstanceState) { compactLayoutPreference = new SwitchPreference(context); compactLayoutPreference.setChecked(SettingsEnum.RYD_COMPACT_LAYOUT.getBoolean()); - compactLayoutPreference.setTitle(str("ryd_compact_layout_title")); - compactLayoutPreference.setSummaryOn(str("ryd_compact_layout_summary_on")); - compactLayoutPreference.setSummaryOff(str("ryd_compact_layout_summary_off")); + compactLayoutPreference.setTitle(str("revanced_ryd_compact_layout_title")); + compactLayoutPreference.setSummaryOn(str("revanced_ryd_compact_layout_summary_on")); + compactLayoutPreference.setSummaryOff(str("revanced_ryd_compact_layout_summary_off")); compactLayoutPreference.setOnPreferenceChangeListener((pref, newValue) -> { SettingsEnum.RYD_COMPACT_LAYOUT.saveValue(newValue); ReturnYouTubeDislike.clearCache(); @@ -110,9 +110,9 @@ public void onCreate(Bundle savedInstanceState) { toastOnRYDNotAvailable = new SwitchPreference(context); toastOnRYDNotAvailable.setChecked(SettingsEnum.RYD_TOAST_ON_CONNECTION_ERROR.getBoolean()); - toastOnRYDNotAvailable.setTitle(str("ryd_toast_on_connection_error_title")); - toastOnRYDNotAvailable.setSummaryOn(str("ryd_toast_on_connection_error_summary_on")); - toastOnRYDNotAvailable.setSummaryOff(str("ryd_toast_on_connection_error_summary_off")); + toastOnRYDNotAvailable.setTitle(str("revanced_ryd_toast_on_connection_error_title")); + toastOnRYDNotAvailable.setSummaryOn(str("revanced_ryd_toast_on_connection_error_summary_on")); + toastOnRYDNotAvailable.setSummaryOff(str("revanced_ryd_toast_on_connection_error_summary_off")); toastOnRYDNotAvailable.setOnPreferenceChangeListener((pref, newValue) -> { SettingsEnum.RYD_TOAST_ON_CONNECTION_ERROR.saveValue(newValue); updateUIState(); @@ -126,14 +126,14 @@ public void onCreate(Bundle savedInstanceState) { // About category PreferenceCategory aboutCategory = new PreferenceCategory(context); - aboutCategory.setTitle(str("ryd_about")); + aboutCategory.setTitle(str("revanced_ryd_about")); preferenceScreen.addPreference(aboutCategory); // ReturnYouTubeDislike Website Preference aboutWebsitePreference = new Preference(context); - aboutWebsitePreference.setTitle(str("ryd_attribution_title")); - aboutWebsitePreference.setSummary(str("ryd_attribution_summary")); + aboutWebsitePreference.setTitle(str("revanced_ryd_attribution_title")); + aboutWebsitePreference.setSummary(str("revanced_ryd_attribution_summary")); aboutWebsitePreference.setOnPreferenceClickListener(pref -> { Intent i = new Intent(Intent.ACTION_VIEW); i.setData(Uri.parse("https://returnyoutubedislike.com")); @@ -149,64 +149,64 @@ public void onCreate(Bundle savedInstanceState) { preferenceScreen.addPreference(emptyCategory); PreferenceCategory statisticsCategory = new PreferenceCategory(context); - statisticsCategory.setTitle(str("ryd_statistics_category_title")); + statisticsCategory.setTitle(str("revanced_ryd_statistics_category_title")); preferenceScreen.addPreference(statisticsCategory); Preference statisticPreference; statisticPreference = new Preference(context); statisticPreference.setSelectable(false); - statisticPreference.setTitle(str("ryd_statistics_getFetchCallResponseTimeAverage_title")); + statisticPreference.setTitle(str("revanced_ryd_statistics_getFetchCallResponseTimeAverage_title")); statisticPreference.setSummary(createMillisecondStringFromNumber(ReturnYouTubeDislikeApi.getFetchCallResponseTimeAverage())); preferenceScreen.addPreference(statisticPreference); statisticPreference = new Preference(context); statisticPreference.setSelectable(false); - statisticPreference.setTitle(str("ryd_statistics_getFetchCallResponseTimeMin_title")); + statisticPreference.setTitle(str("revanced_ryd_statistics_getFetchCallResponseTimeMin_title")); statisticPreference.setSummary(createMillisecondStringFromNumber(ReturnYouTubeDislikeApi.getFetchCallResponseTimeMin())); preferenceScreen.addPreference(statisticPreference); statisticPreference = new Preference(context); statisticPreference.setSelectable(false); - statisticPreference.setTitle(str("ryd_statistics_getFetchCallResponseTimeMax_title")); + statisticPreference.setTitle(str("revanced_ryd_statistics_getFetchCallResponseTimeMax_title")); statisticPreference.setSummary(createMillisecondStringFromNumber(ReturnYouTubeDislikeApi.getFetchCallResponseTimeMax())); preferenceScreen.addPreference(statisticPreference); String fetchCallTimeWaitingLastSummary; final long fetchCallTimeWaitingLast = ReturnYouTubeDislikeApi.getFetchCallResponseTimeLast(); if (fetchCallTimeWaitingLast == ReturnYouTubeDislikeApi.FETCH_CALL_RESPONSE_TIME_VALUE_RATE_LIMIT) { - fetchCallTimeWaitingLastSummary = str("ryd_statistics_getFetchCallResponseTimeLast_rate_limit_summary"); + fetchCallTimeWaitingLastSummary = str("revanced_ryd_statistics_getFetchCallResponseTimeLast_rate_limit_summary"); } else { fetchCallTimeWaitingLastSummary = createMillisecondStringFromNumber(fetchCallTimeWaitingLast); } statisticPreference = new Preference(context); statisticPreference.setSelectable(false); - statisticPreference.setTitle(str("ryd_statistics_getFetchCallResponseTimeLast_title")); + statisticPreference.setTitle(str("revanced_ryd_statistics_getFetchCallResponseTimeLast_title")); statisticPreference.setSummary(fetchCallTimeWaitingLastSummary); preferenceScreen.addPreference(statisticPreference); statisticPreference = new Preference(context); statisticPreference.setSelectable(false); - statisticPreference.setTitle(str("ryd_statistics_getFetchCallCount_title")); + statisticPreference.setTitle(str("revanced_ryd_statistics_getFetchCallCount_title")); statisticPreference.setSummary(createSummaryText(ReturnYouTubeDislikeApi.getFetchCallCount(), - "ryd_statistics_getFetchCallCount_zero_summary", - "ryd_statistics_getFetchCallCount_non_zero_summary")); + "revanced_ryd_statistics_getFetchCallCount_zero_summary", + "revanced_ryd_statistics_getFetchCallCount_non_zero_summary")); preferenceScreen.addPreference(statisticPreference); statisticPreference = new Preference(context); statisticPreference.setSelectable(false); - statisticPreference.setTitle(str("ryd_statistics_getFetchCallNumberOfFailures_title")); + statisticPreference.setTitle(str("revanced_ryd_statistics_getFetchCallNumberOfFailures_title")); statisticPreference.setSummary(createSummaryText(ReturnYouTubeDislikeApi.getFetchCallNumberOfFailures(), - "ryd_statistics_getFetchCallNumberOfFailures_zero_summary", - "ryd_statistics_getFetchCallNumberOfFailures_non_zero_summary")); + "revanced_ryd_statistics_getFetchCallNumberOfFailures_zero_summary", + "revanced_ryd_statistics_getFetchCallNumberOfFailures_non_zero_summary")); preferenceScreen.addPreference(statisticPreference); statisticPreference = new Preference(context); statisticPreference.setSelectable(false); - statisticPreference.setTitle(str("ryd_statistics_getNumberOfRateLimitRequestsEncountered_title")); + statisticPreference.setTitle(str("revanced_ryd_statistics_getNumberOfRateLimitRequestsEncountered_title")); statisticPreference.setSummary(createSummaryText(ReturnYouTubeDislikeApi.getNumberOfRateLimitRequestsEncountered(), - "ryd_statistics_getNumberOfRateLimitRequestsEncountered_zero_summary", - "ryd_statistics_getNumberOfRateLimitRequestsEncountered_non_zero_summary")); + "revanced_ryd_statistics_getNumberOfRateLimitRequestsEncountered_zero_summary", + "revanced_ryd_statistics_getNumberOfRateLimitRequestsEncountered_non_zero_summary")); preferenceScreen.addPreference(statisticPreference); } } @@ -219,7 +219,7 @@ private static String createSummaryText(int value, String summaryStringZeroKey, } private static String createMillisecondStringFromNumber(long number) { - return String.format(str("ryd_statistics_millisecond_text"), number); + return String.format(str("revanced_ryd_statistics_millisecond_text"), number); } } From 749446e5d890d9fe5119c1f3fae978b4de1a986e Mon Sep 17 00:00:00 2001 From: LisoUseInAIKyrios <118716522+LisoUseInAIKyrios@users.noreply.github.com> Date: Fri, 16 Jun 2023 01:48:11 +0400 Subject: [PATCH 20/48] use revanced prefix --- .../SponsorBlockSettingsFragment.java | 120 +++++++++--------- .../SegmentPlaybackController.java | 2 +- .../sponsorblock/SponsorBlockSettings.java | 10 +- .../sponsorblock/SponsorBlockUtils.java | 6 +- .../objects/CategoryBehaviour.java | 2 +- .../sponsorblock/objects/SegmentCategory.java | 2 +- .../sponsorblock/requests/SBRequester.java | 4 +- .../ui/CreateSegmentButtonController.java | 2 +- .../sponsorblock/ui/NewSegmentLayout.java | 4 +- .../sponsorblock/ui/SkipSponsorButton.java | 2 +- .../ui/SponsorBlockViewController.java | 6 +- .../ui/VotingButtonController.java | 2 +- 12 files changed, 81 insertions(+), 81 deletions(-) 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 85bac3ab0e..b712cdce71 100644 --- a/app/src/main/java/app/revanced/integrations/settingsmenu/SponsorBlockSettingsFragment.java +++ b/app/src/main/java/app/revanced/integrations/settingsmenu/SponsorBlockSettingsFragment.java @@ -132,8 +132,8 @@ public void onCreate(Bundle savedInstanceState) { SponsorBlockSettings.initialize(); sbEnabled = new SwitchPreference(context); - sbEnabled.setTitle(str("sb_enable_sb")); - sbEnabled.setSummary(str("sb_enable_sb_sum")); + sbEnabled.setTitle(str("revanced_sb_enable_sb")); + sbEnabled.setSummary(str("revanced_sb_enable_sb_sum")); preferenceScreen.addPreference(sbEnabled); sbEnabled.setOnPreferenceChangeListener((preference1, newValue) -> { SettingsEnum.SB_ENABLED.saveValue(newValue); @@ -144,7 +144,7 @@ public void onCreate(Bundle savedInstanceState) { addAppearanceCategory(context, preferenceScreen); segmentCategory = new PreferenceCategory(context); - segmentCategory.setTitle(str("sb_diff_segments")); + segmentCategory.setTitle(str("revanced_sb_diff_segments")); preferenceScreen.addPreference(segmentCategory); updateSegmentCategories(); @@ -153,7 +153,7 @@ public void onCreate(Bundle savedInstanceState) { addGeneralCategory(context, preferenceScreen); statsCategory = new PreferenceCategory(context); - statsCategory.setTitle(str("sb_stats")); + statsCategory.setTitle(str("revanced_sb_stats")); preferenceScreen.addPreference(statsCategory); fetchAndDisplayStats(); @@ -168,12 +168,12 @@ public void onCreate(Bundle savedInstanceState) { private void addAppearanceCategory(Context context, PreferenceScreen screen) { PreferenceCategory category = new PreferenceCategory(context); screen.addPreference(category); - category.setTitle(str("sb_appearance_category")); + category.setTitle(str("revanced_sb_appearance_category")); votingEnabled = new SwitchPreference(context); - votingEnabled.setTitle(str("sb_enable_voting")); - votingEnabled.setSummaryOn(str("sb_enable_voting_sum_on")); - votingEnabled.setSummaryOff(str("sb_enable_voting_sum_off")); + votingEnabled.setTitle(str("revanced_sb_enable_voting")); + votingEnabled.setSummaryOn(str("revanced_sb_enable_voting_sum_on")); + votingEnabled.setSummaryOff(str("revanced_sb_enable_voting_sum_off")); category.addPreference(votingEnabled); votingEnabled.setOnPreferenceChangeListener((preference1, newValue) -> { SettingsEnum.SB_VOTING_BUTTON.saveValue(newValue); @@ -182,9 +182,9 @@ private void addAppearanceCategory(Context context, PreferenceScreen screen) { }); compactSkipButton = new SwitchPreference(context); - compactSkipButton.setTitle(str("sb_enable_compact_skip_button")); - compactSkipButton.setSummaryOn(str("sb_enable_compact_skip_button_sum_on")); - compactSkipButton.setSummaryOff(str("sb_enable_compact_skip_button_sum_off")); + compactSkipButton.setTitle(str("revanced_sb_enable_compact_skip_button")); + compactSkipButton.setSummaryOn(str("revanced_sb_enable_compact_skip_button_sum_on")); + compactSkipButton.setSummaryOff(str("revanced_sb_enable_compact_skip_button_sum_off")); category.addPreference(compactSkipButton); compactSkipButton.setOnPreferenceChangeListener((preference1, newValue) -> { SettingsEnum.SB_COMPACT_SKIP_BUTTON.saveValue(newValue); @@ -193,9 +193,9 @@ private void addAppearanceCategory(Context context, PreferenceScreen screen) { }); autoHideSkipSegmentButton = new SwitchPreference(context); - autoHideSkipSegmentButton.setTitle(str("sb_enable_auto_hide_skip_segment_button")); - autoHideSkipSegmentButton.setSummaryOn(str("sb_enable_auto_hide_skip_segment_button_sum_on")); - autoHideSkipSegmentButton.setSummaryOff(str("sb_enable_auto_hide_skip_segment_button_sum_off")); + autoHideSkipSegmentButton.setTitle(str("revanced_sb_enable_auto_hide_skip_segment_button")); + autoHideSkipSegmentButton.setSummaryOn(str("revanced_sb_enable_auto_hide_skip_segment_button_sum_on")); + autoHideSkipSegmentButton.setSummaryOff(str("revanced_sb_enable_auto_hide_skip_segment_button_sum_off")); category.addPreference(autoHideSkipSegmentButton); autoHideSkipSegmentButton.setOnPreferenceChangeListener((preference1, newValue) -> { SettingsEnum.SB_AUTO_HIDE_SKIP_BUTTON.saveValue(newValue); @@ -204,11 +204,11 @@ private void addAppearanceCategory(Context context, PreferenceScreen screen) { }); showSkipToast = new SwitchPreference(context); - showSkipToast.setTitle(str("sb_general_skiptoast")); - showSkipToast.setSummaryOn(str("sb_general_skiptoast_sum_on")); - showSkipToast.setSummaryOff(str("sb_general_skiptoast_sum_off")); + showSkipToast.setTitle(str("revanced_sb_general_skiptoast")); + showSkipToast.setSummaryOn(str("revanced_sb_general_skiptoast_sum_on")); + showSkipToast.setSummaryOff(str("revanced_sb_general_skiptoast_sum_off")); showSkipToast.setOnPreferenceClickListener(preference1 -> { - ReVancedUtils.showToastShort(str("sb_skipped_sponsor")); + ReVancedUtils.showToastShort(str("revanced_sb_skipped_sponsor")); return false; }); showSkipToast.setOnPreferenceChangeListener((preference1, newValue) -> { @@ -219,9 +219,9 @@ private void addAppearanceCategory(Context context, PreferenceScreen screen) { category.addPreference(showSkipToast); showTimeWithoutSegments = new SwitchPreference(context); - showTimeWithoutSegments.setTitle(str("sb_general_time_without")); - showTimeWithoutSegments.setSummaryOn(str("sb_general_time_without_sum_on")); - showTimeWithoutSegments.setSummaryOff(str("sb_general_time_without_sum_off")); + showTimeWithoutSegments.setTitle(str("revanced_sb_general_time_without")); + showTimeWithoutSegments.setSummaryOn(str("revanced_sb_general_time_without_sum_on")); + showTimeWithoutSegments.setSummaryOff(str("revanced_sb_general_time_without_sum_off")); showTimeWithoutSegments.setOnPreferenceChangeListener((preference1, newValue) -> { SettingsEnum.SB_VIDEO_LENGTH_WITHOUT_SEGMENTS.saveValue(newValue); updateUI(); @@ -233,21 +233,21 @@ private void addAppearanceCategory(Context context, PreferenceScreen screen) { private void addCreateSegmentCategory(Context context, PreferenceScreen screen) { PreferenceCategory category = new PreferenceCategory(context); screen.addPreference(category); - category.setTitle(str("sb_create_segment_category")); + category.setTitle(str("revanced_sb_create_segment_category")); addNewSegment = new SwitchPreference(context); - addNewSegment.setTitle(str("sb_enable_create_segment")); - addNewSegment.setSummaryOn(str("sb_enable_create_segment_sum_on")); - addNewSegment.setSummaryOff(str("sb_enable_create_segment_sum_off")); + addNewSegment.setTitle(str("revanced_sb_enable_create_segment")); + addNewSegment.setSummaryOn(str("revanced_sb_enable_create_segment_sum_on")); + addNewSegment.setSummaryOff(str("revanced_sb_enable_create_segment_sum_off")); category.addPreference(addNewSegment); addNewSegment.setOnPreferenceChangeListener((preference1, o) -> { Boolean newValue = (Boolean) o; if (newValue && !SettingsEnum.SB_SEEN_GUIDELINES.getBoolean()) { new AlertDialog.Builder(preference1.getContext()) - .setTitle(str("sb_guidelines_popup_title")) - .setMessage(str("sb_guidelines_popup_content")) - .setNegativeButton(str("sb_guidelines_popup_already_read"), null) - .setPositiveButton(str("sb_guidelines_popup_open"), (dialogInterface, i) -> openGuidelines()) + .setTitle(str("revanced_sb_guidelines_popup_title")) + .setMessage(str("revanced_sb_guidelines_popup_content")) + .setNegativeButton(str("revanced_sb_guidelines_popup_already_read"), null) + .setPositiveButton(str("revanced_sb_guidelines_popup_open"), (dialogInterface, i) -> openGuidelines()) .setOnDismissListener(dialog -> SettingsEnum.SB_SEEN_GUIDELINES.saveValue(true)) .setCancelable(false) .show(); @@ -258,13 +258,13 @@ private void addCreateSegmentCategory(Context context, PreferenceScreen screen) }); newSegmentStep = new EditTextPreference(context); - newSegmentStep.setTitle(str("sb_general_adjusting")); - newSegmentStep.setSummary(str("sb_general_adjusting_sum")); + newSegmentStep.setTitle(str("revanced_sb_general_adjusting")); + newSegmentStep.setSummary(str("revanced_sb_general_adjusting_sum")); newSegmentStep.getEditText().setInputType(InputType.TYPE_CLASS_NUMBER); newSegmentStep.setOnPreferenceChangeListener((preference1, newValue) -> { final int newAdjustmentValue = Integer.parseInt(newValue.toString()); if (newAdjustmentValue == 0) { - ReVancedUtils.showToastLong(str("sb_general_adjusting_invalid")); + ReVancedUtils.showToastLong(str("revanced_sb_general_adjusting_invalid")); return false; } SettingsEnum.SB_CREATE_NEW_SEGMENT_STEP.saveValue(newAdjustmentValue); @@ -273,8 +273,8 @@ private void addCreateSegmentCategory(Context context, PreferenceScreen screen) category.addPreference(newSegmentStep); Preference guidelinePreferences = new Preference(context); - guidelinePreferences.setTitle(str("sb_guidelines_preference_title")); - guidelinePreferences.setSummary(str("sb_guidelines_preference_sum")); + guidelinePreferences.setTitle(str("revanced_sb_guidelines_preference_title")); + guidelinePreferences.setSummary(str("revanced_sb_guidelines_preference_sum")); guidelinePreferences.setOnPreferenceClickListener(preference1 -> { openGuidelines(); return true; @@ -285,12 +285,12 @@ private void addCreateSegmentCategory(Context context, PreferenceScreen screen) private void addGeneralCategory(final Context context, PreferenceScreen screen) { PreferenceCategory category = new PreferenceCategory(context); screen.addPreference(category); - category.setTitle(str("sb_general")); + category.setTitle(str("revanced_sb_general")); toastOnConnectionError = new SwitchPreference(context); - toastOnConnectionError.setTitle(str("sb_toast_on_connection_error_title")); - toastOnConnectionError.setSummaryOn(str("sb_toast_on_connection_error_summary_on")); - toastOnConnectionError.setSummaryOff(str("sb_toast_on_connection_error_summary_off")); + toastOnConnectionError.setTitle(str("revanced_sb_toast_on_connection_error_title")); + toastOnConnectionError.setSummaryOn(str("revanced_sb_toast_on_connection_error_summary_on")); + toastOnConnectionError.setSummaryOff(str("revanced_sb_toast_on_connection_error_summary_off")); toastOnConnectionError.setOnPreferenceChangeListener((preference1, newValue) -> { SettingsEnum.SB_TOAST_ON_CONNECTION_ERROR.saveValue(newValue); updateUI(); @@ -299,9 +299,9 @@ private void addGeneralCategory(final Context context, PreferenceScreen screen) category.addPreference(toastOnConnectionError); trackSkips = new SwitchPreference(context); - trackSkips.setTitle(str("sb_general_skipcount")); - trackSkips.setSummaryOn(str("sb_general_skipcount_sum_on")); - trackSkips.setSummaryOff(str("sb_general_skipcount_sum_off")); + trackSkips.setTitle(str("revanced_sb_general_skipcount")); + trackSkips.setSummaryOn(str("revanced_sb_general_skipcount_sum_on")); + trackSkips.setSummaryOff(str("revanced_sb_general_skipcount_sum_off")); trackSkips.setOnPreferenceChangeListener((preference1, newValue) -> { SettingsEnum.SB_TRACK_SKIP_COUNT.saveValue(newValue); updateUI(); @@ -310,8 +310,8 @@ private void addGeneralCategory(final Context context, PreferenceScreen screen) category.addPreference(trackSkips); minSegmentDuration = new EditTextPreference(context); - minSegmentDuration.setTitle(str("sb_general_min_duration")); - minSegmentDuration.setSummary(str("sb_general_min_duration_sum")); + minSegmentDuration.setTitle(str("revanced_sb_general_min_duration")); + minSegmentDuration.setSummary(str("revanced_sb_general_min_duration_sum")); minSegmentDuration.getEditText().setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL); minSegmentDuration.setOnPreferenceChangeListener((preference1, newValue) -> { SettingsEnum.SB_SEGMENT_MIN_DURATION.saveValue(Float.valueOf(newValue.toString())); @@ -320,12 +320,12 @@ private void addGeneralCategory(final Context context, PreferenceScreen screen) category.addPreference(minSegmentDuration); privateUserId = new EditTextPreference(context); - privateUserId.setTitle(str("sb_general_uuid")); - privateUserId.setSummary(str("sb_general_uuid_sum")); + privateUserId.setTitle(str("revanced_sb_general_uuid")); + privateUserId.setSummary(str("revanced_sb_general_uuid_sum")); privateUserId.setOnPreferenceChangeListener((preference1, newValue) -> { String newUUID = newValue.toString(); if (!SponsorBlockSettings.isValidSBUserId(newUUID)) { - ReVancedUtils.showToastLong(str("sb_general_uuid_invalid")); + ReVancedUtils.showToastLong(str("revanced_sb_general_uuid_invalid")); return false; } SettingsEnum.SB_PRIVATE_USER_ID.saveValue(newUUID); @@ -335,8 +335,8 @@ private void addGeneralCategory(final Context context, PreferenceScreen screen) category.addPreference(privateUserId); apiUrl = new Preference(context); - apiUrl.setTitle(str("sb_general_api_url")); - apiUrl.setSummary(Html.fromHtml(str("sb_general_api_url_sum"))); + apiUrl.setTitle(str("revanced_sb_general_api_url")); + apiUrl.setSummary(Html.fromHtml(str("revanced_sb_general_api_url_sum"))); apiUrl.setOnPreferenceClickListener(preference1 -> { EditText editText = new EditText(context); editText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI); @@ -345,14 +345,14 @@ private void addGeneralCategory(final Context context, PreferenceScreen screen) DialogInterface.OnClickListener urlChangeListener = (dialog, buttonPressed) -> { if (buttonPressed == DialogInterface.BUTTON_NEUTRAL) { SettingsEnum.SB_API_URL.saveValue(SettingsEnum.SB_API_URL.defaultValue); - ReVancedUtils.showToastLong(str("sb_api_url_reset")); + ReVancedUtils.showToastLong(str("revanced_sb_api_url_reset")); } else if (buttonPressed == DialogInterface.BUTTON_POSITIVE) { String serverAddress = editText.getText().toString(); if (!SponsorBlockSettings.isValidSBServerAddress(serverAddress)) { - ReVancedUtils.showToastLong(str("sb_api_url_invalid")); + ReVancedUtils.showToastLong(str("revanced_sb_api_url_invalid")); } else if (!serverAddress.equals(SettingsEnum.SB_API_URL.getString())) { SettingsEnum.SB_API_URL.saveValue(serverAddress); - ReVancedUtils.showToastLong(str("sb_api_url_changed")); + ReVancedUtils.showToastLong(str("revanced_sb_api_url_changed")); } } }; @@ -360,7 +360,7 @@ private void addGeneralCategory(final Context context, PreferenceScreen screen) .setTitle(apiUrl.getTitle()) .setView(editText) .setNegativeButton(android.R.string.cancel, null) - .setNeutralButton(str("sb_reset"), urlChangeListener) + .setNeutralButton(str("revanced_sb_reset"), urlChangeListener) .setPositiveButton(android.R.string.ok, urlChangeListener) .show(); return true; @@ -369,13 +369,13 @@ private void addGeneralCategory(final Context context, PreferenceScreen screen) importExport = new EditTextPreference(context) { protected void onPrepareDialogBuilder(AlertDialog.Builder builder) { - builder.setNeutralButton(str("sb_settings_copy"), (dialog, which) -> { + builder.setNeutralButton(str("revanced_sb_settings_copy"), (dialog, which) -> { ReVancedUtils.setClipboard(getEditText().getText().toString()); }); } }; - importExport.setTitle(str("sb_settings_ie")); - importExport.setSummary(str("sb_settings_ie_sum")); + importExport.setTitle(str("revanced_sb_settings_ie")); + importExport.setSummary(str("revanced_sb_settings_ie_sum")); importExport.getEditText().setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_MULTI_LINE | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS); @@ -413,13 +413,13 @@ private void updateSegmentCategories() { private void addAboutCategory(Context context, PreferenceScreen screen) { PreferenceCategory category = new PreferenceCategory(context); screen.addPreference(category); - category.setTitle(str("sb_about")); + category.setTitle(str("revanced_sb_about")); { Preference preference = new Preference(context); category.addPreference(preference); - preference.setTitle(str("sb_about_api")); - preference.setSummary(str("sb_about_api_sum")); + preference.setTitle(str("revanced_sb_about_api")); + preference.setSummary(str("revanced_sb_about_api_sum")); preference.setOnPreferenceClickListener(preference1 -> { Intent i = new Intent(Intent.ACTION_VIEW); i.setData(Uri.parse("https://sponsor.ajay.app")); @@ -431,7 +431,7 @@ private void addAboutCategory(Context context, PreferenceScreen screen) { { Preference preference = new Preference(context); category.addPreference(preference); - preference.setSummary(str("sb_about_made_by")); + preference.setSummary(str("revanced_sb_about_made_by")); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { preference.setSingleLineTitle(false); } @@ -458,7 +458,7 @@ private void fetchAndDisplayStats() { loadingPlaceholderPreference.setEnabled(false); statsCategory.addPreference(loadingPlaceholderPreference); if (SettingsEnum.SB_ENABLED.getBoolean()) { - loadingPlaceholderPreference.setTitle(str("sb_stats_loading")); + loadingPlaceholderPreference.setTitle(str("revanced_sb_stats_loading")); ReVancedUtils.runOnBackgroundThread(() -> { UserStats stats = SBRequester.retrieveUserStats(); ReVancedUtils.runOnMainThread(() -> { // get back on main thread to modify UI elements diff --git a/app/src/main/java/app/revanced/integrations/sponsorblock/SegmentPlaybackController.java b/app/src/main/java/app/revanced/integrations/sponsorblock/SegmentPlaybackController.java index e6bb328d60..00ea6ff486 100644 --- a/app/src/main/java/app/revanced/integrations/sponsorblock/SegmentPlaybackController.java +++ b/app/src/main/java/app/revanced/integrations/sponsorblock/SegmentPlaybackController.java @@ -571,7 +571,7 @@ private static void showSkippedSegmentToast(@NonNull SponsorSegment segment) { } ReVancedUtils.showToastShort(toastNumberOfSegmentsSkipped == 1 ? toastSegmentSkipped.getSkippedToastText() - : str("sb_skipped_multiple_segments")); + : str("revanced_sb_skipped_multiple_segments")); } catch (Exception ex) { LogHelper.printException(() -> "showSkippedSegmentToast failure", ex); } finally { 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 595a037ee3..597f09b1e5 100644 --- a/app/src/main/java/app/revanced/integrations/sponsorblock/SponsorBlockSettings.java +++ b/app/src/main/java/app/revanced/integrations/sponsorblock/SponsorBlockSettings.java @@ -112,10 +112,10 @@ public static void importSettings(@NonNull String json) { SettingsEnum.SB_LOCAL_TIME_SAVED_MILLISECONDS.saveValue((long) (minutesSaved * 60 * 1000)); } - ReVancedUtils.showToastLong(str("sb_settings_import_successful")); + ReVancedUtils.showToastLong(str("revanced_sb_settings_import_successful")); } catch (Exception ex) { LogHelper.printInfo(() -> "failed to import settings", ex); // use info level, as we are showing our own toast - ReVancedUtils.showToastLong(str("sb_settings_import_failed", ex.getMessage())); + ReVancedUtils.showToastLong(str("revanced_sb_settings_import_failed", ex.getMessage())); } } @@ -161,7 +161,7 @@ public static String exportSettings() { return json.toString(2); } catch (Exception ex) { LogHelper.printInfo(() -> "failed to export settings", ex); // use info level, as we are showing our own toast - ReVancedUtils.showToastLong(str("sb_settings_export_failed", ex)); + ReVancedUtils.showToastLong(str("revanced_sb_settings_export_failed", ex)); return ""; } } @@ -178,8 +178,8 @@ public static void exportCategoriesToFlatJson(@Nullable Context dialogContext, if (dialogContext != null && SponsorBlockSettings.userHasSBPrivateId() && !SettingsEnum.SB_HIDE_EXPORT_WARNING.getBoolean()) { new AlertDialog.Builder(dialogContext) - .setMessage(str("sb_settings_revanced_export_user_id_warning")) - .setNeutralButton(str("sb_settings_revanced_export_user_id_warning_dismiss"), + .setMessage(str("revanced_sb_settings_revanced_export_user_id_warning")) + .setNeutralButton(str("revanced_sb_settings_revanced_export_user_id_warning_dismiss"), (dialog, which) -> SettingsEnum.SB_HIDE_EXPORT_WARNING.saveValue(true)) .setPositiveButton(android.R.string.ok, null) .setCancelable(false) 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 37020fce55..e645ed1b52 100644 --- a/app/src/main/java/app/revanced/integrations/sponsorblock/SponsorBlockUtils.java +++ b/app/src/main/java/app/revanced/integrations/sponsorblock/SponsorBlockUtils.java @@ -74,7 +74,7 @@ public void onClick(DialogInterface dialog, int which) { SegmentCategory category = SegmentCategory.categoriesWithoutHighlights()[which]; final boolean enableButton; if (category.behaviour == CategoryBehaviour.IGNORE) { - ReVancedUtils.showToastLong(str("sb_new_segment_disabled_category")); + ReVancedUtils.showToastLong(str("revanced_sb_new_segment_disabled_category")); enableButton = false; } else { newUserCreatedSegmentCategory = category; @@ -105,7 +105,7 @@ public void onClick(DialogInterface dialog, int which) { newUserCreatedSegmentCategory = null; new AlertDialog.Builder(context) - .setTitle(str("sb_new_segment_choose_category")) + .setTitle(str("revanced_sb_new_segment_choose_category")) .setSingleChoiceItems(titles, -1, segmentTypeListener) .setNegativeButton(android.R.string.cancel, null) .setPositiveButton(android.R.string.ok, segmentCategorySelectedDialogListener) @@ -141,7 +141,7 @@ public void onClick(DialogInterface dialog, int which) { editByHandSaveDialogListener.settingStart = isStart; editByHandSaveDialogListener.editText = new WeakReference<>(textView); new AlertDialog.Builder(context) - .setTitle(str(isStart ? "sb_new_segment_time_start" : "sb_new_segment_time_end")) + .setTitle(str(isStart ? "revanced_sb_new_segment_time_start" : "sb_new_segment_time_end")) .setView(textView) .setNegativeButton(android.R.string.cancel, null) .setNeutralButton(str("sb_new_segment_now"), editByHandSaveDialogListener) diff --git a/app/src/main/java/app/revanced/integrations/sponsorblock/objects/CategoryBehaviour.java b/app/src/main/java/app/revanced/integrations/sponsorblock/objects/CategoryBehaviour.java index 9b15d086f6..976e3d56fe 100644 --- a/app/src/main/java/app/revanced/integrations/sponsorblock/objects/CategoryBehaviour.java +++ b/app/src/main/java/app/revanced/integrations/sponsorblock/objects/CategoryBehaviour.java @@ -11,7 +11,7 @@ import app.revanced.integrations.utils.StringRef; public enum CategoryBehaviour { - SKIP_AUTOMATICALLY("skip", 2, true, sf("sb_skip_automatically")), + SKIP_AUTOMATICALLY("skip", 2, true, sf("revanced_sb_skip_automatically")), // desktop does not have skip-once behavior. Key is unique to ReVanced SKIP_AUTOMATICALLY_ONCE("skip-once", 3, true, sf("sb_skip_automatically_once")), MANUAL_SKIP("manual-skip", 1, false, sf("sb_skip_showbutton")), diff --git a/app/src/main/java/app/revanced/integrations/sponsorblock/objects/SegmentCategory.java b/app/src/main/java/app/revanced/integrations/sponsorblock/objects/SegmentCategory.java index ed34bf10d2..0c2c151b70 100644 --- a/app/src/main/java/app/revanced/integrations/sponsorblock/objects/SegmentCategory.java +++ b/app/src/main/java/app/revanced/integrations/sponsorblock/objects/SegmentCategory.java @@ -31,7 +31,7 @@ import app.revanced.integrations.utils.StringRef; public enum SegmentCategory { - SPONSOR("sponsor", sf("sb_segments_sponsor"), sf("sb_segments_sponsor_sum"), sf("sb_skip_button_sponsor"), sf("sb_skipped_sponsor"), + SPONSOR("sponsor", sf("revanced_sb_segments_sponsor"), sf("sb_segments_sponsor_sum"), sf("sb_skip_button_sponsor"), sf("sb_skipped_sponsor"), SKIP_AUTOMATICALLY_ONCE, 0x00D400), SELF_PROMO("selfpromo", sf("sb_segments_selfpromo"), sf("sb_segments_selfpromo_sum"), sf("sb_skip_button_selfpromo"), sf("sb_skipped_selfpromo"), MANUAL_SKIP, 0xFFFF00), 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 6bb699173a..a03c0aa23d 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 @@ -97,11 +97,11 @@ public static SponsorSegment[] getSegments(@NonNull String videoId) { // no segments are found. a normal response LogHelper.printDebug(() -> "No segments found for video: " + videoId); } else { - handleConnectionError(str("sb_sponsorblock_connection_failure_status", responseCode), null); + handleConnectionError(str("revanced_sb_sponsorblock_connection_failure_status", responseCode), null); connection.disconnect(); // something went wrong, might as well disconnect } } catch (SocketTimeoutException ex) { - handleConnectionError(str("sb_sponsorblock_connection_failure_timeout"), ex); + handleConnectionError(str("revanced_sb_sponsorblock_connection_failure_timeout"), ex); } catch (IOException ex) { handleConnectionError(str("sb_sponsorblock_connection_failure_generic"), ex); } catch (Exception ex) { diff --git a/app/src/main/java/app/revanced/integrations/sponsorblock/ui/CreateSegmentButtonController.java b/app/src/main/java/app/revanced/integrations/sponsorblock/ui/CreateSegmentButtonController.java index 83528d0914..6c0875ca62 100644 --- a/app/src/main/java/app/revanced/integrations/sponsorblock/ui/CreateSegmentButtonController.java +++ b/app/src/main/java/app/revanced/integrations/sponsorblock/ui/CreateSegmentButtonController.java @@ -25,7 +25,7 @@ public static void initialize(View youtubeControlsLayout) { try { LogHelper.printDebug(() -> "initializing new segment button"); ImageView imageView = Objects.requireNonNull(youtubeControlsLayout.findViewById( - getResourceIdentifier("sb_sponsorblock_button", "id"))); + getResourceIdentifier("revanced_sb_sponsorblock_button", "id"))); imageView.setVisibility(View.GONE); imageView.setOnClickListener(v -> { SponsorBlockViewController.toggleNewSegmentLayoutVisibility(); diff --git a/app/src/main/java/app/revanced/integrations/sponsorblock/ui/NewSegmentLayout.java b/app/src/main/java/app/revanced/integrations/sponsorblock/ui/NewSegmentLayout.java index 970462afe0..3f66acacc5 100644 --- a/app/src/main/java/app/revanced/integrations/sponsorblock/ui/NewSegmentLayout.java +++ b/app/src/main/java/app/revanced/integrations/sponsorblock/ui/NewSegmentLayout.java @@ -52,14 +52,14 @@ public NewSegmentLayout(final Context context, final AttributeSet attributeSet, initializeButton( context, - "sb_new_segment_rewind", + "revanced_sb_new_segment_rewind", () -> VideoInformation.seekToRelative(-SettingsEnum.SB_CREATE_NEW_SEGMENT_STEP.getInt()), "Rewind button clicked" ); initializeButton( context, - "sb_new_segment_forward", + "revanced_sb_new_segment_forward", () -> VideoInformation.seekToRelative(SettingsEnum.SB_CREATE_NEW_SEGMENT_STEP.getInt()), "Forward button clicked" ); diff --git a/app/src/main/java/app/revanced/integrations/sponsorblock/ui/SkipSponsorButton.java b/app/src/main/java/app/revanced/integrations/sponsorblock/ui/SkipSponsorButton.java index 47613392d5..3b927681f6 100644 --- a/app/src/main/java/app/revanced/integrations/sponsorblock/ui/SkipSponsorButton.java +++ b/app/src/main/java/app/revanced/integrations/sponsorblock/ui/SkipSponsorButton.java @@ -49,7 +49,7 @@ public SkipSponsorButton(Context context, AttributeSet attributeSet, int defStyl LayoutInflater.from(context).inflate(getResourceIdentifier(context, "skip_sponsor_button", "layout"), this, true); // layout:skip_ad_button setMinimumHeight(getResourceDimensionPixelSize("ad_skip_ad_button_min_height")); // dimen:ad_skip_ad_button_min_height - skipSponsorBtnContainer = Objects.requireNonNull((LinearLayout) findViewById(getResourceIdentifier(context, "sb_skip_sponsor_button_container", "id"))); // id:skip_ad_button_container + skipSponsorBtnContainer = Objects.requireNonNull((LinearLayout) findViewById(getResourceIdentifier(context, "revanced_sb_skip_sponsor_button_container", "id"))); // id:skip_ad_button_container background = new Paint(); background.setColor(getResourceColor("skip_ad_button_background_color")); // color:skip_ad_button_background_color); background.setStyle(Paint.Style.FILL); diff --git a/app/src/main/java/app/revanced/integrations/sponsorblock/ui/SponsorBlockViewController.java b/app/src/main/java/app/revanced/integrations/sponsorblock/ui/SponsorBlockViewController.java index ac3a390980..987efe2cac 100644 --- a/app/src/main/java/app/revanced/integrations/sponsorblock/ui/SponsorBlockViewController.java +++ b/app/src/main/java/app/revanced/integrations/sponsorblock/ui/SponsorBlockViewController.java @@ -81,11 +81,11 @@ public void onChildViewRemoved(View parent, View child) { youtubeOverlaysLayoutRef = new WeakReference<>(viewGroup); skipHighlightButtonRef = new WeakReference<>( - Objects.requireNonNull(layout.findViewById(getResourceIdentifier("sb_skip_highlight_button", "id")))); + Objects.requireNonNull(layout.findViewById(getResourceIdentifier("revanced_sb_skip_highlight_button", "id")))); skipSponsorButtonRef = new WeakReference<>( - Objects.requireNonNull(layout.findViewById(getResourceIdentifier("sb_skip_sponsor_button", "id")))); + Objects.requireNonNull(layout.findViewById(getResourceIdentifier("revanced_sb_skip_sponsor_button", "id")))); newSegmentLayoutRef = new WeakReference<>( - Objects.requireNonNull(layout.findViewById(getResourceIdentifier("sb_new_segment_view", "id")))); + Objects.requireNonNull(layout.findViewById(getResourceIdentifier("revanced_sb_new_segment_view", "id")))); newSegmentLayoutVisible = false; skipHighlight = null; diff --git a/app/src/main/java/app/revanced/integrations/sponsorblock/ui/VotingButtonController.java b/app/src/main/java/app/revanced/integrations/sponsorblock/ui/VotingButtonController.java index e0e4d555fc..1211497826 100644 --- a/app/src/main/java/app/revanced/integrations/sponsorblock/ui/VotingButtonController.java +++ b/app/src/main/java/app/revanced/integrations/sponsorblock/ui/VotingButtonController.java @@ -27,7 +27,7 @@ public static void initialize(View youtubeControlsLayout) { try { LogHelper.printDebug(() -> "initializing voting button"); ImageView imageView = Objects.requireNonNull(youtubeControlsLayout.findViewById( - getResourceIdentifier("sb_voting_button", "id"))); + getResourceIdentifier("revanced_sb_voting_button", "id"))); imageView.setVisibility(View.GONE); imageView.setOnClickListener(v -> { SponsorBlockUtils.onVotingClicked(v.getContext()); From 248f23319eaa9ae488b56315446f457438e7e1fb Mon Sep 17 00:00:00 2001 From: LisoUseInAIKyrios <118716522+LisoUseInAIKyrios@users.noreply.github.com> Date: Fri, 16 Jun 2023 20:02:57 +0400 Subject: [PATCH 21/48] Fixing strings not renamed. Android Studio apparently gives up after a set limit of found items are encountered. --- .../SponsorBlockSettingsFragment.java | 30 ++++++------ .../sponsorblock/SponsorBlockUtils.java | 46 +++++++++---------- .../objects/CategoryBehaviour.java | 8 ++-- .../sponsorblock/objects/SegmentCategory.java | 34 +++++++------- .../SegmentCategoryListPreference.java | 10 ++-- .../sponsorblock/objects/SponsorSegment.java | 6 +-- .../sponsorblock/requests/SBRequester.java | 30 ++++++------ .../sponsorblock/ui/NewSegmentLayout.java | 8 ++-- .../sponsorblock/ui/SkipSponsorButton.java | 2 +- .../views/SwipeControlsOverlayLayout.kt | 8 ++-- .../videoplayer/CopyVideoUrlButton.java | 2 +- .../CopyVideoUrlTimestampButton.java | 2 +- .../videoplayer/ExternalDownloadButton.java | 2 +- 13 files changed, 94 insertions(+), 94 deletions(-) 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 b712cdce71..721811f530 100644 --- a/app/src/main/java/app/revanced/integrations/settingsmenu/SponsorBlockSettingsFragment.java +++ b/app/src/main/java/app/revanced/integrations/settingsmenu/SponsorBlockSettingsFragment.java @@ -467,7 +467,7 @@ private void fetchAndDisplayStats() { }); }); } else { - loadingPlaceholderPreference.setTitle(str("sb_stats_sb_disabled")); + loadingPlaceholderPreference.setTitle(str("revanced_sb_stats_sb_disabled")); } } catch (Exception ex) { LogHelper.printException(() -> "fetchAndDisplayStats failure", ex); @@ -480,7 +480,7 @@ private void addUserStats(@NonNull Preference loadingPlaceholder, @Nullable User ReVancedUtils.verifyOnMainThread(); try { if (stats == null) { - loadingPlaceholder.setTitle(str("sb_stats_connection_failure")); + loadingPlaceholder.setTitle(str("revanced_sb_stats_connection_failure")); return; } statsCategory.removeAll(); @@ -491,8 +491,8 @@ private void addUserStats(@NonNull Preference loadingPlaceholder, @Nullable User EditTextPreference preference = new EditTextPreference(context); statsCategory.addPreference(preference); String userName = stats.userName; - preference.setTitle(fromHtml(str("sb_stats_username", userName))); - preference.setSummary(str("sb_stats_username_change")); + preference.setTitle(fromHtml(str("revanced_sb_stats_username", userName))); + preference.setSummary(str("revanced_sb_stats_username_change")); preference.setText(userName); preference.setOnPreferenceChangeListener((preference1, value) -> { ReVancedUtils.runOnBackgroundThread(() -> { @@ -500,9 +500,9 @@ private void addUserStats(@NonNull Preference loadingPlaceholder, @Nullable User String errorMessage = SBRequester.setUsername(newUserName); ReVancedUtils.runOnMainThread(() -> { if (errorMessage == null) { - preference.setTitle(fromHtml(str("sb_stats_username", newUserName))); + preference.setTitle(fromHtml(str("revanced_sb_stats_username", newUserName))); preference.setText(newUserName); - ReVancedUtils.showToastLong(str("sb_stats_username_changed")); + ReVancedUtils.showToastLong(str("revanced_sb_stats_username_changed")); } else { preference.setText(userName); // revert to previous ReVancedUtils.showToastLong(errorMessage); @@ -518,7 +518,7 @@ private void addUserStats(@NonNull Preference loadingPlaceholder, @Nullable User Preference preference = new Preference(context); statsCategory.addPreference(preference); String formatted = statsNumberOfSegmentsSkippedFormatter.format(stats.segmentCount); - preference.setTitle(fromHtml(str("sb_stats_submissions", formatted))); + preference.setTitle(fromHtml(str("revanced_sb_stats_submissions", formatted))); if (stats.totalSegmentCountIncludingIgnored == 0) { preference.setSelectable(false); } else { @@ -535,7 +535,7 @@ private void addUserStats(@NonNull Preference loadingPlaceholder, @Nullable User // "user reputation". Usually not useful, since it appears most users have zero reputation. // But if there is a reputation, then show it here Preference preference = new Preference(context); - preference.setTitle(fromHtml(str("sb_stats_reputation", stats.reputation))); + preference.setTitle(fromHtml(str("revanced_sb_stats_reputation", stats.reputation))); preference.setSelectable(false); if (stats.reputation != 0) { statsCategory.addPreference(preference); @@ -550,11 +550,11 @@ private void addUserStats(@NonNull Preference loadingPlaceholder, @Nullable User String stats_saved; String stats_saved_sum; if (stats.totalSegmentCountIncludingIgnored == 0) { - stats_saved = str("sb_stats_saved_zero"); - stats_saved_sum = str("sb_stats_saved_sum_zero"); + stats_saved = str("revanced_sb_stats_saved_zero"); + stats_saved_sum = str("revanced_sb_stats_saved_sum_zero"); } else { - stats_saved = str("sb_stats_saved", statsNumberOfSegmentsSkippedFormatter.format(stats.viewCount)); - stats_saved_sum = str("sb_stats_saved_sum", SponsorBlockUtils.getTimeSavedString((long) (60 * stats.minutesSaved))); + stats_saved = str("revanced_sb_stats_saved", statsNumberOfSegmentsSkippedFormatter.format(stats.viewCount)); + stats_saved_sum = str("revanced_sb_stats_saved_sum", SponsorBlockUtils.getTimeSavedString((long) (60 * stats.minutesSaved))); } preference.setTitle(fromHtml(stats_saved)); preference.setSummary(fromHtml(stats_saved_sum)); @@ -577,14 +577,14 @@ private void addLocalUserStats() { Runnable updateStatsSelfSaved = () -> { String formatted = statsNumberOfSegmentsSkippedFormatter.format(SettingsEnum.SB_LOCAL_TIME_SAVED_NUMBER_SEGMENTS.getInt()); - preference.setTitle(fromHtml(str("sb_stats_self_saved", formatted))); + preference.setTitle(fromHtml(str("revanced_sb_stats_self_saved", formatted))); String formattedSaved = SponsorBlockUtils.getTimeSavedString(SettingsEnum.SB_LOCAL_TIME_SAVED_MILLISECONDS.getLong() / 1000); - preference.setSummary(fromHtml(str("sb_stats_self_saved_sum", formattedSaved))); + preference.setSummary(fromHtml(str("revanced_sb_stats_self_saved_sum", formattedSaved))); }; updateStatsSelfSaved.run(); preference.setOnPreferenceClickListener(preference1 -> { new AlertDialog.Builder(preference1.getContext()) - .setTitle(str("sb_stats_self_saved_reset_title")) + .setTitle(str("revanced_sb_stats_self_saved_reset_title")) .setPositiveButton(android.R.string.yes, (dialog, whichButton) -> { SettingsEnum.SB_LOCAL_TIME_SAVED_NUMBER_SEGMENTS.saveValue(SettingsEnum.SB_LOCAL_TIME_SAVED_NUMBER_SEGMENTS.defaultValue); SettingsEnum.SB_LOCAL_TIME_SAVED_MILLISECONDS.saveValue(SettingsEnum.SB_LOCAL_TIME_SAVED_MILLISECONDS.defaultValue); 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 e645ed1b52..b966b961e3 100644 --- a/app/src/main/java/app/revanced/integrations/sponsorblock/SponsorBlockUtils.java +++ b/app/src/main/java/app/revanced/integrations/sponsorblock/SponsorBlockUtils.java @@ -141,10 +141,10 @@ public void onClick(DialogInterface dialog, int which) { editByHandSaveDialogListener.settingStart = isStart; editByHandSaveDialogListener.editText = new WeakReference<>(textView); new AlertDialog.Builder(context) - .setTitle(str(isStart ? "revanced_sb_new_segment_time_start" : "sb_new_segment_time_end")) + .setTitle(str(isStart ? "revanced_sb_new_segment_time_start" : "revanced_sb_new_segment_time_end")) .setView(textView) .setNegativeButton(android.R.string.cancel, null) - .setNeutralButton(str("sb_new_segment_now"), editByHandSaveDialogListener) + .setNeutralButton(str("revanced_sb_new_segment_now"), editByHandSaveDialogListener) .setPositiveButton(android.R.string.ok, editByHandSaveDialogListener) .show(); @@ -239,14 +239,14 @@ public static void onMarkLocationClicked() { newSponsorSegmentDialogShownMillis = VideoInformation.getVideoTime(); new AlertDialog.Builder(SponsorBlockViewController.getOverLaysViewGroupContext()) - .setTitle(str("sb_new_segment_title")) - .setMessage(str("sb_new_segment_mark_time_as_question", + .setTitle(str("revanced_sb_new_segment_title")) + .setMessage(str("revanced_sb_new_segment_mark_time_as_question", newSponsorSegmentDialogShownMillis / 60000, newSponsorSegmentDialogShownMillis / 1000 % 60, newSponsorSegmentDialogShownMillis % 1000)) .setNeutralButton(android.R.string.cancel, null) - .setNegativeButton(str("sb_new_segment_mark_start"), newSponsorSegmentDialogListener) - .setPositiveButton(str("sb_new_segment_mark_end"), newSponsorSegmentDialogListener) + .setNegativeButton(str("revanced_sb_new_segment_mark_start"), newSponsorSegmentDialogListener) + .setPositiveButton(str("revanced_sb_new_segment_mark_end"), newSponsorSegmentDialogListener) .show(); } catch (Exception ex) { LogHelper.printException(() -> "onMarkLocationClicked failure", ex); @@ -257,18 +257,18 @@ public static void onPublishClicked() { try { ReVancedUtils.verifyOnMainThread(); if (newSponsorSegmentStartMillis < 0 || newSponsorSegmentEndMillis < 0) { - ReVancedUtils.showToastShort(str("sb_new_segment_mark_locations_first")); + ReVancedUtils.showToastShort(str("revanced_sb_new_segment_mark_locations_first")); } else if (newSponsorSegmentStartMillis >= newSponsorSegmentEndMillis) { - ReVancedUtils.showToastShort(str("sb_new_segment_start_is_before_end")); + ReVancedUtils.showToastShort(str("revanced_sb_new_segment_start_is_before_end")); } else if (!newSponsorSegmentPreviewed && newSponsorSegmentStartMillis != 0) { - ReVancedUtils.showToastLong(str("sb_new_segment_preview_segment_first")); + ReVancedUtils.showToastLong(str("revanced_sb_new_segment_preview_segment_first")); } else { long length = (newSponsorSegmentEndMillis - newSponsorSegmentStartMillis) / 1000; long start = (newSponsorSegmentStartMillis) / 1000; long end = (newSponsorSegmentEndMillis) / 1000; new AlertDialog.Builder(SponsorBlockViewController.getOverLaysViewGroupContext()) - .setTitle(str("sb_new_segment_confirm_title")) - .setMessage(str("sb_new_segment_confirm_content", + .setTitle(str("revanced_sb_new_segment_confirm_title")) + .setMessage(str("revanced_sb_new_segment_confirm_content", start / 60, start % 60, end / 60, end % 60, length / 60, length % 60)) @@ -289,7 +289,7 @@ public static void onVotingClicked(@NonNull Context context) { // Button is hidden if no segments exist. // But if prior video had segments, and current video does not, // then the button persists until the overlay fades out (this is intentional, as abruptly hiding the button is jarring). - ReVancedUtils.showToastShort(str("sb_vote_no_segments")); + ReVancedUtils.showToastShort(str("revanced_sb_vote_no_segments")); return; } @@ -345,7 +345,7 @@ private static void onNewCategorySelect(@NonNull SponsorSegment segment, @NonNul } new AlertDialog.Builder(context) - .setTitle(str("sb_new_segment_choose_category")) + .setTitle(str("revanced_sb_new_segment_choose_category")) .setItems(titles, (dialog, which) -> SBRequester.voteToChangeCategoryOnBackgroundThread(segment, values[which])) .show(); } catch (Exception ex) { @@ -357,9 +357,9 @@ public static void onPreviewClicked() { try { ReVancedUtils.verifyOnMainThread(); if (newSponsorSegmentStartMillis < 0 || newSponsorSegmentEndMillis < 0) { - ReVancedUtils.showToastShort(str("sb_new_segment_mark_locations_first")); + ReVancedUtils.showToastShort(str("revanced_sb_new_segment_mark_locations_first")); } else if (newSponsorSegmentStartMillis >= newSponsorSegmentEndMillis) { - ReVancedUtils.showToastShort(str("sb_new_segment_start_is_before_end")); + ReVancedUtils.showToastShort(str("revanced_sb_new_segment_start_is_before_end")); } else { SegmentPlaybackController.removeUnsubmittedSegments(); // If user hits preview more than once before playing. SegmentPlaybackController.addUnsubmittedSegment( @@ -391,11 +391,11 @@ public static void onEditByHandClicked() { try { ReVancedUtils.verifyOnMainThread(); new AlertDialog.Builder(SponsorBlockViewController.getOverLaysViewGroupContext()) - .setTitle(str("sb_new_segment_edit_by_hand_title")) - .setMessage(str("sb_new_segment_edit_by_hand_content")) + .setTitle(str("revanced_sb_new_segment_edit_by_hand_title")) + .setMessage(str("revanced_sb_new_segment_edit_by_hand_content")) .setNeutralButton(android.R.string.cancel, null) - .setNegativeButton(str("sb_new_segment_mark_start"), editByHandDialogListener) - .setPositiveButton(str("sb_new_segment_mark_end"), editByHandDialogListener) + .setNegativeButton(str("revanced_sb_new_segment_mark_start"), editByHandDialogListener) + .setPositiveButton(str("revanced_sb_new_segment_mark_end"), editByHandDialogListener) .show(); } catch (Exception ex) { LogHelper.printException(() -> "onEditByHandClicked failure", ex); @@ -408,13 +408,13 @@ public static String getTimeSavedString(long totalSecondsSaved) { final long hoursSaved = duration.toHours(); final long minutesSaved = duration.toMinutes() % 60; if (hoursSaved > 0) { - return str("sb_stats_saved_hour_format", hoursSaved, minutesSaved); + return str("revanced_sb_stats_saved_hour_format", hoursSaved, minutesSaved); } final long secondsSaved = duration.getSeconds() % 60; if (minutesSaved > 0) { - return str("sb_stats_saved_minute_format", minutesSaved, secondsSaved); + return str("revanced_sb_stats_saved_minute_format", minutesSaved, secondsSaved); } - return str("sb_stats_saved_second_format", secondsSaved); + return str("revanced_sb_stats_saved_second_format", secondsSaved); } return "error"; // will never be reached. YouTube requires Android O or greater } @@ -443,7 +443,7 @@ public void onClick(DialogInterface dialog, int which) { DialogInterface.BUTTON_NEGATIVE : DialogInterface.BUTTON_POSITIVE); } catch (ParseException e) { - ReVancedUtils.showToastLong(str("sb_new_segment_edit_by_hand_parse_error")); + ReVancedUtils.showToastLong(str("revanced_sb_new_segment_edit_by_hand_parse_error")); } catch (Exception ex) { LogHelper.printException(() -> "EditByHandSaveDialogListener failure", ex); } diff --git a/app/src/main/java/app/revanced/integrations/sponsorblock/objects/CategoryBehaviour.java b/app/src/main/java/app/revanced/integrations/sponsorblock/objects/CategoryBehaviour.java index 976e3d56fe..3ebd1effb9 100644 --- a/app/src/main/java/app/revanced/integrations/sponsorblock/objects/CategoryBehaviour.java +++ b/app/src/main/java/app/revanced/integrations/sponsorblock/objects/CategoryBehaviour.java @@ -13,11 +13,11 @@ public enum CategoryBehaviour { SKIP_AUTOMATICALLY("skip", 2, true, sf("revanced_sb_skip_automatically")), // desktop does not have skip-once behavior. Key is unique to ReVanced - SKIP_AUTOMATICALLY_ONCE("skip-once", 3, true, sf("sb_skip_automatically_once")), - MANUAL_SKIP("manual-skip", 1, false, sf("sb_skip_showbutton")), - SHOW_IN_SEEKBAR("seekbar-only", 0, false, sf("sb_skip_seekbaronly")), + SKIP_AUTOMATICALLY_ONCE("skip-once", 3, true, sf("revanced_sb_skip_automatically_once")), + MANUAL_SKIP("manual-skip", 1, false, sf("revanced_sb_skip_showbutton")), + SHOW_IN_SEEKBAR("seekbar-only", 0, false, sf("revanced_sb_skip_seekbaronly")), // ignored categories are not exported to json, and ignore is the default behavior when importing - IGNORE("ignore", -1, false, sf("sb_skip_ignore")); + IGNORE("ignore", -1, false, sf("revanced_sb_skip_ignore")); @NonNull public final String key; diff --git a/app/src/main/java/app/revanced/integrations/sponsorblock/objects/SegmentCategory.java b/app/src/main/java/app/revanced/integrations/sponsorblock/objects/SegmentCategory.java index 0c2c151b70..49e69dec6c 100644 --- a/app/src/main/java/app/revanced/integrations/sponsorblock/objects/SegmentCategory.java +++ b/app/src/main/java/app/revanced/integrations/sponsorblock/objects/SegmentCategory.java @@ -31,41 +31,41 @@ import app.revanced.integrations.utils.StringRef; public enum SegmentCategory { - SPONSOR("sponsor", sf("revanced_sb_segments_sponsor"), sf("sb_segments_sponsor_sum"), sf("sb_skip_button_sponsor"), sf("sb_skipped_sponsor"), + SPONSOR("sponsor", sf("revanced_sb_segments_sponsor"), sf("revanced_sb_segments_sponsor_sum"), sf("revanced_sb_skip_button_sponsor"), sf("revanced_sb_skipped_sponsor"), SKIP_AUTOMATICALLY_ONCE, 0x00D400), - SELF_PROMO("selfpromo", sf("sb_segments_selfpromo"), sf("sb_segments_selfpromo_sum"), sf("sb_skip_button_selfpromo"), sf("sb_skipped_selfpromo"), + SELF_PROMO("selfpromo", sf("revanced_sb_segments_selfpromo"), sf("revanced_sb_segments_selfpromo_sum"), sf("revanced_sb_skip_button_selfpromo"), sf("revanced_sb_skipped_selfpromo"), MANUAL_SKIP, 0xFFFF00), - INTERACTION("interaction", sf("sb_segments_interaction"), sf("sb_segments_interaction_sum"), sf("sb_skip_button_interaction"), sf("sb_skipped_interaction"), + INTERACTION("interaction", sf("revanced_sb_segments_interaction"), sf("revanced_sb_segments_interaction_sum"), sf("revanced_sb_skip_button_interaction"), sf("revanced_sb_skipped_interaction"), MANUAL_SKIP, 0xCC00FF), /** * Unique category that is treated differently than the rest. */ - HIGHLIGHT("poi_highlight", sf("sb_segments_highlight"), sf("sb_segments_highlight_sum"), sf("sb_skip_button_highlight"), sf("sb_skipped_highlight"), + HIGHLIGHT("poi_highlight", sf("revanced_sb_segments_highlight"), sf("revanced_sb_segments_highlight_sum"), sf("revanced_sb_skip_button_highlight"), sf("revanced_sb_skipped_highlight"), MANUAL_SKIP, 0xFF1684), - INTRO("intro", sf("sb_segments_intro"), sf("sb_segments_intro_sum"), - sf("sb_skip_button_intro_beginning"), sf("sb_skip_button_intro_middle"), sf("sb_skip_button_intro_end"), - sf("sb_skipped_intro_beginning"), sf("sb_skipped_intro_middle"), sf("sb_skipped_intro_end"), + INTRO("intro", sf("revanced_sb_segments_intro"), sf("revanced_sb_segments_intro_sum"), + sf("revanced_sb_skip_button_intro_beginning"), sf("revanced_sb_skip_button_intro_middle"), sf("revanced_sb_skip_button_intro_end"), + sf("revanced_sb_skipped_intro_beginning"), sf("revanced_sb_skipped_intro_middle"), sf("revanced_sb_skipped_intro_end"), MANUAL_SKIP, 0x00FFFF), - OUTRO("outro", sf("sb_segments_outro"), sf("sb_segments_outro_sum"), sf("sb_skip_button_outro"), sf("sb_skipped_outro"), + OUTRO("outro", sf("revanced_sb_segments_outro"), sf("revanced_sb_segments_outro_sum"), sf("revanced_sb_skip_button_outro"), sf("revanced_sb_skipped_outro"), MANUAL_SKIP, 0x0202ED), - PREVIEW("preview", sf("sb_segments_preview"), sf("sb_segments_preview_sum"), - sf("sb_skip_button_preview_beginning"), sf("sb_skip_button_preview_middle"), sf("sb_skip_button_preview_end"), - sf("sb_skipped_preview_beginning"), sf("sb_skipped_preview_middle"), sf("sb_skipped_preview_end"), + PREVIEW("preview", sf("revanced_sb_segments_preview"), sf("revanced_sb_segments_preview_sum"), + sf("revanced_sb_skip_button_preview_beginning"), sf("revanced_sb_skip_button_preview_middle"), sf("revanced_sb_skip_button_preview_end"), + sf("revanced_sb_skipped_preview_beginning"), sf("revanced_sb_skipped_preview_middle"), sf("revanced_sb_skipped_preview_end"), IGNORE, 0x008FD6), - FILLER("filler", sf("sb_segments_filler"), sf("sb_segments_filler_sum"), sf("sb_skip_button_filler"), sf("sb_skipped_filler"), + FILLER("filler", sf("revanced_sb_segments_filler"), sf("revanced_sb_segments_filler_sum"), sf("revanced_sb_skip_button_filler"), sf("revanced_sb_skipped_filler"), IGNORE, 0x7300FF), - MUSIC_OFFTOPIC("music_offtopic", sf("sb_segments_nomusic"), sf("sb_segments_nomusic_sum"), sf("sb_skip_button_nomusic"), sf("sb_skipped_nomusic"), + MUSIC_OFFTOPIC("music_offtopic", sf("revanced_sb_segments_nomusic"), sf("revanced_sb_segments_nomusic_sum"), sf("revanced_sb_skip_button_nomusic"), sf("revanced_sb_skipped_nomusic"), MANUAL_SKIP, 0xFF9900), - UNSUBMITTED("unsubmitted", StringRef.empty, StringRef.empty, sf("sb_skip_button_unsubmitted"), sf("sb_skipped_unsubmitted"), + UNSUBMITTED("unsubmitted", StringRef.empty, StringRef.empty, sf("revanced_sb_skip_button_unsubmitted"), sf("revanced_sb_skipped_unsubmitted"), SKIP_AUTOMATICALLY, 0xFFFFFF); - private static final StringRef skipSponsorTextCompact = sf("sb_skip_button_compact"); - private static final StringRef skipSponsorTextCompactHighlight = sf("sb_skip_button_compact_highlight"); + private static final StringRef skipSponsorTextCompact = sf("revanced_sb_skip_button_compact"); + private static final StringRef skipSponsorTextCompactHighlight = sf("revanced_sb_skip_button_compact_highlight"); /** * Prefix to use when serializing to flat JSON layout used with ReVanced import/export. */ - private static final String FLAT_JSON_IMPORT_EXPORT_PREFIX = "sb_"; + private static final String FLAT_JSON_IMPORT_EXPORT_PREFIX = "revanced_sb_"; private static final SegmentCategory[] categoriesWithoutHighlights = new SegmentCategory[]{ SPONSOR, diff --git a/app/src/main/java/app/revanced/integrations/sponsorblock/objects/SegmentCategoryListPreference.java b/app/src/main/java/app/revanced/integrations/sponsorblock/objects/SegmentCategoryListPreference.java index b2e9e2c9b7..adc03e3084 100644 --- a/app/src/main/java/app/revanced/integrations/sponsorblock/objects/SegmentCategoryListPreference.java +++ b/app/src/main/java/app/revanced/integrations/sponsorblock/objects/SegmentCategoryListPreference.java @@ -54,7 +54,7 @@ protected void onPrepareDialogBuilder(AlertDialog.Builder builder) { TableRow row = new TableRow(context); TextView colorTextLabel = new TextView(context); - colorTextLabel.setText(str("sb_color_dot_label")); + colorTextLabel.setText(str("revanced_sb_color_dot_label")); row.addView(colorTextLabel); TextView colorDotView = new TextView(context); @@ -103,14 +103,14 @@ public void afterTextChanged(Editable s) { builder.setPositiveButton(android.R.string.ok, (dialog, which) -> { onClick(dialog, DialogInterface.BUTTON_POSITIVE); }); - builder.setNeutralButton(str("sb_reset_color"), (dialog, which) -> { + builder.setNeutralButton(str("revanced_sb_reset_color"), (dialog, which) -> { try { SharedPreferences.Editor editor = getSharedPreferences().edit(); category.setColor(category.defaultColor); category.save(editor); editor.apply(); updateTitle(); - ReVancedUtils.showToastShort(str("sb_color_reset")); + ReVancedUtils.showToastShort(str("revanced_sb_color_reset")); } catch (Exception ex) { LogHelper.printException(() -> "setNeutralButton failure", ex); } @@ -139,10 +139,10 @@ protected void onDialogClosed(boolean positiveResult) { final int color = Color.parseColor(colorString) & 0xFFFFFF; if (color != category.color) { category.setColor(color); - ReVancedUtils.showToastShort(str("sb_color_changed")); + ReVancedUtils.showToastShort(str("revanced_sb_color_changed")); } } catch (IllegalArgumentException ex) { - ReVancedUtils.showToastShort(str("sb_color_invalid")); + ReVancedUtils.showToastShort(str("revanced_sb_color_invalid")); } // behavior is already saved, but color needs to be saved SharedPreferences.Editor editor = getSharedPreferences().edit(); diff --git a/app/src/main/java/app/revanced/integrations/sponsorblock/objects/SponsorSegment.java b/app/src/main/java/app/revanced/integrations/sponsorblock/objects/SponsorSegment.java index 60c6059867..a18c25f42f 100644 --- a/app/src/main/java/app/revanced/integrations/sponsorblock/objects/SponsorSegment.java +++ b/app/src/main/java/app/revanced/integrations/sponsorblock/objects/SponsorSegment.java @@ -11,9 +11,9 @@ public class SponsorSegment implements Comparable { public enum SegmentVote { - UPVOTE(sf("sb_vote_upvote"), 1,false), - DOWNVOTE(sf("sb_vote_downvote"), 0, true), - CATEGORY_CHANGE(sf("sb_vote_category"), -1, true); // apiVoteType is not used for category change + UPVOTE(sf("revanced_sb_vote_upvote"), 1,false), + DOWNVOTE(sf("revanced_sb_vote_downvote"), 0, true), + CATEGORY_CHANGE(sf("revanced_sb_vote_category"), -1, true); // apiVoteType is not used for category change public static final SegmentVote[] voteTypesWithoutCategoryChange = { UPVOTE, 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 a03c0aa23d..89ed4c106e 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 @@ -103,7 +103,7 @@ public static SponsorSegment[] getSegments(@NonNull String videoId) { } catch (SocketTimeoutException ex) { handleConnectionError(str("revanced_sb_sponsorblock_connection_failure_timeout"), ex); } catch (IOException ex) { - handleConnectionError(str("sb_sponsorblock_connection_failure_generic"), ex); + handleConnectionError(str("revanced_sb_sponsorblock_connection_failure_generic"), ex); } catch (Exception ex) { // Should never happen LogHelper.printException(() -> "getSegments failure", ex); @@ -153,30 +153,30 @@ public static void submitSegments(@NonNull String videoId, @NonNull String categ final String messageToToast; switch (responseCode) { case HTTP_STATUS_CODE_SUCCESS: - messageToToast = str("sb_submit_succeeded"); + messageToToast = str("revanced_sb_submit_succeeded"); break; case 409: - messageToToast = str("sb_submit_failed_duplicate"); + messageToToast = str("revanced_sb_submit_failed_duplicate"); break; case 403: - messageToToast = str("sb_submit_failed_forbidden", Requester.parseErrorJsonAndDisconnect(connection)); + messageToToast = str("revanced_sb_submit_failed_forbidden", Requester.parseErrorJsonAndDisconnect(connection)); break; case 429: - messageToToast = str("sb_submit_failed_rate_limit"); + messageToToast = str("revanced_sb_submit_failed_rate_limit"); break; case 400: - messageToToast = str("sb_submit_failed_invalid", Requester.parseErrorJsonAndDisconnect(connection)); + messageToToast = str("revanced_sb_submit_failed_invalid", Requester.parseErrorJsonAndDisconnect(connection)); break; default: - messageToToast = str("sb_submit_failed_unknown_error", responseCode, connection.getResponseMessage()); + messageToToast = str("revanced_sb_submit_failed_unknown_error", responseCode, connection.getResponseMessage()); break; } ReVancedUtils.showToastLong(messageToToast); } catch (SocketTimeoutException ex) { // Always show, even if show connection toasts is turned off - ReVancedUtils.showToastLong(str("sb_submit_failed_timeout")); + ReVancedUtils.showToastLong(str("revanced_sb_submit_failed_timeout")); } catch (IOException ex) { - ReVancedUtils.showToastLong(str("sb_submit_failed_unknown_error", 0, ex.getMessage())); + ReVancedUtils.showToastLong(str("revanced_sb_submit_failed_unknown_error", 0, ex.getMessage())); } catch (Exception ex) { LogHelper.printException(() -> "failed to submit segments", ex); } @@ -223,17 +223,17 @@ private static void voteOrRequestCategoryChange(@NonNull SponsorSegment segment, break; case 403: ReVancedUtils.showToastLong( - str("sb_vote_failed_forbidden", Requester.parseErrorJsonAndDisconnect(connection))); + str("revanced_sb_vote_failed_forbidden", Requester.parseErrorJsonAndDisconnect(connection))); break; default: ReVancedUtils.showToastLong( - str("sb_vote_failed_unknown_error", responseCode, connection.getResponseMessage())); + str("revanced_sb_vote_failed_unknown_error", responseCode, connection.getResponseMessage())); break; } } catch (SocketTimeoutException ex) { - ReVancedUtils.showToastShort(str("sb_vote_failed_timeout")); + ReVancedUtils.showToastShort(str("revanced_sb_vote_failed_timeout")); } catch (IOException ex) { - ReVancedUtils.showToastShort(str("sb_vote_failed_unknown_error", 0, ex.getMessage())); + ReVancedUtils.showToastShort(str("revanced_sb_vote_failed_unknown_error", 0, ex.getMessage())); } catch (Exception ex) { LogHelper.printException(() -> "failed to vote for segment", ex); // should never happen } @@ -271,10 +271,10 @@ public static String setUsername(@NonNull String username) { if (responseCode == HTTP_STATUS_CODE_SUCCESS) { return null; } - return str("sb_stats_username_change_unknown_error", responseCode, responseMessage); + return str("revanced_sb_stats_username_change_unknown_error", responseCode, responseMessage); } catch (Exception ex) { // should never happen LogHelper.printInfo(() -> "failed to set username", ex); // do not toast - return str("sb_stats_username_change_unknown_error", 0, ex.getMessage()); + return str("revanced_sb_stats_username_change_unknown_error", 0, ex.getMessage()); } } diff --git a/app/src/main/java/app/revanced/integrations/sponsorblock/ui/NewSegmentLayout.java b/app/src/main/java/app/revanced/integrations/sponsorblock/ui/NewSegmentLayout.java index 3f66acacc5..12f92111c4 100644 --- a/app/src/main/java/app/revanced/integrations/sponsorblock/ui/NewSegmentLayout.java +++ b/app/src/main/java/app/revanced/integrations/sponsorblock/ui/NewSegmentLayout.java @@ -66,28 +66,28 @@ public NewSegmentLayout(final Context context, final AttributeSet attributeSet, initializeButton( context, - "sb_new_segment_adjust", + "revanced_sb_new_segment_adjust", SponsorBlockUtils::onMarkLocationClicked, "Adjust button clicked" ); initializeButton( context, - "sb_new_segment_compare", + "revanced_sb_new_segment_compare", SponsorBlockUtils::onPreviewClicked, "Compare button clicked" ); initializeButton( context, - "sb_new_segment_edit", + "revanced_sb_new_segment_edit", SponsorBlockUtils::onEditByHandClicked, "Edit button clicked" ); initializeButton( context, - "sb_new_segment_publish", + "revanced_sb_new_segment_publish", SponsorBlockUtils::onPublishClicked, "Publish button clicked" ); diff --git a/app/src/main/java/app/revanced/integrations/sponsorblock/ui/SkipSponsorButton.java b/app/src/main/java/app/revanced/integrations/sponsorblock/ui/SkipSponsorButton.java index 3b927681f6..7f0a257f1b 100644 --- a/app/src/main/java/app/revanced/integrations/sponsorblock/ui/SkipSponsorButton.java +++ b/app/src/main/java/app/revanced/integrations/sponsorblock/ui/SkipSponsorButton.java @@ -57,7 +57,7 @@ public SkipSponsorButton(Context context, AttributeSet attributeSet, int defStyl border.setColor(getResourceColor("skip_ad_button_border_color")); // color:skip_ad_button_border_color); border.setStrokeWidth(getResourceDimension("ad_skip_ad_button_border_width")); // dimen:ad_skip_ad_button_border_width); border.setStyle(Paint.Style.STROKE); - skipSponsorTextView = Objects.requireNonNull((TextView) findViewById(getResourceIdentifier(context, "sb_skip_sponsor_button_text", "id"))); // id:skip_ad_button_text; + skipSponsorTextView = Objects.requireNonNull((TextView) findViewById(getResourceIdentifier(context, "revanced_sb_skip_sponsor_button_text", "id"))); // id:skip_ad_button_text; defaultBottomMargin = getResourceDimensionPixelSize("skip_button_default_bottom_margin"); // dimen:skip_button_default_bottom_margin ctaBottomMargin = getResourceDimensionPixelSize("skip_button_cta_bottom_margin"); // dimen:skip_button_cta_bottom_margin diff --git a/app/src/main/java/app/revanced/integrations/swipecontrols/views/SwipeControlsOverlayLayout.kt b/app/src/main/java/app/revanced/integrations/swipecontrols/views/SwipeControlsOverlayLayout.kt index 9127c13051..9378b93a95 100644 --- a/app/src/main/java/app/revanced/integrations/swipecontrols/views/SwipeControlsOverlayLayout.kt +++ b/app/src/main/java/app/revanced/integrations/swipecontrols/views/SwipeControlsOverlayLayout.kt @@ -82,10 +82,10 @@ class SwipeControlsOverlayLayout( // get icons scaled, assuming square icons val iconHeight = round(feedbackTextView.lineHeight * .8).toInt() - autoBrightnessIcon = getDrawable("ic_sc_brightness_auto", iconHeight, iconHeight) - manualBrightnessIcon = getDrawable("ic_sc_brightness_manual", iconHeight, iconHeight) - mutedVolumeIcon = getDrawable("ic_sc_volume_mute", iconHeight, iconHeight) - normalVolumeIcon = getDrawable("ic_sc_volume_normal", iconHeight, iconHeight) + autoBrightnessIcon = getDrawable("revanced_ic_sc_brightness_auto", iconHeight, iconHeight) + manualBrightnessIcon = getDrawable("revanced_ic_sc_brightness_manual", iconHeight, iconHeight) + mutedVolumeIcon = getDrawable("revanced_ic_sc_volume_mute", iconHeight, iconHeight) + normalVolumeIcon = getDrawable("revanced_ic_sc_volume_normal", iconHeight, iconHeight) } private val feedbackHideHandler = Handler(Looper.getMainLooper()) diff --git a/app/src/main/java/app/revanced/integrations/videoplayer/CopyVideoUrlButton.java b/app/src/main/java/app/revanced/integrations/videoplayer/CopyVideoUrlButton.java index 90eed3615c..618c81292e 100644 --- a/app/src/main/java/app/revanced/integrations/videoplayer/CopyVideoUrlButton.java +++ b/app/src/main/java/app/revanced/integrations/videoplayer/CopyVideoUrlButton.java @@ -16,7 +16,7 @@ public class CopyVideoUrlButton extends BottomControlButton { public CopyVideoUrlButton(ViewGroup viewGroup) { super( viewGroup, - "copy_video_url_button", + "revanced_copy_video_url_button", SettingsEnum.COPY_VIDEO_URL, view -> CopyVideoUrlPatch.copyUrl(false), view -> { diff --git a/app/src/main/java/app/revanced/integrations/videoplayer/CopyVideoUrlTimestampButton.java b/app/src/main/java/app/revanced/integrations/videoplayer/CopyVideoUrlTimestampButton.java index a3d290ad7f..53c30ff476 100644 --- a/app/src/main/java/app/revanced/integrations/videoplayer/CopyVideoUrlTimestampButton.java +++ b/app/src/main/java/app/revanced/integrations/videoplayer/CopyVideoUrlTimestampButton.java @@ -16,7 +16,7 @@ public class CopyVideoUrlTimestampButton extends BottomControlButton { public CopyVideoUrlTimestampButton(ViewGroup bottomControlsViewGroup) { super( bottomControlsViewGroup, - "copy_video_url_timestamp_button", + "revanced_copy_video_url_timestamp_button", SettingsEnum.COPY_VIDEO_URL_TIMESTAMP, view -> CopyVideoUrlPatch.copyUrl(true), view -> { diff --git a/app/src/main/java/app/revanced/integrations/videoplayer/ExternalDownloadButton.java b/app/src/main/java/app/revanced/integrations/videoplayer/ExternalDownloadButton.java index e62a323360..cbebedfed3 100644 --- a/app/src/main/java/app/revanced/integrations/videoplayer/ExternalDownloadButton.java +++ b/app/src/main/java/app/revanced/integrations/videoplayer/ExternalDownloadButton.java @@ -20,7 +20,7 @@ public class ExternalDownloadButton extends BottomControlButton { public ExternalDownloadButton(ViewGroup viewGroup) { super( viewGroup, - "external_download_button", + "revanced_external_download_button", SettingsEnum.EXTERNAL_DOWNLOADER, ExternalDownloadButton::onDownloadClick, null From fdf3323a6f7592f424abdd4d0ed311df5888458d Mon Sep 17 00:00:00 2001 From: LisoUseInAIKyrios <118716522+LisoUseInAIKyrios@users.noreply.github.com> Date: Fri, 16 Jun 2023 23:19:54 +0400 Subject: [PATCH 22/48] fixing RTL languages --- .../integrations/videoplayer/ExternalDownloadButton.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/app/revanced/integrations/videoplayer/ExternalDownloadButton.java b/app/src/main/java/app/revanced/integrations/videoplayer/ExternalDownloadButton.java index cbebedfed3..126b046710 100644 --- a/app/src/main/java/app/revanced/integrations/videoplayer/ExternalDownloadButton.java +++ b/app/src/main/java/app/revanced/integrations/videoplayer/ExternalDownloadButton.java @@ -60,7 +60,7 @@ private static void onDownloadClick(View view) { // If the package is not installed, show the toast if (!packageEnabled) { - ReVancedUtils.showToastLong(downloaderPackageName + " " + StringRef.str("revanced_external_downloader_not_installed_warning")); + ReVancedUtils.showToastLong(StringRef.str("revanced_external_downloader_not_installed_warning", downloaderPackageName)); return; } From 137cce4c7bd8308bc18e7874912fe35805248ab4 Mon Sep 17 00:00:00 2001 From: LisoUseInAIKyrios <118716522+LisoUseInAIKyrios@users.noreply.github.com> Date: Sun, 18 Jun 2023 22:13:52 +0400 Subject: [PATCH 23/48] comments --- .../app/revanced/integrations/settingsmenu/SettingsUtils.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/app/revanced/integrations/settingsmenu/SettingsUtils.java b/app/src/main/java/app/revanced/integrations/settingsmenu/SettingsUtils.java index 2610f487f6..1d41246661 100644 --- a/app/src/main/java/app/revanced/integrations/settingsmenu/SettingsUtils.java +++ b/app/src/main/java/app/revanced/integrations/settingsmenu/SettingsUtils.java @@ -24,7 +24,8 @@ public class SettingsUtils { * Android Preferences are automatically sorted by title, * but if using a localized string key it sorts on the key and not the actual title text that's used at runtime. * - * @param menuDepthToSort Maximum menu depth to sort. Menus deep than this value will show it's preferences in the order created in patches. + * @param menuDepthToSort Maximum menu depth to sort. Menus deeper than this value + * will show preferences in the order created in patches. */ public static void sortPreferenceGroupByTitle(PreferenceGroup group, int menuDepthToSort) { if (menuDepthToSort == 0) return; From 64b996f83db943533a5ad7fb85f2242dd25e1c1e Mon Sep 17 00:00:00 2001 From: LisoUseInAIKyrios <118716522+LisoUseInAIKyrios@users.noreply.github.com> Date: Wed, 21 Jun 2023 00:21:55 +0400 Subject: [PATCH 24/48] fixing prefix that should not be renamed --- .../integrations/sponsorblock/objects/SegmentCategory.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/app/revanced/integrations/sponsorblock/objects/SegmentCategory.java b/app/src/main/java/app/revanced/integrations/sponsorblock/objects/SegmentCategory.java index 49e69dec6c..2d9639ee05 100644 --- a/app/src/main/java/app/revanced/integrations/sponsorblock/objects/SegmentCategory.java +++ b/app/src/main/java/app/revanced/integrations/sponsorblock/objects/SegmentCategory.java @@ -64,8 +64,9 @@ public enum SegmentCategory { /** * Prefix to use when serializing to flat JSON layout used with ReVanced import/export. + * Should match the naming scheme as SB settings in {@link SettingsEnum}. */ - private static final String FLAT_JSON_IMPORT_EXPORT_PREFIX = "revanced_sb_"; + private static final String FLAT_JSON_IMPORT_EXPORT_PREFIX = "sb_"; private static final SegmentCategory[] categoriesWithoutHighlights = new SegmentCategory[]{ SPONSOR, From 3bc09b4c28ae27f1b557871dbcc7324acdbdf379 Mon Sep 17 00:00:00 2001 From: LisoUseInAIKyrios <118716522+LisoUseInAIKyrios@users.noreply.github.com> Date: Wed, 21 Jun 2023 00:23:25 +0400 Subject: [PATCH 25/48] comments --- .../integrations/sponsorblock/objects/SegmentCategory.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/app/revanced/integrations/sponsorblock/objects/SegmentCategory.java b/app/src/main/java/app/revanced/integrations/sponsorblock/objects/SegmentCategory.java index 2d9639ee05..ff39d63185 100644 --- a/app/src/main/java/app/revanced/integrations/sponsorblock/objects/SegmentCategory.java +++ b/app/src/main/java/app/revanced/integrations/sponsorblock/objects/SegmentCategory.java @@ -64,7 +64,7 @@ public enum SegmentCategory { /** * Prefix to use when serializing to flat JSON layout used with ReVanced import/export. - * Should match the naming scheme as SB settings in {@link SettingsEnum}. + * Should match the naming scheme of SB settings in {@link SettingsEnum}. */ private static final String FLAT_JSON_IMPORT_EXPORT_PREFIX = "sb_"; From cd205a5e5a0a854032e539054195baf7d999e919 Mon Sep 17 00:00:00 2001 From: LisoUseInAIKyrios <118716522+LisoUseInAIKyrios@users.noreply.github.com> Date: Thu, 22 Jun 2023 20:24:55 +0400 Subject: [PATCH 26/48] Removing dead code. Cannot change quality if no internet connection exists. --- .../playback/quality/RememberVideoQualityPatch.java | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/app/src/main/java/app/revanced/integrations/patches/playback/quality/RememberVideoQualityPatch.java b/app/src/main/java/app/revanced/integrations/patches/playback/quality/RememberVideoQualityPatch.java index d1ef08eb5a..e16591c4c8 100644 --- a/app/src/main/java/app/revanced/integrations/patches/playback/quality/RememberVideoQualityPatch.java +++ b/app/src/main/java/app/revanced/integrations/patches/playback/quality/RememberVideoQualityPatch.java @@ -38,13 +38,8 @@ public class RememberVideoQualityPatch { private static List videoQualities; private static void changeDefaultQuality(int defaultQuality) { - NetworkType networkType = ReVancedUtils.getNetworkType(); - if (networkType == NetworkType.NONE) { - ReVancedUtils.showToastShort("No internet connection"); - return; - } String networkTypeMessage; - if (networkType == NetworkType.MOBILE) { + if (ReVancedUtils.getNetworkType() == NetworkType.MOBILE) { mobileQualitySetting.saveValue(defaultQuality); networkTypeMessage = "mobile"; } else { From 742ebb8203d65daf13f9b2a0784cb36f2a7ea9c8 Mon Sep 17 00:00:00 2001 From: LisoUseInAIKyrios <118716522+LisoUseInAIKyrios@users.noreply.github.com> Date: Thu, 22 Jun 2023 20:56:29 +0400 Subject: [PATCH 27/48] Adding last untranslated strings. Verified that all YouTube strings are now extracted to Strings.xml. --- .../patches/SpoofSignatureVerificationPatch.java | 8 +++++--- .../playback/quality/RememberVideoQualityPatch.java | 9 +++++---- .../patches/playback/speed/CustomVideoSpeedPatch.java | 4 +++- .../playback/speed/RememberPlaybackSpeedPatch.java | 4 +++- .../integrations/patches/theme/SeekbarColorPatch.java | 4 +++- 5 files changed, 19 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/app/revanced/integrations/patches/SpoofSignatureVerificationPatch.java b/app/src/main/java/app/revanced/integrations/patches/SpoofSignatureVerificationPatch.java index 9edd455fac..a6293b3fd0 100644 --- a/app/src/main/java/app/revanced/integrations/patches/SpoofSignatureVerificationPatch.java +++ b/app/src/main/java/app/revanced/integrations/patches/SpoofSignatureVerificationPatch.java @@ -1,14 +1,16 @@ package app.revanced.integrations.patches; +import static app.revanced.integrations.utils.ReVancedUtils.containsAny; +import static app.revanced.integrations.utils.StringRef.str; + import androidx.annotation.NonNull; import androidx.annotation.Nullable; + import app.revanced.integrations.settings.SettingsEnum; import app.revanced.integrations.shared.PlayerType; import app.revanced.integrations.utils.LogHelper; import app.revanced.integrations.utils.ReVancedUtils; -import static app.revanced.integrations.utils.ReVancedUtils.containsAny; - public class SpoofSignatureVerificationPatch { /** * Enable/disable all workarounds that are required due to signature spoofing. @@ -113,7 +115,7 @@ public static void onResponse(int responseCode) { } SettingsEnum.SPOOF_SIGNATURE_VERIFICATION.saveValue(true); - ReVancedUtils.showToastLong("Spoofing app signature to prevent playback issues"); + ReVancedUtils.showToastLong(str("revanced_spoof_signature_verification_toast")); // it would be great if the video could be forcefully reloaded, but currently there is no code to do this } catch (Exception ex) { diff --git a/app/src/main/java/app/revanced/integrations/patches/playback/quality/RememberVideoQualityPatch.java b/app/src/main/java/app/revanced/integrations/patches/playback/quality/RememberVideoQualityPatch.java index e16591c4c8..2ed81f94be 100644 --- a/app/src/main/java/app/revanced/integrations/patches/playback/quality/RememberVideoQualityPatch.java +++ b/app/src/main/java/app/revanced/integrations/patches/playback/quality/RememberVideoQualityPatch.java @@ -1,6 +1,7 @@ package app.revanced.integrations.patches.playback.quality; import static app.revanced.integrations.utils.ReVancedUtils.NetworkType; +import static app.revanced.integrations.utils.StringRef.str; import androidx.annotation.Nullable; @@ -41,13 +42,13 @@ private static void changeDefaultQuality(int defaultQuality) { String networkTypeMessage; if (ReVancedUtils.getNetworkType() == NetworkType.MOBILE) { mobileQualitySetting.saveValue(defaultQuality); - networkTypeMessage = "mobile"; + networkTypeMessage = str("revanced_remember_video_quality_mobile"); } else { wifiQualitySetting.saveValue(defaultQuality); - networkTypeMessage = "Wi-Fi"; + networkTypeMessage = str("revanced_remember_video_quality_wifi"); } - ReVancedUtils.showToastShort("Changed default " + networkTypeMessage - + " quality to: " + defaultQuality +"p"); + ReVancedUtils.showToastShort( + str("revanced_remember_video_quality_toast", networkTypeMessage, (defaultQuality + "p"))); } /** diff --git a/app/src/main/java/app/revanced/integrations/patches/playback/speed/CustomVideoSpeedPatch.java b/app/src/main/java/app/revanced/integrations/patches/playback/speed/CustomVideoSpeedPatch.java index df80c1f547..33fa061d83 100644 --- a/app/src/main/java/app/revanced/integrations/patches/playback/speed/CustomVideoSpeedPatch.java +++ b/app/src/main/java/app/revanced/integrations/patches/playback/speed/CustomVideoSpeedPatch.java @@ -1,5 +1,7 @@ package app.revanced.integrations.patches.playback.speed; +import static app.revanced.integrations.utils.StringRef.str; + import android.preference.ListPreference; import androidx.annotation.NonNull; @@ -70,7 +72,7 @@ private static void loadSpeeds() { } } catch (Exception ex) { LogHelper.printInfo(() -> "parse error", ex); - resetCustomSpeeds("Invalid custom video speeds. Using default values."); + resetCustomSpeeds(str("revanced_custom_playback_speeds_invalid")); loadSpeeds(); } } diff --git a/app/src/main/java/app/revanced/integrations/patches/playback/speed/RememberPlaybackSpeedPatch.java b/app/src/main/java/app/revanced/integrations/patches/playback/speed/RememberPlaybackSpeedPatch.java index f557f1a630..44779e8b97 100644 --- a/app/src/main/java/app/revanced/integrations/patches/playback/speed/RememberPlaybackSpeedPatch.java +++ b/app/src/main/java/app/revanced/integrations/patches/playback/speed/RememberPlaybackSpeedPatch.java @@ -1,5 +1,7 @@ package app.revanced.integrations.patches.playback.speed; +import static app.revanced.integrations.utils.StringRef.str; + import app.revanced.integrations.patches.VideoInformation; import app.revanced.integrations.settings.SettingsEnum; import app.revanced.integrations.utils.LogHelper; @@ -24,7 +26,7 @@ public static void newVideoStarted(Object ignoredPlayerController) { public static void userSelectedPlaybackSpeed(float playbackSpeed) { if (SettingsEnum.REMEMBER_PLAYBACK_SPEED_LAST_SELECTED.getBoolean()) { SettingsEnum.PLAYBACK_SPEED_DEFAULT.saveValue(playbackSpeed); - ReVancedUtils.showToastLong("Changed default speed to: " + playbackSpeed + "x"); + ReVancedUtils.showToastLong(str("revanced_remember_playback_speed_toast", (playbackSpeed + "x"))); } } diff --git a/app/src/main/java/app/revanced/integrations/patches/theme/SeekbarColorPatch.java b/app/src/main/java/app/revanced/integrations/patches/theme/SeekbarColorPatch.java index efedb5f4a2..2119f37853 100644 --- a/app/src/main/java/app/revanced/integrations/patches/theme/SeekbarColorPatch.java +++ b/app/src/main/java/app/revanced/integrations/patches/theme/SeekbarColorPatch.java @@ -1,5 +1,7 @@ package app.revanced.integrations.patches.theme; +import static app.revanced.integrations.utils.StringRef.str; + import android.graphics.Color; import app.revanced.integrations.settings.SettingsEnum; @@ -41,7 +43,7 @@ private static void loadCustomSeekbarColorHSV() { customSeekbarColor = Color.parseColor(SettingsEnum.SEEKBAR_COLOR.getString()); Color.colorToHSV(customSeekbarColor, customSeekbarColorHSV); } catch (Exception ex) { - ReVancedUtils.showToastShort("Invalid seekbar color value. Using default value."); + ReVancedUtils.showToastShort(str("revanced_seekbar_color_invalid")); SettingsEnum.SEEKBAR_COLOR.saveValue(SettingsEnum.SEEKBAR_COLOR.defaultValue); loadCustomSeekbarColorHSV(); } From a79cf45296904720ef659d9a2661f49521a47885 Mon Sep 17 00:00:00 2001 From: LisoUseInAIKyrios <118716522+LisoUseInAIKyrios@users.noreply.github.com> Date: Wed, 28 Jun 2023 23:59:38 +0400 Subject: [PATCH 28/48] this should be the last non-localized string --- .../patches/playback/speed/CustomVideoSpeedPatch.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/app/revanced/integrations/patches/playback/speed/CustomVideoSpeedPatch.java b/app/src/main/java/app/revanced/integrations/patches/playback/speed/CustomVideoSpeedPatch.java index 33fa061d83..642cdb6cb1 100644 --- a/app/src/main/java/app/revanced/integrations/patches/playback/speed/CustomVideoSpeedPatch.java +++ b/app/src/main/java/app/revanced/integrations/patches/playback/speed/CustomVideoSpeedPatch.java @@ -61,8 +61,7 @@ private static void loadSpeeds() { throw new IllegalArgumentException(); } if (speed >= MAXIMUM_PLAYBACK_SPEED) { - resetCustomSpeeds("Custom speeds must be less than " + MAXIMUM_PLAYBACK_SPEED - + ". Using default values."); + resetCustomSpeeds(str("revanced_custom_playback_speeds_invalid", MAXIMUM_PLAYBACK_SPEED)); loadSpeeds(); return; } @@ -72,7 +71,7 @@ private static void loadSpeeds() { } } catch (Exception ex) { LogHelper.printInfo(() -> "parse error", ex); - resetCustomSpeeds(str("revanced_custom_playback_speeds_invalid")); + resetCustomSpeeds(str("revanced_custom_playback_speeds_parse_exception")); loadSpeeds(); } } From d31af2f78ec4ba737f384ba9f71bc711b2cb3d0a Mon Sep 17 00:00:00 2001 From: LisoUseInAIKyrios <118716522+LisoUseInAIKyrios@users.noreply.github.com> Date: Thu, 20 Jul 2023 22:54:24 +0400 Subject: [PATCH 29/48] finishing merge --- .../revanced/integrations/patches/theme/SeekbarColorPatch.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/app/revanced/integrations/patches/theme/SeekbarColorPatch.java b/app/src/main/java/app/revanced/integrations/patches/theme/SeekbarColorPatch.java index 7190c6cb83..90fab4aaff 100644 --- a/app/src/main/java/app/revanced/integrations/patches/theme/SeekbarColorPatch.java +++ b/app/src/main/java/app/revanced/integrations/patches/theme/SeekbarColorPatch.java @@ -49,7 +49,7 @@ private static void loadCustomSeekbarColor() { seekbarColor = Color.parseColor(SettingsEnum.SEEKBAR_CUSTOM_COLOR_VALUE.getString()); Color.colorToHSV(seekbarColor, customSeekbarColorHSV); } catch (Exception ex) { - ReVancedUtils.showToastShort(str("revanced_seekbar_color_invalid")); + ReVancedUtils.showToastShort(str("revanced_seekbar_custom_color_invalid")); SettingsEnum.SEEKBAR_CUSTOM_COLOR_VALUE.saveValue(SettingsEnum.SEEKBAR_CUSTOM_COLOR_VALUE.defaultValue); loadCustomSeekbarColor(); } From c1f9e92125b6794a4eabba43a1a679e788703a19 Mon Sep 17 00:00:00 2001 From: LisoUseInAIKyrios <118716522+LisoUseInAIKyrios@users.noreply.github.com> Date: Mon, 18 Sep 2023 17:56:15 +0400 Subject: [PATCH 30/48] extract string --- .../integrations/patches/CustomPlayerOverlayOpacityPatch.java | 4 +++- .../integrations/sponsorblock/SponsorBlockSettings.java | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/app/revanced/integrations/patches/CustomPlayerOverlayOpacityPatch.java b/app/src/main/java/app/revanced/integrations/patches/CustomPlayerOverlayOpacityPatch.java index a2b4a94c52..2dc2d2730e 100644 --- a/app/src/main/java/app/revanced/integrations/patches/CustomPlayerOverlayOpacityPatch.java +++ b/app/src/main/java/app/revanced/integrations/patches/CustomPlayerOverlayOpacityPatch.java @@ -1,5 +1,7 @@ package app.revanced.integrations.patches; +import static app.revanced.integrations.utils.StringRef.str; + import android.widget.ImageView; import app.revanced.integrations.settings.SettingsEnum; @@ -12,7 +14,7 @@ public static void changeOpacity(ImageView imageView) { int opacity = SettingsEnum.PLAYER_OVERLAY_OPACITY.getInt(); if (opacity < 0 || opacity > 100) { - ReVancedUtils.showToastLong("Player overlay opacity must be between 0-100"); + ReVancedUtils.showToastLong(str("revanced_player_overlay_opacity_parse_error")); SettingsEnum.PLAYER_OVERLAY_OPACITY.saveValue(DEFAULT_OPACITY); opacity = DEFAULT_OPACITY; } 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 597f09b1e5..d0cba62a19 100644 --- a/app/src/main/java/app/revanced/integrations/sponsorblock/SponsorBlockSettings.java +++ b/app/src/main/java/app/revanced/integrations/sponsorblock/SponsorBlockSettings.java @@ -57,6 +57,7 @@ public static void importSettings(@NonNull String json) { final int desktopKey = categorySelectionObject.getInt("option"); CategoryBehaviour behaviour = CategoryBehaviour.byDesktopKey(desktopKey); if (behaviour == null) { + // String is not worth localizing, as this should never happen. ReVancedUtils.showToastLong(categoryKey + " unknown behavior key: " + desktopKey); } else if (category == SegmentCategory.HIGHLIGHT && behaviour == CategoryBehaviour.SKIP_AUTOMATICALLY_ONCE) { ReVancedUtils.showToastLong("Skip-once behavior not allowed for " + category.key); From d82f418b24df7c8289850117332c9a36e508b3e8 Mon Sep 17 00:00:00 2001 From: LisoUseInAIKyrios <118716522+LisoUseInAIKyrios@users.noreply.github.com> Date: Sat, 14 Oct 2023 13:56:07 +0300 Subject: [PATCH 31/48] Since strings are localized,sorting is now done at runtime. --- .../integrations/settingsmenu/SettingsUtils.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/app/revanced/integrations/settingsmenu/SettingsUtils.java b/app/src/main/java/app/revanced/integrations/settingsmenu/SettingsUtils.java index 1d41246661..72e81e9968 100644 --- a/app/src/main/java/app/revanced/integrations/settingsmenu/SettingsUtils.java +++ b/app/src/main/java/app/revanced/integrations/settingsmenu/SettingsUtils.java @@ -6,6 +6,8 @@ import java.util.SortedMap; import java.util.TreeMap; +import kotlin.text.Regex; + /** * Class is used across multiple target apps. * @@ -18,6 +20,8 @@ */ public class SettingsUtils { + private static final Regex punctuationRegex = new Regex("\\p{P}+"); + /** * Sort the preferences by title and ignore the casing. * @@ -36,7 +40,7 @@ public static void sortPreferenceGroupByTitle(PreferenceGroup group, int menuDep if (preference instanceof PreferenceGroup) { sortPreferenceGroupByTitle((PreferenceGroup) preference, menuDepthToSort - 1); } - preferences.put(preference.getTitle().toString().toLowerCase(), preference); + preferences.put(removePunctuationConvertToLowercase(preference.getTitle()), preference); } int prefIndex = 0; @@ -45,4 +49,8 @@ public static void sortPreferenceGroupByTitle(PreferenceGroup group, int menuDep } } + private static String removePunctuationConvertToLowercase(CharSequence original) { + return punctuationRegex.replace(original, "").toLowerCase(); + } + } From cdfd8e632929e4d4c5aa8a1918328cdb9b785a86 Mon Sep 17 00:00:00 2001 From: LisoUseInAIKyrios <118716522+LisoUseInAIKyrios@users.noreply.github.com> Date: Sun, 15 Oct 2023 01:46:54 +0300 Subject: [PATCH 32/48] No functional changes: renamed Utils classes. --- .../patches/AlternativeThumbnailsPatch.java | 4 +-- .../patches/CopyVideoUrlPatch.java | 6 ++-- .../CustomPlayerOverlayOpacityPatch.java | 4 +-- .../patches/HideAlbumCardsPatch.java | 4 +-- .../patches/HideBreakingNewsPatch.java | 4 +-- .../patches/HideCrowdfundingBoxPatch.java | 4 +-- .../patches/HideFilterBarPatch.java | 4 +-- .../patches/HideLoadMoreButtonPatch.java | 4 +-- .../integrations/patches/MicroGSupport.java | 6 ++-- .../patches/ReturnYouTubeDislikePatch.java | 8 ++--- .../patches/VideoInformation.java | 4 +-- .../patches/components/AdsFilter.java | 4 +-- .../patches/components/ShortsFilter.java | 4 +-- .../quality/RememberVideoQualityPatch.java | 10 +++--- .../speed/CustomPlaybackSpeedPatch.java | 4 +-- .../speed/RememberPlaybackSpeedPatch.java | 4 +-- .../patches/spoof/SpoofSignaturePatch.java | 6 ++-- .../requests/StoryboardRendererRequester.java | 4 +-- .../patches/theme/SeekbarColorPatch.java | 4 +-- .../patches/theme/ThemePatch.java | 6 ++-- .../ReturnYouTubeDislike.java | 16 ++++----- .../requests/ReturnYouTubeDislikeApi.java | 18 +++++----- .../integrations/settings/SettingsEnum.java | 6 ++-- .../settings/SharedPrefCategory.java | 4 +-- .../settingsmenu/ImportExportPreference.java | 4 +-- .../SponsorBlockSettingsFragment.java | 30 ++++++++-------- .../settingsmenu/YouTubeSettingActivity.java | 4 +-- .../settingsmenu/YouTubeSettingsFragment.java | 4 +-- .../PlayerControlsVisibilityObserver.kt | 6 ++-- .../SegmentPlaybackController.java | 22 ++++++------ .../sponsorblock/SponsorBlockSettings.java | 20 +++++------ .../sponsorblock/SponsorBlockUtils.java | 36 +++++++++---------- .../objects/CategoryBehaviour.java | 4 +-- .../SegmentCategoryListPreference.java | 8 ++--- .../sponsorblock/requests/SBRequester.java | 32 ++++++++--------- .../ui/CreateSegmentButtonController.java | 6 ++-- .../sponsorblock/ui/NewSegmentLayout.java | 4 +-- .../sponsorblock/ui/SkipSponsorButton.java | 8 ++--- .../ui/SponsorBlockViewController.java | 6 ++-- .../ui/VotingButtonController.java | 6 ++-- .../controller/SwipeZonesController.kt | 4 +-- .../views/SwipeControlsOverlayLayout.kt | 4 +-- .../integrations/utils/LogHelper.java | 2 +- .../integrations/utils/StringRef.java | 2 +- .../integrations/utils/ThemeHelper.java | 2 +- .../utils/{ReVancedUtils.java => Utils.java} | 4 +-- .../videoplayer/BottomControlButton.java | 12 +++---- .../videoplayer/ExternalDownloadButton.java | 4 +-- .../tiktok/feedfilter/LikeCountFilter.java | 4 +-- .../tiktok/feedfilter/ViewCountFilter.java | 2 +- .../tiktok/settings/SettingsEnum.java | 6 ++-- .../settingsmenu/TikTokSettingsFragment.java | 4 +-- .../settingsmenu/TikTokSettingsMenu.java | 4 +-- .../utils/{TikTokUtils.java => Utils.java} | 4 +-- .../twitch/adblock/LuminousService.java | 4 +-- .../twitch/adblock/PurpleAdblockService.java | 4 +-- .../twitch/api/RequestInterceptor.java | 12 +++---- .../patches/ShowDeletedMessagesPatch.java | 4 +-- .../twitch/settings/SettingsEnum.java | 6 ++-- .../settingsmenu/TwitchSettingsFragment.java | 10 +++--- .../settingsmenu/TwitchSettingsHooks.java | 8 ++--- .../app/revanced/twitch/utils/LogHelper.java | 2 +- .../utils/{TwitchUtils.java => Utils.java} | 2 +- 63 files changed, 226 insertions(+), 226 deletions(-) rename app/src/main/java/app/revanced/integrations/utils/{ReVancedUtils.java => Utils.java} (99%) rename app/src/main/java/app/revanced/tiktok/utils/{TikTokUtils.java => Utils.java} (91%) rename app/src/main/java/app/revanced/twitch/utils/{TwitchUtils.java => Utils.java} (99%) diff --git a/app/src/main/java/app/revanced/integrations/patches/AlternativeThumbnailsPatch.java b/app/src/main/java/app/revanced/integrations/patches/AlternativeThumbnailsPatch.java index 1e4d3f0500..7248170457 100644 --- a/app/src/main/java/app/revanced/integrations/patches/AlternativeThumbnailsPatch.java +++ b/app/src/main/java/app/revanced/integrations/patches/AlternativeThumbnailsPatch.java @@ -15,7 +15,7 @@ import app.revanced.integrations.settings.SettingsEnum; import app.revanced.integrations.utils.LogHelper; -import app.revanced.integrations.utils.ReVancedUtils; +import app.revanced.integrations.utils.Utils; /** * Alternative YouTube thumbnails, showing the beginning/middle/end of the video. @@ -236,7 +236,7 @@ synchronized boolean verifyYouTubeThumbnailExists(@NonNull String videoId, @NonN // This hooked code is running on a low priority thread, and it's slightly faster // to run the url connection thru the integrations thread pool which runs at the highest priority. final long start = System.currentTimeMillis(); - imageFileFound = ReVancedUtils.submitOnBackgroundThread(() -> { + imageFileFound = Utils.submitOnBackgroundThread(() -> { final int connectionTimeoutMillis = 5000; HttpURLConnection connection = (HttpURLConnection) new URL(imageUrl).openConnection(); connection.setConnectTimeout(connectionTimeoutMillis); diff --git a/app/src/main/java/app/revanced/integrations/patches/CopyVideoUrlPatch.java b/app/src/main/java/app/revanced/integrations/patches/CopyVideoUrlPatch.java index f21e488918..6a27fce59c 100644 --- a/app/src/main/java/app/revanced/integrations/patches/CopyVideoUrlPatch.java +++ b/app/src/main/java/app/revanced/integrations/patches/CopyVideoUrlPatch.java @@ -5,7 +5,7 @@ import android.os.Build; import app.revanced.integrations.utils.LogHelper; -import app.revanced.integrations.utils.ReVancedUtils; +import app.revanced.integrations.utils.Utils; public class CopyVideoUrlPatch { @@ -30,12 +30,12 @@ public static void copyUrl(boolean withTimestamp) { } } - ReVancedUtils.setClipboard(builder.toString()); + Utils.setClipboard(builder.toString()); // Do not show a toast if using Android 13+ as it shows it's own toast. // But if the user copied with a timestamp then show a toast. // Unfortunately this will show 2 toasts on Android 13+, but no way around this. if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.S_V2 || (withTimestamp && currentVideoTimeInSeconds > 0)) { - ReVancedUtils.showToastShort(withTimestamp && currentVideoTimeInSeconds > 0 + Utils.showToastShort(withTimestamp && currentVideoTimeInSeconds > 0 ? str("revanced_share_copy_url_timestamp_success") : str("revanced_share_copy_url_success")); } diff --git a/app/src/main/java/app/revanced/integrations/patches/CustomPlayerOverlayOpacityPatch.java b/app/src/main/java/app/revanced/integrations/patches/CustomPlayerOverlayOpacityPatch.java index 2dc2d2730e..3ef54126e8 100644 --- a/app/src/main/java/app/revanced/integrations/patches/CustomPlayerOverlayOpacityPatch.java +++ b/app/src/main/java/app/revanced/integrations/patches/CustomPlayerOverlayOpacityPatch.java @@ -5,7 +5,7 @@ import android.widget.ImageView; import app.revanced.integrations.settings.SettingsEnum; -import app.revanced.integrations.utils.ReVancedUtils; +import app.revanced.integrations.utils.Utils; public class CustomPlayerOverlayOpacityPatch { private static final int DEFAULT_OPACITY = (int) SettingsEnum.PLAYER_OVERLAY_OPACITY.defaultValue; @@ -14,7 +14,7 @@ public static void changeOpacity(ImageView imageView) { int opacity = SettingsEnum.PLAYER_OVERLAY_OPACITY.getInt(); if (opacity < 0 || opacity > 100) { - ReVancedUtils.showToastLong(str("revanced_player_overlay_opacity_parse_error")); + Utils.showToastLong(str("revanced_player_overlay_opacity_parse_error")); SettingsEnum.PLAYER_OVERLAY_OPACITY.saveValue(DEFAULT_OPACITY); opacity = DEFAULT_OPACITY; } diff --git a/app/src/main/java/app/revanced/integrations/patches/HideAlbumCardsPatch.java b/app/src/main/java/app/revanced/integrations/patches/HideAlbumCardsPatch.java index b0f42e8985..3cb4c486e0 100644 --- a/app/src/main/java/app/revanced/integrations/patches/HideAlbumCardsPatch.java +++ b/app/src/main/java/app/revanced/integrations/patches/HideAlbumCardsPatch.java @@ -3,11 +3,11 @@ import android.view.View; import app.revanced.integrations.settings.SettingsEnum; -import app.revanced.integrations.utils.ReVancedUtils; +import app.revanced.integrations.utils.Utils; public class HideAlbumCardsPatch { public static void hideAlbumCard(View view) { if (!SettingsEnum.HIDE_ALBUM_CARDS.getBoolean()) return; - ReVancedUtils.hideViewByLayoutParams(view); + Utils.hideViewByLayoutParams(view); } } \ No newline at end of file diff --git a/app/src/main/java/app/revanced/integrations/patches/HideBreakingNewsPatch.java b/app/src/main/java/app/revanced/integrations/patches/HideBreakingNewsPatch.java index 465c28367d..229ef540bc 100644 --- a/app/src/main/java/app/revanced/integrations/patches/HideBreakingNewsPatch.java +++ b/app/src/main/java/app/revanced/integrations/patches/HideBreakingNewsPatch.java @@ -3,7 +3,7 @@ import android.view.View; import app.revanced.integrations.settings.SettingsEnum; -import app.revanced.integrations.utils.ReVancedUtils; +import app.revanced.integrations.utils.Utils; public class HideBreakingNewsPatch { @@ -24,6 +24,6 @@ private static boolean isSpoofingOldVersionWithHorizontalCardListWatchHistory() public static void hideBreakingNews(View view) { if (!SettingsEnum.HIDE_BREAKING_NEWS.getBoolean() || isSpoofingOldVersionWithHorizontalCardListWatchHistory()) return; - ReVancedUtils.hideViewByLayoutParams(view); + Utils.hideViewByLayoutParams(view); } } diff --git a/app/src/main/java/app/revanced/integrations/patches/HideCrowdfundingBoxPatch.java b/app/src/main/java/app/revanced/integrations/patches/HideCrowdfundingBoxPatch.java index c8b8733976..99f3dd88bd 100644 --- a/app/src/main/java/app/revanced/integrations/patches/HideCrowdfundingBoxPatch.java +++ b/app/src/main/java/app/revanced/integrations/patches/HideCrowdfundingBoxPatch.java @@ -3,12 +3,12 @@ import android.view.View; import app.revanced.integrations.settings.SettingsEnum; -import app.revanced.integrations.utils.ReVancedUtils; +import app.revanced.integrations.utils.Utils; public class HideCrowdfundingBoxPatch { //Used by app.revanced.patches.youtube.layout.hidecrowdfundingbox.patch.HideCrowdfundingBoxPatch public static void hideCrowdfundingBox(View view) { if (!SettingsEnum.HIDE_CROWDFUNDING_BOX.getBoolean()) return; - ReVancedUtils.hideViewByLayoutParams(view); + Utils.hideViewByLayoutParams(view); } } diff --git a/app/src/main/java/app/revanced/integrations/patches/HideFilterBarPatch.java b/app/src/main/java/app/revanced/integrations/patches/HideFilterBarPatch.java index 24d117dcc3..e1c3fb8e3e 100644 --- a/app/src/main/java/app/revanced/integrations/patches/HideFilterBarPatch.java +++ b/app/src/main/java/app/revanced/integrations/patches/HideFilterBarPatch.java @@ -2,7 +2,7 @@ import android.view.View; import app.revanced.integrations.settings.SettingsEnum; -import app.revanced.integrations.utils.ReVancedUtils; +import app.revanced.integrations.utils.Utils; public final class HideFilterBarPatch { public static int hideInFeed(final int height) { @@ -14,7 +14,7 @@ public static int hideInFeed(final int height) { public static void hideInRelatedVideos(final View chipView) { if (!SettingsEnum.HIDE_FILTER_BAR_FEED_IN_RELATED_VIDEOS.getBoolean()) return; - ReVancedUtils.hideViewByLayoutParams(chipView); + Utils.hideViewByLayoutParams(chipView); } public static int hideInSearch(final int height) { diff --git a/app/src/main/java/app/revanced/integrations/patches/HideLoadMoreButtonPatch.java b/app/src/main/java/app/revanced/integrations/patches/HideLoadMoreButtonPatch.java index ab77cf2a0d..37ba735676 100644 --- a/app/src/main/java/app/revanced/integrations/patches/HideLoadMoreButtonPatch.java +++ b/app/src/main/java/app/revanced/integrations/patches/HideLoadMoreButtonPatch.java @@ -3,11 +3,11 @@ import android.view.View; import app.revanced.integrations.settings.SettingsEnum; -import app.revanced.integrations.utils.ReVancedUtils; +import app.revanced.integrations.utils.Utils; public class HideLoadMoreButtonPatch { public static void hideLoadMoreButton(View view){ if(!SettingsEnum.HIDE_LOAD_MORE_BUTTON.getBoolean()) return; - ReVancedUtils.hideViewByLayoutParams(view); + Utils.hideViewByLayoutParams(view); } } diff --git a/app/src/main/java/app/revanced/integrations/patches/MicroGSupport.java b/app/src/main/java/app/revanced/integrations/patches/MicroGSupport.java index 7d12346d9c..f779665445 100644 --- a/app/src/main/java/app/revanced/integrations/patches/MicroGSupport.java +++ b/app/src/main/java/app/revanced/integrations/patches/MicroGSupport.java @@ -11,7 +11,7 @@ import java.util.Objects; import app.revanced.integrations.utils.LogHelper; -import app.revanced.integrations.utils.ReVancedUtils; +import app.revanced.integrations.utils.Utils; public class MicroGSupport { private static final String MICROG_VENDOR = "com.mgoogle"; @@ -21,7 +21,7 @@ public class MicroGSupport { private static final Uri VANCED_MICROG_PROVIDER = Uri.parse("content://" + MICROG_VENDOR + ".android.gsf.gservices/prefix"); private static void startIntent(Context context, String uriString, String message) { - ReVancedUtils.showToastLong(message); + Utils.showToastLong(message); var intent = new Intent(Intent.ACTION_VIEW); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); @@ -31,7 +31,7 @@ private static void startIntent(Context context, String uriString, String messag @TargetApi(26) public static void checkAvailability() { - var context = Objects.requireNonNull(ReVancedUtils.getContext()); + var context = Objects.requireNonNull(Utils.getContext()); try { context.getPackageManager().getPackageInfo(MICROG_PACKAGE_NAME, PackageManager.GET_ACTIVITIES); diff --git a/app/src/main/java/app/revanced/integrations/patches/ReturnYouTubeDislikePatch.java b/app/src/main/java/app/revanced/integrations/patches/ReturnYouTubeDislikePatch.java index 7bbcb8b852..2223624f94 100644 --- a/app/src/main/java/app/revanced/integrations/patches/ReturnYouTubeDislikePatch.java +++ b/app/src/main/java/app/revanced/integrations/patches/ReturnYouTubeDislikePatch.java @@ -26,7 +26,7 @@ import app.revanced.integrations.settings.SettingsEnum; import app.revanced.integrations.shared.PlayerType; import app.revanced.integrations.utils.LogHelper; -import app.revanced.integrations.utils.ReVancedUtils; +import app.revanced.integrations.utils.Utils; /** * Handles all interaction of UI patch components. @@ -90,7 +90,7 @@ public static void onRYDStatusChange(boolean rydEnabled) { * Resource identifier of old UI dislike button. */ private static final int OLD_UI_DISLIKE_BUTTON_RESOURCE_ID - = ReVancedUtils.getResourceIdentifier("dislike_button", "id"); + = Utils.getResourceIdentifier("dislike_button", "id"); /** * Dislikes text label used by old UI. @@ -347,7 +347,7 @@ private static void updateOnScreenShortsTextViews(boolean forceUpdate) { Runnable update = () -> { Spanned shortsDislikesSpan = videoData.getDislikeSpanForShort(SHORTS_LOADING_SPAN); - ReVancedUtils.runOnMainThreadNowOrLater(() -> { + Utils.runOnMainThreadNowOrLater(() -> { String videoId = videoData.getVideoId(); if (!videoId.equals(VideoInformation.getVideoId())) { // User swiped to new video before fetch completed @@ -375,7 +375,7 @@ private static void updateOnScreenShortsTextViews(boolean forceUpdate) { if (videoData.fetchCompleted()) { update.run(); // Network call is completed, no need to wait on background thread. } else { - ReVancedUtils.runOnBackgroundThread(update); + Utils.runOnBackgroundThread(update); } } catch (Exception ex) { LogHelper.printException(() -> "updateOnScreenShortsTextViews failure", ex); diff --git a/app/src/main/java/app/revanced/integrations/patches/VideoInformation.java b/app/src/main/java/app/revanced/integrations/patches/VideoInformation.java index ee9034b0b3..06dc7e09e0 100644 --- a/app/src/main/java/app/revanced/integrations/patches/VideoInformation.java +++ b/app/src/main/java/app/revanced/integrations/patches/VideoInformation.java @@ -4,7 +4,7 @@ import app.revanced.integrations.patches.playback.speed.RememberPlaybackSpeedPatch; import app.revanced.integrations.shared.VideoState; import app.revanced.integrations.utils.LogHelper; -import app.revanced.integrations.utils.ReVancedUtils; +import app.revanced.integrations.utils.Utils; import java.lang.ref.WeakReference; import java.lang.reflect.Method; @@ -132,7 +132,7 @@ public static void setVideoTime(final long currentPlaybackTime) { * @return if the seek was successful */ public static boolean seekTo(final long millisecond) { - ReVancedUtils.verifyOnMainThread(); + Utils.verifyOnMainThread(); try { LogHelper.printDebug(() -> "Seeking to " + millisecond); return (Boolean) seekMethod.invoke(playerControllerRef.get(), millisecond); diff --git a/app/src/main/java/app/revanced/integrations/patches/components/AdsFilter.java b/app/src/main/java/app/revanced/integrations/patches/components/AdsFilter.java index 40192d0dfd..de707b3934 100644 --- a/app/src/main/java/app/revanced/integrations/patches/components/AdsFilter.java +++ b/app/src/main/java/app/revanced/integrations/patches/components/AdsFilter.java @@ -6,7 +6,7 @@ import androidx.annotation.Nullable; import app.revanced.integrations.settings.SettingsEnum; -import app.revanced.integrations.utils.ReVancedUtils; +import app.revanced.integrations.utils.Utils; import app.revanced.integrations.utils.StringTrieSearch; @@ -113,6 +113,6 @@ public boolean isFiltered(@Nullable String identifier, String path, byte[] proto * @param view The view, which shows ads. */ public static void hideAdAttributionView(View view) { - ReVancedUtils.hideViewBy1dpUnderCondition(SettingsEnum.HIDE_GENERAL_ADS, view); + Utils.hideViewBy1dpUnderCondition(SettingsEnum.HIDE_GENERAL_ADS, view); } } diff --git a/app/src/main/java/app/revanced/integrations/patches/components/ShortsFilter.java b/app/src/main/java/app/revanced/integrations/patches/components/ShortsFilter.java index 7ab5a54296..0c224555d5 100644 --- a/app/src/main/java/app/revanced/integrations/patches/components/ShortsFilter.java +++ b/app/src/main/java/app/revanced/integrations/patches/components/ShortsFilter.java @@ -7,8 +7,8 @@ import app.revanced.integrations.settings.SettingsEnum; import com.google.android.libraries.youtube.rendering.ui.pivotbar.PivotBar; -import static app.revanced.integrations.utils.ReVancedUtils.hideViewBy1dpUnderCondition; -import static app.revanced.integrations.utils.ReVancedUtils.hideViewUnderCondition; +import static app.revanced.integrations.utils.Utils.hideViewBy1dpUnderCondition; +import static app.revanced.integrations.utils.Utils.hideViewUnderCondition; /** @noinspection unused*/ @RequiresApi(api = Build.VERSION_CODES.N) diff --git a/app/src/main/java/app/revanced/integrations/patches/playback/quality/RememberVideoQualityPatch.java b/app/src/main/java/app/revanced/integrations/patches/playback/quality/RememberVideoQualityPatch.java index 39b893edcb..ab7088d81a 100644 --- a/app/src/main/java/app/revanced/integrations/patches/playback/quality/RememberVideoQualityPatch.java +++ b/app/src/main/java/app/revanced/integrations/patches/playback/quality/RememberVideoQualityPatch.java @@ -1,6 +1,6 @@ package app.revanced.integrations.patches.playback.quality; -import static app.revanced.integrations.utils.ReVancedUtils.NetworkType; +import static app.revanced.integrations.utils.Utils.NetworkType; import static app.revanced.integrations.utils.StringRef.str; import androidx.annotation.Nullable; @@ -12,7 +12,7 @@ import app.revanced.integrations.settings.SettingsEnum; import app.revanced.integrations.utils.LogHelper; -import app.revanced.integrations.utils.ReVancedUtils; +import app.revanced.integrations.utils.Utils; public class RememberVideoQualityPatch { private static final int AUTOMATIC_VIDEO_QUALITY_VALUE = -2; @@ -40,14 +40,14 @@ public class RememberVideoQualityPatch { private static void changeDefaultQuality(int defaultQuality) { String networkTypeMessage; - if (ReVancedUtils.getNetworkType() == NetworkType.MOBILE) { + if (Utils.getNetworkType() == NetworkType.MOBILE) { mobileQualitySetting.saveValue(defaultQuality); networkTypeMessage = str("revanced_remember_video_quality_mobile"); } else { wifiQualitySetting.saveValue(defaultQuality); networkTypeMessage = str("revanced_remember_video_quality_wifi"); } - ReVancedUtils.showToastShort( + Utils.showToastShort( str("revanced_remember_video_quality_toast", networkTypeMessage, (defaultQuality + "p"))); } @@ -65,7 +65,7 @@ public static int setVideoQuality(Object[] qualities, final int originalQualityI qualityNeedsUpdating = false; final int preferredQuality; - if (ReVancedUtils.getNetworkType() == NetworkType.MOBILE) { + if (Utils.getNetworkType() == NetworkType.MOBILE) { preferredQuality = mobileQualitySetting.getInt(); } else { preferredQuality = wifiQualitySetting.getInt(); diff --git a/app/src/main/java/app/revanced/integrations/patches/playback/speed/CustomPlaybackSpeedPatch.java b/app/src/main/java/app/revanced/integrations/patches/playback/speed/CustomPlaybackSpeedPatch.java index 7c0f89ee9d..9a0ce37182 100644 --- a/app/src/main/java/app/revanced/integrations/patches/playback/speed/CustomPlaybackSpeedPatch.java +++ b/app/src/main/java/app/revanced/integrations/patches/playback/speed/CustomPlaybackSpeedPatch.java @@ -14,7 +14,7 @@ import app.revanced.integrations.patches.components.PlaybackSpeedMenuFilterPatch; import app.revanced.integrations.settings.SettingsEnum; import app.revanced.integrations.utils.LogHelper; -import app.revanced.integrations.utils.ReVancedUtils; +import app.revanced.integrations.utils.Utils; public class CustomPlaybackSpeedPatch { /** @@ -38,7 +38,7 @@ public class CustomPlaybackSpeedPatch { } private static void resetCustomSpeeds(@NonNull String toastMessage) { - ReVancedUtils.showToastLong(toastMessage); + Utils.showToastLong(toastMessage); SettingsEnum.CUSTOM_PLAYBACK_SPEEDS.saveValue(SettingsEnum.CUSTOM_PLAYBACK_SPEEDS.defaultValue); } diff --git a/app/src/main/java/app/revanced/integrations/patches/playback/speed/RememberPlaybackSpeedPatch.java b/app/src/main/java/app/revanced/integrations/patches/playback/speed/RememberPlaybackSpeedPatch.java index 44779e8b97..346bba9241 100644 --- a/app/src/main/java/app/revanced/integrations/patches/playback/speed/RememberPlaybackSpeedPatch.java +++ b/app/src/main/java/app/revanced/integrations/patches/playback/speed/RememberPlaybackSpeedPatch.java @@ -5,7 +5,7 @@ import app.revanced.integrations.patches.VideoInformation; import app.revanced.integrations.settings.SettingsEnum; import app.revanced.integrations.utils.LogHelper; -import app.revanced.integrations.utils.ReVancedUtils; +import app.revanced.integrations.utils.Utils; public final class RememberPlaybackSpeedPatch { @@ -26,7 +26,7 @@ public static void newVideoStarted(Object ignoredPlayerController) { public static void userSelectedPlaybackSpeed(float playbackSpeed) { if (SettingsEnum.REMEMBER_PLAYBACK_SPEED_LAST_SELECTED.getBoolean()) { SettingsEnum.PLAYBACK_SPEED_DEFAULT.saveValue(playbackSpeed); - ReVancedUtils.showToastLong(str("revanced_remember_playback_speed_toast", (playbackSpeed + "x"))); + Utils.showToastLong(str("revanced_remember_playback_speed_toast", (playbackSpeed + "x"))); } } diff --git a/app/src/main/java/app/revanced/integrations/patches/spoof/SpoofSignaturePatch.java b/app/src/main/java/app/revanced/integrations/patches/spoof/SpoofSignaturePatch.java index 16a284d049..ef65b718e4 100644 --- a/app/src/main/java/app/revanced/integrations/patches/spoof/SpoofSignaturePatch.java +++ b/app/src/main/java/app/revanced/integrations/patches/spoof/SpoofSignaturePatch.java @@ -1,7 +1,7 @@ package app.revanced.integrations.patches.spoof; import static app.revanced.integrations.patches.spoof.requests.StoryboardRendererRequester.getStoryboardRenderer; -import static app.revanced.integrations.utils.ReVancedUtils.containsAny; +import static app.revanced.integrations.utils.Utils.containsAny; import androidx.annotation.Nullable; @@ -14,7 +14,7 @@ import app.revanced.integrations.settings.SettingsEnum; import app.revanced.integrations.shared.PlayerType; import app.revanced.integrations.utils.LogHelper; -import app.revanced.integrations.utils.ReVancedUtils; +import app.revanced.integrations.utils.Utils; /** @noinspection unused*/ public class SpoofSignaturePatch { @@ -104,7 +104,7 @@ public static String spoofParameter(String parameters) { private static void fetchStoryboardRenderer() { String videoId = VideoInformation.getPlayerResponseVideoId(); if (!videoId.equals(lastPlayerResponseVideoId)) { - rendererFuture = ReVancedUtils.submitOnBackgroundThread(() -> getStoryboardRenderer(videoId)); + rendererFuture = Utils.submitOnBackgroundThread(() -> getStoryboardRenderer(videoId)); lastPlayerResponseVideoId = videoId; } // Block until the fetch is completed. Without this, occasionally when a new video is opened diff --git a/app/src/main/java/app/revanced/integrations/patches/spoof/requests/StoryboardRendererRequester.java b/app/src/main/java/app/revanced/integrations/patches/spoof/requests/StoryboardRendererRequester.java index 61828a04bb..a9aac07395 100644 --- a/app/src/main/java/app/revanced/integrations/patches/spoof/requests/StoryboardRendererRequester.java +++ b/app/src/main/java/app/revanced/integrations/patches/spoof/requests/StoryboardRendererRequester.java @@ -5,7 +5,7 @@ import app.revanced.integrations.patches.spoof.StoryboardRenderer; import app.revanced.integrations.requests.Requester; import app.revanced.integrations.utils.LogHelper; -import app.revanced.integrations.utils.ReVancedUtils; +import app.revanced.integrations.utils.Utils; import org.json.JSONException; import org.json.JSONObject; @@ -23,7 +23,7 @@ private StoryboardRendererRequester() { @Nullable private static JSONObject fetchPlayerResponse(@NonNull String requestBody) { try { - ReVancedUtils.verifyOffMainThread(); + Utils.verifyOffMainThread(); Objects.requireNonNull(requestBody); final byte[] innerTubeBody = requestBody.getBytes(StandardCharsets.UTF_8); diff --git a/app/src/main/java/app/revanced/integrations/patches/theme/SeekbarColorPatch.java b/app/src/main/java/app/revanced/integrations/patches/theme/SeekbarColorPatch.java index 90fab4aaff..b75595765b 100644 --- a/app/src/main/java/app/revanced/integrations/patches/theme/SeekbarColorPatch.java +++ b/app/src/main/java/app/revanced/integrations/patches/theme/SeekbarColorPatch.java @@ -6,7 +6,7 @@ import app.revanced.integrations.settings.SettingsEnum; import app.revanced.integrations.utils.LogHelper; -import app.revanced.integrations.utils.ReVancedUtils; +import app.revanced.integrations.utils.Utils; public final class SeekbarColorPatch { @@ -49,7 +49,7 @@ private static void loadCustomSeekbarColor() { seekbarColor = Color.parseColor(SettingsEnum.SEEKBAR_CUSTOM_COLOR_VALUE.getString()); Color.colorToHSV(seekbarColor, customSeekbarColorHSV); } catch (Exception ex) { - ReVancedUtils.showToastShort(str("revanced_seekbar_custom_color_invalid")); + Utils.showToastShort(str("revanced_seekbar_custom_color_invalid")); SettingsEnum.SEEKBAR_CUSTOM_COLOR_VALUE.saveValue(SettingsEnum.SEEKBAR_CUSTOM_COLOR_VALUE.defaultValue); loadCustomSeekbarColor(); } diff --git a/app/src/main/java/app/revanced/integrations/patches/theme/ThemePatch.java b/app/src/main/java/app/revanced/integrations/patches/theme/ThemePatch.java index e9796db250..15d9117107 100644 --- a/app/src/main/java/app/revanced/integrations/patches/theme/ThemePatch.java +++ b/app/src/main/java/app/revanced/integrations/patches/theme/ThemePatch.java @@ -1,7 +1,7 @@ package app.revanced.integrations.patches.theme; import app.revanced.integrations.settings.SettingsEnum; -import app.revanced.integrations.utils.ReVancedUtils; +import app.revanced.integrations.utils.Utils; import app.revanced.integrations.utils.ThemeHelper; public class ThemePatch { @@ -46,12 +46,12 @@ public static boolean gradientLoadingScreenEnabled() { } private static int getBlackColor() { - if (blackColor == 0) blackColor = ReVancedUtils.getResourceColor("yt_black1"); + if (blackColor == 0) blackColor = Utils.getResourceColor("yt_black1"); return blackColor; } private static int getWhiteColor() { - if (whiteColor == 0) whiteColor = ReVancedUtils.getResourceColor("yt_white1"); + if (whiteColor == 0) whiteColor = Utils.getResourceColor("yt_white1"); return whiteColor; } diff --git a/app/src/main/java/app/revanced/integrations/returnyoutubedislike/ReturnYouTubeDislike.java b/app/src/main/java/app/revanced/integrations/returnyoutubedislike/ReturnYouTubeDislike.java index da8cd810a9..f8c89f4ac3 100644 --- a/app/src/main/java/app/revanced/integrations/returnyoutubedislike/ReturnYouTubeDislike.java +++ b/app/src/main/java/app/revanced/integrations/returnyoutubedislike/ReturnYouTubeDislike.java @@ -41,7 +41,7 @@ import app.revanced.integrations.settings.SettingsEnum; import app.revanced.integrations.shared.PlayerType; import app.revanced.integrations.utils.LogHelper; -import app.revanced.integrations.utils.ReVancedUtils; +import app.revanced.integrations.utils.Utils; import app.revanced.integrations.utils.ThemeHelper; /** @@ -116,7 +116,7 @@ public enum Vote { private static final Rect middleSeparatorBounds; static { - DisplayMetrics dp = Objects.requireNonNull(ReVancedUtils.getContext()).getResources().getDisplayMetrics(); + DisplayMetrics dp = Objects.requireNonNull(Utils.getContext()).getResources().getDisplayMetrics(); leftSeparatorBounds = new Rect(0, 0, (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 1.2f, dp), @@ -208,7 +208,7 @@ private static SpannableString createDislikeSpan(@NonNull Spanned oldSpannable, if (!compactLayout) { // left separator - String leftSeparatorString = ReVancedUtils.isRightToLeftTextLayout() + String leftSeparatorString = Utils.isRightToLeftTextLayout() ? "\u200F " // u200F = right to left character : "\u200E "; // u200E = left to right character Spannable leftSeparatorSpan = new SpannableString(leftSeparatorString); @@ -306,7 +306,7 @@ private static String formatDislikeCount(long dislikeCount) { // such as Arabic which formats "1.234" into "Û±,Û²Û³Ù¤" // But YouTube disregards locale specific number characters // and instead shows english number characters everywhere. - Locale locale = Objects.requireNonNull(ReVancedUtils.getContext()).getResources().getConfiguration().locale; + Locale locale = Objects.requireNonNull(Utils.getContext()).getResources().getConfiguration().locale; LogHelper.printDebug(() -> "Locale: " + locale); dislikeCountFormatter = CompactDecimalFormat.getInstance(locale, CompactDecimalFormat.CompactStyle.SHORT); } @@ -321,7 +321,7 @@ private static String formatDislikeCount(long dislikeCount) { private static String formatDislikePercentage(float dislikePercentage) { synchronized (ReturnYouTubeDislike.class) { // number formatter is not thread safe, must synchronize if (dislikePercentageFormatter == null) { - Locale locale = Objects.requireNonNull(ReVancedUtils.getContext()).getResources().getConfiguration().locale; + Locale locale = Objects.requireNonNull(Utils.getContext()).getResources().getConfiguration().locale; LogHelper.printDebug(() -> "Locale: " + locale); dislikePercentageFormatter = NumberFormat.getPercentInstance(locale); } @@ -372,7 +372,7 @@ public static void clearAllUICaches() { private ReturnYouTubeDislike(@NonNull String videoId) { this.videoId = Objects.requireNonNull(videoId); this.timeFetched = System.currentTimeMillis(); - this.future = ReVancedUtils.submitOnBackgroundThread(() -> ReturnYouTubeDislikeApi.fetchVotes(videoId)); + this.future = Utils.submitOnBackgroundThread(() -> ReturnYouTubeDislikeApi.fetchVotes(videoId)); } private boolean isExpired(long now) { @@ -510,14 +510,14 @@ private Spanned waitForFetchAndUpdateReplacementSpan(@NonNull Spanned original, } public void sendVote(@NonNull Vote vote) { - ReVancedUtils.verifyOnMainThread(); + Utils.verifyOnMainThread(); Objects.requireNonNull(vote); try { if (isShort != PlayerType.getCurrent().isNoneOrHidden()) { // Shorts was loaded with regular video present, then Shorts was closed. // and then user voted on the now visible original video. // Cannot send a vote, because this instance is for the wrong video. - ReVancedUtils.showToastLong(str("revanced_ryd_failure_ryd_enabled_while_playing_video_then_user_voted")); + Utils.showToastLong(str("revanced_ryd_failure_ryd_enabled_while_playing_video_then_user_voted")); return; } diff --git a/app/src/main/java/app/revanced/integrations/returnyoutubedislike/requests/ReturnYouTubeDislikeApi.java b/app/src/main/java/app/revanced/integrations/returnyoutubedislike/requests/ReturnYouTubeDislikeApi.java index f10ed8210f..4b52844614 100644 --- a/app/src/main/java/app/revanced/integrations/returnyoutubedislike/requests/ReturnYouTubeDislikeApi.java +++ b/app/src/main/java/app/revanced/integrations/returnyoutubedislike/requests/ReturnYouTubeDislikeApi.java @@ -26,7 +26,7 @@ import app.revanced.integrations.returnyoutubedislike.ReturnYouTubeDislike; import app.revanced.integrations.settings.SettingsEnum; import app.revanced.integrations.utils.LogHelper; -import app.revanced.integrations.utils.ReVancedUtils; +import app.revanced.integrations.utils.Utils; public class ReturnYouTubeDislikeApi { /** @@ -196,7 +196,7 @@ private static boolean checkIfRateLimitWasHit(int httpResponseCode) { numberOfRateLimitRequestsEncountered++; LogHelper.printDebug(() -> "API rate limit was hit. Stopping API calls for the next " + RATE_LIMIT_BACKOFF_SECONDS + " seconds"); - ReVancedUtils.showToastLong(str("revanced_ryd_failure_client_rate_limit_requested")); + Utils.showToastLong(str("revanced_ryd_failure_client_rate_limit_requested")); return true; } return false; @@ -224,7 +224,7 @@ private static void updateStatistics(long timeNetworkCallStarted, long timeNetwo private static void handleConnectionError(@NonNull String toastMessage, @Nullable Exception ex) { if (SettingsEnum.RYD_TOAST_ON_CONNECTION_ERROR.getBoolean()) { - ReVancedUtils.showToastShort(toastMessage); + Utils.showToastShort(toastMessage); } if (ex != null) { LogHelper.printInfo(() -> toastMessage, ex); @@ -236,7 +236,7 @@ private static void handleConnectionError(@NonNull String toastMessage, @Nullabl */ @Nullable public static RYDVoteData fetchVotes(String videoId) { - ReVancedUtils.verifyOffMainThread(); + Utils.verifyOffMainThread(); Objects.requireNonNull(videoId); if (checkIfRateLimitInEffect("fetchVotes")) { @@ -305,7 +305,7 @@ public static RYDVoteData fetchVotes(String videoId) { */ @Nullable public static String registerAsNewUser() { - ReVancedUtils.verifyOffMainThread(); + Utils.verifyOffMainThread(); try { if (checkIfRateLimitInEffect("registerAsNewUser")) { return null; @@ -345,7 +345,7 @@ public static String registerAsNewUser() { @Nullable private static String confirmRegistration(String userId, String solution) { - ReVancedUtils.verifyOffMainThread(); + Utils.verifyOffMainThread(); Objects.requireNonNull(userId); Objects.requireNonNull(solution); try { @@ -399,7 +399,7 @@ private static String confirmRegistration(String userId, String solution) { */ @Nullable private static String getUserId() { - ReVancedUtils.verifyOffMainThread(); + Utils.verifyOffMainThread(); String userId = SettingsEnum.RYD_USER_ID.getString(); if (!userId.isEmpty()) { @@ -414,7 +414,7 @@ private static String getUserId() { } public static boolean sendVote(String videoId, ReturnYouTubeDislike.Vote vote) { - ReVancedUtils.verifyOffMainThread(); + Utils.verifyOffMainThread(); Objects.requireNonNull(videoId); Objects.requireNonNull(vote); @@ -465,7 +465,7 @@ public static boolean sendVote(String videoId, ReturnYouTubeDislike.Vote vote) { } private static boolean confirmVote(String videoId, String userId, String solution) { - ReVancedUtils.verifyOffMainThread(); + Utils.verifyOffMainThread(); Objects.requireNonNull(videoId); Objects.requireNonNull(userId); Objects.requireNonNull(solution); 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 6b8c18a386..a066d64cab 100644 --- a/app/src/main/java/app/revanced/integrations/settings/SettingsEnum.java +++ b/app/src/main/java/app/revanced/integrations/settings/SettingsEnum.java @@ -5,7 +5,7 @@ import androidx.annotation.Nullable; import app.revanced.integrations.sponsorblock.SponsorBlockSettings; import app.revanced.integrations.utils.LogHelper; -import app.revanced.integrations.utils.ReVancedUtils; +import app.revanced.integrations.utils.Utils; import app.revanced.integrations.utils.StringRef; import org.json.JSONException; import org.json.JSONObject; @@ -672,13 +672,13 @@ public static boolean importJSON(@NonNull String settingsJsonString) { } numberOfSettingsImported += SponsorBlockSettings.importCategoriesFromFlatJson(json); - ReVancedUtils.showToastLong(numberOfSettingsImported == 0 + Utils.showToastLong(numberOfSettingsImported == 0 ? str("revanced_settings_import_reset") : str("revanced_settings_import_success", numberOfSettingsImported)); return rebootSettingChanged; } catch (JSONException | IllegalArgumentException ex) { - ReVancedUtils.showToastLong(str("revanced_settings_import_failure_parse", ex.getMessage())); + Utils.showToastLong(str("revanced_settings_import_failure_parse", ex.getMessage())); LogHelper.printInfo(() -> "", ex); } catch (Exception ex) { LogHelper.printException(() -> "Import failure: " + ex.getMessage(), ex); // should never happen diff --git a/app/src/main/java/app/revanced/integrations/settings/SharedPrefCategory.java b/app/src/main/java/app/revanced/integrations/settings/SharedPrefCategory.java index 17799e2538..e72574d6e1 100644 --- a/app/src/main/java/app/revanced/integrations/settings/SharedPrefCategory.java +++ b/app/src/main/java/app/revanced/integrations/settings/SharedPrefCategory.java @@ -9,7 +9,7 @@ import java.util.Objects; import app.revanced.integrations.utils.LogHelper; -import app.revanced.integrations.utils.ReVancedUtils; +import app.revanced.integrations.utils.Utils; /** * Shared categories, and helper methods. @@ -33,7 +33,7 @@ public enum SharedPrefCategory { SharedPrefCategory(@NonNull String prefName) { this.prefName = Objects.requireNonNull(prefName); - preferences = Objects.requireNonNull(ReVancedUtils.getContext()).getSharedPreferences(prefName, Context.MODE_PRIVATE); + preferences = Objects.requireNonNull(Utils.getContext()).getSharedPreferences(prefName, Context.MODE_PRIVATE); } private void removeConflictingPreferenceKeyValue(@NonNull String key) { diff --git a/app/src/main/java/app/revanced/integrations/settingsmenu/ImportExportPreference.java b/app/src/main/java/app/revanced/integrations/settingsmenu/ImportExportPreference.java index 40aab6a337..45f2e14d86 100644 --- a/app/src/main/java/app/revanced/integrations/settingsmenu/ImportExportPreference.java +++ b/app/src/main/java/app/revanced/integrations/settingsmenu/ImportExportPreference.java @@ -14,7 +14,7 @@ import app.revanced.integrations.settings.SettingsEnum; import app.revanced.integrations.utils.LogHelper; -import app.revanced.integrations.utils.ReVancedUtils; +import app.revanced.integrations.utils.Utils; public class ImportExportPreference extends EditTextPreference implements Preference.OnPreferenceClickListener { @@ -68,7 +68,7 @@ protected void onPrepareDialogBuilder(AlertDialog.Builder builder) { try { // Show the user the settings in JSON format. builder.setNeutralButton(str("revanced_settings_import_copy"), (dialog, which) -> { - ReVancedUtils.setClipboard(getEditText().getText().toString()); + Utils.setClipboard(getEditText().getText().toString()); }).setPositiveButton(str("revanced_settings_import"), (dialog, which) -> { importSettings(getEditText().getText().toString()); }); 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 3d53808168..67dd313be1 100644 --- a/app/src/main/java/app/revanced/integrations/settingsmenu/SponsorBlockSettingsFragment.java +++ b/app/src/main/java/app/revanced/integrations/settingsmenu/SponsorBlockSettingsFragment.java @@ -39,7 +39,7 @@ import app.revanced.integrations.sponsorblock.requests.SBRequester; import app.revanced.integrations.sponsorblock.ui.SponsorBlockViewController; import app.revanced.integrations.utils.LogHelper; -import app.revanced.integrations.utils.ReVancedUtils; +import app.revanced.integrations.utils.Utils; @SuppressWarnings("deprecation") public class SponsorBlockSettingsFragment extends PreferenceFragment { @@ -214,7 +214,7 @@ private void addAppearanceCategory(Context context, PreferenceScreen screen) { showSkipToast.setSummaryOn(str("revanced_sb_general_skiptoast_sum_on")); showSkipToast.setSummaryOff(str("revanced_sb_general_skiptoast_sum_off")); showSkipToast.setOnPreferenceClickListener(preference1 -> { - ReVancedUtils.showToastShort(str("revanced_sb_skipped_sponsor")); + Utils.showToastShort(str("revanced_sb_skipped_sponsor")); return false; }); showSkipToast.setOnPreferenceChangeListener((preference1, newValue) -> { @@ -270,7 +270,7 @@ private void addCreateSegmentCategory(Context context, PreferenceScreen screen) newSegmentStep.setOnPreferenceChangeListener((preference1, newValue) -> { final int newAdjustmentValue = Integer.parseInt(newValue.toString()); if (newAdjustmentValue == 0) { - ReVancedUtils.showToastLong(str("revanced_sb_general_adjusting_invalid")); + Utils.showToastLong(str("revanced_sb_general_adjusting_invalid")); return false; } SettingsEnum.SB_CREATE_NEW_SEGMENT_STEP.saveValue(newAdjustmentValue); @@ -331,7 +331,7 @@ private void addGeneralCategory(final Context context, PreferenceScreen screen) privateUserId.setOnPreferenceChangeListener((preference1, newValue) -> { String newUUID = newValue.toString(); if (!SponsorBlockSettings.isValidSBUserId(newUUID)) { - ReVancedUtils.showToastLong(str("revanced_sb_general_uuid_invalid")); + Utils.showToastLong(str("revanced_sb_general_uuid_invalid")); return false; } SettingsEnum.SB_PRIVATE_USER_ID.saveValue(newUUID); @@ -352,14 +352,14 @@ private void addGeneralCategory(final Context context, PreferenceScreen screen) DialogInterface.OnClickListener urlChangeListener = (dialog, buttonPressed) -> { if (buttonPressed == DialogInterface.BUTTON_NEUTRAL) { SettingsEnum.SB_API_URL.saveValue(SettingsEnum.SB_API_URL.defaultValue); - ReVancedUtils.showToastLong(str("revanced_sb_api_url_reset")); + Utils.showToastLong(str("revanced_sb_api_url_reset")); } else if (buttonPressed == DialogInterface.BUTTON_POSITIVE) { String serverAddress = editText.getText().toString(); if (!SponsorBlockSettings.isValidSBServerAddress(serverAddress)) { - ReVancedUtils.showToastLong(str("revanced_sb_api_url_invalid")); + Utils.showToastLong(str("revanced_sb_api_url_invalid")); } else if (!serverAddress.equals(SettingsEnum.SB_API_URL.getString())) { SettingsEnum.SB_API_URL.saveValue(serverAddress); - ReVancedUtils.showToastLong(str("revanced_sb_api_url_changed")); + Utils.showToastLong(str("revanced_sb_api_url_changed")); } } }; @@ -377,7 +377,7 @@ private void addGeneralCategory(final Context context, PreferenceScreen screen) importExport = new EditTextPreference(context) { protected void onPrepareDialogBuilder(AlertDialog.Builder builder) { builder.setNeutralButton(str("revanced_sb_settings_copy"), (dialog, which) -> { - ReVancedUtils.setClipboard(getEditText().getText().toString()); + Utils.setClipboard(getEditText().getText().toString()); }); } }; @@ -456,9 +456,9 @@ private void fetchAndDisplayStats() { statsCategory.addPreference(loadingPlaceholderPreference); if (SettingsEnum.SB_ENABLED.getBoolean()) { loadingPlaceholderPreference.setTitle(str("revanced_sb_stats_loading")); - ReVancedUtils.runOnBackgroundThread(() -> { + Utils.runOnBackgroundThread(() -> { UserStats stats = SBRequester.retrieveUserStats(); - ReVancedUtils.runOnMainThread(() -> { // get back on main thread to modify UI elements + Utils.runOnMainThread(() -> { // get back on main thread to modify UI elements addUserStats(loadingPlaceholderPreference, stats); addLocalUserStats(); }); @@ -474,7 +474,7 @@ private void fetchAndDisplayStats() { private static final DecimalFormat statsNumberOfSegmentsSkippedFormatter = new DecimalFormat("#,###,###"); private void addUserStats(@NonNull Preference loadingPlaceholder, @Nullable UserStats stats) { - ReVancedUtils.verifyOnMainThread(); + Utils.verifyOnMainThread(); try { if (stats == null) { loadingPlaceholder.setTitle(str("revanced_sb_stats_connection_failure")); @@ -492,17 +492,17 @@ private void addUserStats(@NonNull Preference loadingPlaceholder, @Nullable User preference.setSummary(str("revanced_sb_stats_username_change")); preference.setText(userName); preference.setOnPreferenceChangeListener((preference1, value) -> { - ReVancedUtils.runOnBackgroundThread(() -> { + Utils.runOnBackgroundThread(() -> { String newUserName = (String) value; String errorMessage = SBRequester.setUsername(newUserName); - ReVancedUtils.runOnMainThread(() -> { + Utils.runOnMainThread(() -> { if (errorMessage == null) { preference.setTitle(fromHtml(str("revanced_sb_stats_username", newUserName))); preference.setText(newUserName); - ReVancedUtils.showToastLong(str("revanced_sb_stats_username_changed")); + Utils.showToastLong(str("revanced_sb_stats_username_changed")); } else { preference.setText(userName); // revert to previous - ReVancedUtils.showToastLong(errorMessage); + Utils.showToastLong(errorMessage); } }); }); diff --git a/app/src/main/java/app/revanced/integrations/settingsmenu/YouTubeSettingActivity.java b/app/src/main/java/app/revanced/integrations/settingsmenu/YouTubeSettingActivity.java index 45b9cbae2b..05270d8943 100644 --- a/app/src/main/java/app/revanced/integrations/settingsmenu/YouTubeSettingActivity.java +++ b/app/src/main/java/app/revanced/integrations/settingsmenu/YouTubeSettingActivity.java @@ -1,7 +1,7 @@ package app.revanced.integrations.settingsmenu; -import static app.revanced.integrations.utils.ReVancedUtils.getChildView; -import static app.revanced.integrations.utils.ReVancedUtils.getResourceIdentifier; +import static app.revanced.integrations.utils.Utils.getChildView; +import static app.revanced.integrations.utils.Utils.getResourceIdentifier; import android.annotation.SuppressLint; import android.app.Activity; diff --git a/app/src/main/java/app/revanced/integrations/settingsmenu/YouTubeSettingsFragment.java b/app/src/main/java/app/revanced/integrations/settingsmenu/YouTubeSettingsFragment.java index b8e96a8700..9f5b158f7a 100644 --- a/app/src/main/java/app/revanced/integrations/settingsmenu/YouTubeSettingsFragment.java +++ b/app/src/main/java/app/revanced/integrations/settingsmenu/YouTubeSettingsFragment.java @@ -28,7 +28,7 @@ import app.revanced.integrations.settings.SettingsEnum; import app.revanced.integrations.settings.SharedPrefCategory; import app.revanced.integrations.utils.LogHelper; -import app.revanced.integrations.utils.ReVancedUtils; +import app.revanced.integrations.utils.Utils; public class YouTubeSettingsFragment extends PreferenceFragment { /** @@ -128,7 +128,7 @@ public void onActivityCreated(@Nullable Bundle savedInstanceState) { try { PreferenceManager preferenceManager = getPreferenceManager(); preferenceManager.setSharedPreferencesName(SharedPrefCategory.YOUTUBE.prefName); - addPreferencesFromResource(ReVancedUtils.getResourceIdentifier("revanced_prefs", "xml")); + addPreferencesFromResource(Utils.getResourceIdentifier("revanced_prefs", "xml")); enableDisablePreferences(); diff --git a/app/src/main/java/app/revanced/integrations/shared/PlayerControlsVisibilityObserver.kt b/app/src/main/java/app/revanced/integrations/shared/PlayerControlsVisibilityObserver.kt index 1db019e1c0..31c8f62f11 100644 --- a/app/src/main/java/app/revanced/integrations/shared/PlayerControlsVisibilityObserver.kt +++ b/app/src/main/java/app/revanced/integrations/shared/PlayerControlsVisibilityObserver.kt @@ -3,7 +3,7 @@ package app.revanced.integrations.shared import android.app.Activity import android.view.View import android.view.ViewGroup -import app.revanced.integrations.utils.ReVancedUtils +import app.revanced.integrations.utils.Utils import java.lang.ref.WeakReference /** @@ -19,13 +19,13 @@ class PlayerControlsVisibilityObserverImpl( * id of the direct parent of controls_layout, R.id.youtube_controls_overlay */ private val controlsLayoutParentId = - ReVancedUtils.getResourceIdentifier(activity, "youtube_controls_overlay", "id") + Utils.getResourceIdentifier(activity, "youtube_controls_overlay", "id") /** * id of R.id.controls_layout */ private val controlsLayoutId = - ReVancedUtils.getResourceIdentifier(activity, "controls_layout", "id") + Utils.getResourceIdentifier(activity, "controls_layout", "id") /** * reference to the controls layout view diff --git a/app/src/main/java/app/revanced/integrations/sponsorblock/SegmentPlaybackController.java b/app/src/main/java/app/revanced/integrations/sponsorblock/SegmentPlaybackController.java index b48ce5ecb1..f86a573c5b 100644 --- a/app/src/main/java/app/revanced/integrations/sponsorblock/SegmentPlaybackController.java +++ b/app/src/main/java/app/revanced/integrations/sponsorblock/SegmentPlaybackController.java @@ -16,7 +16,7 @@ import app.revanced.integrations.sponsorblock.requests.SBRequester; import app.revanced.integrations.sponsorblock.ui.SponsorBlockViewController; import app.revanced.integrations.utils.LogHelper; -import app.revanced.integrations.utils.ReVancedUtils; +import app.revanced.integrations.utils.Utils; import java.lang.reflect.Field; import java.util.*; @@ -178,7 +178,7 @@ private static void clearData() { */ public static void initialize(Object ignoredPlayerController) { try { - ReVancedUtils.verifyOnMainThread(); + Utils.verifyOnMainThread(); SponsorBlockSettings.initialize(); clearData(); SponsorBlockViewController.hideAll(); @@ -205,7 +205,7 @@ public static void setCurrentVideoId(@Nullable String videoId) { LogHelper.printDebug(() -> "ignoring Short"); return; } - if (!ReVancedUtils.isNetworkConnected()) { + if (!Utils.isNetworkConnected()) { LogHelper.printDebug(() -> "Network not connected, ignoring video"); return; } @@ -213,7 +213,7 @@ public static void setCurrentVideoId(@Nullable String videoId) { currentVideoId = videoId; LogHelper.printDebug(() -> "setCurrentVideoId: " + videoId); - ReVancedUtils.runOnBackgroundThread(() -> { + Utils.runOnBackgroundThread(() -> { try { executeDownloadSegments(videoId); } catch (Exception e) { @@ -233,7 +233,7 @@ static void executeDownloadSegments(@NonNull String videoId) { try { SponsorSegment[] segments = SBRequester.getSegments(videoId); - ReVancedUtils.runOnMainThread(()-> { + Utils.runOnMainThread(()-> { if (!videoId.equals(currentVideoId)) { // user changed videos before get segments network call could complete LogHelper.printDebug(() -> "Ignoring segments for prior video: " + videoId); @@ -393,7 +393,7 @@ public static void setVideoTime(long millis) { scheduledHideSegment = segmentToHide; LogHelper.printDebug(() -> "Scheduling hide segment: " + segmentToHide + " playbackSpeed: " + playbackSpeed); final long delayUntilHide = (long) ((segmentToHide.end - millis) / playbackSpeed); - ReVancedUtils.runOnMainThreadDelayed(() -> { + Utils.runOnMainThreadDelayed(() -> { if (scheduledHideSegment != segmentToHide) { LogHelper.printDebug(() -> "Ignoring old scheduled hide segment: " + segmentToHide); return; @@ -432,7 +432,7 @@ public static void setVideoTime(long millis) { LogHelper.printDebug(() -> "Scheduling segment: " + segmentToSkip + " playbackSpeed: " + playbackSpeed); final long delayUntilSkip = (long) ((segmentToSkip.start - millis) / playbackSpeed); - ReVancedUtils.runOnMainThreadDelayed(() -> { + Utils.runOnMainThreadDelayed(() -> { if (scheduledUpcomingSegment != segmentToSkip) { LogHelper.printDebug(() -> "Ignoring old scheduled segment: " + segmentToSkip); return; @@ -577,7 +577,7 @@ private static void skipSegment(@NonNull SponsorSegment segmentToSkip, boolean u private static SponsorSegment toastSegmentSkipped; private static void showSkippedSegmentToast(@NonNull SponsorSegment segment) { - ReVancedUtils.verifyOnMainThread(); + Utils.verifyOnMainThread(); toastNumberOfSegmentsSkipped++; if (toastNumberOfSegmentsSkipped > 1) { return; // toast already scheduled @@ -585,13 +585,13 @@ private static void showSkippedSegmentToast(@NonNull SponsorSegment segment) { toastSegmentSkipped = segment; final long delayToToastMilliseconds = 250; // also the maximum time between skips to be considered skipping multiple segments - ReVancedUtils.runOnMainThreadDelayed(() -> { + Utils.runOnMainThreadDelayed(() -> { try { if (toastSegmentSkipped == null) { // video was changed just after skipping segment LogHelper.printDebug(() -> "Ignoring old scheduled show toast"); return; } - ReVancedUtils.showToastShort(toastNumberOfSegmentsSkipped == 1 + Utils.showToastShort(toastNumberOfSegmentsSkipped == 1 ? toastSegmentSkipped.getSkippedToastText() : str("revanced_sb_skipped_multiple_segments")); } catch (Exception ex) { @@ -727,7 +727,7 @@ private static int getHighlightSegmentTimeBarScreenWidth() { if (highlightSegmentTimeBarScreenWidth == -1) { highlightSegmentTimeBarScreenWidth = (int) TypedValue.applyDimension( TypedValue.COMPLEX_UNIT_DIP, HIGHLIGHT_SEGMENT_DRAW_BAR_WIDTH, - Objects.requireNonNull(ReVancedUtils.getContext()).getResources().getDisplayMetrics()); + Objects.requireNonNull(Utils.getContext()).getResources().getDisplayMetrics()); } return highlightSegmentTimeBarScreenWidth; } 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 d0cba62a19..fb74fc79dd 100644 --- a/app/src/main/java/app/revanced/integrations/sponsorblock/SponsorBlockSettings.java +++ b/app/src/main/java/app/revanced/integrations/sponsorblock/SponsorBlockSettings.java @@ -21,7 +21,7 @@ import app.revanced.integrations.sponsorblock.objects.CategoryBehaviour; import app.revanced.integrations.sponsorblock.objects.SegmentCategory; import app.revanced.integrations.utils.LogHelper; -import app.revanced.integrations.utils.ReVancedUtils; +import app.revanced.integrations.utils.Utils; public class SponsorBlockSettings { /** @@ -30,7 +30,7 @@ public class SponsorBlockSettings { private static final int SB_PRIVATE_USER_ID_MINIMUM_LENGTH = 30; public static void importSettings(@NonNull String json) { - ReVancedUtils.verifyOnMainThread(); + Utils.verifyOnMainThread(); try { JSONObject settingsJson = new JSONObject(json); JSONObject barTypesObject = settingsJson.getJSONObject("barTypes"); @@ -58,9 +58,9 @@ public static void importSettings(@NonNull String json) { CategoryBehaviour behaviour = CategoryBehaviour.byDesktopKey(desktopKey); if (behaviour == null) { // String is not worth localizing, as this should never happen. - ReVancedUtils.showToastLong(categoryKey + " unknown behavior key: " + desktopKey); + Utils.showToastLong(categoryKey + " unknown behavior key: " + desktopKey); } else if (category == SegmentCategory.HIGHLIGHT && behaviour == CategoryBehaviour.SKIP_AUTOMATICALLY_ONCE) { - ReVancedUtils.showToastLong("Skip-once behavior not allowed for " + category.key); + Utils.showToastLong("Skip-once behavior not allowed for " + category.key); category.behaviour = CategoryBehaviour.SKIP_AUTOMATICALLY; // use closest match } else { category.behaviour = behaviour; @@ -113,16 +113,16 @@ public static void importSettings(@NonNull String json) { SettingsEnum.SB_LOCAL_TIME_SAVED_MILLISECONDS.saveValue((long) (minutesSaved * 60 * 1000)); } - ReVancedUtils.showToastLong(str("revanced_sb_settings_import_successful")); + Utils.showToastLong(str("revanced_sb_settings_import_successful")); } catch (Exception ex) { LogHelper.printInfo(() -> "failed to import settings", ex); // use info level, as we are showing our own toast - ReVancedUtils.showToastLong(str("revanced_sb_settings_import_failed", ex.getMessage())); + Utils.showToastLong(str("revanced_sb_settings_import_failed", ex.getMessage())); } } @NonNull public static String exportSettings() { - ReVancedUtils.verifyOnMainThread(); + Utils.verifyOnMainThread(); try { LogHelper.printDebug(() -> "Creating SponsorBlock export settings string"); JSONObject json = new JSONObject(); @@ -162,7 +162,7 @@ public static String exportSettings() { return json.toString(2); } catch (Exception ex) { LogHelper.printInfo(() -> "failed to export settings", ex); // use info level, as we are showing our own toast - ReVancedUtils.showToastLong(str("revanced_sb_settings_export_failed", ex)); + Utils.showToastLong(str("revanced_sb_settings_export_failed", ex)); return ""; } } @@ -172,7 +172,7 @@ public static String exportSettings() { */ public static void exportCategoriesToFlatJson(@Nullable Context dialogContext, @NonNull JSONObject json) throws JSONException { - ReVancedUtils.verifyOnMainThread(); + Utils.verifyOnMainThread(); initialize(); // If user has a SponsorBlock user id then show a warning. @@ -198,7 +198,7 @@ public static void exportCategoriesToFlatJson(@Nullable Context dialogContext, * @return the number of settings imported */ public static int importCategoriesFromFlatJson(JSONObject json) throws JSONException { - ReVancedUtils.verifyOnMainThread(); + Utils.verifyOnMainThread(); initialize(); int numberOfImportedSettings = 0; 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 b966b961e3..ab3eb26519 100644 --- a/app/src/main/java/app/revanced/integrations/sponsorblock/SponsorBlockUtils.java +++ b/app/src/main/java/app/revanced/integrations/sponsorblock/SponsorBlockUtils.java @@ -28,7 +28,7 @@ import app.revanced.integrations.sponsorblock.requests.SBRequester; import app.revanced.integrations.sponsorblock.ui.SponsorBlockViewController; import app.revanced.integrations.utils.LogHelper; -import app.revanced.integrations.utils.ReVancedUtils; +import app.revanced.integrations.utils.Utils; /** * Not thread safe. All fields/methods must be accessed from the main thread. @@ -74,7 +74,7 @@ public void onClick(DialogInterface dialog, int which) { SegmentCategory category = SegmentCategory.categoriesWithoutHighlights()[which]; final boolean enableButton; if (category.behaviour == CategoryBehaviour.IGNORE) { - ReVancedUtils.showToastLong(str("revanced_sb_new_segment_disabled_category")); + Utils.showToastLong(str("revanced_sb_new_segment_disabled_category")); enableButton = false; } else { newUserCreatedSegmentCategory = category; @@ -213,7 +213,7 @@ static void clearUnsubmittedSegmentTimes() { private static void submitNewSegment() { try { - ReVancedUtils.verifyOnMainThread(); + Utils.verifyOnMainThread(); final long start = newSponsorSegmentStartMillis; final long end = newSponsorSegmentEndMillis; final String videoId = VideoInformation.getVideoId(); @@ -224,7 +224,7 @@ private static void submitNewSegment() { return; } clearUnsubmittedSegmentTimes(); - ReVancedUtils.runOnBackgroundThread(() -> { + Utils.runOnBackgroundThread(() -> { SBRequester.submitSegments(videoId, segmentCategory.key, start, end, videoLength); SegmentPlaybackController.executeDownloadSegments(videoId); }); @@ -235,7 +235,7 @@ private static void submitNewSegment() { public static void onMarkLocationClicked() { try { - ReVancedUtils.verifyOnMainThread(); + Utils.verifyOnMainThread(); newSponsorSegmentDialogShownMillis = VideoInformation.getVideoTime(); new AlertDialog.Builder(SponsorBlockViewController.getOverLaysViewGroupContext()) @@ -255,13 +255,13 @@ public static void onMarkLocationClicked() { public static void onPublishClicked() { try { - ReVancedUtils.verifyOnMainThread(); + Utils.verifyOnMainThread(); if (newSponsorSegmentStartMillis < 0 || newSponsorSegmentEndMillis < 0) { - ReVancedUtils.showToastShort(str("revanced_sb_new_segment_mark_locations_first")); + Utils.showToastShort(str("revanced_sb_new_segment_mark_locations_first")); } else if (newSponsorSegmentStartMillis >= newSponsorSegmentEndMillis) { - ReVancedUtils.showToastShort(str("revanced_sb_new_segment_start_is_before_end")); + Utils.showToastShort(str("revanced_sb_new_segment_start_is_before_end")); } else if (!newSponsorSegmentPreviewed && newSponsorSegmentStartMillis != 0) { - ReVancedUtils.showToastLong(str("revanced_sb_new_segment_preview_segment_first")); + Utils.showToastLong(str("revanced_sb_new_segment_preview_segment_first")); } else { long length = (newSponsorSegmentEndMillis - newSponsorSegmentStartMillis) / 1000; long start = (newSponsorSegmentStartMillis) / 1000; @@ -283,13 +283,13 @@ public static void onPublishClicked() { public static void onVotingClicked(@NonNull Context context) { try { - ReVancedUtils.verifyOnMainThread(); + Utils.verifyOnMainThread(); SponsorSegment[] segments = SegmentPlaybackController.getSegments(); if (segments == null || segments.length == 0) { // Button is hidden if no segments exist. // But if prior video had segments, and current video does not, // then the button persists until the overlay fades out (this is intentional, as abruptly hiding the button is jarring). - ReVancedUtils.showToastShort(str("revanced_sb_vote_no_segments")); + Utils.showToastShort(str("revanced_sb_vote_no_segments")); return; } @@ -337,7 +337,7 @@ public static void onVotingClicked(@NonNull Context context) { private static void onNewCategorySelect(@NonNull SponsorSegment segment, @NonNull Context context) { try { - ReVancedUtils.verifyOnMainThread(); + Utils.verifyOnMainThread(); final SegmentCategory[] values = SegmentCategory.categoriesWithoutHighlights(); CharSequence[] titles = new CharSequence[values.length]; for (int i = 0; i < values.length; i++) { @@ -355,11 +355,11 @@ private static void onNewCategorySelect(@NonNull SponsorSegment segment, @NonNul public static void onPreviewClicked() { try { - ReVancedUtils.verifyOnMainThread(); + Utils.verifyOnMainThread(); if (newSponsorSegmentStartMillis < 0 || newSponsorSegmentEndMillis < 0) { - ReVancedUtils.showToastShort(str("revanced_sb_new_segment_mark_locations_first")); + Utils.showToastShort(str("revanced_sb_new_segment_mark_locations_first")); } else if (newSponsorSegmentStartMillis >= newSponsorSegmentEndMillis) { - ReVancedUtils.showToastShort(str("revanced_sb_new_segment_start_is_before_end")); + Utils.showToastShort(str("revanced_sb_new_segment_start_is_before_end")); } else { SegmentPlaybackController.removeUnsubmittedSegments(); // If user hits preview more than once before playing. SegmentPlaybackController.addUnsubmittedSegment( @@ -383,13 +383,13 @@ static void sendViewRequestAsync(@NonNull SponsorSegment segment) { SettingsEnum.SB_LOCAL_TIME_SAVED_NUMBER_SEGMENTS.saveValue(SettingsEnum.SB_LOCAL_TIME_SAVED_NUMBER_SEGMENTS.getInt() + 1); if (SettingsEnum.SB_TRACK_SKIP_COUNT.getBoolean()) { - ReVancedUtils.runOnBackgroundThread(() -> SBRequester.sendSegmentSkippedViewedRequest(segment)); + Utils.runOnBackgroundThread(() -> SBRequester.sendSegmentSkippedViewedRequest(segment)); } } public static void onEditByHandClicked() { try { - ReVancedUtils.verifyOnMainThread(); + Utils.verifyOnMainThread(); new AlertDialog.Builder(SponsorBlockViewController.getOverLaysViewGroupContext()) .setTitle(str("revanced_sb_new_segment_edit_by_hand_title")) .setMessage(str("revanced_sb_new_segment_edit_by_hand_content")) @@ -443,7 +443,7 @@ public void onClick(DialogInterface dialog, int which) { DialogInterface.BUTTON_NEGATIVE : DialogInterface.BUTTON_POSITIVE); } catch (ParseException e) { - ReVancedUtils.showToastLong(str("revanced_sb_new_segment_edit_by_hand_parse_error")); + Utils.showToastLong(str("revanced_sb_new_segment_edit_by_hand_parse_error")); } catch (Exception ex) { LogHelper.printException(() -> "EditByHandSaveDialogListener failure", ex); } diff --git a/app/src/main/java/app/revanced/integrations/sponsorblock/objects/CategoryBehaviour.java b/app/src/main/java/app/revanced/integrations/sponsorblock/objects/CategoryBehaviour.java index 3ebd1effb9..f680300f37 100644 --- a/app/src/main/java/app/revanced/integrations/sponsorblock/objects/CategoryBehaviour.java +++ b/app/src/main/java/app/revanced/integrations/sponsorblock/objects/CategoryBehaviour.java @@ -7,7 +7,7 @@ import java.util.Objects; -import app.revanced.integrations.utils.ReVancedUtils; +import app.revanced.integrations.utils.Utils; import app.revanced.integrations.utils.StringRef; public enum CategoryBehaviour { @@ -63,7 +63,7 @@ public static CategoryBehaviour byDesktopKey(int desktopKey) { private static String[] behaviorDescriptionsWithoutSkipOnce; private static void createNameAndKeyArrays() { - ReVancedUtils.verifyOnMainThread(); + Utils.verifyOnMainThread(); CategoryBehaviour[] behaviours = values(); final int behaviorLength = behaviours.length; diff --git a/app/src/main/java/app/revanced/integrations/sponsorblock/objects/SegmentCategoryListPreference.java b/app/src/main/java/app/revanced/integrations/sponsorblock/objects/SegmentCategoryListPreference.java index adc03e3084..e9286b8a9b 100644 --- a/app/src/main/java/app/revanced/integrations/sponsorblock/objects/SegmentCategoryListPreference.java +++ b/app/src/main/java/app/revanced/integrations/sponsorblock/objects/SegmentCategoryListPreference.java @@ -20,7 +20,7 @@ import java.util.Objects; import app.revanced.integrations.utils.LogHelper; -import app.revanced.integrations.utils.ReVancedUtils; +import app.revanced.integrations.utils.Utils; public class SegmentCategoryListPreference extends ListPreference { private final SegmentCategory category; @@ -110,7 +110,7 @@ public void afterTextChanged(Editable s) { category.save(editor); editor.apply(); updateTitle(); - ReVancedUtils.showToastShort(str("revanced_sb_color_reset")); + Utils.showToastShort(str("revanced_sb_color_reset")); } catch (Exception ex) { LogHelper.printException(() -> "setNeutralButton failure", ex); } @@ -139,10 +139,10 @@ protected void onDialogClosed(boolean positiveResult) { final int color = Color.parseColor(colorString) & 0xFFFFFF; if (color != category.color) { category.setColor(color); - ReVancedUtils.showToastShort(str("revanced_sb_color_changed")); + Utils.showToastShort(str("revanced_sb_color_changed")); } } catch (IllegalArgumentException ex) { - ReVancedUtils.showToastShort(str("revanced_sb_color_invalid")); + Utils.showToastShort(str("revanced_sb_color_invalid")); } // behavior is already saved, but color needs to be saved SharedPreferences.Editor editor = getSharedPreferences().edit(); 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 89ed4c106e..6f901f421f 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 @@ -26,7 +26,7 @@ import app.revanced.integrations.sponsorblock.objects.SponsorSegment.SegmentVote; import app.revanced.integrations.sponsorblock.objects.UserStats; import app.revanced.integrations.utils.LogHelper; -import app.revanced.integrations.utils.ReVancedUtils; +import app.revanced.integrations.utils.Utils; public class SBRequester { private static final String TIME_TEMPLATE = "%.3f"; @@ -51,7 +51,7 @@ private SBRequester() { private static void handleConnectionError(@NonNull String toastMessage, @Nullable Exception ex) { if (SettingsEnum.SB_TOAST_ON_CONNECTION_ERROR.getBoolean()) { - ReVancedUtils.showToastShort(toastMessage); + Utils.showToastShort(toastMessage); } if (ex != null) { LogHelper.printInfo(() -> toastMessage, ex); @@ -60,7 +60,7 @@ private static void handleConnectionError(@NonNull String toastMessage, @Nullabl @NonNull public static SponsorSegment[] getSegments(@NonNull String videoId) { - ReVancedUtils.verifyOffMainThread(); + Utils.verifyOffMainThread(); List segments = new ArrayList<>(); try { HttpURLConnection connection = getConnectionFromRoute(SBRoutes.GET_SEGMENTS, videoId, SegmentCategory.sponsorBlockAPIFetchCategories); @@ -140,7 +140,7 @@ public static SponsorSegment[] getSegments(@NonNull String videoId) { public static void submitSegments(@NonNull String videoId, @NonNull String category, long startTime, long endTime, long videoLength) { - ReVancedUtils.verifyOffMainThread(); + Utils.verifyOffMainThread(); try { String privateUserId = SponsorBlockSettings.getSBPrivateUserID(); String start = String.format(Locale.US, TIME_TEMPLATE, startTime / 1000f); @@ -171,19 +171,19 @@ public static void submitSegments(@NonNull String videoId, @NonNull String categ messageToToast = str("revanced_sb_submit_failed_unknown_error", responseCode, connection.getResponseMessage()); break; } - ReVancedUtils.showToastLong(messageToToast); + Utils.showToastLong(messageToToast); } catch (SocketTimeoutException ex) { // Always show, even if show connection toasts is turned off - ReVancedUtils.showToastLong(str("revanced_sb_submit_failed_timeout")); + Utils.showToastLong(str("revanced_sb_submit_failed_timeout")); } catch (IOException ex) { - ReVancedUtils.showToastLong(str("revanced_sb_submit_failed_unknown_error", 0, ex.getMessage())); + Utils.showToastLong(str("revanced_sb_submit_failed_unknown_error", 0, ex.getMessage())); } catch (Exception ex) { LogHelper.printException(() -> "failed to submit segments", ex); } } public static void sendSegmentSkippedViewedRequest(@NonNull SponsorSegment segment) { - ReVancedUtils.verifyOffMainThread(); + Utils.verifyOffMainThread(); try { HttpURLConnection connection = getConnectionFromRoute(SBRoutes.VIEWED_SEGMENT, segment.UUID); final int responseCode = connection.getResponseCode(); @@ -208,7 +208,7 @@ public static void voteToChangeCategoryOnBackgroundThread(@NonNull SponsorSegmen voteOrRequestCategoryChange(segment, SegmentVote.CATEGORY_CHANGE, categoryToVoteFor); } private static void voteOrRequestCategoryChange(@NonNull SponsorSegment segment, @NonNull SegmentVote voteOption, SegmentCategory categoryToVoteFor) { - ReVancedUtils.runOnBackgroundThread(() -> { + Utils.runOnBackgroundThread(() -> { try { String segmentUuid = segment.UUID; String uuid = SponsorBlockSettings.getSBPrivateUserID(); @@ -222,18 +222,18 @@ private static void voteOrRequestCategoryChange(@NonNull SponsorSegment segment, LogHelper.printDebug(() -> "Vote success for segment: " + segment); break; case 403: - ReVancedUtils.showToastLong( + Utils.showToastLong( str("revanced_sb_vote_failed_forbidden", Requester.parseErrorJsonAndDisconnect(connection))); break; default: - ReVancedUtils.showToastLong( + Utils.showToastLong( str("revanced_sb_vote_failed_unknown_error", responseCode, connection.getResponseMessage())); break; } } catch (SocketTimeoutException ex) { - ReVancedUtils.showToastShort(str("revanced_sb_vote_failed_timeout")); + Utils.showToastShort(str("revanced_sb_vote_failed_timeout")); } catch (IOException ex) { - ReVancedUtils.showToastShort(str("revanced_sb_vote_failed_unknown_error", 0, ex.getMessage())); + Utils.showToastShort(str("revanced_sb_vote_failed_unknown_error", 0, ex.getMessage())); } catch (Exception ex) { LogHelper.printException(() -> "failed to vote for segment", ex); // should never happen } @@ -245,7 +245,7 @@ private static void voteOrRequestCategoryChange(@NonNull SponsorSegment segment, */ @Nullable public static UserStats retrieveUserStats() { - ReVancedUtils.verifyOffMainThread(); + Utils.verifyOffMainThread(); try { UserStats stats = new UserStats(getJSONObject(SBRoutes.GET_USER_STATS, SponsorBlockSettings.getSBPrivateUserID())); LogHelper.printDebug(() -> "user stats: " + stats); @@ -263,7 +263,7 @@ public static UserStats retrieveUserStats() { */ @Nullable public static String setUsername(@NonNull String username) { - ReVancedUtils.verifyOffMainThread(); + Utils.verifyOffMainThread(); try { HttpURLConnection connection = getConnectionFromRoute(SBRoutes.CHANGE_USERNAME, SponsorBlockSettings.getSBPrivateUserID(), username); final int responseCode = connection.getResponseCode(); @@ -286,7 +286,7 @@ public static void runVipCheckInBackgroundIfNeeded() { if (now < (SettingsEnum.SB_LAST_VIP_CHECK.getLong() + TimeUnit.DAYS.toMillis(3))) { return; } - ReVancedUtils.runOnBackgroundThread(() -> { + Utils.runOnBackgroundThread(() -> { try { JSONObject json = getJSONObject(SBRoutes.IS_USER_VIP, SponsorBlockSettings.getSBPrivateUserID()); boolean vip = json.getBoolean("vip"); diff --git a/app/src/main/java/app/revanced/integrations/sponsorblock/ui/CreateSegmentButtonController.java b/app/src/main/java/app/revanced/integrations/sponsorblock/ui/CreateSegmentButtonController.java index 6c0875ca62..7ee6dce168 100644 --- a/app/src/main/java/app/revanced/integrations/sponsorblock/ui/CreateSegmentButtonController.java +++ b/app/src/main/java/app/revanced/integrations/sponsorblock/ui/CreateSegmentButtonController.java @@ -1,6 +1,6 @@ package app.revanced.integrations.sponsorblock.ui; -import static app.revanced.integrations.utils.ReVancedUtils.getResourceIdentifier; +import static app.revanced.integrations.utils.Utils.getResourceIdentifier; import android.view.View; import android.widget.ImageView; @@ -11,7 +11,7 @@ import app.revanced.integrations.patches.VideoInformation; import app.revanced.integrations.settings.SettingsEnum; import app.revanced.integrations.utils.LogHelper; -import app.revanced.integrations.utils.ReVancedUtils; +import app.revanced.integrations.utils.Utils; import app.revanced.integrations.videoplayer.BottomControlButton; public class CreateSegmentButtonController { @@ -96,7 +96,7 @@ public static void hide() { if (!isShowing) { return; } - ReVancedUtils.verifyOnMainThread(); + Utils.verifyOnMainThread(); View v = buttonReference.get(); if (v == null) { return; diff --git a/app/src/main/java/app/revanced/integrations/sponsorblock/ui/NewSegmentLayout.java b/app/src/main/java/app/revanced/integrations/sponsorblock/ui/NewSegmentLayout.java index 12f92111c4..51c326f762 100644 --- a/app/src/main/java/app/revanced/integrations/sponsorblock/ui/NewSegmentLayout.java +++ b/app/src/main/java/app/revanced/integrations/sponsorblock/ui/NewSegmentLayout.java @@ -13,8 +13,8 @@ import app.revanced.integrations.sponsorblock.SponsorBlockUtils; import app.revanced.integrations.utils.LogHelper; -import static app.revanced.integrations.utils.ReVancedUtils.getResourceDimensionPixelSize; -import static app.revanced.integrations.utils.ReVancedUtils.getResourceIdentifier; +import static app.revanced.integrations.utils.Utils.getResourceDimensionPixelSize; +import static app.revanced.integrations.utils.Utils.getResourceIdentifier; public final class NewSegmentLayout extends FrameLayout { private static final ColorStateList rippleColorStateList = new ColorStateList( diff --git a/app/src/main/java/app/revanced/integrations/sponsorblock/ui/SkipSponsorButton.java b/app/src/main/java/app/revanced/integrations/sponsorblock/ui/SkipSponsorButton.java index 7f0a257f1b..21b59806fc 100644 --- a/app/src/main/java/app/revanced/integrations/sponsorblock/ui/SkipSponsorButton.java +++ b/app/src/main/java/app/revanced/integrations/sponsorblock/ui/SkipSponsorButton.java @@ -1,9 +1,9 @@ package app.revanced.integrations.sponsorblock.ui; -import static app.revanced.integrations.utils.ReVancedUtils.getResourceColor; -import static app.revanced.integrations.utils.ReVancedUtils.getResourceDimension; -import static app.revanced.integrations.utils.ReVancedUtils.getResourceDimensionPixelSize; -import static app.revanced.integrations.utils.ReVancedUtils.getResourceIdentifier; +import static app.revanced.integrations.utils.Utils.getResourceColor; +import static app.revanced.integrations.utils.Utils.getResourceDimension; +import static app.revanced.integrations.utils.Utils.getResourceDimensionPixelSize; +import static app.revanced.integrations.utils.Utils.getResourceIdentifier; import android.content.Context; import android.graphics.Canvas; diff --git a/app/src/main/java/app/revanced/integrations/sponsorblock/ui/SponsorBlockViewController.java b/app/src/main/java/app/revanced/integrations/sponsorblock/ui/SponsorBlockViewController.java index 987efe2cac..a9713aa3ce 100644 --- a/app/src/main/java/app/revanced/integrations/sponsorblock/ui/SponsorBlockViewController.java +++ b/app/src/main/java/app/revanced/integrations/sponsorblock/ui/SponsorBlockViewController.java @@ -1,6 +1,6 @@ package app.revanced.integrations.sponsorblock.ui; -import static app.revanced.integrations.utils.ReVancedUtils.getResourceIdentifier; +import static app.revanced.integrations.utils.Utils.getResourceIdentifier; import android.content.Context; import android.view.LayoutInflater; @@ -18,7 +18,7 @@ import app.revanced.integrations.shared.PlayerType; import app.revanced.integrations.sponsorblock.objects.SponsorSegment; import app.revanced.integrations.utils.LogHelper; -import app.revanced.integrations.utils.ReVancedUtils; +import app.revanced.integrations.utils.Utils; public class SponsorBlockViewController { private static WeakReference inlineSponsorOverlayRef = new WeakReference<>(null); @@ -58,7 +58,7 @@ public static void initialize(ViewGroup viewGroup) { // hide any old components, just in case they somehow are still hanging around hideAll(); - Context context = ReVancedUtils.getContext(); + Context context = Utils.getContext(); RelativeLayout layout = new RelativeLayout(context); layout.setLayoutParams(new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT,RelativeLayout.LayoutParams.MATCH_PARENT)); LayoutInflater.from(context).inflate(getResourceIdentifier("inline_sponsor_overlay", "layout"), layout); diff --git a/app/src/main/java/app/revanced/integrations/sponsorblock/ui/VotingButtonController.java b/app/src/main/java/app/revanced/integrations/sponsorblock/ui/VotingButtonController.java index 1211497826..2602316c3d 100644 --- a/app/src/main/java/app/revanced/integrations/sponsorblock/ui/VotingButtonController.java +++ b/app/src/main/java/app/revanced/integrations/sponsorblock/ui/VotingButtonController.java @@ -1,6 +1,6 @@ package app.revanced.integrations.sponsorblock.ui; -import static app.revanced.integrations.utils.ReVancedUtils.getResourceIdentifier; +import static app.revanced.integrations.utils.Utils.getResourceIdentifier; import android.view.View; import android.widget.ImageView; @@ -13,7 +13,7 @@ import app.revanced.integrations.sponsorblock.SegmentPlaybackController; import app.revanced.integrations.sponsorblock.SponsorBlockUtils; import app.revanced.integrations.utils.LogHelper; -import app.revanced.integrations.utils.ReVancedUtils; +import app.revanced.integrations.utils.Utils; import app.revanced.integrations.videoplayer.BottomControlButton; public class VotingButtonController { @@ -98,7 +98,7 @@ public static void hide() { if (!isShowing) { return; } - ReVancedUtils.verifyOnMainThread(); + Utils.verifyOnMainThread(); View v = buttonReference.get(); if (v == null) { return; diff --git a/app/src/main/java/app/revanced/integrations/swipecontrols/controller/SwipeZonesController.kt b/app/src/main/java/app/revanced/integrations/swipecontrols/controller/SwipeZonesController.kt index efa05429ad..33ff4a0a03 100644 --- a/app/src/main/java/app/revanced/integrations/swipecontrols/controller/SwipeZonesController.kt +++ b/app/src/main/java/app/revanced/integrations/swipecontrols/controller/SwipeZonesController.kt @@ -5,7 +5,7 @@ import android.util.TypedValue import android.view.ViewGroup import app.revanced.integrations.swipecontrols.misc.Rectangle import app.revanced.integrations.swipecontrols.misc.applyDimension -import app.revanced.integrations.utils.ReVancedUtils +import app.revanced.integrations.utils.Utils import kotlin.math.min /** @@ -56,7 +56,7 @@ class SwipeZonesController( /** * id for R.id.player_view */ - private val playerViewId = ReVancedUtils.getResourceIdentifier(host, "player_view", "id") + private val playerViewId = Utils.getResourceIdentifier(host, "player_view", "id") /** * current bounding rectangle of the player diff --git a/app/src/main/java/app/revanced/integrations/swipecontrols/views/SwipeControlsOverlayLayout.kt b/app/src/main/java/app/revanced/integrations/swipecontrols/views/SwipeControlsOverlayLayout.kt index 9378b93a95..b13a69769b 100644 --- a/app/src/main/java/app/revanced/integrations/swipecontrols/views/SwipeControlsOverlayLayout.kt +++ b/app/src/main/java/app/revanced/integrations/swipecontrols/views/SwipeControlsOverlayLayout.kt @@ -14,7 +14,7 @@ import android.widget.TextView import app.revanced.integrations.swipecontrols.SwipeControlsConfigurationProvider import app.revanced.integrations.swipecontrols.misc.SwipeControlsOverlay import app.revanced.integrations.swipecontrols.misc.applyDimension -import app.revanced.integrations.utils.ReVancedUtils +import app.revanced.integrations.utils.Utils import kotlin.math.round /** @@ -39,7 +39,7 @@ class SwipeControlsOverlayLayout( private fun getDrawable(name: String, width: Int, height: Int): Drawable { return resources.getDrawable( - ReVancedUtils.getResourceIdentifier(context, name, "drawable"), + Utils.getResourceIdentifier(context, name, "drawable"), context.theme ).apply { setTint(config.overlayForegroundColor) 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 b0f96635b2..724ebf0d70 100644 --- a/app/src/main/java/app/revanced/integrations/utils/LogHelper.java +++ b/app/src/main/java/app/revanced/integrations/utils/LogHelper.java @@ -129,7 +129,7 @@ public static void printException(@NonNull LogMessage message, @Nullable Throwab String toastMessageToDisplay = (userToastMessage != null) ? userToastMessage : outerClassSimpleName + ": " + messageString; - ReVancedUtils.showToastLong(toastMessageToDisplay); + Utils.showToastLong(toastMessageToDisplay); } } diff --git a/app/src/main/java/app/revanced/integrations/utils/StringRef.java b/app/src/main/java/app/revanced/integrations/utils/StringRef.java index e30a1d7d76..fe2653b371 100644 --- a/app/src/main/java/app/revanced/integrations/utils/StringRef.java +++ b/app/src/main/java/app/revanced/integrations/utils/StringRef.java @@ -102,7 +102,7 @@ public StringRef(@NonNull String resName) { public String toString() { if (!resolved) { if (resources == null || packageName == null) { - Context context = ReVancedUtils.getContext(); + Context context = Utils.getContext(); resources = context.getResources(); packageName = context.getPackageName(); } diff --git a/app/src/main/java/app/revanced/integrations/utils/ThemeHelper.java b/app/src/main/java/app/revanced/integrations/utils/ThemeHelper.java index 99fe57d33e..ee64eefe0b 100644 --- a/app/src/main/java/app/revanced/integrations/utils/ThemeHelper.java +++ b/app/src/main/java/app/revanced/integrations/utils/ThemeHelper.java @@ -21,7 +21,7 @@ public static void setActivityTheme(Activity activity) { final var theme = isDarkTheme() ? "Theme.YouTube.Settings.Dark" : "Theme.YouTube.Settings"; - activity.setTheme(ReVancedUtils.getResourceIdentifier(theme, "style")); + activity.setTheme(Utils.getResourceIdentifier(theme, "style")); } } diff --git a/app/src/main/java/app/revanced/integrations/utils/ReVancedUtils.java b/app/src/main/java/app/revanced/integrations/utils/Utils.java similarity index 99% rename from app/src/main/java/app/revanced/integrations/utils/ReVancedUtils.java rename to app/src/main/java/app/revanced/integrations/utils/Utils.java index 286a03bf23..aac1fcbc84 100644 --- a/app/src/main/java/app/revanced/integrations/utils/ReVancedUtils.java +++ b/app/src/main/java/app/revanced/integrations/utils/Utils.java @@ -20,12 +20,12 @@ import java.util.Objects; import java.util.concurrent.*; -public class ReVancedUtils { +public class Utils { @SuppressLint("StaticFieldLeak") public static Context context; - private ReVancedUtils() { + private Utils() { } // utility class /** diff --git a/app/src/main/java/app/revanced/integrations/videoplayer/BottomControlButton.java b/app/src/main/java/app/revanced/integrations/videoplayer/BottomControlButton.java index dc30ad5cbf..30891ba102 100644 --- a/app/src/main/java/app/revanced/integrations/videoplayer/BottomControlButton.java +++ b/app/src/main/java/app/revanced/integrations/videoplayer/BottomControlButton.java @@ -13,7 +13,7 @@ import app.revanced.integrations.settings.SettingsEnum; import app.revanced.integrations.utils.LogHelper; -import app.revanced.integrations.utils.ReVancedUtils; +import app.revanced.integrations.utils.Utils; public abstract class BottomControlButton { private static final Animation fadeIn; @@ -25,11 +25,11 @@ public abstract class BottomControlButton { static { // TODO: check if these durations are correct. - fadeIn = ReVancedUtils.getResourceAnimation("fade_in"); - fadeIn.setDuration(ReVancedUtils.getResourceInteger("fade_duration_fast")); + fadeIn = Utils.getResourceAnimation("fade_in"); + fadeIn.setDuration(Utils.getResourceInteger("fade_duration_fast")); - fadeOut = ReVancedUtils.getResourceAnimation("fade_out"); - fadeOut.setDuration(ReVancedUtils.getResourceInteger("fade_duration_scheduled")); + fadeOut = Utils.getResourceAnimation("fade_out"); + fadeOut.setDuration(Utils.getResourceInteger("fade_duration_scheduled")); } @NonNull @@ -54,7 +54,7 @@ public BottomControlButton(@NonNull ViewGroup bottomControlsViewGroup, @NonNull // Create the button. ImageView imageView = Objects.requireNonNull(bottomControlsViewGroup.findViewById( - ReVancedUtils.getResourceIdentifier(imageViewButtonId, "id") + Utils.getResourceIdentifier(imageViewButtonId, "id") )); imageView.setOnClickListener(onClickListener); if (longClickListener != null) { diff --git a/app/src/main/java/app/revanced/integrations/videoplayer/ExternalDownloadButton.java b/app/src/main/java/app/revanced/integrations/videoplayer/ExternalDownloadButton.java index 3fdb2e90dc..891f1dd079 100644 --- a/app/src/main/java/app/revanced/integrations/videoplayer/ExternalDownloadButton.java +++ b/app/src/main/java/app/revanced/integrations/videoplayer/ExternalDownloadButton.java @@ -10,7 +10,7 @@ import app.revanced.integrations.patches.VideoInformation; import app.revanced.integrations.settings.SettingsEnum; import app.revanced.integrations.utils.LogHelper; -import app.revanced.integrations.utils.ReVancedUtils; +import app.revanced.integrations.utils.Utils; import app.revanced.integrations.utils.StringRef; public class ExternalDownloadButton extends BottomControlButton { @@ -61,7 +61,7 @@ private static void onDownloadClick(View view) { // If the package is not installed, show the toast if (!packageEnabled) { - ReVancedUtils.showToastLong(StringRef.str("revanced_external_downloader_not_installed_warning", downloaderPackageName)); + Utils.showToastLong(StringRef.str("revanced_external_downloader_not_installed_warning", downloaderPackageName)); return; } diff --git a/app/src/main/java/app/revanced/tiktok/feedfilter/LikeCountFilter.java b/app/src/main/java/app/revanced/tiktok/feedfilter/LikeCountFilter.java index 02f4482bd8..d278a745a5 100644 --- a/app/src/main/java/app/revanced/tiktok/feedfilter/LikeCountFilter.java +++ b/app/src/main/java/app/revanced/tiktok/feedfilter/LikeCountFilter.java @@ -4,14 +4,14 @@ import com.ss.android.ugc.aweme.feed.model.Aweme; import com.ss.android.ugc.aweme.feed.model.AwemeStatistics; -import app.revanced.tiktok.utils.TikTokUtils; +import app.revanced.tiktok.utils.Utils; public final class LikeCountFilter implements IFilter { final long minLike; final long maxLike; LikeCountFilter() { - long[] minMax = TikTokUtils.parseMinMax(SettingsEnum.MIN_MAX_LIKES); + long[] minMax = Utils.parseMinMax(SettingsEnum.MIN_MAX_LIKES); minLike = minMax[0]; maxLike = minMax[1]; } diff --git a/app/src/main/java/app/revanced/tiktok/feedfilter/ViewCountFilter.java b/app/src/main/java/app/revanced/tiktok/feedfilter/ViewCountFilter.java index 5e7e6ef3bc..0a0b8ba729 100644 --- a/app/src/main/java/app/revanced/tiktok/feedfilter/ViewCountFilter.java +++ b/app/src/main/java/app/revanced/tiktok/feedfilter/ViewCountFilter.java @@ -1,6 +1,6 @@ package app.revanced.tiktok.feedfilter; -import static app.revanced.tiktok.utils.TikTokUtils.parseMinMax; +import static app.revanced.tiktok.utils.Utils.parseMinMax; import com.ss.android.ugc.aweme.feed.model.Aweme; import com.ss.android.ugc.aweme.feed.model.AwemeStatistics; diff --git a/app/src/main/java/app/revanced/tiktok/settings/SettingsEnum.java b/app/src/main/java/app/revanced/tiktok/settings/SettingsEnum.java index 5b60d0f855..00bd0b6ab4 100644 --- a/app/src/main/java/app/revanced/tiktok/settings/SettingsEnum.java +++ b/app/src/main/java/app/revanced/tiktok/settings/SettingsEnum.java @@ -15,7 +15,7 @@ import java.util.Map; import app.revanced.tiktok.utils.LogHelper; -import app.revanced.tiktok.utils.TikTokUtils; +import app.revanced.tiktok.utils.Utils; public enum SettingsEnum { DEBUG("debug", BOOLEAN, FALSE), // Must be first value, otherwise logging during loading will not work. @@ -79,7 +79,7 @@ public static SettingsEnum getSettingsFromPath(@NonNull String str) { private static void loadAllSettings() { try { - Context context = TikTokUtils.getAppContext(); + Context context = Utils.getAppContext(); if (context == null) { Log.e("revanced: SettingsEnum", "Context returned null! Settings NOT initialized"); return; @@ -128,7 +128,7 @@ public static void setValue(SettingsEnum setting, Object newValue) { } public void saveValue(Object newValue) { - Context context = TikTokUtils.getAppContext(); + Context context = Utils.getAppContext(); if (context == null) { LogHelper.printException(SettingsEnum.class, "Context on SaveValue is null!"); return; diff --git a/app/src/main/java/app/revanced/tiktok/settingsmenu/TikTokSettingsFragment.java b/app/src/main/java/app/revanced/tiktok/settingsmenu/TikTokSettingsFragment.java index fc0317241b..a8a6be1698 100644 --- a/app/src/main/java/app/revanced/tiktok/settingsmenu/TikTokSettingsFragment.java +++ b/app/src/main/java/app/revanced/tiktok/settingsmenu/TikTokSettingsFragment.java @@ -29,7 +29,7 @@ import app.revanced.tiktok.settingsmenu.preference.categories.FeedFilterPreferenceCategory; import app.revanced.tiktok.settingsmenu.preference.categories.IntegrationsPreferenceCategory; import app.revanced.tiktok.settingsmenu.preference.categories.SimSpoofPreferenceCategory; -import app.revanced.tiktok.utils.TikTokUtils; +import app.revanced.tiktok.utils.Utils; @SuppressWarnings("deprecation") public class TikTokSettingsFragment extends PreferenceFragment { @@ -66,7 +66,7 @@ public class TikTokSettingsFragment extends PreferenceFragment { LogHelper.printException(() -> "Setting cannot be handled: " + pref.getClass() + " " + pref); return; } - if (TikTokUtils.getAppContext() != null && this.settingsInitialized && setting.rebootApp) { + if (Utils.getAppContext() != null && this.settingsInitialized && setting.rebootApp) { rebootDialog(getActivity()); } } catch (Exception ex) { diff --git a/app/src/main/java/app/revanced/tiktok/settingsmenu/TikTokSettingsMenu.java b/app/src/main/java/app/revanced/tiktok/settingsmenu/TikTokSettingsMenu.java index 749419d712..25b0f8e278 100644 --- a/app/src/main/java/app/revanced/tiktok/settingsmenu/TikTokSettingsMenu.java +++ b/app/src/main/java/app/revanced/tiktok/settingsmenu/TikTokSettingsMenu.java @@ -8,7 +8,7 @@ import android.widget.FrameLayout; import android.widget.LinearLayout; import app.revanced.tiktok.utils.LogHelper; -import app.revanced.tiktok.utils.TikTokUtils; +import app.revanced.tiktok.utils.Utils; import com.bytedance.ies.ugc.aweme.commercialize.compliance.personalization.AdPersonalizationActivity; import java.lang.reflect.Constructor; @@ -60,7 +60,7 @@ public static boolean initializeSettings(AdPersonalizationActivity base) { } private static void startSettingsActivity() { - Context appContext = TikTokUtils.getAppContext(); + Context appContext = Utils.getAppContext(); if (appContext != null) { Intent intent = new Intent(appContext, AdPersonalizationActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); diff --git a/app/src/main/java/app/revanced/tiktok/utils/TikTokUtils.java b/app/src/main/java/app/revanced/tiktok/utils/Utils.java similarity index 91% rename from app/src/main/java/app/revanced/tiktok/utils/TikTokUtils.java rename to app/src/main/java/app/revanced/tiktok/utils/Utils.java index 1f62792444..6b94951396 100644 --- a/app/src/main/java/app/revanced/tiktok/utils/TikTokUtils.java +++ b/app/src/main/java/app/revanced/tiktok/utils/Utils.java @@ -5,7 +5,7 @@ import app.revanced.tiktok.settings.SettingsEnum; -public class TikTokUtils { +public class Utils { @SuppressLint("StaticFieldLeak") public static Context context; @@ -14,7 +14,7 @@ public static Context getAppContext() { if (context != null) { return context; } - LogHelper.printException(TikTokUtils.class, "Context is null!"); + LogHelper.printException(Utils.class, "Context is null!"); return null; } diff --git a/app/src/main/java/app/revanced/twitch/adblock/LuminousService.java b/app/src/main/java/app/revanced/twitch/adblock/LuminousService.java index f049175509..efbc16f6bd 100644 --- a/app/src/main/java/app/revanced/twitch/adblock/LuminousService.java +++ b/app/src/main/java/app/revanced/twitch/adblock/LuminousService.java @@ -1,14 +1,14 @@ package app.revanced.twitch.adblock; import app.revanced.twitch.utils.LogHelper; -import app.revanced.twitch.utils.TwitchUtils; +import app.revanced.twitch.utils.Utils; import okhttp3.HttpUrl; import okhttp3.Request; public class LuminousService implements IAdblockService { @Override public String friendlyName() { - return TwitchUtils.getString("revanced_proxy_luminous"); + return Utils.getString("revanced_proxy_luminous"); } @Override diff --git a/app/src/main/java/app/revanced/twitch/adblock/PurpleAdblockService.java b/app/src/main/java/app/revanced/twitch/adblock/PurpleAdblockService.java index d417f02795..917275cf84 100644 --- a/app/src/main/java/app/revanced/twitch/adblock/PurpleAdblockService.java +++ b/app/src/main/java/app/revanced/twitch/adblock/PurpleAdblockService.java @@ -2,7 +2,7 @@ import app.revanced.twitch.api.RetrofitClient; import app.revanced.twitch.utils.LogHelper; -import app.revanced.twitch.utils.TwitchUtils; +import app.revanced.twitch.utils.Utils; import okhttp3.HttpUrl; import okhttp3.Request; @@ -17,7 +17,7 @@ public class PurpleAdblockService implements IAdblockService { @Override public String friendlyName() { - return TwitchUtils.getString("revanced_proxy_purpleadblock"); + return Utils.getString("revanced_proxy_purpleadblock"); } @Override diff --git a/app/src/main/java/app/revanced/twitch/api/RequestInterceptor.java b/app/src/main/java/app/revanced/twitch/api/RequestInterceptor.java index a87fb8d260..a7ddd852aa 100644 --- a/app/src/main/java/app/revanced/twitch/api/RequestInterceptor.java +++ b/app/src/main/java/app/revanced/twitch/api/RequestInterceptor.java @@ -6,7 +6,7 @@ import app.revanced.twitch.adblock.PurpleAdblockService; import app.revanced.twitch.settings.SettingsEnum; import app.revanced.twitch.utils.LogHelper; -import app.revanced.twitch.utils.TwitchUtils; +import app.revanced.twitch.utils.Utils; import okhttp3.Interceptor; import okhttp3.Response; @@ -46,7 +46,7 @@ public Response intercept(@NonNull Chain chain) throws IOException { if (!available || rewritten == null) { - TwitchUtils.toast(String.format(TwitchUtils.getString("revanced_embedded_ads_service_unavailable"), activeService.friendlyName()), true); + Utils.toast(String.format(Utils.getString("revanced_embedded_ads_service_unavailable"), activeService.friendlyName()), true); return chain.proceed(originalRequest); } @@ -74,7 +74,7 @@ public Response intercept(@NonNull Chain chain) throws IOException { } // maxAttempts exceeded; giving up on using the ad blocker - TwitchUtils.toast(String.format(TwitchUtils.getString("revanced_embedded_ads_service_failed"), activeService.friendlyName()), true); + Utils.toast(String.format(Utils.getString("revanced_embedded_ads_service_failed"), activeService.friendlyName()), true); } @@ -86,11 +86,11 @@ public Response intercept(@NonNull Chain chain) throws IOException { private void updateActiveService() { var current = SettingsEnum.BLOCK_EMBEDDED_ADS.getString(); - if (current.equals(TwitchUtils.getString("key_revanced_proxy_luminous")) && !(activeService instanceof LuminousService)) + if (current.equals(Utils.getString("key_revanced_proxy_luminous")) && !(activeService instanceof LuminousService)) activeService = new LuminousService(); - else if (current.equals(TwitchUtils.getString("key_revanced_proxy_purpleadblock")) && !(activeService instanceof PurpleAdblockService)) + else if (current.equals(Utils.getString("key_revanced_proxy_purpleadblock")) && !(activeService instanceof PurpleAdblockService)) activeService = new PurpleAdblockService(); - else if (current.equals(TwitchUtils.getString("key_revanced_proxy_disabled"))) + else if (current.equals(Utils.getString("key_revanced_proxy_disabled"))) activeService = null; } } diff --git a/app/src/main/java/app/revanced/twitch/patches/ShowDeletedMessagesPatch.java b/app/src/main/java/app/revanced/twitch/patches/ShowDeletedMessagesPatch.java index 6eab1e1083..87cfe23dbd 100644 --- a/app/src/main/java/app/revanced/twitch/patches/ShowDeletedMessagesPatch.java +++ b/app/src/main/java/app/revanced/twitch/patches/ShowDeletedMessagesPatch.java @@ -12,7 +12,7 @@ import java.util.Objects; import app.revanced.twitch.settings.SettingsEnum; -import app.revanced.twitch.utils.TwitchUtils; +import app.revanced.twitch.utils.Utils; import tv.twitch.android.shared.chat.util.ClickableUsernameSpan; public class ShowDeletedMessagesPatch { @@ -37,7 +37,7 @@ public static Spanned reformatDeletedMessage(Spanned original) { SpannableStringBuilder ssb = new SpannableStringBuilder(original); ssb.setSpan(new StrikethroughSpan(), 0, original.length(), 0); - ssb.append(" (").append(TwitchUtils.getString("revanced_deleted_msg")).append(")"); + ssb.append(" (").append(Utils.getString("revanced_deleted_msg")).append(")"); ssb.setSpan(new StyleSpan(Typeface.ITALIC), original.length(), ssb.length(), 0); // Gray-out username diff --git a/app/src/main/java/app/revanced/twitch/settings/SettingsEnum.java b/app/src/main/java/app/revanced/twitch/settings/SettingsEnum.java index df215b722b..e920954b1d 100644 --- a/app/src/main/java/app/revanced/twitch/settings/SettingsEnum.java +++ b/app/src/main/java/app/revanced/twitch/settings/SettingsEnum.java @@ -4,7 +4,7 @@ import android.content.SharedPreferences; import androidx.annotation.NonNull; import app.revanced.twitch.utils.LogHelper; -import app.revanced.twitch.utils.TwitchUtils; +import app.revanced.twitch.utils.Utils; import static app.revanced.twitch.settings.SettingsEnum.ReturnType.BOOLEAN; import static app.revanced.twitch.settings.SettingsEnum.ReturnType.STRING; @@ -55,7 +55,7 @@ public enum SettingsEnum { } private static void loadAllSettings() { - TwitchUtils.ifContextAttached((context -> { + Utils.ifContextAttached((context -> { try { SharedPreferences prefs = context.getSharedPreferences(REVANCED_PREFS, Context.MODE_PRIVATE); for (SettingsEnum setting : values()) { @@ -121,7 +121,7 @@ private void setValue(Object newValue) { } public void saveValue(Object newValue) { - TwitchUtils.ifContextAttached((context) -> { + Utils.ifContextAttached((context) -> { SharedPreferences prefs = context.getSharedPreferences(REVANCED_PREFS, Context.MODE_PRIVATE); if (returnType == BOOLEAN) { prefs.edit().putBoolean(path, (Boolean)newValue).apply(); diff --git a/app/src/main/java/app/revanced/twitch/settingsmenu/TwitchSettingsFragment.java b/app/src/main/java/app/revanced/twitch/settingsmenu/TwitchSettingsFragment.java index b18516329a..9989383fe3 100644 --- a/app/src/main/java/app/revanced/twitch/settingsmenu/TwitchSettingsFragment.java +++ b/app/src/main/java/app/revanced/twitch/settingsmenu/TwitchSettingsFragment.java @@ -22,7 +22,7 @@ import app.revanced.integrations.settingsmenu.SettingsUtils; import app.revanced.twitch.settings.SettingsEnum; import app.revanced.twitch.utils.LogHelper; -import app.revanced.twitch.utils.TwitchUtils; +import app.revanced.twitch.utils.Utils; import tv.twitch.android.app.core.LandingActivity; public class TwitchSettingsFragment extends PreferenceFragment { @@ -62,7 +62,7 @@ else if (pref instanceof ListPreference) { LogHelper.error("Setting '%s' cannot be handled!", pref); } - if (TwitchUtils.getContext() != null && key != null && settingsInitialized && setting.rebootApp) { + if (Utils.getContext() != null && key != null && settingsInitialized && setting.rebootApp) { rebootDialog(getActivity()); } @@ -140,9 +140,9 @@ private void reboot(Activity activity) { private void rebootDialog(final Activity activity) { new AlertDialog.Builder(activity). - setMessage(TwitchUtils.getString("revanced_reboot_message")). - setPositiveButton(TwitchUtils.getString("revanced_reboot"), (dialog, i) -> reboot(activity)) - .setNegativeButton(TwitchUtils.getString("revanced_cancel"), null) + setMessage(Utils.getString("revanced_reboot_message")). + setPositiveButton(Utils.getString("revanced_reboot"), (dialog, i) -> reboot(activity)) + .setNegativeButton(Utils.getString("revanced_cancel"), null) .show(); } } diff --git a/app/src/main/java/app/revanced/twitch/settingsmenu/TwitchSettingsHooks.java b/app/src/main/java/app/revanced/twitch/settingsmenu/TwitchSettingsHooks.java index 43c5d70cd2..6043708f6c 100644 --- a/app/src/main/java/app/revanced/twitch/settingsmenu/TwitchSettingsHooks.java +++ b/app/src/main/java/app/revanced/twitch/settingsmenu/TwitchSettingsHooks.java @@ -1,7 +1,7 @@ package app.revanced.twitch.settingsmenu; -import static app.revanced.twitch.utils.TwitchUtils.getIdentifier; -import static app.revanced.twitch.utils.TwitchUtils.getStringId; +import static app.revanced.twitch.utils.Utils.getIdentifier; +import static app.revanced.twitch.utils.Utils.getStringId; import android.content.Intent; import android.os.Bundle; @@ -12,7 +12,7 @@ import java.util.ArrayList; import java.util.List; -import app.revanced.twitch.utils.TwitchUtils; +import app.revanced.twitch.utils.Utils; import app.revanced.twitch.utils.LogHelper; import tv.twitch.android.feature.settings.menu.SettingsMenuGroup; import tv.twitch.android.settings.SettingsActivity; @@ -27,7 +27,7 @@ public class TwitchSettingsHooks { public static void startSettingsActivity() { LogHelper.debug("Launching ReVanced settings"); - TwitchUtils.ifContextAttached((c) -> { + Utils.ifContextAttached((c) -> { Intent intent = new Intent(c, SettingsActivity.class); Bundle bundle = new Bundle(); bundle.putBoolean(REVANCED_TWITCH_SETTINGS_INTENT_NAME, true); diff --git a/app/src/main/java/app/revanced/twitch/utils/LogHelper.java b/app/src/main/java/app/revanced/twitch/utils/LogHelper.java index 1fc6529d5c..bc94eb2115 100644 --- a/app/src/main/java/app/revanced/twitch/utils/LogHelper.java +++ b/app/src/main/java/app/revanced/twitch/utils/LogHelper.java @@ -48,7 +48,7 @@ public static void printException(String message, Throwable ex) { private static void showDebugToast(String msg) { if(SettingsEnum.DEBUG_MODE.getBoolean()) { - TwitchUtils.toast(msg, false); + Utils.toast(msg, false); } } } diff --git a/app/src/main/java/app/revanced/twitch/utils/TwitchUtils.java b/app/src/main/java/app/revanced/twitch/utils/Utils.java similarity index 99% rename from app/src/main/java/app/revanced/twitch/utils/TwitchUtils.java rename to app/src/main/java/app/revanced/twitch/utils/Utils.java index 9878ca69f9..cd46628ed2 100644 --- a/app/src/main/java/app/revanced/twitch/utils/TwitchUtils.java +++ b/app/src/main/java/app/revanced/twitch/utils/Utils.java @@ -6,7 +6,7 @@ import android.os.Looper; import android.widget.Toast; -public class TwitchUtils { +public class Utils { @SuppressLint("StaticFieldLeak") public static Context context; From 8f1d3c493d808b259bf4a8fa8374a0ade1ead78a Mon Sep 17 00:00:00 2001 From: LisoUseInAIKyrios <118716522+LisoUseInAIKyrios@users.noreply.github.com> Date: Sun, 19 Nov 2023 17:03:26 +0200 Subject: [PATCH 33/48] feat(YouTube):Add `Disable rolling number animations` patch (#519) --- .../patches/DisableRollingNumberAnimationsPatch.java | 12 ++++++++++++ .../revanced/integrations/settings/SettingsEnum.java | 1 + 2 files changed, 13 insertions(+) create mode 100644 app/src/main/java/app/revanced/integrations/patches/DisableRollingNumberAnimationsPatch.java diff --git a/app/src/main/java/app/revanced/integrations/patches/DisableRollingNumberAnimationsPatch.java b/app/src/main/java/app/revanced/integrations/patches/DisableRollingNumberAnimationsPatch.java new file mode 100644 index 0000000000..83a05a1c6f --- /dev/null +++ b/app/src/main/java/app/revanced/integrations/patches/DisableRollingNumberAnimationsPatch.java @@ -0,0 +1,12 @@ +package app.revanced.integrations.patches; + +import app.revanced.integrations.settings.SettingsEnum; + +public class DisableRollingNumberAnimationsPatch { + /** + * Injection point. + */ + public static boolean disableRollingNumberAnimations() { + return SettingsEnum.DISABLE_ROLLING_NUMBER_ANIMATIONS.getBoolean(); + } +} 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 fe011e4724..99f624215a 100644 --- a/app/src/main/java/app/revanced/integrations/settings/SettingsEnum.java +++ b/app/src/main/java/app/revanced/integrations/settings/SettingsEnum.java @@ -62,6 +62,7 @@ public enum SettingsEnum { CUSTOM_FILTER_STRINGS("revanced_custom_filter_strings", STRING, "", true, parents(CUSTOM_FILTER)), DISABLE_FULLSCREEN_AMBIENT_MODE("revanced_disable_fullscreen_ambient_mode", BOOLEAN, TRUE, true), DISABLE_RESUMING_SHORTS_PLAYER("revanced_disable_resuming_shorts_player", BOOLEAN, FALSE), + DISABLE_ROLLING_NUMBER_ANIMATIONS("revanced_disable_rolling_number_animations", BOOLEAN, FALSE), DISABLE_SUGGESTED_VIDEO_END_SCREEN("revanced_disable_suggested_video_end_screen", BOOLEAN, TRUE), GRADIENT_LOADING_SCREEN("revanced_gradient_loading_screen", BOOLEAN, FALSE), HIDE_ALBUM_CARDS("revanced_hide_album_cards", BOOLEAN, FALSE, true), From 3eb07c12dda889f6ed50fb3b6900b2d789bb0c10 Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Sun, 19 Nov 2023 19:46:44 +0100 Subject: [PATCH 34/48] fix(YouTube - Hide layout components): Check if `bytes` parameter of `LayoutComponentsFilter#filterMixPlaylists` for null --- .../patches/components/LayoutComponentsFilter.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/app/revanced/integrations/patches/components/LayoutComponentsFilter.java b/app/src/main/java/app/revanced/integrations/patches/components/LayoutComponentsFilter.java index 7603bc68cf..278bfc2e2c 100644 --- a/app/src/main/java/app/revanced/integrations/patches/components/LayoutComponentsFilter.java +++ b/app/src/main/java/app/revanced/integrations/patches/components/LayoutComponentsFilter.java @@ -247,7 +247,12 @@ public boolean isFiltered(@Nullable String identifier, String path, byte[] proto * Injection point. * Called from a different place then the other filters. */ - public static boolean filterMixPlaylists(final Object conversionContext, final byte[] bytes) { + public static boolean filterMixPlaylists(final Object conversionContext, @Nullable final byte[] bytes) { + if (bytes == null) { + LogHelper.printDebug(() -> "bytes is null"); + return false; + } + // Prevent playlist items being hidden, if a mix playlist is present in it. if (mixPlaylistsExceptions.matches(conversionContext.toString())) return false; From 7ae7e8d3db0970a0d708888753fa662b953c7348 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Sun, 19 Nov 2023 18:49:55 +0000 Subject: [PATCH 35/48] chore(release): 0.122.2-dev.1 [skip ci] ## [0.122.2-dev.1](https://github.com/ReVanced/revanced-integrations/compare/v0.122.1...v0.122.2-dev.1) (2023-11-19) ### Bug Fixes * **YouTube - Hide layout components:** Check if `bytes` parameter of `LayoutComponentsFilter#filterMixPlaylists` for null ([3eb07c1](https://github.com/ReVanced/revanced-integrations/commit/3eb07c12dda889f6ed50fb3b6900b2d789bb0c10)) --- CHANGELOG.md | 7 +++++++ gradle.properties | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6380c03735..90103490c7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +## [0.122.2-dev.1](https://github.com/ReVanced/revanced-integrations/compare/v0.122.1...v0.122.2-dev.1) (2023-11-19) + + +### Bug Fixes + +* **YouTube - Hide layout components:** Check if `bytes` parameter of `LayoutComponentsFilter#filterMixPlaylists` for null ([3eb07c1](https://github.com/ReVanced/revanced-integrations/commit/3eb07c12dda889f6ed50fb3b6900b2d789bb0c10)) + ## [0.122.1](https://github.com/ReVanced/revanced-integrations/compare/v0.122.0...v0.122.1) (2023-11-19) diff --git a/gradle.properties b/gradle.properties index 4fc4b3fce8..df11ed1747 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ org.gradle.parallel = true org.gradle.caching = true android.useAndroidX = true -version = 0.122.1 +version = 0.122.2-dev.1 From 006cb032ef6c9cdda7dde9489310df89f3ea0245 Mon Sep 17 00:00:00 2001 From: LisoUseInAIKyrios <118716522+LisoUseInAIKyrios@users.noreply.github.com> Date: Mon, 20 Nov 2023 13:36:21 +0200 Subject: [PATCH 36/48] Sort groups at the end --- .../revanced/integrations/settingsmenu/SettingsUtils.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/app/revanced/integrations/settingsmenu/SettingsUtils.java b/app/src/main/java/app/revanced/integrations/settingsmenu/SettingsUtils.java index 051e8a9c7b..2ef7f6b5f9 100644 --- a/app/src/main/java/app/revanced/integrations/settingsmenu/SettingsUtils.java +++ b/app/src/main/java/app/revanced/integrations/settingsmenu/SettingsUtils.java @@ -45,7 +45,13 @@ public static void sortPreferenceGroupByTitle(PreferenceGroup group, int menuDep int prefIndex = 0; for (Preference pref : preferences.values()) { - pref.setOrder(prefIndex++); + int indexToSet = prefIndex++; + if (pref instanceof PreferenceGroup) { + // Place preference groups last. + // Use an offset to push the group to the end. + indexToSet += 1000; + } + pref.setOrder(indexToSet); } } From 8e4bdecb541658057dae618c8d1752b75490cb58 Mon Sep 17 00:00:00 2001 From: LisoUseInAIKyrios <118716522+LisoUseInAIKyrios@users.noreply.github.com> Date: Tue, 28 Nov 2023 13:54:20 +0200 Subject: [PATCH 37/48] extract strings --- .../patches/announcements/AnnouncementsPatch.java | 13 +++++-------- .../spoof/requests/StoryboardRendererRequester.java | 7 ++++--- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/app/revanced/integrations/patches/announcements/AnnouncementsPatch.java b/app/src/main/java/app/revanced/integrations/patches/announcements/AnnouncementsPatch.java index 3d9611758f..40917c7147 100644 --- a/app/src/main/java/app/revanced/integrations/patches/announcements/AnnouncementsPatch.java +++ b/app/src/main/java/app/revanced/integrations/patches/announcements/AnnouncementsPatch.java @@ -22,6 +22,7 @@ import static android.text.Html.FROM_HTML_MODE_COMPACT; import static app.revanced.integrations.patches.announcements.requests.AnnouncementsRoutes.GET_LATEST_ANNOUNCEMENT; +import static app.revanced.integrations.utils.StringRef.str; public final class AnnouncementsPatch { private final static String CONSUMER = getOrSetConsumer(); @@ -37,7 +38,7 @@ public static void showAnnouncement(final Activity context) { try { HttpURLConnection connection = AnnouncementsRoutes.getAnnouncementsConnectionFromRoute(GET_LATEST_ANNOUNCEMENT, CONSUMER); - LogHelper.printDebug(() -> "Get latest announcement route connection url: " + connection.getURL().toString()); + LogHelper.printDebug(() -> "Get latest announcement route connection url: " + connection.getURL()); try { // Do not show the announcement if the request failed. @@ -45,14 +46,12 @@ public static void showAnnouncement(final Activity context) { if (SettingsEnum.ANNOUNCEMENT_LAST_HASH.getString().isEmpty()) return; SettingsEnum.ANNOUNCEMENT_LAST_HASH.saveValue(""); - Utils.showToastLong("Failed to get announcement"); + Utils.showToastLong(str("revanced_announcements_connection_failed")); return; } } catch (IOException ex) { - final var message = "Failed connecting to announcements provider"; - - LogHelper.printException(() -> message, ex); + LogHelper.printException(() -> str("revanced_announcements_connection_failed"), ex); return; } @@ -105,9 +104,7 @@ public static void showAnnouncement(final Activity context) { .setMovementMethod(LinkMovementMethod.getInstance()); }); } catch (Exception e) { - final var message = "Failed to get announcement"; - - LogHelper.printException(() -> message, e); + LogHelper.printException(() -> "showAnnouncement failure", e); } }); } diff --git a/app/src/main/java/app/revanced/integrations/patches/spoof/requests/StoryboardRendererRequester.java b/app/src/main/java/app/revanced/integrations/patches/spoof/requests/StoryboardRendererRequester.java index 15b413f5dd..a213c04ee7 100644 --- a/app/src/main/java/app/revanced/integrations/patches/spoof/requests/StoryboardRendererRequester.java +++ b/app/src/main/java/app/revanced/integrations/patches/spoof/requests/StoryboardRendererRequester.java @@ -3,6 +3,7 @@ import static app.revanced.integrations.patches.spoof.requests.PlayerRoutes.ANDROID_INNER_TUBE_BODY; import static app.revanced.integrations.patches.spoof.requests.PlayerRoutes.GET_STORYBOARD_SPEC_RENDERER; import static app.revanced.integrations.patches.spoof.requests.PlayerRoutes.TV_EMBED_INNER_TUBE_BODY; +import static app.revanced.integrations.utils.StringRef.str; import androidx.annotation.NonNull; import androidx.annotation.Nullable; @@ -66,14 +67,14 @@ private static JSONObject fetchPlayerResponse(@NonNull String requestBody, boole if (responseCode == 200) return Requester.parseJSONObject(connection); // Always show a toast for this, as a non 200 response means something is broken. + // Not a normal code path and should not be reached, so no translations are needed. handleConnectionError("Spoof storyboard not available: " + responseCode, null, showToastOnIOException || SettingsEnum.DEBUG_TOAST_ON_ERROR.getBoolean()); connection.disconnect(); } catch (SocketTimeoutException ex) { - handleConnectionError("Spoof storyboard temporarily not available (API timed out)", - ex, showToastOnIOException); + handleConnectionError(str("revanced_spoof_storyboard_timeout"), ex, showToastOnIOException); } catch (IOException ex) { - handleConnectionError("Spoof storyboard temporarily not available: " + ex.getMessage(), + handleConnectionError(str("revanced_spoof_storyboard_io_exception", ex.getMessage()), ex, showToastOnIOException); } catch (Exception ex) { LogHelper.printException(() -> "Spoof storyboard fetch failed", ex); // Should never happen. From 1f661794dd206e080dda0de44a4466db8027ab57 Mon Sep 17 00:00:00 2001 From: LisoUseInAIKyrios <118716522+LisoUseInAIKyrios@users.noreply.github.com> Date: Wed, 29 Nov 2023 11:20:39 +0200 Subject: [PATCH 38/48] no functional changes: move to shared integrations --- .../integrations/settingsmenu/YouTubeSettingsFragment.java | 1 + .../settingsmenu => shared/settings}/SettingsUtils.java | 2 +- .../revanced/twitch/settingsmenu/TwitchSettingsFragment.java | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) rename app/src/main/java/app/revanced/{integrations/settingsmenu => shared/settings}/SettingsUtils.java (97%) diff --git a/app/src/main/java/app/revanced/integrations/settingsmenu/YouTubeSettingsFragment.java b/app/src/main/java/app/revanced/integrations/settingsmenu/YouTubeSettingsFragment.java index 9f5b158f7a..015e09e422 100644 --- a/app/src/main/java/app/revanced/integrations/settingsmenu/YouTubeSettingsFragment.java +++ b/app/src/main/java/app/revanced/integrations/settingsmenu/YouTubeSettingsFragment.java @@ -29,6 +29,7 @@ import app.revanced.integrations.settings.SharedPrefCategory; import app.revanced.integrations.utils.LogHelper; import app.revanced.integrations.utils.Utils; +import app.revanced.shared.settings.SettingsUtils; public class YouTubeSettingsFragment extends PreferenceFragment { /** diff --git a/app/src/main/java/app/revanced/integrations/settingsmenu/SettingsUtils.java b/app/src/main/java/app/revanced/shared/settings/SettingsUtils.java similarity index 97% rename from app/src/main/java/app/revanced/integrations/settingsmenu/SettingsUtils.java rename to app/src/main/java/app/revanced/shared/settings/SettingsUtils.java index 2ef7f6b5f9..999d00087e 100644 --- a/app/src/main/java/app/revanced/integrations/settingsmenu/SettingsUtils.java +++ b/app/src/main/java/app/revanced/shared/settings/SettingsUtils.java @@ -1,4 +1,4 @@ -package app.revanced.integrations.settingsmenu; +package app.revanced.shared.settings; import android.preference.Preference; import android.preference.PreferenceGroup; diff --git a/app/src/main/java/app/revanced/twitch/settingsmenu/TwitchSettingsFragment.java b/app/src/main/java/app/revanced/twitch/settingsmenu/TwitchSettingsFragment.java index 9989383fe3..18bac522e7 100644 --- a/app/src/main/java/app/revanced/twitch/settingsmenu/TwitchSettingsFragment.java +++ b/app/src/main/java/app/revanced/twitch/settingsmenu/TwitchSettingsFragment.java @@ -19,7 +19,7 @@ import androidx.annotation.Nullable; -import app.revanced.integrations.settingsmenu.SettingsUtils; +import app.revanced.shared.settings.SettingsUtils; import app.revanced.twitch.settings.SettingsEnum; import app.revanced.twitch.utils.LogHelper; import app.revanced.twitch.utils.Utils; From 545a20eb2645910f7869573f4de3844980366a89 Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Sat, 30 Dec 2023 04:26:36 +0100 Subject: [PATCH 39/48] fix(YouTube - GmsCore support): Gracefully exit when GmsCore is not running --- .../revanced/integrations/patches/ChangeStartPagePatch.java | 2 +- .../app/revanced/integrations/patches/GmsCoreSupport.java | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/app/revanced/integrations/patches/ChangeStartPagePatch.java b/app/src/main/java/app/revanced/integrations/patches/ChangeStartPagePatch.java index ede239a3ad..b3b6fac202 100644 --- a/app/src/main/java/app/revanced/integrations/patches/ChangeStartPagePatch.java +++ b/app/src/main/java/app/revanced/integrations/patches/ChangeStartPagePatch.java @@ -6,7 +6,7 @@ @SuppressWarnings("unused") public final class ChangeStartPagePatch { - public static void changeIntent(Intent intent) { + public static void changeIntent(final Intent intent) { final var startPage = SettingsEnum.START_PAGE.getString(); if (startPage.isEmpty()) return; diff --git a/app/src/main/java/app/revanced/integrations/patches/GmsCoreSupport.java b/app/src/main/java/app/revanced/integrations/patches/GmsCoreSupport.java index 633b01c202..30e9b51974 100644 --- a/app/src/main/java/app/revanced/integrations/patches/GmsCoreSupport.java +++ b/app/src/main/java/app/revanced/integrations/patches/GmsCoreSupport.java @@ -44,14 +44,16 @@ public static void checkAvailability() { LogHelper.printInfo(() -> "GmsCore was not found", exception); search(context, getGmsCoreDownloadLink(), str("gms_core_not_installed_warning")); - // Gracefully exit the app, so it does not crash. System.exit(0); } try (var client = context.getContentResolver().acquireContentProviderClient(GMS_CORE_PROVIDER)) { if (client != null) return; + LogHelper.printInfo(() -> "GmsCore is not running in the background"); search(context, DONT_KILL_MY_APP_LINK, str("gms_core_not_running_warning")); + + System.exit(0); } } From 354ed0e2a5627da84b3056337e55c4711bf14ee6 Mon Sep 17 00:00:00 2001 From: LisoUseInAIKyrios <118716522+LisoUseInAIKyrios@users.noreply.github.com> Date: Sun, 31 Dec 2023 14:46:23 +0400 Subject: [PATCH 40/48] refactor: use common class name --- .../integrations/settingsmenu/ImportExportPreference.java | 6 +++--- ...ettingsFragment.java => ReVancedPreferenceFragment.java} | 2 +- .../integrations/settingsmenu/YouTubeSettingActivity.java | 2 +- ...ettingsFragment.java => ReVancedPreferenceFragment.java} | 2 +- .../revanced/tiktok/settingsmenu/TikTokSettingsMenu.java | 2 +- ...ettingsFragment.java => ReVancedPreferenceFragment.java} | 2 +- .../revanced/twitch/settingsmenu/TwitchSettingsHooks.java | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-) rename app/src/main/java/app/revanced/integrations/settingsmenu/{YouTubeSettingsFragment.java => ReVancedPreferenceFragment.java} (99%) rename app/src/main/java/app/revanced/tiktok/settingsmenu/{TikTokSettingsFragment.java => ReVancedPreferenceFragment.java} (98%) rename app/src/main/java/app/revanced/twitch/settingsmenu/{TwitchSettingsFragment.java => ReVancedPreferenceFragment.java} (98%) diff --git a/app/src/main/java/app/revanced/integrations/settingsmenu/ImportExportPreference.java b/app/src/main/java/app/revanced/integrations/settingsmenu/ImportExportPreference.java index f8b4d3be51..be712c7258 100644 --- a/app/src/main/java/app/revanced/integrations/settingsmenu/ImportExportPreference.java +++ b/app/src/main/java/app/revanced/integrations/settingsmenu/ImportExportPreference.java @@ -82,15 +82,15 @@ private void importSettings(String replacementSettings) { if (replacementSettings.equals(existingSettings)) { return; } - YouTubeSettingsFragment.settingImportInProgress = true; + ReVancedPreferenceFragment.settingImportInProgress = true; final boolean rebootNeeded = SettingsEnum.importJSON(replacementSettings); if (rebootNeeded) { - YouTubeSettingsFragment.showRestartDialog(getContext()); + ReVancedPreferenceFragment.showRestartDialog(getContext()); } } catch (Exception ex) { LogHelper.printException(() -> "importSettings failure", ex); } finally { - YouTubeSettingsFragment.settingImportInProgress = false; + ReVancedPreferenceFragment.settingImportInProgress = false; } } diff --git a/app/src/main/java/app/revanced/integrations/settingsmenu/YouTubeSettingsFragment.java b/app/src/main/java/app/revanced/integrations/settingsmenu/ReVancedPreferenceFragment.java similarity index 99% rename from app/src/main/java/app/revanced/integrations/settingsmenu/YouTubeSettingsFragment.java rename to app/src/main/java/app/revanced/integrations/settingsmenu/ReVancedPreferenceFragment.java index bfda37feba..fa16e8a5dc 100644 --- a/app/src/main/java/app/revanced/integrations/settingsmenu/YouTubeSettingsFragment.java +++ b/app/src/main/java/app/revanced/integrations/settingsmenu/ReVancedPreferenceFragment.java @@ -24,7 +24,7 @@ import app.revanced.integrations.utils.Utils; import app.revanced.shared.settings.SettingsUtils; -public class YouTubeSettingsFragment extends PreferenceFragment { +public class ReVancedPreferenceFragment extends PreferenceFragment { /** * Indicates that if a preference changes, * to apply the change from the Setting to the UI component. diff --git a/app/src/main/java/app/revanced/integrations/settingsmenu/YouTubeSettingActivity.java b/app/src/main/java/app/revanced/integrations/settingsmenu/YouTubeSettingActivity.java index 05270d8943..3eaccdac74 100644 --- a/app/src/main/java/app/revanced/integrations/settingsmenu/YouTubeSettingActivity.java +++ b/app/src/main/java/app/revanced/integrations/settingsmenu/YouTubeSettingActivity.java @@ -41,7 +41,7 @@ public static void initializeSettings(Activity licenseActivity) { break; case "revanced_settings_intent": toolbarTitleResourceName = "revanced_settings_title"; - fragment = new YouTubeSettingsFragment(); + fragment = new ReVancedPreferenceFragment(); break; default: LogHelper.printException(() -> "Unknown setting: " + dataString); diff --git a/app/src/main/java/app/revanced/tiktok/settingsmenu/TikTokSettingsFragment.java b/app/src/main/java/app/revanced/tiktok/settingsmenu/ReVancedPreferenceFragment.java similarity index 98% rename from app/src/main/java/app/revanced/tiktok/settingsmenu/TikTokSettingsFragment.java rename to app/src/main/java/app/revanced/tiktok/settingsmenu/ReVancedPreferenceFragment.java index 15c4b8ec33..02e97763ac 100644 --- a/app/src/main/java/app/revanced/tiktok/settingsmenu/TikTokSettingsFragment.java +++ b/app/src/main/java/app/revanced/tiktok/settingsmenu/ReVancedPreferenceFragment.java @@ -28,7 +28,7 @@ import app.revanced.tiktok.utils.Utils; @SuppressWarnings("deprecation") -public class TikTokSettingsFragment extends PreferenceFragment { +public class ReVancedPreferenceFragment extends PreferenceFragment { private boolean registered = false; private boolean settingsInitialized = false; diff --git a/app/src/main/java/app/revanced/tiktok/settingsmenu/TikTokSettingsMenu.java b/app/src/main/java/app/revanced/tiktok/settingsmenu/TikTokSettingsMenu.java index 5188d985b8..aa943ca999 100644 --- a/app/src/main/java/app/revanced/tiktok/settingsmenu/TikTokSettingsMenu.java +++ b/app/src/main/java/app/revanced/tiktok/settingsmenu/TikTokSettingsMenu.java @@ -54,7 +54,7 @@ public static boolean initializeSettings(AdPersonalizationActivity base) { linearLayout.addView(fragment); base.setContentView(linearLayout); - PreferenceFragment preferenceFragment = new TikTokSettingsFragment(); + PreferenceFragment preferenceFragment = new ReVancedPreferenceFragment(); base.getFragmentManager().beginTransaction().replace(fragmentId, preferenceFragment).commit(); return true; diff --git a/app/src/main/java/app/revanced/twitch/settingsmenu/TwitchSettingsFragment.java b/app/src/main/java/app/revanced/twitch/settingsmenu/ReVancedPreferenceFragment.java similarity index 98% rename from app/src/main/java/app/revanced/twitch/settingsmenu/TwitchSettingsFragment.java rename to app/src/main/java/app/revanced/twitch/settingsmenu/ReVancedPreferenceFragment.java index 0044cd76c6..3bcf2b3d2c 100644 --- a/app/src/main/java/app/revanced/twitch/settingsmenu/TwitchSettingsFragment.java +++ b/app/src/main/java/app/revanced/twitch/settingsmenu/ReVancedPreferenceFragment.java @@ -20,7 +20,7 @@ import app.revanced.twitch.utils.LogHelper; import app.revanced.twitch.utils.Utils; -public class TwitchSettingsFragment extends PreferenceFragment { +public class ReVancedPreferenceFragment extends PreferenceFragment { private boolean registered = false; private boolean settingsInitialized = false; diff --git a/app/src/main/java/app/revanced/twitch/settingsmenu/TwitchSettingsHooks.java b/app/src/main/java/app/revanced/twitch/settingsmenu/TwitchSettingsHooks.java index 6043708f6c..d5a81c0a83 100644 --- a/app/src/main/java/app/revanced/twitch/settingsmenu/TwitchSettingsHooks.java +++ b/app/src/main/java/app/revanced/twitch/settingsmenu/TwitchSettingsHooks.java @@ -96,7 +96,7 @@ public static boolean handleSettingsCreation(AppCompatActivity base) { } LogHelper.debug("ReVanced settings requested"); - TwitchSettingsFragment fragment = new TwitchSettingsFragment(); + ReVancedPreferenceFragment fragment = new ReVancedPreferenceFragment(); ActionBar supportActionBar = base.getSupportActionBar(); if(supportActionBar != null) supportActionBar.setTitle(getStringId("revanced_settings")); From bc8e17019f8f8a5aaef742498fff1a2466c7853c Mon Sep 17 00:00:00 2001 From: LisoUseInAIKyrios <118716522+LisoUseInAIKyrios@users.noreply.github.com> Date: Sun, 31 Dec 2023 15:31:11 +0400 Subject: [PATCH 41/48] fix build --- .../app/revanced/integrations/patches/components/AdsFilter.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/app/revanced/integrations/patches/components/AdsFilter.java b/app/src/main/java/app/revanced/integrations/patches/components/AdsFilter.java index d5d855e0db..df85c67af4 100644 --- a/app/src/main/java/app/revanced/integrations/patches/components/AdsFilter.java +++ b/app/src/main/java/app/revanced/integrations/patches/components/AdsFilter.java @@ -167,6 +167,6 @@ private static void closeFullscreenAd() { LogHelper.printDebug(() -> "Closing fullscreen ad"); - ReVancedUtils.runOnMainThreadDelayed(() -> instrumentation.sendKeyDownUpSync(KeyEvent.KEYCODE_BACK), 1000); + Utils.runOnMainThreadDelayed(() -> instrumentation.sendKeyDownUpSync(KeyEvent.KEYCODE_BACK), 1000); } } From 2b7003bbbf5b43fc327c93a8dd8bf18b52394693 Mon Sep 17 00:00:00 2001 From: LisoUseInAIKyrios <118716522+LisoUseInAIKyrios@users.noreply.github.com> Date: Tue, 2 Jan 2024 19:01:53 +0400 Subject: [PATCH 42/48] fix: Add menu sorting code overlooked during last merge --- .../revanced/integrations/shared/Utils.java | 44 +++++++++++++++++++ .../AbstractPreferenceFragment.java | 1 + 2 files changed, 45 insertions(+) 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 359397c949..74c92caaf2 100644 --- a/app/src/main/java/app/revanced/integrations/shared/Utils.java +++ b/app/src/main/java/app/revanced/integrations/shared/Utils.java @@ -10,6 +10,8 @@ import android.os.Build; import android.os.Handler; import android.os.Looper; +import android.preference.Preference; +import android.preference.PreferenceGroup; import android.view.View; import android.view.ViewGroup; import android.view.animation.Animation; @@ -26,6 +28,8 @@ import java.text.Bidi; import java.util.Locale; import java.util.Objects; +import java.util.SortedMap; +import java.util.TreeMap; import java.util.concurrent.Callable; import java.util.concurrent.Future; import java.util.concurrent.SynchronousQueue; @@ -33,6 +37,7 @@ import java.util.concurrent.TimeUnit; import app.revanced.integrations.shared.settings.BooleanSetting; +import kotlin.text.Regex; public class Utils { @@ -388,6 +393,45 @@ public static void hideViewByLayoutParams(View view) { } } + private static final Regex punctuationRegex = new Regex("\\p{P}+"); + + /** + * Sort the preferences by title and ignore the casing. + * + * Android Preferences are automatically sorted by title, + * but if using a localized string key it sorts on the key and not the actual title text that's used at runtime. + * + * @param menuDepthToSort Maximum menu depth to sort. Menus deeper than this value + * will show preferences in the order created in patches. + */ + public static void sortPreferenceGroupByTitle(PreferenceGroup group, int menuDepthToSort) { + if (menuDepthToSort == 0) return; + + SortedMap preferences = new TreeMap<>(); + for (int i = 0, prefCount = group.getPreferenceCount(); i < prefCount; i++) { + Preference preference = group.getPreference(i); + if (preference instanceof PreferenceGroup) { + sortPreferenceGroupByTitle((PreferenceGroup) preference, menuDepthToSort - 1); + } + preferences.put(removePunctuationConvertToLowercase(preference.getTitle()), preference); + } + + int prefIndex = 0; + for (Preference pref : preferences.values()) { + int indexToSet = prefIndex++; + if (pref instanceof PreferenceGroup) { + // Place preference groups last. + // Use an offset to push the group to the end. + indexToSet += 1000; + } + pref.setOrder(indexToSet); + } + } + + public static String removePunctuationConvertToLowercase(CharSequence original) { + return punctuationRegex.replace(original, "").toLowerCase(); + } + public enum NetworkType { NONE, MOBILE, diff --git a/app/src/main/java/app/revanced/integrations/shared/settings/preference/AbstractPreferenceFragment.java b/app/src/main/java/app/revanced/integrations/shared/settings/preference/AbstractPreferenceFragment.java index eec7b35a7d..67e0ed6d11 100644 --- a/app/src/main/java/app/revanced/integrations/shared/settings/preference/AbstractPreferenceFragment.java +++ b/app/src/main/java/app/revanced/integrations/shared/settings/preference/AbstractPreferenceFragment.java @@ -78,6 +78,7 @@ protected void initialize() { if (identifier == 0) return; addPreferencesFromResource(identifier); + Utils.sortPreferenceGroupByTitle(getPreferenceScreen(), 2); } private void showSettingUserDialogConfirmation(SwitchPreference switchPref, BooleanSetting setting) { From 4c086a50995874dbf6298f9834b113326200bc3b Mon Sep 17 00:00:00 2001 From: LisoUseInAIKyrios <118716522+LisoUseInAIKyrios@users.noreply.github.com> Date: Tue, 2 Jan 2024 19:20:01 +0400 Subject: [PATCH 43/48] fix typo --- .../youtube/sponsorblock/SponsorBlockSettings.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/app/revanced/integrations/youtube/sponsorblock/SponsorBlockSettings.java b/app/src/main/java/app/revanced/integrations/youtube/sponsorblock/SponsorBlockSettings.java index a2397c139c..084bbf5254 100644 --- a/app/src/main/java/app/revanced/integrations/youtube/sponsorblock/SponsorBlockSettings.java +++ b/app/src/main/java/app/revanced/integrations/youtube/sponsorblock/SponsorBlockSettings.java @@ -169,8 +169,8 @@ public static void showExportWarningIfNeeded(@Nullable Context dialogContext) { if (dialogContext != null && SponsorBlockSettings.userHasSBPrivateId() && !Settings.SB_HIDE_EXPORT_WARNING.get()) { new AlertDialog.Builder(dialogContext) - .setMessage(str("sb_settings_revanced_export_user_id_warning")) - .setNeutralButton(str("sb_settings_revanced_export_user_id_warning_dismiss"), + .setMessage(str("revanced_sb_settings_revanced_export_user_id_warning")) + .setNeutralButton(str("revanced_sb_settings_revanced_export_user_id_warning_dismiss"), (dialog, which) -> Settings.SB_HIDE_EXPORT_WARNING.save(true)) .setPositiveButton(android.R.string.ok, null) .setCancelable(false) From 14f4e16b937d84b8866b4c14c6f18c1bb5f03785 Mon Sep 17 00:00:00 2001 From: LisoUseInAIKyrios <118716522+LisoUseInAIKyrios@users.noreply.github.com> Date: Wed, 17 Jan 2024 22:28:38 +0400 Subject: [PATCH 44/48] Include language code with announcement parameters if it's also localized. --- .../youtube/patches/announcements/AnnouncementsPatch.java | 4 +++- .../patches/announcements/requests/AnnouncementsRoutes.java | 6 ++++-- 2 files changed, 7 insertions(+), 3 deletions(-) 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 f1e564c7b1..6f2c9e50ba 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 @@ -18,6 +18,7 @@ import java.net.HttpURLConnection; import java.nio.charset.StandardCharsets; import java.security.MessageDigest; +import java.util.Locale; import java.util.UUID; import static android.text.Html.FROM_HTML_MODE_COMPACT; @@ -40,7 +41,8 @@ public static void showAnnouncement(final Activity context) { Utils.runOnBackgroundThread(() -> { try { - HttpURLConnection connection = AnnouncementsRoutes.getAnnouncementsConnectionFromRoute(GET_LATEST_ANNOUNCEMENT, CONSUMER); + HttpURLConnection connection = AnnouncementsRoutes.getAnnouncementsConnectionFromRoute( + GET_LATEST_ANNOUNCEMENT, CONSUMER, Locale.getDefault().toLanguageTag()); Logger.printDebug(() -> "Get latest announcement route connection url: " + connection.getURL()); diff --git a/app/src/main/java/app/revanced/integrations/youtube/patches/announcements/requests/AnnouncementsRoutes.java b/app/src/main/java/app/revanced/integrations/youtube/patches/announcements/requests/AnnouncementsRoutes.java index 39a7d4f3c3..6fca530c2b 100644 --- a/app/src/main/java/app/revanced/integrations/youtube/patches/announcements/requests/AnnouncementsRoutes.java +++ b/app/src/main/java/app/revanced/integrations/youtube/patches/announcements/requests/AnnouncementsRoutes.java @@ -11,8 +11,10 @@ public class AnnouncementsRoutes { private static final String ANNOUNCEMENTS_PROVIDER = "https://api.revanced.app/v2"; - - public static final Route GET_LATEST_ANNOUNCEMENT = new Route(GET, "/announcements/youtube/latest?consumer={consumer}"); + /** + * 'language' parameter is IETF format (for USA it would be 'en-us'). + */ + public static final Route GET_LATEST_ANNOUNCEMENT = new Route(GET, "/announcements/youtube/latest?consumer={consumer}&language={language}"); private AnnouncementsRoutes() { } From c5d3b65db4341b5fa475b6c657e13844ec067de3 Mon Sep 17 00:00:00 2001 From: LisoUseInAIKyrios <118716522+LisoUseInAIKyrios@users.noreply.github.com> Date: Thu, 25 Jan 2024 13:34:41 +0400 Subject: [PATCH 45/48] add missing 'revanced_sb_' resource prefix. --- .../integrations/youtube/sponsorblock/ui/NewSegmentLayout.java | 2 +- .../integrations/youtube/sponsorblock/ui/SkipSponsorButton.java | 2 +- .../youtube/sponsorblock/ui/SponsorBlockViewController.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/app/revanced/integrations/youtube/sponsorblock/ui/NewSegmentLayout.java b/app/src/main/java/app/revanced/integrations/youtube/sponsorblock/ui/NewSegmentLayout.java index 1b708a2ea6..d5ee7f4278 100644 --- a/app/src/main/java/app/revanced/integrations/youtube/sponsorblock/ui/NewSegmentLayout.java +++ b/app/src/main/java/app/revanced/integrations/youtube/sponsorblock/ui/NewSegmentLayout.java @@ -44,7 +44,7 @@ public NewSegmentLayout(final Context context, final AttributeSet attributeSet, super(context, attributeSet, defStyleAttr, defStyleRes); LayoutInflater.from(context).inflate( - getResourceIdentifier(context, "new_segment", "layout"), this, true + getResourceIdentifier(context, "revanced_sb_new_segment", "layout"), this, true ); TypedValue rippleEffect = new TypedValue(); 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 7bdfb60d6b..f3b954d4f4 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 @@ -47,7 +47,7 @@ public SkipSponsorButton(Context context, AttributeSet attributeSet, int defStyl public SkipSponsorButton(Context context, AttributeSet attributeSet, int defStyleAttr, int defStyleRes) { super(context, attributeSet, defStyleAttr, defStyleRes); - LayoutInflater.from(context).inflate(getResourceIdentifier(context, "skip_sponsor_button", "layout"), this, true); // layout:skip_ad_button + LayoutInflater.from(context).inflate(getResourceIdentifier(context, "revanced_sb_skip_sponsor_button", "layout"), this, true); // layout:skip_ad_button setMinimumHeight(getResourceDimensionPixelSize("ad_skip_ad_button_min_height")); // dimen:ad_skip_ad_button_min_height skipSponsorBtnContainer = Objects.requireNonNull((LinearLayout) findViewById(getResourceIdentifier(context, "revanced_sb_skip_sponsor_button_container", "id"))); // id:skip_ad_button_container background = new Paint(); diff --git a/app/src/main/java/app/revanced/integrations/youtube/sponsorblock/ui/SponsorBlockViewController.java b/app/src/main/java/app/revanced/integrations/youtube/sponsorblock/ui/SponsorBlockViewController.java index 9bfa2ff768..12deeb8342 100644 --- a/app/src/main/java/app/revanced/integrations/youtube/sponsorblock/ui/SponsorBlockViewController.java +++ b/app/src/main/java/app/revanced/integrations/youtube/sponsorblock/ui/SponsorBlockViewController.java @@ -61,7 +61,7 @@ public static void initialize(ViewGroup viewGroup) { Context context = Utils.getContext(); RelativeLayout layout = new RelativeLayout(context); layout.setLayoutParams(new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT,RelativeLayout.LayoutParams.MATCH_PARENT)); - LayoutInflater.from(context).inflate(getResourceIdentifier("inline_sponsor_overlay", "layout"), layout); + LayoutInflater.from(context).inflate(getResourceIdentifier("revanced_sb_inline_sponsor_overlay", "layout"), layout); inlineSponsorOverlayRef = new WeakReference<>(layout); viewGroup.addView(layout); From f35c2350c4d0ff48dc61b4d58c110c8100b4b01d Mon Sep 17 00:00:00 2001 From: LisoUseInAIKyrios <118716522+LisoUseInAIKyrios@users.noreply.github.com> Date: Thu, 25 Jan 2024 13:43:53 +0400 Subject: [PATCH 46/48] use more consistent intent names --- .../integrations/youtube/settings/LicenseActivityHook.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/app/revanced/integrations/youtube/settings/LicenseActivityHook.java b/app/src/main/java/app/revanced/integrations/youtube/settings/LicenseActivityHook.java index ebf22d2099..30d97a6724 100644 --- a/app/src/main/java/app/revanced/integrations/youtube/settings/LicenseActivityHook.java +++ b/app/src/main/java/app/revanced/integrations/youtube/settings/LicenseActivityHook.java @@ -41,11 +41,11 @@ public static void initialize(Activity licenseActivity) { String toolbarTitleResourceName; String dataString = licenseActivity.getIntent().getDataString(); switch (dataString) { - case "sponsorblock_settings_intent": - toolbarTitleResourceName = "revanced_sponsorblock_settings_title"; + case "revanced_sb_settings_intent": + toolbarTitleResourceName = "revanced_sb_settings_title"; fragment = new SponsorBlockPreferenceFragment(); break; - case "ryd_settings_intent": + case "revanced_ryd_settings_intent": toolbarTitleResourceName = "revanced_ryd_settings_title"; fragment = new ReturnYouTubeDislikePreferenceFragment(); break; From 3d1c08ed9cf3a1fe094a59fc5db71337f3ad0db7 Mon Sep 17 00:00:00 2001 From: LisoUseInAIKyrios <118716522+LisoUseInAIKyrios@users.noreply.github.com> Date: Thu, 25 Jan 2024 14:33:32 +0400 Subject: [PATCH 47/48] use descriptive name --- .../youtube/sponsorblock/ui/CreateSegmentButtonController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/app/revanced/integrations/youtube/sponsorblock/ui/CreateSegmentButtonController.java b/app/src/main/java/app/revanced/integrations/youtube/sponsorblock/ui/CreateSegmentButtonController.java index e88ef69f1d..dffdf9ff48 100644 --- a/app/src/main/java/app/revanced/integrations/youtube/sponsorblock/ui/CreateSegmentButtonController.java +++ b/app/src/main/java/app/revanced/integrations/youtube/sponsorblock/ui/CreateSegmentButtonController.java @@ -25,7 +25,7 @@ public static void initialize(View youtubeControlsLayout) { try { Logger.printDebug(() -> "initializing new segment button"); ImageView imageView = Objects.requireNonNull(youtubeControlsLayout.findViewById( - getResourceIdentifier("revanced_sb_sponsorblock_button", "id"))); + getResourceIdentifier("revanced_sb_create_segment_button", "id"))); imageView.setVisibility(View.GONE); imageView.setOnClickListener(v -> { SponsorBlockViewController.toggleNewSegmentLayoutVisibility(); From 68d38d0b88cefeeb59d371a93066e34adb0e54e5 Mon Sep 17 00:00:00 2001 From: LisoUseInAIKyrios <118716522+LisoUseInAIKyrios@users.noreply.github.com> Date: Thu, 25 Jan 2024 15:10:56 +0400 Subject: [PATCH 48/48] Correctly sort intent preferences --- app/src/main/java/app/revanced/integrations/shared/Utils.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 74c92caaf2..279abdead2 100644 --- a/app/src/main/java/app/revanced/integrations/shared/Utils.java +++ b/app/src/main/java/app/revanced/integrations/shared/Utils.java @@ -419,7 +419,7 @@ public static void sortPreferenceGroupByTitle(PreferenceGroup group, int menuDep int prefIndex = 0; for (Preference pref : preferences.values()) { int indexToSet = prefIndex++; - if (pref instanceof PreferenceGroup) { + if (pref instanceof PreferenceGroup || pref.getIntent() != null) { // Place preference groups last. // Use an offset to push the group to the end. indexToSet += 1000;