6.7.0 - Alpha6 - 升级并适配 Android SDK 版本 35 -> 36

This commit is contained in:
SuperMonster003
2025-09-26 16:49:12 +08:00
parent aced2c4150
commit ecb1c57ebc
24 changed files with 226 additions and 185 deletions

View File

@@ -34,7 +34,10 @@ public class Type {
public Type(final @NonNull TypeHeader header) {
this.id = header.getId();
final ResTableConfig config = header.config;
this.locale = new Locale(config.getLanguage(), config.getCountry());
this.locale = new Locale.Builder()
.setLanguage(config.getLanguage())
.setRegion(config.getCountry())
.build();
this.density = config.getDensity();
}

View File

@@ -1,49 +1,36 @@
package net.dongliu.apk.parser.utils
import java.util.Locale
import java.util.*
/**
* @author dongliu
*
* Modified by SuperMonster003 as of Sep 25, 2025.
*/
object Locales {
/**
* when do localize, any locale will match this
*/
@JvmField
val any = Locale("", "")
val any: Locale = Locale.Builder()
.setLanguage("")
.setRegion("")
.build()
/**
* How much the given locale match the expected locale.
*/
@JvmStatic
fun match(locale: Locale?, targetLocale: Locale): Int {
if (locale == null) {
return -1
}
return when {
locale.language == targetLocale.language -> {
when {
locale.country == targetLocale.country -> {
3
}
targetLocale.country.isEmpty() -> {
2
}
else -> {
0
}
}
}
targetLocale.country.isEmpty() || targetLocale.language.isEmpty() -> {
1
}
else -> {
0
}
fun match(locale: Locale?, targetLocale: Locale): Int = when {
locale == null -> -1
locale.language == targetLocale.language -> when {
locale.country == targetLocale.country -> 3
targetLocale.country.isEmpty() -> 2
else -> 0
}
targetLocale.country.isEmpty() || targetLocale.language.isEmpty() -> 1
else -> 0
}
}