X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/blobdiff_plain/17ffd07e36497be3f81b4874229a121f982b2a5e..766b51f497971141da27ed16a11413d1bf590529:/src/com/owncloud/android/files/services/FileDownloader.java diff --git a/src/com/owncloud/android/files/services/FileDownloader.java b/src/com/owncloud/android/files/services/FileDownloader.java index ba9824ad..fdc35f8d 100644 --- a/src/com/owncloud/android/files/services/FileDownloader.java +++ b/src/com/owncloud/android/files/services/FileDownloader.java @@ -34,20 +34,21 @@ import com.owncloud.android.datamodel.FileDataStorageManager; import com.owncloud.android.datamodel.OCFile; 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.notifications.NotificationBuilderWithProgressBar; import com.owncloud.android.notifications.NotificationDelayer; -import com.owncloud.android.operations.DownloadFileOperation; import com.owncloud.android.lib.common.operations.RemoteOperationResult; import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode; +import com.owncloud.android.lib.common.utils.Log_OC; import com.owncloud.android.lib.resources.files.FileUtils; +import com.owncloud.android.operations.DownloadFileOperation; import com.owncloud.android.ui.activity.FileActivity; import com.owncloud.android.ui.activity.FileDisplayActivity; import com.owncloud.android.ui.preview.PreviewImageActivity; import com.owncloud.android.ui.preview.PreviewImageFragment; import com.owncloud.android.utils.ErrorMessageAdapter; -import com.owncloud.android.utils.Log_OC; import android.accounts.Account; import android.accounts.AccountsException; @@ -347,8 +348,11 @@ public class FileDownloader extends Service implements OnDatatransferProgressLis /// prepare client object to send the request to the ownCloud server if (mDownloadClient == null || !mLastAccount.equals(mCurrentDownload.getAccount())) { mLastAccount = mCurrentDownload.getAccount(); - mStorageManager = new FileDataStorageManager(mLastAccount, getContentResolver()); - mDownloadClient = OwnCloudClientFactory.createOwnCloudClient(mLastAccount, getApplicationContext()); + mStorageManager = + new FileDataStorageManager(mLastAccount, getContentResolver()); + OwnCloudAccount ocAccount = new OwnCloudAccount(mLastAccount, this); + mDownloadClient = OwnCloudClientManagerFactory.getDefaultSingleton(). + getClientFor(ocAccount, this); } /// perform the download @@ -387,12 +391,14 @@ public class FileDownloader extends Service implements OnDatatransferProgressLis long syncDate = System.currentTimeMillis(); file.setLastSyncDateForProperties(syncDate); file.setLastSyncDateForData(syncDate); + file.setNeedsUpdateThumbnail(true); file.setModificationTimestamp(mCurrentDownload.getModificationTimestamp()); file.setModificationTimestampAtLastSyncForData(mCurrentDownload.getModificationTimestamp()); // file.setEtag(mCurrentDownload.getEtag()); // TODO Etag, where available file.setMimetype(mCurrentDownload.getMimeType()); file.setStoragePath(mCurrentDownload.getSavePath()); file.setFileLength((new File(mCurrentDownload.getSavePath()).length())); + file.setRemoteId(mCurrentDownload.getFile().getRemoteId()); mStorageManager.saveFile(file); } @@ -466,9 +472,10 @@ public class FileDownloader extends Service implements OnDatatransferProgressLis int tickerId = (downloadResult.isSuccess()) ? R.string.downloader_download_succeeded_ticker : R.string.downloader_download_failed_ticker; - boolean needsToUpdateCredentials = (downloadResult.getCode() == ResultCode.UNAUTHORIZED || - (downloadResult.isIdPRedirection() - && mDownloadClient.getCredentials() == null)); + boolean needsToUpdateCredentials = ( + downloadResult.getCode() == ResultCode.UNAUTHORIZED || + downloadResult.isIdPRedirection() + ); tickerId = (needsToUpdateCredentials) ? R.string.downloader_download_failed_credentials_error : tickerId; @@ -512,15 +519,6 @@ public class FileDownloader extends Service implements OnDatatransferProgressLis mNotificationManager, R.string.downloader_download_succeeded_ticker, 2000); - /* - Handler handler = new Handler(); - handler.postDelayed(new Runnable() { - public void run() { - mNotificationManager.cancel(R.string.downloader_download_succeeded_ticker); - } - }, 2000); - */ - } }