Fix. Avoid load logs again when changing device orientation
[pub/Android/ownCloud.git] / src / com / owncloud / android / utils / ErrorMessageAdapter.java
index ec0ddd8..e56e876 100644 (file)
@@ -32,6 +32,7 @@ import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCo
 import com.owncloud.android.operations.CreateFolderOperation;
 import com.owncloud.android.operations.CreateShareOperation;
 import com.owncloud.android.operations.DownloadFileOperation;
+import com.owncloud.android.operations.MoveFileOperation;
 import com.owncloud.android.operations.RemoveFileOperation;
 import com.owncloud.android.operations.RenameFileOperation;
 import com.owncloud.android.operations.SynchronizeFileOperation;
@@ -69,8 +70,12 @@ public class ErrorMessageAdapter {
                 /*
                 } else if (result.getCode() == ResultCode.QUOTA_EXCEEDED) {
                     message = res.getString(R.string.failed_upload_quota_exceeded_text);
-                  
                     */
+                    
+                } else if (result.getCode() == ResultCode.FORBIDDEN) {
+                    message = String.format(res.getString(R.string.forbidden_permissions),
+                            res.getString(R.string.uploader_upload_forbidden_permissions));
+
                 } else {
                     message = String.format(res.getString(R.string.uploader_upload_failed_content_single), 
                             ((UploadFileOperation) operation).getFileName());
@@ -84,8 +89,13 @@ public class ErrorMessageAdapter {
                         new File(((DownloadFileOperation) operation).getSavePath()).getName());
                 
             } else {
-                message = String.format(res.getString(R.string.downloader_download_failed_content), 
-                        new File(((DownloadFileOperation) operation).getSavePath()).getName());
+                if (result.getCode() == ResultCode.FILE_NOT_FOUND) {
+                    message = res.getString(R.string.downloader_download_file_not_found);
+
+                } else {
+                    message = String.format(res.getString(R.string.downloader_download_failed_content), new File(
+                            ((DownloadFileOperation) operation).getSavePath()).getName());
+                }
             }
             
         } else if (operation instanceof RemoveFileOperation) {
@@ -177,6 +187,25 @@ public class ErrorMessageAdapter {
                 // Show a Message, operation finished without success
                 message = res.getString(R.string.unshare_link_file_error);
             }
+        } else if (operation instanceof MoveFileOperation) {
+
+            if (result.getCode() == ResultCode.FILE_NOT_FOUND) {
+                message = res.getString(R.string.move_file_not_found);
+                
+            } else if (result.getCode() == ResultCode.INVALID_MOVE_INTO_DESCENDANT)  {
+                message = res.getString(R.string.move_file_invalid_into_descendent);
+
+            } else if (result.getCode() == ResultCode.INVALID_OVERWRITE) {
+                message = res.getString(R.string.move_file_invalid_overwrite);
+
+            } else if (result.getCode() == ResultCode.FORBIDDEN) {
+                message = String.format(res.getString(R.string.forbidden_permissions),
+                        res.getString(R.string.forbidden_permissions_move));
+
+            }else {    // Generic error
+                // Show a Message, operation finished without success
+                message = res.getString(R.string.move_file_error);
+            }
         }
         
         return message;