瀏覽代碼

Extract common logic retrieving remote path

Signed-off-by: alperozturk <alper_ozturk@proton.me>
alperozturk 1 年之前
父節點
當前提交
55aed575df

+ 13 - 0
app/src/main/java/com/owncloud/android/datamodel/FileDataStorageManager.java

@@ -2302,6 +2302,19 @@ public class FileDataStorageManager {
         return "/" + path.split("/")[1] + "/";
     }
 
+    public String retrieveRemotePathConsideringEncryption(OCFile file) {
+        if (file == null) {
+            throw new NullPointerException("file cannot be null");
+        }
+
+        String remotePath = file.getRemotePath();
+        if (file.isEncrypted()) {
+            remotePath = getEncryptedRemotePath(file.getRemotePath());
+        }
+
+        return remotePath;
+    }
+
     public String getEncryptedRemotePath(String decryptedRemotePath) {
         String folderName = getFolderName(decryptedRemotePath);
 

+ 2 - 10
app/src/main/java/com/owncloud/android/ui/activity/ConflictsResolveActivity.kt

@@ -164,11 +164,7 @@ class ConflictsResolveActivity : FileActivity(), OnConflictDecisionMadeListener
             return
         }
         if (existingFile == null) {
-            var remotePath = newFile!!.remotePath
-            if (newFile?.isEncrypted == true) {
-                remotePath = fileStorageManager?.getEncryptedRemotePath(newFile!!.remotePath)
-            }
-
+            val remotePath = fileStorageManager?.retrieveRemotePathConsideringEncryption(newFile) ?: return
             val operation = ReadFileRemoteOperation(remotePath)
 
             @Suppress("TooGenericExceptionCaught")
@@ -189,11 +185,7 @@ class ConflictsResolveActivity : FileActivity(), OnConflictDecisionMadeListener
                 }
             }.start()
         } else {
-            var remotePath = existingFile!!.remotePath
-            if (newFile?.isEncrypted == true) {
-                remotePath = fileStorageManager?.getEncryptedRemotePath(existingFile!!.remotePath)
-            }
-
+            val remotePath = fileStorageManager?.retrieveRemotePathConsideringEncryption(existingFile) ?: return
             startDialog(remotePath)
         }
     }