Merge pull request #740 from owncloud/revert-669-master
[pub/Android/ownCloud.git] / src / com / owncloud / android / authentication / AccountUtils.java
index 5f0441c..dc02344 100644 (file)
 \r
 package com.owncloud.android.authentication;\r
 \r
+import java.util.Locale;\r
+\r
 import com.owncloud.android.MainApp;\r
-import com.owncloud.android.lib.accounts.AccountTypeUtils;\r
-import com.owncloud.android.lib.utils.OwnCloudVersion;\r
+import com.owncloud.android.lib.common.accounts.AccountTypeUtils;\r
+import com.owncloud.android.lib.resources.status.OwnCloudVersion;\r
 \r
 import android.accounts.Account;\r
 import android.accounts.AccountManager;\r
@@ -81,8 +83,18 @@ public class AccountUtils {
                 MainApp.getAccountType());\r
 \r
         if (account != null && account.name != null) {\r
-            for (Account ac : ocAccounts) {\r
-                if (ac.name.equals(account.name)) {\r
+            int lastAtPos = account.name.lastIndexOf("@");\r
+            String hostAndPort = account.name.substring(lastAtPos + 1);\r
+            String username = account.name.substring(0, lastAtPos);\r
+            String otherHostAndPort, otherUsername;\r
+            Locale currentLocale = context.getResources().getConfiguration().locale;\r
+            for (Account otherAccount : ocAccounts) {\r
+                lastAtPos = otherAccount.name.lastIndexOf("@");\r
+                otherHostAndPort = otherAccount.name.substring(lastAtPos + 1);\r
+                otherUsername = otherAccount.name.substring(0, lastAtPos);\r
+                if (otherHostAndPort.equals(hostAndPort) &&\r
+                        otherUsername.toLowerCase(currentLocale).\r
+                            equals(username.toLowerCase(currentLocale))) {\r
                     return true;\r
                 }\r
             }\r