mirror of
https://github.com/YTVanced/VancedManager
synced 2024-11-29 22:43:01 +00:00
fixed launch button making app crash
This commit is contained in:
parent
e2b641fc3e
commit
ea0bf3c177
2 changed files with 36 additions and 33 deletions
|
@ -46,10 +46,9 @@ class MainActivity : Main() {
|
||||||
|
|
||||||
private val broadcastReceiver: BroadcastReceiver = object : BroadcastReceiver() {
|
private val broadcastReceiver: BroadcastReceiver = object : BroadcastReceiver() {
|
||||||
override fun onReceive(context: Context, intent: Intent) {
|
override fun onReceive(context: Context, intent: Intent) {
|
||||||
if (intent.action.equals(INSTALL_COMPLETED)) {
|
when {
|
||||||
launchVanced()
|
intent.action.equals(INSTALL_COMPLETED) -> launchVanced()
|
||||||
} else {
|
else -> intent.action?.let { alertBuilder(it) }
|
||||||
intent.action?.let { alertBuilder(it) }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -127,7 +126,7 @@ class MainActivity : Main() {
|
||||||
|
|
||||||
private fun launchVanced() {
|
private fun launchVanced() {
|
||||||
val intent = Intent()
|
val intent = Intent()
|
||||||
intent.component = ComponentName("com.vanced.android.youtube", "com.vanced.android.youtube.HomeActivity")
|
intent.component = ComponentName("com.vanced.android.youtube", "com.google.android.youtube.HomeActivity")
|
||||||
AlertDialog.Builder(this)
|
AlertDialog.Builder(this)
|
||||||
.setTitle("Success!")
|
.setTitle("Success!")
|
||||||
.setMessage("Vanced has been successfully installed, do you want to launch it now?")
|
.setMessage("Vanced has been successfully installed, do you want to launch it now?")
|
||||||
|
|
|
@ -74,44 +74,48 @@ class HomeFragment : Home() {
|
||||||
vancedinstallbtn?.visibility = View.VISIBLE
|
vancedinstallbtn?.visibility = View.VISIBLE
|
||||||
microginstallbtn?.visibility = View.VISIBLE
|
microginstallbtn?.visibility = View.VISIBLE
|
||||||
|
|
||||||
val vancedRemoteVer: String =
|
val vancedRemoteVer =
|
||||||
GetJson().AsJSONObject("https://x1nto.github.io/VancedFiles/vanced.json")
|
GetJson().AsJSONObject("https://x1nto.github.io/VancedFiles/vanced.json")
|
||||||
.get("version").asString
|
.get("version").asInt
|
||||||
val microgRemoteVer: String =
|
val microgRemoteVer =
|
||||||
GetJson().AsJSONObject("https://x1nto.github.io/VancedFiles/microg.json")
|
GetJson().AsJSONObject("https://x1nto.github.io/VancedFiles/microg.json")
|
||||||
.get("version").asString
|
.get("version").asInt
|
||||||
vancedLatestTxt?.text = vancedRemoteVer
|
vancedLatestTxt?.text = vancedRemoteVer.toString()
|
||||||
microgLatestTxt?.text = microgRemoteVer
|
microgLatestTxt?.text = microgRemoteVer.toString()
|
||||||
|
|
||||||
if (microgStatus!!) {
|
if (microgStatus!!) {
|
||||||
val microgVer =
|
val microgVer =
|
||||||
pm.getPackageInfo("com.mgoogle.android.gms", 0).versionName
|
pm.getPackageInfo("com.mgoogle.android.gms", 0).versionName.toInt()
|
||||||
if (microgRemoteVer > microgVer) {
|
when {
|
||||||
microginstallbtn?.text = activity?.getString(R.string.update)
|
microgRemoteVer > microgVer -> {
|
||||||
microginstallbtn?.icon =
|
microginstallbtn?.text = activity?.getString(R.string.update)
|
||||||
activity?.getDrawable(R.drawable.ic_cloud_upload_black_24dp)
|
microginstallbtn?.icon =
|
||||||
}
|
activity?.getDrawable(R.drawable.ic_cloud_upload_black_24dp)
|
||||||
else if (microgRemoteVer == microgVer) {
|
}
|
||||||
microginstallbtn?.text =
|
microgRemoteVer == microgVer -> {
|
||||||
activity?.getString(R.string.button_installed)
|
microginstallbtn?.text =
|
||||||
microginstallbtn?.icon =
|
activity?.getString(R.string.button_installed)
|
||||||
activity?.getDrawable(R.drawable.outline_cloud_done_24)
|
microginstallbtn?.icon =
|
||||||
|
activity?.getDrawable(R.drawable.outline_cloud_done_24)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vancedStatus!!) {
|
if (vancedStatus!!) {
|
||||||
val vancedVer =
|
val vancedVer =
|
||||||
pm.getPackageInfo("com.vanced.android.youtube", 0).versionName
|
pm.getPackageInfo("com.vanced.android.youtube", 0).versionName.toInt()
|
||||||
if (vancedRemoteVer > vancedVer) {
|
when {
|
||||||
vancedinstallbtn?.text = activity?.getString(R.string.update)
|
vancedRemoteVer > vancedVer -> {
|
||||||
vancedinstallbtn?.icon =
|
vancedinstallbtn?.text = activity?.getString(R.string.update)
|
||||||
activity?.getDrawable(R.drawable.ic_cloud_upload_black_24dp)
|
vancedinstallbtn?.icon =
|
||||||
}
|
activity?.getDrawable(R.drawable.ic_cloud_upload_black_24dp)
|
||||||
else if (vancedRemoteVer == vancedVer) {
|
}
|
||||||
vancedinstallbtn?.text =
|
vancedRemoteVer == vancedVer -> {
|
||||||
activity?.getString(R.string.button_installed)
|
vancedinstallbtn?.text =
|
||||||
vancedinstallbtn?.icon =
|
activity?.getString(R.string.button_installed)
|
||||||
activity?.getDrawable(R.drawable.outline_cloud_done_24)
|
vancedinstallbtn?.icon =
|
||||||
|
activity?.getDrawable(R.drawable.outline_cloud_done_24)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue