diff --git a/extensions/shared/src/main/java/app/revanced/extension/music/patches/navigation/NavigationPatch.java b/extensions/shared/src/main/java/app/revanced/extension/music/patches/navigation/NavigationPatch.java index 904aced74..9b05a5af0 100644 --- a/extensions/shared/src/main/java/app/revanced/extension/music/patches/navigation/NavigationPatch.java +++ b/extensions/shared/src/main/java/app/revanced/extension/music/patches/navigation/NavigationPatch.java @@ -1,5 +1,6 @@ package app.revanced.extension.music.patches.navigation; +import static app.revanced.extension.shared.utils.StringRef.str; import static app.revanced.extension.shared.utils.Utils.hideViewUnderCondition; import android.graphics.Color; @@ -11,6 +12,7 @@ import androidx.annotation.NonNull; import app.revanced.extension.music.patches.utils.PatchStatus; import app.revanced.extension.music.settings.Settings; import app.revanced.extension.shared.utils.ResourceUtils; +import app.revanced.extension.shared.utils.Utils; @SuppressWarnings("unused") public class NavigationPatch { @@ -20,10 +22,19 @@ public class NavigationPatch { public static Enum lastPivotTab; - public static int enableBlackNavigationBar() { - return Settings.ENABLE_BLACK_NAVIGATION_BAR.get() - ? Color.BLACK - : colorGrey12; + public static int enableCustomNavigationBarColor() { + try { + if (Settings.ENABLE_CUSTOM_NAVIGATION_BAR_COLOR.get()) { + return Color.parseColor(Settings.ENABLE_CUSTOM_NAVIGATION_BAR_COLOR_VALUE.get()); + } + } catch (Exception ex) { + Utils.showToastShort(str("revanced_custom_navigation_bar_color_value_invalid_invalid_toast")); + Utils.showToastShort(str("revanced_extended_reset_to_default_toast")); + app.revanced.extension.youtube.settings.Settings.ENABLE_CUSTOM_SEEKBAR_COLOR_VALUE.resetToDefault(); + Settings.ENABLE_CUSTOM_NAVIGATION_BAR_COLOR_VALUE.resetToDefault(); + } + + return colorGrey12; } public static void hideNavigationLabel(TextView textview) { diff --git a/extensions/shared/src/main/java/app/revanced/extension/music/settings/Settings.java b/extensions/shared/src/main/java/app/revanced/extension/music/settings/Settings.java index 9bf63fad6..43da6f9c4 100644 --- a/extensions/shared/src/main/java/app/revanced/extension/music/settings/Settings.java +++ b/extensions/shared/src/main/java/app/revanced/extension/music/settings/Settings.java @@ -117,6 +117,8 @@ public class Settings extends BaseSettings { // PreferenceScreen: Navigation Bar + public static final BooleanSetting ENABLE_CUSTOM_NAVIGATION_BAR_COLOR = new BooleanSetting("revanced_enable_custom_navigation_bar_color", FALSE, true); + public static final StringSetting ENABLE_CUSTOM_NAVIGATION_BAR_COLOR_VALUE = new StringSetting("revanced_custom_navigation_bar_color_value", "#000000", true); public static final BooleanSetting HIDE_NAVIGATION_HOME_BUTTON = new BooleanSetting("revanced_hide_navigation_home_button", FALSE, true); public static final BooleanSetting HIDE_NAVIGATION_SAMPLES_BUTTON = new BooleanSetting("revanced_hide_navigation_samples_button", FALSE, true); public static final BooleanSetting HIDE_NAVIGATION_EXPLORE_BUTTON = new BooleanSetting("revanced_hide_navigation_explore_button", FALSE, true); @@ -124,7 +126,6 @@ public class Settings extends BaseSettings { public static final BooleanSetting HIDE_NAVIGATION_UPGRADE_BUTTON = new BooleanSetting("revanced_hide_navigation_upgrade_button", TRUE, true); public static final BooleanSetting HIDE_NAVIGATION_BAR = new BooleanSetting("revanced_hide_navigation_bar", FALSE, true); public static final BooleanSetting HIDE_NAVIGATION_LABEL = new BooleanSetting("revanced_hide_navigation_label", FALSE, true); - public static final BooleanSetting ENABLE_BLACK_NAVIGATION_BAR = new BooleanSetting("revanced_enable_black_navigation_bar", FALSE); // PreferenceScreen: Player @@ -251,6 +252,7 @@ public class Settings extends BaseSettings { CUSTOM_FILTER_STRINGS.key, CUSTOM_PLAYBACK_SPEEDS.key, DISABLE_MUSIC_VIDEO_IN_ALBUM_REDIRECT_TYPE.key, + ENABLE_CUSTOM_NAVIGATION_BAR_COLOR_VALUE.key, EXTERNAL_DOWNLOADER_PACKAGE_NAME.key, HIDE_ACCOUNT_MENU_FILTER_STRINGS.key, SB_API_URL.key, diff --git a/extensions/shared/src/main/java/app/revanced/extension/music/settings/preference/ReVancedPreferenceFragment.java b/extensions/shared/src/main/java/app/revanced/extension/music/settings/preference/ReVancedPreferenceFragment.java index 1245e8dce..67c442d04 100644 --- a/extensions/shared/src/main/java/app/revanced/extension/music/settings/preference/ReVancedPreferenceFragment.java +++ b/extensions/shared/src/main/java/app/revanced/extension/music/settings/preference/ReVancedPreferenceFragment.java @@ -5,6 +5,7 @@ import static app.revanced.extension.music.settings.Settings.CHANGE_START_PAGE; import static app.revanced.extension.music.settings.Settings.CUSTOM_FILTER_STRINGS; import static app.revanced.extension.music.settings.Settings.CUSTOM_PLAYBACK_SPEEDS; import static app.revanced.extension.music.settings.Settings.DISABLE_MUSIC_VIDEO_IN_ALBUM_REDIRECT_TYPE; +import static app.revanced.extension.music.settings.Settings.ENABLE_CUSTOM_NAVIGATION_BAR_COLOR_VALUE; import static app.revanced.extension.music.settings.Settings.EXTERNAL_DOWNLOADER_PACKAGE_NAME; import static app.revanced.extension.music.settings.Settings.HIDE_ACCOUNT_MENU_FILTER_STRINGS; import static app.revanced.extension.music.settings.Settings.OPEN_DEFAULT_APP_SETTINGS; @@ -140,6 +141,7 @@ public class ReVancedPreferenceFragment extends PreferenceFragment { } else if (settings.equals(BYPASS_IMAGE_REGION_RESTRICTIONS_DOMAIN) || settings.equals(CUSTOM_FILTER_STRINGS) || settings.equals(CUSTOM_PLAYBACK_SPEEDS) + || settings.equals(ENABLE_CUSTOM_NAVIGATION_BAR_COLOR_VALUE) || settings.equals(HIDE_ACCOUNT_MENU_FILTER_STRINGS) || settings.equals(RETURN_YOUTUBE_USERNAME_YOUTUBE_DATA_API_V3_DEVELOPER_KEY)) { ResettableEditTextPreference.showDialog(mActivity, stringSetting); diff --git a/patches/src/main/kotlin/app/revanced/patches/music/navigation/components/NavigationBarComponentsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/music/navigation/components/NavigationBarComponentsPatch.kt index ba894a3af..265ee72d4 100644 --- a/patches/src/main/kotlin/app/revanced/patches/music/navigation/components/NavigationBarComponentsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/music/navigation/components/NavigationBarComponentsPatch.kt @@ -14,6 +14,7 @@ import app.revanced.patches.music.utils.resourceid.sharedResourceIdPatch import app.revanced.patches.music.utils.resourceid.text1 import app.revanced.patches.music.utils.settings.CategoryType import app.revanced.patches.music.utils.settings.ResourceUtils.updatePatchStatus +import app.revanced.patches.music.utils.settings.addPreferenceWithIntent import app.revanced.patches.music.utils.settings.addSwitchPreference import app.revanced.patches.music.utils.settings.settingsPatch import app.revanced.util.fingerprint.matchOrThrow @@ -62,7 +63,7 @@ val navigationBarComponentsPatch = bytecodePatch( execute { /** - * Enable black navigation bar + * Enable custom navigation bar color */ tabLayoutFingerprint.methodOrThrow().apply { val constIndex = indexOfFirstLiteralInstructionOrThrow(colorGrey) @@ -74,7 +75,7 @@ val navigationBarComponentsPatch = bytecodePatch( addInstructions( insertIndex, """ - invoke-static {}, $NAVIGATION_CLASS_DESCRIPTOR->enableBlackNavigationBar()I + invoke-static {}, $NAVIGATION_CLASS_DESCRIPTOR->enableCustomNavigationBarColor()I move-result v$insertRegister """ ) @@ -127,6 +128,16 @@ val navigationBarComponentsPatch = bytecodePatch( } } + addSwitchPreference( + CategoryType.NAVIGATION, + "revanced_enable_custom_navigation_bar_color", + "false" + ) + addPreferenceWithIntent( + CategoryType.NAVIGATION, + "revanced_custom_navigation_bar_color_value", + "revanced_enable_custom_navigation_bar_color" + ) addSwitchPreference( CategoryType.NAVIGATION, "revanced_hide_navigation_home_button", @@ -162,11 +173,6 @@ val navigationBarComponentsPatch = bytecodePatch( "revanced_hide_navigation_label", "false" ) - addSwitchPreference( - CategoryType.NAVIGATION, - "revanced_enable_black_navigation_bar", - "true" - ) updatePatchStatus(NAVIGATION_BAR_COMPONENTS) diff --git a/patches/src/main/resources/music/settings/host/values/strings.xml b/patches/src/main/resources/music/settings/host/values/strings.xml index a0788b34a..442be5600 100644 --- a/patches/src/main/resources/music/settings/host/values/strings.xml +++ b/patches/src/main/resources/music/settings/host/values/strings.xml @@ -199,6 +199,11 @@ This does not bypass the age restriction. It just accepts it automatically." Navigation Bar + Enable custom navigation bar color + Sets the navigation bar color. + Custom navigation bar color value + Type the hex code of the navigation bar color. + Invalid navigation bar color value. Hide Home button Hides the Home button. Hide Samples button @@ -213,8 +218,6 @@ This does not bypass the age restriction. It just accepts it automatically."Hides the navigation bar. Hide navigation labels Hides the label below each navigation buttons. - Set navigation bar to black - Sets the navigation bar color to black.