diff --git a/app/src/main/java/foundation/e/drive/FileObservers/FileEventListener.java b/app/src/main/java/foundation/e/drive/FileObservers/FileEventListener.java index 43d47a8abed80726c35d965eb2f3e4d7f366bc36..5f9a07f442b51d78fa0092a4f9fa854091079d96 100644 --- a/app/src/main/java/foundation/e/drive/FileObservers/FileEventListener.java +++ b/app/src/main/java/foundation/e/drive/FileObservers/FileEventListener.java @@ -27,6 +27,7 @@ import foundation.e.drive.database.DbHelper; import foundation.e.drive.models.SyncRequest; import foundation.e.drive.models.SyncedFileState; import foundation.e.drive.models.SyncedFolder; +import foundation.e.drive.services.SynchronizationService; import foundation.e.drive.utils.CommonUtils; import foundation.e.drive.utils.SynchronizationServiceConnection; import timber.log.Timber; 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 2c3d46b90f3c5039e862da228194585dd91ab558..cd03ed03637abac006796c2a735299d369989ec4 100644 --- a/app/src/main/java/foundation/e/drive/utils/RootSyncedFolderProvider.kt +++ b/app/src/main/java/foundation/e/drive/utils/RootSyncedFolderProvider.kt @@ -12,13 +12,15 @@ import android.os.Build import android.os.Build.BRAND import android.os.Build.MODEL import android.os.Environment -import android.os.Environment.DIRECTORY_PODCASTS -import android.os.Environment.DIRECTORY_MUSIC import android.os.Environment.DIRECTORY_DCIM import android.os.Environment.DIRECTORY_DOCUMENTS +import android.os.Environment.DIRECTORY_MOVIES +import android.os.Environment.DIRECTORY_MUSIC import android.os.Environment.DIRECTORY_PICTURES +import android.os.Environment.DIRECTORY_PODCASTS +import android.os.Environment.DIRECTORY_RECORDINGS import android.os.Environment.DIRECTORY_RINGTONES -import android.os.Environment.DIRECTORY_MOVIES +import androidx.annotation.RequiresApi import com.owncloud.android.lib.resources.files.FileUtils.PATH_SEPARATOR import foundation.e.drive.models.SyncedFolder @@ -26,6 +28,7 @@ object RootSyncedFolderProvider { private const val CATEGORY_IMAGES = "Images" private const val CATEGORY_MOVIES = "Movies" private const val CATEGORY_MUSIC = "Music" + private const val CATEGORY_RECORDINGS = "Recordings" private const val CATEGORY_RINGTONES = "Ringtones" private const val CATEGORY_DOCUMENTS = "Documents" private const val CATEGORY_PODCASTS = "Podcasts" @@ -48,6 +51,11 @@ object RootSyncedFolderProvider { CATEGORY_MOVIES -> syncedFolders.add(createMovieSyncedFolder()) CATEGORY_DOCUMENTS -> syncedFolders.add(createDocumentsSyncedFolder()) CATEGORY_MUSIC -> syncedFolders.add(createMusicsSyncedFolder()) + CATEGORY_RECORDINGS -> { + if (isAboveA12()) { + syncedFolders.add(createRecordingsSyncedFolder()) + } + } CATEGORY_PODCASTS -> syncedFolders.add(createPodcastsSyncedFolder()) CATEGORY_RINGTONES -> syncedFolders.add(createRingtonesSyncedFolder()) CATEGORY_ROM_SETTINGS -> { @@ -60,13 +68,16 @@ object RootSyncedFolderProvider { } private fun getSyncableCategories(): List { - return listOf(CATEGORY_IMAGES, - CATEGORY_MOVIES, - CATEGORY_MUSIC, - CATEGORY_RINGTONES, - CATEGORY_DOCUMENTS, - CATEGORY_PODCASTS, - CATEGORY_ROM_SETTINGS) + return listOf( + CATEGORY_IMAGES, + CATEGORY_MOVIES, + CATEGORY_MUSIC, + CATEGORY_RECORDINGS, + CATEGORY_RINGTONES, + CATEGORY_DOCUMENTS, + CATEGORY_PODCASTS, + CATEGORY_ROM_SETTINGS, + ) } private fun createPhotosSyncedFolder(): SyncedFolder { @@ -89,6 +100,11 @@ object RootSyncedFolderProvider { return createMediaSyncedFolder(CATEGORY_MUSIC, DIRECTORY_MUSIC, "/Music/") } + @RequiresApi(Build.VERSION_CODES.S) + private fun createRecordingsSyncedFolder(): SyncedFolder { + return createMediaSyncedFolder(CATEGORY_RECORDINGS, DIRECTORY_RECORDINGS, "/Recordings/") + } + private fun createRingtonesSyncedFolder(): SyncedFolder { return createMediaSyncedFolder(CATEGORY_RINGTONES, DIRECTORY_RINGTONES, "/Ringtones/") } @@ -115,4 +131,13 @@ object RootSyncedFolderProvider { private fun createSettingsSyncedFolder(category: String, localPath: String, remotePath: String): SyncedFolder { return SyncedFolder(category, localPath, remotePath, true, false, true, false) } + + /** + * Function to check if device android version is above Android 12, SDK 31 + * + * @return true or false + */ + fun isAboveA12(): Boolean { + return Build.VERSION.SDK_INT >= Build.VERSION_CODES.S + } } \ No newline at end of file