mirror of
https://github.com/YTVanced/VancedManager
synced 2024-12-01 23:37:26 +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,46 +74,50 @@ 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 {
|
||||||
|
microgRemoteVer > microgVer -> {
|
||||||
microginstallbtn?.text = activity?.getString(R.string.update)
|
microginstallbtn?.text = activity?.getString(R.string.update)
|
||||||
microginstallbtn?.icon =
|
microginstallbtn?.icon =
|
||||||
activity?.getDrawable(R.drawable.ic_cloud_upload_black_24dp)
|
activity?.getDrawable(R.drawable.ic_cloud_upload_black_24dp)
|
||||||
}
|
}
|
||||||
else if (microgRemoteVer == microgVer) {
|
microgRemoteVer == microgVer -> {
|
||||||
microginstallbtn?.text =
|
microginstallbtn?.text =
|
||||||
activity?.getString(R.string.button_installed)
|
activity?.getString(R.string.button_installed)
|
||||||
microginstallbtn?.icon =
|
microginstallbtn?.icon =
|
||||||
activity?.getDrawable(R.drawable.outline_cloud_done_24)
|
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 {
|
||||||
|
vancedRemoteVer > vancedVer -> {
|
||||||
vancedinstallbtn?.text = activity?.getString(R.string.update)
|
vancedinstallbtn?.text = activity?.getString(R.string.update)
|
||||||
vancedinstallbtn?.icon =
|
vancedinstallbtn?.icon =
|
||||||
activity?.getDrawable(R.drawable.ic_cloud_upload_black_24dp)
|
activity?.getDrawable(R.drawable.ic_cloud_upload_black_24dp)
|
||||||
}
|
}
|
||||||
else if (vancedRemoteVer == vancedVer) {
|
vancedRemoteVer == vancedVer -> {
|
||||||
vancedinstallbtn?.text =
|
vancedinstallbtn?.text =
|
||||||
activity?.getString(R.string.button_installed)
|
activity?.getString(R.string.button_installed)
|
||||||
vancedinstallbtn?.icon =
|
vancedinstallbtn?.icon =
|
||||||
activity?.getDrawable(R.drawable.outline_cloud_done_24)
|
activity?.getDrawable(R.drawable.outline_cloud_done_24)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
val oa2 = ObjectAnimator.ofFloat(networkErrorLayout, "yFraction", 0f, 0.3f)
|
val oa2 = ObjectAnimator.ofFloat(networkErrorLayout, "yFraction", 0f, 0.3f)
|
||||||
val oa3 = ObjectAnimator.ofFloat(networkErrorLayout, "yFraction", 0.3f, -1f)
|
val oa3 = ObjectAnimator.ofFloat(networkErrorLayout, "yFraction", 0.3f, -1f)
|
||||||
|
|
Loading…
Reference in a new issue