feat(kakaotalk): implement layout handling for deleted messages in chat log
This is the third commit to make deleted, hidden messages visible.
This commit is contained in:
@ -1,7 +1,11 @@
|
||||
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.getInstruction
|
||||
import app.revanced.patcher.patch.bytecodePatch
|
||||
import app.revanced.patcher.util.proxy.mutableTypes.MutableField.Companion.toMutable
|
||||
import app.revanced.patcher.util.smali.ExternalLabel
|
||||
import com.android.tools.smali.dexlib2.AccessFlags
|
||||
import com.android.tools.smali.dexlib2.immutable.ImmutableField
|
||||
import com.android.tools.smali.dexlib2.immutable.value.ImmutableBooleanEncodedValue
|
||||
@ -169,6 +173,48 @@ val addDeletedOrHiddenLayoutPatch = bytecodePatch(
|
||||
)
|
||||
|
||||
// TODO: Add logic to initialize these fields in the makeLayout method
|
||||
|
||||
makeLayoutMethod.addInstructionsWithLabels(
|
||||
0,
|
||||
"""
|
||||
iget-boolean v0, p0, Lcom/kakao/talk/widget/chatlog/ChatInfoView;->isDeleted:Z
|
||||
if-eqz v0, :not_deleted
|
||||
const-string v0, "[Deleted]"
|
||||
iget-object v1, p0, Lcom/kakao/talk/widget/chatlog/ChatInfoView;->deletedPaint:Landroid/text/TextPaint;
|
||||
invoke-static {v0, v1}, Landroid/text/BoringLayout;->isBoring(Ljava/lang/CharSequence;Landroid/text/TextPaint;)Landroid/text/BoringLayout${'$'}Metrics;
|
||||
move-result-object v8
|
||||
|
||||
if-nez v8, :boring_deleted
|
||||
new-instance v1, Landroid/text/StaticLayout;
|
||||
iget-object v4, p0, Lcom/kakao/talk/widget/chatlog/ChatInfoView;->deletedPaint:Landroid/text/TextPaint;
|
||||
invoke-virtual { v4, v0 }, Landroid/graphics/Paint;->measureText(Ljava/lang/String;)F
|
||||
move-result v2
|
||||
float-to-int v5, v2
|
||||
sget-object v6, Landroid/text/Layout${'$'}Alignment;->ALIGN_NORMAL:Landroid/text/Layout${'$'}Alignment;
|
||||
const/4 v9, 0x1
|
||||
const/high16 v7, 0x3f800000 # 1.0f
|
||||
const/4 v8, 0x0
|
||||
move-object v2, v1
|
||||
move-object v3, v0
|
||||
invoke-direct/range {v2 .. v9}, Landroid/text/StaticLayout;-><init>(Ljava/lang/CharSequence;Landroid/text/TextPaint;ILandroid/text/Layout${'$'}Alignment;FFZ)V
|
||||
goto :set_deleted_layout
|
||||
:boring_deleted
|
||||
iget-object v3, p0, Lcom/kakao/talk/widget/chatlog/ChatInfoView;->deletedPaint:Landroid/text/TextPaint;
|
||||
invoke-virtual {v3, v0}, Landroid/graphics/Paint;->measureText(Ljava/lang/String;)F
|
||||
move-result v1
|
||||
float-to-int v4, v1
|
||||
sget-object v5, Landroid/text/Layout${'$'}Alignment;->ALIGN_NORMAL:Landroid/text/Layout${'$'}Alignment;
|
||||
const/4 v9, 0x0
|
||||
const/high16 v6, 0x3f800000 # 1.0f
|
||||
const/4 v7, 0x0
|
||||
move-object v2, v0
|
||||
invoke-static/range {v2 .. v9}, Landroid/text/BoringLayout;->make(Ljava/lang/CharSequence;Landroid/text/TextPaint;ILandroid/text/Layout${'$'}Alignment;FFLandroid/text/BoringLayout${'$'}Metrics;Z)Landroid/text/BoringLayout;
|
||||
move-result-object v1
|
||||
:set_deleted_layout
|
||||
iput-object v1, p0, Lcom/kakao/talk/widget/chatlog/ChatInfoView;->deletedLayout:Landroid/text/Layout;
|
||||
""".trimIndent(),
|
||||
ExternalLabel("not_deleted", makeLayoutMethod.getInstruction(0))
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user