generated from ReVanced/revanced-patches-template
-
-
Notifications
You must be signed in to change notification settings - Fork 281
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add
Remove share targets
patch (#3334)
Co-authored-by: oSumAtrIX <johan.melkonyan1@web.de>
- Loading branch information
Showing
2 changed files
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
src/main/kotlin/app/revanced/patches/all/shortcut/sharetargets/RemoveShareTargetsPatch.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package app.revanced.patches.all.shortcut.sharetargets | ||
|
||
import app.revanced.patcher.data.ResourceContext | ||
import app.revanced.patcher.patch.ResourcePatch | ||
import app.revanced.patcher.patch.annotation.Patch | ||
import app.revanced.util.asSequence | ||
import app.revanced.util.getNode | ||
import org.w3c.dom.Element | ||
import java.io.FileNotFoundException | ||
import java.util.logging.Logger | ||
|
||
@Patch( | ||
name = "Remove share targets", | ||
description = "Removes share targets like directly sharing to a frequent contact.", | ||
use = false, | ||
) | ||
@Suppress("unused") | ||
object RemoveShareTargetsPatch : ResourcePatch() { | ||
override fun execute(context: ResourceContext) { | ||
try { | ||
context.document["res/xml/shortcuts.xml"] | ||
} catch (_: FileNotFoundException) { | ||
return Logger.getLogger(this::class.java.name).warning("The app has no shortcuts") | ||
}.use { document -> | ||
val rootNode = document.getNode("shortcuts") as? Element ?: return@use | ||
|
||
document.getElementsByTagName("share-target").asSequence().forEach { | ||
rootNode.removeChild(it) | ||
} | ||
} | ||
} | ||
} |