mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-06-12 05:07:41 +02:00
fix(Reddit - Remove subreddit dialog): Remove notification suggestion dialog
not working in Reddit 2024.41.0
+ https://github.com/inotia00/ReVanced_Extended/issues/2667
This commit is contained in:
@ -3,6 +3,7 @@ package app.revanced.patches.reddit.layout.subredditdialog
|
||||
import app.revanced.util.fingerprint.legacyFingerprint
|
||||
import app.revanced.util.getReference
|
||||
import app.revanced.util.indexOfFirstInstruction
|
||||
import app.revanced.util.indexOfFirstInstructionReversed
|
||||
import app.revanced.util.or
|
||||
import com.android.tools.smali.dexlib2.AccessFlags
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
@ -25,6 +26,40 @@ internal val frequentUpdatesSheetScreenFingerprint = legacyFingerprint(
|
||||
}
|
||||
)
|
||||
|
||||
internal val frequentUpdatesSheetV2ScreenFingerprint = legacyFingerprint(
|
||||
name = "frequentUpdatesSheetV2ScreenFingerprint",
|
||||
returnType = "V",
|
||||
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||
strings = listOf("subreddit_name"),
|
||||
customFingerprint = { method, classDef ->
|
||||
classDef.type == "Lcom/reddit/screens/pager/v2/FrequentUpdatesSheetV2Screen;"
|
||||
}
|
||||
)
|
||||
|
||||
internal val frequentUpdatesSheetV2ScreenInvokeFingerprint = legacyFingerprint(
|
||||
name = "frequentUpdatesSheetV2ScreenInvokeFingerprint",
|
||||
returnType = "V",
|
||||
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||
opcodes = listOf(
|
||||
Opcode.IGET_OBJECT,
|
||||
Opcode.INVOKE_VIRTUAL,
|
||||
Opcode.RETURN_VOID,
|
||||
),
|
||||
customFingerprint = { method, classDef ->
|
||||
classDef.type.startsWith("Lcom/reddit/screens/pager/v2/FrequentUpdatesSheetV2Screen${'$'}SheetContent${'$'}") &&
|
||||
method.name == "invoke" &&
|
||||
indexOfDismissScreenInstruction(method) >= 0
|
||||
}
|
||||
)
|
||||
|
||||
fun indexOfDismissScreenInstruction(method: Method) =
|
||||
method.indexOfFirstInstructionReversed {
|
||||
val reference = getReference<MethodReference>()
|
||||
opcode == Opcode.INVOKE_VIRTUAL &&
|
||||
reference?.returnType == "V" &&
|
||||
reference.parameterTypes.isEmpty()
|
||||
}
|
||||
|
||||
internal val redditAlertDialogsFingerprint = legacyFingerprint(
|
||||
name = "redditAlertDialogsFingerprint",
|
||||
returnType = "V",
|
||||
|
@ -1,20 +1,25 @@
|
||||
package app.revanced.patches.reddit.layout.subredditdialog
|
||||
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.removeInstruction
|
||||
import app.revanced.patcher.patch.bytecodePatch
|
||||
import app.revanced.patches.reddit.utils.compatibility.Constants.COMPATIBLE_PACKAGE
|
||||
import app.revanced.patches.reddit.utils.extension.Constants.PATCHES_PATH
|
||||
import app.revanced.patches.reddit.utils.patch.PatchList.REMOVE_SUBREDDIT_DIALOG
|
||||
import app.revanced.patches.reddit.utils.settings.is_2024_41_or_greater
|
||||
import app.revanced.patches.reddit.utils.settings.settingsPatch
|
||||
import app.revanced.patches.reddit.utils.settings.updatePatchStatus
|
||||
import app.revanced.util.fingerprint.matchOrThrow
|
||||
import app.revanced.util.findMethodOrThrow
|
||||
import app.revanced.util.fingerprint.methodOrThrow
|
||||
import app.revanced.util.getReference
|
||||
import app.revanced.util.indexOfFirstInstructionOrThrow
|
||||
import app.revanced.util.indexOfFirstInstructionReversedOrThrow
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
|
||||
import com.android.tools.smali.dexlib2.iface.reference.MethodReference
|
||||
|
||||
private const val EXTENSION_CLASS_DESCRIPTOR =
|
||||
@ -30,20 +35,50 @@ val subRedditDialogPatch = bytecodePatch(
|
||||
dependsOn(settingsPatch)
|
||||
|
||||
execute {
|
||||
frequentUpdatesSheetScreenFingerprint.matchOrThrow().let {
|
||||
it.method.apply {
|
||||
val cancelButtonViewIndex = it.patternMatch!!.startIndex + 2
|
||||
val cancelButtonViewRegister =
|
||||
getInstruction<OneRegisterInstruction>(cancelButtonViewIndex).registerA
|
||||
|
||||
addInstruction(
|
||||
cancelButtonViewIndex + 1,
|
||||
"invoke-static {v$cancelButtonViewRegister}, $EXTENSION_CLASS_DESCRIPTOR->dismissDialog(Landroid/view/View;)V"
|
||||
)
|
||||
}
|
||||
frequentUpdatesSheetScreenFingerprint.methodOrThrow().apply {
|
||||
val index = indexOfFirstInstructionReversedOrThrow(Opcode.RETURN_OBJECT)
|
||||
val register =
|
||||
getInstruction<OneRegisterInstruction>(index).registerA
|
||||
|
||||
addInstruction(
|
||||
index,
|
||||
"invoke-static {v$register}, $EXTENSION_CLASS_DESCRIPTOR->onDialogCreated(Landroid/view/View;)V"
|
||||
)
|
||||
}
|
||||
|
||||
redditAlertDialogsFingerprint.methodOrThrow().apply {
|
||||
if (is_2024_41_or_greater) {
|
||||
val dismissReference = with (frequentUpdatesSheetV2ScreenInvokeFingerprint.methodOrThrow()) {
|
||||
val index = indexOfDismissScreenInstruction(this)
|
||||
getInstruction<ReferenceInstruction>(index).reference as MethodReference
|
||||
}
|
||||
|
||||
findMethodOrThrow(EXTENSION_CLASS_DESCRIPTOR) {
|
||||
name == "dismissRedditDialogV2"
|
||||
}.addInstructions(
|
||||
0, """
|
||||
check-cast p0, ${dismissReference.definingClass}
|
||||
invoke-virtual {p0}, $dismissReference
|
||||
"""
|
||||
)
|
||||
|
||||
frequentUpdatesSheetV2ScreenFingerprint
|
||||
.methodOrThrow()
|
||||
.apply {
|
||||
val targetIndex = implementation!!.instructions.lastIndex
|
||||
|
||||
addInstructions(
|
||||
targetIndex + 1, """
|
||||
invoke-static {p0}, $EXTENSION_CLASS_DESCRIPTOR->dismissDialogV2(Ljava/lang/Object;)V
|
||||
return-void
|
||||
"""
|
||||
)
|
||||
removeInstruction(targetIndex)
|
||||
}
|
||||
}
|
||||
|
||||
// Not used in latest Reddit client.
|
||||
redditAlertDialogsFingerprint.second.methodOrNull?.apply {
|
||||
val backgroundTintIndex = indexOfSetBackgroundTintListInstruction(this)
|
||||
val insertIndex =
|
||||
indexOfFirstInstructionOrThrow(backgroundTintIndex) {
|
||||
|
@ -35,6 +35,8 @@ private lateinit var settingsStatusLoadMethod: MutableMethod
|
||||
|
||||
var is_2024_18_or_greater = false
|
||||
private set
|
||||
var is_2024_41_or_greater = false
|
||||
private set
|
||||
|
||||
private val settingsBytecodePatch = bytecodePatch(
|
||||
description = "settingsBytecodePatch"
|
||||
@ -56,6 +58,7 @@ private val settingsBytecodePatch = bytecodePatch(
|
||||
.replace(".", "").toInt()
|
||||
|
||||
is_2024_18_or_greater = 2024180 <= versionNumber
|
||||
is_2024_41_or_greater = 2024100 <= versionNumber
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user