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

made new installer toggleable

This commit is contained in:
X1nto 2020-08-26 18:22:36 +04:00
parent 1b38101928
commit fbe3076267
5 changed files with 44 additions and 31 deletions

View file

@ -41,6 +41,7 @@ class VancedDownloadService: Service() {
private var variant: String? = null
private var theme: String? = null
private var lang: Array<String>? = null
private var newInstaller: Boolean? = null
private lateinit var themePath: String
@ -65,6 +66,7 @@ class VancedDownloadService: Service() {
theme = prefs.getString("theme", "dark")
themePath = "$installUrl/apks/v$vancedVersion/$variant/Theme"
hashUrl = "apks/v$vancedVersion/$variant/Theme/hash.json"
newInstaller = defPrefs.getBoolean("new_installer", false)
arch =
when {
Build.SUPPORTED_ABIS.contains("x86") -> "x86"
@ -105,7 +107,7 @@ class VancedDownloadService: Service() {
override fun onDownloadComplete() {
when (type) {
"theme" ->
if (variant == "root") {
if (variant == "root" && newInstaller == true) {
if (ValidateTheme()) {
if(downloadStockCheck())
downloadSplits("arch")
@ -115,7 +117,7 @@ class VancedDownloadService: Service() {
downloadSplits("theme")
} else
downloadSplits("arch")
"arch" -> if (variant == "root") downloadSplits("stock") else downloadSplits("lang")
"arch" -> if (variant == "root" && newInstaller == true) downloadSplits("stock") else downloadSplits("lang")
"stock" -> downloadSplits("dpi")
"dpi" -> downloadSplits("lang")
"lang" -> {

View file

@ -9,6 +9,7 @@ import android.util.Log
import androidx.annotation.Nullable
import androidx.annotation.WorkerThread
import androidx.localbroadcastmanager.content.LocalBroadcastManager
import androidx.preference.PreferenceManager.getDefaultSharedPreferences
import com.topjohnwu.superuser.Shell
import com.topjohnwu.superuser.io.SuFile
import com.vanced.manager.BuildConfig
@ -32,7 +33,7 @@ import kotlin.collections.ArrayList
class RootSplitInstallerService: Service() {
private var vancedVersionCode: Int = runBlocking { getJsonInt("vanced.json","versionCode", application) }
val yPkg = "com.google.android.youtube"
private val yPkg = "com.google.android.youtube"
private val localBroadcastManager by lazy { LocalBroadcastManager.getInstance(this) }
@ -56,12 +57,16 @@ class RootSplitInstallerService: Service() {
}
}
if (modApk != null) {
if (getDefaultSharedPreferences(this@RootSplitInstallerService).getBoolean("new_installer", false)) {
if (overwriteBase(modApk, fileInfoList, vancedVersionCode)) {
with(localBroadcastManager) {
sendBroadcast(Intent(HomeFragment.REFRESH_HOME))
sendBroadcast(Intent(HomeFragment.VANCED_INSTALLED))
}
}
} else
installSplitApkFiles(fileInfoList)
}
else
{
@ -229,9 +234,7 @@ class RootSplitInstallerService: Service() {
if(PackageHelper.uninstallApk(yPkg, applicationContext)) {
return installSplitApkFiles(apkFiles)
}
with(localBroadcastManager) {
sendFailure(listOf("Failed_Uninstall").toMutableList(), applicationContext)
}
sendFailure(listOf("Failed_Uninstall").toMutableList(), this)
return false
}

View file

@ -40,10 +40,10 @@ object AppUtils {
status.contains("INSTALL_FAILED_VERSION_DOWNGRADE") -> context.getString(R.string.installation_downgrade)
status.contains("INSTALL_PARSE_FAILED_NO_CERTIFICATES") -> context.getString(R.string.installation_signature)
status.contains("Failed_Uninstall") -> context.getString(R.string.Failed_Uninstall)
status.contains("Chown_Fail") -> context.getString(R.string.Chown_Fail)
status.contains("IFile_Missing") -> context.getString(R.string.IFile_Missing)
status.contains("ModApk_Missing") -> context.getString(R.string.ModApk_Missing)
status.contains("Files_Missing_VA") -> context.getString(R.string.Files_Missing_VA)
status.contains("Chown_Fail") -> context.getString(R.string.chown_fail)
status.contains("IFile_Missing") -> context.getString(R.string.ifile_missing)
status.contains("ModApk_Missing") -> context.getString(R.string.modapk_missing)
status.contains("Files_Missing_VA") -> context.getString(R.string.files_missing_va)
else ->
if (MiuiHelper.isMiui())
context.getString(R.string.installation_miui)

View file

@ -14,20 +14,8 @@
<!-- Home Page -->
<string name="changelogs">Changelogs</string>
<string name="downloading_file">Downloading %1$s</string>
<string name="failed_uninstall">Failed to uninstall package %1$s</string>
<string name="error_downloading">Error Downloading %1$s</string>
<string name="install">Install</string>
<string name="installing_app">Installing %1$s</string>
<string name="installation_aborted">Installation failed because user aborted the installation.</string>
<string name="installation_blocked">Installation failed because user blocked the installation.</string>
<string name="installation_downgrade">Installation failed because user tried to downgrade the package. Uninstall updates from stock YouTube app, then try again.</string>
<string name="installation_conflict">Installation failed because the app conflicts with an already installed app. Uninstall the current version of Vanced, then try again.</string>
<string name="installation_failed">Installation failed for unknown reasons, join our Telegram or Discord for further support.</string>
<string name="installation_incompatible">Installation failed because the installation file is incompatible with your device. Clear downloaded files in the Settings, then try again.</string>
<string name="installation_invalid">Installation failed because the apk files are corrupted, please try again.</string>
<string name="installation_signature">Installation failed because apk signature verification is enabled. Disable apk signature verification, then try again.</string>
<string name="installation_miui">Installation failed because MIUI Optimization is enabled. Disable MIUI Optimization, then try again.</string>
<string name="installation_storage">Installation failed due to a storage error.</string>
<string name="installation_wait">DO NOT leave the app until the installation finishes.</string>
<string name="button_reinstall">Reinstall</string>
<string name="version_installed">Installed:</string>
@ -61,6 +49,8 @@
<string name="link_title">Use Chrome Custom Tabs</string>
<string name="link_custom_tabs">Links will open in Chrome Custom Tabs</string>
<string name="link_external_browser">Links will open in an External Browser</string>
<string name="new_installer_title">Use new root installer (Experimental)</string>
<string name="new_installer_summary">This installer does not depend on Signature Verification ststus</string>
<string name="theme">Theme</string>
<string name="theme_follow">Follow System</string>
<string name="theme_dark">Dark Theme</string>
@ -101,10 +91,23 @@
<string name="manager_dev">Manager Dev</string>
<string name="sources">Sources</string>
<string name="vanced_team">Vanced Team</string>
<string name="Failed_Uninstall">Failed Uninstall Of Installed Version, Try Manually</string>
<string name="Chown_Fail">Failed To Chown Apk to system owner, Try Again</string>
<string name="IFile_Missing">Dark/Black.apk Cannot Be Read(Did Storage Get Blocked?) or File Missing</string>
<string name="ModApk_Missing">Black/Dark apk missing from installer, This should not happen, please clear app data of manager</string>
<!-- Error messages -->
<string name="chown_fail">Failed To Chown Apk to system owner, Try Again</string>
<string name="error_downloading">Error Downloading %1$s</string>
<string name="failed_uninstall">Failed to uninstall package %1$s</string>
<string name="Files_Missing_VA">Files are missing, Failed Download?</string>
<string name="ifile_missing">Dark/Black.apk Cannot Be Read(Did Storage Get Blocked?) or File Missing</string>
<string name="installation_aborted">Installation failed because user aborted the installation.</string>
<string name="installation_blocked">Installation failed because user blocked the installation.</string>
<string name="installation_downgrade">Installation failed because user tried to downgrade the package. Uninstall updates from stock YouTube app, then try again.</string>
<string name="installation_conflict">Installation failed because the app conflicts with an already installed app. Uninstall the current version of Vanced, then try again.</string>
<string name="installation_failed">Installation failed for unknown reasons, join our Telegram or Discord for further support.</string>
<string name="installation_incompatible">Installation failed because the installation file is incompatible with your device. Clear downloaded files in the Settings, then try again.</string>
<string name="installation_invalid">Installation failed because the apk files are corrupted, please try again.</string>
<string name="installation_signature">Installation failed because apk signature verification is enabled. Disable apk signature verification, then try again.</string>
<string name="installation_miui">Installation failed because MIUI Optimization is enabled. Disable MIUI Optimization, then try again.</string>
<string name="installation_storage">Installation failed due to a storage error.</string>
<string name="modapk_Missing">Black/Dark apk missing from installer, This should not happen, please clear app data of manager</string>
</resources>

View file

@ -30,6 +30,11 @@
android:defaultValue="true"
android:icon="@drawable/ic_notifications_black_24dp"/>
<SwitchPreference
android:key="new_installer"
android:title="@string/new_installer_title"
android:summary="@string/new_installer_summary" />
</PreferenceCategory>
<PreferenceCategory