add custom-seekbar-color patch

This commit is contained in:
inotia00
2023-01-08 03:11:02 +09:00
parent a9cc2326f2
commit c02b923404
4 changed files with 25 additions and 21 deletions

View File

@ -1,4 +1,4 @@
package app.revanced.patches.youtube.layout.seekbar.oldseekbarcolor.bytecode.patch
package app.revanced.patches.youtube.layout.seekbar.customseekbarcolor.bytecode.patch
import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
@ -13,13 +13,14 @@ import app.revanced.shared.extensions.toResult
import app.revanced.shared.patches.mapping.ResourceMappingPatch
import app.revanced.shared.util.integrations.Constants.SEEKBAR_LAYOUT
import org.jf.dexlib2.Opcode
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
import org.jf.dexlib2.iface.instruction.formats.Instruction31i
@DependsOn([ResourceMappingPatch::class])
@Name("old-seekbar-color-bytecode-patch")
@Name("custom-seekbar-color-bytecode-patch")
@YouTubeCompatibility
@Version("0.0.1")
class OldSeekbarColorBytecodePatch : BytecodePatch() {
class CustomSeekbarColorBytecodePatch : BytecodePatch() {
// list of resource names to get the id of
private val resourceIds = arrayOf(
@ -38,15 +39,15 @@ class OldSeekbarColorBytecodePatch : BytecodePatch() {
Opcode.CONST -> {
when ((instruction as Instruction31i).wideLiteral) {
resourceIds[0] -> { // seekbar color
val insertIndex = index + 1
val registerIndex = index + 2
val mutableMethod = context.proxy(classDef).mutableClass.findMutableMethodOf(method)
val viewRegister = (instructions.elementAt(index) as Instruction31i).registerA
val viewRegister = (instructions.elementAt(registerIndex) as OneRegisterInstruction).registerA
mutableMethod.addInstructions(
insertIndex, """
invoke-static {v$viewRegister}, $SEEKBAR_LAYOUT->enableOldSeekbarColor(I)I
registerIndex + 1, """
invoke-static {v$viewRegister}, $SEEKBAR_LAYOUT->enableCustomSeekbarColor(I)I
move-result v$viewRegister
"""
)

View File

@ -1,4 +1,4 @@
package app.revanced.patches.youtube.layout.seekbar.oldseekbarcolor.resource.patch
package app.revanced.patches.youtube.layout.seekbar.customseekbarcolor.resource.patch
import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name
@ -9,23 +9,23 @@ import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.ResourcePatch
import app.revanced.patches.youtube.layout.seekbar.oldseekbarcolor.bytecode.patch.OldSeekbarColorBytecodePatch
import app.revanced.patches.youtube.layout.seekbar.customseekbarcolor.bytecode.patch.CustomSeekbarColorBytecodePatch
import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch
import app.revanced.shared.annotation.YouTubeCompatibility
import app.revanced.shared.util.resources.ResourceHelper
@Patch
@Name("enable-old-seekbar-color")
@Description("Enable old seekbar color in dark mode.")
@Name("custom-seekbar-color")
@Description("Change seekbar color in dark mode.")
@DependsOn(
[
OldSeekbarColorBytecodePatch::class,
CustomSeekbarColorBytecodePatch::class,
SettingsPatch::class
]
)
@YouTubeCompatibility
@Version("0.0.1")
class OldSeekbarColorPatch : ResourcePatch {
class CustomSeekbarColorPatch : ResourcePatch {
override fun execute(context: ResourceContext): PatchResult {
/*
@ -36,12 +36,12 @@ class OldSeekbarColorPatch : ResourcePatch {
"PREFERENCE_CATEGORY: REVANCED_SETTINGS",
"PREFERENCE: LAYOUT_SETTINGS",
"PREFERENCE_HEADER: SEEKBAR",
"SETTINGS: ENABLE_OLD_SEEKBAR_COLOR"
"SETTINGS: CUSTOM_SEEKBAR_COLOR"
)
ResourceHelper.patchSuccess(
context,
"enable-old-seekbar-color"
"custom-seekbar-color"
)
return PatchResultSuccess()