X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/blobdiff_plain/17ffd07e36497be3f81b4874229a121f982b2a5e..dba9c3a64dec698d142eb6f1653d441db7e1573a:/src/com/owncloud/android/files/services/FileUploader.java diff --git a/src/com/owncloud/android/files/services/FileUploader.java b/src/com/owncloud/android/files/services/FileUploader.java index 731522cf..7a5f8de5 100644 --- a/src/com/owncloud/android/files/services/FileUploader.java +++ b/src/com/owncloud/android/files/services/FileUploader.java @@ -48,8 +48,9 @@ import com.owncloud.android.lib.resources.files.FileUtils; import com.owncloud.android.lib.resources.status.OwnCloudVersion; import com.owncloud.android.lib.common.accounts.AccountUtils.Constants; import com.owncloud.android.lib.common.network.OnDatatransferProgressListener; -import com.owncloud.android.lib.common.OwnCloudClientFactory; +import com.owncloud.android.lib.common.OwnCloudAccount; import com.owncloud.android.lib.common.OwnCloudClient; +import com.owncloud.android.lib.common.OwnCloudClientManagerFactory; import com.owncloud.android.ui.activity.FailedUploadActivity; import com.owncloud.android.ui.activity.FileActivity; import com.owncloud.android.ui.activity.FileDisplayActivity; @@ -486,8 +487,11 @@ public class FileUploader extends Service implements OnDatatransferProgressListe /// prepare client object to send requests to the ownCloud server if (mUploadClient == null || !mLastAccount.equals(mCurrentUpload.getAccount())) { mLastAccount = mCurrentUpload.getAccount(); - mStorageManager = new FileDataStorageManager(mLastAccount, getContentResolver()); - mUploadClient = OwnCloudClientFactory.createOwnCloudClient(mLastAccount, getApplicationContext()); + mStorageManager = + new FileDataStorageManager(mLastAccount, getContentResolver()); + OwnCloudAccount ocAccount = new OwnCloudAccount(mLastAccount, this); + mUploadClient = OwnCloudClientManagerFactory.getDefaultSingleton(). + getClientFor(ocAccount, this); } /// check the existence of the parent folder for the file to upload @@ -737,9 +741,10 @@ public class FileUploader extends Service implements OnDatatransferProgressListe String content = null; // check credentials error - boolean needsToUpdateCredentials = (uploadResult.getCode() == ResultCode.UNAUTHORIZED || - (uploadResult.isIdPRedirection() && - mUploadClient.getCredentials() == null)); + boolean needsToUpdateCredentials = ( + uploadResult.getCode() == ResultCode.UNAUTHORIZED || + uploadResult.isIdPRedirection() + ); tickerId = (needsToUpdateCredentials) ? R.string.uploader_upload_failed_credentials_error : tickerId; @@ -807,9 +812,13 @@ public class FileUploader extends Service implements OnDatatransferProgressListe resultBuilder.setContentText(content); mNotificationManager.notify(tickerId, resultBuilder.build()); - // Remove success notification - if (uploadResult.isSuccess()) { - // Sleep 2 seconds, so show the notification before remove it + if (uploadResult.isSuccess()) { + + DbHandler db = new DbHandler(this.getBaseContext()); + db.removeIUPendingFile(mCurrentUpload.getOriginalStoragePath()); + db.close(); + + // remove success notification, with a delay of 2 seconds NotificationDelayer.cancelWithDelay( mNotificationManager, R.string.uploader_upload_succeeded_ticker,