Skip to content

Commit

Permalink
Add support for extracting APK url on Aurora's releases
Browse files Browse the repository at this point in the history
  • Loading branch information
rumboalla committed Nov 4, 2023
1 parent c149c47 commit 7e3884f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
3 changes: 1 addition & 2 deletions app/src/main/kotlin/com/apkupdater/data/gitlab/GitLabApp.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,5 @@ data class GitLabApp(
)

val GitLabApps = listOf(
GitLabApp("com.aurora.store", "AuroraOSS", "AuroraStore"),
GitLabApp("com.github.axet.bookreader", "axet", "android-book-reader")
GitLabApp("com.aurora.store", "AuroraOSS", "AuroraStore")
)
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.apkupdater.repository
import android.net.Uri
import android.util.Log
import com.apkupdater.data.gitlab.GitLabApps
import com.apkupdater.data.gitlab.GitLabRelease
import com.apkupdater.data.ui.AppInstalled
import com.apkupdater.data.ui.AppUpdate
import com.apkupdater.data.ui.GitLabSource
Expand Down Expand Up @@ -60,7 +61,7 @@ class GitLabRepository(
versionCode = 0L,
oldVersionCode = app?.versionCode ?: 0L,
source = GitLabSource,
link = releases[0].assets.sources.find { url -> url.url.endsWith(".apk", true) }?.url.orEmpty(),
link = getApkUrl(packageName, releases[0]),
whatsNew = releases[0].description,
iconUri = if (apps == null) Uri.parse(releases[0].author.avatar_url) else Uri.EMPTY
)))
Expand All @@ -72,4 +73,22 @@ class GitLabRepository(
Log.e("GitLabRepository", "Error fetching releases for $packageName.", it)
}

private fun getApkUrl(
packageName: String,
release: GitLabRelease
): String {
// TODO: Take into account arch
val source = release.assets.sources.find { it.url.endsWith(".apk", true) }
if (source != null) {
return source.url
} else if (packageName == "com.aurora.store") {
// For whatever reason Aurora doesn't store the APK as an asset.
// Instead there is a markdown link to the APK.
Regex("\\[(.+)]\\(([^ ]+?)( \"(.+)\")?\\)").find(release.description)?.let {
return "https://gitlab.com/AuroraOSS/AuroraStore" + it.groups[2]!!.value
}
}
return ""
}

}

0 comments on commit 7e3884f

Please sign in to comment.