projects
/
pub
/
Android
/
ownCloud.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
4241642
)
Cancellable synchronization; current synchronizations are cancelled when the user...
author
David A. Velasco
<dvelasco@solidgear.es>
Mon, 16 Jul 2012 13:06:03 +0000
(15:06 +0200)
committer
David A. Velasco
<dvelasco@solidgear.es>
Mon, 16 Jul 2012 13:06:03 +0000
(15:06 +0200)
AndroidManifest.xml
patch
|
blob
|
blame
|
history
src/eu/alefzero/owncloud/syncadapter/FileSyncAdapter.java
patch
|
blob
|
blame
|
history
src/eu/alefzero/owncloud/ui/activity/FileDisplayActivity.java
patch
|
blob
|
blame
|
history
diff --git
a/AndroidManifest.xml
b/AndroidManifest.xml
index
a6539f4
..
53c014c
100644
(file)
--- a/
AndroidManifest.xml
+++ b/
AndroidManifest.xml
@@
-18,7
+18,7
@@
-->
\r
<manifest package="eu.alefzero.owncloud"
\r
android:versionCode="1"
\r
-->
\r
<manifest package="eu.alefzero.owncloud"
\r
android:versionCode="1"
\r
- android:versionName="0.1.1
59
B" xmlns:android="http://schemas.android.com/apk/res/android">
\r
+ android:versionName="0.1.1
60
B" xmlns:android="http://schemas.android.com/apk/res/android">
\r
\r
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
\r
<uses-permission android:name="android.permission.USE_CREDENTIALS" />
\r
\r
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
\r
<uses-permission android:name="android.permission.USE_CREDENTIALS" />
\r
diff --git
a/src/eu/alefzero/owncloud/syncadapter/FileSyncAdapter.java
b/src/eu/alefzero/owncloud/syncadapter/FileSyncAdapter.java
index
fbee3b0
..
9f0c0dc
100644
(file)
--- a/
src/eu/alefzero/owncloud/syncadapter/FileSyncAdapter.java
+++ b/
src/eu/alefzero/owncloud/syncadapter/FileSyncAdapter.java
@@
-19,7
+19,6
@@
package eu.alefzero.owncloud.syncadapter;
\r
\r
import java.io.IOException;
\r
package eu.alefzero.owncloud.syncadapter;
\r
\r
import java.io.IOException;
\r
-import java.io.ObjectInputStream.GetField;
\r
import java.util.List;
\r
import java.util.Vector;
\r
\r
import java.util.List;
\r
import java.util.Vector;
\r
\r
@@
-60,6
+59,8
@@
public class FileSyncAdapter extends AbstractOwnCloudSyncAdapter {
*/
\r
\r
private long mCurrentSyncTime;
\r
*/
\r
\r
private long mCurrentSyncTime;
\r
+ private boolean mCancellation;
\r
+ private Account mAccount;
\r
\r
public FileSyncAdapter(Context context, boolean autoInitialize) {
\r
super(context, autoInitialize);
\r
\r
public FileSyncAdapter(Context context, boolean autoInitialize) {
\r
super(context, autoInitialize);
\r
@@
-70,9
+71,12
@@
public class FileSyncAdapter extends AbstractOwnCloudSyncAdapter {
String authority, ContentProviderClient provider,
\r
SyncResult syncResult) {
\r
\r
String authority, ContentProviderClient provider,
\r
SyncResult syncResult) {
\r
\r
- this.setAccount(account);
\r
+ mCancellation = false;
\r
+ mAccount = account;
\r
+
\r
+ this.setAccount(mAccount);
\r
this.setContentProvider(provider);
\r
this.setContentProvider(provider);
\r
- this.setStorageManager(new FileDataStorageManager(
a
ccount,
\r
+ this.setStorageManager(new FileDataStorageManager(
mA
ccount,
\r
getContentProvider()));
\r
\r
/* Commented code for ugly performance tests
\r
getContentProvider()));
\r
\r
/* Commented code for ugly performance tests
\r
@@
-81,7
+85,7
@@
public class FileSyncAdapter extends AbstractOwnCloudSyncAdapter {
*/
\r
\r
\r
*/
\r
\r
\r
- Log.d(TAG, "syncing owncloud account " +
a
ccount.name);
\r
+ Log.d(TAG, "syncing owncloud account " +
mA
ccount.name);
\r
\r
sendStickyBroadcast(true, null); // message to signal the start to the UI
\r
\r
\r
sendStickyBroadcast(true, null); // message to signal the start to the UI
\r
\r
@@
-98,7
+102,9
@@
public class FileSyncAdapter extends AbstractOwnCloudSyncAdapter {
OCFile file = fillOCFile(we);
\r
file.setParentId(0);
\r
getStorageManager().saveFile(file);
\r
OCFile file = fillOCFile(we);
\r
file.setParentId(0);
\r
getStorageManager().saveFile(file);
\r
- fetchData(getUri().toString(), syncResult, file.getFileId(), account);
\r
+ if (!mCancellation) {
\r
+ fetchData(getUri().toString(), syncResult, file.getFileId());
\r
+ }
\r
}
\r
} catch (OperationCanceledException e) {
\r
e.printStackTrace();
\r
}
\r
} catch (OperationCanceledException e) {
\r
e.printStackTrace();
\r
@@
-141,7
+147,7
@@
public class FileSyncAdapter extends AbstractOwnCloudSyncAdapter {
sendStickyBroadcast(false, null);
\r
}
\r
\r
sendStickyBroadcast(false, null);
\r
}
\r
\r
- private void fetchData(String uri, SyncResult syncResult, long parentId
, Account account
) {
\r
+ private void fetchData(String uri, SyncResult syncResult, long parentId) {
\r
try {
\r
//Log.v(TAG, "syncing: fetching " + uri);
\r
\r
try {
\r
//Log.v(TAG, "syncing: fetching " + uri);
\r
\r
@@
-210,12
+216,14
@@
public class FileSyncAdapter extends AbstractOwnCloudSyncAdapter {
sendStickyBroadcast(true, getStorageManager().getFileById(parentId).getRemotePath());
\r
\r
// recursive fetch
\r
sendStickyBroadcast(true, getStorageManager().getFileById(parentId).getRemotePath());
\r
\r
// recursive fetch
\r
- for (OCFile newFile : files) {
\r
+ for (int i=0; i < files.size() && !mCancellation; i++) {
\r
+ OCFile newFile = files.get(i);
\r
if (newFile.getMimetype().equals("DIR")) {
\r
if (newFile.getMimetype().equals("DIR")) {
\r
- fetchData(getUri().toString() + newFile.getRemotePath(), syncResult, newFile.getFileId()
, account
);
\r
+ fetchData(getUri().toString() + newFile.getRemotePath(), syncResult, newFile.getFileId());
\r
}
\r
}
\r
}
\r
}
\r
-
\r
+ if (mCancellation) Log.d(TAG, "Leaving " + uri + " because cancellation request");
\r
+
\r
/* Commented code for ugly performance tests
\r
mResponseDelays[mDelaysIndex] = responseDelay;
\r
mSaveDelays[mDelaysIndex] = saveDelay;
\r
/* Commented code for ugly performance tests
\r
mResponseDelays[mDelaysIndex] = responseDelay;
\r
mSaveDelays[mDelaysIndex] = saveDelay;
\r
@@
-240,7
+248,7
@@
public class FileSyncAdapter extends AbstractOwnCloudSyncAdapter {
e.printStackTrace();
\r
} catch (Throwable t) {
\r
// TODO update syncResult
\r
e.printStackTrace();
\r
} catch (Throwable t) {
\r
// TODO update syncResult
\r
- Log.e(TAG, "problem while synchronizing owncloud account " +
a
ccount.name, t);
\r
+ Log.e(TAG, "problem while synchronizing owncloud account " +
mA
ccount.name, t);
\r
t.printStackTrace();
\r
}
\r
}
\r
t.printStackTrace();
\r
}
\r
}
\r
@@
-266,9
+274,16
@@
public class FileSyncAdapter extends AbstractOwnCloudSyncAdapter {
getContext().sendStickyBroadcast(i);
\r
}
\r
\r
getContext().sendStickyBroadcast(i);
\r
}
\r
\r
+ /**
\r
+ * Called by system SyncManager when a synchronization is required to be cancelled.
\r
+ *
\r
+ * Sets the mCancellation flag to 'true'. THe synchronization will be stopped when before a new folder is fetched. Data of the last folder
\r
+ * fetched will be still saved in the database. See onPerformSync implementation.
\r
+ */
\r
@Override
\r
public void onSyncCanceled() {
\r
@Override
\r
public void onSyncCanceled() {
\r
- Log.d(TAG, "sync is being cancelled !! ************************************************");
\r
+ Log.d(TAG, "Synchronization of " + mAccount.name + " has been requested to cancell");
\r
+ mCancellation = true;
\r
super.onSyncCanceled();
\r
}
\r
\r
super.onSyncCanceled();
\r
}
\r
\r
diff --git
a/src/eu/alefzero/owncloud/ui/activity/FileDisplayActivity.java
b/src/eu/alefzero/owncloud/ui/activity/FileDisplayActivity.java
index
7e62084
..
e54913a
100644
(file)
--- a/
src/eu/alefzero/owncloud/ui/activity/FileDisplayActivity.java
+++ b/
src/eu/alefzero/owncloud/ui/activity/FileDisplayActivity.java
@@
-170,8
+170,7
@@
public class FileDisplayActivity extends SherlockFragmentActivity implements
break;
\r
}
\r
case R.id.startSync: {
\r
break;
\r
}
\r
case R.id.startSync: {
\r
- // This could be interesting
\r
- //ContentResolver.cancelSync(null, "org.owncloud"); // cancel the current synchronizations of any other ownCloud account
\r
+ ContentResolver.cancelSync(null, "org.owncloud"); // cancel the current synchronizations of any ownCloud account
\r
Bundle bundle = new Bundle();
\r
bundle.putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, true);
\r
ContentResolver.requestSync(
\r
Bundle bundle = new Bundle();
\r
bundle.putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, true);
\r
ContentResolver.requestSync(
\r