0
0
Fork 0
mirror of https://github.com/YTVanced/VancedManager synced 2024-11-19 09:45:10 +00:00
This commit is contained in:
X1nto 2020-05-26 23:07:34 +04:00
parent aa7bade5ce
commit b1fe32b2bd
2 changed files with 5 additions and 7 deletions

View file

@ -2,6 +2,7 @@ package com.vanced.manager.core
import android.annotation.SuppressLint import android.annotation.SuppressLint
import android.app.PendingIntent import android.app.PendingIntent
import android.content.Context
import android.content.Intent import android.content.Intent
import android.content.pm.PackageInstaller import android.content.pm.PackageInstaller
import android.os.Bundle import android.os.Bundle
@ -48,6 +49,7 @@ open class Main: BaseActivity() {
override fun onDestroy() { override fun onDestroy() {
super.onDestroy() super.onDestroy()
getSharedPreferences("installPrefs", Context.MODE_PRIVATE).edit().putBoolean("isInstalling", false).apply()
try { try {
cacheDir.deleteRecursively() cacheDir.deleteRecursively()
} catch (e: Exception) { } catch (e: Exception) {

View file

@ -31,7 +31,7 @@ open class BaseFragment : Fragment() {
private var disposable: Disposable? = null private var disposable: Disposable? = null
private val prefs = activity?.getSharedPreferences("installPrefs", Context.MODE_PRIVATE) private val prefs = activity?.getSharedPreferences("installPrefs", Context.MODE_PRIVATE)
private val baseUrl = "https://x1nto.github.io/VancedFiles/Splits/" private val baseUrl = "https://x1nto.github.io/VancedFiles/Splits"
fun openUrl(Url: String, color: Int) { fun openUrl(Url: String, color: Int) {
val builder = CustomTabsIntent.Builder() val builder = CustomTabsIntent.Builder()
@ -79,7 +79,6 @@ open class BaseFragment : Fragment() {
loadBar.progress = progress.percent().toInt() loadBar.progress = progress.percent().toInt()
}, },
onComplete = { onComplete = {
loadBar.visibility = View.GONE
downloadTheme(loadBar, dlText) downloadTheme(loadBar, dlText)
}, },
onError = { throwable -> onError = { throwable ->
@ -88,7 +87,7 @@ open class BaseFragment : Fragment() {
) )
} }
private fun downloadTheme(loadBar: ProgressBar, dlText: TextView) { private fun downloadTheme(loadBar: ProgressBar, dlText: TextView) {
val theme = prefs?.getString("theme", "") val theme = prefs?.getString("theme", "dark")
val url = "$baseUrl/Theme/$theme.apk" val url = "$baseUrl/Theme/$theme.apk"
val task = activity?.cacheDir?.path?.let { val task = activity?.cacheDir?.path?.let {
@ -107,12 +106,10 @@ open class BaseFragment : Fragment() {
.subscribeBy( .subscribeBy(
onNext = { progress -> onNext = { progress ->
val filename = getFileNameFromUrl(url) val filename = getFileNameFromUrl(url)
loadBar.visibility = View.VISIBLE
dlText.text = "Downloading $filename..." dlText.text = "Downloading $filename..."
loadBar.progress = progress.percent().toInt() loadBar.progress = progress.percent().toInt()
}, },
onComplete = { onComplete = {
loadBar.visibility = View.GONE
downloadLang(loadBar, dlText) downloadLang(loadBar, dlText)
}, },
onError = { throwable -> onError = { throwable ->
@ -122,7 +119,7 @@ open class BaseFragment : Fragment() {
} }
private fun downloadLang(loadBar: ProgressBar, dlText: TextView) { private fun downloadLang(loadBar: ProgressBar, dlText: TextView) {
val lang = prefs?.getString("lang", "") val lang = prefs?.getString("lang", "en")
val url = "$baseUrl/Language/split_config.$lang.apk" val url = "$baseUrl/Language/split_config.$lang.apk"
val task = activity?.cacheDir?.path?.let { val task = activity?.cacheDir?.path?.let {
@ -141,7 +138,6 @@ open class BaseFragment : Fragment() {
.subscribeBy( .subscribeBy(
onNext = { progress -> onNext = { progress ->
val filename = getFileNameFromUrl(url) val filename = getFileNameFromUrl(url)
loadBar.visibility = View.VISIBLE
dlText.text = "Downloading $filename..." dlText.text = "Downloading $filename..."
loadBar.progress = progress.percent().toInt() loadBar.progress = progress.percent().toInt()
}, },