Skip to content

Commit 70e54f8

Browse files
1fexdoSumAtrIX
andauthored
feat: Add Remove share targets patch (#3334)
Co-authored-by: oSumAtrIX <[email protected]>
1 parent e2f9193 commit 70e54f8

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

api/revanced-patches.api

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,12 @@ public final class app/revanced/patches/all/screenshot/removerestriction/RemoveS
155155
public static fun values ()[Lapp/revanced/patches/all/screenshot/removerestriction/RemoveScreenshotRestrictionPatch$MethodCall;
156156
}
157157

158+
public final class app/revanced/patches/all/shortcut/sharetargets/RemoveShareTargetsPatch : app/revanced/patcher/patch/ResourcePatch {
159+
public static final field INSTANCE Lapp/revanced/patches/all/shortcut/sharetargets/RemoveShareTargetsPatch;
160+
public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V
161+
public fun execute (Lapp/revanced/patcher/data/ResourceContext;)V
162+
}
163+
158164
public final class app/revanced/patches/all/telephony/sim/spoof/SpoofSimCountryPatch : app/revanced/patches/all/misc/transformation/BaseTransformInstructionsPatch {
159165
public static final field INSTANCE Lapp/revanced/patches/all/telephony/sim/spoof/SpoofSimCountryPatch;
160166
public synthetic fun filterMap (Lcom/android/tools/smali/dexlib2/iface/ClassDef;Lcom/android/tools/smali/dexlib2/iface/Method;Lcom/android/tools/smali/dexlib2/iface/instruction/Instruction;I)Ljava/lang/Object;
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package app.revanced.patches.all.shortcut.sharetargets
2+
3+
import app.revanced.patcher.data.ResourceContext
4+
import app.revanced.patcher.patch.ResourcePatch
5+
import app.revanced.patcher.patch.annotation.Patch
6+
import app.revanced.util.asSequence
7+
import app.revanced.util.getNode
8+
import org.w3c.dom.Element
9+
import java.io.FileNotFoundException
10+
import java.util.logging.Logger
11+
12+
@Patch(
13+
name = "Remove share targets",
14+
description = "Removes share targets like directly sharing to a frequent contact.",
15+
use = false,
16+
)
17+
@Suppress("unused")
18+
object RemoveShareTargetsPatch : ResourcePatch() {
19+
override fun execute(context: ResourceContext) {
20+
try {
21+
context.document["res/xml/shortcuts.xml"]
22+
} catch (_: FileNotFoundException) {
23+
return Logger.getLogger(this::class.java.name).warning("The app has no shortcuts")
24+
}.use { document ->
25+
val rootNode = document.getNode("shortcuts") as? Element ?: return@use
26+
27+
document.getElementsByTagName("share-target").asSequence().forEach {
28+
rootNode.removeChild(it)
29+
}
30+
}
31+
}
32+
}

0 commit comments

Comments
 (0)