diff --git a/app/src/main/java/com/vanced/manager/core/downloader/impl/MicrogDownloader.kt b/app/src/main/java/com/vanced/manager/core/downloader/impl/MicrogDownloader.kt index 9a02b181..99581ce3 100644 --- a/app/src/main/java/com/vanced/manager/core/downloader/impl/MicrogDownloader.kt +++ b/app/src/main/java/com/vanced/manager/core/downloader/impl/MicrogDownloader.kt @@ -4,6 +4,7 @@ import android.content.Context import com.vanced.manager.core.downloader.api.MicrogAPI import com.vanced.manager.core.downloader.base.AppDownloader import com.vanced.manager.core.downloader.util.DownloadStatus +import com.vanced.manager.core.downloader.util.getMicrogPath import java.io.File class MicrogDownloader( @@ -43,8 +44,7 @@ class MicrogDownloader( } override fun getSavedFilePath(): String { - val directory = - File(context.getExternalFilesDir("microg")!!.path) + val directory = File(getMicrogPath(context)) if (!directory.exists()) directory.mkdirs() diff --git a/app/src/main/java/com/vanced/manager/core/downloader/impl/MusicDownloader.kt b/app/src/main/java/com/vanced/manager/core/downloader/impl/MusicDownloader.kt index bb8bf897..b715b76e 100644 --- a/app/src/main/java/com/vanced/manager/core/downloader/impl/MusicDownloader.kt +++ b/app/src/main/java/com/vanced/manager/core/downloader/impl/MusicDownloader.kt @@ -4,6 +4,7 @@ import android.content.Context import com.vanced.manager.core.downloader.api.MusicAPI import com.vanced.manager.core.downloader.base.AppDownloader import com.vanced.manager.core.downloader.util.DownloadStatus +import com.vanced.manager.core.downloader.util.getVancedMusicPath import com.vanced.manager.core.preferences.holder.managerVariantPref import com.vanced.manager.core.preferences.holder.musicVersionPref import com.vanced.manager.core.util.getLatestOrProvidedAppVersion @@ -53,8 +54,7 @@ class MusicDownloader( } override fun getSavedFilePath(): String { - val directory = - File(context.getExternalFilesDir("vancedmusic")!!.path + "$absoluteVersion/$managerVariantPref") + val directory = File(getVancedMusicPath(absoluteVersion, managerVariantPref, context)) if (!directory.exists()) directory.mkdirs() diff --git a/app/src/main/java/com/vanced/manager/core/downloader/impl/VancedDownloader.kt b/app/src/main/java/com/vanced/manager/core/downloader/impl/VancedDownloader.kt index 8a66d255..7f8811f2 100644 --- a/app/src/main/java/com/vanced/manager/core/downloader/impl/VancedDownloader.kt +++ b/app/src/main/java/com/vanced/manager/core/downloader/impl/VancedDownloader.kt @@ -4,6 +4,7 @@ import android.content.Context import com.vanced.manager.core.downloader.api.VancedAPI import com.vanced.manager.core.downloader.base.AppDownloader import com.vanced.manager.core.downloader.util.DownloadStatus +import com.vanced.manager.core.downloader.util.getVancedMusicPath import com.vanced.manager.core.preferences.holder.managerVariantPref import com.vanced.manager.core.preferences.holder.vancedLanguagesPref import com.vanced.manager.core.preferences.holder.vancedThemePref @@ -64,8 +65,7 @@ class VancedDownloader( } override fun getSavedFilePath(): String { - val directory = - File(context.getExternalFilesDir("vanced")!!.path + "/$absoluteVersion/$managerVariantPref") + val directory = File(getVancedMusicPath(absoluteVersion, managerVariantPref, context)) if (!directory.exists()) directory.mkdirs() diff --git a/app/src/main/java/com/vanced/manager/core/downloader/util/DownloadPath.kt b/app/src/main/java/com/vanced/manager/core/downloader/util/DownloadPath.kt new file mode 100644 index 00000000..0692eb90 --- /dev/null +++ b/app/src/main/java/com/vanced/manager/core/downloader/util/DownloadPath.kt @@ -0,0 +1,19 @@ +package com.vanced.manager.core.downloader.util + +import android.content.Context + +fun getVancedPath( + version: String, + variant: String, + context: Context +) = context.getExternalFilesDir("vanced_youtube")!!.path + "/$version/$variant" + +fun getVancedMusicPath( + version: String, + variant: String, + context: Context +) = context.getExternalFilesDir("vanced_music")!!.path + "/$version/$variant" + +fun getMicrogPath( + context: Context +) = context.getExternalFilesDir("microg")!!.path \ No newline at end of file diff --git a/app/src/main/java/com/vanced/manager/core/installer/impl/MicrogInstaller.kt b/app/src/main/java/com/vanced/manager/core/installer/impl/MicrogInstaller.kt index 766a9b2d..6c673a75 100644 --- a/app/src/main/java/com/vanced/manager/core/installer/impl/MicrogInstaller.kt +++ b/app/src/main/java/com/vanced/manager/core/installer/impl/MicrogInstaller.kt @@ -1,6 +1,7 @@ package com.vanced.manager.core.installer.impl import android.content.Context +import com.vanced.manager.core.downloader.util.getMicrogPath import com.vanced.manager.core.installer.base.AppInstaller import com.vanced.manager.core.installer.util.installApp import java.io.File @@ -9,8 +10,11 @@ class MicrogInstaller( private val context: Context ) : AppInstaller() { - override fun install(appVersions: List?) { - val musicApk = File(context.getExternalFilesDir("microg/microg.apk")!!.path) + override fun install( + appVersions: List? + ) { + val musicApk = File(getMicrogPath(context) + "/microg.apk") + installApp(musicApk, context) } diff --git a/app/src/main/java/com/vanced/manager/core/installer/impl/MusicInstaller.kt b/app/src/main/java/com/vanced/manager/core/installer/impl/MusicInstaller.kt index 8704ffb6..825c29ec 100644 --- a/app/src/main/java/com/vanced/manager/core/installer/impl/MusicInstaller.kt +++ b/app/src/main/java/com/vanced/manager/core/installer/impl/MusicInstaller.kt @@ -1,20 +1,25 @@ package com.vanced.manager.core.installer.impl import android.content.Context +import com.vanced.manager.core.downloader.util.getVancedMusicPath import com.vanced.manager.core.installer.base.AppInstaller import com.vanced.manager.core.installer.util.installApp import com.vanced.manager.core.preferences.holder.managerVariantPref import com.vanced.manager.core.preferences.holder.musicVersionPref +import com.vanced.manager.core.preferences.holder.vancedVersionPref +import com.vanced.manager.core.util.getLatestOrProvidedAppVersion import java.io.File class MusicInstaller( private val context: Context ) : AppInstaller() { - override fun install(appVersions: List?) { - val musicApk = File( - context.getExternalFilesDir("music/$musicVersionPref/$managerVariantPref/music.apk")!!.path - ) + override fun install( + appVersions: List? + ) { + val absoluteVersion = getLatestOrProvidedAppVersion(musicVersionPref, appVersions) + + val musicApk = File(getVancedMusicPath(absoluteVersion, managerVariantPref, context) + "/music.apk") installApp(musicApk, context) } diff --git a/app/src/main/java/com/vanced/manager/core/installer/impl/VancedInstaller.kt b/app/src/main/java/com/vanced/manager/core/installer/impl/VancedInstaller.kt index 5a99d105..7ba18ead 100644 --- a/app/src/main/java/com/vanced/manager/core/installer/impl/VancedInstaller.kt +++ b/app/src/main/java/com/vanced/manager/core/installer/impl/VancedInstaller.kt @@ -1,21 +1,24 @@ package com.vanced.manager.core.installer.impl import android.content.Context +import com.vanced.manager.core.downloader.util.getVancedPath import com.vanced.manager.core.installer.base.AppInstaller import com.vanced.manager.core.installer.util.installSplitApp import com.vanced.manager.core.preferences.holder.managerVariantPref import com.vanced.manager.core.preferences.holder.vancedVersionPref import com.vanced.manager.core.util.getLatestOrProvidedAppVersion +import java.io.File class VancedInstaller( private val context: Context ) : AppInstaller() { - override fun install(appVersions: List?) { + override fun install( + appVersions: List? + ) { val absoluteVersion = getLatestOrProvidedAppVersion(vancedVersionPref, appVersions) - val apks = context - .getExternalFilesDir("vanced/$absoluteVersion/$managerVariantPref")!! + val apks = File(getVancedPath(absoluteVersion, managerVariantPref, context)) .listFiles { file -> file.extension == "apk" }