From 5a775b5e87d099104665be2b20c84f7132b1033a Mon Sep 17 00:00:00 2001 From: vincent Bourgmayer Date: Fri, 5 May 2023 11:04:37 +0200 Subject: [PATCH] Add sound records as root synced folder for device with build.version_codes equal to S --- .../e/drive/utils/RootSyncedFolderProvider.kt | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/app/src/main/java/foundation/e/drive/utils/RootSyncedFolderProvider.kt b/app/src/main/java/foundation/e/drive/utils/RootSyncedFolderProvider.kt index 2c3d46b9..367cfcd1 100644 --- a/app/src/main/java/foundation/e/drive/utils/RootSyncedFolderProvider.kt +++ b/app/src/main/java/foundation/e/drive/utils/RootSyncedFolderProvider.kt @@ -19,6 +19,9 @@ import android.os.Environment.DIRECTORY_DOCUMENTS import android.os.Environment.DIRECTORY_PICTURES import android.os.Environment.DIRECTORY_RINGTONES import android.os.Environment.DIRECTORY_MOVIES +import android.os.Environment.DIRECTORY_RECORDINGS + +import androidx.annotation.RequiresApi import com.owncloud.android.lib.resources.files.FileUtils.PATH_SEPARATOR import foundation.e.drive.models.SyncedFolder @@ -30,6 +33,7 @@ object RootSyncedFolderProvider { private const val CATEGORY_DOCUMENTS = "Documents" private const val CATEGORY_PODCASTS = "Podcasts" private const val CATEGORY_ROM_SETTINGS = "Rom settings" + private const val CATEGORY_AUDIO_RECORDS = "Records" private const val LOCAL_ROM_SETTINGS_PATH = "/data/system/users/0/" private val REMOTE_ROM_SETTINGS_PATH = PATH_SEPARATOR + "Devices" + PATH_SEPARATOR + BRAND + "_" + MODEL + "_" + Build.getSerial() + "/rom_settings/" @@ -54,6 +58,11 @@ object RootSyncedFolderProvider { syncedFolders.add(createRomSettingsSyncedFolder()) syncedFolders.add(createAppListSyncedFolder(context)) } + CATEGORY_AUDIO_RECORDS -> { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { + syncedFolders.add(createAudioRecordsSyncedFolder()) + } + } } } return syncedFolders @@ -66,6 +75,7 @@ object RootSyncedFolderProvider { CATEGORY_RINGTONES, CATEGORY_DOCUMENTS, CATEGORY_PODCASTS, + CATEGORY_AUDIO_RECORDS, CATEGORY_ROM_SETTINGS) } @@ -106,6 +116,11 @@ object RootSyncedFolderProvider { return createSettingsSyncedFolder(CATEGORY_ROM_SETTINGS, localPath, REMOTE_APP_LIST_PATH) } + @RequiresApi(Build.VERSION_CODES.S) + private fun createAudioRecordsSyncedFolder(): SyncedFolder { + return createMediaSyncedFolder(CATEGORY_AUDIO_RECORDS, DIRECTORY_RECORDINGS, "/Music/Sound records/") + } + private fun createMediaSyncedFolder(category: String, publicDirectoryType: String, remotePath: String): SyncedFolder { val dirPath = CommonUtils.getLocalPath(Environment.getExternalStoragePublicDirectory(publicDirectoryType)) val localPath = dirPath + PATH_SEPARATOR -- GitLab