mirror of
https://github.com/nextcloud/android.git
synced 2024-11-27 09:39:25 +03:00
Considered servers without sharing support
This commit is contained in:
parent
0fde0084e2
commit
dd7d44ed32
3 changed files with 31 additions and 6 deletions
|
@ -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) {
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Reference in a new issue