Skip to content

Commit

Permalink
Enable GitLab Source
Browse files Browse the repository at this point in the history
  • Loading branch information
rumboalla committed Oct 28, 2023
1 parent 1a5e332 commit b2c0b2a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
5 changes: 4 additions & 1 deletion app/src/main/kotlin/com/apkupdater/di/MainModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import com.apkupdater.repository.AppsRepository
import com.apkupdater.repository.AptoideRepository
import com.apkupdater.repository.FdroidRepository
import com.apkupdater.repository.GitHubRepository
import com.apkupdater.repository.GitLabRepository
import com.apkupdater.repository.SearchRepository
import com.apkupdater.repository.UpdatesRepository
import com.apkupdater.service.ApkMirrorService
Expand Down Expand Up @@ -137,6 +138,8 @@ val mainModule = module {

single { GitHubRepository(get(), get()) }

single { GitLabRepository(get(), get()) }

single { ApkPureRepository(get(), get(), get()) }

single { AptoideRepository(get(), get(), get()) }
Expand All @@ -145,7 +148,7 @@ val mainModule = module {

single(named("izzy")) { FdroidRepository(get(), "https://apt.izzysoft.de/fdroid/repo/", IzzySource, get()) }

single { UpdatesRepository(get(), get(), get(), get(named("main")), get(named("izzy")), get(), get(), get()) }
single { UpdatesRepository(get(), get(), get(), get(named("main")), get(named("izzy")), get(), get(), get(), get()) }

single { SearchRepository(get(), get(named("main")), get(named("izzy")), get(), get(), get(), get()) }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import android.util.Log
import com.apkupdater.data.gitlab.GitLabApps
import com.apkupdater.data.ui.AppInstalled
import com.apkupdater.data.ui.AppUpdate
import com.apkupdater.data.ui.GitHubSource
import com.apkupdater.data.ui.GitLabSource
import com.apkupdater.data.ui.getApp
import com.apkupdater.prefs.Prefs
import com.apkupdater.service.GitLabService
Expand All @@ -31,9 +31,9 @@ class GitLabRepository(
}
}
if (checks.isEmpty()) {
emit(Result.success(emptyList()))
emit(emptyList())
} else {
checks.combine { all -> emit(Result.success(all.flatMap { it })) }.collect()
checks.combine { all -> emit(all.flatMap { it }) }.collect()
}
}

Expand All @@ -47,7 +47,7 @@ class GitLabRepository(
) = flow {
val releases = service.getReleases(user, repo)
.filter { Version(filterVersionTag(it.tag_name)) > Version(currentVersion) }
//.filter { it.assets.sources.find { url -> url.url.endsWith(".apk", true) } != null }
// .filter { it.assets.sources.find { url -> url.url.endsWith(".apk", true) } != null }

if (releases.isNotEmpty()) {
val app = apps?.getApp(packageName)
Expand All @@ -59,7 +59,7 @@ class GitLabRepository(
oldVersion = app?.version ?: "?",
versionCode = 0L,
oldVersionCode = app?.versionCode ?: 0L,
source = GitHubSource,
source = GitLabSource,
link = releases[0].assets.sources.find { url -> url.url.endsWith(".apk", true) }?.url.orEmpty(),
whatsNew = releases[0].description,
iconUri = if (apps == null) Uri.parse(releases[0].author.avatar_url) else Uri.EMPTY
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class UpdatesRepository(
private val izzyRepository: FdroidRepository,
private val aptoideRepository: AptoideRepository,
private val apkPureRepository: ApkPureRepository,
private val gitLabRepository: GitLabRepository,
private val prefs: Prefs
) {

Expand All @@ -32,6 +33,7 @@ class UpdatesRepository(
if (prefs.useIzzy.get()) sources.add(izzyRepository.updates(filtered))
if (prefs.useAptoide.get()) sources.add(aptoideRepository.updates(filtered))
if (prefs.useApkPure.get()) sources.add(apkPureRepository.updates(filtered))
if (prefs.useGitLab.get()) sources.add(gitLabRepository.updates(filtered))

if (sources.isNotEmpty()) {
sources
Expand Down

0 comments on commit b2c0b2a

Please sign in to comment.