Skip to content
This repository has been archived by the owner on Oct 26, 2024. It is now read-only.

Commit

Permalink
feat(YouTube): Merge multiple player overlay patches into `Hide playe…
Browse files Browse the repository at this point in the history
…r overlay buttons` (#722)
  • Loading branch information
LisoUseInAIKyrios authored Oct 22, 2024
1 parent c76d8b1 commit 55089ba
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,8 @@ public Setting(@NonNull String key,
* Migrate a setting value if the path is renamed but otherwise the old and new settings are identical.
*/
public static <T> void migrateOldSettingToNew(@NonNull Setting<T> oldSetting, @NonNull Setting<T> newSetting) {
if (oldSetting == newSetting) throw new IllegalArgumentException();

if (!oldSetting.isSetToDefault()) {
Logger.printInfo(() -> "Migrating old setting value: " + oldSetting + " into replacement setting: " + newSetting);
newSetting.save(oldSetting.value);
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,15 +1,40 @@
package app.revanced.integrations.youtube.patches;

import android.view.View;
import android.widget.ImageView;

import app.revanced.integrations.shared.Logger;
import app.revanced.integrations.shared.Utils;
import app.revanced.integrations.youtube.settings.Settings;

@SuppressWarnings("unused")
public final class HidePlayerButtonsPatch {
public final class HidePlayerOverlayButtonsPatch {

private static final boolean HIDE_PLAYER_BUTTONS_ENABLED = Settings.HIDE_PLAYER_BUTTONS.get();
private static final boolean HIDE_AUTOPLAY_BUTTON_ENABLED = Settings.HIDE_AUTOPLAY_BUTTON.get();

/**
* Injection point.
*/
public static boolean hideAutoPlayButton() {
return HIDE_AUTOPLAY_BUTTON_ENABLED;
}

/**
* Injection point.
*/
public static int getCastButtonOverrideV2(int original) {
return Settings.HIDE_CAST_BUTTON.get() ? View.GONE : original;
}

/**
* Injection point.
*/
public static void hideCaptionsButton(ImageView imageView) {
imageView.setVisibility(Settings.HIDE_CAPTIONS_BUTTON.get() ? ImageView.GONE : ImageView.VISIBLE);
}

private static final boolean HIDE_PLAYER_PREVIOUS_NEXT_BUTTONS_ENABLED
= Settings.HIDE_PLAYER_PREVIOUS_NEXT_BUTTONS.get();

private static final int PLAYER_CONTROL_PREVIOUS_BUTTON_TOUCH_AREA_ID =
Utils.getResourceIdentifier("player_control_previous_button_touch_area", "id");
Expand All @@ -21,7 +46,7 @@ public final class HidePlayerButtonsPatch {
* Injection point.
*/
public static void hidePreviousNextButtons(View parentView) {
if (!HIDE_PLAYER_BUTTONS_ENABLED) {
if (!HIDE_PLAYER_PREVIOUS_NEXT_BUTTONS_ENABLED) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ public class Settings extends BaseSettings {
public static final BooleanSetting DISABLE_LIKE_SUBSCRIBE_GLOW = new BooleanSetting("revanced_disable_like_subscribe_glow", FALSE);
public static final BooleanSetting HIDE_AUTOPLAY_BUTTON = new BooleanSetting("revanced_hide_autoplay_button", TRUE, true);
public static final BooleanSetting HIDE_CAST_BUTTON = new BooleanSetting("revanced_hide_cast_button", TRUE, true);
public static final BooleanSetting HIDE_PLAYER_PREVIOUS_NEXT_BUTTONS = new BooleanSetting("revanced_hide_player_previous_next_buttons", FALSE, true);
@Deprecated
public static final BooleanSetting HIDE_PLAYER_BUTTONS = new BooleanSetting("revanced_hide_player_buttons", FALSE, true);
public static final BooleanSetting COPY_VIDEO_URL = new BooleanSetting("revanced_copy_video_url", FALSE);
public static final BooleanSetting COPY_VIDEO_URL_TIMESTAMP = new BooleanSetting("revanced_copy_video_url_timestamp", TRUE);
Expand Down Expand Up @@ -438,6 +440,8 @@ public class Settings extends BaseSettings {

migrateOldSettingToNew(HIDE_LOAD_MORE_BUTTON, HIDE_SHOW_MORE_BUTTON);

migrateOldSettingToNew(HIDE_PLAYER_BUTTONS, HIDE_PLAYER_PREVIOUS_NEXT_BUTTONS);

// endregion
}
}

0 comments on commit 55089ba

Please sign in to comment.