if (accountName != null) {\r
Account[] ocAccounts = AccountManager.get(context).getAccountsByType(\r
MainApp.getAccountType());\r
- boolean found = false;\r
+ boolean found;\r
for (Account account : ocAccounts) {\r
found = (account.name.equals(accountName));\r
if (found) {\r
if (isOAuth) {\r
accountMgr.setUserData(newAccount, Constants.KEY_SUPPORTS_OAUTH2, "TRUE");\r
}\r
- /* TODO - study if it's possible to run this method in a background thread to copy the authToken\r
- if (isOAuth || isSaml) {\r
- accountMgr.setAuthToken(newAccount, mAuthTokenType, mAuthToken);\r
- }\r
- */\r
+ /* TODO - study if it's possible to run this method in a background thread to copy the authToken\r
+ if (isOAuth || isSaml) {\r
+ accountMgr.setAuthToken(newAccount, mAuthTokenType, mAuthToken);\r
+ }\r
+ */\r
\r
// don't forget the account saved in preferences as the current one\r
- if (currentAccount != null && currentAccount.name.equals(account.name)) {\r
+ if (currentAccount.name.equals(account.name)) {\r
AccountUtils.setCurrentOwnCloudAccount(context, newAccountName);\r
}\r
\r
// remove the old account\r
- accountMgr.removeAccount(account, null, null); // will assume it succeeds, not a big deal otherwise\r
+ accountMgr.removeAccount(account, null, null);\r
+ // will assume it succeeds, not a big deal otherwise\r
\r
} else {\r
// servers which base URL is in the root of their domain need no change\r
\r
// at least, upgrade account version\r
Log_OC.d(TAG, "Setting version " + ACCOUNT_VERSION + " to " + newAccountName);\r
- accountMgr.setUserData(newAccount, Constants.KEY_OC_ACCOUNT_VERSION, Integer.toString(ACCOUNT_VERSION));\r
+ accountMgr.setUserData(\r
+ newAccount, Constants.KEY_OC_ACCOUNT_VERSION, Integer.toString(ACCOUNT_VERSION)\r
+ );\r
\r
}\r
}\r
return url;\r
}\r
\r
+ /**\r
+ * Access the version of the OC server corresponding to an account SAVED IN THE ACCOUNTMANAGER\r
+ *\r
+ * @param account ownCloud account\r
+ * @return Version of the OC server corresponding to account, according to the data saved\r
+ * in the system AccountManager\r
+ */\r
+ public static OwnCloudVersion getServerVersion(Account account) {\r
+ OwnCloudVersion serverVersion = null;\r
+ if (account != null) {\r
+ AccountManager accountMgr = AccountManager.get(MainApp.getAppContext());\r
+ String serverVersionStr = accountMgr.getUserData(account, Constants.KEY_OC_VERSION);\r
+ if (serverVersionStr != null) {\r
+ serverVersion = new OwnCloudVersion(serverVersionStr);\r
+ }\r
+ }\r
+ return serverVersion;\r
+ }\r
+\r
+ public static boolean hasSearchUsersSupport(Account account){\r
+ OwnCloudVersion serverVersion = null;\r
+ if (account != null) {\r
+ AccountManager accountMgr = AccountManager.get(MainApp.getAppContext());\r
+ String serverVersionStr = accountMgr.getUserData(account, Constants.KEY_OC_VERSION);\r
+ if (serverVersionStr != null) {\r
+ serverVersion = new OwnCloudVersion(serverVersionStr);\r
+ }\r
+ }\r
+ return (serverVersion != null ? serverVersion.isSearchUsersSupported() : false);\r
+ }\r
}\r