Skip to content

Commit

Permalink
fix: Can set navbar differently for light/dark mode
Browse files Browse the repository at this point in the history
  • Loading branch information
LisoUseInAIKyrios committed Dec 16, 2024
1 parent dfcdb50 commit b368bf7
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import java.util.Map;

import android.widget.TextView;

import app.revanced.extension.shared.Utils;
import app.revanced.extension.youtube.settings.Settings;

@SuppressWarnings("unused")
Expand All @@ -28,11 +30,16 @@ public final class NavigationButtonsPatch {
= Settings.SWITCH_CREATE_WITH_NOTIFICATIONS_BUTTON.get();

private static final Boolean TRANSLUCENT_STATUS_BAR
= Settings.TRANSLUCENT_STATUS_BAR.get();
= Build.VERSION.SDK_INT >= Build.VERSION_CODES.S
&& Settings.TRANSLUCENT_STATUS_BAR.get();

private static final Boolean TRANSLUCENT_NAVIGATION_BUTTONS_LIGHT
= Build.VERSION.SDK_INT >= Build.VERSION_CODES.S
&& Settings.TRANSLUCENT_NAVIGATION_BUTTONS_LIGHT.get();

private static final Boolean TRANSLUCENT_NAVIGATION_BUTTONS
private static final Boolean TRANSLUCENT_NAVIGATION_BUTTONS_DARK
= Build.VERSION.SDK_INT >= Build.VERSION_CODES.S
&& Settings.TRANSLUCENT_NAVIGATION_BUTTONS.get();
&& Settings.TRANSLUCENT_NAVIGATION_BUTTONS_DARK.get();

/**
* Injection point.
Expand Down Expand Up @@ -68,6 +75,12 @@ public static boolean useTranslucentNavigationStatusBar(boolean original) {
* Injection point.
*/
public static boolean useTranslucentNavigationButtons(boolean original) {
return TRANSLUCENT_NAVIGATION_BUTTONS;
if (!TRANSLUCENT_NAVIGATION_BUTTONS_DARK && !TRANSLUCENT_NAVIGATION_BUTTONS_LIGHT) {
return false;
}

return Utils.isDarkModeEnabled(Utils.getContext())
? TRANSLUCENT_NAVIGATION_BUTTONS_DARK
: TRANSLUCENT_NAVIGATION_BUTTONS_LIGHT;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,8 @@ public class Settings extends BaseSettings {
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 TRANSLUCENT_STATUS_BAR = new BooleanSetting("revanced_translucent_status_bar", TRUE, true);
public static final BooleanSetting TRANSLUCENT_NAVIGATION_BUTTONS = new BooleanSetting("revanced_translucent_navigation_buttons", FALSE, true);
public static final BooleanSetting TRANSLUCENT_NAVIGATION_BUTTONS_LIGHT = new BooleanSetting("revanced_translucent_navigation_buttons_light", FALSE, true);
public static final BooleanSetting TRANSLUCENT_NAVIGATION_BUTTONS_DARK = new BooleanSetting("revanced_translucent_navigation_buttons_dark", FALSE, true);

// Shorts
public static final BooleanSetting DISABLE_RESUMING_SHORTS_PLAYER = new BooleanSetting("revanced_disable_resuming_shorts_player", FALSE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ val navigationButtonsPatch = bytecodePatch(

if (is_19_25_or_greater) {
preferences += SwitchPreference("revanced_translucent_status_bar")
preferences += SwitchPreference("revanced_translucent_navigation_buttons")
preferences += SwitchPreference("revanced_translucent_navigation_buttons_light")
preferences += SwitchPreference("revanced_translucent_navigation_buttons_dark")
}

PreferenceScreen.GENERAL_LAYOUT.addPreferences(
Expand Down
15 changes: 10 additions & 5 deletions patches/src/main/resources/addresources/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -523,12 +523,17 @@ Note: Enabling this also forcibly hides video ads"</string>
<string name="revanced_hide_navigation_button_labels_summary_on">Labels are hidden</string>
<string name="revanced_hide_navigation_button_labels_summary_off">Labels are shown</string>
<string name="revanced_translucent_status_bar_title">Enable translucent status bar</string>
<string name="revanced_translucent_status_bar_summary_on">Status bar is translucent</string>
<string name="revanced_translucent_status_bar_summary_on">"Status bar is translucent
(requires Android 12)"</string>
<string name="revanced_translucent_status_bar_summary_off">Status bar is opaque</string>
<string name="revanced_translucent_navigation_buttons_title">Enable translucent buttons</string>
<string name="revanced_translucent_navigation_buttons_summary_on">"Buttons are translucent
(Requires Android 12)"</string>
<string name="revanced_translucent_navigation_buttons_summary_off">Buttons are opaque</string>
<string name="revanced_translucent_navigation_buttons_light_title">Enable translucent light buttons</string>
<string name="revanced_translucent_navigation_buttons_light_summary_on">"Light mode buttons are translucent
(requires Android 12)"</string>
<string name="revanced_translucent_navigation_buttons_light_summary_off">Light mode buttons are opaque</string>
<string name="revanced_translucent_navigation_buttons_dark_title">Enable translucent dark buttons</string>
<string name="revanced_translucent_navigation_buttons_dark_summary_on">"Dark mode buttons are translucent
(requires Android 12)"</string>
<string name="revanced_translucent_navigation_buttons_dark_summary_off">Dark mode buttons are opaque</string>
</patch>
<patch id="layout.hide.player.flyoutmenupanel.hidePlayerFlyoutMenuPatch">
<string name="revanced_hide_player_flyout_title">Flyout menu</string>
Expand Down

0 comments on commit b368bf7

Please sign in to comment.