Skip to content

Commit 6cc9ebd

Browse files
committed
flavor-specific picker for updater
1 parent 0f9a793 commit 6cc9ebd

1 file changed

Lines changed: 14 additions & 6 deletions

File tree

  • composeApp/src/androidGithub/kotlin/me/knighthat/updater

composeApp/src/androidGithub/kotlin/me/knighthat/updater/Updater.kt

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,21 @@ object Updater {
3434
*/
3535
@Throws(NoSuchFileException::class)
3636
private fun extractBuild( assets: List<GithubRelease.Build> ): GithubRelease.Build {
37+
// Ignore the warning `BuildConfig.FLAVOR_env == "nightly"` either `true` or `false`
38+
// This condition is different based on the build
39+
val suffix = if( BuildConfig.FLAVOR_env == "nightly" )
40+
BuildConfig.FLAVOR_env
41+
else when( BuildConfig.FLAVOR_arch ) {
42+
"universal" -> "release"
43+
"arm32" -> "armeabi-v7a"
44+
"arm64" -> "arm64-v8a"
45+
"x86" -> "x86"
46+
"x86_64" -> "x86_64"
47+
else -> throw IllegalStateException("Unknown architecture ${BuildConfig.FLAVOR_arch}")
48+
}
3749
// e.g. Release version will have name 'Kreate-release.apk'
38-
val filename = "%s-%s.apk".format(
39-
BuildConfig.APP_NAME,
40-
// Ignore the warning `BuildConfig.FLAVOR_env == "nightly"` either `true` or `false`
41-
// This condition is different based on the build
42-
if( BuildConfig.FLAVOR_env == "nightly" ) "nightly" else "release"
43-
)
50+
val filename = "%s-%s.apk".format(BuildConfig.APP_NAME, suffix)
51+
4452
return assets.fastFirstOrNull {
4553
// Get the first build that has name matches 'Kreate-<buildType>.apk'
4654
// with the exception of nightly build, which is `Kreate-nightly.apk`

0 commit comments

Comments
 (0)