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-29 10:47:38 +00:00
|
|
|
import androidx.databinding.ObservableField
|
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-10-31 19:45:39 +00:00
|
|
|
import kotlinx.coroutines.CoroutineScope
|
|
|
|
import kotlinx.coroutines.Dispatchers
|
|
|
|
import kotlinx.coroutines.launch
|
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-29 10:47:38 +00:00
|
|
|
var vanced = ObservableField<JsonObject?>()
|
|
|
|
var music = ObservableField<JsonObject?>()
|
|
|
|
var microg = ObservableField<JsonObject?>()
|
|
|
|
var manager = ObservableField<JsonObject?>()
|
2020-09-16 10:40:01 +00:00
|
|
|
|
2020-11-02 14:41:39 +00:00
|
|
|
//var braveTiers = ObservableField<JsonObject?>()
|
|
|
|
|
2020-06-21 19:24:14 +00:00
|
|
|
override fun onCreate() {
|
2020-11-02 14:41:39 +00:00
|
|
|
loadJson()
|
2020-09-20 14:41:28 +00:00
|
|
|
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()
|
2020-11-02 14:41:39 +00:00
|
|
|
.withDistributionHash("3b84be9663023b0b1a22988j4s6")
|
2020-09-20 14:41:28 +00:00
|
|
|
.withNetworkType(NetworkType.WIFI)
|
|
|
|
.build()
|
|
|
|
)
|
2020-08-23 00:24:43 +00:00
|
|
|
|
2020-07-06 11:38:00 +00:00
|
|
|
}
|
|
|
|
|
2020-11-02 14:41:39 +00:00
|
|
|
open fun loadJson() = CoroutineScope(Dispatchers.IO).launch {
|
|
|
|
val installUrl = getDefaultSharedPreferences(this@App).getString("install_url", baseUrl)
|
|
|
|
val latest = getJson("$installUrl/latest.json")
|
|
|
|
// braveTiers.apply {
|
|
|
|
// set(getJson("$installUrl/sponsor.json"))
|
|
|
|
// notifyChange()
|
|
|
|
// }
|
2020-09-29 10:47:38 +00:00
|
|
|
|
2020-10-31 19:45:39 +00:00
|
|
|
vanced.apply {
|
|
|
|
set(latest?.obj("vanced"))
|
|
|
|
notifyChange()
|
|
|
|
}
|
|
|
|
music.apply {
|
|
|
|
set(latest?.obj("music"))
|
|
|
|
notifyChange()
|
|
|
|
}
|
|
|
|
microg.apply {
|
|
|
|
set(latest?.obj("microg"))
|
|
|
|
notifyChange()
|
|
|
|
}
|
|
|
|
manager.apply {
|
|
|
|
set(latest?.obj("manager"))
|
|
|
|
notifyChange()
|
|
|
|
}
|
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-09-29 10:47:38 +00:00
|
|
|
|
2020-08-12 13:40:13 +00:00
|
|
|
}
|