Fixed title in action bar when user clicks on upload notification in progress / failed
[pub/Android/ownCloud.git] / src / com / owncloud / android / authentication / AccountUtils.java
index b535fc9..87766b5 100644 (file)
@@ -23,7 +23,6 @@ package com.owncloud.android.authentication;
 import java.util.Locale;\r
 \r
 import com.owncloud.android.MainApp;\r
-import com.owncloud.android.lib.common.OwnCloudAccount;\r
 import com.owncloud.android.lib.common.accounts.AccountTypeUtils;\r
 import com.owncloud.android.lib.common.accounts.AccountUtils.Constants;\r
 import com.owncloud.android.lib.common.utils.Log_OC;\r
@@ -115,7 +114,7 @@ public class AccountUtils {
         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
@@ -221,19 +220,20 @@ public class AccountUtils {
                         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
@@ -243,7 +243,9 @@ public class AccountUtils {
 \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
@@ -276,12 +278,15 @@ public class AccountUtils {
      *                      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
-            return new OwnCloudVersion(serverVersionStr);\r
+            if (serverVersionStr != null) {\r
+                serverVersion = new OwnCloudVersion(serverVersionStr);\r
+            }\r
         }\r
-        return null;\r
+        return serverVersion;\r
     }\r
 \r
 }\r