2020-06-21 19:24:14 +00:00
|
|
|
package com.vanced.manager.core
|
|
|
|
|
|
|
|
import android.app.Application
|
2020-09-16 05:18:07 +00:00
|
|
|
import android.content.res.Configuration
|
2020-09-25 17:01:24 +00:00
|
|
|
import androidx.preference.PreferenceManager.getDefaultSharedPreferences
|
2020-09-16 10:40:01 +00:00
|
|
|
import com.beust.klaxon.JsonObject
|
2020-07-06 11:38:00 +00:00
|
|
|
import com.crowdin.platform.Crowdin
|
|
|
|
import com.crowdin.platform.CrowdinConfig
|
|
|
|
import com.crowdin.platform.data.remote.NetworkType
|
2020-06-21 19:24:14 +00:00
|
|
|
import com.downloader.PRDownloader
|
2020-09-17 10:13:16 +00:00
|
|
|
import com.vanced.manager.utils.InternetTools.baseUrl
|
2020-09-16 10:40:01 +00:00
|
|
|
import com.vanced.manager.utils.JsonHelper.getJson
|
2020-09-20 14:41:28 +00:00
|
|
|
import kotlinx.coroutines.*
|
2020-06-21 19:24:14 +00:00
|
|
|
|
2020-09-16 05:18:07 +00:00
|
|
|
open class App: Application() {
|
2020-06-21 19:24:14 +00:00
|
|
|
|
2020-09-17 10:13:16 +00:00
|
|
|
var vanced: JsonObject? = null
|
|
|
|
var music: JsonObject? = null
|
|
|
|
var microg: JsonObject? = null
|
|
|
|
var manager: JsonObject? = null
|
2020-09-16 10:40:01 +00:00
|
|
|
|
2020-06-21 19:24:14 +00:00
|
|
|
override fun onCreate() {
|
2020-09-20 14:41:28 +00:00
|
|
|
loadJsonAsync()
|
|
|
|
super.onCreate()
|
|
|
|
PRDownloader.initialize(this)
|
2020-07-06 11:38:00 +00:00
|
|
|
|
2020-09-20 14:41:28 +00:00
|
|
|
Crowdin.init(this,
|
|
|
|
CrowdinConfig.Builder()
|
|
|
|
.withDistributionHash("36c51aed3180a4f43073d28j4s6")
|
|
|
|
.withNetworkType(NetworkType.WIFI)
|
|
|
|
.build()
|
|
|
|
)
|
2020-08-23 00:24:43 +00:00
|
|
|
|
2020-07-06 11:38:00 +00:00
|
|
|
}
|
|
|
|
|
2020-09-20 14:41:28 +00:00
|
|
|
fun loadJsonAsync() {
|
2020-09-25 17:01:24 +00:00
|
|
|
val latest = runBlocking { getJson("${getDefaultSharedPreferences(this@App).getString("update_url", baseUrl)}/latest.json") }
|
2020-09-17 10:13:16 +00:00
|
|
|
vanced = latest.obj("vanced")
|
|
|
|
music = latest.obj("music")
|
|
|
|
microg = latest.obj("microg")
|
|
|
|
manager = latest.obj("manager")
|
2020-09-16 10:40:01 +00:00
|
|
|
}
|
|
|
|
|
2020-07-06 11:38:00 +00:00
|
|
|
override fun onConfigurationChanged(newConfig: Configuration) {
|
|
|
|
super.onConfigurationChanged(newConfig)
|
|
|
|
Crowdin.onConfigurationChanged()
|
2020-06-21 19:24:14 +00:00
|
|
|
}
|
|
|
|
|
2020-08-12 13:40:13 +00:00
|
|
|
}
|