Checking Credential Error failed uploads: show error as Credential error and relogin

This commit is contained in:
masensio 2016-01-25 13:02:22 +01:00
parent b6f8e93504
commit 198c1bf3b0
6 changed files with 46 additions and 16 deletions

View file

@ -118,8 +118,12 @@
<string name="uploader_upload_failed_ticker">Upload failed</string>
<string name="uploader_upload_failed_content_single">Upload of %1$s could not be completed</string>
<string name="uploader_upload_failed_credentials_error">Upload failed, you need to relogin</string>
<string name="uploads_view_upload_status_succeeded">Completed</string>
<string name="uploads_view_upload_status_cancelled">Cancelled</string>
<string name="uploads_view_upload_status_paused">Paused</string>
<string name="uploads_view_upload_status_failed_connection_error">Connection error</string>
<string name="uploads_view_upload_status_failed_retry">Upload will be retried shortly</string>
<string name="uploads_view_upload_status_failed_credentials_error">Credentials error</string>
<string name="downloader_download_in_progress_ticker">Downloading &#8230;</string>
<string name="downloader_download_in_progress_content">%1$d%% Downloading %2$s</string>
<string name="downloader_download_succeeded_ticker">Download succeeded</string>

View file

@ -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);

View file

@ -341,7 +341,7 @@ public class OCUpload implements Parcelable{
/****
* PARCELABLE METHODS
*
*/
public static final Parcelable.Creator<OCUpload> CREATOR = new Parcelable.Creator<OCUpload>() {

View file

@ -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;
}

View file

@ -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())) {

View file

@ -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();
}