mirror of
https://github.com/YTVanced/VancedManager
synced 2024-11-22 19:25:11 +00:00
some little changes
This commit is contained in:
parent
4e68ad63f2
commit
8849903f95
13 changed files with 144 additions and 54 deletions
|
@ -72,15 +72,15 @@
|
|||
<content url="file://$MODULE_DIR$">
|
||||
<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/source/buildConfig/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/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/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/source/buildConfig/androidTest/debug" 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" />
|
||||
|
|
|
@ -9,7 +9,6 @@ import android.widget.*
|
|||
import androidx.navigation.findNavController
|
||||
import androidx.preference.PreferenceManager.getDefaultSharedPreferences
|
||||
import com.google.android.material.button.MaterialButton
|
||||
import com.google.android.material.switchmaterial.SwitchMaterial
|
||||
import com.topjohnwu.superuser.Shell
|
||||
import com.vanced.manager.R
|
||||
import com.vanced.manager.core.base.BaseFragment
|
||||
|
@ -31,32 +30,18 @@ open class Home : BaseFragment(), View.OnClickListener {
|
|||
val signaturebtn = view.findViewById<MaterialButton>(R.id.signature_button)
|
||||
val microguninstallbtn = view.findViewById<ImageView>(R.id.microg_uninstallbtn)
|
||||
val vanceduninstallbtn = view.findViewById<ImageView>(R.id.vanced_uninstallbtn)
|
||||
val switch: SwitchMaterial = view.findViewById(R.id.variant_switcher)
|
||||
val rootswitch = view.findViewById<MaterialButton>(R.id.root_switch)
|
||||
val nonrootswitch = view.findViewById<MaterialButton>(R.id.nonroot_switch)
|
||||
|
||||
val variantPref = getDefaultSharedPreferences(activity).getString("vanced_variant", "nonroot")
|
||||
//val variantPref = getDefaultSharedPreferences(activity).getString("vanced_variant", "nonroot")
|
||||
|
||||
vancedinstallbtn.setOnClickListener(this)
|
||||
microginstallbtn.setOnClickListener(this)
|
||||
signaturebtn.setOnClickListener(this)
|
||||
microguninstallbtn.setOnClickListener(this)
|
||||
vanceduninstallbtn.setOnClickListener(this)
|
||||
switch.setOnCheckedChangeListener { _, isChecked ->
|
||||
if (isChecked) {
|
||||
if (Shell.rootAccess())
|
||||
writeToVariantPref("root")
|
||||
else
|
||||
writeToVariantPref("nonroot")
|
||||
} else {
|
||||
writeToVariantPref("nonroot")
|
||||
}
|
||||
}
|
||||
|
||||
when (variantPref) {
|
||||
"nonroot" -> switch.isChecked = false
|
||||
"root" -> {
|
||||
switch.isChecked = Shell.rootAccess()
|
||||
}
|
||||
}
|
||||
rootswitch.setOnClickListener(this)
|
||||
nonrootswitch.setOnClickListener(this)
|
||||
|
||||
}
|
||||
|
||||
|
@ -134,20 +119,23 @@ open class Home : BaseFragment(), View.OnClickListener {
|
|||
}
|
||||
R.id.microg_uninstallbtn -> activity?.let { uninstallApk("com.mgoogle.android.gms", it) }
|
||||
R.id.vanced_uninstallbtn -> activity?.let { uninstallApk(vancedPkgName, it) }
|
||||
R.id.nonroot_switch -> writeToVariantPref("nonroot", R.anim.slide_in_left, R.anim.slide_out_right)
|
||||
R.id.root_switch ->
|
||||
if (Shell.rootAccess())
|
||||
writeToVariantPref("root", R.anim.slide_in_right, R.anim.slide_out_left)
|
||||
else
|
||||
writeToVariantPref("nonroot", R.anim.slide_in_left, R.anim.slide_out_right)
|
||||
}
|
||||
}
|
||||
|
||||
private fun writeToVariantPref(variant: String) {
|
||||
private fun writeToVariantPref(variant: String, animIn: Int, animOut: Int) {
|
||||
val prefs = getDefaultSharedPreferences(activity)
|
||||
if (prefs.getString("vanced_variant", "nonroot") != variant) {
|
||||
prefs.edit().putString("vanced_variant", variant).apply()
|
||||
restartActivity()
|
||||
startActivity(Intent(activity, MainActivity::class.java))
|
||||
activity?.overridePendingTransition(animIn, animOut)
|
||||
activity?.finish()
|
||||
} else Log.d("VMvariant", "$variant is already selected")
|
||||
}
|
||||
|
||||
private fun restartActivity() {
|
||||
startActivity(Intent(activity, MainActivity::class.java))
|
||||
activity?.finish()
|
||||
}
|
||||
|
||||
}
|
|
@ -16,8 +16,9 @@ class StubInstaller: Service() {
|
|||
if (!apkFile.exists()) {
|
||||
copyStub()
|
||||
}
|
||||
Log.d("VMpath", apkFile.path)
|
||||
Log.d("AppLog", "Installing stub...")
|
||||
val installResult = Shell.su("pm install ${apkFile.absolutePath}").exec()
|
||||
val installResult = Shell.su("pm install ${apkFile.path}").exec()
|
||||
Log.d("AppLog", "succeeded installing?${installResult.isSuccess}")
|
||||
if (installResult.isSuccess) {
|
||||
val mIntent = Intent(HomeFragment.SIGNATURE_DISABLED)
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package com.vanced.manager.ui.fragments
|
||||
|
||||
import android.animation.LayoutTransition
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.BroadcastReceiver
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
|
@ -46,7 +45,6 @@ class HomeFragment : Home() {
|
|||
return binding.root
|
||||
}
|
||||
|
||||
@SuppressLint("ClickableViewAccessibility")
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
|
@ -60,15 +58,15 @@ class HomeFragment : Home() {
|
|||
attachRootChangelog()
|
||||
if (viewModel.signatureStatusTxt.value != getString(R.string.signature_disabled)) {
|
||||
when (viewModel.signatureStatusTxt.value) {
|
||||
getString(R.string.unavailable) -> disableVancedButton(getString(R.string.signature_not_checked))
|
||||
getString(R.string.signature_enabled) -> disableVancedButton(getString(R.string.signature_disable))
|
||||
getString(R.string.unavailable) -> disableVancedButton()
|
||||
getString(R.string.signature_enabled) -> disableVancedButton()
|
||||
else -> throw NotImplementedError("Error handling status")
|
||||
}
|
||||
}
|
||||
} else {
|
||||
attachNonrootChangelog()
|
||||
if (!viewModel.microgInstalled) {
|
||||
disableVancedButton(getString(R.string.no_microg))
|
||||
disableVancedButton()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -82,19 +80,17 @@ class HomeFragment : Home() {
|
|||
val viewPagerContainer = view?.findViewById<ViewPager2>(R.id.viewpager)
|
||||
val tabLayoutContainer = view?.findViewById<TabLayout>(R.id.tablayout)
|
||||
val arrow = view?.findViewById<ImageButton>(R.id.changelog_button)
|
||||
val arrowAnimation: RotateAnimation
|
||||
if (isExpanded) {
|
||||
viewPagerContainer?.visibility = View.GONE
|
||||
tabLayoutContainer?.visibility = View.GONE
|
||||
isExpanded = false
|
||||
arrowAnimation = RotateAnimation(180f, 0f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f)
|
||||
arrow?.startAnimation(RotateAnimation(180f, 0f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f))
|
||||
} else {
|
||||
viewPagerContainer?.visibility = View.VISIBLE
|
||||
tabLayoutContainer?.visibility = View.VISIBLE
|
||||
isExpanded = true
|
||||
arrowAnimation = RotateAnimation(0f, 180f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f)
|
||||
arrow?.startAnimation(RotateAnimation(0f, 180f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f))
|
||||
}
|
||||
arrow?.startAnimation(arrowAnimation)
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
|
@ -210,12 +206,11 @@ class HomeFragment : Home() {
|
|||
super .onCreateOptionsMenu(menu, inflater)
|
||||
}
|
||||
|
||||
private fun disableVancedButton(txt: String) {
|
||||
private fun disableVancedButton() {
|
||||
val vancedinstallbtn = view?.findViewById<MaterialButton>(R.id.vanced_installbtn)
|
||||
vancedinstallbtn?.isEnabled = false
|
||||
vancedinstallbtn?.backgroundTintList = ColorStateList.valueOf(Color.DKGRAY)
|
||||
vancedinstallbtn?.setTextColor(ColorStateList.valueOf(Color.GRAY))
|
||||
vancedinstallbtn?.text = txt
|
||||
vancedinstallbtn?.icon = null
|
||||
}
|
||||
|
||||
|
|
|
@ -34,8 +34,6 @@ class HomeViewModel(application: Application): AndroidViewModel(application) {
|
|||
|
||||
private val pm = application.packageManager
|
||||
|
||||
val variantSwitchTxt = "Variant: $variant"
|
||||
|
||||
val microgInstalled: Boolean = isPackageInstalled("com.mgoogle.android.gms", application.packageManager)
|
||||
val vancedInstalled: Boolean = isPackageInstalled(vancedPkgName, application.packageManager)
|
||||
|
||||
|
@ -51,10 +49,8 @@ class HomeViewModel(application: Application): AndroidViewModel(application) {
|
|||
private val vancedVersionCode = displayJsonInt("vanced.json", "versionCode", application)
|
||||
private val microgVersionCode = displayJsonInt("microg.json", "versionCode", application)
|
||||
|
||||
val vancedInstallButtonTxt = compareInt(vancedInstalledVersionCode, vancedVersionCode, application)
|
||||
val microgInstallButtonTxt = compareInt(microgInstalledVersionCode, microgVersionCode, application)
|
||||
|
||||
val vancedInstallButtonIcon = compareIntDrawable(vancedInstalledVersionCode, vancedVersionCode, application)
|
||||
val microgInstallButtonIcon = compareIntDrawable(microgInstalledVersionCode, microgVersionCode, application)
|
||||
|
||||
val nonrootModeSelected: Boolean = variant == "nonroot"
|
||||
|
@ -140,5 +136,35 @@ class HomeViewModel(application: Application): AndroidViewModel(application) {
|
|||
|
||||
}
|
||||
|
||||
val vancedInstallButtonTxt =
|
||||
if (variant == "nonroot") {
|
||||
if (microgInstalled) {
|
||||
compareInt(vancedInstalledVersionCode, vancedVersionCode, application)
|
||||
} else {
|
||||
application.getString(R.string.no_microg)
|
||||
}
|
||||
} else {
|
||||
when (signatureStatusTxt.value) {
|
||||
application.getString(R.string.unavailable) -> application.getString(R.string.signature_not_checked)
|
||||
application.getString(R.string.signature_enabled) -> application.getString(R.string.signature_disable)
|
||||
application.getString(R.string.signature_disabled) -> compareInt(vancedInstalledVersionCode, vancedVersionCode, application)
|
||||
else -> throw NotImplementedError("Error handling status")
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
val vancedInstallButtonIcon =
|
||||
if (variant == "nonroot") {
|
||||
if (microgInstalled)
|
||||
compareIntDrawable(vancedInstalledVersionCode, vancedVersionCode, application)
|
||||
else
|
||||
null
|
||||
} else {
|
||||
if (signatureStatusTxt.value == application.getString(R.string.signature_disabled))
|
||||
compareIntDrawable(vancedInstalledVersionCode, vancedVersionCode, application)
|
||||
else
|
||||
null
|
||||
}
|
||||
|
||||
|
||||
}
|
9
app/src/main/res/anim/slide_in_left.xml
Normal file
9
app/src/main/res/anim/slide_in_left.xml
Normal file
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<set xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<translate
|
||||
android:fromXDelta="100%"
|
||||
android:toXDelta="0%"
|
||||
android:duration="500"/>
|
||||
|
||||
</set>
|
9
app/src/main/res/anim/slide_in_right.xml
Normal file
9
app/src/main/res/anim/slide_in_right.xml
Normal file
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<set xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<translate
|
||||
android:fromXDelta="-100%"
|
||||
android:toXDelta="0%"
|
||||
android:duration="500"/>
|
||||
|
||||
</set>
|
9
app/src/main/res/anim/slide_out_left.xml
Normal file
9
app/src/main/res/anim/slide_out_left.xml
Normal file
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<set xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<translate
|
||||
android:fromXDelta="0%"
|
||||
android:toXDelta="100%"
|
||||
android:duration="500"/>
|
||||
|
||||
</set>
|
9
app/src/main/res/anim/slide_out_right.xml
Normal file
9
app/src/main/res/anim/slide_out_right.xml
Normal file
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<set xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<translate
|
||||
android:fromXDelta="0%"
|
||||
android:toXDelta="-100%"
|
||||
android:duration="500"/>
|
||||
|
||||
</set>
|
|
@ -4,6 +4,6 @@
|
|||
android:viewportWidth="24.0"
|
||||
android:viewportHeight="24.0">
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:fillColor="?attr/colorOnSurfaceVariant"
|
||||
android:pathData="M7.41,7.84L12,12.42l4.59,-4.58L18,9.25l-6,6 -6,-6z"/>
|
||||
</vector>
|
||||
|
|
|
@ -27,11 +27,54 @@
|
|||
android:layout_marginTop="4dp"
|
||||
android:orientation="vertical">
|
||||
|
||||
<com.google.android.material.switchmaterial.SwitchMaterial
|
||||
android:id="@+id/variant_switcher"
|
||||
android:layout_width="wrap_content"
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@{viewModel.variantSwitchTxt}"/>
|
||||
android:orientation="horizontal">
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentStart="true">
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
style="@style/Widget.MaterialComponents.Button.OutlinedButton"
|
||||
android:text="@string/nonroot"/>
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/nonroot_switch"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
style="@style/ButtonStyle"
|
||||
android:text="@string/nonroot"
|
||||
android:visibility="@{viewModel.nonrootModeSelected ? View.GONE : View.VISIBLE}"/>
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentEnd="true">
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
style="@style/Widget.MaterialComponents.Button.OutlinedButton"
|
||||
android:text="@string/root"/>
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/root_switch"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
style="@style/ButtonStyle"
|
||||
android:text="@string/root"
|
||||
android:visibility="@{viewModel.nonrootModeSelected ? View.VISIBLE : View.GONE}"/>
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<include
|
||||
layout="@layout/include_vanced"
|
||||
|
|
|
@ -4,5 +4,7 @@
|
|||
<string name="app_name" translatable="false">Vanced Manager</string>
|
||||
<string name="vanced" translatable="false">Vanced</string>
|
||||
<string name="microg" translatable="false">MicroG</string>
|
||||
<string name="root" translatable="false">root</string>
|
||||
<string name="nonroot" translatable="false">nonroot</string>
|
||||
|
||||
</resources>
|
|
@ -32,8 +32,7 @@
|
|||
<string name="unavailable">Unavailable</string>
|
||||
<string name="update">Update</string>
|
||||
<string name="useful_links">Useful Links</string>
|
||||
<string name="vanced_medias">Vanced on Social Media</string>
|
||||
<string name="website_text">Vanced Website</string>
|
||||
<string name="website_text">Website</string>
|
||||
<string name="signature_disable">Disable Sig.</string>
|
||||
<string name="signature_disabled">Disabled</string>
|
||||
<string name="signature_enabled">Enabled</string>
|
||||
|
|
Loading…
Reference in a new issue