mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-06-13 05:37:40 +02:00
fix(YouTube - Snack bar components): Invert snack bar theme
setting does not work in YouTube 18.29.38
This commit is contained in:
@ -29,6 +29,7 @@ import app.revanced.util.fingerprint.methodOrThrow
|
|||||||
import app.revanced.util.getNode
|
import app.revanced.util.getNode
|
||||||
import app.revanced.util.getReference
|
import app.revanced.util.getReference
|
||||||
import app.revanced.util.indexOfFirstInstructionOrThrow
|
import app.revanced.util.indexOfFirstInstructionOrThrow
|
||||||
|
import app.revanced.util.indexOfFirstInstructionReversedOrThrow
|
||||||
import app.revanced.util.valueOrThrow
|
import app.revanced.util.valueOrThrow
|
||||||
import com.android.tools.smali.dexlib2.Opcode
|
import com.android.tools.smali.dexlib2.Opcode
|
||||||
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
|
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
|
||||||
@ -78,22 +79,31 @@ private val snackBarComponentsBytecodePatch = bytecodePatch(
|
|||||||
|
|
||||||
bottomUiContainerThemeFingerprint.matchOrThrow().let {
|
bottomUiContainerThemeFingerprint.matchOrThrow().let {
|
||||||
it.method.apply {
|
it.method.apply {
|
||||||
val startIndex = it.patternMatch!!.startIndex
|
val darkThemeIndex = it.patternMatch!!.startIndex + 2
|
||||||
val appThemeIndex = startIndex + 1
|
val darkThemeReference = getInstruction<ReferenceInstruction>(darkThemeIndex).reference.toString()
|
||||||
val darkThemeIndex = startIndex + 2
|
|
||||||
val insertIndex = startIndex + 3
|
|
||||||
|
|
||||||
val appThemeRegister =
|
implementation!!.instructions
|
||||||
getInstruction<OneRegisterInstruction>(appThemeIndex).registerA
|
.withIndex()
|
||||||
val darkThemeRegister =
|
.filter { (_, instruction) ->
|
||||||
getInstruction<OneRegisterInstruction>(darkThemeIndex).registerA
|
instruction.opcode == Opcode.SGET_OBJECT &&
|
||||||
|
(instruction as? ReferenceInstruction)?.reference?.toString() == darkThemeReference
|
||||||
|
}
|
||||||
|
.map { (index, _) -> index }
|
||||||
|
.reversed()
|
||||||
|
.forEach { index ->
|
||||||
|
val appThemeIndex = indexOfFirstInstructionReversedOrThrow(index, Opcode.MOVE_RESULT_OBJECT)
|
||||||
|
val appThemeRegister =
|
||||||
|
getInstruction<OneRegisterInstruction>(appThemeIndex).registerA
|
||||||
|
val darkThemeRegister =
|
||||||
|
getInstruction<OneRegisterInstruction>(index).registerA
|
||||||
|
|
||||||
addInstructions(
|
addInstructions(
|
||||||
insertIndex, """
|
index + 1, """
|
||||||
invoke-static {v$appThemeRegister, v$darkThemeRegister}, $EXTENSION_CLASS_DESCRIPTOR->invertSnackBarTheme(Ljava/lang/Enum;Ljava/lang/Enum;)Ljava/lang/Enum;
|
invoke-static {v$appThemeRegister, v$darkThemeRegister}, $EXTENSION_CLASS_DESCRIPTOR->invertSnackBarTheme(Ljava/lang/Enum;Ljava/lang/Enum;)Ljava/lang/Enum;
|
||||||
move-result-object v$appThemeRegister
|
move-result-object v$appThemeRegister
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user