Add support to sourceName in multisrc generators (#11857)
* Add support to sourceName in multisrc generators. * Fix missing attribute in MMRCMS.
This commit is contained in:
parent
e3cd553ee6
commit
0322746770
|
@ -12,7 +12,16 @@ class MMRCMSGenerator : ThemeSourceGenerator {
|
|||
override val baseVersionCode: Int = MMRCMSSources.version
|
||||
|
||||
override val sources = MMRCMSSources.sourceList.map {
|
||||
SingleLang(it.name, it.baseUrl, it.lang, it.isNsfw, it.className, it.pkgName, it.overrideVersionCode)
|
||||
SingleLang(
|
||||
it.name,
|
||||
it.baseUrl,
|
||||
it.lang,
|
||||
it.isNsfw,
|
||||
it.className,
|
||||
it.pkgName,
|
||||
it.sourceName,
|
||||
it.overrideVersionCode
|
||||
)
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
|
|
@ -10,6 +10,7 @@ class MMRCMSSources {
|
|||
abstract val isNsfw: Boolean
|
||||
abstract val className: String
|
||||
abstract val pkgName: String
|
||||
abstract val sourceName: String
|
||||
abstract val overrideVersionCode: Int
|
||||
|
||||
data class Single(
|
||||
|
@ -19,6 +20,7 @@ class MMRCMSSources {
|
|||
override val isNsfw: Boolean = false,
|
||||
override val className: String = name.replace(" ", ""),
|
||||
override val pkgName: String = className.toLowerCase(Locale.ENGLISH),
|
||||
override val sourceName: String = name,
|
||||
override val overrideVersionCode: Int = 0,
|
||||
) : SourceData()
|
||||
|
||||
|
@ -29,6 +31,7 @@ class MMRCMSSources {
|
|||
override val isNsfw: Boolean = false,
|
||||
override val className: String = name.replace(" ", "") + "Factory",
|
||||
override val pkgName: String = className.substringBefore("Factory").toLowerCase(Locale.ENGLISH),
|
||||
override val sourceName: String = name,
|
||||
override val overrideVersionCode: Int = 0,
|
||||
) : SourceData()
|
||||
}
|
||||
|
|
|
@ -196,11 +196,11 @@ ${placeholders.map { "${" ".repeat(28)}${it.key}: \"${it.value}\""}.joinToString
|
|||
fun factoryClassText(): String {
|
||||
return when (source) {
|
||||
is ThemeSourceData.SingleLang -> {
|
||||
"""class ${source.className} : $themeClass("${source.name}", "${source.baseUrl}", "${source.lang}")"""
|
||||
"""class ${source.className} : $themeClass("${source.sourceName}", "${source.baseUrl}", "${source.lang}")"""
|
||||
}
|
||||
is ThemeSourceData.MultiLang -> {
|
||||
val sourceClasses = source.langs.map { lang ->
|
||||
"""$themeClass("${source.name}", "${source.baseUrl}", "$lang")"""
|
||||
"""$themeClass("${source.sourceName}", "${source.baseUrl}", "$lang")"""
|
||||
}
|
||||
|
||||
"""
|
||||
|
@ -243,6 +243,14 @@ sealed class ThemeSourceData {
|
|||
abstract val className: String
|
||||
abstract val pkgName: String
|
||||
|
||||
/**
|
||||
* Override it if for some reason the name attribute inside the source class
|
||||
* should be different from the extension name. Useful in cases where the
|
||||
* extension name should be romanized and the source name should be the one
|
||||
* in the source language. Defaults to the extension name if not specified.
|
||||
*/
|
||||
abstract val sourceName: String
|
||||
|
||||
/**
|
||||
* overrideVersionCode defaults to 0, if a source changes their source override code or
|
||||
* a previous existing source suddenly needs source code overrides, overrideVersionCode
|
||||
|
@ -260,6 +268,7 @@ sealed class ThemeSourceData {
|
|||
override val isNsfw: Boolean = false,
|
||||
override val className: String = name.replace(" ", ""),
|
||||
override val pkgName: String = className.toLowerCase(Locale.ENGLISH),
|
||||
override val sourceName: String = name,
|
||||
override val overrideVersionCode: Int = 0,
|
||||
) : ThemeSourceData()
|
||||
|
||||
|
@ -270,6 +279,7 @@ sealed class ThemeSourceData {
|
|||
override val isNsfw: Boolean = false,
|
||||
override val className: String = name.replace(" ", "") + "Factory",
|
||||
override val pkgName: String = className.substringBefore("Factory").toLowerCase(Locale.ENGLISH),
|
||||
override val sourceName: String = name,
|
||||
override val overrideVersionCode: Int = 0,
|
||||
) : ThemeSourceData()
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue