diff --git a/api/api.iml b/api/api.iml
index ca9c4bea..ce0230c2 100644
--- a/api/api.iml
+++ b/api/api.iml
@@ -70,15 +70,15 @@
-
+
+
+
-
-
diff --git a/app/app.iml b/app/app.iml
index eecdd09d..7a3ea9c9 100644
--- a/app/app.iml
+++ b/app/app.iml
@@ -70,17 +70,17 @@
-
-
-
-
+
+
+
+
-
+
@@ -135,10 +135,10 @@
-
-
+
+
diff --git a/app/src/main/java/com/vanced/manager/core/base/BaseFragment.kt b/app/src/main/java/com/vanced/manager/core/base/BaseFragment.kt
index 4afe14c5..2819902b 100644
--- a/app/src/main/java/com/vanced/manager/core/base/BaseFragment.kt
+++ b/app/src/main/java/com/vanced/manager/core/base/BaseFragment.kt
@@ -1,5 +1,6 @@
package com.vanced.manager.core.base
+import android.content.ActivityNotFoundException
import android.content.Intent
import android.content.pm.PackageManager
import android.net.Uri
@@ -149,7 +150,7 @@ open class BaseFragment : Fragment() {
intent.setDataAndType(uri, "application/vnd.android.package-archive")
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
- startActivity(intent)
+ startActivityForResult(intent, 69)
},
onError = { throwable ->
Toast.makeText(requireContext(), throwable.toString(), Toast.LENGTH_SHORT)
@@ -158,4 +159,23 @@ open class BaseFragment : Fragment() {
)
}
+ fun uninstallApk(pkgUri: String) {
+ try {
+ val uri = Uri.parse(pkgUri)
+ val uninstall = Intent(Intent.ACTION_DELETE, uri)
+ startActivityForResult(uninstall, 69)
+ } catch (e: ActivityNotFoundException) {
+ Toast.makeText(requireContext(), "App not installed", Toast.LENGTH_SHORT).show()
+ activity?.recreate()
+ }
+ }
+
+ override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
+ super.onActivityResult(requestCode, resultCode, data)
+ if (requestCode == 69) {
+ activity?.recreate()
+ }
+ }
+
+
}
\ No newline at end of file
diff --git a/app/src/main/java/com/vanced/manager/core/fragments/Home.kt b/app/src/main/java/com/vanced/manager/core/fragments/Home.kt
index e86d5d7d..6b13eb98 100644
--- a/app/src/main/java/com/vanced/manager/core/fragments/Home.kt
+++ b/app/src/main/java/com/vanced/manager/core/fragments/Home.kt
@@ -11,7 +11,6 @@ import android.widget.*
import androidx.navigation.findNavController
import com.vanced.manager.R
import com.vanced.manager.core.base.BaseFragment
-import java.io.File
open class Home : BaseFragment() {
@@ -54,58 +53,46 @@ open class Home : BaseFragment() {
installApk("https://x1nto.github.io/VancedFiles/microg.json", microgProgress)
}
- val microgVerText = view.findViewById(R.id.microg_installed_version)
- if (microgStatus!!) {
- val microgVer = pm.getPackageInfo("com.mgoogle.android.gms", 0).versionName
- microguninstallbtn.setOnClickListener {
- try {
- val uri = Uri.parse("package:com.mgoogle.android.gms")
- val mgUninstall = Intent(Intent.ACTION_DELETE, uri)
- startActivity(mgUninstall)
- } catch (e: ActivityNotFoundException) {
- Toast.makeText(requireContext(), "App not installed", Toast.LENGTH_SHORT).show()
- activity?.recreate()
- }
-
- }
-
- 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(requireContext(), "App not installed", Toast.LENGTH_SHORT).show()
- activity?.recreate()
- }
- }
- microgVerText.text = microgVer.toString()
- } else {
- microgsettingsbtn.visibility = View.INVISIBLE
- microguninstallbtn.visibility = View.INVISIBLE
- microgVerText.text = getString(R.string.unavailable)
- }
-
val vancedVerText = view.findViewById(R.id.vanced_installed_version)
- if (vancedStatus!!) {
- val vancedVer = pm.getPackageInfo("com.vanced.android.youtube", 0).versionName
- vanceduninstallbtn.setOnClickListener {
- try {
- val uri = Uri.parse("package:com.vanced.android.youtube")
- val vanUninstall = Intent(Intent.ACTION_DELETE, uri)
- startActivity(vanUninstall)
- } catch (e: ActivityNotFoundException) {
- Toast.makeText(requireContext(), "App not installed", Toast.LENGTH_SHORT).show()
- activity?.recreate()
+ val microgVerText = view.findViewById(R.id.microg_installed_version)
+ when {
+ 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(requireContext(), "App not installed", Toast.LENGTH_SHORT).show()
+ activity?.recreate()
+ }
+ }
+ microgVerText.text = microgVer.toString()
+ }
+ !microgStatus -> {
+ microgsettingsbtn.visibility = View.INVISIBLE
+ microguninstallbtn.visibility = View.INVISIBLE
+ microgVerText.text = getString(R.string.unavailable)
+ }
+ vancedStatus!! -> {
+ val vancedVer = pm.getPackageInfo("com.vanced.android.youtube", 0).versionName
+ vanceduninstallbtn.setOnClickListener {
+ uninstallApk("com.vanced.android.youtube")
+ }
+ vancedVerText.text = vancedVer.toString()
+ }
+ !vancedStatus -> {
+ vanceduninstallbtn.visibility = View.INVISIBLE
+ vancedVerText.text = getString(R.string.unavailable)
}
- vancedVerText.text = vancedVer.toString()
- } else {
- vanceduninstallbtn.visibility = View.INVISIBLE
- vancedVerText.text = getString(R.string.unavailable)
}
bravebtn.setOnClickListener {
diff --git a/app/src/main/java/com/vanced/manager/ui/fragments/HomeFragment.kt b/app/src/main/java/com/vanced/manager/ui/fragments/HomeFragment.kt
index a4595f7d..25469313 100644
--- a/app/src/main/java/com/vanced/manager/ui/fragments/HomeFragment.kt
+++ b/app/src/main/java/com/vanced/manager/ui/fragments/HomeFragment.kt
@@ -3,12 +3,13 @@ package com.vanced.manager.ui.fragments
import android.animation.ObjectAnimator
import android.os.Bundle
import android.view.*
-import android.widget.Button
import android.widget.TextView
import androidx.core.animation.addListener
+import androidx.core.content.res.ResourcesCompat
import androidx.viewpager2.widget.ViewPager2
import com.dezlum.codelabs.getjson.GetJson
import com.github.pwittchen.reactivenetwork.library.rx2.ReactiveNetwork
+import com.google.android.material.button.MaterialButton
import com.google.android.material.card.MaterialCardView
import com.google.android.material.tabs.TabLayout
import com.google.android.material.tabs.TabLayoutMediator
@@ -44,6 +45,7 @@ class HomeFragment : Home() {
val tabLayout = view.findViewById(R.id.tablayout) as TabLayout
viewPager = view.findViewById(R.id.viewpager)
viewPager.adapter = sectionPageAdapter
+ viewPager.currentItem = 0
TabLayoutMediator(tabLayout, viewPager) { tab, position ->
when (position) {
@@ -59,8 +61,8 @@ class HomeFragment : Home() {
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 microginstallbtn = view?.findViewById