From db6ce554779d58b23685b1794e17f89342abbd87 Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Fri, 24 Feb 2023 04:13:52 +0100 Subject: [PATCH 01/24] feat(youtube/general-ads): hide image shelf from search results Signed-off-by: oSumAtrIX --- .../java/app/revanced/integrations/patches/GeneralAdsPatch.java | 2 ++ .../java/app/revanced/integrations/settings/SettingsEnum.java | 1 + 2 files changed, 3 insertions(+) diff --git a/app/src/main/java/app/revanced/integrations/patches/GeneralAdsPatch.java b/app/src/main/java/app/revanced/integrations/patches/GeneralAdsPatch.java index 6abb1a6e..85ca0123 100644 --- a/app/src/main/java/app/revanced/integrations/patches/GeneralAdsPatch.java +++ b/app/src/main/java/app/revanced/integrations/patches/GeneralAdsPatch.java @@ -42,6 +42,7 @@ public final class GeneralAdsPatch extends Filter { var channelBar = new BlockRule(SettingsEnum.ADREMOVER_CHANNEL_BAR, "channel_bar"); var relatedVideos = new BlockRule(SettingsEnum.ADREMOVER_RELATED_VIDEOS, "fullscreen_related_videos"); var quickActions = new BlockRule(SettingsEnum.ADREMOVER_QUICK_ACTIONS, "quick_actions"); + var imageShelf = new BlockRule(SettingsEnum.ADREMOVER_IMAGE_SHELF, "image_shelf"); var graySeparator = new BlockRule(SettingsEnum.ADREMOVER_GRAY_SEPARATOR, "cell_divider" // layout residue (gray line above the buttoned ad), ); @@ -92,6 +93,7 @@ public final class GeneralAdsPatch extends Filter { artistCard, selfSponsor, webLinkPanel, + imageShelf, horizontalVideoShelf, subscribersCommunityGuidelines, channelMemberShelf 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 73b99d20..5066e640 100644 --- a/app/src/main/java/app/revanced/integrations/settings/SettingsEnum.java +++ b/app/src/main/java/app/revanced/integrations/settings/SettingsEnum.java @@ -58,6 +58,7 @@ public enum SettingsEnum { ADREMOVER_CHANNEL_BAR("revanced_hide_channel_bar", false, ReturnType.BOOLEAN), ADREMOVER_QUICK_ACTIONS("revanced_hide_quick_actions", false, ReturnType.BOOLEAN), ADREMOVER_RELATED_VIDEOS("revanced_hide_related_videos", false, ReturnType.BOOLEAN), + ADREMOVER_IMAGE_SHELF("revanced_hide_image_shelf", true, ReturnType.BOOLEAN), // Action buttons HIDE_LIKE_BUTTON("revanced_hide_like_button", false, ReturnType.BOOLEAN, false), From 0b83be989bbb269a0c4911d946ea325e732c0d04 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Fri, 24 Feb 2023 03:16:12 +0000 Subject: [PATCH 02/24] chore(release): 0.100.0-dev.1 [skip ci] # [0.100.0-dev.1](https://github.com/revanced/revanced-integrations/compare/v0.99.0...v0.100.0-dev.1) (2023-02-24) ### Features * **youtube/general-ads:** hide image shelf from search results ([db6ce55](https://github.com/revanced/revanced-integrations/commit/db6ce554779d58b23685b1794e17f89342abbd87)) --- CHANGELOG.md | 7 +++++++ gradle.properties | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6c63b31d..899a96b3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +# [0.100.0-dev.1](https://github.com/revanced/revanced-integrations/compare/v0.99.0...v0.100.0-dev.1) (2023-02-24) + + +### Features + +* **youtube/general-ads:** hide image shelf from search results ([db6ce55](https://github.com/revanced/revanced-integrations/commit/db6ce554779d58b23685b1794e17f89342abbd87)) + # [0.99.0](https://github.com/revanced/revanced-integrations/compare/v0.98.0...v0.99.0) (2023-02-24) diff --git a/gradle.properties b/gradle.properties index 312e5797..1e4f4dd2 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,3 +1,3 @@ org.gradle.jvmargs = -Xmx2048m android.useAndroidX = true -version = 0.99.0 +version = 0.100.0-dev.1 From 3c00e58c13fa11da68ff21f4d76e341bc24c5737 Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Sat, 25 Feb 2023 00:09:48 +0100 Subject: [PATCH 03/24] feat(youtube/general-ads): do not hide components in library tab This reverts commit fd975ecd Signed-off-by: oSumAtrIX --- .../java/app/revanced/integrations/patches/GeneralAdsPatch.java | 2 -- .../java/app/revanced/integrations/settings/SettingsEnum.java | 1 - 2 files changed, 3 deletions(-) diff --git a/app/src/main/java/app/revanced/integrations/patches/GeneralAdsPatch.java b/app/src/main/java/app/revanced/integrations/patches/GeneralAdsPatch.java index 85ca0123..2b581b3b 100644 --- a/app/src/main/java/app/revanced/integrations/patches/GeneralAdsPatch.java +++ b/app/src/main/java/app/revanced/integrations/patches/GeneralAdsPatch.java @@ -38,7 +38,6 @@ public final class GeneralAdsPatch extends Filter { var chapterTeaser = new BlockRule(SettingsEnum.ADREMOVER_CHAPTER_TEASER_REMOVAL, "expandable_metadata"); var viewProducts = new BlockRule(SettingsEnum.ADREMOVER_VIEW_PRODUCTS, "product_item", "products_in_video"); var webLinkPanel = new BlockRule(SettingsEnum.ADREMOVER_WEB_SEARCH_RESULTS, "web_link_panel"); - var horizontalVideoShelf = new BlockRule(SettingsEnum.ADREMOVER_HORIZONTAL_VIDEO_SHELF, "horizontal_video_shelf"); var channelBar = new BlockRule(SettingsEnum.ADREMOVER_CHANNEL_BAR, "channel_bar"); var relatedVideos = new BlockRule(SettingsEnum.ADREMOVER_RELATED_VIDEOS, "fullscreen_related_videos"); var quickActions = new BlockRule(SettingsEnum.ADREMOVER_QUICK_ACTIONS, "quick_actions"); @@ -94,7 +93,6 @@ public final class GeneralAdsPatch extends Filter { selfSponsor, webLinkPanel, imageShelf, - horizontalVideoShelf, subscribersCommunityGuidelines, channelMemberShelf ); 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 5066e640..aa85ecc1 100644 --- a/app/src/main/java/app/revanced/integrations/settings/SettingsEnum.java +++ b/app/src/main/java/app/revanced/integrations/settings/SettingsEnum.java @@ -54,7 +54,6 @@ public enum SettingsEnum { ADREMOVER_GRAY_SEPARATOR("revanced_adremover_separator", true, ReturnType.BOOLEAN), ADREMOVER_VIEW_PRODUCTS("revanced_adremover_view_products", true, ReturnType.BOOLEAN), ADREMOVER_WEB_SEARCH_RESULTS("revanced_adremover_web_search_result", true, ReturnType.BOOLEAN), - ADREMOVER_HORIZONTAL_VIDEO_SHELF("revanced_horizontal_video_shelf", true, ReturnType.BOOLEAN), ADREMOVER_CHANNEL_BAR("revanced_hide_channel_bar", false, ReturnType.BOOLEAN), ADREMOVER_QUICK_ACTIONS("revanced_hide_quick_actions", false, ReturnType.BOOLEAN), ADREMOVER_RELATED_VIDEOS("revanced_hide_related_videos", false, ReturnType.BOOLEAN), From f758b0967639375ad9bbd4aeb24ace63d765408e Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Fri, 24 Feb 2023 23:13:28 +0000 Subject: [PATCH 04/24] chore(release): 0.100.0-dev.2 [skip ci] # [0.100.0-dev.2](https://github.com/revanced/revanced-integrations/compare/v0.100.0-dev.1...v0.100.0-dev.2) (2023-02-24) ### Features * **youtube/general-ads:** do not hide components in library tab ([3c00e58](https://github.com/revanced/revanced-integrations/commit/3c00e58c13fa11da68ff21f4d76e341bc24c5737)) --- CHANGELOG.md | 7 +++++++ gradle.properties | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 899a96b3..343b2bdf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +# [0.100.0-dev.2](https://github.com/revanced/revanced-integrations/compare/v0.100.0-dev.1...v0.100.0-dev.2) (2023-02-24) + + +### Features + +* **youtube/general-ads:** do not hide components in library tab ([3c00e58](https://github.com/revanced/revanced-integrations/commit/3c00e58c13fa11da68ff21f4d76e341bc24c5737)) + # [0.100.0-dev.1](https://github.com/revanced/revanced-integrations/compare/v0.99.0...v0.100.0-dev.1) (2023-02-24) diff --git a/gradle.properties b/gradle.properties index 1e4f4dd2..655ef829 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,3 +1,3 @@ org.gradle.jvmargs = -Xmx2048m android.useAndroidX = true -version = 0.100.0-dev.1 +version = 0.100.0-dev.2 From f31e3a02a0965da0c1f901e9d6afcfe4f6f6b608 Mon Sep 17 00:00:00 2001 From: johnconner122 <107796137+johnconner122@users.noreply.github.com> Date: Sat, 25 Feb 2023 20:24:45 +0500 Subject: [PATCH 05/24] fix(youtube/general-ads): hide chapters in video description (#326) --- .../java/app/revanced/integrations/patches/GeneralAdsPatch.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/app/revanced/integrations/patches/GeneralAdsPatch.java b/app/src/main/java/app/revanced/integrations/patches/GeneralAdsPatch.java index 2b581b3b..4ae11418 100644 --- a/app/src/main/java/app/revanced/integrations/patches/GeneralAdsPatch.java +++ b/app/src/main/java/app/revanced/integrations/patches/GeneralAdsPatch.java @@ -35,7 +35,7 @@ public final class GeneralAdsPatch extends Filter { var channelGuidelines = new BlockRule(SettingsEnum.ADREMOVER_HIDE_CHANNEL_GUIDELINES, "channel_guidelines_entry_banner"); var artistCard = new BlockRule(SettingsEnum.HIDE_ARTIST_CARDS, "official_card"); var selfSponsor = new BlockRule(SettingsEnum.ADREMOVER_SELF_SPONSOR_REMOVAL, "cta_shelf_card"); - var chapterTeaser = new BlockRule(SettingsEnum.ADREMOVER_CHAPTER_TEASER_REMOVAL, "expandable_metadata"); + var chapterTeaser = new BlockRule(SettingsEnum.ADREMOVER_CHAPTER_TEASER_REMOVAL, "expandable_metadata", "macro_markers_carousel"); var viewProducts = new BlockRule(SettingsEnum.ADREMOVER_VIEW_PRODUCTS, "product_item", "products_in_video"); var webLinkPanel = new BlockRule(SettingsEnum.ADREMOVER_WEB_SEARCH_RESULTS, "web_link_panel"); var channelBar = new BlockRule(SettingsEnum.ADREMOVER_CHANNEL_BAR, "channel_bar"); From db60d983e52e7594818065076012b5eb71d972a7 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Sat, 25 Feb 2023 15:26:37 +0000 Subject: [PATCH 06/24] chore(release): 0.100.0-dev.3 [skip ci] # [0.100.0-dev.3](https://github.com/revanced/revanced-integrations/compare/v0.100.0-dev.2...v0.100.0-dev.3) (2023-02-25) ### Bug Fixes * **youtube/general-ads:** hide chapters in video description ([#326](https://github.com/revanced/revanced-integrations/issues/326)) ([f31e3a0](https://github.com/revanced/revanced-integrations/commit/f31e3a02a0965da0c1f901e9d6afcfe4f6f6b608)) --- CHANGELOG.md | 7 +++++++ gradle.properties | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 343b2bdf..a7647d58 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +# [0.100.0-dev.3](https://github.com/revanced/revanced-integrations/compare/v0.100.0-dev.2...v0.100.0-dev.3) (2023-02-25) + + +### Bug Fixes + +* **youtube/general-ads:** hide chapters in video description ([#326](https://github.com/revanced/revanced-integrations/issues/326)) ([f31e3a0](https://github.com/revanced/revanced-integrations/commit/f31e3a02a0965da0c1f901e9d6afcfe4f6f6b608)) + # [0.100.0-dev.2](https://github.com/revanced/revanced-integrations/compare/v0.100.0-dev.1...v0.100.0-dev.2) (2023-02-24) diff --git a/gradle.properties b/gradle.properties index 655ef829..3ecd31bd 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,3 +1,3 @@ org.gradle.jvmargs = -Xmx2048m android.useAndroidX = true -version = 0.100.0-dev.2 +version = 0.100.0-dev.3 From 0b3508bd8dcd6e031f1a7625ee5214fd093ee3f5 Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Sun, 26 Feb 2023 22:17:18 +0100 Subject: [PATCH 07/24] fix(youtube/general-ads): hide any kind of buttoned ad Signed-off-by: oSumAtrIX --- .../java/app/revanced/integrations/patches/GeneralAdsPatch.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/app/revanced/integrations/patches/GeneralAdsPatch.java b/app/src/main/java/app/revanced/integrations/patches/GeneralAdsPatch.java index 4ae11418..40a55282 100644 --- a/app/src/main/java/app/revanced/integrations/patches/GeneralAdsPatch.java +++ b/app/src/main/java/app/revanced/integrations/patches/GeneralAdsPatch.java @@ -46,7 +46,7 @@ public final class GeneralAdsPatch extends Filter { "cell_divider" // layout residue (gray line above the buttoned ad), ); var buttonedAd = new BlockRule(SettingsEnum.ADREMOVER_BUTTONED_REMOVAL, - "video_display_full_buttoned_layout", + "_buttoned_layout", "full_width_square_image_layout", "_ad_with", "landscape_image_wide_button_layout" From 8a8924ab0907e788af9c1598837811ed5578d37a Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Sun, 26 Feb 2023 21:19:20 +0000 Subject: [PATCH 08/24] chore(release): 0.100.0-dev.4 [skip ci] # [0.100.0-dev.4](https://github.com/revanced/revanced-integrations/compare/v0.100.0-dev.3...v0.100.0-dev.4) (2023-02-26) ### Bug Fixes * **youtube/general-ads:** hide any kind of buttoned ad ([0b3508b](https://github.com/revanced/revanced-integrations/commit/0b3508bd8dcd6e031f1a7625ee5214fd093ee3f5)) --- CHANGELOG.md | 7 +++++++ gradle.properties | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a7647d58..2a8750e5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +# [0.100.0-dev.4](https://github.com/revanced/revanced-integrations/compare/v0.100.0-dev.3...v0.100.0-dev.4) (2023-02-26) + + +### Bug Fixes + +* **youtube/general-ads:** hide any kind of buttoned ad ([0b3508b](https://github.com/revanced/revanced-integrations/commit/0b3508bd8dcd6e031f1a7625ee5214fd093ee3f5)) + # [0.100.0-dev.3](https://github.com/revanced/revanced-integrations/compare/v0.100.0-dev.2...v0.100.0-dev.3) (2023-02-25) diff --git a/gradle.properties b/gradle.properties index 3ecd31bd..8551ae7d 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,3 +1,3 @@ org.gradle.jvmargs = -Xmx2048m android.useAndroidX = true -version = 0.100.0-dev.3 +version = 0.100.0-dev.4 From 519c2bd5118db41fc512a665d9454b902134ba2c Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Sun, 26 Feb 2023 22:38:08 +0100 Subject: [PATCH 09/24] feat(youtube/hide-autoplay-button): do not disable autoplay button when hidden Signed-off-by: oSumAtrIX --- .../revanced/integrations/patches/HideAutoplayButtonPatch.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/src/main/java/app/revanced/integrations/patches/HideAutoplayButtonPatch.java b/app/src/main/java/app/revanced/integrations/patches/HideAutoplayButtonPatch.java index c84a9d4a..7f42e7f3 100644 --- a/app/src/main/java/app/revanced/integrations/patches/HideAutoplayButtonPatch.java +++ b/app/src/main/java/app/revanced/integrations/patches/HideAutoplayButtonPatch.java @@ -3,8 +3,7 @@ package app.revanced.integrations.patches; import app.revanced.integrations.settings.SettingsEnum; public class HideAutoplayButtonPatch { - public static boolean isButtonShown() { - return SettingsEnum.HIDE_AUTOPLAY_BUTTON.getBoolean() == false; + return !SettingsEnum.HIDE_AUTOPLAY_BUTTON.getBoolean(); } } From cb77e96da91bb4707d8559757cd86a7583f8048b Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Sun, 26 Feb 2023 22:59:56 +0100 Subject: [PATCH 10/24] feat(youtube): `hide-floating-microphone-button` patch Signed-off-by: oSumAtrIX --- .../patches/HideFloatingMicrophoneButtonPatch.java | 9 +++++++++ .../app/revanced/integrations/settings/SettingsEnum.java | 1 + 2 files changed, 10 insertions(+) create mode 100644 app/src/main/java/app/revanced/integrations/patches/HideFloatingMicrophoneButtonPatch.java diff --git a/app/src/main/java/app/revanced/integrations/patches/HideFloatingMicrophoneButtonPatch.java b/app/src/main/java/app/revanced/integrations/patches/HideFloatingMicrophoneButtonPatch.java new file mode 100644 index 00000000..17cb5779 --- /dev/null +++ b/app/src/main/java/app/revanced/integrations/patches/HideFloatingMicrophoneButtonPatch.java @@ -0,0 +1,9 @@ +package app.revanced.integrations.patches; + +import app.revanced.integrations.settings.SettingsEnum; + +public final class HideFloatingMicrophoneButtonPatch { + public static boolean hideFloatingMicrophoneButton(boolean original) { + return SettingsEnum.HIDE_FLOATING_MICROPHONE_BUTTON.getBoolean() || original; + } +} 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 aa85ecc1..e47d7d49 100644 --- a/app/src/main/java/app/revanced/integrations/settings/SettingsEnum.java +++ b/app/src/main/java/app/revanced/integrations/settings/SettingsEnum.java @@ -96,6 +96,7 @@ public enum SettingsEnum { HIDE_WATCH_IN_VR("revanced_hide_watch_in_vr", false, ReturnType.BOOLEAN, true), HIDE_BREAKING_NEWS("revanced_hide_breaking_news", true, ReturnType.BOOLEAN, true), HIDE_PLAYER_BUTTONS("revanced_hide_player_buttons", false, ReturnType.BOOLEAN, false), + HIDE_FLOATING_MICROPHONE_BUTTON("revanced_hide_floating_microphone_button", true, ReturnType.BOOLEAN), // Misc. Settings FIX_PLAYBACK("revanced_fix_playback", false, ReturnType.BOOLEAN, false), From 24162934ba1a1e4785ed30d9a60758f3ff2615dc Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Sun, 26 Feb 2023 23:10:35 +0100 Subject: [PATCH 11/24] refactor(youtube/hide-timestamp): use better descriptions Signed-off-by: oSumAtrIX --- .../app/revanced/integrations/patches/HideTimePatch.java | 9 --------- .../integrations/patches/HideTimestampPatch.java | 9 +++++++++ .../app/revanced/integrations/settings/SettingsEnum.java | 8 ++++++-- 3 files changed, 15 insertions(+), 11 deletions(-) delete mode 100644 app/src/main/java/app/revanced/integrations/patches/HideTimePatch.java create mode 100644 app/src/main/java/app/revanced/integrations/patches/HideTimestampPatch.java diff --git a/app/src/main/java/app/revanced/integrations/patches/HideTimePatch.java b/app/src/main/java/app/revanced/integrations/patches/HideTimePatch.java deleted file mode 100644 index 87f023d3..00000000 --- a/app/src/main/java/app/revanced/integrations/patches/HideTimePatch.java +++ /dev/null @@ -1,9 +0,0 @@ -package app.revanced.integrations.patches; - -import app.revanced.integrations.settings.SettingsEnum; - -public class HideTimePatch { - public static boolean hideTime() { - return SettingsEnum.HIDE_TIME.getBoolean(); - } -} diff --git a/app/src/main/java/app/revanced/integrations/patches/HideTimestampPatch.java b/app/src/main/java/app/revanced/integrations/patches/HideTimestampPatch.java new file mode 100644 index 00000000..9bb85294 --- /dev/null +++ b/app/src/main/java/app/revanced/integrations/patches/HideTimestampPatch.java @@ -0,0 +1,9 @@ +package app.revanced.integrations.patches; + +import app.revanced.integrations.settings.SettingsEnum; + +public class HideTimestampPatch { + public static boolean hideTimestamp() { + return SettingsEnum.HIDE_TIMESTAMP.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 e47d7d49..7dacf318 100644 --- a/app/src/main/java/app/revanced/integrations/settings/SettingsEnum.java +++ b/app/src/main/java/app/revanced/integrations/settings/SettingsEnum.java @@ -91,7 +91,7 @@ public enum SettingsEnum { HIDE_REEL_BUTTON("revanced_hide_reel_button", true, ReturnType.BOOLEAN, true), HIDE_SHORTS_BUTTON("revanced_hide_shorts_button", true, ReturnType.BOOLEAN, true), HIDE_SHORTS_COMMENTS_BUTTON("revanced_hide_shorts_comments_button", false, ReturnType.BOOLEAN), - HIDE_TIME("revanced_hide_time", false, ReturnType.BOOLEAN), + HIDE_TIMESTAMP("revanced_hide_timestamp", false, ReturnType.BOOLEAN), HIDE_SEEKBAR("revanced_hide_seekbar", false, ReturnType.BOOLEAN), HIDE_WATCH_IN_VR("revanced_hide_watch_in_vr", false, ReturnType.BOOLEAN, true), HIDE_BREAKING_NEWS("revanced_hide_breaking_news", true, ReturnType.BOOLEAN, true), @@ -194,7 +194,10 @@ public enum SettingsEnum { @Deprecated DEPRECATED_COPY_VIDEO_URL_BUTTON_SHOWN("revanced_copy_video_url", true, ReturnType.BOOLEAN, true), @Deprecated - DEPRECATED_COPY_VIDEO_URL_TIMESTAMP_BUTTON_SHOWN("revanced_copy_video_url_timestamp", true, ReturnType.BOOLEAN, true); + DEPRECATED_COPY_VIDEO_URL_TIMESTAMP_BUTTON_SHOWN("revanced_copy_video_url_timestamp", true, ReturnType.BOOLEAN, true), + @Deprecated + DEPRECATED_HIDE_TIME("revanced_hide_time", false, ReturnType.BOOLEAN); + // // end deprecated settings // @@ -247,6 +250,7 @@ public enum SettingsEnum { {DEPRECATED_CAST_BUTTON_SHOWN, HIDE_CAST_BUTTON}, {DEPRECATED_BRANDING_SHOWN, HIDE_VIDEO_WATERMARK}, {DEPRECATED_REMEMBER_VIDEO_QUALITY, REMEMBER_VIDEO_QUALITY_LAST_SELECTED}, + {DEPRECATED_HIDE_TIME, HIDE_TIMESTAMP} }; for (SettingsEnum[] oldNewSetting : invertedSettingsToMigrate) { // by default, old setting was default off From 7dc6bb4428a3f7083da93e2c9c675e21246d1abe Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Sun, 26 Feb 2023 23:11:59 +0100 Subject: [PATCH 12/24] refactor(youtube/settings): use default parameter Signed-off-by: oSumAtrIX --- .../integrations/settings/SettingsEnum.java | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) 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 7dacf318..a15c99d7 100644 --- a/app/src/main/java/app/revanced/integrations/settings/SettingsEnum.java +++ b/app/src/main/java/app/revanced/integrations/settings/SettingsEnum.java @@ -60,12 +60,12 @@ public enum SettingsEnum { ADREMOVER_IMAGE_SHELF("revanced_hide_image_shelf", true, ReturnType.BOOLEAN), // Action buttons - HIDE_LIKE_BUTTON("revanced_hide_like_button", false, ReturnType.BOOLEAN, false), - HIDE_DISLIKE_BUTTON("revanced_hide_dislike_button", false, ReturnType.BOOLEAN, false), - HIDE_DOWNLOAD_BUTTON("revanced_hide_download_button", false, ReturnType.BOOLEAN, false), - HIDE_PLAYLIST_BUTTON("revanced_hide_playlist_button", false, ReturnType.BOOLEAN, false), - HIDE_ACTION_BUTTON("revanced_hide_action_button", false, ReturnType.BOOLEAN, false), - HIDE_SHARE_BUTTON("revanced_hide_share_button", false, ReturnType.BOOLEAN, false), + HIDE_LIKE_BUTTON("revanced_hide_like_button", false, ReturnType.BOOLEAN), + HIDE_DISLIKE_BUTTON("revanced_hide_dislike_button", false, ReturnType.BOOLEAN), + HIDE_DOWNLOAD_BUTTON("revanced_hide_download_button", false, ReturnType.BOOLEAN), + HIDE_PLAYLIST_BUTTON("revanced_hide_playlist_button", false, ReturnType.BOOLEAN), + HIDE_ACTION_BUTTON("revanced_hide_action_button", false, ReturnType.BOOLEAN), + HIDE_SHARE_BUTTON("revanced_hide_share_button", false, ReturnType.BOOLEAN), // Layout settings DISABLE_STARTUP_SHORTS_PLAYER("revanced_startup_shorts_player_enabled", false, ReturnType.BOOLEAN), @@ -95,18 +95,18 @@ public enum SettingsEnum { HIDE_SEEKBAR("revanced_hide_seekbar", false, ReturnType.BOOLEAN), HIDE_WATCH_IN_VR("revanced_hide_watch_in_vr", false, ReturnType.BOOLEAN, true), HIDE_BREAKING_NEWS("revanced_hide_breaking_news", true, ReturnType.BOOLEAN, true), - HIDE_PLAYER_BUTTONS("revanced_hide_player_buttons", false, ReturnType.BOOLEAN, false), + HIDE_PLAYER_BUTTONS("revanced_hide_player_buttons", false, ReturnType.BOOLEAN), HIDE_FLOATING_MICROPHONE_BUTTON("revanced_hide_floating_microphone_button", true, ReturnType.BOOLEAN), // Misc. Settings - FIX_PLAYBACK("revanced_fix_playback", false, ReturnType.BOOLEAN, false), - CAPTIONS_ENABLED("revanced_autocaptions_enabled", false, ReturnType.BOOLEAN, false), + FIX_PLAYBACK("revanced_fix_playback", false, ReturnType.BOOLEAN), + CAPTIONS_ENABLED("revanced_autocaptions_enabled", false, ReturnType.BOOLEAN), PREFERRED_AUTO_REPEAT("revanced_pref_auto_repeat", false, ReturnType.BOOLEAN), USE_HDR_AUTO_BRIGHTNESS("revanced_pref_hdr_autobrightness", true, ReturnType.BOOLEAN), TAP_SEEKING_ENABLED("revanced_enable_tap_seeking", true, ReturnType.BOOLEAN), ENABLE_MINIMIZED_PLAYBACK("revanced_enable_minimized_playback", true, ReturnType.BOOLEAN), OPEN_LINKS_DIRECTLY("revanced_uri_redirect", true, ReturnType.BOOLEAN, true), - DISABLE_ZOOM_HAPTICS("revanced_disable_zoom_haptics", true, ReturnType.BOOLEAN, false), + DISABLE_ZOOM_HAPTICS("revanced_disable_zoom_haptics", true, ReturnType.BOOLEAN), ENABLE_EXTERNAL_BROWSER("revanced_enable_external_browser", true, ReturnType.BOOLEAN, true), // Swipe controls @@ -162,17 +162,17 @@ public enum SettingsEnum { @Deprecated DEPRECATED_HIDE_MIX_PLAYLISTS("revanced_mix_playlists_hidden", false, ReturnType.BOOLEAN, true), @Deprecated - DEPRECATED_HIDE_LIKE_BUTTON("revanced_like_button", false, ReturnType.BOOLEAN, false), + DEPRECATED_HIDE_LIKE_BUTTON("revanced_like_button", false, ReturnType.BOOLEAN), @Deprecated - DEPRECATED_HIDE_DISLIKE_BUTTON("revanced_dislike_button", false, ReturnType.BOOLEAN, false), + DEPRECATED_HIDE_DISLIKE_BUTTON("revanced_dislike_button", false, ReturnType.BOOLEAN), @Deprecated - DEPRECATED_HIDE_DOWNLOAD_BUTTON("revanced_download_button", false, ReturnType.BOOLEAN, false), + DEPRECATED_HIDE_DOWNLOAD_BUTTON("revanced_download_button", false, ReturnType.BOOLEAN), @Deprecated - DEPRECATED_HIDE_PLAYLIST_BUTTON("revanced_playlist_button", false, ReturnType.BOOLEAN, false), + DEPRECATED_HIDE_PLAYLIST_BUTTON("revanced_playlist_button", false, ReturnType.BOOLEAN), @Deprecated - DEPRECATED_HIDE_ACTION_BUTTON("revanced_action_button", false, ReturnType.BOOLEAN, false), + DEPRECATED_HIDE_ACTION_BUTTON("revanced_action_button", false, ReturnType.BOOLEAN), @Deprecated - DEPRECATED_HIDE_SHARE_BUTTON("revanced_share_button", false, ReturnType.BOOLEAN, false), + DEPRECATED_HIDE_SHARE_BUTTON("revanced_share_button", false, ReturnType.BOOLEAN), @Deprecated DEPRECATED_FULLSCREEN_PANELS_SHOWN("revanced_fullscreen_panels_enabled", false, ReturnType.BOOLEAN), @Deprecated From 66bcf12dc680113776008323384c19664c4b39f2 Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Sun, 26 Feb 2023 23:14:00 +0100 Subject: [PATCH 13/24] refactor(youtube/settings): remove deprecated settings Signed-off-by: oSumAtrIX --- .../integrations/settings/SettingsEnum.java | 112 +----------------- 1 file changed, 1 insertion(+), 111 deletions(-) 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 a15c99d7..5d81bedf 100644 --- a/app/src/main/java/app/revanced/integrations/settings/SettingsEnum.java +++ b/app/src/main/java/app/revanced/integrations/settings/SettingsEnum.java @@ -153,54 +153,7 @@ public enum SettingsEnum { SB_IS_VIP("sb-is-vip", false, SharedPrefHelper.SharedPrefNames.SPONSOR_BLOCK, ReturnType.BOOLEAN), SB_LAST_VIP_CHECK("sb-last-vip-check", 0L, SharedPrefHelper.SharedPrefNames.SPONSOR_BLOCK, ReturnType.LONG), SB_SHOW_BROWSER_BUTTON("sb-browser-button", false, SharedPrefHelper.SharedPrefNames.SPONSOR_BLOCK, ReturnType.BOOLEAN), - SB_API_URL("sb-api-host-url", "https://sponsor.ajay.app", SharedPrefHelper.SharedPrefNames.SPONSOR_BLOCK, ReturnType.STRING), - - // - // old deprecated settings, kept around to migrate user settings on existing installations - // FIXME: after a few months, eventually delete these settings - // - @Deprecated - DEPRECATED_HIDE_MIX_PLAYLISTS("revanced_mix_playlists_hidden", false, ReturnType.BOOLEAN, true), - @Deprecated - DEPRECATED_HIDE_LIKE_BUTTON("revanced_like_button", false, ReturnType.BOOLEAN), - @Deprecated - DEPRECATED_HIDE_DISLIKE_BUTTON("revanced_dislike_button", false, ReturnType.BOOLEAN), - @Deprecated - DEPRECATED_HIDE_DOWNLOAD_BUTTON("revanced_download_button", false, ReturnType.BOOLEAN), - @Deprecated - DEPRECATED_HIDE_PLAYLIST_BUTTON("revanced_playlist_button", false, ReturnType.BOOLEAN), - @Deprecated - DEPRECATED_HIDE_ACTION_BUTTON("revanced_action_button", false, ReturnType.BOOLEAN), - @Deprecated - DEPRECATED_HIDE_SHARE_BUTTON("revanced_share_button", false, ReturnType.BOOLEAN), - @Deprecated - DEPRECATED_FULLSCREEN_PANELS_SHOWN("revanced_fullscreen_panels_enabled", false, ReturnType.BOOLEAN), - @Deprecated - DEPRECATED_CREATE_BUTTON_ENABLED("revanced_create_button_enabled", false, ReturnType.BOOLEAN, true), - @Deprecated - DEPRECATED_SHORTS_BUTTON_SHOWN("revanced_shorts_button_enabled", false, ReturnType.BOOLEAN, true), - @Deprecated - DEPRECATED_REEL_BUTTON_SHOWN("revanced_reel_button_enabled", false, ReturnType.BOOLEAN, true), - @Deprecated - DEPRECATED_AUTOPLAY_BUTTON_SHOWN("revanced_autoplay_button_enabled", false, ReturnType.BOOLEAN, true), - @Deprecated - DEPRECATED_CAST_BUTTON_SHOWN("revanced_cast_button_enabled", false, ReturnType.BOOLEAN, true), - @Deprecated - DEPRECATED_BRANDING_SHOWN("revanced_branding_watermark_enabled", false, ReturnType.BOOLEAN), - @Deprecated - DEPRECATED_REMEMBER_VIDEO_QUALITY("revanced_remember_video_quality_selection", false, ReturnType.BOOLEAN), - @Deprecated - DEPRECATED_DOWNLOADS_BUTTON_SHOWN("revanced_downloads", true, ReturnType.BOOLEAN, true), - @Deprecated - DEPRECATED_COPY_VIDEO_URL_BUTTON_SHOWN("revanced_copy_video_url", true, ReturnType.BOOLEAN, true), - @Deprecated - DEPRECATED_COPY_VIDEO_URL_TIMESTAMP_BUTTON_SHOWN("revanced_copy_video_url_timestamp", true, ReturnType.BOOLEAN, true), - @Deprecated - DEPRECATED_HIDE_TIME("revanced_hide_time", false, ReturnType.BOOLEAN); - - // - // end deprecated settings - // + SB_API_URL("sb-api-host-url", "https://sponsor.ajay.app", SharedPrefHelper.SharedPrefNames.SPONSOR_BLOCK, ReturnType.STRING); private final String path; private final Object defaultValue; @@ -234,69 +187,6 @@ public enum SettingsEnum { static { load(); - - // - // temporary code to migrate user configuration of old settings into current settings - // FIXME: eventually delete this code - // - - // old/new settings where old is default off, and new has inverted value and is default on - SettingsEnum[][] invertedSettingsToMigrate = { - {DEPRECATED_FULLSCREEN_PANELS_SHOWN, HIDE_FULLSCREEN_PANELS}, - {DEPRECATED_CREATE_BUTTON_ENABLED, HIDE_CREATE_BUTTON}, - {DEPRECATED_SHORTS_BUTTON_SHOWN, HIDE_SHORTS_BUTTON}, - {DEPRECATED_REEL_BUTTON_SHOWN, HIDE_REEL_BUTTON}, - {DEPRECATED_AUTOPLAY_BUTTON_SHOWN, HIDE_AUTOPLAY_BUTTON}, - {DEPRECATED_CAST_BUTTON_SHOWN, HIDE_CAST_BUTTON}, - {DEPRECATED_BRANDING_SHOWN, HIDE_VIDEO_WATERMARK}, - {DEPRECATED_REMEMBER_VIDEO_QUALITY, REMEMBER_VIDEO_QUALITY_LAST_SELECTED}, - {DEPRECATED_HIDE_TIME, HIDE_TIMESTAMP} - }; - for (SettingsEnum[] oldNewSetting : invertedSettingsToMigrate) { - // by default, old setting was default off - // migrate to new setting of default on - SettingsEnum oldSetting = oldNewSetting[0]; - SettingsEnum newSetting = oldNewSetting[1]; - - // only need to check if old setting was turned on - if (oldSetting.getBoolean()) { - // this code will only run once - LogHelper.printInfo(() -> "Migrating setting: " + oldSetting + " of 'true' to new setting: " - + newSetting + " of 'false'"); - newSetting.saveValue(false); // set opposite of old value - oldSetting.saveValue(false); // clear old value - } - } - - // - // renamed settings with new path names, but otherwise the new and old settings are identical - // - SettingsEnum[][] renamedSettings = { - {DEPRECATED_HIDE_MIX_PLAYLISTS, HIDE_MIX_PLAYLISTS}, - {DEPRECATED_HIDE_LIKE_BUTTON, HIDE_LIKE_BUTTON}, - {DEPRECATED_HIDE_DISLIKE_BUTTON, HIDE_DISLIKE_BUTTON}, - {DEPRECATED_HIDE_DOWNLOAD_BUTTON, HIDE_DOWNLOAD_BUTTON}, - {DEPRECATED_HIDE_PLAYLIST_BUTTON, HIDE_PLAYLIST_BUTTON}, - {DEPRECATED_HIDE_ACTION_BUTTON, HIDE_ACTION_BUTTON}, - {DEPRECATED_HIDE_SHARE_BUTTON, HIDE_SHARE_BUTTON}, - {DEPRECATED_DOWNLOADS_BUTTON_SHOWN, DOWNLOADS_BUTTON_SHOWN}, - {DEPRECATED_COPY_VIDEO_URL_BUTTON_SHOWN, COPY_VIDEO_URL_BUTTON_SHOWN}, - {DEPRECATED_COPY_VIDEO_URL_TIMESTAMP_BUTTON_SHOWN, COPY_VIDEO_URL_TIMESTAMP_BUTTON_SHOWN}, - }; - for (SettingsEnum[] oldNewSetting : renamedSettings) { - SettingsEnum oldSetting = oldNewSetting[0]; - SettingsEnum newSetting = oldNewSetting[1]; - - if (!oldSetting.value.equals(oldSetting.defaultValue)) { - LogHelper.printInfo(() -> "Migrating old setting of '" + oldSetting.value - + "' from: " + oldSetting + " into replacement setting: " + newSetting); - newSetting.saveValue(oldSetting.value); - oldSetting.saveValue(oldSetting.getDefaultValue()); // reset old value - } - } - // - // end temporary code - // } private static void load() { From a1d4fabaaf8dc9d74d290ef7a4d236ac88909f2f Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Sun, 26 Feb 2023 23:14:24 +0100 Subject: [PATCH 14/24] refactor(youtube/settings): remove unused code Signed-off-by: oSumAtrIX --- .../integrations/settings/SettingsEnum.java | 13 ------------- 1 file changed, 13 deletions(-) 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 5d81bedf..eb414f67 100644 --- a/app/src/main/java/app/revanced/integrations/settings/SettingsEnum.java +++ b/app/src/main/java/app/revanced/integrations/settings/SettingsEnum.java @@ -5,9 +5,6 @@ import app.revanced.integrations.utils.LogHelper; import app.revanced.integrations.utils.ReVancedUtils; import app.revanced.integrations.utils.SharedPrefHelper; -import java.util.ArrayList; -import java.util.List; - public enum SettingsEnum { //Download Settings // TODO: DOWNLOAD_PATH("revanced_download_path", Environment.getExternalStorageDirectory().getPath() + "/Download", ReturnType.STRING), @@ -222,16 +219,6 @@ public enum SettingsEnum { } } - public static List getAdRemovalSettings() { - List list = new ArrayList<>(); - for (SettingsEnum var : SettingsEnum.values()) { - if (var.toString().startsWith("ADREMOVER")) { - list.add(var); - } - } - return list; - } - /** * Sets, but does _not_ persistently save the value. * From 040ba2464098bb893ab48729757f185e4571ffbd Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Sun, 26 Feb 2023 22:17:18 +0000 Subject: [PATCH 15/24] chore(release): 0.100.0-dev.5 [skip ci] # [0.100.0-dev.5](https://github.com/revanced/revanced-integrations/compare/v0.100.0-dev.4...v0.100.0-dev.5) (2023-02-26) ### Features * **youtube/hide-autoplay-button:** do not disable autoplay button when hidden ([519c2bd](https://github.com/revanced/revanced-integrations/commit/519c2bd5118db41fc512a665d9454b902134ba2c)) * **youtube:** `hide-floating-microphone-button` patch ([cb77e96](https://github.com/revanced/revanced-integrations/commit/cb77e96da91bb4707d8559757cd86a7583f8048b)) --- CHANGELOG.md | 8 ++++++++ gradle.properties | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2a8750e5..e4f4d93b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,11 @@ +# [0.100.0-dev.5](https://github.com/revanced/revanced-integrations/compare/v0.100.0-dev.4...v0.100.0-dev.5) (2023-02-26) + + +### Features + +* **youtube/hide-autoplay-button:** do not disable autoplay button when hidden ([519c2bd](https://github.com/revanced/revanced-integrations/commit/519c2bd5118db41fc512a665d9454b902134ba2c)) +* **youtube:** `hide-floating-microphone-button` patch ([cb77e96](https://github.com/revanced/revanced-integrations/commit/cb77e96da91bb4707d8559757cd86a7583f8048b)) + # [0.100.0-dev.4](https://github.com/revanced/revanced-integrations/compare/v0.100.0-dev.3...v0.100.0-dev.4) (2023-02-26) diff --git a/gradle.properties b/gradle.properties index 8551ae7d..ca048a8a 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,3 +1,3 @@ org.gradle.jvmargs = -Xmx2048m android.useAndroidX = true -version = 0.100.0-dev.4 +version = 0.100.0-dev.5 From 919f2855edff0acc96c42ea733fff41a55211e48 Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Sun, 26 Feb 2023 23:19:31 +0100 Subject: [PATCH 16/24] fix(youtube/hide-floating-microphone-button): reboot when changing settings Signed-off-by: oSumAtrIX --- .../integrations/patches/HideFloatingMicrophoneButtonPatch.java | 2 +- .../java/app/revanced/integrations/settings/SettingsEnum.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/app/revanced/integrations/patches/HideFloatingMicrophoneButtonPatch.java b/app/src/main/java/app/revanced/integrations/patches/HideFloatingMicrophoneButtonPatch.java index 17cb5779..ece09ff5 100644 --- a/app/src/main/java/app/revanced/integrations/patches/HideFloatingMicrophoneButtonPatch.java +++ b/app/src/main/java/app/revanced/integrations/patches/HideFloatingMicrophoneButtonPatch.java @@ -3,7 +3,7 @@ package app.revanced.integrations.patches; import app.revanced.integrations.settings.SettingsEnum; public final class HideFloatingMicrophoneButtonPatch { - public static boolean hideFloatingMicrophoneButton(boolean original) { + public static boolean hideFloatingMicrophoneButton(final boolean original) { return SettingsEnum.HIDE_FLOATING_MICROPHONE_BUTTON.getBoolean() || original; } } 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 eb414f67..3d1b59de 100644 --- a/app/src/main/java/app/revanced/integrations/settings/SettingsEnum.java +++ b/app/src/main/java/app/revanced/integrations/settings/SettingsEnum.java @@ -93,7 +93,7 @@ public enum SettingsEnum { HIDE_WATCH_IN_VR("revanced_hide_watch_in_vr", false, ReturnType.BOOLEAN, true), HIDE_BREAKING_NEWS("revanced_hide_breaking_news", true, ReturnType.BOOLEAN, true), HIDE_PLAYER_BUTTONS("revanced_hide_player_buttons", false, ReturnType.BOOLEAN), - HIDE_FLOATING_MICROPHONE_BUTTON("revanced_hide_floating_microphone_button", true, ReturnType.BOOLEAN), + HIDE_FLOATING_MICROPHONE_BUTTON("revanced_hide_floating_microphone_button", true, ReturnType.BOOLEAN, true), // Misc. Settings FIX_PLAYBACK("revanced_fix_playback", false, ReturnType.BOOLEAN), From 416c695837debefb4762d381f25157de480614cc Mon Sep 17 00:00:00 2001 From: LisousEinaiKyrios <118716522+LisoUseInAIKyrios@users.noreply.github.com> Date: Fri, 24 Feb 2023 12:51:13 +0400 Subject: [PATCH 17/24] fix(youtube/return-youtube-dislike): improve segmented like/dislike layout --- .../ReturnYouTubeDislike.java | 339 ++++++++---------- 1 file changed, 156 insertions(+), 183 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 3903ae33..158a0226 100644 --- a/app/src/main/java/app/revanced/integrations/returnyoutubedislike/ReturnYouTubeDislike.java +++ b/app/src/main/java/app/revanced/integrations/returnyoutubedislike/ReturnYouTubeDislike.java @@ -1,15 +1,36 @@ package app.revanced.integrations.returnyoutubedislike; +import static app.revanced.integrations.sponsorblock.StringRef.str; + +import android.graphics.Canvas; +import android.graphics.Paint; +import android.graphics.Rect; +import android.graphics.drawable.Drawable; +import android.graphics.drawable.ShapeDrawable; +import android.graphics.drawable.shapes.OvalShape; +import android.graphics.drawable.shapes.RectShape; import android.icu.text.CompactDecimalFormat; import android.os.Build; -import android.text.*; -import android.text.style.CharacterStyle; -import android.text.style.ForegroundColorSpan; -import android.text.style.RelativeSizeSpan; -import android.text.style.ScaleXSpan; +import android.text.Spannable; +import android.text.SpannableString; +import android.text.SpannableStringBuilder; +import android.text.Spanned; +import android.text.style.ImageSpan; + import androidx.annotation.GuardedBy; import androidx.annotation.NonNull; import androidx.annotation.Nullable; + +import java.text.NumberFormat; +import java.util.Locale; +import java.util.Objects; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.Future; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; +import java.util.concurrent.atomic.AtomicReference; + import app.revanced.integrations.returnyoutubedislike.requests.RYDVoteData; import app.revanced.integrations.returnyoutubedislike.requests.ReturnYouTubeDislikeApi; import app.revanced.integrations.settings.SettingsEnum; @@ -18,14 +39,6 @@ import app.revanced.integrations.utils.LogHelper; import app.revanced.integrations.utils.ReVancedUtils; import app.revanced.integrations.utils.ThemeHelper; -import java.text.NumberFormat; -import java.util.Locale; -import java.util.Objects; -import java.util.concurrent.*; -import java.util.concurrent.atomic.AtomicReference; - -import static app.revanced.integrations.sponsorblock.StringRef.str; - public class ReturnYouTubeDislike { /** * Maximum amount of time to block the UI from updates while waiting for network call to complete. @@ -36,9 +49,10 @@ public class ReturnYouTubeDislike { private static final long MAX_MILLISECONDS_TO_BLOCK_UI_WHILE_WAITING_FOR_FETCH_VOTES_TO_COMPLETE = 4000; /** - * Separator character to use for segmented like/dislike + * Unique placeholder character, used to detect if a segmented span already has dislikes added to it. + * Can be any almost any non-visible character */ - private static final char MIDDLE_SEPARATOR_CHARACTER = '•'; + private static final char MIDDLE_SEPARATOR_CHARACTER = '\u2009'; // 'narrow space' character /** * Used to send votes, one by one, in the same order the user created them @@ -177,49 +191,30 @@ public class ReturnYouTubeDislike { * This method can be called multiple times for the same UI element (including after dislikes was added) */ public static void onComponentCreated(@NonNull Object conversionContext, @NonNull AtomicReference textRef) { - if (!SettingsEnum.RYD_ENABLED.getBoolean()) return; - - // do not set lastVideoLoadedWasShort to false. It will be cleared when the next regular video is loaded. - if (lastVideoLoadedWasShort) { - return; - } - if (PlayerType.getCurrent().isNoneOrHidden()) { - return; - } - - String conversionContextString = conversionContext.toString(); - final boolean isSegmentedButton; - if (conversionContextString.contains("|segmented_like_dislike_button.eml|")) { - isSegmentedButton = true; - } else if (conversionContextString.contains("|dislike_button.eml|")) { - isSegmentedButton = false; - } else { - return; - } - try { + if (!SettingsEnum.RYD_ENABLED.getBoolean()) return; + + // do not set lastVideoLoadedWasShort to false. It will be cleared when the next regular video is loaded. + if (lastVideoLoadedWasShort || PlayerType.getCurrent().isNoneOrHidden()) { + return; + } + + String conversionContextString = conversionContext.toString(); + final boolean isSegmentedButton; + if (conversionContextString.contains("|segmented_like_dislike_button.eml|")) { + isSegmentedButton = true; + } else if (conversionContextString.contains("|dislike_button.eml|")) { + isSegmentedButton = false; + } else { + return; + } + Spanned replacement = waitForFetchAndUpdateReplacementSpan((Spanned) textRef.get(), isSegmentedButton); if (replacement != null) { textRef.set(replacement); } } catch (Exception ex) { - LogHelper.printException(() -> "Error while trying to update dislikes", ex); - } - } - - public static void sendVote(int vote) { - if (!SettingsEnum.RYD_ENABLED.getBoolean()) return; - - try { - for (ReturnYouTubeDislike.Vote v : ReturnYouTubeDislike.Vote.values()) { - if (v.value == vote) { - ReturnYouTubeDislike.sendVote(v); - return; - } - } - LogHelper.printException(() -> "Unknown vote type: " + vote); - } catch (Exception ex) { - LogHelper.printException(() -> "sendVote failure", ex); + LogHelper.printException(() -> "onComponentCreated failure", ex); } } @@ -238,7 +233,8 @@ public class ReturnYouTubeDislike { return span; } - private static boolean isPreviouslyCreatedSegmentedSpan(Spanned span) { + // alternatively, this could check if the span contains one of the custom created spans, but this is simple and quick + private static boolean isPreviouslyCreatedSegmentedSpan(@NonNull Spanned span) { return span.toString().indexOf(MIDDLE_SEPARATOR_CHARACTER) != -1; } @@ -246,7 +242,7 @@ public class ReturnYouTubeDislike { * @return NULL if the span does not need changing or if RYD is not available */ @Nullable - private static Spanned waitForFetchAndUpdateReplacementSpan(Spanned oldSpannable, boolean isSegmentedButton) { + private static Spanned waitForFetchAndUpdateReplacementSpan(@Nullable Spanned oldSpannable, boolean isSegmentedButton) { if (oldSpannable == null) { LogHelper.printDebug(() -> "Cannot add dislikes (injection code was called with null Span)"); return null; @@ -256,7 +252,7 @@ public class ReturnYouTubeDislike { long fetchStartTime = 0; try { synchronized (videoIdLockObject) { - if (oldSpannable == replacementLikeDislikeSpan) { + if (oldSpannable.equals(replacementLikeDislikeSpan)) { LogHelper.printDebug(() -> "Ignoring previously created dislike span"); return null; } @@ -264,6 +260,15 @@ public class ReturnYouTubeDislike { if (isPreviouslyCreatedSegmentedSpan(oldSpannable)) { // need to recreate using original, as oldSpannable has prior outdated dislike values oldSpannable = originalDislikeSpan; + if (oldSpannable == null) { + // Regular video is opened, then a short is opened then closed, + // then the app is closed then reopened (causes a call of NewVideoId() of the original videoId) + // The original video (that was opened the entire time), is still showing the dislikes count + // but the oldSpannable is now null because it was reset when the videoId was set again + LogHelper.printDebug(() -> "Cannot add dislikes - original span is null" + + " (short was opened/closed, then app was closed/opened?) "); // ignore, with no toast + return null; + } } else { originalDislikeSpan = oldSpannable; // most up to date original } @@ -301,7 +306,23 @@ public class ReturnYouTubeDislike { return null; } - public static void sendVote(@NonNull Vote vote) { + public static void sendVote(int vote) { + if (!SettingsEnum.RYD_ENABLED.getBoolean()) return; + + try { + for (Vote v : Vote.values()) { + if (v.value == vote) { + sendVote(v); + return; + } + } + LogHelper.printException(() -> "Unknown vote type: " + vote); + } catch (Exception ex) { + LogHelper.printException(() -> "sendVote failure", ex); + } + } + + private static void sendVote(@NonNull Vote vote) { ReVancedUtils.verifyOnMainThread(); Objects.requireNonNull(vote); try { @@ -326,11 +347,11 @@ public class ReturnYouTubeDislike { } }); - // update the downloaded vote data synchronized (videoIdLockObject) { replacementLikeDislikeSpan = null; // ui values need updating } + // update the downloaded vote data Future future = getVoteFetchFuture(); if (future == null) { LogHelper.printException(() -> "Cannot update UI dislike count - vote fetch is null"); @@ -374,7 +395,7 @@ public class ReturnYouTubeDislike { /** * @param isSegmentedButton if UI is using the segmented single UI component for both like and dislike */ - private static Spanned createDislikeSpan(Spanned oldSpannable, boolean isSegmentedButton, RYDVoteData voteData) { + private static Spanned createDislikeSpan(@NonNull Spanned oldSpannable, boolean isSegmentedButton, @NonNull RYDVoteData voteData) { if (!isSegmentedButton) { // simple replacement of 'dislike' with a number/percentage return newSpannableWithDislikes(oldSpannable, voteData); @@ -393,150 +414,66 @@ public class ReturnYouTubeDislike { // likes are hidden. // RYD does not provide usable data for these types of videos, // and the API returns bogus data (zero likes and zero dislikes) + // discussion about this: https://github.com/Anarios/return-youtube-dislike/discussions/530 // // example video: https://www.youtube.com/watch?v=UnrU5vxCHxw // RYD data: https://returnyoutubedislikeapi.com/votes?videoId=UnrU5vxCHxw - // - // discussion about this: https://github.com/Anarios/return-youtube-dislike/discussions/530 - // // Change the "Likes" string to show that likes and dislikes are hidden - // String hiddenMessageString = str("revanced_ryd_video_likes_hidden_by_video_owner"); return newSpanUsingStylingOfAnotherSpan(oldSpannable, hiddenMessageString); } - Spannable likesSpan = newSpanUsingStylingOfAnotherSpan(oldSpannable, oldLikesString); - - // middle separator - final boolean useCompactLayout = SettingsEnum.RYD_USE_COMPACT_LAYOUT.getBoolean(); + SpannableStringBuilder builder = new SpannableStringBuilder(); + final boolean compactLayout = SettingsEnum.RYD_USE_COMPACT_LAYOUT.getBoolean(); final int separatorColor = ThemeHelper.isDarkTheme() ? 0x29AAAAAA // transparent dark gray : 0xFFD9D9D9; // light gray - String middleSegmentedSeparatorString = useCompactLayout - ? "\u2009 " + MIDDLE_SEPARATOR_CHARACTER + " \u2009" // u2009 = "half space" character - : " " + MIDDLE_SEPARATOR_CHARACTER + " "; - Spannable middleSeparatorSpan = newSpanUsingStylingOfAnotherSpan(oldSpannable, middleSegmentedSeparatorString); - addSpanStyling(middleSeparatorSpan, new ForegroundColorSpan(separatorColor)); - CharacterStyle noAntiAliasingStyle = new CharacterStyle() { - @Override - public void updateDrawState(TextPaint tp) { - tp.setAntiAlias(false); // draw without anti-aliasing, to give a sharper edge - } - }; - addSpanStyling(middleSeparatorSpan, noAntiAliasingStyle); - - Spannable dislikeSpan = newSpannableWithDislikes(oldSpannable, voteData); - - SpannableStringBuilder builder = new SpannableStringBuilder(); - if (!useCompactLayout) { - String leftSegmentedSeparatorString = ReVancedUtils.isRightToLeftTextLayout() ? "\u200F| " : "| "; // u200f = right to left character - Spannable leftSeparatorSpan = newSpanUsingStylingOfAnotherSpan(oldSpannable, leftSegmentedSeparatorString); - addSpanStyling(leftSeparatorSpan, new ForegroundColorSpan(separatorColor)); - addSpanStyling(leftSeparatorSpan, noAntiAliasingStyle); - - // Use a left separator with a larger font and visually match the stock right separator. - // But with a larger font, the entire span (including the like/dislike text) becomes shifted downward. - // To correct this, use additional spans to move the alignment back upward by a relative amount. - setSegmentedAdjustmentValues(); - class RelativeVerticalOffsetSpan extends CharacterStyle { - final float relativeVerticalShiftRatio; - - RelativeVerticalOffsetSpan(float relativeVerticalShiftRatio) { - this.relativeVerticalShiftRatio = relativeVerticalShiftRatio; - } - - @Override - public void updateDrawState(TextPaint tp) { - tp.baselineShift -= (int) (relativeVerticalShiftRatio * tp.getFontMetrics().top); - } - } - // each section needs it's own Relative span, otherwise alignment is wrong - addSpanStyling(leftSeparatorSpan, new RelativeVerticalOffsetSpan(segmentedLeftSeparatorVerticalShiftRatio)); - - addSpanStyling(likesSpan, new RelativeVerticalOffsetSpan(segmentedVerticalShiftRatio)); - addSpanStyling(middleSeparatorSpan, new RelativeVerticalOffsetSpan(segmentedVerticalShiftRatio)); - addSpanStyling(dislikeSpan, new RelativeVerticalOffsetSpan(segmentedVerticalShiftRatio)); - - // important: must add size scaling after vertical offset (otherwise alignment gets off) - addSpanStyling(leftSeparatorSpan, new RelativeSizeSpan(segmentedLeftSeparatorFontRatio)); - addSpanStyling(leftSeparatorSpan, new ScaleXSpan(segmentedLeftSeparatorHorizontalScaleRatio)); - // middle separator does not need resizing - + if (!compactLayout) { + // left separator + final Rect leftSeparatorBounds = new Rect(0, 0, 3, 54); + String leftSeparatorString = ReVancedUtils.isRightToLeftTextLayout() + ? "\u200F " // u200F = right to left character + : "\u2FF0 "; // u2FF0 = left to right character + Spannable leftSeparatorSpan = new SpannableString(leftSeparatorString); + ShapeDrawable shapeDrawable = new ShapeDrawable(new RectShape()); + shapeDrawable.getPaint().setColor(separatorColor); + shapeDrawable.setBounds(leftSeparatorBounds); + leftSeparatorSpan.setSpan(new VerticallyCenteredImageSpan(shapeDrawable), 0, 1, + Spannable.SPAN_INCLUSIVE_EXCLUSIVE); builder.append(leftSeparatorSpan); } - builder.append(likesSpan); + // likes + builder.append(newSpanUsingStylingOfAnotherSpan(oldSpannable, oldLikesString)); + + // middle separator + String middleSeparatorString = compactLayout + ? " " + MIDDLE_SEPARATOR_CHARACTER + " " + : " \u2009" + MIDDLE_SEPARATOR_CHARACTER + "\u2009 "; // u2009 = 'narrow space' character + final int shapeInsertionIndex = middleSeparatorString.length() / 2; + final Rect middleSeparatorBounds = new Rect(0, 0, 10, 10); + Spannable middleSeparatorSpan = new SpannableString(middleSeparatorString); + ShapeDrawable shapeDrawable = new ShapeDrawable(new OvalShape()); + shapeDrawable.getPaint().setColor(separatorColor); + shapeDrawable.setBounds(middleSeparatorBounds); + middleSeparatorSpan.setSpan(new VerticallyCenteredImageSpan(shapeDrawable), shapeInsertionIndex, shapeInsertionIndex + 1, + Spannable.SPAN_INCLUSIVE_EXCLUSIVE); builder.append(middleSeparatorSpan); - builder.append(dislikeSpan); + + // dislikes + builder.append(newSpannableWithDislikes(oldSpannable, voteData)); + return new SpannableString(builder); } - private static boolean segmentedValuesSet = false; - private static float segmentedVerticalShiftRatio; - private static float segmentedLeftSeparatorVerticalShiftRatio; - private static float segmentedLeftSeparatorFontRatio; - private static float segmentedLeftSeparatorHorizontalScaleRatio; - - /** - * Set the segmented adjustment values, based on the device. - */ - private static void setSegmentedAdjustmentValues() { - if (segmentedValuesSet) { - return; - } - - String deviceManufacturer = Build.MANUFACTURER; - final int deviceSdkVersion = Build.VERSION.SDK_INT; - LogHelper.printDebug(() -> "Device manufacturer: '" + deviceManufacturer + "' SDK: " + deviceSdkVersion); - - // - // Important: configurations must be with the device default system font, and default font size. - // - // In general, a single configuration will give perfect layout for all devices of the same manufacturer. - final String configManufacturer; - final int configSdk; - switch (deviceManufacturer) { - default: // use Google layout by default - case "Google": - // logging and documentation - configManufacturer = "Google"; - configSdk = 33; - // tested on Android 10 thru 13, and works well for all - segmentedLeftSeparatorVerticalShiftRatio = segmentedVerticalShiftRatio = -0.18f; // move separators and like/dislike up by 18% - segmentedLeftSeparatorFontRatio = 1.8f; // increase left separator size by 80% - segmentedLeftSeparatorHorizontalScaleRatio = 0.65f; // horizontally compress left separator by 35% - break; - case "samsung": - configManufacturer = "samsung"; - configSdk = 33; - // tested on S22 - segmentedLeftSeparatorVerticalShiftRatio = segmentedVerticalShiftRatio = -0.19f; - segmentedLeftSeparatorFontRatio = 1.5f; - segmentedLeftSeparatorHorizontalScaleRatio = 0.7f; - break; - case "OnePlus": - configManufacturer = "OnePlus"; - configSdk = 33; - // tested on OnePlus 8 Pro - segmentedLeftSeparatorVerticalShiftRatio = -0.075f; - segmentedVerticalShiftRatio = -0.38f; - segmentedLeftSeparatorFontRatio = 1.87f; - segmentedLeftSeparatorHorizontalScaleRatio = 0.50f; - break; - } - - LogHelper.printDebug(() -> "Using layout adjustments based on manufacturer: '" + configManufacturer + "' SDK: " + configSdk); - segmentedValuesSet = true; - } - /** * Correctly handles any unicode numbers (such as Arabic numbers) * * @return if the string contains at least 1 number */ - private static boolean stringContainsNumber(String text) { + private static boolean stringContainsNumber(@NonNull String text) { for (int index = 0, length = text.length(); index < length; index++) { if (Character.isDigit(text.codePointAt(index))) { return true; @@ -545,18 +482,14 @@ public class ReturnYouTubeDislike { return false; } - private static void addSpanStyling(Spannable destination, Object styling) { - destination.setSpan(styling, 0, destination.length(), 0); - } - - private static Spannable newSpannableWithDislikes(Spanned sourceStyling, RYDVoteData voteData) { + private static Spannable newSpannableWithDislikes(@NonNull Spanned sourceStyling, @NonNull RYDVoteData voteData) { return newSpanUsingStylingOfAnotherSpan(sourceStyling, SettingsEnum.RYD_SHOW_DISLIKE_PERCENTAGE.getBoolean() ? formatDislikePercentage(voteData.getDislikePercentage()) : formatDislikeCount(voteData.getDislikeCount())); } - private static Spannable newSpanUsingStylingOfAnotherSpan(Spanned sourceStyle, String newSpanText) { + private static Spannable newSpanUsingStylingOfAnotherSpan(@NonNull Spanned sourceStyle, @NonNull String newSpanText) { SpannableString destination = new SpannableString(newSpanText); Object[] spans = sourceStyle.getSpans(0, sourceStyle.length(), Object.class); for (Object span : spans) { @@ -628,3 +561,43 @@ public class ReturnYouTubeDislike { + "average wait time: " + averageTimeForcedToWait + "ms"); } } + +class VerticallyCenteredImageSpan extends ImageSpan { + public VerticallyCenteredImageSpan(Drawable drawable) { + super(drawable); + } + + @Override + public int getSize(@NonNull Paint paint, @NonNull CharSequence text, + int start, int end, @Nullable Paint.FontMetricsInt fontMetrics) { + Drawable drawable = getDrawable(); + Rect bounds = drawable.getBounds(); + if (fontMetrics != null) { + Paint.FontMetricsInt paintMetrics = paint.getFontMetricsInt(); + final int fontHeight = paintMetrics.descent - paintMetrics.ascent; + final int drawHeight = bounds.bottom - bounds.top; + final int yCenter = paintMetrics.ascent + fontHeight / 2; + + fontMetrics.ascent = yCenter - drawHeight / 2; + fontMetrics.top = fontMetrics.ascent; + fontMetrics.bottom = yCenter + drawHeight / 2; + fontMetrics.descent = fontMetrics.bottom; + } + return bounds.right; + } + + @Override + public void draw(@NonNull Canvas canvas, CharSequence text, int start, int end, + float x, int top, int y, int bottom, @NonNull Paint paint) { + Drawable drawable = getDrawable(); + canvas.save(); + Paint.FontMetricsInt paintMetrics = paint.getFontMetricsInt(); + final int fontHeight = paintMetrics.descent - paintMetrics.ascent; + final int yCenter = y + paintMetrics.descent - fontHeight / 2; + final Rect drawBounds = drawable.getBounds(); + final int translateY = yCenter - (drawBounds.bottom - drawBounds.top) / 2; + canvas.translate(x, translateY); + drawable.draw(canvas); + canvas.restore(); + } +} \ No newline at end of file From 0c725218fd7abaeed6ec45d76940541499fcafd2 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Sun, 26 Feb 2023 23:25:49 +0000 Subject: [PATCH 18/24] chore(release): 0.100.0-dev.6 [skip ci] # [0.100.0-dev.6](https://github.com/revanced/revanced-integrations/compare/v0.100.0-dev.5...v0.100.0-dev.6) (2023-02-26) ### Bug Fixes * **youtube/hide-floating-microphone-button:** reboot when changing settings ([919f285](https://github.com/revanced/revanced-integrations/commit/919f2855edff0acc96c42ea733fff41a55211e48)) --- CHANGELOG.md | 7 +++++++ gradle.properties | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e4f4d93b..6ccbe7c5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +# [0.100.0-dev.6](https://github.com/revanced/revanced-integrations/compare/v0.100.0-dev.5...v0.100.0-dev.6) (2023-02-26) + + +### Bug Fixes + +* **youtube/hide-floating-microphone-button:** reboot when changing settings ([919f285](https://github.com/revanced/revanced-integrations/commit/919f2855edff0acc96c42ea733fff41a55211e48)) + # [0.100.0-dev.5](https://github.com/revanced/revanced-integrations/compare/v0.100.0-dev.4...v0.100.0-dev.5) (2023-02-26) diff --git a/gradle.properties b/gradle.properties index ca048a8a..378dae5e 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,3 +1,3 @@ org.gradle.jvmargs = -Xmx2048m android.useAndroidX = true -version = 0.100.0-dev.5 +version = 0.100.0-dev.6 From 1f90f7b9cca2445c776f4f0c8af1ddd0c9bde5f0 Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Mon, 6 Mar 2023 09:19:18 +0100 Subject: [PATCH 19/24] fix(youtube/remember-video-quality): treat any connection as wifi except mobile and bluetooth --- .../quality/RememberVideoQualityPatch.java | 148 +++++++++--------- 1 file changed, 72 insertions(+), 76 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 3a883967..5ce054ea 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,21 +1,18 @@ package app.revanced.integrations.patches.playback.quality; -import android.annotation.SuppressLint; import android.content.Context; import android.net.ConnectivityManager; -import android.net.NetworkInfo; import android.widget.Toast; +import app.revanced.integrations.settings.SettingsEnum; +import app.revanced.integrations.utils.LogHelper; +import app.revanced.integrations.utils.ReVancedUtils; +import app.revanced.integrations.utils.SharedPrefHelper; import java.lang.reflect.Field; import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Collections; -import app.revanced.integrations.settings.SettingsEnum; -import app.revanced.integrations.utils.LogHelper; -import app.revanced.integrations.utils.ReVancedUtils; -import app.revanced.integrations.utils.SharedPrefHelper; - public class RememberVideoQualityPatch { public static int selectedQuality1 = -2; @@ -24,38 +21,37 @@ public class RememberVideoQualityPatch { public static void changeDefaultQuality(int defaultQuality) { Context context = ReVancedUtils.getContext(); - if (isConnectedWifi(context)) { - try { - SharedPrefHelper.saveString(SharedPrefHelper.SharedPrefNames.REVANCED_PREFS, "wifi_quality", defaultQuality + ""); - String message = "Changing default Wi-Fi quality to: " + defaultQuality; - LogHelper.printDebug(() -> message); - Toast.makeText(context, message, Toast.LENGTH_SHORT).show(); - } catch (Exception ex) { - LogHelper.printException(() -> "Failed to change default WI-FI quality", ex); - } - } else if (isConnectedMobile(context)) { - try { - SharedPrefHelper.saveString(SharedPrefHelper.SharedPrefNames.REVANCED_PREFS, "mobile_quality", defaultQuality + ""); - String message = "Changing default mobile data quality to:" + defaultQuality; - LogHelper.printDebug(() -> message); - Toast.makeText(context, message, Toast.LENGTH_SHORT).show(); - } catch (Exception ex) { - LogHelper.printException(() -> "Failed to change default mobile data quality", ex); - } - } else { + + var networkType = getNetworType(context); + + if (networkType == NetworkType.NONE) { String message = "No internet connection."; LogHelper.printDebug(() -> message); Toast.makeText(context, message, Toast.LENGTH_SHORT).show(); + } else { + var preferenceKey = "wifi_quality"; + var networkTypeMessage = "WIFI"; + + if (networkType == NetworkType.MOBILE) { + networkTypeMessage = "mobile"; + preferenceKey = "mobile_quality"; + } + + SharedPrefHelper.saveString(SharedPrefHelper.SharedPrefNames.REVANCED_PREFS, preferenceKey, defaultQuality + ""); + String message = "Changing default" + networkTypeMessage + "quality to:" + defaultQuality; + Toast.makeText(context, message, Toast.LENGTH_SHORT).show(); } + userChangedQuality = false; } public static int setVideoQuality(Object[] qualities, int quality, Object qInterface, String qIndexMethod) { - int preferredQuality; Field[] fields; + if (!(newVideo || userChangedQuality) || qInterface == null) { return quality; } + Class intType = Integer.TYPE; ArrayList iStreamQualities = new ArrayList<>(); try { @@ -93,51 +89,48 @@ public class RememberVideoQualityPatch { LogHelper.printException(() -> "Context is null or settings not initialized, returning quality: " + qualityToLog); return quality; } - if (isConnectedWifi(context)) { - preferredQuality = SharedPrefHelper.getInt(SharedPrefHelper.SharedPrefNames.REVANCED_PREFS, "wifi_quality", -2); - LogHelper.printDebug(() -> "Wi-Fi connection detected, preferred quality: " + preferredQuality); - } else if (isConnectedMobile(context)) { - preferredQuality = SharedPrefHelper.getInt(SharedPrefHelper.SharedPrefNames.REVANCED_PREFS, "mobile_quality", -2); - LogHelper.printDebug(() -> "Mobile data connection detected, preferred quality: " + preferredQuality); - } else { + var networkType = getNetworType(context); + if (networkType == NetworkType.NONE) { LogHelper.printDebug(() -> "No Internet connection!"); return quality; - } - if (preferredQuality == -2) { - return quality; - } - for (int streamQuality2 : iStreamQualities) { - final int indexToLog = index; - LogHelper.printDebug(() -> "Quality at index " + indexToLog + ": " + streamQuality2); - index++; - } - for (Integer iStreamQuality : iStreamQualities) { - int streamQuality3 = iStreamQuality; - if (streamQuality3 <= preferredQuality) { - quality = streamQuality3; + } else { + var preferenceKey = "wifi_quality"; + if (networkType == NetworkType.MOBILE) preferenceKey = "mobile_quality"; + + int preferredQuality = SharedPrefHelper.getInt(SharedPrefHelper.SharedPrefNames.REVANCED_PREFS, preferenceKey, -2); + if (preferredQuality == -2) return quality; + + for (int streamQuality2 : iStreamQualities) { + final int indexToLog = index; + LogHelper.printDebug(() -> "Quality at index " + indexToLog + ": " + streamQuality2); + index++; + } + for (Integer iStreamQuality : iStreamQualities) { + int streamQuality3 = iStreamQuality; + if (streamQuality3 <= preferredQuality) { + quality = streamQuality3; + } + } + if (quality == -2) return quality; + + int qualityIndex = iStreamQualities.indexOf(quality); + final int qualityToLog2 = quality; + LogHelper.printDebug(() -> "Index of quality " + qualityToLog2 + " is " + qualityIndex); + try { + Class cl = qInterface.getClass(); + Method m = cl.getMethod(qIndexMethod, Integer.TYPE); + LogHelper.printDebug(() -> "Method is: " + qIndexMethod); + m.invoke(qInterface, iStreamQualities.get(qualityIndex)); + LogHelper.printDebug(() -> "Quality changed to: " + qualityIndex); + return qualityIndex; + } catch (Exception ex) { + LogHelper.printException(() -> "Failed to set quality", ex); + return qualityIndex; } - } - if (quality == -2) { - return quality; - } - int qualityIndex = iStreamQualities.indexOf(quality); - final int qualityToLog2 = quality; - LogHelper.printDebug(() -> "Index of quality " + qualityToLog2 + " is " + qualityIndex); - try { - Class cl = qInterface.getClass(); - Method m = cl.getMethod(qIndexMethod, Integer.TYPE); - LogHelper.printDebug(() -> "Method is: " + qIndexMethod); - m.invoke(qInterface, iStreamQualities.get(qualityIndex)); - LogHelper.printDebug(() -> "Quality changed to: " + qualityIndex); - return qualityIndex; - } catch (Exception ex) { - LogHelper.printException(() -> "Failed to set quality", ex); - return qualityIndex; } } public static void userChangedQuality(int selectedQuality) { - // Do not remember a **new** quality if REMEMBER_VIDEO_QUALITY is false if (!SettingsEnum.REMEMBER_VIDEO_QUALITY_LAST_SELECTED.getBoolean()) return; selectedQuality1 = selectedQuality; @@ -148,20 +141,23 @@ public class RememberVideoQualityPatch { newVideo = true; } - @SuppressLint("MissingPermission") - private static NetworkInfo getNetworkInfo(Context context) { + private static NetworkType getNetworType(Context context) { ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); - return cm.getActiveNetworkInfo(); + var networkInfo = cm.getActiveNetworkInfo(); + + if (networkInfo == null || !networkInfo.isConnected()) { + return NetworkType.NONE; + } else { + var type = networkInfo.getType(); + + return type == ConnectivityManager.TYPE_MOBILE || type == ConnectivityManager.TYPE_BLUETOOTH ? NetworkType.MOBILE : NetworkType.OTHER; + } } - private static boolean isConnectedWifi(Context context) { - NetworkInfo info = getNetworkInfo(context); - return info != null && info.isConnected() && info.getType() == 1; - } - - private static boolean isConnectedMobile(Context context) { - NetworkInfo info = getNetworkInfo(context); - return info != null && info.isConnected() && info.getType() == 0; + enum NetworkType { + MOBILE, + OTHER, + NONE } } From 67fa87051f929238a54143c4147c1736bf0d9106 Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Mon, 6 Mar 2023 10:51:05 +0100 Subject: [PATCH 20/24] chore: fix logging message --- .../patches/playback/quality/RememberVideoQualityPatch.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 5ce054ea..d5c79a7d 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,7 +38,7 @@ public class RememberVideoQualityPatch { } SharedPrefHelper.saveString(SharedPrefHelper.SharedPrefNames.REVANCED_PREFS, preferenceKey, defaultQuality + ""); - String message = "Changing default" + networkTypeMessage + "quality to:" + defaultQuality; + String message = "Changing default " + networkTypeMessage + " quality to: " + defaultQuality; Toast.makeText(context, message, Toast.LENGTH_SHORT).show(); } From 844bc3b24fe9a2d6b69367d79ad99e452e8a7604 Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Sun, 12 Mar 2023 21:56:06 +0100 Subject: [PATCH 21/24] feat(youtube/general-ads): hide new type of ad --- .../app/revanced/integrations/patches/GeneralAdsPatch.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/app/revanced/integrations/patches/GeneralAdsPatch.java b/app/src/main/java/app/revanced/integrations/patches/GeneralAdsPatch.java index 40a55282..fed574a6 100644 --- a/app/src/main/java/app/revanced/integrations/patches/GeneralAdsPatch.java +++ b/app/src/main/java/app/revanced/integrations/patches/GeneralAdsPatch.java @@ -59,7 +59,8 @@ public final class GeneralAdsPatch extends Filter { "watch_metadata_app_promo", "video_display_full_layout", "hero_promo_image", - "statement_banner" + "statement_banner", + "text_image_button_layout" ); var movieAds = new BlockRule( SettingsEnum.ADREMOVER_MOVIE_REMOVAL, From d5919a8a2cff09bb884ea01ca6b01d8d2d0b8980 Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Mon, 13 Mar 2023 00:24:29 +0100 Subject: [PATCH 22/24] feat(youtube): remove `custom-video-buffer` patch (#1718) --- .../patches/VideoBufferPatch.java | 26 ------------------- .../integrations/settings/SettingsEnum.java | 5 ---- 2 files changed, 31 deletions(-) delete mode 100644 app/src/main/java/app/revanced/integrations/patches/VideoBufferPatch.java diff --git a/app/src/main/java/app/revanced/integrations/patches/VideoBufferPatch.java b/app/src/main/java/app/revanced/integrations/patches/VideoBufferPatch.java deleted file mode 100644 index 14ad96b5..00000000 --- a/app/src/main/java/app/revanced/integrations/patches/VideoBufferPatch.java +++ /dev/null @@ -1,26 +0,0 @@ -package app.revanced.integrations.patches; - -import app.revanced.integrations.settings.SettingsEnum; - -public class VideoBufferPatch { - - public static int getMaxBuffer() { - int confVal = SettingsEnum.MAX_BUFFER.getInt(); - if (confVal < 1) confVal = 1; - return confVal; - } - - public static int getPlaybackBuffer() { - int confVal = SettingsEnum.PLAYBACK_MAX_BUFFER.getInt(); - if (confVal < 1) confVal = 1; - return confVal; - } - - public static int getReBuffer() { - int confVal = SettingsEnum.MAX_PLAYBACK_BUFFER_AFTER_REBUFFER.getInt(); - if (confVal < 1) confVal = 1; - return confVal; - } - - -} 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 3d1b59de..e427e5bd 100644 --- a/app/src/main/java/app/revanced/integrations/settings/SettingsEnum.java +++ b/app/src/main/java/app/revanced/integrations/settings/SettingsEnum.java @@ -116,11 +116,6 @@ public enum SettingsEnum { SWIPE_OVERLAY_BACKGROUND_ALPHA("revanced_swipe_overlay_background_alpha", 127, ReturnType.INTEGER), SWIPE_MAGNITUDE_THRESHOLD("revanced_swipe_magnitude_threshold", 30f, ReturnType.FLOAT), - // Buffer settings - MAX_BUFFER("revanced_pref_max_buffer_ms", 120000, ReturnType.INTEGER), - PLAYBACK_MAX_BUFFER("revanced_pref_buffer_for_playback_ms", 2500, ReturnType.INTEGER), - MAX_PLAYBACK_BUFFER_AFTER_REBUFFER("revanced_pref_buffer_for_playback_after_rebuffer_ms", 5000, ReturnType.INTEGER), - // Debug settings DEBUG("revanced_debug_enabled", false, ReturnType.BOOLEAN), DEBUG_STACKTRACE("revanced_debug_stacktrace_enabled", false, ReturnType.BOOLEAN), From 7e64e05709c63b4631e845799e756a678138813b Mon Sep 17 00:00:00 2001 From: johnconner122 <107796137+johnconner122@users.noreply.github.com> Date: Tue, 14 Mar 2023 19:17:15 +0500 Subject: [PATCH 23/24] feat(youtube/general-ads): hide new type of ad (#331) Co-authored-by: oSumAtrIX --- .../java/app/revanced/integrations/patches/GeneralAdsPatch.java | 1 + 1 file changed, 1 insertion(+) diff --git a/app/src/main/java/app/revanced/integrations/patches/GeneralAdsPatch.java b/app/src/main/java/app/revanced/integrations/patches/GeneralAdsPatch.java index fed574a6..e0f6aa82 100644 --- a/app/src/main/java/app/revanced/integrations/patches/GeneralAdsPatch.java +++ b/app/src/main/java/app/revanced/integrations/patches/GeneralAdsPatch.java @@ -60,6 +60,7 @@ public final class GeneralAdsPatch extends Filter { "video_display_full_layout", "hero_promo_image", "statement_banner", + "carousel_footered_layout" "text_image_button_layout" ); var movieAds = new BlockRule( From 2f5c8396133d182658d378c938c7c3dac8217ef7 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Tue, 14 Mar 2023 14:30:11 +0000 Subject: [PATCH 24/24] chore(release): 0.100.0-dev.6 [skip ci] # [0.100.0-dev.6](https://github.com/revanced/revanced-integrations/compare/v0.100.0-dev.5...v0.100.0-dev.6) (2023-03-14) ### Bug Fixes * **youtube/hide-floating-microphone-button:** reboot when changing settings ([919f285](https://github.com/revanced/revanced-integrations/commit/919f2855edff0acc96c42ea733fff41a55211e48)) * **youtube/remember-video-quality:** treat any connection as wifi except mobile and bluetooth ([1f90f7b](https://github.com/revanced/revanced-integrations/commit/1f90f7b9cca2445c776f4f0c8af1ddd0c9bde5f0)) * **youtube/return-youtube-dislike:** improve segmented like/dislike layout ([416c695](https://github.com/revanced/revanced-integrations/commit/416c695837debefb4762d381f25157de480614cc)) ### Features * **youtube/general-ads:** hide new type of ad ([844bc3b](https://github.com/revanced/revanced-integrations/commit/844bc3b24fe9a2d6b69367d79ad99e452e8a7604)) * **youtube/general-ads:** hide new type of ad ([#331](https://github.com/revanced/revanced-integrations/issues/331)) ([7e64e05](https://github.com/revanced/revanced-integrations/commit/7e64e05709c63b4631e845799e756a678138813b)) * **youtube:** remove `custom-video-buffer` patch ([#1718](https://github.com/revanced/revanced-integrations/issues/1718)) ([d5919a8](https://github.com/revanced/revanced-integrations/commit/d5919a8a2cff09bb884ea01ca6b01d8d2d0b8980)) --- CHANGELOG.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6ccbe7c5..1174d517 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,19 @@ +# [0.100.0-dev.6](https://github.com/revanced/revanced-integrations/compare/v0.100.0-dev.5...v0.100.0-dev.6) (2023-03-14) + + +### Bug Fixes + +* **youtube/hide-floating-microphone-button:** reboot when changing settings ([919f285](https://github.com/revanced/revanced-integrations/commit/919f2855edff0acc96c42ea733fff41a55211e48)) +* **youtube/remember-video-quality:** treat any connection as wifi except mobile and bluetooth ([1f90f7b](https://github.com/revanced/revanced-integrations/commit/1f90f7b9cca2445c776f4f0c8af1ddd0c9bde5f0)) +* **youtube/return-youtube-dislike:** improve segmented like/dislike layout ([416c695](https://github.com/revanced/revanced-integrations/commit/416c695837debefb4762d381f25157de480614cc)) + + +### Features + +* **youtube/general-ads:** hide new type of ad ([844bc3b](https://github.com/revanced/revanced-integrations/commit/844bc3b24fe9a2d6b69367d79ad99e452e8a7604)) +* **youtube/general-ads:** hide new type of ad ([#331](https://github.com/revanced/revanced-integrations/issues/331)) ([7e64e05](https://github.com/revanced/revanced-integrations/commit/7e64e05709c63b4631e845799e756a678138813b)) +* **youtube:** remove `custom-video-buffer` patch ([#1718](https://github.com/revanced/revanced-integrations/issues/1718)) ([d5919a8](https://github.com/revanced/revanced-integrations/commit/d5919a8a2cff09bb884ea01ca6b01d8d2d0b8980)) + # [0.100.0-dev.6](https://github.com/revanced/revanced-integrations/compare/v0.100.0-dev.5...v0.100.0-dev.6) (2023-02-26)