mirror of
https://github.com/revanced/revanced-patches.git
synced 2025-04-29 22:24:27 +02:00
fix(YouTube - Seekbar): Correctly hide the feed seekbar with target 20.07
This commit is contained in:
parent
9f0efab3a1
commit
ddc6e4c34f
@ -226,6 +226,7 @@ public final class SeekbarColorPatch {
|
||||
}
|
||||
|
||||
private static String loadRawResourceAsString(int resourceId) {
|
||||
//noinspection CharsetObjectCanBeUsed
|
||||
try (InputStream inputStream = Utils.getContext().getResources().openRawResource(resourceId);
|
||||
Scanner scanner = new Scanner(inputStream, StandardCharsets.UTF_8.name()).useDelimiter("\\A")) {
|
||||
return scanner.next();
|
||||
@ -281,6 +282,20 @@ public final class SeekbarColorPatch {
|
||||
|
||||
/**
|
||||
* Injection point.
|
||||
* 19.49+
|
||||
*/
|
||||
public static int[] getPlayerLinearGradient(int[] original, int x0, int y1) {
|
||||
// This hook is used for both the player and the feed.
|
||||
// Feed usage always has x0 and y1 value of zero, and the player is always non zero.
|
||||
if (HIDE_SEEKBAR_THUMBNAIL_ENABLED && x0 == 0 && y1 == 0) {
|
||||
return HIDDEN_SEEKBAR_GRADIENT_COLORS;
|
||||
}
|
||||
return getPlayerLinearGradient(original);
|
||||
}
|
||||
|
||||
/**
|
||||
* Injection point.
|
||||
* Pre 19.49
|
||||
*/
|
||||
public static int[] getPlayerLinearGradient(int[] original) {
|
||||
return SEEKBAR_CUSTOM_COLOR_ENABLED
|
||||
|
@ -84,31 +84,14 @@ internal val playerLinearGradientFingerprint = fingerprint {
|
||||
}
|
||||
|
||||
/**
|
||||
* 19.46 - 19.47
|
||||
* 19.25 - 19.47
|
||||
*/
|
||||
internal val playerLinearGradientLegacy1946Fingerprint = fingerprint {
|
||||
accessFlags(AccessFlags.PUBLIC, AccessFlags.FINAL)
|
||||
parameters("I", "I", "I", "I")
|
||||
internal val playerLinearGradientLegacyFingerprint = fingerprint {
|
||||
returns("V")
|
||||
opcodes(
|
||||
Opcode.FILLED_NEW_ARRAY,
|
||||
Opcode.MOVE_RESULT_OBJECT
|
||||
)
|
||||
custom { method, _ ->
|
||||
method.name == "setBounds" && method.containsLiteralInstruction(ytYoutubeMagentaColorId)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 19.25 - 19.45
|
||||
*/
|
||||
internal val playerLinearGradientLegacy1925Fingerprint = fingerprint {
|
||||
accessFlags(AccessFlags.PUBLIC, AccessFlags.CONSTRUCTOR)
|
||||
parameters("Landroid/content/Context;")
|
||||
opcodes(
|
||||
Opcode.FILLED_NEW_ARRAY,
|
||||
Opcode.MOVE_RESULT_OBJECT
|
||||
)
|
||||
literal { ytYoutubeMagentaColorId }
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
package app.revanced.patches.youtube.layout.seekbar
|
||||
|
||||
import app.revanced.patcher.Fingerprint
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
||||
@ -310,14 +311,15 @@ val seekbarColorPatch = bytecodePatch(
|
||||
"""
|
||||
)
|
||||
|
||||
val playerFingerprint =
|
||||
if (is_19_49_or_greater) {
|
||||
playerLinearGradientFingerprint
|
||||
} else if (is_19_46_or_greater) {
|
||||
playerLinearGradientLegacy1946Fingerprint
|
||||
} else {
|
||||
playerLinearGradientLegacy1925Fingerprint
|
||||
}
|
||||
val playerFingerprint: Fingerprint
|
||||
val checkGradientCoordinates: Boolean
|
||||
if (is_19_49_or_greater) {
|
||||
playerFingerprint = playerLinearGradientFingerprint
|
||||
checkGradientCoordinates = true
|
||||
} else {
|
||||
playerFingerprint = playerLinearGradientLegacyFingerprint
|
||||
checkGradientCoordinates = false
|
||||
}
|
||||
|
||||
playerFingerprint.let {
|
||||
it.method.apply {
|
||||
@ -326,10 +328,17 @@ val seekbarColorPatch = bytecodePatch(
|
||||
|
||||
addInstructions(
|
||||
index + 1,
|
||||
"""
|
||||
invoke-static { v$register }, $EXTENSION_CLASS_DESCRIPTOR->getPlayerLinearGradient([I)[I
|
||||
move-result-object v$register
|
||||
"""
|
||||
if (checkGradientCoordinates) {
|
||||
"""
|
||||
invoke-static { v$register, p0, p1 }, $EXTENSION_CLASS_DESCRIPTOR->getPlayerLinearGradient([III)[I
|
||||
move-result-object v$register
|
||||
"""
|
||||
} else {
|
||||
"""
|
||||
invoke-static { v$register }, $EXTENSION_CLASS_DESCRIPTOR->getPlayerLinearGradient([I)[I
|
||||
move-result-object v$register
|
||||
"""
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user