From: masensio Date: Thu, 1 Oct 2015 16:45:01 +0000 (+0200) Subject: Merge pull request #839 from fluffy88/develop X-Git-Tag: oc-android-1.9^2~63 X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/commitdiff_plain/99d7e189168fb85dda899d218ecfb3bd03a7f478?ds=inline;hp=-c Merge pull request #839 from fluffy88/develop Trigger media scan after file upload --- 99d7e189168fb85dda899d218ecfb3bd03a7f478 diff --combined src/com/owncloud/android/files/services/FileUploader.java index 98ad87e2,eb33b376..669ff135 --- a/src/com/owncloud/android/files/services/FileUploader.java +++ b/src/com/owncloud/android/files/services/FileUploader.java @@@ -48,6 -48,7 +48,6 @@@ import android.os.Process import android.support.v4.app.NotificationCompat; import android.webkit.MimeTypeMap; -import com.owncloud.android.MainApp; import com.owncloud.android.R; import com.owncloud.android.authentication.AccountUtils; import com.owncloud.android.authentication.AuthenticatorActivity; @@@ -57,6 -58,7 +57,6 @@@ import com.owncloud.android.db.DbHandle 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.lib.common.accounts.AccountUtils.Constants; import com.owncloud.android.lib.common.network.OnDatatransferProgressListener; import com.owncloud.android.lib.common.operations.RemoteOperation; import com.owncloud.android.lib.common.operations.RemoteOperationResult; @@@ -116,8 -118,7 +116,8 @@@ public class FileUploader extends Servi private Account mLastAccount = null; private FileDataStorageManager mStorageManager; - private ConcurrentMap mPendingUploads = new ConcurrentHashMap(); + private ConcurrentMap mPendingUploads = + new ConcurrentHashMap(); private UploadFileOperation mCurrentUpload = null; private NotificationManager mNotificationManager; @@@ -129,7 -130,7 +129,7 @@@ public static String getUploadFinishMessage() { - return FileUploader.class.getName().toString() + UPLOAD_FINISH_MESSAGE; + return FileUploader.class.getName() + UPLOAD_FINISH_MESSAGE; } /** @@@ -229,7 -230,7 +229,7 @@@ if (uploadType == UPLOAD_SINGLE_FILE) { if (intent.hasExtra(KEY_FILE)) { - files = new OCFile[] { (OCFile) intent.getParcelableExtra(KEY_FILE) }; + files = new OCFile[] { intent.getParcelableExtra(KEY_FILE) }; } else { localPaths = new String[] { intent.getStringExtra(KEY_LOCAL_FILE) }; @@@ -282,7 -283,7 +282,7 @@@ files = new OCFile[localPaths.length]; for (int i = 0; i < localPaths.length; i++) { files[i] = obtainNewOCFileToUpload(remotePaths[i], localPaths[i], - ((mimeTypes != null) ? mimeTypes[i] : (String) null), storageManager); + ((mimeTypes != null) ? mimeTypes[i] : null), storageManager); if (files[i] == null) { // TODO @andomaex add failure Notification return Service.START_NOT_STICKY; @@@ -290,7 -291,9 +290,7 @@@ } } - AccountManager aMgr = AccountManager.get(this); - String version = aMgr.getUserData(account, Constants.KEY_OC_VERSION); - OwnCloudVersion ocv = new OwnCloudVersion(version); + OwnCloudVersion ocv = AccountUtils.getServerVersion(account); boolean chunked = FileUploader.chunkedUploadIsSupported(ocv); AbstractList requestedUploads = new Vector(); @@@ -380,8 -383,7 +380,8 @@@ * Map of listeners that will be reported about progress of uploads from a * {@link FileUploaderBinder} instance */ - private Map mBoundListeners = new HashMap(); + private Map mBoundListeners = + new HashMap(); /** * Cancels a pending or current upload of a remote file. @@@ -390,7 -392,7 +390,7 @@@ * @param file A file in the queue of pending uploads */ public void cancel(Account account, OCFile file) { - UploadFileOperation upload = null; + UploadFileOperation upload; synchronized (mPendingUploads) { upload = mPendingUploads.remove(buildRemoteName(account, file)); } @@@ -561,7 -563,7 +561,7 @@@ notifyUploadStart(mCurrentUpload); - RemoteOperationResult uploadResult = null, grantResult = null; + RemoteOperationResult uploadResult = null, grantResult; try { /// prepare client object to send requests to the ownCloud server @@@ -608,7 -610,7 +608,7 @@@ mPendingUploads.remove(uploadKey); Log_OC.i(TAG, "Remove CurrentUploadItem from pending upload Item Map."); } - if (uploadResult.isException()) { + if (uploadResult != null && uploadResult.isException()) { // enforce the creation of a new client object for next uploads; // this grant that a new socket will be created in the future if // the current exception is due to an abrupt lose of network connection @@@ -725,6 -727,7 +725,7 @@@ } file.setNeedsUpdateThumbnail(true); mStorageManager.saveFile(file); + mStorageManager.triggerMediaScan(file.getStoragePath()); } private void updateOCFile(OCFile file, RemoteFile remoteFile) { @@@ -843,7 -846,7 +844,7 @@@ int tickerId = (uploadResult.isSuccess()) ? R.string.uploader_upload_succeeded_ticker : R.string.uploader_upload_failed_ticker; - String content = null; + String content; // check credentials error boolean needsToUpdateCredentials = ( @@@ -962,8 -965,8 +963,8 @@@ /** * Checks if content provider, using the content:// scheme, returns a file with mime-type * 'application/pdf' but file has not extension - * @param localPath - * @param mimeType + * @param localPath Full path to a file in the local file system. + * @param mimeType MIME type of the file. * @return true if is needed to add the pdf file extension to the file */ private boolean isPdfFileFromContentProviderWithoutExtension(String localPath, @@@ -975,7 -978,7 +976,7 @@@ /** * Remove uploads of an account - * @param accountName + * @param accountName Name of an OC account */ private void cancelUploadForAccount(String accountName){ // this can be slow if there are many uploads :(