diff --git a/res/values/strings.xml b/res/values/strings.xml index 221603af9b..1266ce690f 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -118,8 +118,12 @@ Upload failed Upload of %1$s could not be completed Upload failed, you need to relogin + Completed + Cancelled + Paused Connection error Upload will be retried shortly + Credentials error Downloading … %1$d%% Downloading %2$s Download succeeded diff --git a/src/com/owncloud/android/datamodel/UploadsStorageManager.java b/src/com/owncloud/android/datamodel/UploadsStorageManager.java index 0d496cec64..afd3325832 100644 --- a/src/com/owncloud/android/datamodel/UploadsStorageManager.java +++ b/src/com/owncloud/android/datamodel/UploadsStorageManager.java @@ -128,6 +128,13 @@ public class UploadsStorageManager extends Observable { cv.put(ProviderTableMeta.UPLOADS_PATH, ocUpload.getLocalPath()); cv.put(ProviderTableMeta.UPLOADS_STATUS, ocUpload.getUploadStatus().value); cv.put(ProviderTableMeta.UPLOADS_FILE_ID, ocUpload.getOCFile().getFileId()); + cv.put(ProviderTableMeta.UPLOADS_ACCOUNT_NAME, ocUpload.getAccountName()); + cv.put(ProviderTableMeta.UPLOADS_LOCAL_BEHAVIOUR, ocUpload.getLocalAction()); + //cv.put(ProviderTableMeta.UPLOADS_UPLOAD_TIME, ocUpload.getUploadTime()); + cv.put(ProviderTableMeta.UPLOADS_FORCE_OVERWRITE, ocUpload.isForceOverwrite() ? 1 : 0); + cv.put(ProviderTableMeta.UPLOADS_IS_WHILE_CHARGING_ONLY, ocUpload.isWhileChargingOnly() ? 1 : 0); + cv.put(ProviderTableMeta.UPLOADS_IS_WIFI_ONLY, ocUpload.isUseWifiOnly() ? 1 : 0); + cv.put(ProviderTableMeta.UPLOADS_LAST_RESULT, ocUpload.getLastResult().getValue()); Uri result = getDB().insert(ProviderTableMeta.CONTENT_URI_UPLOADS, cv); diff --git a/src/com/owncloud/android/db/OCUpload.java b/src/com/owncloud/android/db/OCUpload.java index 2f995d07af..0e58ef1eac 100644 --- a/src/com/owncloud/android/db/OCUpload.java +++ b/src/com/owncloud/android/db/OCUpload.java @@ -341,7 +341,7 @@ public class OCUpload implements Parcelable{ /**** - * PARCELABLE METHODS + * */ public static final Parcelable.Creator CREATOR = new Parcelable.Creator() { diff --git a/src/com/owncloud/android/db/UploadResult.java b/src/com/owncloud/android/db/UploadResult.java index ba598fbd56..90af7dad95 100644 --- a/src/com/owncloud/android/db/UploadResult.java +++ b/src/com/owncloud/android/db/UploadResult.java @@ -78,6 +78,7 @@ public enum UploadResult { case WRONG_CONNECTION: return NETWORK_CONNECTION; case ACCOUNT_EXCEPTION: + case UNAUTHORIZED: return CREDENTIAL_ERROR; // case // return FOLDER_ERROR; @@ -85,8 +86,8 @@ public enum UploadResult { return CONFLICT_ERROR; case FILE_NOT_FOUND: return FILE_ERROR; - case UNAUTHORIZED: - return PRIVILEDGES_ERROR; +// case UNAUTHORIZED: +// return PRIVILEDGES_ERROR; case CANCELLED: return CANCELLED; } diff --git a/src/com/owncloud/android/files/services/FileUploadService.java b/src/com/owncloud/android/files/services/FileUploadService.java index 9f750a05d9..affd23abb6 100644 --- a/src/com/owncloud/android/files/services/FileUploadService.java +++ b/src/com/owncloud/android/files/services/FileUploadService.java @@ -871,7 +871,7 @@ public class FileUploadService extends Service implements OnDatatransferProgress notifyUploadStart(mCurrentUpload); RemoteOperationResult uploadResult = null, grantResult; - + try { /// prepare client object to send the request to the ownCloud server if (mCurrentAccount == null || !mCurrentAccount.equals(mCurrentUpload.getAccount())) { diff --git a/src/com/owncloud/android/ui/adapter/ExpandableUploadListAdapter.java b/src/com/owncloud/android/ui/adapter/ExpandableUploadListAdapter.java index e77917a95f..c9ea116e31 100755 --- a/src/com/owncloud/android/ui/adapter/ExpandableUploadListAdapter.java +++ b/src/com/owncloud/android/ui/adapter/ExpandableUploadListAdapter.java @@ -21,6 +21,7 @@ package com.owncloud.android.ui.adapter; import android.content.Context; +import android.content.Intent; import android.database.DataSetObserver; import android.graphics.Bitmap; import android.text.format.DateUtils; @@ -36,6 +37,7 @@ import android.widget.ProgressBar; import android.widget.TextView; import com.owncloud.android.R; +import com.owncloud.android.authentication.AuthenticatorActivity; import com.owncloud.android.datamodel.OCFile; import com.owncloud.android.datamodel.ThumbnailsCacheManager; import com.owncloud.android.datamodel.UploadsStorageManager; @@ -207,7 +209,29 @@ public class ExpandableUploadListAdapter extends BaseExpandableListAdapter imple break; case UPLOAD_FAILED_GIVE_UP: if (upload.getLastResult() != null) { - status = "Upload failed: " + upload.getLastResult().toString(); + if (upload.getLastResult() == UploadResult.CREDENTIAL_ERROR) { + status = mParentActivity.getString( + R.string.uploads_view_upload_status_failed_credentials_error); + + view.setOnClickListener(new OnClickListener() { + @Override + public void onClick(View v) { + // let the user update credentials with one click + Intent updateAccountCredentials = new Intent(mParentActivity, + AuthenticatorActivity.class); + updateAccountCredentials.putExtra( + AuthenticatorActivity.EXTRA_ACCOUNT, upload.getAccount(mParentActivity)); + updateAccountCredentials.putExtra( + AuthenticatorActivity.EXTRA_ACTION, + AuthenticatorActivity.ACTION_UPDATE_EXPIRED_TOKEN); + updateAccountCredentials.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); + updateAccountCredentials.addFlags(Intent.FLAG_FROM_BACKGROUND); + mParentActivity.startActivity(updateAccountCredentials); + } + }); + } else { + status = "Upload failed: " + upload.getLastResult().toString(); + } } else { status = "Upload failed."; } @@ -216,7 +240,7 @@ public class ExpandableUploadListAdapter extends BaseExpandableListAdapter imple if (upload.getLastResult() == UploadResult.NETWORK_CONNECTION) { status = mParentActivity.getString(R.string.uploads_view_upload_status_failed_connection_error); } else { - status = mParentActivity.getString(R.string.uploads_view_upload_status_failed_retry);; + status = mParentActivity.getString(R.string.uploads_view_upload_status_failed_retry); } String laterReason = FileUploadService.getUploadLaterReason(mParentActivity, upload); if(laterReason != null) { @@ -228,13 +252,13 @@ public class ExpandableUploadListAdapter extends BaseExpandableListAdapter imple status = FileUploadService.getUploadLaterReason(mParentActivity, upload); break; case UPLOAD_SUCCEEDED: - status = "Completed."; + status = mParentActivity.getString(R.string.uploads_view_upload_status_succeeded); break; case UPLOAD_CANCELLED: - status = "Upload cancelled."; + status = mParentActivity.getString(R.string.uploads_view_upload_status_cancelled); break; case UPLOAD_PAUSED: - status = "Upload paused."; + status = mParentActivity.getString(R.string.uploads_view_upload_status_paused); break; default: status = upload.getUploadStatus().toString(); @@ -265,7 +289,6 @@ public class ExpandableUploadListAdapter extends BaseExpandableListAdapter imple rightButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { - Log_OC.d(TAG, "Retry unpload CLICK"); mParentActivity.getFileOperationsHelper().retryUpload(upload); } }); @@ -365,12 +388,7 @@ public class ExpandableUploadListAdapter extends BaseExpandableListAdapter imple for (UploadGroup group : mUploadGroups) { group.refresh(); } -// mParentActivity.runOnUiThread(new Runnable() { -// @Override -// public void run() { -// notifyDataSetChanged(); -// } -// }); + notifyDataSetChanged(); }