mirror of
https://github.com/revanced/revanced-patches.git
synced 2025-04-29 22:24:27 +02:00
fix(YouTube - Change start page): Add option to always override start page on app launch (#4832)
This commit is contained in:
parent
ee9039428c
commit
5062e24433
@ -9,6 +9,7 @@ import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import app.revanced.extension.shared.Logger;
|
||||
import app.revanced.extension.shared.settings.Setting;
|
||||
import app.revanced.extension.youtube.settings.Settings;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@ -81,6 +82,13 @@ public final class ChangeStartPagePatch {
|
||||
}
|
||||
}
|
||||
|
||||
public static class ChangeStartPageTypeAvailability implements Setting.Availability {
|
||||
@Override
|
||||
public boolean isAvailable() {
|
||||
return Settings.CHANGE_START_PAGE.get() != StartPage.DEFAULT;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Intent action when YouTube is cold started from the launcher.
|
||||
* <p>
|
||||
@ -93,6 +101,8 @@ public final class ChangeStartPagePatch {
|
||||
|
||||
private static final StartPage START_PAGE = Settings.CHANGE_START_PAGE.get();
|
||||
|
||||
private static final boolean CHANGE_START_PAGE_ALWAYS = Settings.CHANGE_START_PAGE_ALWAYS.get();
|
||||
|
||||
/**
|
||||
* There is an issue where the back button on the toolbar doesn't work properly.
|
||||
* As a workaround for this issue, instead of overriding the browserId multiple times, just override it once.
|
||||
@ -104,13 +114,13 @@ public final class ChangeStartPagePatch {
|
||||
return original;
|
||||
}
|
||||
|
||||
if (appLaunched) {
|
||||
if (!CHANGE_START_PAGE_ALWAYS && appLaunched) {
|
||||
Logger.printDebug(() -> "Ignore override browseId as the app already launched");
|
||||
return original;
|
||||
}
|
||||
appLaunched = true;
|
||||
|
||||
Logger.printDebug(() -> "Changing browseId to " + START_PAGE.id);
|
||||
Logger.printDebug(() -> "Changing browseId to: " + START_PAGE.id);
|
||||
return START_PAGE.id;
|
||||
}
|
||||
|
||||
@ -125,14 +135,14 @@ public final class ChangeStartPagePatch {
|
||||
return;
|
||||
}
|
||||
|
||||
if (appLaunched) {
|
||||
if (!CHANGE_START_PAGE_ALWAYS && appLaunched) {
|
||||
Logger.printDebug(() -> "Ignore override intent action as the app already launched");
|
||||
return;
|
||||
}
|
||||
appLaunched = true;
|
||||
|
||||
String intentAction = START_PAGE.id;
|
||||
Logger.printDebug(() -> "Changing intent action to " + intentAction);
|
||||
Logger.printDebug(() -> "Changing intent action to: " + intentAction);
|
||||
intent.setAction(intentAction);
|
||||
}
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import static app.revanced.extension.shared.settings.Setting.migrateOldSettingTo
|
||||
import static app.revanced.extension.shared.settings.Setting.parent;
|
||||
import static app.revanced.extension.shared.settings.Setting.parentsAny;
|
||||
import static app.revanced.extension.youtube.patches.ChangeFormFactorPatch.FormFactor;
|
||||
import static app.revanced.extension.youtube.patches.ChangeStartPagePatch.ChangeStartPageTypeAvailability;
|
||||
import static app.revanced.extension.youtube.patches.ChangeStartPagePatch.StartPage;
|
||||
import static app.revanced.extension.youtube.patches.ExitFullscreenPatch.FullscreenMode;
|
||||
import static app.revanced.extension.youtube.patches.ForceOriginalAudioPatch.ForceOriginalAudioAvailability;
|
||||
@ -222,6 +223,8 @@ public class Settings extends BaseSettings {
|
||||
public static final BooleanSetting SPOOF_APP_VERSION = new BooleanSetting("revanced_spoof_app_version", FALSE, true, "revanced_spoof_app_version_user_dialog_message");
|
||||
public static final BooleanSetting WIDE_SEARCHBAR = new BooleanSetting("revanced_wide_searchbar", FALSE, true);
|
||||
public static final EnumSetting<StartPage> CHANGE_START_PAGE = new EnumSetting<>("revanced_change_start_page", StartPage.DEFAULT, true);
|
||||
public static final BooleanSetting CHANGE_START_PAGE_ALWAYS = new BooleanSetting("revanced_change_start_page_always", FALSE, true,
|
||||
new ChangeStartPageTypeAvailability());
|
||||
public static final StringSetting SPOOF_APP_VERSION_TARGET = new StringSetting("revanced_spoof_app_version_target", "19.01.34", true, parent(SPOOF_APP_VERSION));
|
||||
// Custom filter
|
||||
public static final BooleanSetting CUSTOM_FILTER = new BooleanSetting("revanced_custom_filter", FALSE);
|
||||
|
@ -7,6 +7,9 @@ import app.revanced.patcher.patch.bytecodePatch
|
||||
import app.revanced.patches.all.misc.resources.addResources
|
||||
import app.revanced.patches.all.misc.resources.addResourcesPatch
|
||||
import app.revanced.patches.shared.misc.settings.preference.ListPreference
|
||||
import app.revanced.patches.shared.misc.settings.preference.PreferenceCategory
|
||||
import app.revanced.patches.shared.misc.settings.preference.PreferenceScreenPreference.Sorting
|
||||
import app.revanced.patches.shared.misc.settings.preference.SwitchPreference
|
||||
import app.revanced.patches.youtube.misc.extension.sharedExtensionPatch
|
||||
import app.revanced.patches.youtube.misc.settings.PreferenceScreen
|
||||
import app.revanced.patches.youtube.misc.settings.settingsPatch
|
||||
@ -43,10 +46,18 @@ val changeStartPagePatch = bytecodePatch(
|
||||
addResources("youtube", "layout.startpage.changeStartPagePatch")
|
||||
|
||||
PreferenceScreen.GENERAL_LAYOUT.addPreferences(
|
||||
ListPreference(
|
||||
key = "revanced_change_start_page",
|
||||
summaryKey = null,
|
||||
),
|
||||
PreferenceCategory(
|
||||
titleKey = null,
|
||||
sorting = Sorting.UNSORTED,
|
||||
tag = "app.revanced.extension.shared.settings.preference.NoTitlePreferenceCategory",
|
||||
preferences = setOf(
|
||||
ListPreference(
|
||||
key = "revanced_change_start_page",
|
||||
summaryKey = null,
|
||||
),
|
||||
SwitchPreference("revanced_change_start_page_always")
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
// Hook browseId.
|
||||
|
@ -1173,7 +1173,7 @@ If later turned off, it is recommended to clear the app data to prevent UI bugs.
|
||||
<string name="revanced_spoof_app_version_target_entry_2">19.01.34 - Restore old navigation icons</string>
|
||||
</patch>
|
||||
<patch id="layout.startpage.changeStartPagePatch">
|
||||
<string name="revanced_change_start_page_title">Set start page</string>
|
||||
<string name="revanced_change_start_page_title">Change start page</string>
|
||||
<string name="revanced_change_start_page_entry_default">Default</string>
|
||||
<string name="revanced_change_start_page_entry_all_subscriptions">All subscriptions</string>
|
||||
<string name="revanced_change_start_page_entry_browse">Browse channels</string>
|
||||
@ -1199,6 +1199,11 @@ If later turned off, it is recommended to clear the app data to prevent UI bugs.
|
||||
<string name="revanced_change_start_page_entry_virtual_reality">Virtual Reality</string>
|
||||
<string name="revanced_change_start_page_entry_watch_later">Watch later</string>
|
||||
<string name="revanced_change_start_page_entry_your_clips">Your clips</string>
|
||||
<string name="revanced_change_start_page_always_title">Always change start page</string>
|
||||
<string name="revanced_change_start_page_always_summary_on">"Start page is always changed
|
||||
|
||||
Limitation: Using the back button on the toolbar may not work"</string>
|
||||
<string name="revanced_change_start_page_always_summary_off">Start page is changed only on app startup</string>
|
||||
</patch>
|
||||
<patch id="layout.startupshortsreset.disableResumingShortsOnStartupPatch">
|
||||
<string name="revanced_disable_resuming_shorts_player_title">Disable resuming Shorts player</string>
|
||||
|
Loading…
x
Reference in New Issue
Block a user