commit
d01e0f70d4
|
@ -36,7 +36,7 @@ object VancedDownloader: CoroutineScope by CoroutineScope(Dispatchers.IO) {
|
|||
private var installUrl: String? = null
|
||||
private var variant: String? = null
|
||||
private var theme: String? = null
|
||||
private var lang: MutableList<String>? = null
|
||||
private var lang = mutableListOf<String>()
|
||||
|
||||
private lateinit var themePath: String
|
||||
|
||||
|
@ -56,7 +56,9 @@ object VancedDownloader: CoroutineScope by CoroutineScope(Dispatchers.IO) {
|
|||
downloadPath = context.getExternalFilesDir("vanced/$variant")?.path
|
||||
File(downloadPath.toString()).deleteRecursively()
|
||||
installUrl = defPrefs.getInstallUrl()
|
||||
lang = prefs.getString("lang", getDefaultVancedLanguages())?.split(", ")?.toMutableList()
|
||||
prefs.getString("lang", getDefaultVancedLanguages())?.let {
|
||||
lang = it.split(", ").toMutableList()
|
||||
}
|
||||
theme = prefs.getString("theme", "dark")
|
||||
vancedVersion = defPrefs.getString("vanced_version", "latest")?.getLatestAppVersion(vancedVersions.get()?.value ?: listOf(""))
|
||||
themePath = "$installUrl/apks/v$vancedVersion/$variant/Theme"
|
||||
|
@ -112,7 +114,7 @@ object VancedDownloader: CoroutineScope by CoroutineScope(Dispatchers.IO) {
|
|||
"lang" -> {
|
||||
count++
|
||||
succesfulLangCount++
|
||||
if (count < lang?.size!!)
|
||||
if (count < lang.size)
|
||||
downloadSplits(context, "lang")
|
||||
else
|
||||
startVancedInstall(context)
|
||||
|
@ -132,9 +134,9 @@ object VancedDownloader: CoroutineScope by CoroutineScope(Dispatchers.IO) {
|
|||
if (type == "lang") {
|
||||
count++
|
||||
when {
|
||||
count < lang?.size!! -> downloadSplits(context, "lang")
|
||||
count < lang.size -> downloadSplits(context, "lang")
|
||||
succesfulLangCount == 0 -> {
|
||||
lang?.add("en")
|
||||
lang.add("en")
|
||||
downloadSplits(context, "lang")
|
||||
}
|
||||
else -> startVancedInstall(context)
|
||||
|
|
|
@ -71,7 +71,7 @@ class VancedLanguageSelectionDialog : BottomSheetDialogFragment() {
|
|||
val loc = Locale(lang)
|
||||
val box: MaterialCheckBox = MaterialCheckBox(requireActivity()).apply {
|
||||
tag = lang
|
||||
isChecked = langPrefs!!.contains(lang)
|
||||
isChecked = langPrefs?.contains(lang) ?: false
|
||||
text = loc.getDisplayLanguage(loc).capitalize(Locale.ROOT)
|
||||
textSize = 18F
|
||||
typeface = ResourcesCompat.getFont(requireActivity(), R.font.exo_bold)
|
||||
|
|
|
@ -100,9 +100,9 @@ object InternetTools {
|
|||
return getJsonString(hashUrl, obj, context)
|
||||
}
|
||||
|
||||
fun checkSHA256(sha256: String, updateFile: File?): Boolean {
|
||||
fun checkSHA256(sha256: String, updateFile: File): Boolean {
|
||||
return try {
|
||||
val dataBuffer = updateFile!!.readBytes()
|
||||
val dataBuffer = updateFile.readBytes()
|
||||
// Generate the checksum
|
||||
val sum = generateChecksum(dataBuffer)
|
||||
|
||||
|
|
|
@ -12,15 +12,11 @@ object JsonHelper {
|
|||
private var dataMap: HashMap<String, JsonObject> = HashMap()
|
||||
|
||||
suspend fun getJson(url: String): JsonObject? {
|
||||
return try {
|
||||
if(dataMap.containsKey(url)) {
|
||||
dataMap[url]!!
|
||||
} else {
|
||||
dataMap[url] = getSuspendJson(url)
|
||||
dataMap[url]!!
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
null
|
||||
return if (dataMap.containsKey(url)) {
|
||||
dataMap[url]
|
||||
} else {
|
||||
dataMap[url] = getSuspendJson(url)
|
||||
dataMap[url]
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -6,28 +6,20 @@ import java.io.InputStreamReader
|
|||
|
||||
object MiuiHelper {
|
||||
|
||||
fun isMiui(): Boolean = getSystemProps("ro.miui.ui.version.name")!!.isNotEmpty()
|
||||
private const val MIUI_PROP_NAME = "ro.miui.ui.version.name"
|
||||
|
||||
fun isMiui(): Boolean = !getSystemProps(MIUI_PROP_NAME).isNullOrEmpty()
|
||||
|
||||
private fun getSystemProps(propname: String): String? {
|
||||
val line: String
|
||||
var input: BufferedReader? = null
|
||||
try {
|
||||
val p = Runtime.getRuntime().exec("getprop $propname")
|
||||
input = BufferedReader(InputStreamReader(p.inputStream), 1024)
|
||||
line = input.readLine()
|
||||
input.close()
|
||||
return try {
|
||||
val process = Runtime.getRuntime().exec("getprop $propname")
|
||||
input = BufferedReader(InputStreamReader(process.inputStream), 1024)
|
||||
input.readLine()
|
||||
} catch (e: IOException) {
|
||||
return null
|
||||
null
|
||||
} finally {
|
||||
if (input != null) {
|
||||
try {
|
||||
input.close()
|
||||
} catch (e: IOException) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
input?.close()
|
||||
}
|
||||
return line
|
||||
}
|
||||
|
||||
}
|
|
@ -298,7 +298,7 @@ object PackageHelper {
|
|||
}
|
||||
|
||||
} finally {
|
||||
session!!.close()
|
||||
session?.close()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -579,8 +579,8 @@ object PackageHelper {
|
|||
|
||||
|
||||
@Throws(IOException::class)
|
||||
fun copy(src: File?, dst: File?) {
|
||||
val cmd = Shell.su("mv ${src!!.absolutePath} ${dst!!.absolutePath}").exec().isSuccess
|
||||
fun copy(src: File, dst: File) {
|
||||
val cmd = Shell.su("mv ${src.absolutePath} ${dst.absolutePath}").exec().isSuccess
|
||||
Log.d("ZLog", cmd.toString())
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue