mirror of
https://github.com/YTVanced/VancedManager
synced 2024-11-26 21:13:01 +00:00
added warning for music
This commit is contained in:
parent
a7fa67e726
commit
6a0bd14680
4 changed files with 39 additions and 12 deletions
|
@ -14,19 +14,19 @@ import com.vanced.manager.utils.PackageHelper.installMusicRoot
|
|||
object MusicDownloader {
|
||||
|
||||
private var variant: String? = null
|
||||
private var version: String? = null
|
||||
private var musicVersion: String? = null
|
||||
private var versionCode: Int? = null
|
||||
private var baseurl = ""
|
||||
private var folderName: String? = null
|
||||
private var downloadPath: String? = null
|
||||
private var hashUrl: String? = null
|
||||
|
||||
fun downloadMusic(context: Context) {
|
||||
fun downloadMusic(context: Context, version: String? = null) {
|
||||
val prefs = context.defPrefs
|
||||
version = prefs.musicVersion?.getLatestAppVersion(musicVersions.value?.value ?: listOf(""))
|
||||
musicVersion = version ?: prefs.musicVersion?.getLatestAppVersion(musicVersions.value?.value ?: listOf(""))
|
||||
versionCode = music.value?.int("versionCode")
|
||||
variant = prefs.managerVariant
|
||||
baseurl = "$baseInstallUrl/music/v$version"
|
||||
baseurl = "$baseInstallUrl/music/v$musicVersion"
|
||||
folderName = "music/$variant"
|
||||
downloadPath = context.getExternalFilesDir(folderName)?.path
|
||||
hashUrl = "$baseurl/hash.json"
|
||||
|
|
|
@ -74,7 +74,7 @@ class AppDownloadDialog : BindingDialogFragment<DialogAppDownloadBinding>() {
|
|||
if (arguments?.getBoolean(TAG_INSTALLING) == false) {
|
||||
when (app) {
|
||||
getString(R.string.vanced) -> downloadVanced(requireContext(), arguments?.getString(TAG_VERSION))
|
||||
getString(R.string.music) -> downloadMusic(requireContext())
|
||||
getString(R.string.music) -> downloadMusic(requireContext(), arguments?.getString(TAG_VERSION))
|
||||
getString(R.string.microg) -> downloadMicrog(requireContext())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,13 +3,12 @@ package com.vanced.manager.ui.dialogs
|
|||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.ViewGroup
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
import com.vanced.manager.R
|
||||
import com.vanced.manager.core.ui.base.BindingBottomSheetDialogFragment
|
||||
import com.vanced.manager.core.ui.ext.showDialog
|
||||
import com.vanced.manager.databinding.DialogMusicPreferencesBinding
|
||||
import com.vanced.manager.utils.convertToAppVersions
|
||||
import com.vanced.manager.utils.defPrefs
|
||||
import com.vanced.manager.utils.musicVersions
|
||||
import com.vanced.manager.utils.*
|
||||
|
||||
class MusicPreferencesDialog : BindingBottomSheetDialogFragment<DialogMusicPreferencesBinding>() {
|
||||
|
||||
|
@ -21,6 +20,7 @@ class MusicPreferencesDialog : BindingBottomSheetDialogFragment<DialogMusicPrefe
|
|||
}
|
||||
|
||||
private val prefs by lazy { requireActivity().defPrefs }
|
||||
private val installPrefs by lazy { requireActivity().installPrefs }
|
||||
|
||||
override fun binding(
|
||||
inflater: LayoutInflater,
|
||||
|
@ -48,11 +48,37 @@ class MusicPreferencesDialog : BindingBottomSheetDialogFragment<DialogMusicPrefe
|
|||
}
|
||||
musicInstall.setOnClickListener {
|
||||
dismiss()
|
||||
showDialog(
|
||||
AppDownloadDialog.newInstance(
|
||||
app = getString(R.string.music)
|
||||
fun downloadMusic(version: String? = null) {
|
||||
showDialog(
|
||||
AppDownloadDialog.newInstance(
|
||||
app = getString(R.string.music),
|
||||
version = version
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
if (prefs.managerVariant == "nonroot" && isMicrogBroken && installPrefs.musicVersion?.getLatestAppVersion(
|
||||
vancedVersions.value?.value ?: listOf(""))?.take(3)?.toIntOrNull() ?: 0 >= 411 && !PackageHelper.isPackageInstalled(
|
||||
AppUtils.musicPkg,
|
||||
requireActivity().packageManager
|
||||
)
|
||||
) {
|
||||
MaterialAlertDialogBuilder(requireActivity()).apply {
|
||||
setTitle(R.string.microg_bug)
|
||||
setMessage(R.string.microg_bug_summary_music)
|
||||
setPositiveButton(R.string.auth_dialog_ok) { _, _ ->
|
||||
downloadMusic("4.07.51")
|
||||
}
|
||||
setNeutralButton(R.string.cancel) { _, _ ->
|
||||
dismiss()
|
||||
}
|
||||
create()
|
||||
}.applyAccent()
|
||||
return@setOnClickListener
|
||||
}
|
||||
|
||||
downloadMusic()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -84,6 +84,7 @@
|
|||
<string name="version">Version</string>
|
||||
<string name="microg_bug">Bug in microG</string>
|
||||
<string name="microg_bug_summary">Due to a bug in microG, installing Vanced 16+ first requires you to install v15.43.32, open it, then login and only then can you install v16 and higher. Do you want proceed with the installation of v15.43.32?</string>
|
||||
<string name="microg_bug_summary_music">Due to a bug in microG, installing Music 4.11+ first requires you to install v4.07.51, open it, then login and only then can you install v16 and higher. Do you want proceed with the installation of v4.07.51?</string>
|
||||
<string name="please_be_patient">Please be patient…</string>
|
||||
<string name="welcome">Welcome</string>
|
||||
|
||||
|
|
Loading…
Reference in a new issue