From: jabarros Date: Tue, 26 Aug 2014 15:44:18 +0000 (+0200) Subject: Add gestion for errors when moving files X-Git-Tag: oc-android-1.7.0_signed~197^2~16 X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/commitdiff_plain/a6afe6efd24d35d02dc9720432a2daa47b58ffdd Add gestion for errors when moving files --- diff --git a/res/values/strings.xml b/res/values/strings.xml index 87e766ba..7107a3cc 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -290,4 +290,7 @@ Nothing in here. You can add a folder! Choose + Invalid move into descendent. + An error occurred while trying to move this file or folder + diff --git a/src/com/owncloud/android/ui/activity/FileDisplayActivity.java b/src/com/owncloud/android/ui/activity/FileDisplayActivity.java index 093de7d3..da6eb527 100644 --- a/src/com/owncloud/android/ui/activity/FileDisplayActivity.java +++ b/src/com/owncloud/android/ui/activity/FileDisplayActivity.java @@ -80,6 +80,7 @@ import com.owncloud.android.lib.common.operations.RemoteOperationResult; import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode; import com.owncloud.android.operations.CreateFolderOperation; import com.owncloud.android.operations.CreateShareOperation; +import com.owncloud.android.operations.MoveFileOperation; import com.owncloud.android.operations.RemoveFileOperation; import com.owncloud.android.operations.RenameFileOperation; import com.owncloud.android.operations.SynchronizeFileOperation; @@ -1332,7 +1333,9 @@ OnSslUntrustedCertListener, SwipeRefreshLayout.OnRefreshListener { } else if (operation instanceof UnshareLinkOperation) { onUnshareLinkOperationFinish((UnshareLinkOperation)operation, result); - } + } else if (operation instanceof MoveFileOperation) { + onMoveFileOperationFinish((MoveFileOperation)operation, result); + } } @@ -1411,12 +1414,13 @@ OnSslUntrustedCertListener, SwipeRefreshLayout.OnRefreshListener { /** - * Updates the view associated to the activity after the finish of an operation trying create a new folder + * Updates the view associated to the activity after the finish of an operation trying to move a + * file. * - * @param operation Creation operation performed. - * @param result Result of the creation. + * @param operation Move operation performed. + * @param result Result of the move operation. */ - private void onCreateFolderOperationFinish(CreateFolderOperation operation, RemoteOperationResult result) { + private void onMoveFileOperationFinish(MoveFileOperation operation, RemoteOperationResult result) { if (result.isSuccess()) { dismissLoadingDialog(); refreshListOfFilesFragment(); @@ -1503,6 +1507,30 @@ OnSslUntrustedCertListener, SwipeRefreshLayout.OnRefreshListener { } } + /** + * Updates the view associated to the activity after the finish of an operation trying create a new folder + * + * @param operation Creation operation performed. + * @param result Result of the creation. + */ + private void onCreateFolderOperationFinish(CreateFolderOperation operation, RemoteOperationResult result) { + if (result.isSuccess()) { + dismissLoadingDialog(); + refreshListOfFilesFragment(); + } else { + dismissLoadingDialog(); + try { + Toast msg = Toast.makeText(FileDisplayActivity.this, + ErrorMessageAdapter.getErrorCauseMessage(result, operation, getResources()), + Toast.LENGTH_LONG); + msg.show(); + + } catch (NotFoundException e) { + Log_OC.e(TAG, "Error while trying to show fail message " , e); + } + } + } + /** * {@inheritDoc} diff --git a/src/com/owncloud/android/utils/ErrorMessageAdapter.java b/src/com/owncloud/android/utils/ErrorMessageAdapter.java index 5307d468..84a9113a 100644 --- a/src/com/owncloud/android/utils/ErrorMessageAdapter.java +++ b/src/com/owncloud/android/utils/ErrorMessageAdapter.java @@ -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; @@ -186,6 +187,15 @@ 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.INVALID_MOVE_INTO_DESCENDANT) { + message = res.getString(R.string.move_file_invalid_into_descendent); + + } else { // Generic error + // Show a Message, operation finished without success + message = res.getString(R.string.move_file_error); + } } return message;