Use GitHub pages URLs for public channel JSONs

This commit is contained in:
topjohnwu
2020-10-03 01:57:53 -07:00
parent 241f2656fa
commit 716f06846b
7 changed files with 34 additions and 17 deletions

View File

@@ -47,14 +47,12 @@ object Const {
object Url {
const val ZIP_URL = "https://github.com/Magisk-Modules-Repo/%s/archive/master.zip"
const val PAYPAL_URL = "https://www.paypal.me/topjohnwu"
const val PATREON_URL = "https://www.patreon.com/topjohnwu"
const val TWITTER_URL = "https://twitter.com/topjohnwu"
const val XDA_THREAD = "http://forum.xda-developers.com/showthread.php?t=3432382"
const val SOURCE_CODE_URL = "https://github.com/topjohnwu/Magisk"
const val GITHUB_RAW_URL = "https://raw.githubusercontent.com/"
const val GITHUB_API_URL = "https://api.github.com/users/Magisk-Modules-Repo/"
const val GITHUB_PAGE_URL = "https://topjohnwu.github.io/magisk_files/"
}
object Key {

View File

@@ -7,6 +7,15 @@ import okhttp3.ResponseBody
import retrofit2.Response
import retrofit2.http.*
interface GithubPageServices {
@GET("stable.json")
suspend fun fetchStableUpdate(): UpdateInfo
@GET("beta.json")
suspend fun fetchBetaUpdate(): UpdateInfo
}
interface GithubRawServices {
//region topjohnwu/magisk_files

View File

@@ -2,27 +2,29 @@ package com.topjohnwu.magisk.data.repository
import com.topjohnwu.magisk.core.Config
import com.topjohnwu.magisk.core.Info
import com.topjohnwu.magisk.data.network.GithubPageServices
import com.topjohnwu.magisk.data.network.GithubRawServices
import retrofit2.HttpException
import timber.log.Timber
import java.io.IOException
class MagiskRepository(
private val apiRaw: GithubRawServices
private val rawSvc: GithubRawServices,
private val pageSvc: GithubPageServices
) {
suspend fun fetchUpdate() = try {
var info = when (Config.updateChannel) {
Config.Value.DEFAULT_CHANNEL, Config.Value.STABLE_CHANNEL -> apiRaw.fetchStableUpdate()
Config.Value.BETA_CHANNEL -> apiRaw.fetchBetaUpdate()
Config.Value.CANARY_CHANNEL -> apiRaw.fetchCanaryUpdate()
Config.Value.CUSTOM_CHANNEL -> apiRaw.fetchCustomUpdate(Config.customChannelUrl)
Config.Value.DEFAULT_CHANNEL, Config.Value.STABLE_CHANNEL -> pageSvc.fetchStableUpdate()
Config.Value.BETA_CHANNEL -> pageSvc.fetchBetaUpdate()
Config.Value.CANARY_CHANNEL -> rawSvc.fetchCanaryUpdate()
Config.Value.CUSTOM_CHANNEL -> rawSvc.fetchCustomUpdate(Config.customChannelUrl)
else -> throw IllegalArgumentException()
}
if (info.magisk.versionCode < Info.env.magiskVersionCode &&
Config.updateChannel == Config.Value.DEFAULT_CHANNEL) {
Config.updateChannel = Config.Value.BETA_CHANNEL
info = apiRaw.fetchBetaUpdate()
info = pageSvc.fetchBetaUpdate()
}
Info.remote = info
info

View File

@@ -7,6 +7,7 @@ import com.topjohnwu.magisk.core.Config
import com.topjohnwu.magisk.core.Const
import com.topjohnwu.magisk.core.Info
import com.topjohnwu.magisk.data.network.GithubApiServices
import com.topjohnwu.magisk.data.network.GithubPageServices
import com.topjohnwu.magisk.data.network.GithubRawServices
import com.topjohnwu.magisk.ktx.precomputedText
import com.topjohnwu.magisk.net.Networking
@@ -30,6 +31,7 @@ val networkingModule = module {
single { createRetrofit(get()) }
single { createApiService<GithubRawServices>(get(), Const.Url.GITHUB_RAW_URL) }
single { createApiService<GithubApiServices>(get(), Const.Url.GITHUB_API_URL) }
single { createApiService<GithubPageServices>(get(), Const.Url.GITHUB_PAGE_URL) }
single { createMarkwon(get(), get()) }
}

View File

@@ -7,7 +7,7 @@ import org.koin.dsl.module
val repositoryModule = module {
single { MagiskRepository(get()) }
single { MagiskRepository(get(), get()) }
single { LogRepository(get()) }
single { StringRepository(get()) }
}