refactor: adapt patcher 4.0.0 changes

This commit is contained in:
Sculas 2022-09-07 21:14:03 +02:00
parent 50cd62f64f
commit fd76c45098
No known key found for this signature in database
GPG Key ID: 1530BFF96D1EEB89

View File

@ -53,8 +53,6 @@ class CustomBrandingPatch : ResourcePatch() {
} }
// Name branding // Name branding
val appName: String by options[keyAppName]
val manifest = data["AndroidManifest.xml"] val manifest = data["AndroidManifest.xml"]
manifest.writeText( manifest.writeText(
manifest.readText() manifest.readText()
@ -67,24 +65,7 @@ class CustomBrandingPatch : ResourcePatch() {
return PatchResultSuccess() return PatchResultSuccess()
} }
override val options = PatchOptions(
PatchOption.StringOption(
key = keyAppName,
default = "YouTube ReVanced",
title = "Application Name",
description = "The name of the application it will show on your home screen.",
required = true
),
PatchOption.StringOption(
key = keyAppIconPath,
default = null,
title = "Application Icon Path",
description = "A path to the icon of the application."
)
)
private fun getIconStream(iconPath: String): InputStream? { private fun getIconStream(iconPath: String): InputStream? {
val appIconPath: String? by options[keyAppIconPath]
if (appIconPath == null) { if (appIconPath == null) {
return this.javaClass.classLoader.getResourceAsStream(iconPath) return this.javaClass.classLoader.getResourceAsStream(iconPath)
} }
@ -93,8 +74,24 @@ class CustomBrandingPatch : ResourcePatch() {
return FileInputStream(file) return FileInputStream(file)
} }
private companion object { companion object : OptionsContainer() {
private const val keyAppName = "appName" private var appName: String by option(
private const val keyAppIconPath = "appIconPath" PatchOption.StringOption(
key = "appName",
default = "YouTube ReVanced",
title = "Application Name",
description = "The name of the application it will show on your home screen.",
required = true
)
)
private var appIconPath: String? by option(
PatchOption.StringOption(
key = "appIconPath",
default = null,
title = "Application Icon Path",
description = "A path to the icon of the application."
)
)
} }
} }