Add F-Droid as update check sources

This commit is contained in:
世界
2026-03-11 16:45:27 +08:00
parent 0d1ee7aa80
commit 868c1de2ff
16 changed files with 874 additions and 76 deletions

View File

@@ -13,8 +13,10 @@ import io.nekohasekai.sfa.compose.screen.qrscan.QRCodeCropArea
import io.nekohasekai.sfa.database.Settings
import io.nekohasekai.sfa.update.UpdateCheckException
import io.nekohasekai.sfa.update.UpdateInfo
import io.nekohasekai.sfa.update.UpdateSource
import io.nekohasekai.sfa.update.UpdateState
import io.nekohasekai.sfa.update.UpdateTrack
import io.nekohasekai.sfa.update.checkFDroidUpdate
object Vendor : VendorInterface {
private const val TAG = "Vendor"
@@ -93,19 +95,20 @@ object Vendor : VendorInterface {
onCropArea: ((QRCodeCropArea?) -> Unit)?,
): ImageAnalysis.Analyzer? = null
override fun supportsTrackSelection(): Boolean = true
override val hasCustomUpdate = true
override fun checkUpdateAsync(): UpdateInfo? {
val track = UpdateTrack.fromString(Settings.updateTrack)
return GitHubUpdateChecker().use { checker ->
checker.checkUpdate(track)
override val updateSources = listOf(UpdateSource.GITHUB, UpdateSource.FDROID)
override fun checkUpdateAsync(): UpdateInfo? = when (UpdateSource.fromString(Settings.updateSource)) {
UpdateSource.FDROID -> checkFDroidUpdate(Application.application)
UpdateSource.GITHUB -> {
val track = UpdateTrack.fromString(Settings.updateTrack)
GitHubUpdateChecker().use { checker ->
checker.checkUpdate(track)
}
}
}
override fun supportsSilentInstall(): Boolean = true
override fun supportsAutoUpdate(): Boolean = true
override fun scheduleAutoUpdate() {
UpdateWorker.schedule(io.nekohasekai.sfa.Application.application)
}