mirror of
https://github.com/YTVanced/VancedManager
synced 2024-11-23 19:55:11 +00:00
ah yeah, it's all coming together
This commit is contained in:
parent
a730b89e47
commit
b590f87aa5
15 changed files with 223 additions and 254 deletions
|
@ -33,7 +33,7 @@ import java.io.File
|
|||
open class BaseFragment : Fragment() {
|
||||
|
||||
private var disposable: Disposable? = null
|
||||
private val baseUrl = "https://x1nto.github.io/VancedFiles/Splits"
|
||||
private val baseUrl = "https://vanced.app/api/v1/apks/v15.05.54/"
|
||||
|
||||
fun openUrl(Url: String, color: Int) {
|
||||
val builder = CustomTabsIntent.Builder()
|
||||
|
@ -64,7 +64,7 @@ open class BaseFragment : Fragment() {
|
|||
fun downloadArch(loadBar: ProgressBar, dlText: TextView, loadCircle: ProgressBar) {
|
||||
val prefs = activity?.getSharedPreferences("installPrefs", Context.MODE_PRIVATE)
|
||||
prefs?.edit()?.putBoolean("isVancedDownloading", true)?.apply()
|
||||
val variant = PreferenceManager.getDefaultSharedPreferences(activity).getString("vanced_variant", "Nonroot")
|
||||
val variant = PreferenceManager.getDefaultSharedPreferences(activity).getString("vanced_variant", "nonroot")
|
||||
val arch =
|
||||
when {
|
||||
Build.SUPPORTED_ABIS.contains("x86") -> "x86"
|
||||
|
@ -103,7 +103,7 @@ open class BaseFragment : Fragment() {
|
|||
}
|
||||
|
||||
private fun downloadTheme(loadBar: ProgressBar, dlText: TextView, loadCircle: ProgressBar) {
|
||||
val variant = PreferenceManager.getDefaultSharedPreferences(activity).getString("vanced_variant", "Nonroot")
|
||||
val variant = PreferenceManager.getDefaultSharedPreferences(activity).getString("vanced_variant", "nonroot")
|
||||
val prefs = activity?.getSharedPreferences("installPrefs", Context.MODE_PRIVATE)
|
||||
val theme = prefs?.getString("theme", "dark")
|
||||
val url = "$baseUrl/$variant/Theme/$theme.apk"
|
||||
|
@ -137,7 +137,7 @@ open class BaseFragment : Fragment() {
|
|||
}
|
||||
|
||||
private fun downloadLang(loadBar: ProgressBar, dlText: TextView, loadCircle: ProgressBar) {
|
||||
val variant = PreferenceManager.getDefaultSharedPreferences(activity).getString("vanced_variant", "Nonroot")
|
||||
val variant = PreferenceManager.getDefaultSharedPreferences(activity).getString("vanced_variant", "nonroot")
|
||||
val prefs = activity?.getSharedPreferences("installPrefs", Context.MODE_PRIVATE)
|
||||
val lang = prefs?.getString("lang", "en")
|
||||
val url = "$baseUrl/$variant/Language/split_config.$lang.apk"
|
||||
|
@ -169,7 +169,7 @@ open class BaseFragment : Fragment() {
|
|||
dlText.visibility = View.GONE
|
||||
loadCircle.visibility = View.VISIBLE
|
||||
prefs.edit()?.putBoolean("isVancedDownloading", false)?.apply()
|
||||
if (PreferenceManager.getDefaultSharedPreferences(activity).getString("vanced_variant", "Nonroot") == "Root") {
|
||||
if (PreferenceManager.getDefaultSharedPreferences(activity).getString("vanced_variant", "nonroot") == "root") {
|
||||
launchRootInstaller()
|
||||
} else {
|
||||
launchInstaller()
|
||||
|
@ -183,9 +183,9 @@ open class BaseFragment : Fragment() {
|
|||
}
|
||||
|
||||
private fun downloadEn(loadBar: ProgressBar, dlText: TextView, loadCircle: ProgressBar) {
|
||||
val variant = PreferenceManager.getDefaultSharedPreferences(activity).getString("vanced_variant", "Nonroot")
|
||||
val variant = PreferenceManager.getDefaultSharedPreferences(activity).getString("vanced_variant", "nonroot")
|
||||
val prefs = activity?.getSharedPreferences("installPrefs", Context.MODE_PRIVATE)
|
||||
val url = "https://x1nto.github.io/VancedFiles/Splits/$variant/Language/split_config.en.apk"
|
||||
val url = "$baseUrl/$variant/Language/split_config.en.apk"
|
||||
val task = activity?.cacheDir?.path?.let {
|
||||
Task(
|
||||
url = url,
|
||||
|
@ -211,7 +211,7 @@ open class BaseFragment : Fragment() {
|
|||
dlText.visibility = View.GONE
|
||||
loadCircle.visibility = View.VISIBLE
|
||||
prefs?.edit()?.putBoolean("isVancedDownloading", false)?.apply()
|
||||
if (PreferenceManager.getDefaultSharedPreferences(activity).getString("vanced_variant", "Nonroot") == "Root") {
|
||||
if (PreferenceManager.getDefaultSharedPreferences(activity).getString("vanced_variant", "nonroot") == "root") {
|
||||
launchRootInstaller()
|
||||
} else {
|
||||
launchInstaller()
|
||||
|
@ -287,7 +287,7 @@ open class BaseFragment : Fragment() {
|
|||
)
|
||||
}
|
||||
|
||||
fun uninstallApk(pkgUri: String) {
|
||||
/*fun uninstallApk(pkgUri: String) {
|
||||
try {
|
||||
val uri = Uri.parse("package:$pkgUri")
|
||||
val uninstall = Intent(Intent.ACTION_DELETE, uri)
|
||||
|
@ -296,5 +296,6 @@ open class BaseFragment : Fragment() {
|
|||
Toast.makeText(activity, "Failed to uninstall", Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
|
@ -1,11 +1,6 @@
|
|||
package com.vanced.manager.core.fragments
|
||||
|
||||
import android.content.ActivityNotFoundException
|
||||
import android.content.ComponentName
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.res.ColorStateList
|
||||
import android.graphics.Color
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import android.view.View
|
||||
|
@ -23,38 +18,22 @@ open class Home : BaseFragment() {
|
|||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
val pm = activity?.packageManager
|
||||
|
||||
//Damn that's a lot of buttons
|
||||
val microginstallbtn = view.findViewById<MaterialButton>(R.id.microg_installbtn)
|
||||
val vancedinstallbtn = view.findViewById<MaterialButton>(R.id.vanced_installbtn)
|
||||
|
||||
val bravebtn = view.findViewById<Button>(R.id.brave_button)
|
||||
val websitebtn = view.findViewById<Button>(R.id.website_button)
|
||||
val discordbtn = view.findViewById<Button>(R.id.discordbtn)
|
||||
val telegrambtn = view.findViewById<Button>(R.id.tgbtn)
|
||||
val twitterbtn = view.findViewById<Button>(R.id.twitterbtn)
|
||||
val redditbtn = view.findViewById<Button>(R.id.redditbtn)
|
||||
|
||||
val microguninstallbtn = view.findViewById<ImageView>(R.id.microg_uninstallbtn)
|
||||
val microgsettingsbtn = view.findViewById<ImageView>(R.id.microg_settingsbtn)
|
||||
val vanceduninstallbtn = view.findViewById<ImageView>(R.id.vanced_uninstallbtn)
|
||||
//val bravebtn = view.findViewById<Button>(R.id.brave_button)
|
||||
//val websitebtn = view.findViewById<Button>(R.id.website_button)
|
||||
//val discordbtn = view.findViewById<Button>(R.id.discordbtn)
|
||||
//val telegrambtn = view.findViewById<Button>(R.id.tgbtn)
|
||||
//val twitterbtn = view.findViewById<Button>(R.id.twitterbtn)
|
||||
//val redditbtn = view.findViewById<Button>(R.id.redditbtn)
|
||||
|
||||
val microgProgress = view.findViewById<ProgressBar>(R.id.microg_progress)
|
||||
val prefs = activity?.getSharedPreferences("installPrefs", Context.MODE_PRIVATE)
|
||||
val isVancedDownloading: Boolean? = prefs?.getBoolean("isVancedDownloading", false)
|
||||
val isMicrogDownloading: Boolean? = prefs?.getBoolean("isMicrogDownloading", false)
|
||||
|
||||
//we need to check whether these apps are installed or not
|
||||
val microgStatus = pm?.let { isPackageInstalled("com.mgoogle.android.gms", it) }
|
||||
val vancedStatus =
|
||||
if (PreferenceManager.getDefaultSharedPreferences(activity).getString("vanced_variant", "Nonroot") == "Root") {
|
||||
pm?.let { isPackageInstalled("com.google.android.youtube", it) }
|
||||
}
|
||||
else {
|
||||
pm?.let { isPackageInstalled("com.vanced.android.youtube", it) }
|
||||
}
|
||||
|
||||
vancedinstallbtn.setOnClickListener {
|
||||
if (!isVancedDownloading!!) {
|
||||
val mainActivity = (activity as MainActivity)
|
||||
|
@ -105,66 +84,6 @@ open class Home : BaseFragment() {
|
|||
}
|
||||
|
||||
/*
|
||||
val microgVerText = view.findViewById<TextView>(R.id.microg_installed_version)
|
||||
if (microgStatus!!) {
|
||||
val microgVer = pm.getPackageInfo("com.mgoogle.android.gms", 0).versionName
|
||||
|
||||
microguninstallbtn.setOnClickListener {
|
||||
uninstallApk("com.mgoogle.android.gms")
|
||||
}
|
||||
|
||||
|
||||
microgsettingsbtn.setOnClickListener {
|
||||
try {
|
||||
val intent = Intent()
|
||||
intent.component = ComponentName(
|
||||
"com.mgoogle.android.gms",
|
||||
"org.microg.gms.ui.SettingsActivity"
|
||||
)
|
||||
startActivity(intent)
|
||||
} catch (e: ActivityNotFoundException) {
|
||||
Toast.makeText(activity, "App not installed", Toast.LENGTH_SHORT).show()
|
||||
activity?.recreate()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
//microgVerText.text = microgVer
|
||||
} else {
|
||||
//microgsettingsbtn.visibility = View.INVISIBLE
|
||||
//microguninstallbtn.visibility = View.INVISIBLE
|
||||
microgVerText.text = getString(R.string.unavailable)
|
||||
vancedinstallbtn.isEnabled = PreferenceManager.getDefaultSharedPreferences(activity).getString("vanced_variant", "Nonroot") != "Nonroot"
|
||||
if (!vancedinstallbtn.isEnabled) {
|
||||
vancedinstallbtn.backgroundTintList = ColorStateList.valueOf(Color.DKGRAY)
|
||||
vancedinstallbtn.setTextColor(ColorStateList.valueOf(Color.GRAY))
|
||||
vancedinstallbtn.text = activity?.getString(R.string.no_microg)
|
||||
vancedinstallbtn.icon = null
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
val vancedVerText = view.findViewById<TextView>(R.id.vanced_installed_version)
|
||||
/*if (vancedStatus!!) {
|
||||
val vancedVer =
|
||||
if (PreferenceManager.getDefaultSharedPreferences(activity).getString("vanced_variant", "Nonroot") == "Root")
|
||||
pm.getPackageInfo("com.google.android.youtube", 0).versionName
|
||||
else
|
||||
pm.getPackageInfo("com.vanced.android.youtube", 0).versionName
|
||||
vanceduninstallbtn.setOnClickListener {
|
||||
if (PreferenceManager.getDefaultSharedPreferences(activity).getString("vanced_variant", "Nonroot") == "Root")
|
||||
uninstallApk("com.vanced.android.youtube")
|
||||
else
|
||||
uninstallApk("com.google.android.youtube")
|
||||
}
|
||||
vancedVerText.text = vancedVer
|
||||
} else {
|
||||
//vanceduninstallbtn.visibility = View.INVISIBLE
|
||||
vancedVerText.text = getString(R.string.unavailable)
|
||||
}
|
||||
*/
|
||||
|
||||
bravebtn.setOnClickListener {
|
||||
openUrl("https://brave.com/van874", R.color.Brave)
|
||||
|
||||
|
@ -187,6 +106,7 @@ open class Home : BaseFragment() {
|
|||
redditbtn.setOnClickListener {
|
||||
openUrl("https://reddit.com/r/vanced", R.color.Reddit)
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -52,21 +52,9 @@ class HomeFragment : Home() {
|
|||
val viewModel: HomeViewModel by viewModels()
|
||||
binding.viewModel = viewModel
|
||||
|
||||
val variantPref = getDefaultSharedPreferences(activity).getString("vanced_variant", "Nonroot")
|
||||
val variantPref = getDefaultSharedPreferences(activity).getString("vanced_variant", "nonroot")
|
||||
|
||||
/*val microgWrapper = view.findViewById<MaterialCardView>(R.id.home_microg_wrapper)
|
||||
if (variantPref == "Root") {
|
||||
activity?.runOnUiThread {
|
||||
microgWrapper.visibility = View.GONE
|
||||
}
|
||||
} else {
|
||||
activity?.runOnUiThread {
|
||||
microgWrapper.visibility = View.VISIBLE
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
if (variantPref == "Root")
|
||||
if (variantPref == "root")
|
||||
attachRootChangelog()
|
||||
else
|
||||
attachNonrootChangelog()
|
||||
|
@ -76,11 +64,11 @@ class HomeFragment : Home() {
|
|||
private fun initNetworkFun() {
|
||||
val pm = activity?.packageManager
|
||||
val microgStatus = pm?.let { isPackageInstalled("com.mgoogle.android.gms", it) }
|
||||
//val vancedStatus = pm?.let { isPackageInstalled("com.vanced.android.youtube", it) }
|
||||
val vancedStatus = pm?.let { isPackageInstalled("com.vanced.android.youtube", it) }
|
||||
val vancedinstallbtn = view?.findViewById<MaterialButton>(R.id.vanced_installbtn)
|
||||
val vancedLatestTxt = view?.findViewById<TextView>(R.id.vanced_latest_version)
|
||||
val networkErrorLayout = view?.findViewById<MaterialCardView>(R.id.home_network_wrapper)
|
||||
val variant = getDefaultSharedPreferences(activity).getString("vanced_variant", "Nonroot")
|
||||
val variant = getDefaultSharedPreferences(activity).getString("vanced_variant", "nonroot")
|
||||
|
||||
disposable = ReactiveNetwork.observeInternetConnectivity()
|
||||
.subscribeOn(Schedulers.io())
|
||||
|
@ -90,28 +78,17 @@ class HomeFragment : Home() {
|
|||
if (isConnectedToInternet) {
|
||||
vancedinstallbtn?.visibility = View.VISIBLE
|
||||
|
||||
//val vancedRemoteVer =
|
||||
// GetJson().AsJSONObject("https://x1nto.github.io/VancedFiles/vanced.json")
|
||||
// .get("version").asString
|
||||
val microgRemoteVer =
|
||||
GetJson().AsJSONObject("https://x1nto.github.io/VancedFiles/microg.json")
|
||||
.get("version").asString
|
||||
//vancedLatestTxt?.text = vancedRemoteVer
|
||||
|
||||
//val vancedRemoteCode =
|
||||
// GetJson().AsJSONObject("https://x1nto.github.io/VancedFiles/vanced.json")
|
||||
// .get("versionCode").asInt
|
||||
val vancedRemoteCode =
|
||||
GetJson().AsJSONObject("https://vanced.app/api/v1/vanced.json")
|
||||
.get("versionCode").asInt
|
||||
val microgRemoteCode =
|
||||
GetJson().AsJSONObject("https://x1nto.github.io/VancedFiles/microg.json")
|
||||
GetJson().AsJSONObject("https://vanced.app/api/v1/microg.json")
|
||||
.get("versionCode").asInt
|
||||
|
||||
if (variant == "Nonroot") {
|
||||
val microgLatestTxt =
|
||||
view?.findViewById<TextView>(R.id.microg_latest_version)
|
||||
val microginstallbtn =
|
||||
view?.findViewById<MaterialButton>(R.id.microg_installbtn)
|
||||
microginstallbtn?.visibility = View.VISIBLE
|
||||
microgLatestTxt?.text = microgRemoteVer
|
||||
|
||||
if (microgStatus!!) {
|
||||
val microgVerCode =
|
||||
|
@ -137,10 +114,9 @@ class HomeFragment : Home() {
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
if (vancedStatus!!) {
|
||||
val vanPkgName =
|
||||
if (variant == "Root") {
|
||||
if (variant == "root") {
|
||||
"com.google.android.youtube"
|
||||
} else {
|
||||
"com.vanced.android.youtube"
|
||||
|
@ -160,7 +136,7 @@ class HomeFragment : Home() {
|
|||
).versionCode
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
when {
|
||||
vancedRemoteCode > vancedVerCode -> {
|
||||
vancedinstallbtn?.text =
|
||||
|
@ -177,9 +153,8 @@ class HomeFragment : Home() {
|
|||
}
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
val oa2 = ObjectAnimator.ofFloat(networkErrorLayout, "yFraction", 0f, 0.3f)
|
||||
val oa3 = ObjectAnimator.ofFloat(networkErrorLayout, "yFraction", 0.3f, -1f)
|
||||
|
|
|
@ -9,9 +9,6 @@ import android.widget.TextView
|
|||
import com.dezlum.codelabs.getjson.GetJson
|
||||
import com.vanced.manager.R
|
||||
|
||||
/**
|
||||
* A simple [Fragment] subclass.
|
||||
*/
|
||||
class ManagerChangelogFragment : Fragment() {
|
||||
|
||||
override fun onCreateView(
|
||||
|
@ -26,10 +23,10 @@ class ManagerChangelogFragment : Fragment() {
|
|||
|
||||
val changelogTxt = view.findViewById<TextView>(R.id.manager_changelog)
|
||||
|
||||
val checkUrl = GetJson().AsJSONObject("https://x1nto.github.io/VancedFiles/manager.json")
|
||||
val checkUrl = GetJson().AsJSONObject("https://vanced.app/api/v1/manager.json")
|
||||
val changelog = checkUrl.get("changelog").asString
|
||||
|
||||
if (GetJson().isConnected(requireContext()))
|
||||
if (GetJson().isConnected(activity))
|
||||
changelogTxt.text = changelog
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,11 +6,9 @@ import android.view.LayoutInflater
|
|||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.TextView
|
||||
import com.dezlum.codelabs.getjson.GetJson
|
||||
import com.vanced.manager.R
|
||||
|
||||
/**
|
||||
* A simple [Fragment] subclass.
|
||||
*/
|
||||
class MicrogChangelogFragment : Fragment() {
|
||||
|
||||
override fun onCreateView(
|
||||
|
@ -19,4 +17,16 @@ class MicrogChangelogFragment : Fragment() {
|
|||
): View? {
|
||||
return inflater.inflate(R.layout.fragment_microg_changelog, container, false)
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
val changelogTxt = view.findViewById<TextView>(R.id.microg_changelog)
|
||||
|
||||
val checkUrl = GetJson().AsJSONObject("https://vanced.app/api/v1/microg.json")
|
||||
val changelog = checkUrl.get("changelog").asString
|
||||
|
||||
if (GetJson().isConnected(activity))
|
||||
changelogTxt.text = changelog
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
package com.vanced.manager.ui.fragments
|
||||
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.view.Menu
|
||||
import android.view.MenuInflater
|
||||
import androidx.preference.*
|
||||
import com.topjohnwu.superuser.Shell
|
||||
import com.vanced.manager.R
|
||||
import com.vanced.manager.ui.MainActivity
|
||||
|
||||
class SettingsFragment : PreferenceFragmentCompat() {
|
||||
|
||||
|
@ -38,16 +40,17 @@ class SettingsFragment : PreferenceFragmentCompat() {
|
|||
}
|
||||
|
||||
val installMode: DropDownPreference? = findPreference("vanced_variant")
|
||||
installMode?.summary = preferenceScreen.sharedPreferences.getString("vanced_variant", "Nonroot")
|
||||
installMode?.summary = preferenceScreen.sharedPreferences.getString("vanced_variant", "nonroot")
|
||||
installMode?.setOnPreferenceChangeListener{ _, _ ->
|
||||
when (installMode.value) {
|
||||
"Nonroot" -> {
|
||||
"nonroot" -> {
|
||||
if (!Shell.rootAccess()) {
|
||||
preferenceScreen.sharedPreferences.edit().putString("vanced_variant", "Nonroot").apply()
|
||||
preferenceScreen.sharedPreferences.edit().putString("vanced_variant", "nonroot").apply()
|
||||
}
|
||||
}
|
||||
}
|
||||
activity?.recreate()
|
||||
startActivity(Intent(activity, MainActivity::class.java))
|
||||
activity?.finish()
|
||||
true
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@ package com.vanced.manager.ui.fragments
|
|||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Intent
|
||||
import android.content.pm.PackageManager
|
||||
import android.graphics.Color
|
||||
import android.graphics.drawable.ColorDrawable
|
||||
import android.net.Uri
|
||||
|
@ -58,7 +57,7 @@ class UpdateCheckFragment : DialogFragment() {
|
|||
closebtn.setOnClickListener { dismiss() }
|
||||
|
||||
if (GetJson().isConnected(requireContext())) {
|
||||
val checkUrl = GetJson().AsJSONObject("https://x1nto.github.io/VancedFiles/manager.json")
|
||||
val checkUrl = GetJson().AsJSONObject("https://vanced.app/api/v1/manager.json")
|
||||
val remoteVersion = checkUrl.get("versionCode").asInt
|
||||
|
||||
if (remoteVersion > BuildConfig.VERSION_CODE) {
|
||||
|
@ -80,27 +79,8 @@ class UpdateCheckFragment : DialogFragment() {
|
|||
|
||||
}
|
||||
|
||||
override fun onRequestPermissionsResult(
|
||||
requestCode: Int,
|
||||
permissions: Array<out String>,
|
||||
grantResults: IntArray
|
||||
) {
|
||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults)
|
||||
|
||||
when (requestCode) {
|
||||
69 -> {
|
||||
if (grantResults.isNotEmpty() && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
||||
Toast.makeText(requireContext(), "Permission Granted", Toast.LENGTH_SHORT)
|
||||
.show()
|
||||
}
|
||||
else
|
||||
Toast.makeText(requireContext(), "Permission Denied", Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun upgradeManager(loadBar: ProgressBar) {
|
||||
val apkUrl = GetJson().AsJSONObject("https://x1nto.github.io/VancedFiles/manager.json")
|
||||
val apkUrl = GetJson().AsJSONObject("https://vanced.app/api/v1/manager.json")
|
||||
val dwnldUrl = apkUrl.get("url").asString
|
||||
|
||||
val task = activity?.filesDir?.path?.let {
|
||||
|
|
|
@ -1,17 +1,14 @@
|
|||
package com.vanced.manager.ui.fragments
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.os.Bundle
|
||||
import androidx.fragment.app.Fragment
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.TextView
|
||||
import com.dezlum.codelabs.getjson.GetJson
|
||||
import com.vanced.manager.R
|
||||
|
||||
/**
|
||||
* A simple [Fragment] subclass.
|
||||
*/
|
||||
class VancedChangelogFragment : Fragment() {
|
||||
|
||||
override fun onCreateView(
|
||||
|
@ -21,4 +18,16 @@ class VancedChangelogFragment : Fragment() {
|
|||
return inflater.inflate(R.layout.fragment_vanced_changelog, container, false)
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
val changelogTxt = view.findViewById<TextView>(R.id.vanced_changelog)
|
||||
|
||||
val checkUrl = GetJson().AsJSONObject("https://vanced.app/api/v1/changelog/15_05_54.json")
|
||||
val changelog = checkUrl.get("message").asString
|
||||
|
||||
if (GetJson().isConnected(activity))
|
||||
changelogTxt.text = changelog
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -5,7 +5,11 @@ import android.content.ActivityNotFoundException
|
|||
import android.content.ComponentName
|
||||
import android.content.Intent
|
||||
import android.content.pm.PackageManager
|
||||
import android.net.Uri
|
||||
import android.os.Build
|
||||
import android.widget.Toast
|
||||
import androidx.browser.customtabs.CustomTabsIntent
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.content.ContextCompat.startActivity
|
||||
import androidx.lifecycle.AndroidViewModel
|
||||
import androidx.preference.PreferenceManager.getDefaultSharedPreferences
|
||||
|
@ -23,8 +27,10 @@ open class HomeViewModel(application: Application): AndroidViewModel(application
|
|||
}
|
||||
}
|
||||
|
||||
val isConnected = GetJson().isConnected(application)
|
||||
|
||||
private val vancedPkgName: String =
|
||||
if (getDefaultSharedPreferences(application).getString("vanced_variant", "Nonroot") == "Nonroot") {
|
||||
if (getDefaultSharedPreferences(application).getString("vanced_variant", "nonroot") == "root") {
|
||||
"com.google.android.youtube"
|
||||
} else {
|
||||
"com.vanced.android.youtube"
|
||||
|
@ -33,9 +39,6 @@ open class HomeViewModel(application: Application): AndroidViewModel(application
|
|||
val isMicrogInstalled: Boolean = isPackageInstalled("com.mgoogle.android.gms", application.packageManager)
|
||||
val isVancedInstalled: Boolean = isPackageInstalled(vancedPkgName, application.packageManager)
|
||||
|
||||
|
||||
val isConnected = GetJson().isConnected(application)
|
||||
|
||||
val vancedInstalledVersion: String =
|
||||
if (isVancedInstalled) {
|
||||
application.packageManager.getPackageInfo(vancedPkgName, 0).versionName
|
||||
|
@ -57,7 +60,7 @@ open class HomeViewModel(application: Application): AndroidViewModel(application
|
|||
val microgVersion: String = GetJson().AsJSONObject("https://x1nto.github.io/VancedFiles/microg.json")
|
||||
.get("version").asString
|
||||
|
||||
val isNonrootModeSelected: Boolean = getDefaultSharedPreferences(application).getString("vanced_variant", "Nonroot") == "Nonroot"
|
||||
val isNonrootModeSelected: Boolean = getDefaultSharedPreferences(application).getString("vanced_variant", "nonroot") == "ronroot"
|
||||
|
||||
fun openMicrogSettings() {
|
||||
try {
|
||||
|
@ -66,10 +69,42 @@ open class HomeViewModel(application: Application): AndroidViewModel(application
|
|||
"com.mgoogle.android.gms",
|
||||
"org.microg.gms.ui.SettingsActivity"
|
||||
)
|
||||
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK
|
||||
startActivity(getApplication(), intent, null)
|
||||
} catch (e: ActivityNotFoundException) {
|
||||
Toast.makeText(getApplication(), "App not installed", Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
||||
|
||||
fun uninstallMicrog() {
|
||||
try {
|
||||
val uri = Uri.parse("package:com.mgoogle.android.gms")
|
||||
val uninstall = Intent(Intent.ACTION_DELETE, uri)
|
||||
uninstall.flags = Intent.FLAG_ACTIVITY_NEW_TASK
|
||||
startActivity(getApplication(), uninstall, null)
|
||||
|
||||
} catch (e: ActivityNotFoundException) {
|
||||
Toast.makeText(getApplication(), "Failed to uninstall", Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
||||
|
||||
fun uninstallVanced() {
|
||||
try {
|
||||
val uri = Uri.parse("package:$vancedPkgName")
|
||||
val uninstall = Intent(Intent.ACTION_DELETE, uri)
|
||||
uninstall.flags = Intent.FLAG_ACTIVITY_NEW_TASK
|
||||
startActivity(getApplication(), uninstall, null)
|
||||
|
||||
} catch (e: ActivityNotFoundException) {
|
||||
Toast.makeText(getApplication(), "Failed to uninstall", Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
||||
|
||||
fun openUrl(Url: String, color: Int) {
|
||||
val builder = CustomTabsIntent.Builder()
|
||||
builder.setToolbarColor(ContextCompat.getColor(getApplication(), color))
|
||||
val customTabsIntent = builder.build()
|
||||
customTabsIntent.launchUrl(getApplication(), Uri.parse(Url))
|
||||
}
|
||||
|
||||
}
|
|
@ -70,7 +70,8 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/stdp"
|
||||
android:layout_marginTop="@dimen/stdp"
|
||||
android:layout_marginEnd="@dimen/stdp" />
|
||||
android:layout_marginEnd="@dimen/stdp"
|
||||
bind:viewModel="@{viewModel}"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
tools:context=".ui.fragments.MicrogChangelogFragment">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/microg_changelog"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="18sp"
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
tools:context=".ui.fragments.VancedChangelogFragment">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/vanced_changelog"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:textSize="18sp"
|
||||
|
|
|
@ -114,6 +114,7 @@
|
|||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/microg_title_buttons_barrier"
|
||||
android:onClick="@{()-> viewModel.uninstallMicrog()}"
|
||||
android:visibility="@{viewModel.microgInstalled ? View.VISIBLE : View.GONE}" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
|
|
@ -1,46 +1,64 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<com.google.android.material.card.MaterialCardView
|
||||
<layout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
style="@style/MaterialCard"
|
||||
app:contentPaddingTop="2dp">
|
||||
xmlns:bind="http://schemas.android.com/tools">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
<data>
|
||||
|
||||
<TextView
|
||||
style="@style/CardTitle"
|
||||
android:text="@string/useful_links" />
|
||||
<variable
|
||||
name="viewModel"
|
||||
type="com.vanced.manager.ui.viewmodels.HomeViewModel" />
|
||||
|
||||
</data>
|
||||
|
||||
<com.google.android.material.card.MaterialCardView
|
||||
style="@style/MaterialCard"
|
||||
app:contentPaddingTop="2dp">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:layout_marginTop="2dp">
|
||||
android:orientation="vertical">
|
||||
|
||||
<include
|
||||
layout="@layout/include_vanced_medias"
|
||||
<TextView
|
||||
style="@style/CardTitle"
|
||||
android:text="@string/useful_links" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:layout_marginTop="2dp">
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
style="@style/LinkButtonStyle"
|
||||
android:id="@+id/brave_button"
|
||||
android:text="@string/support_us"
|
||||
android:layout_marginTop="5dp"
|
||||
app:cornerRadius="@dimen/eightdp" />
|
||||
<include
|
||||
layout="@layout/include_vanced_medias"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
bind:viewModel="@{viewModel}"/>
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
style="@style/LinkButtonStyle"
|
||||
android:id="@+id/website_button"
|
||||
android:text="@string/website_text"
|
||||
app:cornerRadius="@dimen/eightdp" />
|
||||
<com.google.android.material.button.MaterialButton
|
||||
style="@style/LinkButtonStyle"
|
||||
android:id="@+id/brave_button"
|
||||
android:text="@string/support_us"
|
||||
android:layout_marginTop="5dp"
|
||||
app:cornerRadius="@dimen/eightdp"
|
||||
android:onClick='@{()-> viewModel.openUrl("https://brave.com/van874", @color/Brave)}'/>
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
style="@style/LinkButtonStyle"
|
||||
android:id="@+id/website_button"
|
||||
android:text="@string/website_text"
|
||||
app:cornerRadius="@dimen/eightdp"
|
||||
android:onClick='@{()-> viewModel.openUrl("https://vanced.app", @color/Vanced)}'/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
</com.google.android.material.card.MaterialCardView>
|
||||
|
||||
</layout>
|
||||
|
||||
|
||||
</com.google.android.material.card.MaterialCardView>
|
||||
|
||||
|
|
|
@ -1,70 +1,87 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<com.google.android.material.card.MaterialCardView
|
||||
<layout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
style="@style/InnerMaterialCard"
|
||||
app:cardBackgroundColor="#6958D0">
|
||||
xmlns:bind="http://schemas.android.com/tools">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
<data>
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginTop="2dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:fontFamily="@font/exo_semibold"
|
||||
android:text="@string/vanced_medias"
|
||||
android:textColor="#ffffff"
|
||||
android:textSize="18sp" />
|
||||
<variable
|
||||
name="viewModel"
|
||||
type="com.vanced.manager.ui.viewmodels.HomeViewModel" />
|
||||
|
||||
</data>
|
||||
|
||||
<com.google.android.material.card.MaterialCardView
|
||||
style="@style/InnerMaterialCard"
|
||||
app:cardBackgroundColor="#6958D0">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginTop="2dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:fontFamily="@font/exo_semibold"
|
||||
android:text="@string/vanced_medias"
|
||||
android:textColor="#ffffff"
|
||||
android:textSize="18sp" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/discordbtn"
|
||||
style="@style/SocialButtonStyle"
|
||||
app:icon="@drawable/discord"
|
||||
app:layout_constraintEnd_toStartOf="@id/tgbtn"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"/>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/tgbtn"
|
||||
style="@style/SocialButtonStyle"
|
||||
app:icon="@drawable/telegram"
|
||||
app:layout_constraintEnd_toStartOf="@id/twitterbtn"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@id/discordbtn"/>
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/discordbtn"
|
||||
style="@style/SocialButtonStyle"
|
||||
app:icon="@drawable/discord"
|
||||
app:layout_constraintEnd_toStartOf="@id/tgbtn"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
android:onClick='@{()-> viewModel.openUrl("https://discord.gg/TUVd7rd", @color/Discord)}'/>
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/twitterbtn"
|
||||
style="@style/SocialButtonStyle"
|
||||
app:icon="@drawable/twitter"
|
||||
app:layout_constraintEnd_toStartOf="@id/redditbtn"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@id/tgbtn"/>
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/tgbtn"
|
||||
style="@style/SocialButtonStyle"
|
||||
app:icon="@drawable/telegram"
|
||||
app:layout_constraintEnd_toStartOf="@id/twitterbtn"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@id/discordbtn"
|
||||
android:onClick='@{()-> viewModel.openUrl("https://t.me/joinchat/AAAAAEHf-pi4jH1SDlAL4w", @color/Telegram)}'/>
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/redditbtn"
|
||||
style="@style/SocialButtonStyle"
|
||||
app:icon="@drawable/ic_reddit"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@id/twitterbtn"/>
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/twitterbtn"
|
||||
style="@style/SocialButtonStyle"
|
||||
app:icon="@drawable/twitter"
|
||||
app:layout_constraintEnd_toStartOf="@id/redditbtn"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@id/tgbtn"
|
||||
android:onClick='@{()-> viewModel.openUrl("https://twitter.com/YTVanced", @color/Twitter)}'/>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/redditbtn"
|
||||
style="@style/SocialButtonStyle"
|
||||
app:icon="@drawable/ic_reddit"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@id/twitterbtn"
|
||||
android:onClick='@{()-> viewModel.openUrl("https://reddit.com/r/vanced", @color/Reddit)}'/>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
</com.google.android.material.card.MaterialCardView>
|
||||
|
||||
</com.google.android.material.card.MaterialCardView>
|
||||
</layout>
|
||||
|
|
Loading…
Reference in a new issue