Эх сурвалжийг харах

Rename argument name

Signed-off-by: alperozturk <alper_ozturk@proton.me>
alperozturk 1 жил өмнө
parent
commit
8d7aec013f

+ 2 - 2
app/src/main/java/com/nextcloud/client/files/downloader/FileDownloadIntents.kt

@@ -39,7 +39,7 @@ class FileDownloadIntents(private val context: Context) {
         linkedToRemotePath: String
         linkedToRemotePath: String
     ): Intent {
     ): Intent {
         return Intent(FileDownloadWorker.getDownloadAddedMessage()).apply {
         return Intent(FileDownloadWorker.getDownloadAddedMessage()).apply {
-            putExtra(FileDownloadWorker.ACCOUNT_NAME, download.user.accountName)
+            putExtra(FileDownloadWorker.EXTRA_ACCOUNT_NAME, download.user.accountName)
             putExtra(FileDownloadWorker.EXTRA_REMOTE_PATH, download.remotePath)
             putExtra(FileDownloadWorker.EXTRA_REMOTE_PATH, download.remotePath)
             putExtra(FileDownloadWorker.EXTRA_LINKED_TO_PATH, linkedToRemotePath)
             putExtra(FileDownloadWorker.EXTRA_LINKED_TO_PATH, linkedToRemotePath)
             setPackage(context.packageName)
             setPackage(context.packageName)
@@ -53,7 +53,7 @@ class FileDownloadIntents(private val context: Context) {
     ): Intent {
     ): Intent {
         return Intent(FileDownloadWorker.getDownloadFinishMessage()).apply {
         return Intent(FileDownloadWorker.getDownloadFinishMessage()).apply {
             putExtra(FileDownloadWorker.EXTRA_DOWNLOAD_RESULT, downloadResult.isSuccess)
             putExtra(FileDownloadWorker.EXTRA_DOWNLOAD_RESULT, downloadResult.isSuccess)
-            putExtra(FileDownloadWorker.ACCOUNT_NAME, download.user.accountName)
+            putExtra(FileDownloadWorker.EXTRA_ACCOUNT_NAME, download.user.accountName)
             putExtra(FileDownloadWorker.EXTRA_REMOTE_PATH, download.remotePath)
             putExtra(FileDownloadWorker.EXTRA_REMOTE_PATH, download.remotePath)
             putExtra(OCFileListFragment.DOWNLOAD_BEHAVIOUR, download.behaviour)
             putExtra(OCFileListFragment.DOWNLOAD_BEHAVIOUR, download.behaviour)
             putExtra(SendShareDialog.ACTIVITY_NAME, download.activityName)
             putExtra(SendShareDialog.ACTIVITY_NAME, download.activityName)

+ 26 - 24
app/src/main/java/com/nextcloud/client/files/downloader/FileDownloadWorker.kt

@@ -42,7 +42,6 @@ import com.owncloud.android.datamodel.OCFile
 import com.owncloud.android.datamodel.UploadsStorageManager
 import com.owncloud.android.datamodel.UploadsStorageManager
 import com.owncloud.android.files.services.IndexedForest
 import com.owncloud.android.files.services.IndexedForest
 import com.owncloud.android.lib.common.OwnCloudAccount
 import com.owncloud.android.lib.common.OwnCloudAccount
-import com.owncloud.android.lib.common.OwnCloudClient
 import com.owncloud.android.lib.common.OwnCloudClientManagerFactory
 import com.owncloud.android.lib.common.OwnCloudClientManagerFactory
 import com.owncloud.android.lib.common.network.OnDatatransferProgressListener
 import com.owncloud.android.lib.common.network.OnDatatransferProgressListener
 import com.owncloud.android.lib.common.operations.RemoteOperationResult
 import com.owncloud.android.lib.common.operations.RemoteOperationResult
@@ -71,21 +70,20 @@ class FileDownloadWorker(
         private var currentDownload: DownloadFileOperation? = null
         private var currentDownload: DownloadFileOperation? = null
 
 
         const val FILES_SEPARATOR = ","
         const val FILES_SEPARATOR = ","
-        const val FOLDER_PATH = "FOLDER_PATH"
-        const val USER_NAME = "USER"
-        const val FILE_PATH = "FILE_PATH"
-        const val FILES_PATH = "FILES_PATH"
+        const val FOLDER_REMOTE_PATH = "FOLDER_REMOTE_PATH"
+        const val FILE_REMOTE_PATH = "FILE_REMOTE_PATH"
+        const val FILES_REMOTE_PATH = "FILES_REMOTE_PATH"
+        const val ACCOUNT_NAME = "ACCOUNT_NAME"
         const val BEHAVIOUR = "BEHAVIOUR"
         const val BEHAVIOUR = "BEHAVIOUR"
         const val DOWNLOAD_TYPE = "DOWNLOAD_TYPE"
         const val DOWNLOAD_TYPE = "DOWNLOAD_TYPE"
         const val ACTIVITY_NAME = "ACTIVITY_NAME"
         const val ACTIVITY_NAME = "ACTIVITY_NAME"
         const val PACKAGE_NAME = "PACKAGE_NAME"
         const val PACKAGE_NAME = "PACKAGE_NAME"
         const val CONFLICT_UPLOAD_ID = "CONFLICT_UPLOAD_ID"
         const val CONFLICT_UPLOAD_ID = "CONFLICT_UPLOAD_ID"
-        const val EXTRA_USER = "USER"
-        const val EXTRA_FILE = "FILE"
-        const val EXTRA_DOWNLOAD_RESULT = "RESULT"
-        const val EXTRA_REMOTE_PATH = "REMOTE_PATH"
-        const val EXTRA_LINKED_TO_PATH = "LINKED_TO"
-        const val ACCOUNT_NAME = "ACCOUNT_NAME"
+
+        const val EXTRA_DOWNLOAD_RESULT = "EXTRA_DOWNLOAD_RESULT"
+        const val EXTRA_REMOTE_PATH = "EXTRA_REMOTE_PATH"
+        const val EXTRA_LINKED_TO_PATH = "EXTRA_LINKED_TO_PATH"
+        const val EXTRA_ACCOUNT_NAME = "EXTRA_ACCOUNT_NAME"
 
 
         fun isDownloading(user: User, file: OCFile): Boolean {
         fun isDownloading(user: User, file: OCFile): Boolean {
             return currentDownload?.file?.fileId == file.fileId &&
             return currentDownload?.file?.fileId == file.fileId &&
@@ -102,16 +100,20 @@ class FileDownloadWorker(
     }
     }
 
 
     private val pendingDownloads = IndexedForest<DownloadFileOperation>()
     private val pendingDownloads = IndexedForest<DownloadFileOperation>()
+
     private var conflictUploadId: Long? = null
     private var conflictUploadId: Long? = null
     private var lastPercent = 0
     private var lastPercent = 0
+
     private val intents = FileDownloadIntents(context)
     private val intents = FileDownloadIntents(context)
     private val notificationManager = DownloadNotificationManager(context, viewThemeUtils)
     private val notificationManager = DownloadNotificationManager(context, viewThemeUtils)
     private var downloadProgressListener = FileDownloadProgressListener()
     private var downloadProgressListener = FileDownloadProgressListener()
+
+    private var user: User? = null
     private var currentUser = Optional.empty<User>()
     private var currentUser = Optional.empty<User>()
-    private var storageManager: FileDataStorageManager? = null
+
+    private var currentUserFileStorageManager: FileDataStorageManager? = null
     private var fileDataStorageManager: FileDataStorageManager? = null
     private var fileDataStorageManager: FileDataStorageManager? = null
-    private var downloadClient: OwnCloudClient? = null
-    private var user: User? = null
+
     private var folder: OCFile? = null
     private var folder: OCFile? = null
     private var isAnyOperationFailed = true
     private var isAnyOperationFailed = true
 
 
@@ -223,22 +225,22 @@ class FileDownloadWorker(
     }
     }
 
 
     private fun setUser() {
     private fun setUser() {
-        val accountName = inputData.keyValueMap[USER_NAME] as String
+        val accountName = inputData.keyValueMap[ACCOUNT_NAME] as String
         user = accountManager.getUser(accountName).get()
         user = accountManager.getUser(accountName).get()
         fileDataStorageManager = FileDataStorageManager(user, context.contentResolver)
         fileDataStorageManager = FileDataStorageManager(user, context.contentResolver)
     }
     }
 
 
     private fun setFolder() {
     private fun setFolder() {
-        val folderPath = inputData.keyValueMap[FOLDER_PATH] as? String?
+        val folderPath = inputData.keyValueMap[FOLDER_REMOTE_PATH] as? String?
         if (folderPath != null) {
         if (folderPath != null) {
-            folder = storageManager?.getFileByEncryptedRemotePath(folderPath)
+            folder = currentUserFileStorageManager?.getFileByEncryptedRemotePath(folderPath)
         }
         }
     }
     }
 
 
     private fun getFiles(): List<OCFile> {
     private fun getFiles(): List<OCFile> {
         val result = arrayListOf<OCFile>()
         val result = arrayListOf<OCFile>()
 
 
-        val filesPath = inputData.keyValueMap[FILES_PATH] as String?
+        val filesPath = inputData.keyValueMap[FILES_REMOTE_PATH] as String?
         val filesPathList = filesPath?.split(FILES_SEPARATOR)
         val filesPathList = filesPath?.split(FILES_SEPARATOR)
 
 
         if (filesPathList != null) {
         if (filesPathList != null) {
@@ -248,7 +250,7 @@ class FileDownloadWorker(
                 }
                 }
             }
             }
         } else {
         } else {
-            val remotePath = inputData.keyValueMap[FILE_PATH] as String
+            val remotePath = inputData.keyValueMap[FILE_REMOTE_PATH] as String
             fileDataStorageManager?.getFileByEncryptedRemotePath(remotePath)?.let { file ->
             fileDataStorageManager?.getFileByEncryptedRemotePath(remotePath)?.let { file ->
                 result.add(file)
                 result.add(file)
             }
             }
@@ -296,13 +298,13 @@ class FileDownloadWorker(
         var downloadResult: RemoteOperationResult<*>? = null
         var downloadResult: RemoteOperationResult<*>? = null
         try {
         try {
             val ocAccount = getOCAccountForDownload()
             val ocAccount = getOCAccountForDownload()
-            downloadClient =
+            val downloadClient =
                 OwnCloudClientManagerFactory.getDefaultSingleton().getClientFor(ocAccount, context)
                 OwnCloudClientManagerFactory.getDefaultSingleton().getClientFor(ocAccount, context)
 
 
             downloadResult = currentDownload?.execute(downloadClient)
             downloadResult = currentDownload?.execute(downloadClient)
             if (downloadResult?.isSuccess == true && currentDownload?.downloadType === DownloadType.DOWNLOAD) {
             if (downloadResult?.isSuccess == true && currentDownload?.downloadType === DownloadType.DOWNLOAD) {
                 getCurrentFile()?.let {
                 getCurrentFile()?.let {
-                    FileDownloadHelper.instance().saveFile(it, currentDownload, storageManager)
+                    FileDownloadHelper.instance().saveFile(it, currentDownload, currentUserFileStorageManager)
                 }
                 }
             }
             }
         } catch (e: Exception) {
         } catch (e: Exception) {
@@ -328,16 +330,16 @@ class FileDownloadWorker(
         val currentDownloadUser = accountManager.getUser(currentDownloadAccount?.name)
         val currentDownloadUser = accountManager.getUser(currentDownloadAccount?.name)
         if (currentUser != currentDownloadUser) {
         if (currentUser != currentDownloadUser) {
             currentUser = currentDownloadUser
             currentUser = currentDownloadUser
-            storageManager = FileDataStorageManager(currentUser.get(), context.contentResolver)
+            currentUserFileStorageManager = FileDataStorageManager(currentUser.get(), context.contentResolver)
         }
         }
         return currentDownloadUser.get().toOwnCloudAccount()
         return currentDownloadUser.get().toOwnCloudAccount()
     }
     }
 
 
     private fun getCurrentFile(): OCFile? {
     private fun getCurrentFile(): OCFile? {
-        var file: OCFile? = currentDownload?.file?.fileId?.let { storageManager?.getFileById(it) }
+        var file: OCFile? = currentDownload?.file?.fileId?.let { currentUserFileStorageManager?.getFileById(it) }
 
 
         if (file == null) {
         if (file == null) {
-            file = storageManager?.getFileByDecryptedRemotePath(currentDownload?.file?.remotePath)
+            file = currentUserFileStorageManager?.getFileByDecryptedRemotePath(currentDownload?.file?.remotePath)
         }
         }
 
 
         if (file == null) {
         if (file == null) {

+ 5 - 5
app/src/main/java/com/nextcloud/client/jobs/BackgroundJobManagerImpl.kt

@@ -523,9 +523,9 @@ internal class BackgroundJobManagerImpl(
 
 
     override fun startFolderDownloadJob(folder: OCFile, user: User, filesPath: List<String>) {
     override fun startFolderDownloadJob(folder: OCFile, user: User, filesPath: List<String>) {
         val data = workDataOf(
         val data = workDataOf(
-            FileDownloadWorker.USER_NAME to user.accountName,
-            FileDownloadWorker.FOLDER_PATH to folder.remotePath,
-            FileDownloadWorker.FILES_PATH to filesPath.joinToString(FileDownloadWorker.FILES_SEPARATOR),
+            FileDownloadWorker.ACCOUNT_NAME to user.accountName,
+            FileDownloadWorker.FOLDER_REMOTE_PATH to folder.remotePath,
+            FileDownloadWorker.FILES_REMOTE_PATH to filesPath.joinToString(FileDownloadWorker.FILES_SEPARATOR),
             FileDownloadWorker.DOWNLOAD_TYPE to DownloadType.DOWNLOAD.toString()
             FileDownloadWorker.DOWNLOAD_TYPE to DownloadType.DOWNLOAD.toString()
         )
         )
 
 
@@ -552,8 +552,8 @@ internal class BackgroundJobManagerImpl(
         val tag = startFileDownloadJobTag(user, file)
         val tag = startFileDownloadJobTag(user, file)
 
 
         val data = workDataOf(
         val data = workDataOf(
-            FileDownloadWorker.USER_NAME to user.accountName,
-            FileDownloadWorker.FILE_PATH to file.remotePath,
+            FileDownloadWorker.ACCOUNT_NAME to user.accountName,
+            FileDownloadWorker.FILE_REMOTE_PATH to file.remotePath,
             FileDownloadWorker.BEHAVIOUR to behaviour,
             FileDownloadWorker.BEHAVIOUR to behaviour,
             FileDownloadWorker.DOWNLOAD_TYPE to downloadType.toString(),
             FileDownloadWorker.DOWNLOAD_TYPE to downloadType.toString(),
             FileDownloadWorker.ACTIVITY_NAME to activityName,
             FileDownloadWorker.ACTIVITY_NAME to activityName,

+ 2 - 2
app/src/main/java/com/owncloud/android/services/SyncFolderHandler.java

@@ -170,7 +170,7 @@ class SyncFolderHandler extends Handler {
      */
      */
     private void sendBroadcastNewSyncFolder(Account account, String remotePath) {
     private void sendBroadcastNewSyncFolder(Account account, String remotePath) {
         Intent added = new Intent(FileDownloadWorker.Companion.getDownloadAddedMessage());
         Intent added = new Intent(FileDownloadWorker.Companion.getDownloadAddedMessage());
-        added.putExtra(FileDownloadWorker.ACCOUNT_NAME, account.name);
+        added.putExtra(FileDownloadWorker.EXTRA_ACCOUNT_NAME, account.name);
         added.putExtra(FileDownloadWorker.EXTRA_REMOTE_PATH, remotePath);
         added.putExtra(FileDownloadWorker.EXTRA_REMOTE_PATH, remotePath);
         added.setPackage(mService.getPackageName());
         added.setPackage(mService.getPackageName());
         LocalBroadcastManager.getInstance(mService.getApplicationContext()).sendBroadcast(added);
         LocalBroadcastManager.getInstance(mService.getApplicationContext()).sendBroadcast(added);
@@ -183,7 +183,7 @@ class SyncFolderHandler extends Handler {
     private void sendBroadcastFinishedSyncFolder(Account account, String remotePath,
     private void sendBroadcastFinishedSyncFolder(Account account, String remotePath,
                                                  boolean success) {
                                                  boolean success) {
         Intent finished = new Intent(FileDownloadWorker.Companion.getDownloadFinishMessage());
         Intent finished = new Intent(FileDownloadWorker.Companion.getDownloadFinishMessage());
-        finished.putExtra(FileDownloadWorker.ACCOUNT_NAME, account.name);
+        finished.putExtra(FileDownloadWorker.EXTRA_ACCOUNT_NAME, account.name);
         finished.putExtra(FileDownloadWorker.EXTRA_REMOTE_PATH, remotePath);
         finished.putExtra(FileDownloadWorker.EXTRA_REMOTE_PATH, remotePath);
         finished.putExtra(FileDownloadWorker.EXTRA_DOWNLOAD_RESULT, success);
         finished.putExtra(FileDownloadWorker.EXTRA_DOWNLOAD_RESULT, success);
         finished.setPackage(mService.getPackageName());
         finished.setPackage(mService.getPackageName());

+ 1 - 1
app/src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.java

@@ -1472,7 +1472,7 @@ public class FileDisplayActivity extends FileActivity
         }
         }
 
 
         private boolean isSameAccount(Intent intent) {
         private boolean isSameAccount(Intent intent) {
-            String accountName = intent.getStringExtra(FileDownloadWorker.ACCOUNT_NAME);
+            String accountName = intent.getStringExtra(FileDownloadWorker.EXTRA_ACCOUNT_NAME);
             return accountName != null && getAccount() != null && accountName.equals(getAccount().name);
             return accountName != null && getAccount() != null && accountName.equals(getAccount().name);
         }
         }
     }
     }

+ 1 - 1
app/src/main/java/com/owncloud/android/ui/preview/PreviewImageActivity.java

@@ -507,7 +507,7 @@ public class PreviewImageActivity extends FileActivity implements
     }
     }
 
 
     private void previewNewImage(Intent intent) {
     private void previewNewImage(Intent intent) {
-        String accountName = intent.getStringExtra(FileDownloadWorker.ACCOUNT_NAME);
+        String accountName = intent.getStringExtra(FileDownloadWorker.EXTRA_ACCOUNT_NAME);
         String downloadedRemotePath = intent.getStringExtra(FileDownloadWorker.EXTRA_REMOTE_PATH);
         String downloadedRemotePath = intent.getStringExtra(FileDownloadWorker.EXTRA_REMOTE_PATH);
         String downloadBehaviour = intent.getStringExtra(OCFileListFragment.DOWNLOAD_BEHAVIOUR);
         String downloadBehaviour = intent.getStringExtra(OCFileListFragment.DOWNLOAD_BEHAVIOUR);
         if (getAccount().name.equals(accountName) && downloadedRemotePath != null) {
         if (getAccount().name.equals(accountName) && downloadedRemotePath != null) {