Compare commits

..

2 Commits

Author SHA1 Message Date
semantic-release-bot
1b21f5d4ab chore: Release v1.26.0-dev.19 [skip ci]
# app [1.26.0-dev.19](https://github.com/ReVanced/revanced-manager/compare/v1.26.0-dev.18...v1.26.0-dev.19) (2026-01-08)

### Bug Fixes

* **locales:** use buildconfig instead of generating kt file ([72b1db9](72b1db9a2f))
2026-01-08 22:35:21 +00:00
Ax333l
72b1db9a2f fix(locales): use buildconfig instead of generating kt file 2026-01-08 23:27:02 +01:00
4 changed files with 38 additions and 54 deletions

View File

@@ -1,3 +1,10 @@
# app [1.26.0-dev.19](https://github.com/ReVanced/revanced-manager/compare/v1.26.0-dev.18...v1.26.0-dev.19) (2026-01-08)
### Bug Fixes
* **locales:** use buildconfig instead of generating kt file ([72b1db9](https://github.com/ReVanced/revanced-manager/commit/72b1db9a2f33ab5d5fffd8ba83c05901eff19bea))
# app [1.26.0-dev.18](https://github.com/ReVanced/revanced-manager/compare/v1.26.0-dev.17...v1.26.0-dev.18) (2026-01-08)

View File

@@ -143,6 +143,19 @@ android {
(preRelease?.substringAfterLast('.')?.toInt() ?: 99)
}
vectorDrawables.useSupportLibrary = true
val resDir = file("src/main/res")
val locales = resDir.listFiles()
.orEmpty()
//noinspection WrongGradleMethod
.filter { it.isDirectory && it.name.matches(Regex("values-[a-z]{2}(-r[A-Z]{2})?")) }
//noinspection WrongGradleMethod
.map { it.name.removePrefix("values-").replace("-r", "-") }
.sorted()
//noinspection WrongGradleMethod
.joinToString(prefix = "{", separator = ",", postfix = "}") { "\"$it\"" }
buildConfigField("String[]", "SUPPORTED_LOCALES", locales)
}
buildTypes {
@@ -230,10 +243,8 @@ android {
buildConfig = true
}
android {
androidResources {
generateLocaleConfig = true
}
androidResources {
generateLocaleConfig = true
}
externalNativeBuild {
@@ -242,8 +253,6 @@ android {
version = "3.22.1"
}
}
sourceSets["main"].kotlin.srcDir(layout.buildDirectory.dir("generated/source/locales"))
}
kotlin {
@@ -251,46 +260,6 @@ kotlin {
}
tasks {
val generateSupportedLocales by registering {
description = "Generate list of supported locales from resource directories"
val resDir = file("src/main/res")
val outputDir = layout.buildDirectory.dir("generated/source/locales")
inputs.dir(resDir)
outputs.dir(outputDir)
doLast {
val locales = resDir.listFiles()
.orEmpty()
.filter { it.isDirectory && it.name.matches(Regex("values-[a-z]{2}(-r[A-Z]{2})?")) }
.map { it.name.removePrefix("values-").replace("-r", "-") }
.sorted()
.joinToString("\n ") { "Locale.forLanguageTag(\"$it\")," }
val output = outputDir.get().asFile.resolve("app/revanced/manager/util/GeneratedLocales.kt")
output.parentFile.mkdirs()
output.writeText(
"""
|package app.revanced.manager.util
|
|import java.util.Locale
|
|object GeneratedLocales {
| val SUPPORTED_LOCALES = listOf(
| Locale.ENGLISH,$locales
| )
|}
""".trimMargin()
)
}
}
preBuild {
dependsOn(generateSupportedLocales)
}
// Needed by gradle-semantic-release-plugin.
// Tracking: https://github.com/KengoTODA/gradle-semantic-release-plugin/issues/435.
val publish by registering {

View File

@@ -1 +1 @@
version = 1.26.0-dev.18
version = 1.26.0-dev.19

View File

@@ -1,21 +1,22 @@
package app.revanced.manager.util
import android.app.LocaleConfig
import android.content.Context
import android.os.Build
import android.os.LocaleList
import androidx.appcompat.app.AppCompatDelegate
import androidx.core.os.LocaleListCompat
import app.revanced.manager.BuildConfig
import java.util.Locale
object SupportedLocales {
fun getSupportedLocales(context: Context): List<Locale> {
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
runCatching {
android.app.LocaleConfig(context).supportedLocales?.toList()
}.getOrNull() ?: GeneratedLocales.SUPPORTED_LOCALES
} else {
GeneratedLocales.SUPPORTED_LOCALES
}
var result: List<Locale>? = null
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) result = runCatching {
LocaleConfig(context).supportedLocales?.toList()
}.getOrNull()
return result ?: generated
}
fun getCurrentLocale(): Locale? =
@@ -29,4 +30,11 @@ object SupportedLocales {
locale.getDisplayName(locale).replaceFirstChar { it.uppercase(locale) }
private fun LocaleList.toList() = (0 until size()).map { get(it) }
private val generated by lazy {
listOf(
Locale.ENGLISH,
*BuildConfig.SUPPORTED_LOCALES.map(Locale::forLanguageTag).toTypedArray()
)
}
}