Skip to content

Commit c1379f6

Browse files
feat(YouTube): Support version 20.07.39 (#4677)
1 parent f191ab6 commit c1379f6

File tree

127 files changed

+873
-594
lines changed

Some content is hidden

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

127 files changed

+873
-594
lines changed

extensions/shared/library/src/main/java/app/revanced/extension/shared/spoof/SpoofVideoStreamsPatch.java

+15
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,21 @@ public static boolean useMediaFetchHotConfigReplacement(boolean original) {
122122
return false;
123123
}
124124

125+
/**
126+
* Injection point.
127+
* Turns off a feature flag that interferes with video playback.
128+
*/
129+
public static boolean usePlaybackStartFeatureFlag(boolean original) {
130+
if (original) {
131+
Logger.printDebug(() -> "usePlaybackStartFeatureFlag is set on");
132+
}
133+
134+
if (!SPOOF_STREAMING_DATA) {
135+
return original;
136+
}
137+
return false;
138+
}
139+
125140
/**
126141
* Injection point.
127142
*/

extensions/youtube/src/main/java/app/revanced/extension/youtube/patches/DisableResumingStartupShortsPlayerPatch.java

+8-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import app.revanced.extension.youtube.settings.Settings;
44

5-
/** @noinspection unused*/
5+
@SuppressWarnings("unused")
66
public class DisableResumingStartupShortsPlayerPatch {
77

88
/**
@@ -11,4 +11,11 @@ public class DisableResumingStartupShortsPlayerPatch {
1111
public static boolean disableResumingStartupShortsPlayer() {
1212
return Settings.DISABLE_RESUMING_SHORTS_PLAYER.get();
1313
}
14+
15+
/**
16+
* Injection point.
17+
*/
18+
public static boolean disableResumingStartupShortsPlayer(boolean original) {
19+
return original && !Settings.DISABLE_RESUMING_SHORTS_PLAYER.get();
20+
}
1421
}

extensions/youtube/src/main/java/app/revanced/extension/youtube/patches/MiniplayerPatch.java

+56-27
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,13 @@ public enum MiniplayerType {
4343
MODERN_2(null, 2),
4444
MODERN_3(null, 3),
4545
/**
46-
* Half broken miniplayer, that might be work in progress or left over abandoned code.
47-
* Can force this type by editing the import/export settings.
46+
* Works and is functional with 20.03+
4847
*/
49-
MODERN_4(null, 4);
48+
MODERN_4(null, 4),
49+
/**
50+
* Half broken miniplayer, and in 20.02 and earlier is declared as type 4.
51+
*/
52+
MODERN_5(null, 5);
5053

5154
/**
5255
* Legacy tablet hook value.
@@ -126,20 +129,21 @@ public boolean isModern() {
126129
private static final boolean DRAG_AND_DROP_ENABLED =
127130
CURRENT_TYPE.isModern() && Settings.MINIPLAYER_DRAG_AND_DROP.get();
128131

129-
private static final boolean HIDE_EXPAND_CLOSE_ENABLED =
130-
Settings.MINIPLAYER_HIDE_EXPAND_CLOSE.get()
131-
&& Settings.MINIPLAYER_HIDE_EXPAND_CLOSE.isAvailable();
132+
private static final boolean HIDE_OVERLAY_BUTTONS_ENABLED =
133+
Settings.MINIPLAYER_HIDE_OVERLAY_BUTTONS.get()
134+
&& Settings.MINIPLAYER_HIDE_OVERLAY_BUTTONS.isAvailable();
132135

133136
private static final boolean HIDE_SUBTEXT_ENABLED =
134-
(CURRENT_TYPE == MODERN_1 || CURRENT_TYPE == MODERN_3) && Settings.MINIPLAYER_HIDE_SUBTEXT.get();
137+
(CURRENT_TYPE == MODERN_1 || CURRENT_TYPE == MODERN_3 || CURRENT_TYPE == MODERN_4)
138+
&& Settings.MINIPLAYER_HIDE_SUBTEXT.get();
135139

136140
// 19.25 is last version that has forward/back buttons for phones,
137141
// but buttons still show for tablets/foldable devices and they don't work well so always hide.
138142
private static final boolean HIDE_REWIND_FORWARD_ENABLED = CURRENT_TYPE == MODERN_1
139143
&& (VersionCheckPatch.IS_19_34_OR_GREATER || Settings.MINIPLAYER_HIDE_REWIND_FORWARD.get());
140144

141145
private static final boolean MINIPLAYER_ROUNDED_CORNERS_ENABLED =
142-
Settings.MINIPLAYER_ROUNDED_CORNERS.get();
146+
CURRENT_TYPE.isModern() && Settings.MINIPLAYER_ROUNDED_CORNERS.get();
143147

144148
private static final boolean MINIPLAYER_HORIZONTAL_DRAG_ENABLED =
145149
DRAG_AND_DROP_ENABLED && Settings.MINIPLAYER_HORIZONTAL_DRAG.get();
@@ -172,11 +176,12 @@ public boolean isAvailable() {
172176
}
173177
}
174178

175-
public static final class MiniplayerHideExpandCloseAvailability implements Setting.Availability {
179+
public static final class MiniplayerHideOverlayButtonsAvailability implements Setting.Availability {
176180
@Override
177181
public boolean isAvailable() {
178182
MiniplayerType type = Settings.MINIPLAYER_TYPE.get();
179-
return (!IS_19_20_OR_GREATER && (type == MODERN_1 || type == MODERN_3))
183+
return type == MODERN_4
184+
|| (!IS_19_20_OR_GREATER && (type == MODERN_1 || type == MODERN_3))
180185
|| (!IS_19_26_OR_GREATER && type == MODERN_1
181186
&& !Settings.MINIPLAYER_DOUBLE_TAP_ACTION.get() && !Settings.MINIPLAYER_DRAG_AND_DROP.get())
182187
|| (IS_19_29_OR_GREATER && type == MODERN_3);
@@ -227,9 +232,13 @@ public static int getModernMiniplayerOverrideType(int original) {
227232
/**
228233
* Injection point.
229234
*/
230-
public static void adjustMiniplayerOpacity(ImageView view) {
235+
public static void adjustMiniplayerOpacity(View view) {
231236
if (CURRENT_TYPE == MODERN_1) {
232-
view.setImageAlpha(OPACITY_LEVEL);
237+
if (view instanceof ImageView imageView) {
238+
imageView.setImageAlpha(OPACITY_LEVEL);
239+
} else {
240+
Logger.printException(() -> "Unknown miniplayer overlay view: " + view);
241+
}
233242
}
234243
}
235244

@@ -247,7 +256,7 @@ public static boolean getModernFeatureFlagsActiveOverride(boolean original) {
247256
/**
248257
* Injection point.
249258
*/
250-
public static boolean enableMiniplayerDoubleTapAction(boolean original) {
259+
public static boolean getMiniplayerDoubleTapAction(boolean original) {
251260
if (CURRENT_TYPE == DEFAULT) {
252261
return original;
253262
}
@@ -258,44 +267,55 @@ public static boolean enableMiniplayerDoubleTapAction(boolean original) {
258267
/**
259268
* Injection point.
260269
*/
261-
public static boolean enableMiniplayerDragAndDrop(boolean original) {
270+
public static boolean getMiniplayerDragAndDrop(boolean original) {
262271
if (CURRENT_TYPE == DEFAULT) {
263272
return original;
264273
}
265274

266275
return DRAG_AND_DROP_ENABLED;
267276
}
268277

278+
/**
279+
* Injection point.
280+
*/
281+
public static boolean getRoundedCorners(boolean original) {
282+
if (CURRENT_TYPE == DEFAULT) {
283+
return original;
284+
}
285+
286+
return MINIPLAYER_ROUNDED_CORNERS_ENABLED;
287+
}
269288

270289
/**
271290
* Injection point.
272291
*/
273-
public static boolean setRoundedCorners(boolean original) {
274-
if (CURRENT_TYPE.isModern()) {
275-
return MINIPLAYER_ROUNDED_CORNERS_ENABLED;
292+
public static boolean getHorizontalDrag(boolean original) {
293+
if (CURRENT_TYPE == DEFAULT) {
294+
return original;
276295
}
277296

278-
return original;
297+
return MINIPLAYER_HORIZONTAL_DRAG_ENABLED;
279298
}
280299

281300
/**
282301
* Injection point.
283302
*/
284-
public static int setMiniplayerDefaultSize(int original) {
285-
if (CURRENT_TYPE.isModern()) {
286-
return MINIPLAYER_SIZE;
303+
public static boolean getMaximizeAnimation(boolean original) {
304+
// This must be forced on if horizontal drag is enabled,
305+
// otherwise the UI has visual glitches when maximizing the miniplayer.
306+
if (MINIPLAYER_HORIZONTAL_DRAG_ENABLED) {
307+
return true;
287308
}
288309

289310
return original;
290311
}
291312

292-
293313
/**
294314
* Injection point.
295315
*/
296-
public static boolean setHorizontalDrag(boolean original) {
316+
public static int getMiniplayerDefaultSize(int original) {
297317
if (CURRENT_TYPE.isModern()) {
298-
return MINIPLAYER_HORIZONTAL_DRAG_ENABLED;
318+
return MINIPLAYER_SIZE;
299319
}
300320

301321
return original;
@@ -304,14 +324,23 @@ public static boolean setHorizontalDrag(boolean original) {
304324
/**
305325
* Injection point.
306326
*/
307-
public static void hideMiniplayerExpandClose(ImageView view) {
308-
Utils.hideViewByRemovingFromParentUnderCondition(HIDE_EXPAND_CLOSE_ENABLED, view);
327+
public static void hideMiniplayerExpandClose(View view) {
328+
Utils.hideViewByRemovingFromParentUnderCondition(HIDE_OVERLAY_BUTTONS_ENABLED, view);
329+
}
330+
331+
/**
332+
* Injection point.
333+
*/
334+
public static void hideMiniplayerActionButton(View view) {
335+
if (CURRENT_TYPE == MODERN_4) {
336+
Utils.hideViewByRemovingFromParentUnderCondition(HIDE_OVERLAY_BUTTONS_ENABLED, view);
337+
}
309338
}
310339

311340
/**
312341
* Injection point.
313342
*/
314-
public static void hideMiniplayerRewindForward(ImageView view) {
343+
public static void hideMiniplayerRewindForward(View view) {
315344
Utils.hideViewByRemovingFromParentUnderCondition(HIDE_REWIND_FORWARD_ENABLED, view);
316345
}
317346

extensions/youtube/src/main/java/app/revanced/extension/youtube/patches/VersionCheckPatch.java

+11-7
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,15 @@
33
import app.revanced.extension.shared.Utils;
44

55
public class VersionCheckPatch {
6-
public static final boolean IS_19_17_OR_GREATER = Utils.getAppVersionName().compareTo("19.17.00") >= 0;
7-
public static final boolean IS_19_20_OR_GREATER = Utils.getAppVersionName().compareTo("19.20.00") >= 0;
8-
public static final boolean IS_19_21_OR_GREATER = Utils.getAppVersionName().compareTo("19.21.00") >= 0;
9-
public static final boolean IS_19_26_OR_GREATER = Utils.getAppVersionName().compareTo("19.26.00") >= 0;
10-
public static final boolean IS_19_29_OR_GREATER = Utils.getAppVersionName().compareTo("19.29.00") >= 0;
11-
public static final boolean IS_19_34_OR_GREATER = Utils.getAppVersionName().compareTo("19.34.00") >= 0;
12-
public static final boolean IS_19_46_OR_GREATER = Utils.getAppVersionName().compareTo("19.46.00") >= 0;
6+
private static boolean isVersionOrGreater(String version) {
7+
return Utils.getAppVersionName().compareTo(version) >= 0;
8+
}
9+
10+
public static final boolean IS_19_17_OR_GREATER = isVersionOrGreater("19.17.00");
11+
public static final boolean IS_19_20_OR_GREATER = isVersionOrGreater("19.20.00");
12+
public static final boolean IS_19_21_OR_GREATER = isVersionOrGreater("19.21.00");
13+
public static final boolean IS_19_26_OR_GREATER = isVersionOrGreater("19.26.00");
14+
public static final boolean IS_19_29_OR_GREATER = isVersionOrGreater("19.29.00");
15+
public static final boolean IS_19_34_OR_GREATER = isVersionOrGreater("19.34.00");
16+
public static final boolean IS_19_46_OR_GREATER = isVersionOrGreater("19.46.00");
1317
}

extensions/youtube/src/main/java/app/revanced/extension/youtube/returnyoutubedislike/ReturnYouTubeDislike.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ public enum Vote {
114114
private static final Rect middleSeparatorBounds;
115115

116116
/**
117-
* Left separator horizontal padding for Rolling Number layout.
117+
* Horizontal padding between the left and middle separator.
118118
*/
119119
public static final int leftSeparatorShapePaddingPixels;
120120
private static final ShapeDrawable leftSeparatorShape;
@@ -129,7 +129,7 @@ public enum Vote {
129129
(int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 3.7f, dp);
130130
middleSeparatorBounds = new Rect(0, 0, middleSeparatorSize, middleSeparatorSize);
131131

132-
leftSeparatorShapePaddingPixels = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 10.0f, dp);
132+
leftSeparatorShapePaddingPixels = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8.4f, dp);
133133

134134
leftSeparatorShape = new ShapeDrawable(new RectShape());
135135
leftSeparatorShape.setBounds(leftSeparatorBounds);
@@ -238,7 +238,7 @@ private static SpannableString createDislikeSpan(@NonNull Spanned oldSpannable,
238238
String leftSeparatorString = getTextDirectionString();
239239
final Spannable leftSeparatorSpan;
240240
if (isRollingNumber) {
241-
leftSeparatorSpan = new SpannableString(leftSeparatorString);
241+
leftSeparatorSpan = new SpannableString(leftSeparatorString);
242242
} else {
243243
leftSeparatorString += " ";
244244
leftSeparatorSpan = new SpannableString(leftSeparatorString);
@@ -623,7 +623,7 @@ public void setUserVote(@NonNull Vote vote) {
623623
userVote = vote;
624624
clearUICache();
625625
}
626-
626+
627627
if (future.isDone()) {
628628
// Update the fetched vote data.
629629
RYDVoteData voteData = getFetchData(MAX_MILLISECONDS_TO_BLOCK_UI_WAITING_FOR_FETCH);

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import static app.revanced.extension.youtube.patches.ChangeStartPagePatch.StartPage;
1111
import static app.revanced.extension.youtube.patches.ExitFullscreenPatch.FullscreenMode;
1212
import static app.revanced.extension.youtube.patches.ForceOriginalAudioPatch.ForceOriginalAudioAvailability;
13-
import static app.revanced.extension.youtube.patches.MiniplayerPatch.MiniplayerHideExpandCloseAvailability;
1413
import static app.revanced.extension.youtube.patches.MiniplayerPatch.MiniplayerHorizontalDragAvailability;
1514
import static app.revanced.extension.youtube.patches.MiniplayerPatch.MiniplayerType;
1615
import static app.revanced.extension.youtube.patches.MiniplayerPatch.MiniplayerType.MINIMAL;
@@ -40,6 +39,7 @@
4039
import app.revanced.extension.youtube.patches.AlternativeThumbnailsPatch.StillImagesAvailability;
4140
import app.revanced.extension.youtube.patches.AlternativeThumbnailsPatch.ThumbnailOption;
4241
import app.revanced.extension.youtube.patches.AlternativeThumbnailsPatch.ThumbnailStillTime;
42+
import app.revanced.extension.youtube.patches.MiniplayerPatch;
4343
import app.revanced.extension.youtube.sponsorblock.SponsorBlockSettings;
4444

4545
public class Settings extends BaseSettings {
@@ -156,7 +156,7 @@ public class Settings extends BaseSettings {
156156
public static final BooleanSetting MINIPLAYER_DOUBLE_TAP_ACTION = new BooleanSetting("revanced_miniplayer_double_tap_action", TRUE, true, MINIPLAYER_ANY_MODERN);
157157
public static final BooleanSetting MINIPLAYER_DRAG_AND_DROP = new BooleanSetting("revanced_miniplayer_drag_and_drop", TRUE, true, MINIPLAYER_ANY_MODERN);
158158
public static final BooleanSetting MINIPLAYER_HORIZONTAL_DRAG = new BooleanSetting("revanced_miniplayer_horizontal_drag", FALSE, true, new MiniplayerHorizontalDragAvailability());
159-
public static final BooleanSetting MINIPLAYER_HIDE_EXPAND_CLOSE = new BooleanSetting("revanced_miniplayer_hide_expand_close", FALSE, true, new MiniplayerHideExpandCloseAvailability());
159+
public static final BooleanSetting MINIPLAYER_HIDE_OVERLAY_BUTTONS = new BooleanSetting("revanced_miniplayer_hide_overlay_buttons", FALSE, true, new MiniplayerPatch.MiniplayerHideOverlayButtonsAvailability());
160160
public static final BooleanSetting MINIPLAYER_HIDE_SUBTEXT = new BooleanSetting("revanced_miniplayer_hide_subtext", FALSE, true, MINIPLAYER_TYPE.availability(MODERN_1, MODERN_3));
161161
public static final BooleanSetting MINIPLAYER_HIDE_REWIND_FORWARD = new BooleanSetting("revanced_miniplayer_hide_rewind_forward", TRUE, true, MINIPLAYER_TYPE.availability(MODERN_1));
162162
public static final BooleanSetting MINIPLAYER_ROUNDED_CORNERS = new BooleanSetting("revanced_miniplayer_rounded_corners", TRUE, true, MINIPLAYER_ANY_MODERN);

patches/api/patches.api

+8-12
Original file line numberDiff line numberDiff line change
@@ -776,8 +776,8 @@ public final class app/revanced/patches/shared/misc/settings/preference/TextPref
776776
}
777777

778778
public final class app/revanced/patches/shared/misc/spoof/SpoofVideoStreamsPatchKt {
779-
public static final fun spoofVideoStreamsPatch (Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;)Lapp/revanced/patcher/patch/BytecodePatch;
780-
public static synthetic fun spoofVideoStreamsPatch$default (Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lapp/revanced/patcher/patch/BytecodePatch;
779+
public static final fun spoofVideoStreamsPatch (Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;)Lapp/revanced/patcher/patch/BytecodePatch;
780+
public static synthetic fun spoofVideoStreamsPatch$default (Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lapp/revanced/patcher/patch/BytecodePatch;
781781
}
782782

783783
public final class app/revanced/patches/shared/misc/spoof/UserAgentClientSpoofPatchKt {
@@ -1185,17 +1185,7 @@ public final class app/revanced/patches/youtube/layout/hide/time/HideTimestampPa
11851185
}
11861186

11871187
public final class app/revanced/patches/youtube/layout/miniplayer/MiniplayerPatchKt {
1188-
public static final fun getFloatyBarButtonTopMargin ()J
1189-
public static final fun getMiniplayerMaxSize ()J
11901188
public static final fun getMiniplayerPatch ()Lapp/revanced/patcher/patch/BytecodePatch;
1191-
public static final fun getModernMiniplayerClose ()J
1192-
public static final fun getModernMiniplayerExpand ()J
1193-
public static final fun getModernMiniplayerForwardButton ()J
1194-
public static final fun getModernMiniplayerRewindButton ()J
1195-
public static final fun getPlayerOverlays ()J
1196-
public static final fun getScrimOverlay ()J
1197-
public static final fun getYtOutlinePictureInPictureWhite24 ()J
1198-
public static final fun getYtOutlineXWhite24 ()J
11991189
}
12001190

12011191
public final class app/revanced/patches/youtube/layout/panels/popup/PlayerPopupPanelsPatchKt {
@@ -1390,6 +1380,12 @@ public final class app/revanced/patches/youtube/misc/playservice/VersionCheckPat
13901380
public static final fun is_19_46_or_greater ()Z
13911381
public static final fun is_19_47_or_greater ()Z
13921382
public static final fun is_19_49_or_greater ()Z
1383+
public static final fun is_20_02_or_greater ()Z
1384+
public static final fun is_20_03_or_greater ()Z
1385+
public static final fun is_20_05_or_greater ()Z
1386+
public static final fun is_20_07_or_greater ()Z
1387+
public static final fun is_20_09_or_greater ()Z
1388+
public static final fun is_20_10_or_greater ()Z
13931389
}
13941390

13951391
public final class app/revanced/patches/youtube/misc/privacy/RemoveTrackingQueryParameterPatchKt {

patches/src/main/kotlin/app/revanced/patches/shared/misc/spoof/Fingerprints.kt

+21-3
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,25 @@ internal val patchIncludedExtensionMethodFingerprint = fingerprint {
145145
internal const val MEDIA_FETCH_HOT_CONFIG_FEATURE_FLAG = 45645570L
146146

147147
internal val mediaFetchHotConfigFingerprint = fingerprint {
148-
literal {
149-
MEDIA_FETCH_HOT_CONFIG_FEATURE_FLAG
150-
}
148+
literal { MEDIA_FETCH_HOT_CONFIG_FEATURE_FLAG }
149+
}
150+
151+
// 20.10+
152+
internal const val MEDIA_FETCH_HOT_CONFIG_ALTERNATIVE_FEATURE_FLAG = 45683169L
153+
154+
internal val mediaFetchHotConfigAlternativeFingerprint = fingerprint {
155+
literal { MEDIA_FETCH_HOT_CONFIG_ALTERNATIVE_FEATURE_FLAG }
156+
}
157+
158+
// Feature flag that enables different code for parsing and starting video playback,
159+
// but it's exact purpose is not known. If this flag is enabled while stream spoofing
160+
// then videos will never start playback and load forever.
161+
// Flag does not seem to affect playback if spoofing is off.
162+
internal const val PLAYBACK_START_CHECK_ENDPOINT_USED_FEATURE_FLAG = 45665455L
163+
164+
internal val playbackStartDescriptorFeatureFlagFingerprint = fingerprint {
165+
accessFlags(AccessFlags.PUBLIC, AccessFlags.FINAL)
166+
parameters()
167+
returns("Z")
168+
literal { PLAYBACK_START_CHECK_ENDPOINT_USED_FEATURE_FLAG }
151169
}

0 commit comments

Comments
 (0)