X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/blobdiff_plain/1a3a1502485968a77640c08ae6f6b1bc06de1164..9d4ce6becd3973fb8aff57a2ac2c8b9c9df8a2ec:/src/com/owncloud/android/authentication/AccountUtils.java diff --git a/src/com/owncloud/android/authentication/AccountUtils.java b/src/com/owncloud/android/authentication/AccountUtils.java index b535fc90..87766b54 100644 --- a/src/com/owncloud/android/authentication/AccountUtils.java +++ b/src/com/owncloud/android/authentication/AccountUtils.java @@ -23,7 +23,6 @@ package com.owncloud.android.authentication; import java.util.Locale; import com.owncloud.android.MainApp; -import com.owncloud.android.lib.common.OwnCloudAccount; import com.owncloud.android.lib.common.accounts.AccountTypeUtils; import com.owncloud.android.lib.common.accounts.AccountUtils.Constants; import com.owncloud.android.lib.common.utils.Log_OC; @@ -115,7 +114,7 @@ public class AccountUtils { if (accountName != null) { Account[] ocAccounts = AccountManager.get(context).getAccountsByType( MainApp.getAccountType()); - boolean found = false; + boolean found; for (Account account : ocAccounts) { found = (account.name.equals(accountName)); if (found) { @@ -221,19 +220,20 @@ public class AccountUtils { if (isOAuth) { accountMgr.setUserData(newAccount, Constants.KEY_SUPPORTS_OAUTH2, "TRUE"); } - /* TODO - study if it's possible to run this method in a background thread to copy the authToken - if (isOAuth || isSaml) { - accountMgr.setAuthToken(newAccount, mAuthTokenType, mAuthToken); - } - */ + /* TODO - study if it's possible to run this method in a background thread to copy the authToken + if (isOAuth || isSaml) { + accountMgr.setAuthToken(newAccount, mAuthTokenType, mAuthToken); + } + */ // don't forget the account saved in preferences as the current one - if (currentAccount != null && currentAccount.name.equals(account.name)) { + if (currentAccount.name.equals(account.name)) { AccountUtils.setCurrentOwnCloudAccount(context, newAccountName); } // remove the old account - accountMgr.removeAccount(account, null, null); // will assume it succeeds, not a big deal otherwise + accountMgr.removeAccount(account, null, null); + // will assume it succeeds, not a big deal otherwise } else { // servers which base URL is in the root of their domain need no change @@ -243,7 +243,9 @@ public class AccountUtils { // at least, upgrade account version Log_OC.d(TAG, "Setting version " + ACCOUNT_VERSION + " to " + newAccountName); - accountMgr.setUserData(newAccount, Constants.KEY_OC_ACCOUNT_VERSION, Integer.toString(ACCOUNT_VERSION)); + accountMgr.setUserData( + newAccount, Constants.KEY_OC_ACCOUNT_VERSION, Integer.toString(ACCOUNT_VERSION) + ); } } @@ -276,12 +278,15 @@ public class AccountUtils { * in the system AccountManager */ public static OwnCloudVersion getServerVersion(Account account) { + OwnCloudVersion serverVersion = null; if (account != null) { AccountManager accountMgr = AccountManager.get(MainApp.getAppContext()); String serverVersionStr = accountMgr.getUserData(account, Constants.KEY_OC_VERSION); - return new OwnCloudVersion(serverVersionStr); + if (serverVersionStr != null) { + serverVersion = new OwnCloudVersion(serverVersionStr); + } } - return null; + return serverVersion; } }