feat(YouTube - Seekbar components): If the Custom braning icon patch is included and the patch option Restore old splash animation is enabled, it will not change the Seekbar color from the original splash animation (Lottie animation)

This commit is contained in:
inotia00 2024-12-31 21:47:07 +09:00
parent 721f6043e9
commit f6a5ffd3ba
2 changed files with 28 additions and 16 deletions

View File

@ -11,12 +11,14 @@ import app.revanced.patcher.util.smali.ExternalLabel
import app.revanced.patches.shared.drawable.addDrawableColorHook
import app.revanced.patches.shared.drawable.drawableColorHookPatch
import app.revanced.patches.shared.mainactivity.onCreateMethod
import app.revanced.patches.youtube.layout.branding.icon.customBrandingIconPatch
import app.revanced.patches.youtube.utils.compatibility.Constants.COMPATIBLE_PACKAGE
import app.revanced.patches.youtube.utils.extension.Constants.PATCH_STATUS_CLASS_DESCRIPTOR
import app.revanced.patches.youtube.utils.extension.Constants.PLAYER_CLASS_DESCRIPTOR
import app.revanced.patches.youtube.utils.extension.Constants.PLAYER_PATH
import app.revanced.patches.youtube.utils.flyoutmenu.flyoutMenuHookPatch
import app.revanced.patches.youtube.utils.mainactivity.mainActivityResolvePatch
import app.revanced.patches.youtube.utils.patch.PatchList.CUSTOM_BRANDING_ICON_FOR_YOUTUBE
import app.revanced.patches.youtube.utils.patch.PatchList.SEEKBAR_COMPONENTS
import app.revanced.patches.youtube.utils.playerButtonsResourcesFingerprint
import app.revanced.patches.youtube.utils.playerButtonsVisibilityFingerprint
@ -43,6 +45,7 @@ import app.revanced.util.fingerprint.injectLiteralInstructionBooleanCall
import app.revanced.util.fingerprint.matchOrThrow
import app.revanced.util.fingerprint.methodOrThrow
import app.revanced.util.fingerprint.resolvable
import app.revanced.util.getBooleanOptionValue
import app.revanced.util.getReference
import app.revanced.util.getWalkerMethod
import app.revanced.util.indexOfFirstInstructionOrThrow
@ -116,6 +119,9 @@ val seekbarComponentsPatch = bytecodePatch(
execute {
val restoreOldSplashAnimationIncluded = CUSTOM_BRANDING_ICON_FOR_YOUTUBE.included == true &&
customBrandingIconPatch.getBooleanOptionValue("restoreOldSplashAnimationOption").value == true
var settingArray = arrayOf(
"PREFERENCE_SCREEN: PLAYER",
"SETTINGS: SEEKBAR_COMPONENTS"
@ -257,25 +263,27 @@ val seekbarComponentsPatch = bytecodePatch(
"invoke-static/range { p4 .. p5 }, $EXTENSION_SEEKBAR_COLOR_CLASS_DESCRIPTOR->setLinearGradient([I[F)V"
)
// Don't use the lotte splash screen layout if using custom seekbar.
arrayOf(
launchScreenLayoutTypeFingerprint.methodOrThrow(),
onCreateMethod
).forEach { method ->
method.apply {
val literalIndex =
indexOfFirstLiteralInstructionOrThrow(launchScreenLayoutTypeLotteFeatureFlag)
val resultIndex =
indexOfFirstInstructionOrThrow(literalIndex, Opcode.MOVE_RESULT)
val register = getInstruction<OneRegisterInstruction>(resultIndex).registerA
if (!restoreOldSplashAnimationIncluded) {
// Don't use the lotte splash screen layout if using custom seekbar.
arrayOf(
launchScreenLayoutTypeFingerprint.methodOrThrow(),
onCreateMethod
).forEach { method ->
method.apply {
val literalIndex =
indexOfFirstLiteralInstructionOrThrow(launchScreenLayoutTypeLotteFeatureFlag)
val resultIndex =
indexOfFirstInstructionOrThrow(literalIndex, Opcode.MOVE_RESULT)
val register = getInstruction<OneRegisterInstruction>(resultIndex).registerA
addInstructions(
resultIndex + 1,
"""
addInstructions(
resultIndex + 1,
"""
invoke-static { v$register }, $EXTENSION_SEEKBAR_COLOR_CLASS_DESCRIPTOR->useLotteLaunchSplashScreen(Z)Z
move-result v$register
"""
)
)
}
}
}
@ -317,7 +325,7 @@ val seekbarComponentsPatch = bytecodePatch(
scaleNode.replaceChild(replacementNode, shapeNode)
}
if (is_19_25_or_greater) {
if (is_19_25_or_greater && !restoreOldSplashAnimationIncluded) {
// Add attribute and styles for splash screen custom color.
// Using a style is the only way to selectively change just the seekbar fill color.
//

View File

@ -20,6 +20,10 @@ private val classLoader = object {}.javaClass.classLoader
fun Patch<*>.getStringOptionValue(key: String) =
options[key] as Option<String>
@Suppress("UNCHECKED_CAST")
fun Patch<*>.getBooleanOptionValue(key: String) =
options[key] as Option<Boolean>
fun Option<String>.valueOrThrow() = value
?: throw PatchException("Invalid patch option: $title.")