Skip to content

Commit a30a849

Browse files
refactor: Extract shared patch names/descriptions (#6056)
1 parent 603025a commit a30a849

File tree

10 files changed

+50
-18
lines changed

10 files changed

+50
-18
lines changed

patches/src/main/kotlin/app/revanced/patches/finanzonline/detection/root/RootDetectionPatch.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@ package app.revanced.patches.finanzonline.detection.root
22

33
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
44
import app.revanced.patcher.patch.bytecodePatch
5+
import app.revanced.patches.shared.PATCH_DESCRIPTION_REMOVE_ROOT_DETECTION
6+
import app.revanced.patches.shared.PATCH_NAME_REMOVE_ROOT_DETECTION
57

68
@Suppress("unused")
79
val rootDetectionPatch = bytecodePatch(
8-
name = "Remove root detection",
9-
description = "Removes the check for root permissions.",
10+
name = PATCH_NAME_REMOVE_ROOT_DETECTION,
11+
description = PATCH_DESCRIPTION_REMOVE_ROOT_DETECTION,
1012
) {
1113
compatibleWith("at.gv.bmf.bmf2go")
1214

patches/src/main/kotlin/app/revanced/patches/idaustria/detection/root/RootDetectionPatch.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
package app.revanced.patches.idaustria.detection.root
22

33
import app.revanced.patcher.patch.bytecodePatch
4+
import app.revanced.patches.shared.PATCH_DESCRIPTION_REMOVE_ROOT_DETECTION
5+
import app.revanced.patches.shared.PATCH_NAME_REMOVE_ROOT_DETECTION
46
import app.revanced.util.returnEarly
57

68
@Suppress("unused")
79
val rootDetectionPatch = bytecodePatch(
8-
name = "Remove root detection",
9-
description = "Removes the check for root permissions and unlocked bootloader.",
10+
name = PATCH_NAME_REMOVE_ROOT_DETECTION,
11+
description = PATCH_DESCRIPTION_REMOVE_ROOT_DETECTION
1012
) {
1113
compatibleWith("at.gv.oe.app")
1214

patches/src/main/kotlin/app/revanced/patches/instagram/misc/privacy/SanitizeSharingLinksPatch.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
44
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
55
import app.revanced.patcher.patch.bytecodePatch
66
import app.revanced.patches.instagram.misc.extension.sharedExtensionPatch
7+
import app.revanced.patches.shared.PATCH_DESCRIPTION_SANITIZE_SHARING_LINKS
8+
import app.revanced.patches.shared.PATCH_NAME_SANITIZE_SHARING_LINKS
79
import app.revanced.util.indexOfFirstInstructionOrThrow
810
import com.android.tools.smali.dexlib2.Opcode
911
import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction
@@ -13,8 +15,8 @@ private const val EXTENSION_CLASS_DESCRIPTOR =
1315

1416
@Suppress("unused")
1517
val sanitizeSharingLinksPatch = bytecodePatch(
16-
name = "Sanitize sharing links",
17-
description = "Removes the tracking query parameters from shared links.",
18+
name = PATCH_NAME_SANITIZE_SHARING_LINKS,
19+
description = PATCH_DESCRIPTION_SANITIZE_SHARING_LINKS,
1820
) {
1921
compatibleWith("com.instagram.android")
2022

patches/src/main/kotlin/app/revanced/patches/orfon/detection/root/RemoveRootDetectionPatch.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
package app.revanced.patches.orfon.detection.root
22

33
import app.revanced.patcher.patch.bytecodePatch
4+
import app.revanced.patches.shared.PATCH_DESCRIPTION_REMOVE_ROOT_DETECTION
5+
import app.revanced.patches.shared.PATCH_NAME_REMOVE_ROOT_DETECTION
46
import app.revanced.util.returnEarly
57

68
@Suppress("unused")
79
val removeRootDetectionPatch = bytecodePatch(
8-
name = "Remove root detection",
9-
description = "Removes the check for root permissions.",
10+
name = PATCH_NAME_REMOVE_ROOT_DETECTION,
11+
description = PATCH_DESCRIPTION_REMOVE_ROOT_DETECTION
1012
) {
1113
compatibleWith("com.nousguide.android.orftvthek")
1214

patches/src/main/kotlin/app/revanced/patches/reddit/misc/tracking/url/SanitizeUrlQueryPatch.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@ package app.revanced.patches.reddit.misc.tracking.url
22

33
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
44
import app.revanced.patcher.patch.bytecodePatch
5+
import app.revanced.patches.shared.PATCH_DESCRIPTION_SANITIZE_SHARING_LINKS
6+
import app.revanced.patches.shared.PATCH_NAME_SANITIZE_SHARING_LINKS
57

68
@Suppress("unused")
79
val sanitizeUrlQueryPatch = bytecodePatch(
8-
name = "Sanitize sharing links",
9-
description = "Removes the tracking query parameters from shared links.",
10+
name = PATCH_NAME_SANITIZE_SHARING_LINKS,
11+
description = PATCH_DESCRIPTION_SANITIZE_SHARING_LINKS,
1012
) {
1113
compatibleWith("com.reddit.frontpage")
1214

patches/src/main/kotlin/app/revanced/patches/serviceportalbund/detection/root/RootDetectionPatch.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@ package app.revanced.patches.serviceportalbund.detection.root
22

33
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
44
import app.revanced.patcher.patch.bytecodePatch
5+
import app.revanced.patches.shared.PATCH_DESCRIPTION_REMOVE_ROOT_DETECTION
6+
import app.revanced.patches.shared.PATCH_NAME_REMOVE_ROOT_DETECTION
57

68
@Suppress("unused")
79
val rootDetectionPatch = bytecodePatch(
8-
name = "Remove root detection",
9-
description = "Removes the check for root permissions and unlocked bootloader.",
10+
name = PATCH_NAME_REMOVE_ROOT_DETECTION,
11+
description = PATCH_DESCRIPTION_REMOVE_ROOT_DETECTION
1012
) {
1113
compatibleWith("at.gv.bka.serviceportal")
1214

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package app.revanced.patches.shared
2+
3+
//
4+
// Names and descriptions used by different patches implementing the same feature.
5+
//
6+
7+
internal const val PATCH_NAME_REMOVE_ROOT_DETECTION = "Remove root detection"
8+
internal const val PATCH_DESCRIPTION_REMOVE_ROOT_DETECTION = "Removes the check for root permissions and unlocked bootloader."
9+
10+
internal const val PATCH_NAME_SANITIZE_SHARING_LINKS = "Sanitize sharing links"
11+
internal const val PATCH_DESCRIPTION_SANITIZE_SHARING_LINKS = "Removes the tracking query parameters from shared links."

patches/src/main/kotlin/app/revanced/patches/shared/misc/privacy/SanitizeSharingLinksPatch.kt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import app.revanced.patcher.patch.bytecodePatch
1010
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
1111
import app.revanced.patches.all.misc.resources.addResources
1212
import app.revanced.patches.all.misc.resources.addResourcesPatch
13+
import app.revanced.patches.shared.PATCH_DESCRIPTION_SANITIZE_SHARING_LINKS
14+
import app.revanced.patches.shared.PATCH_NAME_SANITIZE_SHARING_LINKS
1315
import app.revanced.patches.shared.misc.settings.preference.BasePreferenceScreen
1416
import app.revanced.patches.shared.misc.settings.preference.PreferenceCategory
1517
import app.revanced.patches.shared.misc.settings.preference.PreferenceScreenPreference.Sorting
@@ -20,14 +22,17 @@ import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction
2022
private const val EXTENSION_CLASS_DESCRIPTOR =
2123
"Lapp/revanced/extension/shared/patches/SanitizeSharingLinksPatch;"
2224

25+
/**
26+
* Patch shared by YouTube and YT Music.
27+
*/
2328
internal fun sanitizeSharingLinksPatch(
2429
block: BytecodePatchBuilder.() -> Unit = {},
2530
executeBlock: BytecodePatchContext.() -> Unit = {},
2631
preferenceScreen: BasePreferenceScreen.Screen,
2732
replaceMusicLinksWithYouTube: Boolean = false
2833
) = bytecodePatch(
29-
name = "Sanitize sharing links",
30-
description = "Adds an option to remove the tracking query parameter from shared links.",
34+
name = PATCH_NAME_SANITIZE_SHARING_LINKS,
35+
description = PATCH_DESCRIPTION_SANITIZE_SHARING_LINKS,
3136
) {
3237
block()
3338

patches/src/main/kotlin/app/revanced/patches/spotify/misc/privacy/SanitizeSharingLinksPatch.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ package app.revanced.patches.spotify.misc.privacy
33
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
44
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
55
import app.revanced.patcher.patch.bytecodePatch
6+
import app.revanced.patches.shared.PATCH_DESCRIPTION_SANITIZE_SHARING_LINKS
7+
import app.revanced.patches.shared.PATCH_NAME_SANITIZE_SHARING_LINKS
68
import app.revanced.patches.spotify.misc.extension.sharedExtensionPatch
79
import app.revanced.util.getReference
810
import app.revanced.util.indexOfFirstInstructionOrThrow
@@ -15,8 +17,8 @@ private const val EXTENSION_CLASS_DESCRIPTOR =
1517

1618
@Suppress("unused")
1719
val sanitizeSharingLinksPatch = bytecodePatch(
18-
name = "Sanitize sharing links",
19-
description = "Removes the tracking query parameters from shared links.",
20+
name = PATCH_NAME_SANITIZE_SHARING_LINKS,
21+
description = PATCH_DESCRIPTION_SANITIZE_SHARING_LINKS,
2022
) {
2123
compatibleWith("com.spotify.music")
2224

patches/src/main/kotlin/app/revanced/patches/twitter/misc/links/SanitizeSharingLinksPatch.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@ package app.revanced.patches.twitter.misc.links
22

33
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
44
import app.revanced.patcher.patch.bytecodePatch
5+
import app.revanced.patches.shared.PATCH_DESCRIPTION_SANITIZE_SHARING_LINKS
6+
import app.revanced.patches.shared.PATCH_NAME_SANITIZE_SHARING_LINKS
57

68
@Suppress("unused")
79
val sanitizeSharingLinksPatch = bytecodePatch(
8-
name = "Sanitize sharing links",
9-
description = "Removes the tracking query parameters from links before they are shared.",
10+
name = PATCH_NAME_SANITIZE_SHARING_LINKS,
11+
description = PATCH_DESCRIPTION_SANITIZE_SHARING_LINKS,
1012
) {
1113
compatibleWith(
1214
"com.twitter.android"(

0 commit comments

Comments
 (0)