0
0
Fork 0
mirror of https://github.com/YTVanced/VancedManager synced 2024-11-26 05:05:15 +00:00

UI improvements and bug fixes

This commit is contained in:
X1nto 2020-05-25 15:29:07 +04:00
parent 029bf0f186
commit 9be5f5a3eb
8 changed files with 101 additions and 77 deletions

View file

@ -70,15 +70,15 @@
<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/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/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/renderscript_source_output_dir/debug/out" 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/renderscript_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/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/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/ap_generated_sources/debugUnitTest/out" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/res" type="java-resource" />

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

@ -1,5 +1,6 @@
package com.vanced.manager.core.base
import android.content.ActivityNotFoundException
import android.content.Intent
import android.content.pm.PackageManager
import android.net.Uri
@ -149,7 +150,7 @@ open class BaseFragment : Fragment() {
intent.setDataAndType(uri, "application/vnd.android.package-archive")
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
startActivity(intent)
startActivityForResult(intent, 69)
},
onError = { throwable ->
Toast.makeText(requireContext(), throwable.toString(), Toast.LENGTH_SHORT)
@ -158,4 +159,23 @@ open class BaseFragment : Fragment() {
)
}
fun uninstallApk(pkgUri: String) {
try {
val uri = Uri.parse(pkgUri)
val uninstall = Intent(Intent.ACTION_DELETE, uri)
startActivityForResult(uninstall, 69)
} catch (e: ActivityNotFoundException) {
Toast.makeText(requireContext(), "App not installed", Toast.LENGTH_SHORT).show()
activity?.recreate()
}
}
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
if (requestCode == 69) {
activity?.recreate()
}
}
}

View file

@ -11,7 +11,6 @@ import android.widget.*
import androidx.navigation.findNavController
import com.vanced.manager.R
import com.vanced.manager.core.base.BaseFragment
import java.io.File
open class Home : BaseFragment() {
@ -54,58 +53,46 @@ open class Home : BaseFragment() {
installApk("https://x1nto.github.io/VancedFiles/microg.json", microgProgress)
}
val microgVerText = view.findViewById<TextView>(R.id.microg_installed_version)
if (microgStatus!!) {
val microgVer = pm.getPackageInfo("com.mgoogle.android.gms", 0).versionName
microguninstallbtn.setOnClickListener {
try {
val uri = Uri.parse("package:com.mgoogle.android.gms")
val mgUninstall = Intent(Intent.ACTION_DELETE, uri)
startActivity(mgUninstall)
} catch (e: ActivityNotFoundException) {
Toast.makeText(requireContext(), "App not installed", Toast.LENGTH_SHORT).show()
activity?.recreate()
}
}
microgsettingsbtn.setOnClickListener {
try {
val intent = Intent()
intent.component = ComponentName(
"com.mgoogle.android.gms",
"org.microg.gms.ui.SettingsActivity"
)
startActivity(intent)
} catch (e: ActivityNotFoundException) {
Toast.makeText(requireContext(), "App not installed", Toast.LENGTH_SHORT).show()
activity?.recreate()
}
}
microgVerText.text = microgVer.toString()
} else {
microgsettingsbtn.visibility = View.INVISIBLE
microguninstallbtn.visibility = View.INVISIBLE
microgVerText.text = getString(R.string.unavailable)
}
val vancedVerText = view.findViewById<TextView>(R.id.vanced_installed_version)
if (vancedStatus!!) {
val vancedVer = pm.getPackageInfo("com.vanced.android.youtube", 0).versionName
vanceduninstallbtn.setOnClickListener {
try {
val uri = Uri.parse("package:com.vanced.android.youtube")
val vanUninstall = Intent(Intent.ACTION_DELETE, uri)
startActivity(vanUninstall)
} catch (e: ActivityNotFoundException) {
Toast.makeText(requireContext(), "App not installed", Toast.LENGTH_SHORT).show()
activity?.recreate()
val microgVerText = view.findViewById<TextView>(R.id.microg_installed_version)
when {
microgStatus!! -> {
val microgVer = pm.getPackageInfo("com.mgoogle.android.gms", 0).versionName
microguninstallbtn.setOnClickListener {
uninstallApk("com.mgoogle.android.gms")
}
microgsettingsbtn.setOnClickListener {
try {
val intent = Intent()
intent.component = ComponentName(
"com.mgoogle.android.gms",
"org.microg.gms.ui.SettingsActivity"
)
startActivity(intent)
} catch (e: ActivityNotFoundException) {
Toast.makeText(requireContext(), "App not installed", Toast.LENGTH_SHORT).show()
activity?.recreate()
}
}
microgVerText.text = microgVer.toString()
}
!microgStatus -> {
microgsettingsbtn.visibility = View.INVISIBLE
microguninstallbtn.visibility = View.INVISIBLE
microgVerText.text = getString(R.string.unavailable)
}
vancedStatus!! -> {
val vancedVer = pm.getPackageInfo("com.vanced.android.youtube", 0).versionName
vanceduninstallbtn.setOnClickListener {
uninstallApk("com.vanced.android.youtube")
}
vancedVerText.text = vancedVer.toString()
}
!vancedStatus -> {
vanceduninstallbtn.visibility = View.INVISIBLE
vancedVerText.text = getString(R.string.unavailable)
}
vancedVerText.text = vancedVer.toString()
} else {
vanceduninstallbtn.visibility = View.INVISIBLE
vancedVerText.text = getString(R.string.unavailable)
}
bravebtn.setOnClickListener {

View file

@ -3,12 +3,13 @@ package com.vanced.manager.ui.fragments
import android.animation.ObjectAnimator
import android.os.Bundle
import android.view.*
import android.widget.Button
import android.widget.TextView
import androidx.core.animation.addListener
import androidx.core.content.res.ResourcesCompat
import androidx.viewpager2.widget.ViewPager2
import com.dezlum.codelabs.getjson.GetJson
import com.github.pwittchen.reactivenetwork.library.rx2.ReactiveNetwork
import com.google.android.material.button.MaterialButton
import com.google.android.material.card.MaterialCardView
import com.google.android.material.tabs.TabLayout
import com.google.android.material.tabs.TabLayoutMediator
@ -44,6 +45,7 @@ class HomeFragment : Home() {
val tabLayout = view.findViewById(R.id.tablayout) as TabLayout
viewPager = view.findViewById(R.id.viewpager)
viewPager.adapter = sectionPageAdapter
viewPager.currentItem = 0
TabLayoutMediator(tabLayout, viewPager) { tab, position ->
when (position) {
@ -59,8 +61,8 @@ class HomeFragment : Home() {
val pm = activity?.packageManager
val microgStatus = pm?.let { isPackageInstalled("com.mgoogle.android.gms", it) }
val vancedStatus = pm?.let { isPackageInstalled("com.vanced.android.youtube", it) }
val microginstallbtn = view?.findViewById<Button>(R.id.microg_installbtn)
val vancedinstallbtn = view?.findViewById<Button>(R.id.vanced_installbtn)
val microginstallbtn = view?.findViewById<MaterialButton>(R.id.microg_installbtn)
val vancedinstallbtn = view?.findViewById<MaterialButton>(R.id.vanced_installbtn)
val vancedLatestTxt = view?.findViewById<TextView>(R.id.vanced_latest_version)
val microgLatestTxt = view?.findViewById<TextView>(R.id.microg_latest_version)
val networkErrorLayout = view?.findViewById<MaterialCardView>(R.id.home_network_wrapper)
@ -90,36 +92,45 @@ class HomeFragment : Home() {
when {
microgRemoteVer > microgVer -> {
microginstallbtn?.text = getString(R.string.update)
microginstallbtn?.icon = ResourcesCompat.getDrawable(resources, R.drawable.ic_cloud_upload_black_24dp, null)
}
microgRemoteVer == microgVer -> {
microginstallbtn?.text = getString(R.string.button_installed)
microginstallbtn?.icon = ResourcesCompat.getDrawable(resources, R.drawable.outline_cloud_done_24, null)
}
}
}
/*!microgStatus -> {
microginstallbtn?.setCompoundDrawablesRelativeWithIntrinsicBounds(
R.drawable.outline_cloud_download_24,
0,
0,
0
)
}
*/
vancedStatus!! -> {
val vancedVer =
pm.getPackageInfo("com.vanced.android.youtube", 0).versionName
when {
vancedRemoteVer > vancedVer -> {
vancedinstallbtn?.text = getString(R.string.update)
vancedinstallbtn?.setCompoundDrawablesRelativeWithIntrinsicBounds(
R.drawable.ic_cloud_upload_black_24dp,
0,
0,
0
)
vancedinstallbtn?.icon = ResourcesCompat.getDrawable(resources, R.drawable.ic_cloud_upload_black_24dp, null)
}
microgRemoteVer == vancedVer -> {
vancedRemoteVer == vancedVer -> {
vancedinstallbtn?.text = getString(R.string.update)
vancedinstallbtn?.setCompoundDrawablesRelativeWithIntrinsicBounds(
R.drawable.outline_cloud_done_24,
0,
0,
0
)
vancedinstallbtn?.icon = ResourcesCompat.getDrawable(resources, R.drawable.outline_cloud_done_24, null)
}
}
}
/*!vancedStatus -> {
vancedinstallbtn?.setCompoundDrawablesRelativeWithIntrinsicBounds(
R.drawable.outline_cloud_download_24,
0,
0,
0
)
}*/
}
val oa2 = ObjectAnimator.ofFloat(networkErrorLayout, "yFraction", 0f, 0.3f)

View file

@ -58,6 +58,8 @@
style="@style/Widget.AppCompat.ProgressBar.Horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="6dp"
android:layout_marginEnd="6dp"
android:visibility="gone"
tools:visibility="visible"/>

View file

@ -57,6 +57,8 @@
style="@style/Widget.AppCompat.ProgressBar.Horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="6dp"
android:layout_marginEnd="6dp"
android:visibility="gone"
tools:visibility="visible"/>

View file

@ -55,6 +55,8 @@
style="@style/Widget.AppCompat.ProgressBar.Horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="6dp"
android:layout_marginEnd="6dp"
android:visibility="gone"
tools:visibility="visible"/>