Merge pull request #186 from owncloud/fixed_contradicted_messages_in_login_view
[pub/Android/ownCloud.git] / src / com / owncloud / android / AccountUtils.java
index a1d39ae..7297ee1 100644 (file)
@@ -37,12 +37,13 @@ public class AccountUtils {
     public static final String STATUS_PATH = "/status.php";\r
 \r
     /**\r
-     * Can be used to get the currently selected ownCloud account in the\r
-     * preferences\r
+     * Can be used to get the currently selected ownCloud {@link Account} in the\r
+     * application preferences.\r
      * \r
-     * @param context The current appContext\r
-     * @return The current account or first available, if none is available,\r
-     *         then null.\r
+     * @param   context     The current application {@link Context}\r
+     * @return              The ownCloud {@link Account} currently saved in preferences, or the first \r
+     *                      {@link Account} available, if valid (still registered in the system as ownCloud \r
+     *                      account). If none is available and valid, returns null.\r
      */\r
     public static Account getCurrentOwnCloudAccount(Context context) {\r
         Account[] ocAccounts = AccountManager.get(context).getAccountsByType(\r
@@ -54,6 +55,7 @@ public class AccountUtils {
         String accountName = appPreferences\r
                 .getString("select_oc_account", null);\r
 \r
+        // account validation: the saved account MUST be in the list of ownCloud Accounts known by the AccountManager\r
         if (accountName != null) {\r
             for (Account account : ocAccounts) {\r
                 if (account.name.equals(accountName)) {\r
@@ -64,7 +66,7 @@ public class AccountUtils {
         }\r
         \r
         if (defaultAccount == null && ocAccounts.length != 0) {\r
-            // we at least need to take first account as fallback\r
+            // take first account as fallback\r
             defaultAccount = ocAccounts[0];\r
         }\r
 \r