mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-06-13 05:37:40 +02:00
feat(YouTube Music - Navigation bar components): Add Enable custom navigation bar color
setting, Remove Set navigation bar to black
setting
This commit is contained in:
@ -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) {
|
||||
|
@ -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,
|
||||
|
@ -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);
|
||||
|
@ -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)
|
||||
|
||||
|
@ -199,6 +199,11 @@ This does not bypass the age restriction. It just accepts it automatically."</st
|
||||
<!-- PreferenceScreen: Navigation Bar -->
|
||||
<string name="revanced_preference_screen_navigation_title">Navigation Bar</string>
|
||||
|
||||
<string name="revanced_enable_custom_navigation_bar_color_title">Enable custom navigation bar color</string>
|
||||
<string name="revanced_enable_custom_navigation_bar_color_summary">Sets the navigation bar color.</string>
|
||||
<string name="revanced_custom_navigation_bar_color_value_title">Custom navigation bar color value</string>
|
||||
<string name="revanced_custom_navigation_bar_color_value_summary">Type the hex code of the navigation bar color.</string>
|
||||
<string name="revanced_custom_navigation_bar_color_value_invalid_invalid_toast">Invalid navigation bar color value.</string>
|
||||
<string name="revanced_hide_navigation_home_button_title">Hide Home button</string>
|
||||
<string name="revanced_hide_navigation_home_button_summary">Hides the Home button.</string>
|
||||
<string name="revanced_hide_navigation_samples_button_title">Hide Samples button</string>
|
||||
@ -213,8 +218,6 @@ This does not bypass the age restriction. It just accepts it automatically."</st
|
||||
<string name="revanced_hide_navigation_bar_summary">Hides the navigation bar.</string>
|
||||
<string name="revanced_hide_navigation_label_title">Hide navigation labels</string>
|
||||
<string name="revanced_hide_navigation_label_summary">Hides the label below each navigation buttons.</string>
|
||||
<string name="revanced_enable_black_navigation_bar_title">Set navigation bar to black</string>
|
||||
<string name="revanced_enable_black_navigation_bar_summary">Sets the navigation bar color to black.</string>
|
||||
|
||||
|
||||
<!-- PreferenceScreen: Player -->
|
||||
|
Reference in New Issue
Block a user