mirror of
https://github.com/nextcloud/android.git
synced 2024-11-27 09:39:25 +03:00
Migrate CheckCurrentCredentialsOperation to User
Signed-off-by: Chris Narkiewicz <hello@ezaquarii.com>
This commit is contained in:
parent
2cc7788b7f
commit
d06463bbc5
2 changed files with 9 additions and 9 deletions
|
@ -22,6 +22,7 @@ package com.owncloud.android.operations;
|
|||
|
||||
import android.accounts.Account;
|
||||
|
||||
import com.nextcloud.client.account.User;
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
import com.owncloud.android.lib.common.OwnCloudClient;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperation;
|
||||
|
@ -36,19 +37,17 @@ import java.util.ArrayList;
|
|||
*/
|
||||
public class CheckCurrentCredentialsOperation extends SyncOperation {
|
||||
|
||||
private Account mAccount;
|
||||
private final User user;
|
||||
|
||||
public CheckCurrentCredentialsOperation(Account account) {
|
||||
if (account == null) {
|
||||
throw new IllegalArgumentException("NULL account");
|
||||
}
|
||||
mAccount = account;
|
||||
public CheckCurrentCredentialsOperation(User user) {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected RemoteOperationResult run(OwnCloudClient client) {
|
||||
RemoteOperationResult result = null;
|
||||
if (!getStorageManager().getAccount().name.equals(mAccount.name)) {
|
||||
boolean validAccount = user.nameEquals(getStorageManager().getAccount().name);
|
||||
if (!validAccount) {
|
||||
result = new RemoteOperationResult(new IllegalStateException(
|
||||
"Account to validate is not the account connected to!")
|
||||
);
|
||||
|
@ -56,9 +55,10 @@ public class CheckCurrentCredentialsOperation extends SyncOperation {
|
|||
RemoteOperation check = new ExistenceCheckRemoteOperation(OCFile.ROOT_PATH, false);
|
||||
result = check.execute(client);
|
||||
ArrayList<Object> data = new ArrayList<>();
|
||||
data.add(mAccount);
|
||||
data.add(user.toPlatformAccount());
|
||||
result.setData(data);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -672,7 +672,7 @@ public class OperationsService extends Service {
|
|||
break;
|
||||
|
||||
case ACTION_CHECK_CURRENT_CREDENTIALS:
|
||||
operation = new CheckCurrentCredentialsOperation(account);
|
||||
operation = new CheckCurrentCredentialsOperation(user);
|
||||
break;
|
||||
|
||||
case ACTION_RESTORE_VERSION:
|
||||
|
|
Loading…
Reference in a new issue