From beb9aef239bf7df5d17354026db1721f3aa01664 Mon Sep 17 00:00:00 2001 From: X1nto Date: Wed, 27 May 2020 14:15:44 +0400 Subject: [PATCH] revert changes --- .../com/vanced/manager/core/fragments/Home.kt | 35 +++++++++++++++++ .../manager/ui/fragments/HomeFragment.kt | 39 ------------------- 2 files changed, 35 insertions(+), 39 deletions(-) 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 cf91b603..1d155c96 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 @@ -34,10 +34,45 @@ open class Home : BaseFragment() { val microgsettingsbtn = view.findViewById(R.id.microg_settingsbtn) val vanceduninstallbtn = view.findViewById(R.id.vanced_uninstallbtn) + val microgProgress = view.findViewById(R.id.microg_progress) + val prefs = activity?.getSharedPreferences("installPrefs", Context.MODE_PRIVATE) + val isDownloading: Boolean? = prefs?.getBoolean("isDownloading", false) + //we need to check whether these apps are installed or not val microgStatus = pm?.let { isPackageInstalled("com.mgoogle.android.gms", it) } val vancedStatus = pm?.let { isPackageInstalled("com.vanced.android.youtube", it) } + vancedinstallbtn.setOnClickListener { + if (!isDownloading!!) { + try { + activity?.cacheDir?.deleteRecursively() + } catch (e: Exception) { + Log.d("VMCache", "Unable to delete cacheDir") + } + view.findNavController().navigate(R.id.toInstallVariantFragment) + } else { + Toast.makeText(activity, "Please wait until installation finishes", Toast.LENGTH_SHORT).show() + } + + } + + microginstallbtn.setOnClickListener { + if (!isDownloading!!) { + val dlText = view.findViewById(R.id.microg_downloading) + try { + installApk( + "https://x1nto.github.io/VancedFiles/microg.json", + microgProgress, + dlText + ) + } catch (e: Exception) { + Toast.makeText(activity, "Unable to start installation", Toast.LENGTH_SHORT).show() + } + } else { + Toast.makeText(activity, "Please wait until installation finishes", Toast.LENGTH_SHORT).show() + } + } + val microgVerText = view.findViewById(R.id.microg_installed_version) if (microgStatus!!) { val microgVer = pm.getPackageInfo("com.mgoogle.android.gms", 0).versionName 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 d73f5260..6309a2e7 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 @@ -1,15 +1,10 @@ package com.vanced.manager.ui.fragments import android.animation.ObjectAnimator -import android.content.Context import android.os.Bundle -import android.util.Log import android.view.* -import android.widget.ProgressBar import android.widget.TextView -import android.widget.Toast import androidx.core.animation.addListener -import androidx.navigation.findNavController import androidx.viewpager2.widget.ViewPager2 import com.dezlum.codelabs.getjson.GetJson import com.github.pwittchen.reactivenetwork.library.rx2.ReactiveNetwork @@ -69,9 +64,6 @@ class HomeFragment : Home() { val vancedLatestTxt = view?.findViewById(R.id.vanced_latest_version) val microgLatestTxt = view?.findViewById(R.id.microg_latest_version) val networkErrorLayout = view?.findViewById(R.id.home_network_wrapper) - val prefs = activity?.getSharedPreferences("installPrefs", Context.MODE_PRIVATE) - val microgProgress = view?.findViewById(R.id.microg_progress) - val isDownloading: Boolean? = prefs?.getBoolean("isDownloading", false) disposable = ReactiveNetwork.observeInternetConnectivity() .subscribeOn(Schedulers.io()) @@ -91,37 +83,6 @@ class HomeFragment : Home() { vancedLatestTxt?.text = vancedRemoteVer microgLatestTxt?.text = microgRemoteVer - vancedinstallbtn?.setOnClickListener { - if (!isDownloading!!) { - try { - activity?.cacheDir?.deleteRecursively() - } catch (e: Exception) { - Log.d("VMCache", "Unable to delete cacheDir") - } - view?.findNavController()?.navigate(R.id.toInstallVariantFragment) - } else { - Toast.makeText(activity, "Please wait until installation finishes", Toast.LENGTH_SHORT).show() - } - - } - - microginstallbtn?.setOnClickListener { - if (!isDownloading!!) { - val dlText = view?.findViewById(R.id.microg_downloading) - try { - installApk( - "https://x1nto.github.io/VancedFiles/microg.json", - microgProgress!!, - dlText!! - ) - } catch (e: Exception) { - Toast.makeText(activity, "Unable to start installation", Toast.LENGTH_SHORT).show() - } - } else { - Toast.makeText(activity, "Please wait until installation finishes", Toast.LENGTH_SHORT).show() - } - } - if (microgStatus!!) { val microgVer = pm.getPackageInfo("com.mgoogle.android.gms", 0).versionName