diff --git a/patches/src/main/kotlin/app/revanced/patches/myfitnesspal/ads/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/myfitnesspal/ads/Fingerprints.kt index 160e2db27..92a1e2ad5 100644 --- a/patches/src/main/kotlin/app/revanced/patches/myfitnesspal/ads/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/myfitnesspal/ads/Fingerprints.kt @@ -1,19 +1,22 @@ package app.revanced.patches.myfitnesspal.ads -import app.revanced.patcher.fingerprint +import app.revanced.patcher.BytecodePatchContextMethodMatching.gettingFirstMutableMethodDeclaratively +import app.revanced.patcher.accessFlags +import app.revanced.patcher.definingClass +import app.revanced.patcher.name +import app.revanced.patcher.patch.BytecodePatchContext +import app.revanced.patcher.returnType import com.android.tools.smali.dexlib2.AccessFlags -internal val isPremiumUseCaseImplFingerprint = fingerprint { +internal val BytecodePatchContext.isPremiumUseCaseImplMethod by gettingFirstMutableMethodDeclaratively { accessFlags(AccessFlags.PUBLIC) - custom { method, classDef -> - classDef.endsWith("IsPremiumUseCaseImpl;") && method.name == "doWork" - } + definingClass("IsPremiumUseCaseImpl;") + name("doWork") } -internal val mainActivityNavigateToNativePremiumUpsellFingerprint = fingerprint { +internal val BytecodePatchContext.mainActivityNavigateToNativePremiumUpsellMethod by gettingFirstMutableMethodDeclaratively { accessFlags(AccessFlags.PRIVATE, AccessFlags.FINAL) - returns("V") - custom { method, classDef -> - classDef.endsWith("MainActivity;") && method.name == "navigateToNativePremiumUpsell" - } + returnType("V") + definingClass("MainActivity;") + name("navigateToNativePremiumUpsell") } diff --git a/patches/src/main/kotlin/app/revanced/patches/myfitnesspal/ads/HideAdsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/myfitnesspal/ads/HideAdsPatch.kt index f32015c62..43bc2fb62 100644 --- a/patches/src/main/kotlin/app/revanced/patches/myfitnesspal/ads/HideAdsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/myfitnesspal/ads/HideAdsPatch.kt @@ -1,18 +1,17 @@ package app.revanced.patches.myfitnesspal.ads import app.revanced.patcher.extensions.replaceInstructions -import app.revanced.patcher.patch.bytecodePatch +import app.revanced.patcher.patch.creatingBytecodePatch -@Suppress("unused") -val hideAdsPatch = bytecodePatch( - name = "Hide ads", - description = "Hides most of the ads across the app.", +@Suppress("unused", "ObjectPropertyName") +val `Hide ads` by creatingBytecodePatch( + description = "Hides most of the ads across the app." ) { compatibleWith("com.myfitnesspal.android"("24.14.2")) apply { // Overwrite the premium status specifically for ads. - isPremiumUseCaseImplFingerprint.method.replaceInstructions( + isPremiumUseCaseImplMethod.replaceInstructions( 0, """ sget-object v0, Ljava/lang/Boolean;->TRUE:Ljava/lang/Boolean; @@ -22,7 +21,7 @@ val hideAdsPatch = bytecodePatch( // Prevent the premium upsell dialog from showing when the main activity is launched. // In other places that are premium-only the dialog will still show. - mainActivityNavigateToNativePremiumUpsellFingerprint.method.replaceInstructions( + mainActivityNavigateToNativePremiumUpsellMethod.replaceInstructions( 0, "return-void", )