0
0
Fork 0
mirror of https://github.com/YTVanced/VancedManager synced 2024-11-22 19:25:11 +00:00

final steps

This commit is contained in:
X1nto 2020-06-02 16:19:04 +04:00
parent b72e5c0baf
commit 33b533317f
9 changed files with 141 additions and 39 deletions

View file

@ -70,17 +70,17 @@
<output-test url="file://$MODULE_DIR$/build/intermediates/javac/debugUnitTest/classes" />
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/kapt/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/ap_generated_sources/debug/out" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/aidl_source_output_dir/debug/out" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/renderscript_source_output_dir/debug/out" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/kaptKotlin/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/aidl_source_output_dir/debug/out" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/kapt/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/ap_generated_sources/debug/out" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/debug" type="java-resource" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/kapt/debugAndroidTest" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/ap_generated_sources/debugAndroidTest/out" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/aidl_source_output_dir/debugAndroidTest/out" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/androidTest/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/kapt/debugAndroidTest" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/renderscript_source_output_dir/debugAndroidTest/out" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/androidTest/debug" type="java-test-resource" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/kapt/debugUnitTest" isTestSource="true" generated="true" />
@ -135,10 +135,10 @@
<library name="Gradle: kaptGeneratedClasses">
<CLASSES>
<root url="file://$MODULE_DIR$/build/tmp/kapt3/classes/debugAndroidTest" />
<root url="file://$MODULE_DIR$/build/tmp/kapt3/classes/debug" />
<root url="file://$MODULE_DIR$/build/tmp/kapt3/classes/debugUnitTest" />
<root url="file://$MODULE_DIR$/build/tmp/kapt3/classes/release" />
<root url="file://$MODULE_DIR$/build/tmp/kapt3/classes/releaseUnitTest" />
<root url="file://$MODULE_DIR$/build/tmp/kapt3/classes/release" />
<root url="file://$MODULE_DIR$/build/tmp/kapt3/classes/debug" />
</CLASSES>
<JAVADOC />
<SOURCES />

View file

@ -0,0 +1,24 @@
package com.vanced.manager.adapter
import androidx.fragment.app.Fragment
import androidx.viewpager2.adapter.FragmentStateAdapter
import com.vanced.manager.ui.fragments.ManagerChangelogFragment
import com.vanced.manager.ui.fragments.VancedChangelogFragment
class SectionPageRootAdapter(fragment: Fragment) : FragmentStateAdapter(fragment) {
private val fragmentItems = 2
override fun getItemCount(): Int {
return fragmentItems
}
override fun createFragment(position: Int): Fragment {
var fragment: Fragment? = null
when (position) {
0 -> fragment = VancedChangelogFragment()
1 -> fragment = ManagerChangelogFragment()
}
return fragment!!
}
}

View file

@ -85,7 +85,23 @@ open class Main: BaseActivity() {
}
fun secondMiuiDialog() {
basicAlertBuilder("I'm gonna stop you right there!", "I am once again asking you to disable MiUI optimisations if you have not already. K thx bai")
AlertDialog.Builder(this)
.setTitle("I'm gonna stop you right there!")
.setMessage("I am once again asking you to disable MiUI optimisations if you have not already. K thx bai")
.setPositiveButton("wut?") { dialog, _ ->
run {
if (PreferenceManager.getDefaultSharedPreferences(this).getString("vanced_variant", "Nonroot") == "Root")
rootModeDetected()
else
dialog.dismiss()
}
}
.create()
.show()
}
fun rootModeDetected() {
basicAlertBuilder("Root mode detected!", "In order for app to work properly, please make sure you disabled signature verification.")
}
//Easter Egg

View file

@ -27,6 +27,7 @@ import zlc.season.rxdownload4.download
import zlc.season.rxdownload4.file
import zlc.season.rxdownload4.task.Task
import zlc.season.rxdownload4.utils.getFileNameFromUrl
import java.io.File
@SuppressLint("SetTextI18n")
open class BaseFragment : Fragment() {
@ -50,16 +51,27 @@ open class BaseFragment : Fragment() {
}
}
@SuppressLint("SdCardPath")
fun isRootVancedInstalled(): Boolean {
val file = File("/data/data/com.google.android.youtube/shared_prefs/youtube_vanced.xml")
return activity?.packageManager?.let {
isPackageInstalled("com.google.android.youtube",
it
)
}!! && file.exists()
}
fun downloadArch(loadBar: ProgressBar, dlText: TextView, loadCircle: ProgressBar) {
val prefs = activity?.getSharedPreferences("installPrefs", Context.MODE_PRIVATE)
prefs?.edit()?.putBoolean("isVancedDownloading", true)?.apply()
val variant = PreferenceManager.getDefaultSharedPreferences(activity).getString("vanced_variant", "Nonroot")
val arch =
when {
Build.SUPPORTED_ABIS.contains("x86") -> "x86"
Build.SUPPORTED_ABIS.contains("arm64-v8a") -> "arm64_v8a"
else -> "armeabi_v7a"
}
val url = "$baseUrl/Config/config.$arch.apk"
val url = "$baseUrl/$variant/Config/config.$arch.apk"
val task = activity?.cacheDir?.path?.let {
Task(
url = url,
@ -89,10 +101,12 @@ open class BaseFragment : Fragment() {
}
)
}
private fun downloadTheme(loadBar: ProgressBar, dlText: TextView, loadCircle: ProgressBar) {
val variant = PreferenceManager.getDefaultSharedPreferences(activity).getString("vanced_variant", "Nonroot")
val prefs = activity?.getSharedPreferences("installPrefs", Context.MODE_PRIVATE)
val theme = prefs?.getString("theme", "dark")
val url = "$baseUrl/Theme/$theme.apk"
val url = "$baseUrl/$variant/Theme/$theme.apk"
val task = activity?.cacheDir?.path?.let {
Task(
@ -123,9 +137,10 @@ open class BaseFragment : Fragment() {
}
private fun downloadLang(loadBar: ProgressBar, dlText: TextView, loadCircle: ProgressBar) {
val variant = PreferenceManager.getDefaultSharedPreferences(activity).getString("vanced_variant", "Nonroot")
val prefs = activity?.getSharedPreferences("installPrefs", Context.MODE_PRIVATE)
val lang = prefs?.getString("lang", "en")
val url = "$baseUrl/Language/split_config.$lang.apk"
val url = "$baseUrl/$variant/Language/split_config.$lang.apk"
val task = activity?.cacheDir?.path?.let {
Task(
@ -154,8 +169,12 @@ open class BaseFragment : Fragment() {
dlText.visibility = View.GONE
loadCircle.visibility = View.VISIBLE
prefs.edit()?.putBoolean("isVancedDownloading", false)?.apply()
if (PreferenceManager.getDefaultSharedPreferences(activity).getString("vanced_variant", "Nonroot") == "Root") {
launchRootInstaller()
} else {
launchInstaller()
}
}
},
onError = { throwable ->
Toast.makeText(activity, throwable.toString(), Toast.LENGTH_SHORT).show()
@ -164,8 +183,9 @@ open class BaseFragment : Fragment() {
}
private fun downloadEn(loadBar: ProgressBar, dlText: TextView, loadCircle: ProgressBar) {
val variant = PreferenceManager.getDefaultSharedPreferences(activity).getString("vanced_variant", "Nonroot")
val prefs = activity?.getSharedPreferences("installPrefs", Context.MODE_PRIVATE)
val url = "https://x1nto.github.io/VancedFiles/Splits/Language/split_config.en.apk"
val url = "https://x1nto.github.io/VancedFiles/Splits/$variant/Language/split_config.en.apk"
val task = activity?.cacheDir?.path?.let {
Task(
url = url,
@ -191,7 +211,7 @@ open class BaseFragment : Fragment() {
dlText.visibility = View.GONE
loadCircle.visibility = View.VISIBLE
prefs?.edit()?.putBoolean("isVancedDownloading", false)?.apply()
if (PreferenceManager.getDefaultSharedPreferences(activity).getString("vanced_variant", "nonroot") == "root") {
if (PreferenceManager.getDefaultSharedPreferences(activity).getString("vanced_variant", "Nonroot") == "Root") {
launchRootInstaller()
} else {
launchInstaller()

View file

@ -44,13 +44,24 @@ open class Home : BaseFragment() {
//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) }
val vancedStatus =
if (PreferenceManager.getDefaultSharedPreferences(activity).getString("vanced_variant", "Nonroot") == "Root")
isRootVancedInstalled()
else
pm?.let { isPackageInstalled("com.vanced.android.youtube", it) }
vancedinstallbtn.setOnClickListener {
if (!isVancedDownloading!!) {
if (MiuiHelper.isMiui()) {
val mainActivity = (activity as MainActivity)
if (PreferenceManager.getDefaultSharedPreferences(activity).getString("vanced_variant", "Nonroot") == "Root") {
if (MiuiHelper.isMiui()) {
mainActivity.secondMiuiDialog()
} else
mainActivity.rootModeDetected()
} else {
if (MiuiHelper.isMiui()) {
mainActivity.secondMiuiDialog()
}
}
try {
activity?.cacheDir?.deleteRecursively()
@ -107,7 +118,11 @@ open class Home : BaseFragment() {
microgsettingsbtn.visibility = View.INVISIBLE
microguninstallbtn.visibility = View.INVISIBLE
microgVerText.text = getString(R.string.unavailable)
vancedinstallbtn.isEnabled = PreferenceManager.getDefaultSharedPreferences(activity).getString("vanced_variant", "nonroot") != "nonroot"
vancedinstallbtn.isEnabled = PreferenceManager.getDefaultSharedPreferences(activity).getString("vanced_variant", "Nonroot") != "Nonroot"
if (!vancedinstallbtn.isEnabled) {
vancedinstallbtn.setBackgroundColor(R.attr.colorDisabled)
vancedinstallbtn.setTextColor(R.attr.colorDisabledVariant)
}
}
val vancedVerText = view.findViewById<TextView>(R.id.vanced_installed_version)

View file

@ -132,7 +132,11 @@ class MainActivity : Main() {
private fun launchVanced() {
val intent = Intent()
intent.component = ComponentName("com.vanced.android.youtube", "com.google.android.youtube.HomeActivity")
intent.component =
if (PreferenceManager.getDefaultSharedPreferences(this).getString("vanced_variant", "Nonroot") == "Root")
ComponentName("com.google.android.youtube", "com.google.android.youtube.HomeActivity")
else
ComponentName("com.vanced.android.youtube", "com.google.android.youtube.HomeActivity")
AlertDialog.Builder(this)
.setTitle("Success!")
.setMessage("Vanced has been successfully installed, do you want to launch it now?")

View file

@ -16,6 +16,7 @@ import com.google.android.material.tabs.TabLayout
import com.google.android.material.tabs.TabLayoutMediator
import com.vanced.manager.R
import com.vanced.manager.adapter.SectionPageAdapter
import com.vanced.manager.adapter.SectionPageRootAdapter
import com.vanced.manager.core.fragments.Home
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.disposables.Disposable
@ -25,6 +26,7 @@ import io.reactivex.schedulers.Schedulers
class HomeFragment : Home() {
private lateinit var sectionPageAdapter: SectionPageAdapter
private lateinit var sectionPageRootAdapter: SectionPageRootAdapter
private lateinit var viewPager: ViewPager2
private var disposable: Disposable? = null
@ -43,7 +45,7 @@ class HomeFragment : Home() {
initNetworkFun()
val variantPref = getDefaultSharedPreferences(activity).getString("vanced_variant", "nonroot")
val variantPref = getDefaultSharedPreferences(activity).getString("vanced_variant", "Nonroot")
val microgWrapper = view.findViewById<MaterialCardView>(R.id.home_microg_wrapper)
if (variantPref == "root") {
@ -56,18 +58,10 @@ class HomeFragment : Home() {
}
}
sectionPageAdapter = SectionPageAdapter(this)
val tabLayout = view.findViewById(R.id.tablayout) as TabLayout
viewPager = view.findViewById(R.id.viewpager)
viewPager.adapter = sectionPageAdapter
TabLayoutMediator(tabLayout, viewPager) { tab, position ->
when (position) {
0 -> tab.text = "Vanced"
1 -> tab.text = "MicroG"
2 -> tab.text = "Manager"
}
}.attach()
if (variantPref == "Root")
attachRootChangelog()
else
attachNonrootChangelog()
}
@ -103,7 +97,7 @@ class HomeFragment : Home() {
GetJson().AsJSONObject("https://x1nto.github.io/VancedFiles/microg.json")
.get("versionCode").asInt
if (variant == "nonroot") {
if (variant == "Nonroot") {
val microgLatestTxt =
view?.findViewById<TextView>(R.id.microg_latest_version)
val microginstallbtn =
@ -224,6 +218,35 @@ class HomeFragment : Home() {
}
}
private fun attachNonrootChangelog() {
sectionPageAdapter = SectionPageAdapter(this)
val tabLayout = view?.findViewById(R.id.tablayout) as TabLayout
viewPager = view?.findViewById(R.id.viewpager)!!
viewPager.adapter = sectionPageAdapter
TabLayoutMediator(tabLayout, viewPager) { tab, position ->
when (position) {
0 -> tab.text = "Vanced"
1 -> tab.text = "MicroG"
2 -> tab.text = "Manager"
}
}.attach()
}
private fun attachRootChangelog() {
sectionPageRootAdapter = SectionPageRootAdapter(this)
val tabLayout = view?.findViewById(R.id.tablayout) as TabLayout
viewPager = view?.findViewById(R.id.viewpager)!!
viewPager.adapter = sectionPageRootAdapter
TabLayoutMediator(tabLayout, viewPager) { tab, position ->
when (position) {
0 -> tab.text = "Vanced"
1 -> tab.text = "Manager"
}
}.attach()
}
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
inflater.inflate(R.menu.toolbar_menu, menu)
super .onCreateOptionsMenu(menu, inflater)

View file

@ -38,12 +38,12 @@ class SettingsFragment : PreferenceFragmentCompat() {
}
val installMode: DropDownPreference? = findPreference("vanced_variant")
installMode?.summary = preferenceScreen.sharedPreferences.getString("vanced_variant", "nonroot")
installMode?.summary = preferenceScreen.sharedPreferences.getString("vanced_variant", "Nonroot")
installMode?.setOnPreferenceChangeListener{ _, _ ->
when (installMode.value) {
"root" -> {
"Root" -> {
if (!Shell.rootAccess()) {
preferenceScreen.sharedPreferences.edit().putString("vanced_variant", "nonroot").apply()
preferenceScreen.sharedPreferences.edit().putString("vanced_variant", "Nonroot").apply()
}
}
}

View file

@ -35,8 +35,8 @@
</string-array>
<string-array name="vanced_variant_values">
<item>nonroot</item>
<item>root</item>
<item>Nonroot</item>
<item>Root</item>
</string-array>
<string-array name="syke">