mirror of
https://github.com/f-droid/fdroidclient.git
synced 2026-05-03 05:04:53 -04:00
Redesign RepoDetailsActivity
This commit is contained in:
@@ -202,6 +202,14 @@ public data class Repository internal constructor(
|
||||
}.ifEmpty { listOf(org.fdroid.download.Mirror(address)) }
|
||||
}
|
||||
|
||||
public fun getAllUserMirrors(): List<org.fdroid.download.Mirror> {
|
||||
return userMirrors.map { org.fdroid.download.Mirror(it) }
|
||||
}
|
||||
|
||||
public fun getAllOfficialMirrors(): List<org.fdroid.download.Mirror> {
|
||||
return getAllMirrors(false)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all mirrors, including [disabledMirrors].
|
||||
*/
|
||||
|
||||
@@ -22,6 +22,7 @@ import org.fdroid.database.Repository
|
||||
import org.fdroid.database.RepositoryDaoInt
|
||||
import org.fdroid.download.DownloaderFactory
|
||||
import org.fdroid.download.HttpManager
|
||||
import org.fdroid.download.Mirror
|
||||
import org.fdroid.repo.AddRepoState
|
||||
import org.fdroid.repo.RepoAdder
|
||||
import org.fdroid.repo.RepoUriGetter
|
||||
@@ -238,4 +239,36 @@ public class RepoManager @JvmOverloads constructor(
|
||||
return uri != null && RepoUriGetter.isSwapUri(uri)
|
||||
}
|
||||
|
||||
public fun setMirrorEnabled(repoId: Long, mirror: Mirror, enabled: Boolean) {
|
||||
val repo = repositoryDao.getRepository(repoId) ?: return
|
||||
val disabled = repo.disabledMirrors.toMutableList()
|
||||
|
||||
if (enabled) {
|
||||
if (disabled.contains(mirror.baseUrl)) {
|
||||
disabled.remove(mirror.baseUrl)
|
||||
repositoryDao.updateDisabledMirrors(repoId, disabled)
|
||||
}
|
||||
} else {
|
||||
if (!disabled.contains(mirror.baseUrl)) {
|
||||
disabled.add(mirror.baseUrl)
|
||||
|
||||
if (disabled.size == repo.getAllMirrors().size) {
|
||||
// if all mirrors are disabled, re-enable canonical repo as mirror
|
||||
disabled.remove(repo.address)
|
||||
}
|
||||
|
||||
repositoryDao.updateDisabledMirrors(repoId, disabled)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public fun deleteUserMirror(repoId: Long, mirror: Mirror) {
|
||||
val repo = repositoryDao.getRepository(repoId) ?: return
|
||||
val user = repo.userMirrors.toMutableList()
|
||||
|
||||
if (user.contains(mirror.baseUrl)) {
|
||||
user.remove(mirror.baseUrl)
|
||||
repositoryDao.updateUserMirrors(repoId, user)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user