fix(YouTube - Theme): Replace custom seekbar gradient colors instead of disabling (#4329)
This commit is contained in:

committed by
GitHub

parent
b4cc1493b2
commit
f03da98305
@ -34,21 +34,42 @@ internal val shortsSeekbarColorFingerprint = fingerprint {
|
||||
literal { reelTimeBarPlayedColorId }
|
||||
}
|
||||
|
||||
internal const val PLAYER_SEEKBAR_GRADIENT_FEATURE_FLAG = 45617850L
|
||||
|
||||
internal val playerSeekbarGradientConfigFingerprint = fingerprint {
|
||||
accessFlags(AccessFlags.PUBLIC, AccessFlags.FINAL)
|
||||
returns("Z")
|
||||
parameters()
|
||||
literal { PLAYER_SEEKBAR_GRADIENT_FEATURE_FLAG }
|
||||
}
|
||||
|
||||
internal val lithoLinearGradientFingerprint = fingerprint {
|
||||
accessFlags(AccessFlags.STATIC)
|
||||
returns("Landroid/graphics/LinearGradient;")
|
||||
parameters("F", "F", "F", "F", "[I", "[F")
|
||||
}
|
||||
|
||||
/**
|
||||
* 29.25 - 19.50
|
||||
*/
|
||||
internal val playerLinearGradientLegacyFingerprint = fingerprint {
|
||||
accessFlags(AccessFlags.PUBLIC, AccessFlags.FINAL)
|
||||
parameters("I", "I", "I", "I")
|
||||
returns("V")
|
||||
opcodes(
|
||||
Opcode.FILLED_NEW_ARRAY,
|
||||
Opcode.MOVE_RESULT_OBJECT
|
||||
)
|
||||
custom { method, _ ->
|
||||
method.name == "setBounds" && method.containsLiteralInstruction(ytYoutubeMagentaColorId)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 20.03+
|
||||
*/
|
||||
internal val playerLinearGradientFingerprint = fingerprint {
|
||||
accessFlags(AccessFlags.PUBLIC, AccessFlags.STATIC)
|
||||
parameters("I", "I", "I", "I", "Landroid/content/Context;", "I")
|
||||
returns("Landroid/graphics/LinearGradient;")
|
||||
opcodes(
|
||||
Opcode.FILLED_NEW_ARRAY,
|
||||
Opcode.MOVE_RESULT_OBJECT
|
||||
)
|
||||
literal { ytYoutubeMagentaColorId }
|
||||
}
|
||||
|
||||
internal const val launchScreenLayoutTypeLotteFeatureFlag = 268507948L
|
||||
|
||||
internal val launchScreenLayoutTypeFingerprint = fingerprint {
|
||||
|
@ -39,6 +39,8 @@ internal var inlineTimeBarColorizedBarPlayedColorDarkId = -1L
|
||||
private set
|
||||
internal var inlineTimeBarPlayedNotHighlightedColorId = -1L
|
||||
private set
|
||||
internal var ytYoutubeMagentaColorId = -1L
|
||||
private set
|
||||
|
||||
internal const val splashSeekbarColorAttributeName = "splash_custom_seekbar_color"
|
||||
|
||||
@ -62,6 +64,10 @@ private val seekbarColorResourcePatch = resourcePatch {
|
||||
"color",
|
||||
"inline_time_bar_played_not_highlighted_color",
|
||||
]
|
||||
ytYoutubeMagentaColorId = resourceMappings[
|
||||
"color",
|
||||
"yt_youtube_magenta",
|
||||
]
|
||||
|
||||
// Modify the resume playback drawable and replace the progress bar with a custom drawable.
|
||||
document("res/drawable/resume_playback_progressbar_drawable.xml").use { document ->
|
||||
@ -229,16 +235,26 @@ val seekbarColorPatch = bytecodePatch(
|
||||
|
||||
// 19.25+ changes
|
||||
|
||||
playerSeekbarGradientConfigFingerprint.method.insertFeatureFlagBooleanOverride(
|
||||
PLAYER_SEEKBAR_GRADIENT_FEATURE_FLAG,
|
||||
"$EXTENSION_CLASS_DESCRIPTOR->playerSeekbarGradientEnabled(Z)Z"
|
||||
)
|
||||
|
||||
lithoLinearGradientFingerprint.method.addInstruction(
|
||||
0,
|
||||
"invoke-static/range { p4 .. p5 }, $EXTENSION_CLASS_DESCRIPTOR->setLinearGradient([I[F)V"
|
||||
)
|
||||
|
||||
// TODO: add 20.03 support
|
||||
playerLinearGradientLegacyFingerprint.let {
|
||||
it.method.apply {
|
||||
val index = it.patternMatch!!.endIndex
|
||||
val register = getInstruction<OneRegisterInstruction>(index).registerA
|
||||
|
||||
addInstructions(
|
||||
index + 1,
|
||||
"""
|
||||
invoke-static { v$register }, $EXTENSION_CLASS_DESCRIPTOR->getLinearGradient([I)[I
|
||||
move-result-object v$register
|
||||
"""
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// region apply seekbar custom color to splash screen animation.
|
||||
|
||||
|
Reference in New Issue
Block a user