Skip to content

Commit 9ba45b6

Browse files
feat(YouTube - Change header): Add in-app setting to change the app header (#5346)
1 parent a368cda commit 9ba45b6

File tree

46 files changed

+286
-142
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+286
-142
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
package app.revanced.extension.youtube.patches;
2+
3+
import androidx.annotation.Nullable;
4+
5+
import java.util.Objects;
6+
7+
import app.revanced.extension.shared.Utils;
8+
import app.revanced.extension.youtube.settings.Settings;
9+
10+
@SuppressWarnings("unused")
11+
public class ChangeHeaderPatch {
12+
13+
public enum HeaderLogo {
14+
DEFAULT(null),
15+
REGULAR("ytWordmarkHeader"),
16+
PREMIUM("ytPremiumWordmarkHeader"),
17+
REVANCED("revanced_header_logo"),
18+
REVANCED_MINIMAL("revanced_header_logo_minimal"),
19+
CUSTOM("custom_header");
20+
21+
@Nullable
22+
private final String resourceName;
23+
24+
HeaderLogo(@Nullable String resourceName) {
25+
this.resourceName = resourceName;
26+
}
27+
28+
/**
29+
* @return The attribute id of this header logo, or NULL if the logo should not be replaced.
30+
*/
31+
@Nullable
32+
private Integer getAttributeId() {
33+
if (resourceName == null) {
34+
return null;
35+
}
36+
37+
return Utils.getResourceIdentifier(resourceName, "attr");
38+
}
39+
}
40+
41+
@Nullable
42+
private static final Integer headerLogoResource = Settings.HEADER_LOGO.get().getAttributeId();
43+
44+
/**
45+
* Injection point.
46+
*/
47+
public static int getHeaderAttributeId(int original) {
48+
return Objects.requireNonNullElse(headerLogoResource, original);
49+
}
50+
}

extensions/youtube/src/main/java/app/revanced/extension/youtube/settings/Settings.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import static app.revanced.extension.shared.settings.Setting.parentsAll;
99
import static app.revanced.extension.shared.settings.Setting.parentsAny;
1010
import static app.revanced.extension.youtube.patches.ChangeFormFactorPatch.FormFactor;
11+
import static app.revanced.extension.youtube.patches.ChangeHeaderPatch.HeaderLogo;
1112
import static app.revanced.extension.youtube.patches.ChangeStartPagePatch.ChangeStartPageTypeAvailability;
1213
import static app.revanced.extension.youtube.patches.ChangeStartPagePatch.StartPage;
1314
import static app.revanced.extension.youtube.patches.ExitFullscreenPatch.FullscreenMode;
@@ -238,7 +239,8 @@ public class Settings extends BaseSettings {
238239
public static final EnumSetting<FormFactor> CHANGE_FORM_FACTOR = new EnumSetting<>("revanced_change_form_factor", FormFactor.DEFAULT, true, "revanced_change_form_factor_user_dialog_message");
239240
public static final BooleanSetting BYPASS_IMAGE_REGION_RESTRICTIONS = new BooleanSetting("revanced_bypass_image_region_restrictions", FALSE, true);
240241
public static final BooleanSetting GRADIENT_LOADING_SCREEN = new BooleanSetting("revanced_gradient_loading_screen", FALSE, true);
241-
public static final EnumSetting<SplashScreenAnimationStyle> SPLASH_SCREEN_ANIMATION_STYLE = new EnumSetting<>("splash_screen_animation_style", SplashScreenAnimationStyle.FPS_60_ONE_SECOND, true);
242+
public static final EnumSetting<SplashScreenAnimationStyle> SPLASH_SCREEN_ANIMATION_STYLE = new EnumSetting<>("revanced_splash_screen_animation_style", SplashScreenAnimationStyle.FPS_60_ONE_SECOND, true);
243+
public static final EnumSetting<HeaderLogo> HEADER_LOGO = new EnumSetting<>("revanced_header_logo", HeaderLogo.DEFAULT, true);
242244

243245
public static final BooleanSetting REMOVE_VIEWER_DISCRETION_DIALOG = new BooleanSetting("revanced_remove_viewer_discretion_dialog", FALSE,
244246
"revanced_remove_viewer_discretion_dialog_user_dialog_message");

0 commit comments

Comments
 (0)