0
0
Fork 0
mirror of https://github.com/YTVanced/VancedManager synced 2024-11-02 01:02:39 +00:00

moved update checker to activity

This commit is contained in:
X1nto 2020-07-02 20:03:49 +04:00
parent bd562c1df3
commit 7828fb0a35
3 changed files with 23 additions and 5 deletions

View file

@ -13,11 +13,12 @@ class App: Application() {
override fun onCreate() {
super.onCreate()
checkUpdates()
//checkUpdates()
PRDownloader.initialize(applicationContext)
createNotifChannel(this)
}
/*
private fun checkUpdates() {
val checkPrefs = PreferenceManager.getDefaultSharedPreferences(this).getBoolean("auto_check_update", true)
if (checkPrefs) {
@ -28,4 +29,6 @@ class App: Application() {
}
}
*/
}

View file

@ -3,11 +3,16 @@ package com.vanced.manager.core
import android.annotation.SuppressLint
import android.content.Context
import android.os.Bundle
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import androidx.preference.PreferenceManager
import com.dezlum.codelabs.getjson.GetJson
import com.vanced.manager.R
import com.vanced.manager.ui.dialogs.DialogContainer.showRootDialog
import com.vanced.manager.ui.dialogs.DialogContainer.showSecurityDialog
import com.vanced.manager.ui.dialogs.DialogContainer.statementFalse
import com.vanced.manager.ui.fragments.UpdateCheckFragment
import com.vanced.manager.utils.InternetTools.isUpdateAvailable
// This activity will NOT be used in manifest
// since MainActivity will extend it
@ -18,17 +23,17 @@ open class Main: AppCompatActivity() {
super.onCreate(savedInstanceState)
val prefs = PreferenceManager.getDefaultSharedPreferences(this)
val firstStart = prefs.getBoolean("firstStart", true)
val falseStatement = prefs.getBoolean("statement", true)
val variant = prefs.getString("vanced_variant", "nonroot")
val showRootDialog = prefs.getBoolean("show_root_dialog", true)
when {
firstStart -> showSecurityDialog(this)
!falseStatement -> statementFalse(this)
prefs.getBoolean("firstStart", true) -> showSecurityDialog(this)
!prefs.getBoolean("statement", true) -> statementFalse(this)
variant == "root" && showRootDialog -> showRootDialog(this)
}
checkUpdates()
}
override fun onPause() {
@ -38,4 +43,13 @@ open class Main: AppCompatActivity() {
super.onPause()
}
private fun checkUpdates() {
if (GetJson().isConnected(this) && isUpdateAvailable()) {
val fm = supportFragmentManager
UpdateCheckFragment().show(fm, "UpdateCheck")
} else {
Toast.makeText(this, getString(R.string.update_notfound), Toast.LENGTH_SHORT).show()
}
}
}

View file

@ -1,5 +1,6 @@
package com.vanced.manager.utils
import android.app.Activity
import android.content.Context
import android.net.Uri
import androidx.browser.customtabs.CustomTabsIntent