diff --git a/extensions/youtube/src/main/java/app/revanced/extension/youtube/patches/NavigationButtonsPatch.java b/extensions/youtube/src/main/java/app/revanced/extension/youtube/patches/NavigationButtonsPatch.java
index 8c581fc1c..3494ada58 100644
--- a/extensions/youtube/src/main/java/app/revanced/extension/youtube/patches/NavigationButtonsPatch.java
+++ b/extensions/youtube/src/main/java/app/revanced/extension/youtube/patches/NavigationButtonsPatch.java
@@ -3,12 +3,15 @@ package app.revanced.extension.youtube.patches;
import static app.revanced.extension.shared.Utils.hideViewUnderCondition;
import static app.revanced.extension.youtube.shared.NavigationBar.NavigationButton;
+import android.os.Build;
import android.view.View;
import java.util.EnumMap;
import java.util.Map;
import android.widget.TextView;
+
+import app.revanced.extension.shared.Utils;
import app.revanced.extension.youtube.settings.Settings;
@SuppressWarnings("unused")
@@ -26,6 +29,15 @@ public final class NavigationButtonsPatch {
private static final boolean SWITCH_CREATE_WITH_NOTIFICATIONS_BUTTON
= Settings.SWITCH_CREATE_WITH_NOTIFICATIONS_BUTTON.get();
+ private static final Boolean DISABLE_TRANSLUCENT_STATUS_BAR
+ = Settings.DISABLE_TRANSLUCENT_STATUS_BAR.get();
+
+ private static final Boolean DISABLE_TRANSLUCENT_NAVIGATION_BAR_LIGHT
+ = Settings.DISABLE_TRANSLUCENT_NAVIGATION_BAR_LIGHT.get();
+
+ private static final Boolean DISABLE_TRANSLUCENT_NAVIGATION_BAR_DARK
+ = Settings.DISABLE_TRANSLUCENT_NAVIGATION_BAR_DARK.get();
+
/**
* Injection point.
*/
@@ -48,4 +60,42 @@ public final class NavigationButtonsPatch {
public static void hideNavigationButtonLabels(TextView navigationLabelsView) {
hideViewUnderCondition(Settings.HIDE_NAVIGATION_BUTTON_LABELS, navigationLabelsView);
}
+
+ /**
+ * Injection point.
+ */
+ public static boolean useTranslucentNavigationStatusBar(boolean original) {
+ // Must check Android version, as forcing this on Android 11 or lower causes app hang and crash.
+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.S) {
+ return original;
+ }
+
+ if (DISABLE_TRANSLUCENT_STATUS_BAR) {
+ return false;
+ }
+
+ return original;
+ }
+
+ /**
+ * Injection point.
+ */
+ public static boolean useTranslucentNavigationButtons(boolean original) {
+ // Feature requires Android 13+
+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU) {
+ return original;
+ }
+
+ if (!DISABLE_TRANSLUCENT_NAVIGATION_BAR_DARK && !DISABLE_TRANSLUCENT_NAVIGATION_BAR_LIGHT) {
+ return original;
+ }
+
+ if (DISABLE_TRANSLUCENT_NAVIGATION_BAR_DARK && DISABLE_TRANSLUCENT_NAVIGATION_BAR_LIGHT) {
+ return false;
+ }
+
+ return Utils.isDarkModeEnabled(Utils.getContext())
+ ? !DISABLE_TRANSLUCENT_NAVIGATION_BAR_DARK
+ : !DISABLE_TRANSLUCENT_NAVIGATION_BAR_LIGHT;
+ }
}
diff --git a/extensions/youtube/src/main/java/app/revanced/extension/youtube/settings/Settings.java b/extensions/youtube/src/main/java/app/revanced/extension/youtube/settings/Settings.java
index c59d2d04b..e5027a9cc 100644
--- a/extensions/youtube/src/main/java/app/revanced/extension/youtube/settings/Settings.java
+++ b/extensions/youtube/src/main/java/app/revanced/extension/youtube/settings/Settings.java
@@ -16,7 +16,6 @@ import static app.revanced.extension.youtube.patches.MiniplayerPatch.MiniplayerT
import static app.revanced.extension.youtube.patches.MiniplayerPatch.MiniplayerType.MODERN_2;
import static app.revanced.extension.youtube.patches.MiniplayerPatch.MiniplayerType.MODERN_3;
import static app.revanced.extension.youtube.patches.MiniplayerPatch.MiniplayerType.MODERN_4;
-import static app.revanced.extension.youtube.patches.MiniplayerPatch.MiniplayerType.PHONE;
import static app.revanced.extension.youtube.patches.SeekbarThumbnailsPatch.SeekbarThumbnailsHighQualityAvailability;
import static app.revanced.extension.youtube.patches.VersionCheckPatch.IS_19_17_OR_GREATER;
import static app.revanced.extension.youtube.sponsorblock.objects.CategoryBehaviour.IGNORE;
@@ -218,6 +217,9 @@ public class Settings extends BaseSettings {
public static final BooleanSetting HIDE_SUBSCRIPTIONS_BUTTON = new BooleanSetting("revanced_hide_subscriptions_button", FALSE, true);
public static final BooleanSetting HIDE_NAVIGATION_BUTTON_LABELS = new BooleanSetting("revanced_hide_navigation_button_labels", FALSE, true);
public static final BooleanSetting SWITCH_CREATE_WITH_NOTIFICATIONS_BUTTON = new BooleanSetting("revanced_switch_create_with_notifications_button", TRUE, true);
+ public static final BooleanSetting DISABLE_TRANSLUCENT_STATUS_BAR = new BooleanSetting("revanced_disable_translucent_status_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);
// Shorts
public static final BooleanSetting DISABLE_RESUMING_SHORTS_PLAYER = new BooleanSetting("revanced_disable_resuming_shorts_player", FALSE);
@@ -389,7 +391,8 @@ public class Settings extends BaseSettings {
}
// Migrate renamed enum.
- if (MINIPLAYER_TYPE.get() == PHONE) {
+ //noinspection deprecation
+ if (MINIPLAYER_TYPE.get() == MiniplayerType.PHONE) {
MINIPLAYER_TYPE.save(MINIMAL);
}
diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/navigation/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/navigation/Fingerprints.kt
index eebd0befb..a4e65eb28 100644
--- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/navigation/Fingerprints.kt
+++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/navigation/Fingerprints.kt
@@ -3,6 +3,7 @@ package app.revanced.patches.youtube.layout.buttons.navigation
import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.AccessFlags
import app.revanced.patcher.fingerprint
+import app.revanced.util.literal
internal const val ANDROID_AUTOMOTIVE_STRING = "Android Automotive"
@@ -22,4 +23,31 @@ internal val createPivotBarFingerprint = fingerprint {
Opcode.INVOKE_VIRTUAL,
Opcode.RETURN_VOID,
)
+}
+
+internal const val TRANSLUCENT_NAVIGATION_STATUS_BAR_FEATURE_FLAG = 45400535L
+
+internal val translucentNavigationStatusBarFeatureFlagFingerprint = fingerprint {
+ accessFlags(AccessFlags.PUBLIC, AccessFlags.FINAL)
+ returns("Z")
+ literal { TRANSLUCENT_NAVIGATION_STATUS_BAR_FEATURE_FLAG }
+}
+
+internal const val TRANSLUCENT_NAVIGATION_BUTTONS_FEATURE_FLAG = 45630927L
+
+internal val translucentNavigationButtonsFeatureFlagFingerprint = fingerprint {
+ accessFlags(AccessFlags.PUBLIC, AccessFlags.FINAL)
+ returns("V")
+ literal { TRANSLUCENT_NAVIGATION_BUTTONS_FEATURE_FLAG }
+}
+
+/**
+ * The device on screen back/home/recent buttons.
+ */
+internal const val TRANSLUCENT_NAVIGATION_BUTTONS_SYSTEM_FEATURE_FLAG = 45632194L
+
+internal val translucentNavigationButtonsSystemFeatureFlagFingerprint = fingerprint {
+ accessFlags(AccessFlags.PUBLIC, AccessFlags.FINAL)
+ returns("Z")
+ literal { TRANSLUCENT_NAVIGATION_BUTTONS_SYSTEM_FEATURE_FLAG }
}
\ No newline at end of file
diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/navigation/NavigationButtonsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/navigation/NavigationButtonsPatch.kt
index 3fd159933..33ce5e190 100644
--- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/navigation/NavigationButtonsPatch.kt
+++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/navigation/NavigationButtonsPatch.kt
@@ -12,10 +12,13 @@ import app.revanced.patches.shared.misc.settings.preference.SwitchPreference
import app.revanced.patches.youtube.misc.extension.sharedExtensionPatch
import app.revanced.patches.youtube.misc.navigation.hookNavigationButtonCreated
import app.revanced.patches.youtube.misc.navigation.navigationBarHookPatch
+import app.revanced.patches.youtube.misc.playservice.is_19_25_or_greater
+import app.revanced.patches.youtube.misc.playservice.versionCheckPatch
import app.revanced.patches.youtube.misc.settings.PreferenceScreen
import app.revanced.patches.youtube.misc.settings.settingsPatch
import app.revanced.util.getReference
import app.revanced.util.indexOfFirstInstructionOrThrow
+import app.revanced.util.insertFeatureFlagBooleanOverride
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
import com.android.tools.smali.dexlib2.iface.reference.MethodReference
@@ -32,6 +35,7 @@ val navigationButtonsPatch = bytecodePatch(
settingsPatch,
addResourcesPatch,
navigationBarHookPatch,
+ versionCheckPatch
)
compatibleWith(
@@ -50,19 +54,27 @@ val navigationButtonsPatch = bytecodePatch(
execute {
addResources("youtube", "layout.buttons.navigation.navigationButtonsPatch")
+ val preferences = mutableSetOf(
+ SwitchPreference("revanced_hide_home_button"),
+ SwitchPreference("revanced_hide_shorts_button"),
+ SwitchPreference("revanced_hide_create_button"),
+ SwitchPreference("revanced_hide_subscriptions_button"),
+ SwitchPreference("revanced_switch_create_with_notifications_button"),
+ SwitchPreference("revanced_hide_navigation_button_labels"),
+ )
+
+ if (is_19_25_or_greater) {
+ preferences += SwitchPreference("revanced_disable_translucent_status_bar")
+ preferences += SwitchPreference("revanced_disable_translucent_navigation_bar_light")
+ preferences += SwitchPreference("revanced_disable_translucent_navigation_bar_dark")
+ }
+
PreferenceScreen.GENERAL_LAYOUT.addPreferences(
PreferenceScreenPreference(
key = "revanced_navigation_buttons_screen",
sorting = Sorting.UNSORTED,
- preferences = setOf(
- SwitchPreference("revanced_hide_home_button"),
- SwitchPreference("revanced_hide_shorts_button"),
- SwitchPreference("revanced_hide_create_button"),
- SwitchPreference("revanced_hide_subscriptions_button"),
- SwitchPreference("revanced_switch_create_with_notifications_button"),
- SwitchPreference("revanced_hide_navigation_button_labels"),
- ),
- ),
+ preferences = preferences
+ )
)
// Switch create with notifications button.
@@ -101,5 +113,24 @@ val navigationButtonsPatch = bytecodePatch(
// Hook navigation button created, in order to hide them.
hookNavigationButtonCreated(EXTENSION_CLASS_DESCRIPTOR)
+
+
+ // Force on/off translucent effect on status bar and navigation buttons.
+ if (is_19_25_or_greater) {
+ translucentNavigationStatusBarFeatureFlagFingerprint.method.insertFeatureFlagBooleanOverride(
+ TRANSLUCENT_NAVIGATION_STATUS_BAR_FEATURE_FLAG,
+ "$EXTENSION_CLASS_DESCRIPTOR->useTranslucentNavigationStatusBar(Z)Z",
+ )
+
+ translucentNavigationButtonsFeatureFlagFingerprint.method.insertFeatureFlagBooleanOverride(
+ TRANSLUCENT_NAVIGATION_BUTTONS_FEATURE_FLAG,
+ "$EXTENSION_CLASS_DESCRIPTOR->useTranslucentNavigationButtons(Z)Z",
+ )
+
+ translucentNavigationButtonsSystemFeatureFlagFingerprint.method.insertFeatureFlagBooleanOverride(
+ TRANSLUCENT_NAVIGATION_BUTTONS_SYSTEM_FEATURE_FLAG,
+ "$EXTENSION_CLASS_DESCRIPTOR->useTranslucentNavigationButtons(Z)Z",
+ )
+ }
}
}
diff --git a/patches/src/main/resources/addresources/values/strings.xml b/patches/src/main/resources/addresources/values/strings.xml
index b622d5b28..bb502a992 100644
--- a/patches/src/main/resources/addresources/values/strings.xml
+++ b/patches/src/main/resources/addresources/values/strings.xml
@@ -519,6 +519,15 @@ Note: Enabling this also forcibly hides video ads"
Hide navigation button labels
Labels are hidden
Labels are shown
+ Disable translucent status bar
+ Status bar is opaque
+ Status bar is opaque or translucent
+ Disable light translucent bar
+ Light mode navigation bar is opaque
+ Light mode navigation bar is opaque or translucent
+ Disable dark translucent bar
+ Dark mode navigation bar is opaque
+ Dark mode navigation bar is opaque or translucent