feat(kakaotalk): add methods to set text colors for deleted and hidden messages
This commit is contained in:
@ -245,6 +245,72 @@ val addDeletedOrHiddenLayoutPatch = bytecodePatch(
|
||||
},
|
||||
)
|
||||
|
||||
methods.add(
|
||||
ImmutableMethod(
|
||||
type,
|
||||
"setDeletedTextColor",
|
||||
ImmutableList.of(
|
||||
ImmutableMethodParameter(
|
||||
"I",
|
||||
null,
|
||||
null
|
||||
)
|
||||
),
|
||||
"V",
|
||||
AccessFlags.PUBLIC.value or AccessFlags.FINAL.value,
|
||||
null,
|
||||
null,
|
||||
MutableMethodImplementation(2)
|
||||
).toMutable().apply {
|
||||
addInstructions(
|
||||
0,
|
||||
"""
|
||||
iput p1, p0, Lcom/kakao/talk/widget/chatlog/ChatInfoView;->deletedTextColor:I
|
||||
iget-object v0, p0, Lcom/kakao/talk/widget/chatlog/ChatInfoView;->deletedPaint:Landroid/text/TextPaint;
|
||||
if-nez v0, :cond_0
|
||||
goto :goto_0
|
||||
:cond_0
|
||||
invoke-virtual {v0, p1}, Landroid/graphics/Paint;->setColor(I)V
|
||||
:goto_0
|
||||
return-void
|
||||
""".trimIndent()
|
||||
)
|
||||
},
|
||||
)
|
||||
|
||||
methods.add(
|
||||
ImmutableMethod(
|
||||
type,
|
||||
"setHiddenTextColor",
|
||||
ImmutableList.of(
|
||||
ImmutableMethodParameter(
|
||||
"I",
|
||||
null,
|
||||
null
|
||||
)
|
||||
),
|
||||
"V",
|
||||
AccessFlags.PUBLIC.value or AccessFlags.FINAL.value,
|
||||
null,
|
||||
null,
|
||||
MutableMethodImplementation(2)
|
||||
).toMutable().apply {
|
||||
addInstructions(
|
||||
0,
|
||||
"""
|
||||
iput p1, p0, Lcom/kakao/talk/widget/chatlog/ChatInfoView;->hiddenTextColor:I
|
||||
iget-object v0, p0, Lcom/kakao/talk/widget/chatlog/ChatInfoView;->hiddenPaint:Landroid/text/TextPaint;
|
||||
if-nez v0, :cond_0
|
||||
goto :goto_0
|
||||
:cond_0
|
||||
invoke-virtual {v0, p1}, Landroid/graphics/Paint;->setColor(I)V
|
||||
:goto_0
|
||||
return-void
|
||||
""".trimIndent()
|
||||
)
|
||||
},
|
||||
)
|
||||
|
||||
val cls = chatInfoViewClass.type
|
||||
|
||||
val deletedMakeLayoutBlock = """
|
||||
|
@ -1,5 +1,6 @@
|
||||
package app.revanced.patches.kakaotalk.chatlog
|
||||
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.instructions
|
||||
import app.revanced.patcher.patch.bytecodePatch
|
||||
@ -11,6 +12,7 @@ import com.android.tools.smali.dexlib2.builder.instruction.BuilderInstruction21c
|
||||
import com.android.tools.smali.dexlib2.builder.instruction.BuilderInstruction35c
|
||||
import com.android.tools.smali.dexlib2.iface.reference.MethodReference
|
||||
|
||||
// TODO: 레지스터 관련 패치해야함, 자동으로 찾게
|
||||
val showDeletedOrHiddenMessagePatch = bytecodePatch(
|
||||
name = "Show deleted or hidden message",
|
||||
description = "Shows deleted & hidden messages in chat logs",
|
||||
@ -50,22 +52,50 @@ val showDeletedOrHiddenMessagePatch = bytecodePatch(
|
||||
dateIndex + 1,
|
||||
"""
|
||||
invoke-virtual/range {p0 .. p0}, LOe/f2;->u0()LKe/S;
|
||||
move-result-object v12
|
||||
instance-of v13, v12, ${chatLogClass.type}
|
||||
if-eqz v13, :is_not_chat_log
|
||||
check-cast v12, ${chatLogClass.type}
|
||||
goto :fuck
|
||||
move-result-object v14
|
||||
instance-of v15, v14, ${chatLogClass.type}
|
||||
if-eqz v15, :is_not_chat_log
|
||||
check-cast v14, ${chatLogClass.type}
|
||||
goto :set_flags
|
||||
:is_not_chat_log
|
||||
const/4 v12, 0x0
|
||||
:fuck
|
||||
const/4 v14, 0x0
|
||||
:set_flags
|
||||
if-eqz v14, :skip_deleted_check
|
||||
iget-boolean v15, v14, ${chatLogClass.type}->isRealDeleted:Z
|
||||
invoke-virtual {v4, v15}, Lcom/kakao/talk/widget/chatlog/ChatInfoView;->setDeleted(Z)V
|
||||
goto :check_hidden
|
||||
:skip_deleted_check
|
||||
const/4 v15, 0x0
|
||||
invoke-virtual {v4, v15}, Lcom/kakao/talk/widget/chatlog/ChatInfoView;->setDeleted(Z)V
|
||||
:check_hidden
|
||||
if-eqz v14, :skip_hidden_check
|
||||
iget-boolean v15, v14, ${chatLogClass.type}->isHidden:Z
|
||||
invoke-virtual {v4, v15}, Lcom/kakao/talk/widget/chatlog/ChatInfoView;->setHidden(Z)V
|
||||
goto :end_patch
|
||||
:skip_hidden_check
|
||||
const/4 v15, 0x0
|
||||
invoke-virtual {v4, v15}, Lcom/kakao/talk/widget/chatlog/ChatInfoView;->setHidden(Z)V
|
||||
:end_patch
|
||||
nop
|
||||
|
||||
iget-boolean v10, v12, ${chatLogClass.type}->isRealDeleted:Z
|
||||
invoke-virtual {v4, v10}, Lcom/kakao/talk/widget/chatlog/ChatInfoView;->setDeleted(Z)V
|
||||
|
||||
iget-boolean v10, v12, ${chatLogClass.type}->isHidden:Z
|
||||
invoke-virtual {v4, v10}, Lcom/kakao/talk/widget/chatlog/ChatInfoView;->setHidden(Z)V
|
||||
""".trimIndent(),
|
||||
)
|
||||
|
||||
val setModifyTextColorInst = insns
|
||||
.filterIsInstance<BuilderInstruction35c>()
|
||||
.filter { it.opcode == Opcode.INVOKE_VIRTUAL }
|
||||
.find {
|
||||
it.getReference<MethodReference>()?.name == "setModifyTextColor"
|
||||
} ?: error("setModifyTextColor method not found")
|
||||
val setModifyTextColorInstIndex = insns.indexOf(setModifyTextColorInst)
|
||||
|
||||
println("setModifyTextColorInstIndex: $setModifyTextColorInstIndex")
|
||||
|
||||
method.addInstructions(
|
||||
setModifyTextColorInstIndex + 1,
|
||||
"""
|
||||
invoke-virtual {v4, v6}, Lcom/kakao/talk/widget/chatlog/ChatInfoView;->setDeletedTextColor(I)V
|
||||
invoke-virtual {v4, v6}, Lcom/kakao/talk/widget/chatlog/ChatInfoView;->setHiddenTextColor(I)V
|
||||
""".trimIndent()
|
||||
)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user