feat(music/amoled): patch now applies the amoled theme to the comment input box as well

This commit is contained in:
inotia00
2023-09-05 11:04:57 +09:00
parent 6abfa670ac
commit f0dfbd27ee
5 changed files with 13 additions and 9 deletions

View File

@ -3,7 +3,7 @@ package app.revanced.patches.youtube.layout.theme.patch
import app.revanced.patcher.data.ResourceContext
import app.revanced.patcher.patch.ResourcePatch
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patches.youtube.utils.litho.patch.LithoThemePatch
import app.revanced.patches.shared.patch.litho.LithoThemePatch
import app.revanced.util.integrations.Constants.UTILS_PATH
import org.w3c.dom.Element

View File

@ -11,11 +11,11 @@ import app.revanced.patcher.patch.PatchException
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
import app.revanced.patches.shared.patch.litho.LithoThemePatch
import app.revanced.patches.youtube.seekbar.seekbarcolor.fingerprints.ControlsOverlayStyleFingerprint
import app.revanced.patches.youtube.seekbar.seekbarcolor.fingerprints.PlayerSeekbarColorFingerprint
import app.revanced.patches.youtube.seekbar.seekbarcolor.fingerprints.ShortsSeekbarColorFingerprint
import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility
import app.revanced.patches.youtube.utils.litho.patch.LithoThemePatch
import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch
import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch.Companion.InlineTimeBarColorizedBarPlayedColorDark
import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch.Companion.InlineTimeBarPlayedNotHighlightedColor

View File

@ -1,19 +0,0 @@
package app.revanced.patches.youtube.utils.litho.fingerprints
import app.revanced.patcher.extensions.or
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import com.android.tools.smali.dexlib2.AccessFlags
import com.android.tools.smali.dexlib2.Opcode
object LithoThemeFingerprint : MethodFingerprint(
returnType = "V",
accessFlags = AccessFlags.PROTECTED or AccessFlags.FINAL,
parameters = listOf("L"),
opcodes = listOf(
Opcode.IF_NEZ,
Opcode.IGET_OBJECT,
Opcode.INVOKE_VIRTUAL, // Paint.setColor: inject point
Opcode.RETURN_VOID
),
customFingerprint = { methodDef, _ -> methodDef.name == "onBoundsChange" }
)

View File

@ -1,56 +0,0 @@
package app.revanced.patches.youtube.utils.litho.patch
import app.revanced.extensions.exception
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
import app.revanced.patches.youtube.utils.litho.fingerprints.LithoThemeFingerprint
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
import com.android.tools.smali.dexlib2.iface.instruction.formats.Instruction35c
import com.android.tools.smali.dexlib2.iface.reference.MethodReference
class LithoThemePatch : BytecodePatch(
listOf(
LithoThemeFingerprint
)
) {
override fun execute(context: BytecodeContext) {
LithoThemeFingerprint.result?.mutableMethod?.let {
with(it.implementation!!.instructions) {
for (index in size - 1 downTo 0) {
val invokeInstruction = this[index] as? ReferenceInstruction ?: continue
if ((invokeInstruction.reference as MethodReference).name != "setColor") continue
insertIndex = index
insertRegister = (this[index] as Instruction35c).registerD
insertMethod = it
break
}
}
} ?: throw LithoThemeFingerprint.exception
}
companion object {
private var offset = 0
private var insertIndex: Int = 0
private var insertRegister: Int = 0
private lateinit var insertMethod: MutableMethod
fun injectCall(
methodDescriptor: String
) {
insertMethod.addInstructions(
insertIndex + offset, """
invoke-static {v$insertRegister}, $methodDescriptor
move-result v$insertRegister
"""
)
offset += 2
}
}
}