From 69e4a490659ebc4fb4bf46148634f4b064ef1713 Mon Sep 17 00:00:00 2001 From: Palm Date: Thu, 6 Jul 2023 23:17:51 +0700 Subject: [PATCH] feat: remove `Path` option (#202) BREAKING CHANGE: This removes the previously available `Path` option --- .../app/revanced/patcher/patch/PatchOption.kt | 16 ---------------- .../revanced/patcher/patch/PatchOptionsTest.kt | 6 ------ .../usage/bytecode/ExampleBytecodePatch.kt | 8 +------- 3 files changed, 1 insertion(+), 29 deletions(-) diff --git a/src/main/kotlin/app/revanced/patcher/patch/PatchOption.kt b/src/main/kotlin/app/revanced/patcher/patch/PatchOption.kt index 9636f64..cfb0c1c 100644 --- a/src/main/kotlin/app/revanced/patcher/patch/PatchOption.kt +++ b/src/main/kotlin/app/revanced/patcher/patch/PatchOption.kt @@ -229,20 +229,4 @@ sealed class PatchOption( ) : ListOption( key, default, options, title, description, required, validator ) - - /** - * A [PatchOption] representing a [Path], backed by a [String]. - * The validator passes a [String], if you need a [Path] you will have to convert it yourself. - * @see PatchOption - */ - class PathOption( - key: String, - default: Path?, - title: String, - description: String, - required: Boolean = false, - validator: (String?) -> Boolean = { true } - ) : PatchOption( - key, default?.pathString, title, description, required, validator - ) } diff --git a/src/test/kotlin/app/revanced/patcher/patch/PatchOptionsTest.kt b/src/test/kotlin/app/revanced/patcher/patch/PatchOptionsTest.kt index d83e9d8..125b59b 100644 --- a/src/test/kotlin/app/revanced/patcher/patch/PatchOptionsTest.kt +++ b/src/test/kotlin/app/revanced/patcher/patch/PatchOptionsTest.kt @@ -3,8 +3,6 @@ package app.revanced.patcher.patch import app.revanced.patcher.usage.bytecode.ExampleBytecodePatch import org.junit.jupiter.api.Test import org.junit.jupiter.api.assertThrows -import kotlin.io.path.Path -import kotlin.io.path.pathString import kotlin.test.assertNotEquals internal class PatchOptionsTest { @@ -35,10 +33,6 @@ internal class PatchOptionsTest { println(choice) } } - - is PatchOption.PathOption -> { - option.value = Path("test.txt").pathString - } } } val option = options.get("key1") diff --git a/src/test/kotlin/app/revanced/patcher/usage/bytecode/ExampleBytecodePatch.kt b/src/test/kotlin/app/revanced/patcher/usage/bytecode/ExampleBytecodePatch.kt index 0add464..f3bf0fc 100644 --- a/src/test/kotlin/app/revanced/patcher/usage/bytecode/ExampleBytecodePatch.kt +++ b/src/test/kotlin/app/revanced/patcher/usage/bytecode/ExampleBytecodePatch.kt @@ -5,8 +5,8 @@ import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels -import app.revanced.patcher.extensions.or import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction +import app.revanced.patcher.extensions.or import app.revanced.patcher.patch.* import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch @@ -29,7 +29,6 @@ import org.jf.dexlib2.immutable.reference.ImmutableFieldReference import org.jf.dexlib2.immutable.reference.ImmutableStringReference import org.jf.dexlib2.immutable.value.ImmutableFieldEncodedValue import org.jf.dexlib2.util.Preconditions -import kotlin.io.path.Path @Patch @Name("example-bytecode-patch") @@ -193,10 +192,5 @@ class ExampleBytecodePatch : BytecodePatch(listOf(ExampleFingerprint)) { "key5", null, "title", "description", true ) ) - private var key6 by option( - PatchOption.PathOption( - "key6", Path("test.txt"), "title", "description", true - ) - ) } }