Removed more code and string about unused location tracking
[pub/Android/ownCloud.git] / src / com / owncloud / android / authentication / AccountAuthenticator.java
index 2a43dab..c9da67b 100644 (file)
@@ -26,8 +26,11 @@ import android.os.Handler;
 import android.widget.Toast;
 
 import com.owncloud.android.Log_OC;
 import android.widget.Toast;
 
 import com.owncloud.android.Log_OC;
+import com.owncloud.android.MainApp;
+
 import com.owncloud.android.R;
 
 import com.owncloud.android.R;
 
+
 /**
  *  Authenticator for ownCloud accounts.
  * 
 /**
  *  Authenticator for ownCloud accounts.
  * 
@@ -44,14 +47,15 @@ public class AccountAuthenticator extends AbstractAccountAuthenticator {
      * Is used by android system to assign accounts to authenticators. Should be
      * used by application and all extensions.
      */
      * Is used by android system to assign accounts to authenticators. Should be
      * used by application and all extensions.
      */
-    public static final String ACCOUNT_TYPE = "owncloud";
-    public static final String AUTHORITY = "org.owncloud";
-    public static final String AUTH_TOKEN_TYPE = "org.owncloud";
-    public static final String AUTH_TOKEN_TYPE_PASSWORD = "owncloud.password";
-    public static final String AUTH_TOKEN_TYPE_ACCESS_TOKEN = "owncloud.oauth2.access_token";
-    public static final String AUTH_TOKEN_TYPE_REFRESH_TOKEN = "owncloud.oauth2.refresh_token";
-    public static final String AUTH_TOKEN_TYPE_SAML_WEB_SSO_SESSION_COOKIE = "owncloud.saml.web_sso.session_cookie";
-
+    /* These constants are now in MainApp
+         public static final String ACCOUNT_TYPE = "owncloud";
+         public static final String AUTHORITY = "org.owncloud";
+         public static final String AUTH_TOKEN_TYPE = "org.owncloud";
+         public static final String AUTH_TOKEN_TYPE_PASSWORD = "owncloud.password";
+         public static final String AUTH_TOKEN_TYPE_ACCESS_TOKEN = "owncloud.oauth2.access_token";
+         public static final String AUTH_TOKEN_TYPE_REFRESH_TOKEN = "owncloud.oauth2.refresh_token";
+         public static final String AUTH_TOKEN_TYPE_SAML_WEB_SSO_SESSION_COOKIE = "owncloud.saml.web_sso.session_cookie";
+    */
     public static final String KEY_AUTH_TOKEN_TYPE = "authTokenType";
     public static final String KEY_REQUIRED_FEATURES = "requiredFeatures";
     public static final String KEY_LOGIN_OPTIONS = "loginOptions";
     public static final String KEY_AUTH_TOKEN_TYPE = "authTokenType";
     public static final String KEY_REQUIRED_FEATURES = "requiredFeatures";
     public static final String KEY_LOGIN_OPTIONS = "loginOptions";
@@ -111,7 +115,7 @@ public class AccountAuthenticator extends AbstractAccountAuthenticator {
         final Bundle bundle = new Bundle();
         
         AccountManager accountManager = AccountManager.get(mContext);
         final Bundle bundle = new Bundle();
         
         AccountManager accountManager = AccountManager.get(mContext);
-        Account[] accounts = accountManager.getAccountsByType(ACCOUNT_TYPE);
+        Account[] accounts = accountManager.getAccountsByType(MainApp.getAccountType());
         
         if (mContext.getResources().getBoolean(R.bool.multiaccount_support) || accounts.length < 1) {
             try {
         
         if (mContext.getResources().getBoolean(R.bool.multiaccount_support) || accounts.length < 1) {
             try {
@@ -207,7 +211,7 @@ public class AccountAuthenticator extends AbstractAccountAuthenticator {
         /// check if required token is stored
         final AccountManager am = AccountManager.get(mContext);
         String accessToken;
         /// check if required token is stored
         final AccountManager am = AccountManager.get(mContext);
         String accessToken;
-        if (authTokenType.equals(AUTH_TOKEN_TYPE_PASSWORD)) {
+        if (authTokenType.equals(MainApp.getAuthTokenTypePass())) {
             accessToken = am.getPassword(account);
         } else {
             accessToken = am.peekAuthToken(account, authTokenType);
             accessToken = am.getPassword(account);
         } else {
             accessToken = am.peekAuthToken(account, authTokenType);
@@ -215,7 +219,7 @@ public class AccountAuthenticator extends AbstractAccountAuthenticator {
         if (accessToken != null) {
             final Bundle result = new Bundle();
             result.putString(AccountManager.KEY_ACCOUNT_NAME, account.name);
         if (accessToken != null) {
             final Bundle result = new Bundle();
             result.putString(AccountManager.KEY_ACCOUNT_NAME, account.name);
-            result.putString(AccountManager.KEY_ACCOUNT_TYPE, ACCOUNT_TYPE);
+            result.putString(AccountManager.KEY_ACCOUNT_TYPE, MainApp.getAccountType());
             result.putString(AccountManager.KEY_AUTHTOKEN, accessToken);
             return result;
         }
             result.putString(AccountManager.KEY_AUTHTOKEN, accessToken);
             return result;
         }
@@ -280,18 +284,18 @@ public class AccountAuthenticator extends AbstractAccountAuthenticator {
 
     private void validateAccountType(String type)
             throws UnsupportedAccountTypeException {
 
     private void validateAccountType(String type)
             throws UnsupportedAccountTypeException {
-        if (!type.equals(ACCOUNT_TYPE)) {
+        if (!type.equals(MainApp.getAccountType())) {
             throw new UnsupportedAccountTypeException();
         }
     }
 
     private void validateAuthTokenType(String authTokenType)\r
             throws UnsupportedAuthTokenTypeException {\r
             throw new UnsupportedAccountTypeException();
         }
     }
 
     private void validateAuthTokenType(String authTokenType)\r
             throws UnsupportedAuthTokenTypeException {\r
-        if (!authTokenType.equals(AUTH_TOKEN_TYPE) &&\r
-            !authTokenType.equals(AUTH_TOKEN_TYPE_PASSWORD) &&\r
-            !authTokenType.equals(AUTH_TOKEN_TYPE_ACCESS_TOKEN) &&\r
-            !authTokenType.equals(AUTH_TOKEN_TYPE_REFRESH_TOKEN) &&
-            !authTokenType.equals(AUTH_TOKEN_TYPE_SAML_WEB_SSO_SESSION_COOKIE)) {\r
+        if (!authTokenType.equals(MainApp.getAuthTokenType()) &&\r
+            !authTokenType.equals(MainApp.getAuthTokenTypePass()) &&\r
+            !authTokenType.equals(MainApp.getAuthTokenTypeAccessToken()) &&\r
+            !authTokenType.equals(MainApp.getAuthTokenTypeRefreshToken()) &&
+            !authTokenType.equals(MainApp.getAuthTokenTypeSamlSessionCookie())) {\r
             throw new UnsupportedAuthTokenTypeException();\r
         }\r
     }\r
             throw new UnsupportedAuthTokenTypeException();\r
         }\r
     }\r