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() val builder = CustomTabsIntent.Builder()
builder.setToolbarColor(ContextCompat.getColor(requireContext(), color)) builder.setToolbarColor(ContextCompat.getColor(requireContext(), color))
val customTabsIntent = builder.build() val customTabsIntent = builder.build()
customTabsIntent.launchUrl(requireContext(), Uri.parse(Url)) customTabsIntent.launchUrl(activity, Uri.parse(Url))
} }
fun isPackageInstalled(packageName: String, packageManager: PackageManager): Boolean { fun isPackageInstalled(packageName: String, packageManager: PackageManager): Boolean {
@ -259,7 +259,7 @@ open class BaseFragment : Fragment() {
val uninstall = Intent(Intent.ACTION_DELETE, uri) val uninstall = Intent(Intent.ACTION_DELETE, uri)
startActivity(uninstall) startActivity(uninstall)
} catch (e: ActivityNotFoundException) { } 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.ComponentName
import android.content.Context import android.content.Context
import android.content.Intent import android.content.Intent
import android.os.Build
import android.os.Bundle import android.os.Bundle
import android.util.Log import android.util.Log
import android.view.View import android.view.View
import android.widget.* import android.widget.*
import androidx.annotation.RequiresApi
import androidx.navigation.findNavController import androidx.navigation.findNavController
import com.vanced.manager.R import com.vanced.manager.R
import com.vanced.manager.core.base.BaseFragment import com.vanced.manager.core.base.BaseFragment
open class Home : BaseFragment() { open class Home : BaseFragment() {
@RequiresApi(Build.VERSION_CODES.P)
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
@ -75,7 +78,7 @@ open class Home : BaseFragment() {
val microgVerText = view.findViewById<TextView>(R.id.microg_installed_version) val microgVerText = view.findViewById<TextView>(R.id.microg_installed_version)
if (microgStatus!!) { if (microgStatus!!) {
val microgVer = pm.getPackageInfo("com.mgoogle.android.gms", 0).versionName val microgVer = pm.getPackageInfo("com.mgoogle.android.gms", 0).longVersionCode
microguninstallbtn.setOnClickListener { microguninstallbtn.setOnClickListener {
uninstallApk("com.mgoogle.android.gms") uninstallApk("com.mgoogle.android.gms")
} }
@ -89,7 +92,7 @@ open class Home : BaseFragment() {
) )
startActivity(intent) startActivity(intent)
} catch (e: ActivityNotFoundException) { } 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() activity?.recreate()
} }
} }

View File

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