mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-06-13 05:37:40 +02:00
fix(Reddit - Remove subreddit dialog): Navigation bar is not visible when Remove notification suggestion dialog
setting is turned on (Reddit 2025.02+)
This commit is contained in:
@ -8,7 +8,6 @@ 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")
|
||||||
@ -31,20 +30,12 @@ public class RemoveSubRedditDialogPatch {
|
|||||||
clickViewDelayed(cancelButtonView);
|
clickViewDelayed(cancelButtonView);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void dismissDialogV2(Object object) {
|
public static boolean spoofHasBeenVisitedStatus(boolean hasBeenVisited) {
|
||||||
if (!Settings.REMOVE_NOTIFICATION_DIALOG.get())
|
return Settings.REMOVE_NSFW_DIALOG.get() || hasBeenVisited;
|
||||||
return;
|
|
||||||
|
|
||||||
Utils.runOnMainThreadDelayed(() -> {
|
|
||||||
try {
|
|
||||||
dismissRedditDialogV2(object);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
Logger.printException(() -> "dismissDialogV2 failed", ex);
|
|
||||||
}
|
|
||||||
}, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void dismissRedditDialogV2(Object object) {
|
public static boolean spoofLoggedInStatus(boolean isLoggedIn) {
|
||||||
|
return !Settings.REMOVE_NOTIFICATION_DIALOG.get() && isLoggedIn;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void clickViewDelayed(View view) {
|
private static void clickViewDelayed(View view) {
|
||||||
|
@ -3,11 +3,11 @@ 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
|
||||||
import com.android.tools.smali.dexlib2.iface.Method
|
import com.android.tools.smali.dexlib2.iface.Method
|
||||||
|
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
|
||||||
|
|
||||||
internal val frequentUpdatesSheetScreenFingerprint = legacyFingerprint(
|
internal val frequentUpdatesSheetScreenFingerprint = legacyFingerprint(
|
||||||
@ -26,38 +26,49 @@ internal val frequentUpdatesSheetScreenFingerprint = legacyFingerprint(
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
internal val frequentUpdatesSheetV2ScreenFingerprint = legacyFingerprint(
|
internal val frequentUpdatesHandlerFingerprint = legacyFingerprint(
|
||||||
name = "frequentUpdatesSheetV2ScreenFingerprint",
|
name = "frequentUpdatesHandlerFingerprint",
|
||||||
returnType = "V",
|
returnType = "Ljava/lang/Object;",
|
||||||
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||||
strings = listOf("subreddit_name"),
|
strings = listOf("subreddit_name"),
|
||||||
customFingerprint = { method, classDef ->
|
customFingerprint = { method, classDef ->
|
||||||
classDef.type == "Lcom/reddit/screens/pager/v2/FrequentUpdatesSheetV2Screen;"
|
classDef.type.startsWith("Lcom/reddit/screens/pager/FrequentUpdatesHandler${'$'}handleFrequentUpdates${'$'}") &&
|
||||||
|
method.name == "invokeSuspend" &&
|
||||||
|
listOfIsLoggedInInstruction(method).isNotEmpty()
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
internal val frequentUpdatesSheetV2ScreenInvokeFingerprint = legacyFingerprint(
|
fun listOfIsLoggedInInstruction(method: Method) =
|
||||||
name = "frequentUpdatesSheetV2ScreenInvokeFingerprint",
|
method.implementation?.instructions
|
||||||
returnType = "V",
|
?.withIndex()
|
||||||
|
?.filter { (_, instruction) ->
|
||||||
|
val reference = (instruction as? ReferenceInstruction)?.reference
|
||||||
|
instruction.opcode == Opcode.INVOKE_INTERFACE &&
|
||||||
|
reference is MethodReference &&
|
||||||
|
reference.name == "isLoggedIn" &&
|
||||||
|
reference.returnType == "Z"
|
||||||
|
}
|
||||||
|
?.map { (index, _) -> index }
|
||||||
|
?.reversed()
|
||||||
|
?: emptyList()
|
||||||
|
|
||||||
|
internal val nsfwAlertEmitFingerprint = legacyFingerprint(
|
||||||
|
name = "nsfwAlertEmitFingerprint",
|
||||||
|
returnType = "Ljava/lang/Object;",
|
||||||
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||||
opcodes = listOf(
|
strings = listOf("reddit://reddit/r/", "nsfwAlertDelegate"),
|
||||||
Opcode.IGET_OBJECT,
|
customFingerprint = { method, _ ->
|
||||||
Opcode.INVOKE_VIRTUAL,
|
method.name == "emit" &&
|
||||||
Opcode.RETURN_VOID,
|
indexOfHasBeenVisitedInstruction(method) >= 0
|
||||||
),
|
|
||||||
customFingerprint = { method, classDef ->
|
|
||||||
classDef.type.startsWith("Lcom/reddit/screens/pager/v2/FrequentUpdatesSheetV2Screen${'$'}SheetContent${'$'}") &&
|
|
||||||
method.name == "invoke" &&
|
|
||||||
indexOfDismissScreenInstruction(method) >= 0
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
fun indexOfDismissScreenInstruction(method: Method) =
|
fun indexOfHasBeenVisitedInstruction(method: Method) =
|
||||||
method.indexOfFirstInstructionReversed {
|
method.indexOfFirstInstruction {
|
||||||
val reference = getReference<MethodReference>()
|
val reference = getReference<MethodReference>()
|
||||||
opcode == Opcode.INVOKE_VIRTUAL &&
|
opcode == Opcode.INVOKE_VIRTUAL &&
|
||||||
reference?.returnType == "V" &&
|
reference?.name == "getHasBeenVisited" &&
|
||||||
reference.parameterTypes.isEmpty()
|
reference.returnType == "Z"
|
||||||
}
|
}
|
||||||
|
|
||||||
internal val redditAlertDialogsFingerprint = legacyFingerprint(
|
internal val redditAlertDialogsFingerprint = legacyFingerprint(
|
||||||
|
@ -8,10 +8,9 @@ import app.revanced.patches.reddit.utils.compatibility.Constants.COMPATIBLE_PACK
|
|||||||
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.is_2024_41_or_greater
|
||||||
|
import app.revanced.patches.reddit.utils.settings.is_2025_01_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.addInstructionsAtControlFlowLabel
|
|
||||||
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
|
||||||
@ -19,7 +18,6 @@ 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 =
|
||||||
@ -36,6 +34,25 @@ val subRedditDialogPatch = bytecodePatch(
|
|||||||
|
|
||||||
execute {
|
execute {
|
||||||
|
|
||||||
|
if (is_2024_41_or_greater) {
|
||||||
|
frequentUpdatesHandlerFingerprint
|
||||||
|
.methodOrThrow()
|
||||||
|
.apply {
|
||||||
|
listOfIsLoggedInInstruction(this)
|
||||||
|
.forEach { index ->
|
||||||
|
val register = getInstruction<OneRegisterInstruction>(index + 1).registerA
|
||||||
|
|
||||||
|
addInstructions(
|
||||||
|
index + 2, """
|
||||||
|
invoke-static {v$register}, $EXTENSION_CLASS_DESCRIPTOR->spoofLoggedInStatus(Z)Z
|
||||||
|
move-result v$register
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Not used in latest Reddit client.
|
||||||
frequentUpdatesSheetScreenFingerprint.methodOrThrow().apply {
|
frequentUpdatesSheetScreenFingerprint.methodOrThrow().apply {
|
||||||
val index = indexOfFirstInstructionReversedOrThrow(Opcode.RETURN_OBJECT)
|
val index = indexOfFirstInstructionReversedOrThrow(Opcode.RETURN_OBJECT)
|
||||||
val register =
|
val register =
|
||||||
@ -43,39 +60,27 @@ val subRedditDialogPatch = bytecodePatch(
|
|||||||
|
|
||||||
addInstruction(
|
addInstruction(
|
||||||
index,
|
index,
|
||||||
"invoke-static {v$register}, $EXTENSION_CLASS_DESCRIPTOR->onDialogCreated(Landroid/view/View;)V"
|
"invoke-static {v$register}, $EXTENSION_CLASS_DESCRIPTOR->dismissDialog(Landroid/view/View;)V"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_2024_41_or_greater) {
|
if (is_2025_01_or_greater) {
|
||||||
val dismissReference = with (frequentUpdatesSheetV2ScreenInvokeFingerprint.methodOrThrow()) {
|
nsfwAlertEmitFingerprint.methodOrThrow().apply {
|
||||||
val index = indexOfDismissScreenInstruction(this)
|
val hasBeenVisitedIndex = indexOfHasBeenVisitedInstruction(this)
|
||||||
getInstruction<ReferenceInstruction>(index).reference as MethodReference
|
val hasBeenVisitedRegister =
|
||||||
|
getInstruction<OneRegisterInstruction>(hasBeenVisitedIndex + 1).registerA
|
||||||
|
|
||||||
|
addInstructions(
|
||||||
|
hasBeenVisitedIndex + 2, """
|
||||||
|
invoke-static {v$hasBeenVisitedRegister}, $EXTENSION_CLASS_DESCRIPTOR->spoofHasBeenVisitedStatus(Z)Z
|
||||||
|
move-result v$hasBeenVisitedRegister
|
||||||
|
"""
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
findMethodOrThrow(EXTENSION_CLASS_DESCRIPTOR) {
|
|
||||||
name == "dismissRedditDialogV2"
|
|
||||||
}.addInstructions(
|
|
||||||
0, """
|
|
||||||
check-cast p0, ${dismissReference.definingClass}
|
|
||||||
invoke-virtual {p0}, $dismissReference
|
|
||||||
"""
|
|
||||||
)
|
|
||||||
|
|
||||||
frequentUpdatesSheetV2ScreenFingerprint
|
|
||||||
.methodOrThrow()
|
|
||||||
.apply {
|
|
||||||
val targetIndex = indexOfFirstInstructionReversedOrThrow(Opcode.RETURN_VOID)
|
|
||||||
|
|
||||||
addInstructionsAtControlFlowLabel(
|
|
||||||
targetIndex,
|
|
||||||
"invoke-static {p0}, $EXTENSION_CLASS_DESCRIPTOR->dismissDialogV2(Ljava/lang/Object;)V"
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Not used in latest Reddit client.
|
// Not used in latest Reddit client.
|
||||||
redditAlertDialogsFingerprint.second.methodOrNull?.apply {
|
redditAlertDialogsFingerprint.methodOrThrow().apply {
|
||||||
val backgroundTintIndex = indexOfSetBackgroundTintListInstruction(this)
|
val backgroundTintIndex = indexOfSetBackgroundTintListInstruction(this)
|
||||||
val insertIndex =
|
val insertIndex =
|
||||||
indexOfFirstInstructionOrThrow(backgroundTintIndex) {
|
indexOfFirstInstructionOrThrow(backgroundTintIndex) {
|
||||||
|
@ -37,6 +37,8 @@ var is_2024_26_or_greater = false
|
|||||||
private set
|
private set
|
||||||
var is_2024_41_or_greater = false
|
var is_2024_41_or_greater = false
|
||||||
private set
|
private set
|
||||||
|
var is_2025_01_or_greater = false
|
||||||
|
private set
|
||||||
|
|
||||||
private val settingsBytecodePatch = bytecodePatch(
|
private val settingsBytecodePatch = bytecodePatch(
|
||||||
description = "settingsBytecodePatch"
|
description = "settingsBytecodePatch"
|
||||||
@ -59,6 +61,7 @@ private val settingsBytecodePatch = bytecodePatch(
|
|||||||
|
|
||||||
is_2024_26_or_greater = 2024260 <= versionNumber
|
is_2024_26_or_greater = 2024260 <= versionNumber
|
||||||
is_2024_41_or_greater = 2024410 <= versionNumber
|
is_2024_41_or_greater = 2024410 <= versionNumber
|
||||||
|
is_2025_01_or_greater = 2025010 <= versionNumber
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user