This commit is contained in:
X1nto 2020-05-28 12:00:46 +04:00
parent ea0bf3c177
commit 56a044d746
3 changed files with 11 additions and 8 deletions

View File

@ -36,7 +36,7 @@ open class BaseFragment : Fragment() {
val builder = CustomTabsIntent.Builder()
builder.setToolbarColor(ContextCompat.getColor(requireContext(), color))
val customTabsIntent = builder.build()
customTabsIntent.launchUrl(requireContext(), Uri.parse(Url))
customTabsIntent.launchUrl(activity, Uri.parse(Url))
}
fun isPackageInstalled(packageName: String, packageManager: PackageManager): Boolean {
@ -259,7 +259,7 @@ open class BaseFragment : Fragment() {
val uninstall = Intent(Intent.ACTION_DELETE, uri)
startActivity(uninstall)
} catch (e: ActivityNotFoundException) {
Toast.makeText(requireContext(), "Failed to uninstall", Toast.LENGTH_SHORT).show()
Toast.makeText(activity, "Failed to uninstall", Toast.LENGTH_SHORT).show()
}
}

View File

@ -4,16 +4,19 @@ import android.content.ActivityNotFoundException
import android.content.ComponentName
import android.content.Context
import android.content.Intent
import android.os.Build
import android.os.Bundle
import android.util.Log
import android.view.View
import android.widget.*
import androidx.annotation.RequiresApi
import androidx.navigation.findNavController
import com.vanced.manager.R
import com.vanced.manager.core.base.BaseFragment
open class Home : BaseFragment() {
@RequiresApi(Build.VERSION_CODES.P)
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
@ -75,7 +78,7 @@ 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
val microgVer = pm.getPackageInfo("com.mgoogle.android.gms", 0).longVersionCode
microguninstallbtn.setOnClickListener {
uninstallApk("com.mgoogle.android.gms")
}
@ -89,7 +92,7 @@ open class Home : BaseFragment() {
)
startActivity(intent)
} catch (e: ActivityNotFoundException) {
Toast.makeText(requireContext(), "App not installed", Toast.LENGTH_SHORT).show()
Toast.makeText(activity, "App not installed", Toast.LENGTH_SHORT).show()
activity?.recreate()
}
}

View File

@ -76,16 +76,16 @@ class HomeFragment : Home() {
val vancedRemoteVer =
GetJson().AsJSONObject("https://x1nto.github.io/VancedFiles/vanced.json")
.get("version").asInt
.get("version").asString
val microgRemoteVer =
GetJson().AsJSONObject("https://x1nto.github.io/VancedFiles/microg.json")
.get("version").asInt
.get("version").asString
vancedLatestTxt?.text = vancedRemoteVer.toString()
microgLatestTxt?.text = microgRemoteVer.toString()
if (microgStatus!!) {
val microgVer =
pm.getPackageInfo("com.mgoogle.android.gms", 0).versionName.toInt()
pm.getPackageInfo("com.mgoogle.android.gms", 0).versionName
when {
microgRemoteVer > microgVer -> {
microginstallbtn?.text = activity?.getString(R.string.update)
@ -103,7 +103,7 @@ class HomeFragment : Home() {
if (vancedStatus!!) {
val vancedVer =
pm.getPackageInfo("com.vanced.android.youtube", 0).versionName.toInt()
pm.getPackageInfo("com.vanced.android.youtube", 0).versionName
when {
vancedRemoteVer > vancedVer -> {
vancedinstallbtn?.text = activity?.getString(R.string.update)