mirror of
https://github.com/revanced/revanced-patcher.git
synced 2025-05-04 06:34:24 +02:00
refactor: add PatchOption.PathOption
This commit is contained in:
parent
288d50a8b4
commit
53e807dec1
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
package app.revanced.patcher.patch
|
package app.revanced.patcher.patch
|
||||||
|
|
||||||
|
import java.nio.file.Path
|
||||||
import kotlin.reflect.KProperty
|
import kotlin.reflect.KProperty
|
||||||
|
|
||||||
class NoSuchOptionException(val option: String) : Exception("No such option: $option")
|
class NoSuchOptionException(val option: String) : Exception("No such option: $option")
|
||||||
@ -189,4 +190,19 @@ sealed class PatchOption<T>(
|
|||||||
) : ListOption<Int>(
|
) : ListOption<Int>(
|
||||||
key, default, options, title, description, required, validator
|
key, default, options, title, description, required, validator
|
||||||
)
|
)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A [PatchOption] representing a [Path].
|
||||||
|
* @see PatchOption
|
||||||
|
*/
|
||||||
|
class PathOption<T: Path>(
|
||||||
|
key: String,
|
||||||
|
default: T?,
|
||||||
|
title: String,
|
||||||
|
description: String,
|
||||||
|
required: Boolean = false,
|
||||||
|
validator: (T?) -> Boolean = { true }
|
||||||
|
) : PatchOption<T>(
|
||||||
|
key, default, title, description, required, validator
|
||||||
|
)
|
||||||
}
|
}
|
@ -32,6 +32,7 @@ import org.jf.dexlib2.immutable.reference.ImmutableFieldReference
|
|||||||
import org.jf.dexlib2.immutable.reference.ImmutableStringReference
|
import org.jf.dexlib2.immutable.reference.ImmutableStringReference
|
||||||
import org.jf.dexlib2.immutable.value.ImmutableFieldEncodedValue
|
import org.jf.dexlib2.immutable.value.ImmutableFieldEncodedValue
|
||||||
import org.jf.dexlib2.util.Preconditions
|
import org.jf.dexlib2.util.Preconditions
|
||||||
|
import java.io.File
|
||||||
|
|
||||||
@Patch
|
@Patch
|
||||||
@Name("example-bytecode-patch")
|
@Name("example-bytecode-patch")
|
||||||
@ -177,5 +178,8 @@ class ExampleBytecodePatch : BytecodePatch(listOf(ExampleFingerprint)) {
|
|||||||
PatchOption.IntListOption(
|
PatchOption.IntListOption(
|
||||||
"key4", 1, listOf(1, 2, 3), "title", "description"
|
"key4", 1, listOf(1, 2, 3), "title", "description"
|
||||||
),
|
),
|
||||||
|
PatchOption.PathOption(
|
||||||
|
"key5", File("test.txt").toPath(), "title", "description"
|
||||||
|
),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user