mirror of
https://github.com/null2264/yokai.git
synced 2025-06-21 10:44:42 +00:00
enhance: Nightly flag
This commit is contained in:
parent
738fc9ed4b
commit
97cc80c967
2 changed files with 24 additions and 9 deletions
|
@ -45,8 +45,11 @@ android {
|
|||
buildConfigField("String", "BUILD_TIME", "\"${getBuildTime()}\"")
|
||||
buildConfigField("Boolean", "INCLUDE_UPDATER", "false")
|
||||
buildConfigField("Boolean", "BETA", "false")
|
||||
buildConfigField("Boolean", "NIGHTLY", "false")
|
||||
|
||||
ndk {
|
||||
// False positive, we have x86 abi support
|
||||
//noinspection ChromeOsAbiSupport
|
||||
abiFilters += supportedAbis
|
||||
}
|
||||
externalNativeBuild {
|
||||
|
@ -60,6 +63,8 @@ android {
|
|||
abi {
|
||||
isEnable = true
|
||||
reset()
|
||||
// False positive, we have x86 abi support
|
||||
//noinspection ChromeOsAbiSupport
|
||||
include(*supportedAbis.toTypedArray())
|
||||
isUniversalApk = true
|
||||
}
|
||||
|
@ -76,9 +81,17 @@ android {
|
|||
isMinifyEnabled = true
|
||||
proguardFiles("proguard-android-optimize.txt", "proguard-rules.pro")
|
||||
}
|
||||
create("beta") {
|
||||
initWith(getByName("release"))
|
||||
buildConfigField("boolean", "BETA", "true")
|
||||
|
||||
matchingFallbacks.add("release")
|
||||
versionNameSuffix = "-b${getCommitCount()}"
|
||||
}
|
||||
create("nightly") {
|
||||
initWith(getByName("release"))
|
||||
buildConfigField("boolean", "BETA", "true")
|
||||
buildConfigField("boolean", "NIGHTLY", "true")
|
||||
|
||||
signingConfig = signingConfigs.getByName("debug")
|
||||
matchingFallbacks.add("release")
|
||||
|
|
|
@ -94,11 +94,15 @@ class AppUpdateChecker {
|
|||
val isNewVersionNightly = newSemVer.size == 1
|
||||
val oldSemVer = oldPreReleaseVer.first().split(".").map { it.toInt() }
|
||||
|
||||
oldSemVer.mapIndexed { index, i ->
|
||||
if (!isNewVersionNightly && newSemVer.getOrElse(index) { i } > i) {
|
||||
return true
|
||||
} else if (newSemVer.getOrElse(index) { i } < i) {
|
||||
return false
|
||||
// Nightly doesn't use semver
|
||||
if (!BuildConfig.NIGHTLY) {
|
||||
oldSemVer.mapIndexed { index, i ->
|
||||
// Keeping this nightly check for backwards compat
|
||||
if (!isNewVersionNightly && newSemVer.getOrElse(index) { i } > i) {
|
||||
return true
|
||||
} else if (newSemVer.getOrElse(index) { i } < i) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
// For cases of extreme patch versions (new: 1.2.3.1 vs old: 1.2.3, return true)
|
||||
|
@ -113,13 +117,11 @@ class AppUpdateChecker {
|
|||
val oldPreVersion =
|
||||
oldPreReleaseVer.getOrNull(1)?.replace("[^\\d.-]".toRegex(), "")?.toIntOrNull()
|
||||
when {
|
||||
oldPreVersion == null || newPreVersion == null -> false // FIXME: Check if the app is Nightly or Beta
|
||||
/*
|
||||
// For prod, don't bother with betas (current: 1.2.3 vs new: 1.2.3-b1)
|
||||
oldPreVersion == null -> false
|
||||
// For betas, always use prod builds (current: 1.2.3-b1 vs new: 1.2.3)
|
||||
newPreVersion == null -> true
|
||||
*/
|
||||
// For nightly, don't use prod builds
|
||||
newPreVersion == null -> !BuildConfig.NIGHTLY
|
||||
// For nightly, higher beta ver is newer (current: 1.2.3-b1 vs new: 1.2.3-b2 or r2)
|
||||
else -> (oldPreVersion < newPreVersion)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue