fix(YouTube - ReturnYouTubeDislike): Improve layout padding (#3291)
This commit is contained in:
parent
4704943c5c
commit
630b067b18
|
@ -55,7 +55,8 @@ object ReturnYouTubeDislikePatch : BytecodePatch(
|
||||||
DislikeFingerprint,
|
DislikeFingerprint,
|
||||||
RemoveLikeFingerprint,
|
RemoveLikeFingerprint,
|
||||||
RollingNumberSetterFingerprint,
|
RollingNumberSetterFingerprint,
|
||||||
RollingNumberTextViewFingerprint
|
RollingNumberTextViewFingerprint,
|
||||||
|
RollingNumberMeasureTextParentFingerprint
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
private const val INTEGRATIONS_CLASS_DESCRIPTOR =
|
private const val INTEGRATIONS_CLASS_DESCRIPTOR =
|
||||||
|
@ -181,6 +182,31 @@ object ReturnYouTubeDislikePatch : BytecodePatch(
|
||||||
}
|
}
|
||||||
} ?: throw RollingNumberSetterFingerprint.exception
|
} ?: throw RollingNumberSetterFingerprint.exception
|
||||||
|
|
||||||
|
// Rolling Number text views use the measured width of the raw string for layout.
|
||||||
|
// Modify the measure text calculation to include the left drawable separator if needed.
|
||||||
|
RollingNumberMeasureTextFingerprint.also {
|
||||||
|
if (!it.resolve(context, RollingNumberMeasureTextParentFingerprint.result!!.classDef))
|
||||||
|
throw it.exception
|
||||||
|
}.result?.also {
|
||||||
|
it.mutableMethod.apply {
|
||||||
|
val returnInstructionIndex = it.scanResult.patternScanResult!!.endIndex
|
||||||
|
val measuredTextWidthRegister =
|
||||||
|
getInstruction<OneRegisterInstruction>(returnInstructionIndex).registerA
|
||||||
|
|
||||||
|
replaceInstruction( // Replace instruction to preserve control flow label.
|
||||||
|
returnInstructionIndex,
|
||||||
|
"invoke-static {p1, v$measuredTextWidthRegister}, $INTEGRATIONS_CLASS_DESCRIPTOR->onRollingNumberMeasured(Ljava/lang/String;F)F"
|
||||||
|
)
|
||||||
|
addInstructions(
|
||||||
|
returnInstructionIndex + 1,
|
||||||
|
"""
|
||||||
|
move-result v$measuredTextWidthRegister
|
||||||
|
return v$measuredTextWidthRegister
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
}
|
||||||
|
} ?: throw RollingNumberMeasureTextFingerprint.exception
|
||||||
|
|
||||||
// The rolling number Span is missing styling since it's initially set as a String.
|
// The rolling number Span is missing styling since it's initially set as a String.
|
||||||
// Modify the UI text view and use the styled like/dislike Span.
|
// Modify the UI text view and use the styled like/dislike Span.
|
||||||
RollingNumberTextViewFingerprint.result?.let {
|
RollingNumberTextViewFingerprint.result?.let {
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
package app.revanced.patches.youtube.layout.returnyoutubedislike.fingerprints
|
||||||
|
|
||||||
|
import app.revanced.patcher.extensions.or
|
||||||
|
import app.revanced.patcher.fingerprint.MethodFingerprint
|
||||||
|
import com.android.tools.smali.dexlib2.AccessFlags
|
||||||
|
import com.android.tools.smali.dexlib2.Opcode
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resolves to class found in [RollingNumberMeasureTextParentFingerprint].
|
||||||
|
*/
|
||||||
|
object RollingNumberMeasureTextFingerprint : MethodFingerprint(
|
||||||
|
returnType = "F",
|
||||||
|
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||||
|
parameters = listOf("Ljava/lang/String;"),
|
||||||
|
opcodes = listOf(
|
||||||
|
Opcode.INVOKE_VIRTUAL,
|
||||||
|
Opcode.MOVE_RESULT,
|
||||||
|
Opcode.ADD_FLOAT_2ADDR,
|
||||||
|
Opcode.ADD_INT_LIT8,
|
||||||
|
Opcode.GOTO,
|
||||||
|
Opcode.RETURN
|
||||||
|
)
|
||||||
|
)
|
|
@ -0,0 +1,12 @@
|
||||||
|
package app.revanced.patches.youtube.layout.returnyoutubedislike.fingerprints
|
||||||
|
|
||||||
|
import app.revanced.patcher.extensions.or
|
||||||
|
import app.revanced.patcher.fingerprint.MethodFingerprint
|
||||||
|
import com.android.tools.smali.dexlib2.AccessFlags
|
||||||
|
|
||||||
|
object RollingNumberMeasureTextParentFingerprint : MethodFingerprint(
|
||||||
|
returnType = "Ljava/lang/String;",
|
||||||
|
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||||
|
parameters = listOf(),
|
||||||
|
strings = listOf("RollingNumberFontProperties{paint=")
|
||||||
|
)
|
Loading…
Reference in a new issue