chore(YouTube - Seekbar components): Match with ReVanced

This commit is contained in:
inotia00
2025-01-22 13:23:07 +09:00
parent 5dd79073f1
commit f1d04b5323
5 changed files with 113 additions and 16 deletions

View File

@ -1,6 +1,7 @@
package app.revanced.patches.youtube.player.seekbar
import app.revanced.patches.youtube.utils.resourceid.reelTimeBarPlayedColor
import app.revanced.patches.youtube.utils.resourceid.ytYoutubeMagenta
import app.revanced.util.containsLiteralInstruction
import app.revanced.util.fingerprint.legacyFingerprint
import app.revanced.util.or
@ -22,6 +23,35 @@ internal val lithoLinearGradientFingerprint = legacyFingerprint(
returnType = "Landroid/graphics/LinearGradient;",
parameters = listOf("F", "F", "F", "F", "[I", "[F")
)
/**
* YouTube 19.25 - 19.47
*/
internal val playerLinearGradientLegacyFingerprint = legacyFingerprint(
name = "playerLinearGradientLegacyFingerprint",
returnType = "V",
opcodes = listOf(
Opcode.FILLED_NEW_ARRAY,
Opcode.MOVE_RESULT_OBJECT
),
literals = listOf(ytYoutubeMagenta),
)
/**
* YouTube 19.49+
*/
internal val playerLinearGradientFingerprint = legacyFingerprint(
name = "playerLinearGradientFingerprint",
returnType = "Landroid/graphics/LinearGradient;",
accessFlags = AccessFlags.PUBLIC or AccessFlags.STATIC,
parameters = listOf("I", "I", "I", "I", "Landroid/content/Context;", "I"),
opcodes = listOf(
Opcode.FILLED_NEW_ARRAY,
Opcode.MOVE_RESULT_OBJECT
),
literals = listOf(ytYoutubeMagenta),
)
internal const val launchScreenLayoutTypeLotteFeatureFlag = 268507948L
internal val launchScreenLayoutTypeFingerprint = legacyFingerprint(

View File

@ -25,6 +25,7 @@ import app.revanced.patches.youtube.utils.playerButtonsVisibilityFingerprint
import app.revanced.patches.youtube.utils.playerSeekbarColorFingerprint
import app.revanced.patches.youtube.utils.playservice.is_19_25_or_greater
import app.revanced.patches.youtube.utils.playservice.is_19_46_or_greater
import app.revanced.patches.youtube.utils.playservice.is_19_49_or_greater
import app.revanced.patches.youtube.utils.playservice.versionCheckPatch
import app.revanced.patches.youtube.utils.resourceid.inlineTimeBarColorizedBarPlayedColorDark
import app.revanced.patches.youtube.utils.resourceid.inlineTimeBarPlayedNotHighlightedColor
@ -253,16 +254,35 @@ val seekbarComponentsPatch = bytecodePatch(
addDrawableColorHook("$EXTENSION_SEEKBAR_COLOR_CLASS_DESCRIPTOR->getLithoColor(I)I")
if (is_19_25_or_greater) {
playerSeekbarGradientConfigFingerprint.injectLiteralInstructionBooleanCall(
PLAYER_SEEKBAR_GRADIENT_FEATURE_FLAG,
"$EXTENSION_SEEKBAR_COLOR_CLASS_DESCRIPTOR->playerSeekbarGradientEnabled(Z)Z"
)
lithoLinearGradientFingerprint.methodOrThrow().addInstruction(
0,
"invoke-static/range { p4 .. p5 }, $EXTENSION_SEEKBAR_COLOR_CLASS_DESCRIPTOR->setLinearGradient([I[F)V"
)
if (!is_19_49_or_greater) {
playerLinearGradientLegacyFingerprint.matchOrThrow().let {
it.method.apply {
val index = it.patternMatch!!.endIndex
val register = getInstruction<OneRegisterInstruction>(index).registerA
addInstructions(
index + 1,
"""
invoke-static { v$register }, $EXTENSION_SEEKBAR_COLOR_CLASS_DESCRIPTOR->getLinearGradient([I)[I
move-result-object v$register
"""
)
}
}
} else {
// TODO: add 19.49 support
playerSeekbarGradientConfigFingerprint.injectLiteralInstructionBooleanCall(
PLAYER_SEEKBAR_GRADIENT_FEATURE_FLAG,
"$EXTENSION_SEEKBAR_COLOR_CLASS_DESCRIPTOR->playerSeekbarGradientEnabled(Z)Z"
)
}
if (!restoreOldSplashAnimationIncluded) {
// Don't use the lotte splash screen layout if using custom seekbar.
arrayOf(

View File

@ -51,6 +51,8 @@ var is_19_44_or_greater = false
private set
var is_19_46_or_greater = false
private set
var is_19_49_or_greater = false
private set
var is_20_02_or_greater = false
private set
@ -91,6 +93,7 @@ val versionCheckPatch = resourcePatch(
is_19_43_or_greater = 244405000 <= playStoreServicesVersion
is_19_44_or_greater = 244505000 <= playStoreServicesVersion
is_19_46_or_greater = 244705000 <= playStoreServicesVersion
is_19_49_or_greater = 245005000 <= playStoreServicesVersion
is_20_02_or_greater = 250299000 <= playStoreServicesVersion
}
}

View File

@ -243,7 +243,8 @@ var ytPremiumWordMarkHeader = -1L
private set
var ytWordMarkHeader = -1L
private set
var ytYoutubeMagenta = -1L
private set
internal val sharedResourceIdPatch = resourcePatch(
description = "sharedResourceIdPatch"
@ -707,5 +708,9 @@ internal val sharedResourceIdPatch = resourcePatch(
ATTR,
"ytWordmarkHeader"
]
ytYoutubeMagenta = resourceMappings[
COLOR,
"yt_youtube_magenta",
]
}
}