From dec610ea840c7002b3dc7186aca5148a7d4382c5 Mon Sep 17 00:00:00 2001 From: Sayantan Roychowdhury Date: Tue, 6 Jun 2023 08:49:04 +0530 Subject: [PATCH 1/3] add Recordings directory for A12 --- .../foundation/e/drive/utils/CommonUtils.java | 9 ++++++ .../e/drive/utils/RootSyncedFolderProvider.kt | 30 ++++++++++++++----- 2 files changed, 32 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/foundation/e/drive/utils/CommonUtils.java b/app/src/main/java/foundation/e/drive/utils/CommonUtils.java index 1ffb3a1e..79e5a96c 100644 --- a/app/src/main/java/foundation/e/drive/utils/CommonUtils.java +++ b/app/src/main/java/foundation/e/drive/utils/CommonUtils.java @@ -368,4 +368,13 @@ public abstract class CommonUtils { } return value == null ? "" : value; } + + /** + * Function to check if device android version is above Android 12, SDK 31 + * + * @return true or false + */ + public static boolean isAboveA12(){ + return Build.VERSION.SDK_INT >= Build.VERSION_CODES.S; + } } 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..10cb61e0 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,8 @@ 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 @@ -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 (CommonUtils.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/") } -- GitLab From 7ec477f1f0014d39619909dd31d29eed332b1844 Mon Sep 17 00:00:00 2001 From: Sayantan Roychowdhury Date: Tue, 6 Jun 2023 20:21:03 +0530 Subject: [PATCH 2/3] move isAboveA12 to RootSyncedFolderProvider --- .../foundation/e/drive/utils/CommonUtils.java | 9 --------- .../e/drive/utils/RootSyncedFolderProvider.kt | 19 ++++++++++++++----- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/app/src/main/java/foundation/e/drive/utils/CommonUtils.java b/app/src/main/java/foundation/e/drive/utils/CommonUtils.java index 79e5a96c..1ffb3a1e 100644 --- a/app/src/main/java/foundation/e/drive/utils/CommonUtils.java +++ b/app/src/main/java/foundation/e/drive/utils/CommonUtils.java @@ -368,13 +368,4 @@ public abstract class CommonUtils { } return value == null ? "" : value; } - - /** - * Function to check if device android version is above Android 12, SDK 31 - * - * @return true or false - */ - public static boolean isAboveA12(){ - return Build.VERSION.SDK_INT >= Build.VERSION_CODES.S; - } } 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 10cb61e0..cd03ed03 100644 --- a/app/src/main/java/foundation/e/drive/utils/RootSyncedFolderProvider.kt +++ b/app/src/main/java/foundation/e/drive/utils/RootSyncedFolderProvider.kt @@ -12,14 +12,14 @@ 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_PICTURES -import android.os.Environment.DIRECTORY_RINGTONES 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 androidx.annotation.RequiresApi import com.owncloud.android.lib.resources.files.FileUtils.PATH_SEPARATOR import foundation.e.drive.models.SyncedFolder @@ -52,7 +52,7 @@ object RootSyncedFolderProvider { CATEGORY_DOCUMENTS -> syncedFolders.add(createDocumentsSyncedFolder()) CATEGORY_MUSIC -> syncedFolders.add(createMusicsSyncedFolder()) CATEGORY_RECORDINGS -> { - if (CommonUtils.isAboveA12()) { + if (isAboveA12()) { syncedFolders.add(createRecordingsSyncedFolder()) } } @@ -131,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 -- GitLab From bd6fd396e64a3e260dfcafbdd60e962aa0dd871f Mon Sep 17 00:00:00 2001 From: Sayantan Roychowdhury Date: Fri, 9 Jun 2023 03:46:29 +0530 Subject: [PATCH 3/3] add missing import --- .../java/foundation/e/drive/FileObservers/FileEventListener.java | 1 + 1 file changed, 1 insertion(+) 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 43d47a8a..5f9a07f4 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; -- GitLab