6.3.2 - Fix - 检查更新时无法获取版本信息

This commit is contained in:
SuperMonster003
2023-07-07 01:41:38 +08:00
parent 3ebc85fbe5
commit 426a234175
2 changed files with 8 additions and 13 deletions

View File

@@ -33,21 +33,16 @@ class VersionInfo : ExtendedVersionInfo {
val versionNameKey = str(R.string.property_key_app_version_name)
val versionCodeKey = str(R.string.property_key_app_version_code)
val regexVersionName = "$versionNameKey(</\\w+>)?=.+".toRegex()
val regexVersionCode = "$versionCodeKey(</\\w+>)?=.+".toRegex()
val regexVersionName = "$versionNameKey(?:</\\w+>)?=([\\w.]+)".toRegex()
val regexVersionCode = "$versionCodeKey(?:</\\w+>)?=(\\d+)".toRegex()
for (string in propertiesFileRawString.split("\n".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()) {
for (string in propertiesFileRawString.split("\\n".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()) {
if (versionName.isEmpty() && string.contains(regexVersionName)) {
string.split("$versionNameKey(</\\w+>)?=".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()[1]
.replace("<.+?>".toRegex(), "")
.takeIf { it.isNotEmpty() }?.let { versionName = it }
versionName = regexVersionName.find(string)?.groupValues?.get(1) ?: ""
Log.d(TAG, "versionName: $versionName")
}
if (versionCode <= 0 && string.contains(regexVersionCode)) {
string.split("$versionCodeKey(</\\w+>)?=".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()[1]
.replace("<.+?>".toRegex(), "")
.toInt()
.takeIf { it > 0 }?.let { versionCode = it }
versionCode = regexVersionCode.find(string)?.groupValues?.get(1)?.toInt() ?: -1
Log.d(TAG, "versionCode: $versionCode")
}
if (versionName.isNotEmpty() && versionCode > 0) {