feat(YouTube - Navigation bar components): Separate Enable translucent navigation bar setting into Disable light translucent bar and Disable dark translucent bar settings

This commit is contained in:
inotia00
2024-12-21 13:30:25 +09:00
parent e3128a9552
commit b5f9a951d3
8 changed files with 87 additions and 20 deletions

View File

@ -462,6 +462,16 @@ public class Utils {
return false;
}
public static boolean isDarkModeEnabled() {
return isDarkModeEnabled(context);
}
public static boolean isDarkModeEnabled(Context context) {
Configuration config = context.getResources().getConfiguration();
final int currentNightMode = config.uiMode & Configuration.UI_MODE_NIGHT_MASK;
return currentNightMode == Configuration.UI_MODE_NIGHT_YES;
}
/**
* @return whether the device's API level is higher than a specific SDK version.
*/

View File

@ -5,6 +5,7 @@ import static app.revanced.extension.shared.utils.Utils.getChildView;
import static app.revanced.extension.shared.utils.Utils.hideViewByLayoutParams;
import static app.revanced.extension.shared.utils.Utils.hideViewGroupByMarginLayoutParams;
import static app.revanced.extension.shared.utils.Utils.hideViewUnderCondition;
import static app.revanced.extension.shared.utils.Utils.isSDKAbove;
import static app.revanced.extension.youtube.patches.utils.PatchStatus.ImageSearchButton;
import static app.revanced.extension.youtube.shared.NavigationBar.NavigationButton;
@ -214,10 +215,6 @@ public class GeneralPatch {
return Settings.ENABLE_NARROW_NAVIGATION_BUTTONS.get() || original;
}
public static boolean enableTranslucentNavigationBar() {
return Settings.ENABLE_TRANSLUCENT_NAVIGATION_BAR.get();
}
/**
* @noinspection ALL
*/
@ -248,6 +245,31 @@ public class GeneralPatch {
hideViewUnderCondition(Settings.HIDE_NAVIGATION_BAR.get(), view);
}
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();
public static boolean useTranslucentNavigationButtons(boolean original) {
// Feature requires Android 13+
if (!isSDKAbove(33)) {
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()
? !DISABLE_TRANSLUCENT_NAVIGATION_BAR_DARK
: !DISABLE_TRANSLUCENT_NAVIGATION_BAR_LIGHT;
}
// endregion
// region [Remove viewer discretion dialog] patch

View File

@ -189,7 +189,8 @@ 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);
// PreferenceScreen: General - Override buttons

View File

@ -204,8 +204,9 @@ public class ReVancedSettingsPreference extends ReVancedPreferenceFragment {
Settings.REPLACE_TOOLBAR_CREATE_BUTTON_TYPE
);
enableDisablePreferences(
!isSDKAbove(31),
Settings.ENABLE_TRANSLUCENT_NAVIGATION_BAR
!isSDKAbove(33),
Settings.DISABLE_TRANSLUCENT_NAVIGATION_BAR_LIGHT,
Settings.DISABLE_TRANSLUCENT_NAVIGATION_BAR_DARK
);
}