mirror of
https://github.com/ReVanced/revanced-patches.git
synced 2026-01-20 01:23:57 +00:00
add 20.31+ bold icons setting
This commit is contained in:
@@ -5,12 +5,11 @@ import static app.revanced.extension.youtube.shared.NavigationBar.NavigationButt
|
||||
|
||||
import android.os.Build;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
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;
|
||||
|
||||
@@ -39,6 +38,9 @@ public final class NavigationButtonsPatch {
|
||||
private static final Boolean DISABLE_TRANSLUCENT_NAVIGATION_BAR_DARK
|
||||
= Settings.DISABLE_TRANSLUCENT_NAVIGATION_BAR_DARK.get();
|
||||
|
||||
private static final Boolean NAVIGATION_BAR_DISABLE_BOLD_ICONS
|
||||
= Settings.NAVIGATION_BAR_DISABLE_BOLD_ICONS.get();
|
||||
|
||||
/**
|
||||
* Injection point.
|
||||
*/
|
||||
@@ -69,6 +71,13 @@ public final class NavigationButtonsPatch {
|
||||
return Settings.NAVIGATION_BAR_ANIMATIONS.get();
|
||||
}
|
||||
|
||||
/**
|
||||
* Injection point.
|
||||
*/
|
||||
public static boolean useBoldIcons(boolean original) {
|
||||
return !NAVIGATION_BAR_DISABLE_BOLD_ICONS;
|
||||
}
|
||||
|
||||
/**
|
||||
* Injection point.
|
||||
*/
|
||||
|
||||
@@ -285,6 +285,7 @@ public class Settings extends BaseSettings {
|
||||
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 NAVIGATION_BAR_ANIMATIONS = new BooleanSetting("revanced_navigation_bar_animations", FALSE);
|
||||
public static final BooleanSetting NAVIGATION_BAR_DISABLE_BOLD_ICONS = new BooleanSetting("revanced_navigation_bar_disable_bold_icons", TRUE, true);
|
||||
public static final BooleanSetting DISABLE_TRANSLUCENT_STATUS_BAR = new BooleanSetting("revanced_disable_translucent_status_bar", FALSE, true,
|
||||
"revanced_disable_translucent_status_bar_user_dialog_message");
|
||||
public static final BooleanSetting DISABLE_TRANSLUCENT_NAVIGATION_BAR_LIGHT = new BooleanSetting("revanced_disable_translucent_navigation_bar_light", FALSE, true);
|
||||
|
||||
@@ -65,4 +65,14 @@ internal val translucentNavigationButtonsSystemFeatureFlagFingerprint by fingerp
|
||||
instructions(
|
||||
literal(45632194L) // Translucent system buttons feature flag.
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// Flag is present in 20.23, but icons are missing and forcing bold icons crashes the app.
|
||||
internal val boldIconsFeatureFlagFingerprint by fingerprint {
|
||||
accessFlags(AccessFlags.PUBLIC, AccessFlags.FINAL)
|
||||
returns("Z")
|
||||
parameters()
|
||||
instructions(
|
||||
literal(45685201L)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ 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.is_20_15_or_greater
|
||||
import app.revanced.patches.youtube.misc.playservice.is_20_31_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
|
||||
@@ -72,6 +73,12 @@ val navigationButtonsPatch = bytecodePatch(
|
||||
)
|
||||
}
|
||||
|
||||
if (is_20_31_or_greater) {
|
||||
PreferenceScreen.GENERAL_LAYOUT.addPreferences(
|
||||
SwitchPreference("revanced_navigation_bar_disable_bold_icons")
|
||||
)
|
||||
}
|
||||
|
||||
PreferenceScreen.GENERAL_LAYOUT.addPreferences(
|
||||
PreferenceScreenPreference(
|
||||
key = "revanced_navigation_buttons_screen",
|
||||
@@ -146,5 +153,16 @@ val navigationButtonsPatch = bytecodePatch(
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// Bold icon resources are found starting in 20.23, but many YT icons are not bold.
|
||||
// 20.31 is the first version that seems to have all the bold icons.
|
||||
if (is_20_31_or_greater) {
|
||||
boldIconsFeatureFlagFingerprint.let {
|
||||
it.method.insertLiteralOverride(
|
||||
it.instructionMatches.first().index,
|
||||
"$EXTENSION_CLASS_DESCRIPTOR->useBoldIcons(Z)Z"
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -792,6 +792,9 @@ If changing this setting does not take effect, try switching to Incognito mode."
|
||||
<string name="revanced_navigation_bar_animations_title">Enable navigation bar animations</string>
|
||||
<string name="revanced_navigation_bar_animations_summary_on">Navigation transitions are animated</string>
|
||||
<string name="revanced_navigation_bar_animations_summary_off">Navigation transitions are not animated</string>
|
||||
<string name="revanced_navigation_bar_disable_bold_icons_title">Disable bold icons</string>
|
||||
<string name="revanced_navigation_bar_disable_bold_icons_summary_on">Icons are not bold</string>
|
||||
<string name="revanced_navigation_bar_disable_bold_icons_summary_off">Icons are bold</string>
|
||||
<string name="revanced_disable_translucent_status_bar_title">Disable translucent status bar</string>
|
||||
<string name="revanced_disable_translucent_status_bar_summary_on">Status bar is opaque</string>
|
||||
<string name="revanced_disable_translucent_status_bar_summary_off">Status bar is opaque or translucent</string>
|
||||
|
||||
Reference in New Issue
Block a user