0
0
Fork 0
mirror of https://github.com/YTVanced/VancedManager synced 2024-11-22 19:25:11 +00:00

added a backup url for downloads

This commit is contained in:
Xinto 2020-11-10 16:49:27 +04:00
parent 9094cca5a8
commit eda173c327
4 changed files with 25 additions and 4 deletions

View file

@ -8,10 +8,10 @@ import com.downloader.PRDownloader
import com.vanced.manager.R
import com.vanced.manager.utils.DeviceUtils.getArch
import com.vanced.manager.utils.DownloadHelper.downloadProgress
import com.vanced.manager.utils.Extensions.getInstallUrl
import com.vanced.manager.utils.Extensions.getLatestAppVersion
import com.vanced.manager.utils.InternetTools.baseUrl
import com.vanced.manager.utils.InternetTools.backupUrl
import com.vanced.manager.utils.InternetTools.getFileNameFromUrl
import com.vanced.manager.utils.InternetTools.music
import com.vanced.manager.utils.InternetTools.musicVersions
import com.vanced.manager.utils.PackageHelper.install
import com.vanced.manager.utils.PackageHelper.installMusicRoot
@ -29,7 +29,7 @@ object MusicDownloader {
val prefs = getDefaultSharedPreferences(context)
version = prefs.getString("music_version", "latest")?.getLatestAppVersion(musicVersions.get()?.value ?: listOf(""))
variant = prefs.getString("vanced_variant", "nonroot")
baseurl = "${prefs.getString("install_url", baseUrl)}/music/v$version"
baseurl = "${prefs.getInstallUrl()}/music/v$version"
downloadApk(context)
}
@ -61,6 +61,12 @@ object MusicDownloader {
}
override fun onError(error: Error?) {
if (baseurl != backupUrl) {
baseurl = "$backupUrl/music/v$version"
downloadApk(context, apk)
return
}
downloadProgress.get()?.downloadingFile?.set(context.getString(R.string.error_downloading, "Music"))
}
})

View file

@ -12,8 +12,10 @@ import com.vanced.manager.R
import com.vanced.manager.utils.AppUtils.vancedRootPkg
import com.vanced.manager.utils.DeviceUtils.getArch
import com.vanced.manager.utils.DownloadHelper.downloadProgress
import com.vanced.manager.utils.Extensions.getInstallUrl
import com.vanced.manager.utils.Extensions.getLatestAppVersion
import com.vanced.manager.utils.InternetTools
import com.vanced.manager.utils.InternetTools.backupUrl
import com.vanced.manager.utils.InternetTools.baseUrl
import com.vanced.manager.utils.InternetTools.getFileNameFromUrl
import com.vanced.manager.utils.InternetTools.vanced
@ -60,7 +62,7 @@ object VancedDownloader {
variant = defPrefs.getString("vanced_variant", "nonroot")
downloadPath = context.getExternalFilesDir("vanced/$variant")?.path
File(downloadPath.toString()).deleteRecursively()
installUrl = defPrefs.getString("install_url", baseUrl)
installUrl = defPrefs.getInstallUrl()
lang = prefs.getString("lang", getDefaultVancedLanguages())?.split(", ")?.toMutableList()
theme = prefs.getString("theme", "dark")
vancedVersion = defPrefs.getString("vanced_version", "latest")?.getLatestAppVersion(vancedVersions.get()?.value ?: listOf(""))
@ -126,6 +128,14 @@ object VancedDownloader {
}
}
override fun onError(error: Error?) {
if (installUrl != backupUrl) {
installUrl = backupUrl
themePath = "$installUrl/apks/v$vancedVersion/$variant/Theme"
downloadSplits(context, type)
return
}
if (type == "lang") {
count++
when {

View file

@ -11,6 +11,7 @@ import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
import com.google.android.material.radiobutton.MaterialRadioButton
import com.vanced.manager.R
import com.vanced.manager.model.AppVersionsModel
import com.vanced.manager.utils.InternetTools.baseUrl
import com.vanced.manager.utils.InternetTools.loadJson
import java.util.*
@ -69,4 +70,6 @@ object Extensions {
return if (this == "latest") versions.reversed()[0] else this
}
fun SharedPreferences.getInstallUrl() = getString("install_url", baseUrl)
}

View file

@ -31,6 +31,8 @@ object InternetTools {
var vancedVersions = ObservableField<JsonArray<String>>()
var musicVersions = ObservableField<JsonArray<String>>()
const val backupUrl = "https://mirror.codebucket.de/vanced/api/v1"
//var braveTiers = ObservableField<JsonObject?>()
fun openUrl(url: String, color: Int, context: Context) {