From: David A. Velasco Date: Mon, 18 Nov 2013 13:10:16 +0000 (+0100) Subject: Merge branch 'develop' into refactor_remote_operation_to_create_folder X-Git-Tag: oc-android-1.5.5~126^2~1 X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/commitdiff_plain/e1245bbda7894e1a3028d2b54a6918e4bdd46ae2?ds=inline;hp=-c Merge branch 'develop' into refactor_remote_operation_to_create_folder --- e1245bbda7894e1a3028d2b54a6918e4bdd46ae2 diff --combined AndroidManifest.xml index b1075278,f1900f8c..bdd792b0 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@@ -18,8 -18,8 +18,8 @@@ along with this program. If not, see . --> + android:versionCode="105000" + android:versionName="1.5.0" xmlns:android="http://schemas.android.com/apk/res/android"> @@@ -63,7 -63,7 +63,7 @@@ - + diff --combined res/values/strings.xml index 46110933,c8cea0ba..05c7ecf8 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@@ -182,7 -182,6 +182,7 @@@ Remote file could not be checked File contents already synchronized Directory could not be created + Forbidden characters: / \\ < > : " | ? * Wait a moment "Unexpected problem ; please select the file from a different app" No file was selected @@@ -232,7 -231,7 +232,7 @@@ This image can not be shown %1$s could not be copied to %2$s local directory - Failed InstantUpload" + Failed InstantUpload Failed instant uploads Summary of all failed instant uploads select all diff --combined src/com/owncloud/android/files/OwnCloudFileObserver.java index 47a66b65,964b61c3..68c97e4f --- a/src/com/owncloud/android/files/OwnCloudFileObserver.java +++ b/src/com/owncloud/android/files/OwnCloudFileObserver.java @@@ -20,16 -20,14 +20,14 @@@ package com.owncloud.android.files import java.io.File; -import com.owncloud.android.Log_OC; import com.owncloud.android.datamodel.FileDataStorageManager; import com.owncloud.android.datamodel.OCFile; -import com.owncloud.android.operations.RemoteOperationResult; +import com.owncloud.android.oc_framework.operations.RemoteOperationResult; import com.owncloud.android.operations.SynchronizeFileOperation; -import com.owncloud.android.operations.RemoteOperationResult.ResultCode; +import com.owncloud.android.oc_framework.operations.RemoteOperationResult.ResultCode; import com.owncloud.android.ui.activity.ConflictsResolveActivity; +import com.owncloud.android.utils.Log_OC; - - import android.accounts.Account; import android.content.Context; import android.content.Intent; @@@ -37,45 -35,57 +35,57 @@@ import android.os.FileObserver public class OwnCloudFileObserver extends FileObserver { - public static int CHANGES_ONLY = CLOSE_WRITE; + private static int MASK = (FileObserver.MODIFY | FileObserver.CLOSE_WRITE); private static String TAG = OwnCloudFileObserver.class.getSimpleName(); private String mPath; private int mMask; private Account mOCAccount; - //private OCFile mFile; private Context mContext; + private boolean mModified; - public OwnCloudFileObserver(String path, Account account, Context context, int mask) { - super(path, mask); + public OwnCloudFileObserver(String path, Account account, Context context) { + super(path, MASK); if (path == null) throw new IllegalArgumentException("NULL path argument received"); - /*if (file == null) - throw new IllegalArgumentException("NULL file argument received");*/ if (account == null) throw new IllegalArgumentException("NULL account argument received"); if (context == null) throw new IllegalArgumentException("NULL context argument received"); - /*if (!path.equals(file.getStoragePath()) && !path.equals(FileStorageUtils.getDefaultSavePathFor(account.name, file))) - throw new IllegalArgumentException("File argument is not linked to the local file set in path argument"); */ mPath = path; - //mFile = file; mOCAccount = account; mContext = context; - mMask = mask; + mModified = false; } + @Override public void onEvent(int event, String path) { Log_OC.d(TAG, "Got file modified with event " + event + " and path " + mPath + ((path != null) ? File.separator + path : "")); - if ((event & mMask) == 0) { + if ((event & MASK) == 0) { Log_OC.wtf(TAG, "Incorrect event " + event + " sent for file " + mPath + ((path != null) ? File.separator + path : "") + " with registered for " + mMask + " and original path " + mPath); - return; - } + } else { + if ((event & FileObserver.MODIFY) != 0) { + // file changed + mModified = true; + } + // not sure if it's possible, but let's assume that both kind of events can be received at the same time + if ((event & FileObserver.CLOSE_WRITE) != 0) { + // file closed + if (mModified) { + mModified = false; + startSyncOperation(); + } + } + } + } + + + private void startSyncOperation() { FileDataStorageManager storageManager = new FileDataStorageManager(mOCAccount, mContext.getContentResolver()); OCFile file = storageManager.getFileByLocalPath(mPath); // a fresh object is needed; many things could have occurred to the file since it was registered to observe // again, assuming that local files are linked to a remote file AT MOST, SOMETHING TO BE DONE; diff --combined src/com/owncloud/android/files/services/FileObserverService.java index 871d2abf,502d4591..fa1fec24 --- a/src/com/owncloud/android/files/services/FileObserverService.java +++ b/src/com/owncloud/android/files/services/FileObserverService.java @@@ -22,13 -22,13 +22,13 @@@ import java.io.File import java.util.HashMap; import java.util.Map; -import com.owncloud.android.Log_OC; import com.owncloud.android.datamodel.FileDataStorageManager; import com.owncloud.android.datamodel.OCFile; import com.owncloud.android.db.ProviderMeta.ProviderTableMeta; import com.owncloud.android.files.OwnCloudFileObserver; import com.owncloud.android.operations.SynchronizeFileOperation; import com.owncloud.android.utils.FileStorageUtils; +import com.owncloud.android.utils.Log_OC; import android.accounts.Account; @@@ -162,8 -162,7 +162,7 @@@ public class FileObserverService extend OwnCloudFileObserver observer = new OwnCloudFileObserver( path, account, - getApplicationContext(), - OwnCloudFileObserver.CHANGES_ONLY); + getApplicationContext()); mObserversMap.put(path, observer); if (new File(path).exists()) { observer.startWatching(); @@@ -202,8 -201,7 +201,7 @@@ /// the local file was never registered to observe before observer = new OwnCloudFileObserver( localPath, account, - getApplicationContext(), - OwnCloudFileObserver.CHANGES_ONLY); + getApplicationContext()); mObserversMap.put(localPath, observer); Log_OC.d(TAG, "Observer added for path " + localPath);