Skip to content

Commit

Permalink
feat(YouTube - Change start page): Add Change start page type setting
Browse files Browse the repository at this point in the history
  • Loading branch information
anddea committed Sep 30, 2024
1 parent 2711a55 commit ce2d61f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringUtils;

import app.revanced.integrations.shared.settings.Setting;
import app.revanced.integrations.shared.utils.Logger;
import app.revanced.integrations.youtube.settings.Settings;

Expand Down Expand Up @@ -87,6 +88,7 @@ private boolean isIntentAction() {
private static final String ACTION_MAIN = "android.intent.action.MAIN";

private static final StartPage START_PAGE = Settings.CHANGE_START_PAGE.get();
private static final boolean ALWAYS_CHANGE_START_PAGE = Settings.CHANGE_START_PAGE_TYPE.get();

/**
* There is an issue where the back button on the toolbar doesn't work properly.
Expand All @@ -98,7 +100,7 @@ public static String overrideBrowseId(@NonNull String original) {
if (!START_PAGE.isBrowseId()) {
return original;
}
if (appLaunched) {
if (!ALWAYS_CHANGE_START_PAGE && appLaunched) {
Logger.printDebug(() -> "Ignore override browseId as the app already launched");
return original;
}
Expand All @@ -118,14 +120,16 @@ public static void overrideIntentAction(@NonNull Intent intent) {
" as the current activity is not the entry point of the application");
return;
}
if (appLaunched) {
Logger.printDebug(() -> "Ignore override intent action as the app already launched");
return;
}
appLaunched = true;

final String intentAction = START_PAGE.id;
Logger.printDebug(() -> "Changing intent action to " + intentAction);
intent.setAction(intentAction);
}

public static final class ChangeStartPageTypeAvailability implements Setting.Availability {
@Override
public boolean isAvailable() {
return Settings.CHANGE_START_PAGE.get() != StartPage.ORIGINAL;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import app.revanced.integrations.youtube.patches.alternativethumbnails.AlternativeThumbnailsPatch.StillImagesAvailability;
import app.revanced.integrations.youtube.patches.alternativethumbnails.AlternativeThumbnailsPatch.ThumbnailOption;
import app.revanced.integrations.youtube.patches.alternativethumbnails.AlternativeThumbnailsPatch.ThumbnailStillTime;
import app.revanced.integrations.youtube.patches.general.ChangeStartPagePatch;
import app.revanced.integrations.youtube.patches.general.ChangeStartPagePatch.StartPage;
import app.revanced.integrations.youtube.patches.general.YouTubeMusicActionsPatch;
import app.revanced.integrations.youtube.patches.misc.SpoofStreamingDataPatch;
Expand Down Expand Up @@ -133,6 +134,8 @@ public class Settings extends BaseSettings {

// PreferenceScreen: General
public static final EnumSetting<StartPage> CHANGE_START_PAGE = new EnumSetting<>("revanced_change_start_page", StartPage.ORIGINAL, true);
public static final BooleanSetting CHANGE_START_PAGE_TYPE = new BooleanSetting("revanced_change_start_page_type", FALSE, true,
new ChangeStartPagePatch.ChangeStartPageTypeAvailability());
public static final BooleanSetting DISABLE_AUTO_AUDIO_TRACKS = new BooleanSetting("revanced_disable_auto_audio_tracks", FALSE);
public static final BooleanSetting DISABLE_SPLASH_ANIMATION = new BooleanSetting("revanced_disable_splash_animation", FALSE, true);
public static final BooleanSetting ENABLE_GRADIENT_LOADING_SCREEN = new BooleanSetting("revanced_enable_gradient_loading_screen", FALSE, true);
Expand Down

0 comments on commit ce2d61f

Please sign in to comment.