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

feat(YouTube): Support versions 19.25 and 19.34 #689

Merged
merged 104 commits into from
Oct 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
104 commits
Select commit Hold shift + click to select a range
d498d79
fix(YouTube - Spoof Client): Fix playback by replace streaming data
zainarbani Aug 24, 2024
ab0543b
Merge branch 'dev' into fix/yt-spoof-stream
zainarbani Aug 24, 2024
109a83e
Fix missmerge
zainarbani Aug 24, 2024
0bc88bd
Add iOS client as streaming data source
zainarbani Aug 25, 2024
38a54d1
refactor
LisoUseInAIKyrios Aug 26, 2024
3c07c12
Update desc
zainarbani Aug 26, 2024
06824a8
refactor: Present stream replacement in the settings as an option sim…
LisoUseInAIKyrios Aug 26, 2024
6649e0c
refactor
LisoUseInAIKyrios Aug 26, 2024
3c31b6a
fix: Close byte array stream, do not show toast if all streams return…
LisoUseInAIKyrios Aug 26, 2024
612a65b
fix: Remove debug code
LisoUseInAIKyrios Aug 26, 2024
36e072c
fix: Show error toast only if last attempt fails. Add more logging.
LisoUseInAIKyrios Aug 26, 2024
6c46060
fix refactoring typo, use correct Android SDK version
LisoUseInAIKyrios Aug 26, 2024
ab2791d
fix: If debug is enabled, then use a random client order
LisoUseInAIKyrios Aug 26, 2024
cf62175
fix: Comments, warnings
LisoUseInAIKyrios Aug 26, 2024
f419920
fix: Don't override player responses when all spoofing is off
LisoUseInAIKyrios Aug 26, 2024
9b1e84b
fix: Remove unused setting
LisoUseInAIKyrios Aug 26, 2024
bfe7faa
fix: Remove client type spoofing and use only stream replacement
LisoUseInAIKyrios Aug 26, 2024
69a1a88
Fix: Remove obsolete code that no longer works
LisoUseInAIKyrios Aug 26, 2024
7fc164c
fix: Comments
LisoUseInAIKyrios Aug 27, 2024
2e3f219
Cleanup
LisoUseInAIKyrios Aug 27, 2024
4248422
fix: Can use non experimental parent class type
LisoUseInAIKyrios Aug 28, 2024
760bc11
Don't block /get_watch
zainarbani Aug 31, 2024
3319922
Remove debug
zainarbani Aug 31, 2024
f46a46d
Update app/src/main/java/app/revanced/integrations/youtube/patches/sp…
LisoUseInAIKyrios Aug 31, 2024
9010ba4
fix compilation
LisoUseInAIKyrios Aug 31, 2024
f99572f
refactor: Can use a simpler synchronized map since there is little to…
LisoUseInAIKyrios Aug 31, 2024
e5a6981
fix: Do not fetch Shorts streams until the Short is opened
LisoUseInAIKyrios Aug 31, 2024
397f5cf
refactor
LisoUseInAIKyrios Aug 31, 2024
1a30868
refactor
LisoUseInAIKyrios Aug 31, 2024
6c24707
refactor
LisoUseInAIKyrios Aug 31, 2024
6d3f796
Merge branch 'dev' into fix/yt-spoof-stream
LisoUseInAIKyrios Sep 2, 2024
fa81832
Revert "Don't block /get_watch"
LisoUseInAIKyrios Sep 3, 2024
2d7ea04
refactor
LisoUseInAIKyrios Sep 3, 2024
90fee40
Merge remote-tracking branch 'refs/remotes/upstream/dev' into fix/yt-…
LisoUseInAIKyrios Sep 7, 2024
55c7ab8
fix: Remove assert until a way around it is figured out
LisoUseInAIKyrios Sep 7, 2024
bb45316
Comments, logging
LisoUseInAIKyrios Sep 7, 2024
b2693a9
fix: Use a cache again, to handle if any recently used video ids are …
LisoUseInAIKyrios Sep 7, 2024
0bd6dc5
fix: Always fetch if YT is fetching
LisoUseInAIKyrios Sep 7, 2024
7859fc6
fix: Don't use an cache expiration for streams since they are always …
LisoUseInAIKyrios Sep 7, 2024
b55a979
feat(YouTube): Support version `~19.31`
zainarbani Sep 7, 2024
0cc000d
refactor: Use a single enum for all library tabs
LisoUseInAIKyrios Sep 8, 2024
92e17bf
fix: Add cairo style navigation tabs
LisoUseInAIKyrios Sep 8, 2024
01de4f5
fix: Use thread local to fix multi-threaded clashing
LisoUseInAIKyrios Sep 8, 2024
c2c77d0
fix: Fix crashing on newer versions. Do not hide skip ad button in mi…
LisoUseInAIKyrios Sep 8, 2024
60bc6f1
fix(Background play): Fix Premium user unusual edge case failure
LisoUseInAIKyrios Sep 8, 2024
a9bd260
fix(Miniplayer): Add Modern 1 drag and drop, double tap action
LisoUseInAIKyrios Sep 8, 2024
90f84d6
feat(Miniplayer): Customize `19.28` miniplayer size
LisoUseInAIKyrios Sep 8, 2024
d6782c5
fix Sponsorblock overlay buttons
LisoUseInAIKyrios Sep 9, 2024
444bb6b
Merge branch 'refs/heads/fix/yt-spoof-stream' into feat/yt-bump
LisoUseInAIKyrios Sep 9, 2024
4d95b8d
refactor: Move some classes to their own files
LisoUseInAIKyrios Sep 10, 2024
a8ef9e2
fix: Use two method patching only with 19.18+
LisoUseInAIKyrios Sep 10, 2024
c390e2b
feat: Initial support for `19.36.37`. Miniplayer settings need to be…
LisoUseInAIKyrios Sep 12, 2024
6b8f097
fix miniplayer: Only recommend versions that have no bugs, and have s…
LisoUseInAIKyrios Sep 14, 2024
33bee72
Revert "Merge branch 'refs/heads/fix/yt-spoof-stream' into feat/yt-bump"
LisoUseInAIKyrios Sep 14, 2024
cb72fa8
fix(Change start page): Add limited support for 19.25+
LisoUseInAIKyrios Sep 16, 2024
93eac69
Comments
LisoUseInAIKyrios Sep 17, 2024
0f90d6c
Merge remote-tracking branch 'refs/remotes/upstream/dev' into feat/yt…
LisoUseInAIKyrios Sep 17, 2024
8fbf23a
fix: Changing default of 'hide shorts navigation bar' default to off,…
LisoUseInAIKyrios Sep 17, 2024
bf73f80
fix(Enable slide to seek): Require restart
LisoUseInAIKyrios Sep 17, 2024
bc21e6f
Merge remote-tracking branch 'refs/remotes/upstream/dev' into feat/yt…
LisoUseInAIKyrios Sep 17, 2024
0648478
fix: Show an error if a preference has a key but no setting
LisoUseInAIKyrios Sep 18, 2024
89ba56a
fix(Change start page): Fix url start pages
LisoUseInAIKyrios Sep 18, 2024
32b189e
fix(Hide Shorts components): Use same `Hide Shorts Navigation bar` se…
LisoUseInAIKyrios Sep 18, 2024
c2a2504
fix(Hide Shorts components): Simplify fingerprints, use weak referenc…
LisoUseInAIKyrios Sep 18, 2024
1515a90
fix(Hide Shorts components): Fix nav bar hiding at wrong times
LisoUseInAIKyrios Sep 19, 2024
f63a398
fix(Hide Shorts components): Do not cut off Shorts seekbar if navbar …
LisoUseInAIKyrios Sep 19, 2024
0acd61b
revert fix(Hide Shorts components). Cannot set a height otherwise if…
LisoUseInAIKyrios Sep 19, 2024
0647829
fix(Hide Shorts components): If hiding the the nav bar, then use padd…
LisoUseInAIKyrios Sep 19, 2024
d118809
fix(Hide Shorts components): Also hide empty space if sound button is…
LisoUseInAIKyrios Sep 19, 2024
4a57d8b
fix(Hide Shorts components): Hide navigation bar when opening a Short…
LisoUseInAIKyrios Sep 19, 2024
bcc80d1
Merge remote-tracking branch 'refs/remotes/upstream/dev' into feat/yt…
LisoUseInAIKyrios Sep 19, 2024
fffe304
fix(Miniplayer): Fix broken scrolling if 'default' is used
LisoUseInAIKyrios Sep 20, 2024
d85ca87
fix: Resolve `slide to seek` remaining issue
zainarbani Sep 22, 2024
c0069d5
Merge remote-tracking branch 'refs/remotes/upstream/dev' into feat/yt…
LisoUseInAIKyrios Sep 23, 2024
460534a
fix: Only log miniplayer feature flags if they were originally turned on
LisoUseInAIKyrios Sep 24, 2024
954b82a
fix: Increase bottom padding if Shorts navbar is hidden. This featur…
LisoUseInAIKyrios Sep 24, 2024
e396c50
fix(Settings): Do not show background color in edit text preference c…
LisoUseInAIKyrios Sep 27, 2024
294bfa7
Unofficial support for 19.39
LisoUseInAIKyrios Sep 28, 2024
da209d1
Merge remote-tracking branch 'refs/remotes/upstream/dev' into feat/yt…
LisoUseInAIKyrios Sep 29, 2024
1ad4904
Merge remote-tracking branch 'refs/remotes/upstream/dev' into feat/yt…
LisoUseInAIKyrios Oct 3, 2024
fe5b991
Merge remote-tracking branch 'upstream/dev' into feat/yt-bump
LisoUseInAIKyrios Oct 6, 2024
50dbccf
Comments
LisoUseInAIKyrios Oct 6, 2024
849dbe4
Merge remote-tracking branch 'upstream/dev' into feat/yt-bump
LisoUseInAIKyrios Oct 7, 2024
55ec5d1
Miniplayer: Add rounded corners setting if patching 19.36+
LisoUseInAIKyrios Oct 15, 2024
79b8f30
refactor
LisoUseInAIKyrios Oct 15, 2024
694aacf
fix(Hide player buttons patch): fix 19.34
LisoUseInAIKyrios Oct 15, 2024
f7b8249
fix(Hide player buttons patch): Override on click listener
LisoUseInAIKyrios Oct 16, 2024
ea11907
refactor: simplify
LisoUseInAIKyrios Oct 16, 2024
7fa079e
fix: Allow double tapping area where forward/back normally is.
LisoUseInAIKyrios Oct 16, 2024
0790f1d
Merge remote-tracking branch 'upstream/dev' into feat/yt-bump
LisoUseInAIKyrios Oct 18, 2024
bbd6126
feat(Theme): Use Cairo seekbar
LisoUseInAIKyrios Oct 18, 2024
694edf6
refactor: Simplify seekbar cairo setting
LisoUseInAIKyrios Oct 18, 2024
2b9150e
refactor: Use more descriptive fingerprint name
LisoUseInAIKyrios Oct 18, 2024
6b90fbd
fix typo
LisoUseInAIKyrios Oct 19, 2024
934f860
fix(Seekbar color): Support gradient seekbar
LisoUseInAIKyrios Oct 19, 2024
f6ff69d
refactor
LisoUseInAIKyrios Oct 19, 2024
1c953eb
refactor: Move version checks to shared patch
LisoUseInAIKyrios Oct 19, 2024
0e68973
logging
LisoUseInAIKyrios Oct 19, 2024
021ef79
refactor: rename
LisoUseInAIKyrios Oct 19, 2024
ec4cdc5
fix seekbar not hiding if custom seekbar color is off
LisoUseInAIKyrios Oct 19, 2024
611f7c4
fix: simplify
LisoUseInAIKyrios Oct 19, 2024
f2770d7
fix typo
LisoUseInAIKyrios Oct 19, 2024
97d9eac
logging
LisoUseInAIKyrios Oct 19, 2024
de105bc
refactor: Move patch to patch package
LisoUseInAIKyrios Oct 19, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 32 additions & 4 deletions app/src/main/java/app/revanced/integrations/shared/Utils.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
package app.revanced.integrations.shared;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.DialogFragment;
import android.app.*;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageInfo;
Expand Down Expand Up @@ -268,6 +265,20 @@ public interface MatchFilter<T> {
boolean matches(T object);
}

/**
* Includes sub children.
*
* @noinspection unchecked
*/
public static <R extends View> R getChildViewByResourceName(@NonNull View view, @NonNull String str) {
var child = view.findViewById(Utils.getResourceIdentifier(str, "id"));
if (child != null) {
return (R) child;
}

throw new IllegalArgumentException("View with resource name '" + str + "' not found");
}

/**
* @param searchRecursively If children ViewGroups should also be
* recursively searched using depth first search.
Expand Down Expand Up @@ -710,4 +721,21 @@ public static void sortPreferenceGroups(@NonNull PreferenceGroup group) {
pref.setOrder(order);
}
}

/**
* If {@link Fragment} uses [Android library] rather than [AndroidX library],
* the Dialog theme corresponding to [Android library] should be used.
* <p>
* If not, the following issues will occur:
* <a href="https://github.com/ReVanced/revanced-patches/issues/3061">ReVanced/revanced-patches#3061</a>
* <p>
* To prevent these issues, apply the Dialog theme corresponding to [Android library].
*/
public static void setEditTextDialogTheme(AlertDialog.Builder builder) {
final int editTextDialogStyle = getResourceIdentifier(
"revanced_edit_text_dialog_style", "style");
if (editTextDialogStyle != 0) {
builder.getContext().setTheme(editTextDialogStyle);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

import app.revanced.integrations.shared.Logger;
import app.revanced.integrations.shared.Utils;
import app.revanced.integrations.shared.settings.BaseSettings;
import app.revanced.integrations.shared.settings.BooleanSetting;
import app.revanced.integrations.shared.settings.Setting;

Expand Down Expand Up @@ -141,8 +142,13 @@ private void updatePreferenceScreen(@NonNull PreferenceScreen screen,
} else if (pref.hasKey()) {
String key = pref.getKey();
Setting<?> setting = Setting.getSettingFromPath(key);

if (setting != null) {
updatePreference(pref, setting, syncSettingValue, applySettingToPreference);
} else if (BaseSettings.DEBUG.get() && (pref instanceof SwitchPreference
|| pref instanceof EditTextPreference || pref instanceof ListPreference)) {
// Probably a typo in the patches preference declaration.
Logger.printException(() -> "Preference key has no setting: " + key);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ public boolean onPreferenceClick(Preference preference) {
@Override
protected void onPrepareDialogBuilder(AlertDialog.Builder builder) {
try {
Utils.setEditTextDialogTheme(builder);

// Show the user the settings in JSON format.
builder.setNeutralButton(str("revanced_settings_import_copy"), (dialog, which) -> {
Utils.setClipboard(getEditText().getText().toString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import android.util.AttributeSet;
import android.widget.Button;
import android.widget.EditText;

import app.revanced.integrations.shared.Utils;
import app.revanced.integrations.shared.settings.Setting;
import app.revanced.integrations.shared.Logger;

Expand All @@ -33,6 +35,8 @@ public ResettableEditTextPreference(Context context) {
@Override
protected void onPrepareDialogBuilder(AlertDialog.Builder builder) {
super.onPrepareDialogBuilder(builder);
Utils.setEditTextDialogTheme(builder);

Setting<?> setting = Setting.getSettingFromPath(getKey());
if (setting != null) {
builder.setNeutralButton(str("revanced_settings_reset"), null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ public class BackgroundPlaybackPatch {
/**
* Injection point.
*/
public static boolean playbackIsNotShort() {
public static boolean allowBackgroundPlayback(boolean original) {
if (original) return true;

// Steps to verify most edge cases:
// 1. Open a regular video
// 2. Minimize app (PIP should appear)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,129 @@
package app.revanced.integrations.youtube.patches;

import static java.lang.Boolean.FALSE;
import static java.lang.Boolean.TRUE;

import android.content.Intent;
import android.net.Uri;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

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

@SuppressWarnings("unused")
public final class ChangeStartPagePatch {
public static void changeIntent(final Intent intent) {
final var startPage = Settings.START_PAGE.get();
if (startPage.isEmpty()) return;

Logger.printDebug(() -> "Changing start page to " + startPage);
public enum StartPage {
/**
* Unmodified type, and same as un-patched.
*/
ORIGINAL("", null),

/**
* Browse id.
*/
BROWSE("FEguide_builder", TRUE),
EXPLORE("FEexplore", TRUE),
HISTORY("FEhistory", TRUE),
LIBRARY("FElibrary", TRUE),
MOVIE("FEstorefront", TRUE),
SUBSCRIPTIONS("FEsubscriptions", TRUE),
TRENDING("FEtrending", TRUE),

/**
* Channel id, this can be used as a browseId.
*/
GAMING("UCOpNcN46UbXVtpKMrmU4Abg", TRUE),
LIVE("UC4R8DWoMoI7CAwX8_LjQHig", TRUE),
MUSIC("UC-9-kyTW8ZkZNDHQJ6FgpwQ", TRUE),
SPORTS("UCEgdi0XIXXZ-qJOFPf4JSKw", TRUE),

/**
* Playlist id, this can be used as a browseId.
*/
LIKED_VIDEO("VLLL", TRUE),
WATCH_LATER("VLWL", TRUE),

/**
* Intent action.
*/
SEARCH("com.google.android.youtube.action.open.search", FALSE),
SHORTS("com.google.android.youtube.action.open.shorts", FALSE);

@Nullable
final Boolean isBrowseId;

@NonNull
final String id;

StartPage(@NonNull String id, @Nullable Boolean isBrowseId) {
this.id = id;
this.isBrowseId = isBrowseId;
}

private boolean isBrowseId() {
return TRUE.equals(isBrowseId);
}

@SuppressWarnings("BooleanMethodIsAlwaysInverted")
private boolean isIntentAction() {
return FALSE.equals(isBrowseId);
}
}

/**
* Intent action when YouTube is cold started from the launcher.
* <p>
* If you don't check this, the hooking will also apply in the following cases:
* Case 1. The user clicked Shorts button on the YouTube shortcut.
* Case 2. The user clicked Shorts button on the YouTube widget.
* In this case, instead of opening Shorts, the start page specified by the user is opened.
*/
private static final String ACTION_MAIN = "android.intent.action.MAIN";

private static final StartPage START_PAGE = Settings.CHANGE_START_PAGE.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.
*/
private static boolean appLaunched = false;

public static String overrideBrowseId(@NonNull String original) {
if (!START_PAGE.isBrowseId()) {
return original;
}

if (appLaunched) {
Logger.printDebug(() -> "Ignore override browseId as the app already launched");
return original;
}
appLaunched = true;

Logger.printDebug(() -> "Changing browseId to " + START_PAGE.id);
return START_PAGE.id;
}

public static void overrideIntentAction(@NonNull Intent intent) {
if (!START_PAGE.isIntentAction()) {
return;
}

if (!ACTION_MAIN.equals(intent.getAction())) {
Logger.printDebug(() -> "Ignore override intent action" +
" 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;

if (startPage.startsWith("www"))
intent.setData(Uri.parse(startPage));
else
intent.setAction("com.google.android.youtube.action." + startPage);
final String intentAction = START_PAGE.id;
Logger.printDebug(() -> "Changing intent action to " + intentAction);
intent.setAction(intentAction);
}
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,47 @@
package app.revanced.integrations.youtube.patches;

import android.view.View;

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 {

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

private static final int PLAYER_CONTROL_PREVIOUS_BUTTON_TOUCH_AREA_ID =
Utils.getResourceIdentifier("player_control_previous_button_touch_area", "id");

private static final int PLAYER_CONTROL_NEXT_BUTTON_TOUCH_AREA_ID =
Utils.getResourceIdentifier("player_control_next_button_touch_area", "id");

/**
* Injection point.
*/
public static boolean previousOrNextButtonIsVisible(boolean previousOrNextButtonVisible) {
if (Settings.HIDE_PLAYER_BUTTONS.get()) {
return false;
public static void hidePreviousNextButtons(View parentView) {
if (!HIDE_PLAYER_BUTTONS_ENABLED) {
return;
}

// Must use a deferred call to main thread to hide the button.
// Otherwise the layout crashes if set to hidden now.
Utils.runOnMainThread(() -> {
hideView(parentView, PLAYER_CONTROL_PREVIOUS_BUTTON_TOUCH_AREA_ID);
hideView(parentView, PLAYER_CONTROL_NEXT_BUTTON_TOUCH_AREA_ID);
});
}

private static void hideView(View parentView, int resourceId) {
View nextPreviousButton = parentView.findViewById(resourceId);

if (nextPreviousButton == null) {
Logger.printException(() -> "Could not find player previous/next button");
return;
}
return previousOrNextButtonVisible;

Logger.printDebug(() -> "Hiding previous/next button");
Utils.hideViewByRemovingFromParentUnderCondition(true, nextPreviousButton);
}
}
Loading
Loading