From 158f8da6c7432c9df07a3b91d7c25f87ec14aaef Mon Sep 17 00:00:00 2001 From: Aaron Veil <70171475+anddea@users.noreply.github.com> Date: Mon, 23 Dec 2024 09:53:55 +0300 Subject: [PATCH] feat(YouTube - Navigation bar components): Bring back`Enable translucent navigation bar` setting --- .../youtube/patches/general/GeneralPatch.java | 4 ++++ .../revanced/extension/youtube/settings/Settings.java | 1 + .../preference/ReVancedSettingsPreference.java | 1 + .../patches/youtube/general/navigation/Fingerprints.kt | 5 +++++ .../general/navigation/NavigationBarComponentsPatch.kt | 10 ++++++++++ .../resources/youtube/settings/xml/revanced_prefs.xml | 1 + 6 files changed, 22 insertions(+) diff --git a/extensions/shared/src/main/java/app/revanced/extension/youtube/patches/general/GeneralPatch.java b/extensions/shared/src/main/java/app/revanced/extension/youtube/patches/general/GeneralPatch.java index 0893398fb..b7e6599a1 100644 --- a/extensions/shared/src/main/java/app/revanced/extension/youtube/patches/general/GeneralPatch.java +++ b/extensions/shared/src/main/java/app/revanced/extension/youtube/patches/general/GeneralPatch.java @@ -257,6 +257,10 @@ public static boolean useTranslucentNavigationStatusBar(boolean original) { return original; } + public static boolean enableTranslucentNavigationBar() { + return Settings.ENABLE_TRANSLUCENT_NAVIGATION_BAR.get(); + } + private static final Boolean DISABLE_TRANSLUCENT_NAVIGATION_BAR_LIGHT = Settings.DISABLE_TRANSLUCENT_NAVIGATION_BAR_LIGHT.get(); diff --git a/extensions/shared/src/main/java/app/revanced/extension/youtube/settings/Settings.java b/extensions/shared/src/main/java/app/revanced/extension/youtube/settings/Settings.java index 6c1f49919..1501a8e77 100644 --- a/extensions/shared/src/main/java/app/revanced/extension/youtube/settings/Settings.java +++ b/extensions/shared/src/main/java/app/revanced/extension/youtube/settings/Settings.java @@ -190,6 +190,7 @@ public class Settings extends BaseSettings { public static final BooleanSetting HIDE_NAVIGATION_SUBSCRIPTIONS_BUTTON = new BooleanSetting("revanced_hide_navigation_subscriptions_button", FALSE, true); public static final BooleanSetting HIDE_NAVIGATION_LABEL = new BooleanSetting("revanced_hide_navigation_label", FALSE, true); public static final BooleanSetting SWITCH_CREATE_WITH_NOTIFICATIONS_BUTTON = new BooleanSetting("revanced_switch_create_with_notifications_button", TRUE, true, "revanced_switch_create_with_notifications_button_user_dialog_message"); + public static final BooleanSetting ENABLE_TRANSLUCENT_NAVIGATION_BAR = new BooleanSetting("revanced_enable_translucent_navigation_bar", FALSE, true); public static final BooleanSetting DISABLE_TRANSLUCENT_NAVIGATION_BAR_LIGHT = new BooleanSetting("revanced_disable_translucent_navigation_bar_light", FALSE, true); public static final BooleanSetting DISABLE_TRANSLUCENT_NAVIGATION_BAR_DARK = new BooleanSetting("revanced_disable_translucent_navigation_bar_dark", FALSE, true); public static final BooleanSetting HIDE_NAVIGATION_BAR = new BooleanSetting("revanced_hide_navigation_bar", FALSE, true); diff --git a/extensions/shared/src/main/java/app/revanced/extension/youtube/settings/preference/ReVancedSettingsPreference.java b/extensions/shared/src/main/java/app/revanced/extension/youtube/settings/preference/ReVancedSettingsPreference.java index d1dfbcdb4..c89e6c118 100644 --- a/extensions/shared/src/main/java/app/revanced/extension/youtube/settings/preference/ReVancedSettingsPreference.java +++ b/extensions/shared/src/main/java/app/revanced/extension/youtube/settings/preference/ReVancedSettingsPreference.java @@ -205,6 +205,7 @@ private static void NavigationPreferenceLinks() { ); enableDisablePreferences( !isSDKAbove(33), + Settings.ENABLE_TRANSLUCENT_NAVIGATION_BAR, Settings.DISABLE_TRANSLUCENT_NAVIGATION_BAR_LIGHT, Settings.DISABLE_TRANSLUCENT_NAVIGATION_BAR_DARK ); diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/general/navigation/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/general/navigation/Fingerprints.kt index fd74a28bd..9fac63f02 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/general/navigation/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/general/navigation/Fingerprints.kt @@ -74,6 +74,11 @@ internal val setEnumMapFingerprint = legacyFingerprint( literals = listOf(ytFillBell), ) +internal val translucentNavigationBarFingerprint = legacyFingerprint( + name = "translucentNavigationBarFingerprint", + literals = listOf(45630927L), +) + internal const val TRANSLUCENT_NAVIGATION_STATUS_BAR_FEATURE_FLAG = 45400535L internal val translucentNavigationStatusBarFeatureFlagFingerprint = legacyFingerprint( diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/general/navigation/NavigationBarComponentsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/general/navigation/NavigationBarComponentsPatch.kt index 8e8d38987..3367c747e 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/general/navigation/NavigationBarComponentsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/general/navigation/NavigationBarComponentsPatch.kt @@ -11,6 +11,7 @@ import app.revanced.patches.youtube.utils.navigation.addBottomBarContainerHook import app.revanced.patches.youtube.utils.navigation.hookNavigationButtonCreated import app.revanced.patches.youtube.utils.navigation.navigationBarHookPatch import app.revanced.patches.youtube.utils.patch.PatchList.NAVIGATION_BAR_COMPONENTS +import app.revanced.patches.youtube.utils.playservice.is_19_23_or_greater import app.revanced.patches.youtube.utils.playservice.is_19_25_or_greater import app.revanced.patches.youtube.utils.playservice.is_19_28_or_greater import app.revanced.patches.youtube.utils.playservice.versionCheckPatch @@ -84,6 +85,15 @@ val navigationBarComponentsPatch = bytecodePatch( // region patch for enable translucent navigation bar + if (is_19_23_or_greater) { + translucentNavigationBarFingerprint.injectLiteralInstructionBooleanCall( + 45630927L, + "$GENERAL_CLASS_DESCRIPTOR->enableTranslucentNavigationBar()Z" + ) + + settingArray += "SETTINGS: TRANSLUCENT_NAVIGATION_BAR" + } + if (is_19_25_or_greater) { arrayOf( Triple( diff --git a/patches/src/main/resources/youtube/settings/xml/revanced_prefs.xml b/patches/src/main/resources/youtube/settings/xml/revanced_prefs.xml index 225cee258..a406e2454 100644 --- a/patches/src/main/resources/youtube/settings/xml/revanced_prefs.xml +++ b/patches/src/main/resources/youtube/settings/xml/revanced_prefs.xml @@ -92,6 +92,7 @@ SETTINGS: HIDE_NAVIGATION_COMPONENTS -->