mirror of
https://github.com/nextcloud/android.git
synced 2024-11-26 23:28:42 +03:00
Merge pull request #566 from owncloud/update_error_messages_for_non_permitted_actions
Updated error messages for non permitted actions
This commit is contained in:
commit
a449a1cbb1
3 changed files with 52 additions and 9 deletions
|
@ -1 +1 @@
|
||||||
Subproject commit 5ebf81e26ed0827359aa468fb813353656b7cf27
|
Subproject commit 6b155fb8029973af08751cf42a77b4a4afd0536d
|
|
@ -270,4 +270,13 @@
|
||||||
<string name="network_error_connect_timeout_exception">An error occurred while waiting for the server, the operation couldn\'t have been done</string>
|
<string name="network_error_connect_timeout_exception">An error occurred while waiting for the server, the operation couldn\'t have been done</string>
|
||||||
<string name="network_host_not_available">The operation couldn\'t be completed, server is unavailable</string>
|
<string name="network_host_not_available">The operation couldn\'t be completed, server is unavailable</string>
|
||||||
|
|
||||||
|
<string name="forbidden_permissions">You do not have permission %s</string>
|
||||||
|
<string name="forbidden_permissions_rename">to rename this file</string>
|
||||||
|
<string name="forbidden_permissions_delete">to delete this file</string>
|
||||||
|
<string name="share_link_forbidden_permissions">to share this file</string>
|
||||||
|
<string name="unshare_link_forbidden_permissions">to unshare this file</string>
|
||||||
|
<string name="forbidden_permissions_create">to create the file</string>
|
||||||
|
<string name="uploader_upload_forbidden_permissions">to upload in this folder</string>
|
||||||
|
<string name="downloader_download_file_not_found">The file is no longer available on the server</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -20,7 +20,9 @@ package com.owncloud.android.utils;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.net.SocketTimeoutException;
|
import java.net.SocketTimeoutException;
|
||||||
|
|
||||||
import org.apache.commons.httpclient.ConnectTimeoutException;
|
import org.apache.commons.httpclient.ConnectTimeoutException;
|
||||||
|
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
|
|
||||||
import com.owncloud.android.R;
|
import com.owncloud.android.R;
|
||||||
|
@ -67,8 +69,12 @@ public class ErrorMessageAdapter {
|
||||||
/*
|
/*
|
||||||
} else if (result.getCode() == ResultCode.QUOTA_EXCEEDED) {
|
} else if (result.getCode() == ResultCode.QUOTA_EXCEEDED) {
|
||||||
message = res.getString(R.string.failed_upload_quota_exceeded_text);
|
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 {
|
} else {
|
||||||
message = String.format(res.getString(R.string.uploader_upload_failed_content_single),
|
message = String.format(res.getString(R.string.uploader_upload_failed_content_single),
|
||||||
((UploadFileOperation) operation).getFileName());
|
((UploadFileOperation) operation).getFileName());
|
||||||
|
@ -82,8 +88,13 @@ public class ErrorMessageAdapter {
|
||||||
new File(((DownloadFileOperation) operation).getSavePath()).getName());
|
new File(((DownloadFileOperation) operation).getSavePath()).getName());
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
message = String.format(res.getString(R.string.downloader_download_failed_content),
|
if (result.getCode() == ResultCode.FILE_NOT_FOUND) {
|
||||||
new File(((DownloadFileOperation) operation).getSavePath()).getName());
|
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) {
|
} else if (operation instanceof RemoveFileOperation) {
|
||||||
|
@ -91,7 +102,11 @@ public class ErrorMessageAdapter {
|
||||||
message = res.getString(R.string.remove_success_msg);
|
message = res.getString(R.string.remove_success_msg);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if (isNetworkError(result.getCode())) {
|
if (result.getCode().equals(ResultCode.FORBIDDEN)) {
|
||||||
|
// Error --> No permissions
|
||||||
|
message = String.format(res.getString(R.string.forbidden_permissions),
|
||||||
|
res.getString(R.string.forbidden_permissions_delete));
|
||||||
|
} else if (isNetworkError(result.getCode())) {
|
||||||
message = getErrorMessage(result, res);
|
message = getErrorMessage(result, res);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
@ -103,7 +118,12 @@ public class ErrorMessageAdapter {
|
||||||
if (result.getCode().equals(ResultCode.INVALID_LOCAL_FILE_NAME)) {
|
if (result.getCode().equals(ResultCode.INVALID_LOCAL_FILE_NAME)) {
|
||||||
message = res.getString(R.string.rename_local_fail_msg);
|
message = res.getString(R.string.rename_local_fail_msg);
|
||||||
|
|
||||||
} if (result.getCode().equals(ResultCode.INVALID_CHARACTER_IN_NAME)) {
|
} else if (result.getCode().equals(ResultCode.FORBIDDEN)) {
|
||||||
|
// Error --> No permissions
|
||||||
|
message = String.format(res.getString(R.string.forbidden_permissions),
|
||||||
|
res.getString(R.string.forbidden_permissions_rename));
|
||||||
|
|
||||||
|
} else if (result.getCode().equals(ResultCode.INVALID_CHARACTER_IN_NAME)) {
|
||||||
message = res.getString(R.string.filename_forbidden_characters);
|
message = res.getString(R.string.filename_forbidden_characters);
|
||||||
|
|
||||||
} else if (isNetworkError(result.getCode())) {
|
} else if (isNetworkError(result.getCode())) {
|
||||||
|
@ -122,6 +142,10 @@ public class ErrorMessageAdapter {
|
||||||
if (result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME) {
|
if (result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME) {
|
||||||
message = res.getString(R.string.filename_forbidden_characters);
|
message = res.getString(R.string.filename_forbidden_characters);
|
||||||
|
|
||||||
|
} else if (result.getCode().equals(ResultCode.FORBIDDEN)) {
|
||||||
|
message = String.format(res.getString(R.string.forbidden_permissions),
|
||||||
|
res.getString(R.string.forbidden_permissions_create));
|
||||||
|
|
||||||
} else if (isNetworkError(result.getCode())) {
|
} else if (isNetworkError(result.getCode())) {
|
||||||
message = getErrorMessage(result, res);
|
message = getErrorMessage(result, res);
|
||||||
|
|
||||||
|
@ -132,6 +156,11 @@ public class ErrorMessageAdapter {
|
||||||
if (result.getCode() == ResultCode.SHARE_NOT_FOUND) { // Error --> SHARE_NOT_FOUND
|
if (result.getCode() == ResultCode.SHARE_NOT_FOUND) { // Error --> SHARE_NOT_FOUND
|
||||||
message = res.getString(R.string.share_link_file_no_exist);
|
message = res.getString(R.string.share_link_file_no_exist);
|
||||||
|
|
||||||
|
} else if (result.getCode() == ResultCode.SHARE_FORBIDDEN) {
|
||||||
|
// Error --> No permissions
|
||||||
|
message = String.format(res.getString(R.string.forbidden_permissions),
|
||||||
|
res.getString(R.string.share_link_forbidden_permissions));
|
||||||
|
|
||||||
} else if (isNetworkError(result.getCode())) {
|
} else if (isNetworkError(result.getCode())) {
|
||||||
message = getErrorMessage(result, res);
|
message = getErrorMessage(result, res);
|
||||||
|
|
||||||
|
@ -145,6 +174,11 @@ public class ErrorMessageAdapter {
|
||||||
if (result.getCode() == ResultCode.SHARE_NOT_FOUND) { // Error --> SHARE_NOT_FOUND
|
if (result.getCode() == ResultCode.SHARE_NOT_FOUND) { // Error --> SHARE_NOT_FOUND
|
||||||
message = res.getString(R.string.unshare_link_file_no_exist);
|
message = res.getString(R.string.unshare_link_file_no_exist);
|
||||||
|
|
||||||
|
} else if (result.getCode() == ResultCode.SHARE_FORBIDDEN) {
|
||||||
|
// Error --> No permissions
|
||||||
|
message = String.format(res.getString(R.string.forbidden_permissions),
|
||||||
|
res.getString(R.string.unshare_link_forbidden_permissions));
|
||||||
|
|
||||||
} else if (isNetworkError(result.getCode())) {
|
} else if (isNetworkError(result.getCode())) {
|
||||||
message = getErrorMessage(result, res);
|
message = getErrorMessage(result, res);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue