From: David A. Velasco Date: Fri, 7 Feb 2014 07:59:11 +0000 (+0100) Subject: Considered servers without sharing support X-Git-Tag: oc-android-1.5.5~58^2^2 X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/commitdiff_plain/dd7d44ed32245e38a814425f85ef2d61ac8134ac?ds=inline;hp=-c Considered servers without sharing support --- dd7d44ed32245e38a814425f85ef2d61ac8134ac diff --git a/src/com/owncloud/android/operations/SynchronizeFolderOperation.java b/src/com/owncloud/android/operations/SynchronizeFolderOperation.java index bf2a4e08..11ce41e5 100644 --- a/src/com/owncloud/android/operations/SynchronizeFolderOperation.java +++ b/src/com/owncloud/android/operations/SynchronizeFolderOperation.java @@ -100,9 +100,12 @@ public class SynchronizeFolderOperation extends RemoteOperation { /** 'True' means that this operation is part of a full account synchronization */ private boolean mSyncFullAccount; + /** 'True' means that Share resources bound to the files into the folder should be refreshed also */ + private boolean mRefreshShares; + /** 'True' means that the remote folder changed from last synchronization and should be fetched */ private boolean mRemoteFolderChanged; - + /** * Creates a new instance of {@link SynchronizeFolderOperation}. @@ -119,12 +122,14 @@ public class SynchronizeFolderOperation extends RemoteOperation { public SynchronizeFolderOperation( OCFile folder, long currentSyncTime, boolean syncFullAccount, + boolean refreshShares, FileDataStorageManager dataStorageManager, Account account, Context context ) { mLocalFolder = folder; mCurrentSyncTime = currentSyncTime; mSyncFullAccount = syncFullAccount; + mRefreshShares = refreshShares; mStorageManager = dataStorageManager; mAccount = account; mContext = context; @@ -180,10 +185,13 @@ public class SynchronizeFolderOperation extends RemoteOperation { sendLocalBroadcast(EVENT_SINGLE_FOLDER_CONTENTS_SYNCED, mLocalFolder.getRemotePath(), result); } - if (result.isSuccess()) { - result = refreshSharesForFolder(client); + if (result.isSuccess() && mRefreshShares) { + RemoteOperationResult shareResult = refreshSharesForFolder(client); + if (shareResult.getCode() != ResultCode.FILE_NOT_FOUND) { + result = shareResult; + } // else , keep the previous result ; being conservative for servers where Sharing API is supported, but disabled } - + if (!mSyncFullAccount) { sendLocalBroadcast(EVENT_SINGLE_FOLDER_SHARES_SYNCED, mLocalFolder.getRemotePath(), result); } @@ -506,6 +514,7 @@ public class SynchronizeFolderOperation extends RemoteOperation { * @param result */ private void sendLocalBroadcast(String event, String dirRemotePath, RemoteOperationResult result) { + Log_OC.d(TAG, "Send broadcast " + event); Intent intent = new Intent(event); intent.putExtra(FileSyncAdapter.EXTRA_ACCOUNT_NAME, mAccount.name); if (dirRemotePath != null) { diff --git a/src/com/owncloud/android/syncadapter/FileSyncAdapter.java b/src/com/owncloud/android/syncadapter/FileSyncAdapter.java index c550eaa8..6b2ea73e 100644 --- a/src/com/owncloud/android/syncadapter/FileSyncAdapter.java +++ b/src/com/owncloud/android/syncadapter/FileSyncAdapter.java @@ -30,6 +30,7 @@ import com.owncloud.android.R; import com.owncloud.android.authentication.AuthenticatorActivity; import com.owncloud.android.datamodel.FileDataStorageManager; import com.owncloud.android.datamodel.OCFile; +import com.owncloud.android.lib.accounts.OwnCloudAccount; import com.owncloud.android.lib.operations.common.RemoteOperationResult; import com.owncloud.android.operations.SynchronizeFolderOperation; import com.owncloud.android.operations.UpdateOCVersionOperation; @@ -40,6 +41,7 @@ import com.owncloud.android.utils.Log_OC; import android.accounts.Account; +import android.accounts.AccountManager; import android.accounts.AccountsException; import android.app.Notification; import android.app.NotificationManager; @@ -106,6 +108,9 @@ public class FileSyncAdapter extends AbstractOwnCloudSyncAdapter { /** {@link SyncResult} instance to return to the system when the synchronization finish */ private SyncResult mSyncResult; + + /** 'True' means that the server supports the share API */ + private boolean mIsSharedSupported; /** @@ -150,6 +155,10 @@ public class FileSyncAdapter extends AbstractOwnCloudSyncAdapter { this.setAccount(account); this.setContentProviderClient(providerClient); this.setStorageManager(new FileDataStorageManager(account, providerClient)); + + AccountManager accountManager = getAccountManager(); + mIsSharedSupported = Boolean.parseBoolean(accountManager.getUserData(account, OwnCloudAccount.Constants.KEY_SUPPORTS_SHARE_API)); + try { this.initClientForCurrentAccount(); } catch (IOException e) { @@ -254,13 +263,13 @@ public class FileSyncAdapter extends AbstractOwnCloudSyncAdapter { DataStorageManager dataStorageManager, Account account, Context context ) { - } */ // folder synchronization SynchronizeFolderOperation synchFolderOp = new SynchronizeFolderOperation( folder, mCurrentSyncTime, true, + mIsSharedSupported, getStorageManager(), getAccount(), getContext() @@ -360,6 +369,7 @@ public class FileSyncAdapter extends AbstractOwnCloudSyncAdapter { * @param result Result of an individual {@ SynchronizeFolderOperation}, if completed; may be null. */ private void sendLocalBroadcast(String event, String dirRemotePath, RemoteOperationResult result) { + Log_OC.d(TAG, "Send broadcast " + event); Intent intent = new Intent(event); intent.putExtra(FileSyncAdapter.EXTRA_ACCOUNT_NAME, getAccount().name); if (dirRemotePath != null) { diff --git a/src/com/owncloud/android/ui/activity/FileDisplayActivity.java b/src/com/owncloud/android/ui/activity/FileDisplayActivity.java index c6ce16c2..d5c0d5a9 100644 --- a/src/com/owncloud/android/ui/activity/FileDisplayActivity.java +++ b/src/com/owncloud/android/ui/activity/FileDisplayActivity.java @@ -906,6 +906,7 @@ OCFileListFragment.ContainerActivity, FileDetailFragment.ContainerActivity, OnNa @Override public void onReceive(Context context, Intent intent) { String event = intent.getAction(); + Log_OC.d(TAG, "Received broadcast " + event); String accountName = intent.getStringExtra(FileSyncAdapter.EXTRA_ACCOUNT_NAME); String synchFolderRemotePath = intent.getStringExtra(FileSyncAdapter.EXTRA_FOLDER_PATH); RemoteOperationResult synchResult = (RemoteOperationResult)intent.getSerializableExtra(FileSyncAdapter.EXTRA_RESULT); @@ -913,7 +914,10 @@ OCFileListFragment.ContainerActivity, FileDetailFragment.ContainerActivity, OnNa if (sameAccount) { - if (!FileSyncAdapter.EVENT_FULL_SYNC_START.equals(event)) { + if (FileSyncAdapter.EVENT_FULL_SYNC_START.equals(event)) { + mSyncInProgress = true; + + } else { OCFile currentFile = (getFile() == null) ? null : getStorageManager().getFileByPath(getFile().getRemotePath()); OCFile currentDir = (getCurrentDir() == null) ? null : getStorageManager().getFileByPath(getCurrentDir().getRemotePath()); @@ -958,6 +962,7 @@ OCFileListFragment.ContainerActivity, FileDetailFragment.ContainerActivity, OnNa } removeStickyBroadcast(intent); + Log_OC.d(TAG, "Setting progress visibility to " + mSyncInProgress); setSupportProgressBarIndeterminateVisibility(mSyncInProgress /*|| mRefreshSharesInProgress*/); } @@ -1536,6 +1541,7 @@ OCFileListFragment.ContainerActivity, FileDetailFragment.ContainerActivity, OnNa RemoteOperation synchFolderOp = new SynchronizeFolderOperation( folder, currentSyncTime, false, + getFileOperationsHelper().isSharedSupported(this), getStorageManager(), getAccount(), getApplicationContext()