mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-06-13 05:37:40 +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:
@ -8,6 +8,7 @@ import android.widget.TextView;
|
|||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
import app.revanced.extension.reddit.settings.Settings;
|
import app.revanced.extension.reddit.settings.Settings;
|
||||||
|
import app.revanced.extension.shared.utils.Logger;
|
||||||
import app.revanced.extension.shared.utils.Utils;
|
import app.revanced.extension.shared.utils.Utils;
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
@ -30,6 +31,22 @@ public class RemoveSubRedditDialogPatch {
|
|||||||
clickViewDelayed(cancelButtonView);
|
clickViewDelayed(cancelButtonView);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void dismissDialogV2(Object object) {
|
||||||
|
if (!Settings.REMOVE_NOTIFICATION_DIALOG.get())
|
||||||
|
return;
|
||||||
|
|
||||||
|
Utils.runOnMainThreadDelayed(() -> {
|
||||||
|
try {
|
||||||
|
dismissRedditDialogV2(object);
|
||||||
|
} catch (Exception ex) {
|
||||||
|
Logger.printException(() -> "dismissDialogV2 failed", ex);
|
||||||
|
}
|
||||||
|
}, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void dismissRedditDialogV2(Object object) {
|
||||||
|
}
|
||||||
|
|
||||||
private static void clickViewDelayed(View view) {
|
private static void clickViewDelayed(View view) {
|
||||||
Utils.runOnMainThreadDelayed(() -> {
|
Utils.runOnMainThreadDelayed(() -> {
|
||||||
if (view != null) {
|
if (view != null) {
|
||||||
|
@ -3,6 +3,7 @@ package app.revanced.patches.reddit.layout.subredditdialog
|
|||||||
import app.revanced.util.fingerprint.legacyFingerprint
|
import app.revanced.util.fingerprint.legacyFingerprint
|
||||||
import app.revanced.util.getReference
|
import app.revanced.util.getReference
|
||||||
import app.revanced.util.indexOfFirstInstruction
|
import app.revanced.util.indexOfFirstInstruction
|
||||||
|
import app.revanced.util.indexOfFirstInstructionReversed
|
||||||
import app.revanced.util.or
|
import app.revanced.util.or
|
||||||
import com.android.tools.smali.dexlib2.AccessFlags
|
import com.android.tools.smali.dexlib2.AccessFlags
|
||||||
import com.android.tools.smali.dexlib2.Opcode
|
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(
|
internal val redditAlertDialogsFingerprint = legacyFingerprint(
|
||||||
name = "redditAlertDialogsFingerprint",
|
name = "redditAlertDialogsFingerprint",
|
||||||
returnType = "V",
|
returnType = "V",
|
||||||
|
@ -1,20 +1,25 @@
|
|||||||
package app.revanced.patches.reddit.layout.subredditdialog
|
package app.revanced.patches.reddit.layout.subredditdialog
|
||||||
|
|
||||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
|
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.getInstruction
|
||||||
|
import app.revanced.patcher.extensions.InstructionExtensions.removeInstruction
|
||||||
import app.revanced.patcher.patch.bytecodePatch
|
import app.revanced.patcher.patch.bytecodePatch
|
||||||
import app.revanced.patches.reddit.utils.compatibility.Constants.COMPATIBLE_PACKAGE
|
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.extension.Constants.PATCHES_PATH
|
||||||
import app.revanced.patches.reddit.utils.patch.PatchList.REMOVE_SUBREDDIT_DIALOG
|
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.settingsPatch
|
||||||
import app.revanced.patches.reddit.utils.settings.updatePatchStatus
|
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.fingerprint.methodOrThrow
|
||||||
import app.revanced.util.getReference
|
import app.revanced.util.getReference
|
||||||
import app.revanced.util.indexOfFirstInstructionOrThrow
|
import app.revanced.util.indexOfFirstInstructionOrThrow
|
||||||
|
import app.revanced.util.indexOfFirstInstructionReversedOrThrow
|
||||||
import com.android.tools.smali.dexlib2.Opcode
|
import com.android.tools.smali.dexlib2.Opcode
|
||||||
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
|
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.OneRegisterInstruction
|
||||||
|
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
|
||||||
import com.android.tools.smali.dexlib2.iface.reference.MethodReference
|
import com.android.tools.smali.dexlib2.iface.reference.MethodReference
|
||||||
|
|
||||||
private const val EXTENSION_CLASS_DESCRIPTOR =
|
private const val EXTENSION_CLASS_DESCRIPTOR =
|
||||||
@ -30,20 +35,50 @@ val subRedditDialogPatch = bytecodePatch(
|
|||||||
dependsOn(settingsPatch)
|
dependsOn(settingsPatch)
|
||||||
|
|
||||||
execute {
|
execute {
|
||||||
frequentUpdatesSheetScreenFingerprint.matchOrThrow().let {
|
|
||||||
it.method.apply {
|
|
||||||
val cancelButtonViewIndex = it.patternMatch!!.startIndex + 2
|
|
||||||
val cancelButtonViewRegister =
|
|
||||||
getInstruction<OneRegisterInstruction>(cancelButtonViewIndex).registerA
|
|
||||||
|
|
||||||
addInstruction(
|
frequentUpdatesSheetScreenFingerprint.methodOrThrow().apply {
|
||||||
cancelButtonViewIndex + 1,
|
val index = indexOfFirstInstructionReversedOrThrow(Opcode.RETURN_OBJECT)
|
||||||
"invoke-static {v$cancelButtonViewRegister}, $EXTENSION_CLASS_DESCRIPTOR->dismissDialog(Landroid/view/View;)V"
|
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 backgroundTintIndex = indexOfSetBackgroundTintListInstruction(this)
|
||||||
val insertIndex =
|
val insertIndex =
|
||||||
indexOfFirstInstructionOrThrow(backgroundTintIndex) {
|
indexOfFirstInstructionOrThrow(backgroundTintIndex) {
|
||||||
|
@ -35,6 +35,8 @@ private lateinit var settingsStatusLoadMethod: MutableMethod
|
|||||||
|
|
||||||
var is_2024_18_or_greater = false
|
var is_2024_18_or_greater = false
|
||||||
private set
|
private set
|
||||||
|
var is_2024_41_or_greater = false
|
||||||
|
private set
|
||||||
|
|
||||||
private val settingsBytecodePatch = bytecodePatch(
|
private val settingsBytecodePatch = bytecodePatch(
|
||||||
description = "settingsBytecodePatch"
|
description = "settingsBytecodePatch"
|
||||||
@ -56,6 +58,7 @@ private val settingsBytecodePatch = bytecodePatch(
|
|||||||
.replace(".", "").toInt()
|
.replace(".", "").toInt()
|
||||||
|
|
||||||
is_2024_18_or_greater = 2024180 <= versionNumber
|
is_2024_18_or_greater = 2024180 <= versionNumber
|
||||||
|
is_2024_41_or_greater = 2024100 <= versionNumber
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user