Merge branch 'develop' into refactor_remote_operation_to_create_folder
[pub/Android/ownCloud.git] / src / com / owncloud / android / authentication / AuthenticatorActivity.java
index 53f18bb..6928d41 100644 (file)
@@ -49,27 +49,27 @@ import android.widget.CheckBox;
 import android.widget.EditText;\r
 import android.widget.TextView;\r
 import android.widget.TextView.OnEditorActionListener;\r
 import android.widget.EditText;\r
 import android.widget.TextView;\r
 import android.widget.TextView.OnEditorActionListener;\r
-import android.widget.Toast;\r
 \r
 import com.actionbarsherlock.app.SherlockDialogFragment;\r
 \r
 import com.actionbarsherlock.app.SherlockDialogFragment;\r
-import com.owncloud.android.Log_OC;\r
 import com.owncloud.android.MainApp;\r
 import com.owncloud.android.R;\r
 import com.owncloud.android.authentication.SsoWebViewClient.SsoWebViewClientListener;\r
 import com.owncloud.android.MainApp;\r
 import com.owncloud.android.R;\r
 import com.owncloud.android.authentication.SsoWebViewClient.SsoWebViewClientListener;\r
-import com.owncloud.android.network.OwnCloudClientUtils;\r
+import com.owncloud.android.oc_framework.accounts.AccountTypeUtils;\r
+import com.owncloud.android.oc_framework.accounts.OwnCloudAccount;\r
+import com.owncloud.android.oc_framework.network.webdav.OwnCloudClientFactory;\r
+import com.owncloud.android.oc_framework.network.webdav.WebdavClient;\r
 import com.owncloud.android.operations.ExistenceCheckOperation;\r
 import com.owncloud.android.operations.OAuth2GetAccessToken;\r
 import com.owncloud.android.operations.ExistenceCheckOperation;\r
 import com.owncloud.android.operations.OAuth2GetAccessToken;\r
-import com.owncloud.android.operations.OnRemoteOperationListener;\r
+import com.owncloud.android.oc_framework.operations.OnRemoteOperationListener;\r
 import com.owncloud.android.operations.OwnCloudServerCheckOperation;\r
 import com.owncloud.android.operations.OwnCloudServerCheckOperation;\r
-import com.owncloud.android.operations.RemoteOperation;\r
-import com.owncloud.android.operations.RemoteOperationResult;\r
-import com.owncloud.android.operations.RemoteOperationResult.ResultCode;\r
+import com.owncloud.android.oc_framework.operations.RemoteOperation;\r
+import com.owncloud.android.oc_framework.operations.RemoteOperationResult;\r
+import com.owncloud.android.oc_framework.operations.RemoteOperationResult.ResultCode;\r
 import com.owncloud.android.ui.dialog.SamlWebViewDialog;\r
 import com.owncloud.android.ui.dialog.SslValidatorDialog;\r
 import com.owncloud.android.ui.dialog.SslValidatorDialog.OnSslValidatorListener;\r
 import com.owncloud.android.ui.dialog.SamlWebViewDialog;\r
 import com.owncloud.android.ui.dialog.SslValidatorDialog;\r
 import com.owncloud.android.ui.dialog.SslValidatorDialog.OnSslValidatorListener;\r
-import com.owncloud.android.utils.OwnCloudVersion;\r
-\r
-import eu.alefzero.webdav.WebdavClient;\r
+import com.owncloud.android.utils.Log_OC;\r
+import com.owncloud.android.oc_framework.utils.OwnCloudVersion;\r
 \r
 /**\r
  * This Activity is used to add an ownCloud account to the App\r
 \r
 /**\r
  * This Activity is used to add an ownCloud account to the App\r
@@ -193,11 +193,16 @@ implements  OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList
         /// set Host Url Input Enabled\r
         mHostUrlInputEnabled = getResources().getBoolean(R.bool.show_server_url_input);\r
         \r
         /// set Host Url Input Enabled\r
         mHostUrlInputEnabled = getResources().getBoolean(R.bool.show_server_url_input);\r
         \r
-\r
-        /// complete label for 'register account' button\r
-        Button b = (Button) findViewById(R.id.account_register);\r
-        if (b != null) {\r
-            b.setText(String.format(getString(R.string.auth_register), getString(R.string.app_name)));\r
+        /// set visibility of link for new users\r
+        boolean accountRegisterVisibility = getResources().getBoolean(R.bool.show_welcome_link);\r
+        Button welcomeLink = (Button) findViewById(R.id.welcome_link);\r
+        if (welcomeLink != null) {\r
+            if (accountRegisterVisibility) {\r
+                welcomeLink.setVisibility(View.VISIBLE);\r
+                welcomeLink.setText(String.format(getString(R.string.auth_register), getString(R.string.app_name)));            \r
+            } else {\r
+                findViewById(R.id.welcome_link).setVisibility(View.GONE);\r
+            }\r
         }\r
 \r
         /// initialization\r
         }\r
 \r
         /// initialization\r
@@ -231,11 +236,11 @@ implements  OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList
             /// retrieve extras from intent\r
             mAccount = getIntent().getExtras().getParcelable(EXTRA_ACCOUNT);\r
             if (mAccount != null) {\r
             /// retrieve extras from intent\r
             mAccount = getIntent().getExtras().getParcelable(EXTRA_ACCOUNT);\r
             if (mAccount != null) {\r
-                String ocVersion = mAccountMgr.getUserData(mAccount, AccountAuthenticator.KEY_OC_VERSION);\r
+                String ocVersion = mAccountMgr.getUserData(mAccount, OwnCloudAccount.Constants.KEY_OC_VERSION);\r
                 if (ocVersion != null) {\r
                     mDiscoveredVersion = new OwnCloudVersion(ocVersion);\r
                 }\r
                 if (ocVersion != null) {\r
                     mDiscoveredVersion = new OwnCloudVersion(ocVersion);\r
                 }\r
-                mHostBaseUrl = normalizeUrl(mAccountMgr.getUserData(mAccount, AccountAuthenticator.KEY_OC_BASE_URL));\r
+                mHostBaseUrl = normalizeUrl(mAccountMgr.getUserData(mAccount, OwnCloudAccount.Constants.KEY_OC_BASE_URL));\r
                 mHostUrlInput.setText(mHostBaseUrl);\r
                 String userName = mAccount.name.substring(0, mAccount.name.lastIndexOf('@'));\r
                 mUsernameInput.setText(userName);\r
                 mHostUrlInput.setText(mHostBaseUrl);\r
                 String userName = mAccount.name.substring(0, mAccount.name.lastIndexOf('@'));\r
                 mUsernameInput.setText(userName);\r
@@ -274,7 +279,7 @@ implements  OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList
             mAccount = savedInstanceState.getParcelable(KEY_ACCOUNT);\r
             mAuthTokenType = savedInstanceState.getString(AccountAuthenticator.KEY_AUTH_TOKEN_TYPE);\r
             if (mAuthTokenType == null) {\r
             mAccount = savedInstanceState.getParcelable(KEY_ACCOUNT);\r
             mAuthTokenType = savedInstanceState.getString(AccountAuthenticator.KEY_AUTH_TOKEN_TYPE);\r
             if (mAuthTokenType == null) {\r
-                mAuthTokenType =  MainApp.getAuthTokenTypePass();\r
+                mAuthTokenType =  AccountTypeUtils.getAuthTokenTypePass(MainApp.getAccountType());\r
                 \r
             }\r
 \r
                 \r
             }\r
 \r
@@ -312,7 +317,7 @@ implements  OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList
         if (mServerIsChecked && !mServerIsValid && refreshButtonEnabled) showRefreshButton();\r
         mOkButton.setEnabled(mServerIsValid); // state not automatically recovered in configuration changes\r
 \r
         if (mServerIsChecked && !mServerIsValid && refreshButtonEnabled) showRefreshButton();\r
         mOkButton.setEnabled(mServerIsValid); // state not automatically recovered in configuration changes\r
 \r
-        if (MainApp.getAuthTokenTypeSamlSessionCookie().equals(mAuthTokenType) || \r
+        if (AccountTypeUtils.getAuthTokenTypeSamlSessionCookie(MainApp.getAccountType()).equals(mAuthTokenType) || \r
                 !AUTH_OPTIONAL.equals(getString(R.string.auth_method_oauth2))) {\r
             mOAuth2Check.setVisibility(View.GONE);\r
         }\r
                 !AUTH_OPTIONAL.equals(getString(R.string.auth_method_oauth2))) {\r
             mOAuth2Check.setVisibility(View.GONE);\r
         }\r
@@ -364,7 +369,7 @@ implements  OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList
             @Override\r
             public boolean onTouch(View view, MotionEvent event) {\r
                 if (event.getAction() == MotionEvent.ACTION_DOWN) {\r
             @Override\r
             public boolean onTouch(View view, MotionEvent event) {\r
                 if (event.getAction() == MotionEvent.ACTION_DOWN) {\r
-                    if (MainApp.getAuthTokenTypeSamlSessionCookie().equals(mAuthTokenType) &&\r
+                    if (AccountTypeUtils.getAuthTokenTypeSamlSessionCookie(MainApp.getAccountType()).equals(mAuthTokenType) &&\r
                             mHostUrlInput.hasFocus()) {\r
                         checkOcServer();\r
                     }\r
                             mHostUrlInput.hasFocus()) {\r
                         checkOcServer();\r
                     }\r
@@ -388,8 +393,8 @@ implements  OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList
         if (mAuthTokenType == null) {    \r
             if (mAccount != null) {\r
                 /// same authentication method than the one used to create the account to update\r
         if (mAuthTokenType == null) {    \r
             if (mAccount != null) {\r
                 /// same authentication method than the one used to create the account to update\r
-                oAuthRequired = (mAccountMgr.getUserData(mAccount, AccountAuthenticator.KEY_SUPPORTS_OAUTH2) != null);\r
-                samlWebSsoRequired = (mAccountMgr.getUserData(mAccount, AccountAuthenticator.KEY_SUPPORTS_SAML_WEB_SSO) != null);\r
+                oAuthRequired = (mAccountMgr.getUserData(mAccount, OwnCloudAccount.Constants.KEY_SUPPORTS_OAUTH2) != null);\r
+                samlWebSsoRequired = (mAccountMgr.getUserData(mAccount, OwnCloudAccount.Constants.KEY_SUPPORTS_SAML_WEB_SSO) != null);\r
             \r
             } else {\r
                 /// use the one set in setup.xml\r
             \r
             } else {\r
                 /// use the one set in setup.xml\r
@@ -397,11 +402,11 @@ implements  OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList
                 samlWebSsoRequired = AUTH_ON.equals(getString(R.string.auth_method_saml_web_sso));            \r
             }\r
             if (oAuthRequired) {\r
                 samlWebSsoRequired = AUTH_ON.equals(getString(R.string.auth_method_saml_web_sso));            \r
             }\r
             if (oAuthRequired) {\r
-                mAuthTokenType = MainApp.getAuthTokenTypeAccessToken();\r
+                mAuthTokenType = AccountTypeUtils.getAuthTokenTypeAccessToken(MainApp.getAccountType());\r
             } else if (samlWebSsoRequired) {\r
             } else if (samlWebSsoRequired) {\r
-                mAuthTokenType = MainApp.getAuthTokenTypeSamlSessionCookie();\r
+                mAuthTokenType = AccountTypeUtils.getAuthTokenTypeSamlSessionCookie(MainApp.getAccountType());\r
             } else {\r
             } else {\r
-                mAuthTokenType = MainApp.getAuthTokenTypePass();\r
+                mAuthTokenType = AccountTypeUtils.getAuthTokenTypePass(MainApp.getAccountType());\r
             }\r
         }\r
     \r
             }\r
         }\r
     \r
@@ -410,7 +415,7 @@ implements  OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList
             mUsernameInput.setText(userName);\r
         }\r
         \r
             mUsernameInput.setText(userName);\r
         }\r
         \r
-        mOAuth2Check.setChecked(MainApp.getAuthTokenTypeAccessToken().equals(mAuthTokenType));\r
+        mOAuth2Check.setChecked(AccountTypeUtils.getAuthTokenTypeAccessToken(MainApp.getAccountType()).equals(mAuthTokenType));\r
         \r
     }\r
 \r
         \r
     }\r
 \r
@@ -483,10 +488,10 @@ implements  OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList
     protected void onResume() {\r
         super.onResume();\r
         if (mAction == ACTION_UPDATE_TOKEN && mJustCreated && getIntent().getBooleanExtra(EXTRA_ENFORCED_UPDATE, false)) {\r
     protected void onResume() {\r
         super.onResume();\r
         if (mAction == ACTION_UPDATE_TOKEN && mJustCreated && getIntent().getBooleanExtra(EXTRA_ENFORCED_UPDATE, false)) {\r
-            if (MainApp.getAuthTokenTypeAccessToken().equals(mAuthTokenType)) {\r
+            if (AccountTypeUtils.getAuthTokenTypeAccessToken(MainApp.getAccountType()).equals(mAuthTokenType)) {\r
                 //Toast.makeText(this, R.string.auth_expired_oauth_token_toast, Toast.LENGTH_LONG).show();\r
                 showAuthMessage(getString(R.string.auth_expired_oauth_token_toast));\r
                 //Toast.makeText(this, R.string.auth_expired_oauth_token_toast, Toast.LENGTH_LONG).show();\r
                 showAuthMessage(getString(R.string.auth_expired_oauth_token_toast));\r
-            } else if (MainApp.getAuthTokenTypeSamlSessionCookie().equals(mAuthTokenType)) {\r
+            } else if (AccountTypeUtils.getAuthTokenTypeSamlSessionCookie(MainApp.getAccountType()).equals(mAuthTokenType)) {\r
                 //Toast.makeText(this, R.string.auth_expired_saml_sso_token_toast, Toast.LENGTH_LONG).show();\r
                 showAuthMessage(getString(R.string.auth_expired_saml_sso_token_toast));\r
             } else {\r
                 //Toast.makeText(this, R.string.auth_expired_saml_sso_token_toast, Toast.LENGTH_LONG).show();\r
                 showAuthMessage(getString(R.string.auth_expired_saml_sso_token_toast));\r
             } else {\r
@@ -522,7 +527,7 @@ implements  OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList
                 getString(R.string.oauth2_grant_type),\r
                 queryParameters);\r
         //WebdavClient client = OwnCloudClientUtils.createOwnCloudClient(Uri.parse(getString(R.string.oauth2_url_endpoint_access)), getApplicationContext());\r
                 getString(R.string.oauth2_grant_type),\r
                 queryParameters);\r
         //WebdavClient client = OwnCloudClientUtils.createOwnCloudClient(Uri.parse(getString(R.string.oauth2_url_endpoint_access)), getApplicationContext());\r
-        WebdavClient client = OwnCloudClientUtils.createOwnCloudClient(Uri.parse(mOAuthTokenEndpointText.getText().toString().trim()), getApplicationContext(), true);\r
+        WebdavClient client = OwnCloudClientFactory.createOwnCloudClient(Uri.parse(mOAuthTokenEndpointText.getText().toString().trim()), getApplicationContext(), true);\r
         operation.execute(client, this, mHandler);\r
     }\r
 \r
         operation.execute(client, this, mHandler);\r
     }\r
 \r
@@ -586,7 +591,7 @@ implements  OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList
             mServerStatusIcon = R.drawable.progress_small;\r
             showServerStatus();\r
             mOcServerChkOperation = new  OwnCloudServerCheckOperation(uri, this);\r
             mServerStatusIcon = R.drawable.progress_small;\r
             showServerStatus();\r
             mOcServerChkOperation = new  OwnCloudServerCheckOperation(uri, this);\r
-            WebdavClient client = OwnCloudClientUtils.createOwnCloudClient(Uri.parse(uri), this, true);\r
+            WebdavClient client = OwnCloudClientFactory.createOwnCloudClient(Uri.parse(uri), this, true);\r
             mOperationThread = mOcServerChkOperation.execute(client, this, mHandler);\r
         } else {\r
             mServerStatusText = 0;\r
             mOperationThread = mOcServerChkOperation.execute(client, this, mHandler);\r
         } else {\r
             mServerStatusText = 0;\r
@@ -686,9 +691,9 @@ implements  OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList
             return;\r
         }\r
 \r
             return;\r
         }\r
 \r
-        if (MainApp.getAuthTokenTypeAccessToken().equals(mAuthTokenType)) {\r
+        if (AccountTypeUtils.getAuthTokenTypeAccessToken(MainApp.getAccountType()).equals(mAuthTokenType)) {\r
             startOauthorization();\r
             startOauthorization();\r
-        } else if (MainApp.getAuthTokenTypeSamlSessionCookie().equals(mAuthTokenType)) { \r
+        } else if (AccountTypeUtils.getAuthTokenTypeSamlSessionCookie(MainApp.getAccountType()).equals(mAuthTokenType)) { \r
             startSamlBasedFederatedSingleSignOnAuthorization();\r
         } else {\r
             checkBasicAuthorization();\r
             startSamlBasedFederatedSingleSignOnAuthorization();\r
         } else {\r
             checkBasicAuthorization();\r
@@ -713,7 +718,7 @@ implements  OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList
 \r
         /// test credentials accessing the root folder\r
         mAuthCheckOperation = new  ExistenceCheckOperation("", this, false);\r
 \r
         /// test credentials accessing the root folder\r
         mAuthCheckOperation = new  ExistenceCheckOperation("", this, false);\r
-        WebdavClient client = OwnCloudClientUtils.createOwnCloudClient(Uri.parse(mHostBaseUrl + webdav_path), this, true);\r
+        WebdavClient client = OwnCloudClientFactory.createOwnCloudClient(Uri.parse(mHostBaseUrl + webdav_path), this, true);\r
         client.setBasicCredentials(username, password);\r
         mOperationThread = mAuthCheckOperation.execute(client, this, mHandler);\r
     }\r
         client.setBasicCredentials(username, password);\r
         mOperationThread = mAuthCheckOperation.execute(client, this, mHandler);\r
     }\r
@@ -762,7 +767,7 @@ implements  OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList
 \r
         /// test credentials accessing the root folder\r
         mAuthCheckOperation = new  ExistenceCheckOperation("", this, false);\r
 \r
         /// test credentials accessing the root folder\r
         mAuthCheckOperation = new  ExistenceCheckOperation("", this, false);\r
-        WebdavClient client = OwnCloudClientUtils.createOwnCloudClient(Uri.parse(mHostBaseUrl + webdav_path), this, false);\r
+        WebdavClient client = OwnCloudClientFactory.createOwnCloudClient(Uri.parse(mHostBaseUrl + webdav_path), this, false);\r
         mOperationThread = mAuthCheckOperation.execute(client, this, mHandler);\r
       \r
     }\r
         mOperationThread = mAuthCheckOperation.execute(client, this, mHandler);\r
       \r
     }\r
@@ -782,7 +787,7 @@ implements  OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList
             onGetOAuthAccessTokenFinish((OAuth2GetAccessToken)operation, result);\r
 \r
         } else if (operation instanceof ExistenceCheckOperation)  {\r
             onGetOAuthAccessTokenFinish((OAuth2GetAccessToken)operation, result);\r
 \r
         } else if (operation instanceof ExistenceCheckOperation)  {\r
-            if (MainApp.getAuthTokenTypeSamlSessionCookie().equals(mAuthTokenType)) {\r
+            if (AccountTypeUtils.getAuthTokenTypeSamlSessionCookie(MainApp.getAccountType()).equals(mAuthTokenType)) {\r
                 onSamlBasedFederatedSingleSignOnAuthorizationStart(operation, result);\r
                 \r
             } else {\r
                 onSamlBasedFederatedSingleSignOnAuthorizationStart(operation, result);\r
                 \r
             } else {\r
@@ -1081,7 +1086,7 @@ implements  OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList
             mAuthToken = ((OAuth2GetAccessToken)operation).getResultTokenMap().get(OAuth2Constants.KEY_ACCESS_TOKEN);\r
             Log_OC.d(TAG, "Got ACCESS TOKEN: " + mAuthToken);\r
             mAuthCheckOperation = new ExistenceCheckOperation("", this, false);\r
             mAuthToken = ((OAuth2GetAccessToken)operation).getResultTokenMap().get(OAuth2Constants.KEY_ACCESS_TOKEN);\r
             Log_OC.d(TAG, "Got ACCESS TOKEN: " + mAuthToken);\r
             mAuthCheckOperation = new ExistenceCheckOperation("", this, false);\r
-            WebdavClient client = OwnCloudClientUtils.createOwnCloudClient(Uri.parse(mHostBaseUrl + webdav_path), this, true);\r
+            WebdavClient client = OwnCloudClientFactory.createOwnCloudClient(Uri.parse(mHostBaseUrl + webdav_path), this, true);\r
             client.setBearerCredentials(mAuthToken);\r
             mAuthCheckOperation.execute(client, this, mHandler);\r
 \r
             client.setBearerCredentials(mAuthToken);\r
             mAuthCheckOperation.execute(client, this, mHandler);\r
 \r
@@ -1167,12 +1172,12 @@ implements  OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList
         response.putString(AccountManager.KEY_ACCOUNT_NAME, mAccount.name);\r
         response.putString(AccountManager.KEY_ACCOUNT_TYPE, mAccount.type);\r
         \r
         response.putString(AccountManager.KEY_ACCOUNT_NAME, mAccount.name);\r
         response.putString(AccountManager.KEY_ACCOUNT_TYPE, mAccount.type);\r
         \r
-        if (MainApp.getAuthTokenTypeAccessToken().equals(mAuthTokenType)) { \r
+        if (AccountTypeUtils.getAuthTokenTypeAccessToken(MainApp.getAccountType()).equals(mAuthTokenType)) { \r
             response.putString(AccountManager.KEY_AUTHTOKEN, mAuthToken);\r
             // the next line is necessary; by now, notifications are calling directly to the AuthenticatorActivity to update, without AccountManager intervention\r
             mAccountMgr.setAuthToken(mAccount, mAuthTokenType, mAuthToken);\r
             \r
             response.putString(AccountManager.KEY_AUTHTOKEN, mAuthToken);\r
             // the next line is necessary; by now, notifications are calling directly to the AuthenticatorActivity to update, without AccountManager intervention\r
             mAccountMgr.setAuthToken(mAccount, mAuthTokenType, mAuthToken);\r
             \r
-        } else if (MainApp.getAuthTokenTypeSamlSessionCookie().equals(mAuthTokenType)) {\r
+        } else if (AccountTypeUtils.getAuthTokenTypeSamlSessionCookie(MainApp.getAccountType()).equals(mAuthTokenType)) {\r
             String username = getUserNameForSamlSso();\r
             if (!mUsernameInput.getText().toString().equals(username)) {\r
                 // fail - not a new account, but an existing one; disallow\r
             String username = getUserNameForSamlSso();\r
             if (!mUsernameInput.getText().toString().equals(username)) {\r
                 // fail - not a new account, but an existing one; disallow\r
@@ -1207,8 +1212,8 @@ implements  OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList
      */\r
     private boolean createAccount() {\r
         /// create and save new ownCloud account\r
      */\r
     private boolean createAccount() {\r
         /// create and save new ownCloud account\r
-        boolean isOAuth = MainApp.getAuthTokenTypeAccessToken().equals(mAuthTokenType);\r
-        boolean isSaml =  MainApp.getAuthTokenTypeSamlSessionCookie().equals(mAuthTokenType);\r
+        boolean isOAuth = AccountTypeUtils.getAuthTokenTypeAccessToken(MainApp.getAccountType()).equals(mAuthTokenType);\r
+        boolean isSaml =  AccountTypeUtils.getAuthTokenTypeSamlSessionCookie(MainApp.getAccountType()).equals(mAuthTokenType);\r
 \r
         Uri uri = Uri.parse(mHostBaseUrl);\r
         String username = mUsernameInput.getText().toString().trim();\r
 \r
         Uri uri = Uri.parse(mHostBaseUrl);\r
         String username = mUsernameInput.getText().toString().trim();\r
@@ -1260,25 +1265,17 @@ implements  OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList
                 mAccountMgr.setAuthToken(mAccount, mAuthTokenType, mAuthToken);\r
             }\r
             /// add user data to the new account; TODO probably can be done in the last parameter addAccountExplicitly, or in KEY_USERDATA\r
                 mAccountMgr.setAuthToken(mAccount, mAuthTokenType, mAuthToken);\r
             }\r
             /// add user data to the new account; TODO probably can be done in the last parameter addAccountExplicitly, or in KEY_USERDATA\r
-            mAccountMgr.setUserData(mAccount, AccountAuthenticator.KEY_OC_VERSION,    mDiscoveredVersion.toString());\r
-            mAccountMgr.setUserData(mAccount, AccountAuthenticator.KEY_OC_BASE_URL,   mHostBaseUrl);\r
+            mAccountMgr.setUserData(mAccount, OwnCloudAccount.Constants.KEY_OC_VERSION,    mDiscoveredVersion.toString());\r
+            mAccountMgr.setUserData(mAccount, OwnCloudAccount.Constants.KEY_OC_BASE_URL,   mHostBaseUrl);\r
             if (isSaml) {\r
             if (isSaml) {\r
-                mAccountMgr.setUserData(mAccount, AccountAuthenticator.KEY_SUPPORTS_SAML_WEB_SSO, "TRUE"); \r
+                mAccountMgr.setUserData(mAccount, OwnCloudAccount.Constants.KEY_SUPPORTS_SAML_WEB_SSO, "TRUE"); \r
             } else if (isOAuth) {\r
             } else if (isOAuth) {\r
-                mAccountMgr.setUserData(mAccount, AccountAuthenticator.KEY_SUPPORTS_OAUTH2, "TRUE");  \r
+                mAccountMgr.setUserData(mAccount, OwnCloudAccount.Constants.KEY_SUPPORTS_OAUTH2, "TRUE");  \r
             }\r
     \r
             setAccountAuthenticatorResult(intent.getExtras());\r
             setResult(RESULT_OK, intent);\r
     \r
             }\r
     \r
             setAccountAuthenticatorResult(intent.getExtras());\r
             setResult(RESULT_OK, intent);\r
     \r
-            /// immediately request for the synchronization of the new account\r
-            Bundle bundle = new Bundle();\r
-            bundle.putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, true);\r
-            ContentResolver.requestSync(mAccount, MainApp.getAuthTokenType(), bundle);\r
-            syncAccount();\r
-//          Bundle bundle = new Bundle();\r
-//          bundle.putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, true);\r
-//          ContentResolver.requestSync(mAccount, MainApp.getAuthTokenType(), bundle);\r
             return true;\r
         }\r
     }\r
             return true;\r
         }\r
     }\r
@@ -1397,7 +1394,7 @@ implements  OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList
      * @param view      'Account register' button\r
      */\r
     public void onRegisterClick(View view) {\r
      * @param view      'Account register' button\r
      */\r
     public void onRegisterClick(View view) {\r
-        Intent register = new Intent(Intent.ACTION_VIEW, Uri.parse(getString(R.string.url_account_register)));\r
+        Intent register = new Intent(Intent.ACTION_VIEW, Uri.parse(getString(R.string.welcome_link_url)));\r
         setResult(RESULT_CANCELED);\r
         startActivity(register);\r
     }\r
         setResult(RESULT_CANCELED);\r
         startActivity(register);\r
     }\r
@@ -1485,9 +1482,9 @@ implements  OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList
     public void onCheckClick(View view) {\r
         CheckBox oAuth2Check = (CheckBox)view;\r
         if (oAuth2Check.isChecked()) {\r
     public void onCheckClick(View view) {\r
         CheckBox oAuth2Check = (CheckBox)view;\r
         if (oAuth2Check.isChecked()) {\r
-            mAuthTokenType = MainApp.getAuthTokenTypeAccessToken();\r
+            mAuthTokenType = AccountTypeUtils.getAuthTokenTypeAccessToken(MainApp.getAccountType());\r
         } else {\r
         } else {\r
-            mAuthTokenType = MainApp.getAuthTokenTypePass();\r
+            mAuthTokenType = AccountTypeUtils.getAuthTokenTypePass(MainApp.getAccountType());\r
         }\r
         adaptViewAccordingToAuthenticationMethod();\r
     }\r
         }\r
         adaptViewAccordingToAuthenticationMethod();\r
     }\r
@@ -1498,14 +1495,14 @@ implements  OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList
      * the current authorization method.\r
      */\r
     private void adaptViewAccordingToAuthenticationMethod () {\r
      * the current authorization method.\r
      */\r
     private void adaptViewAccordingToAuthenticationMethod () {\r
-        if (MainApp.getAuthTokenTypeAccessToken().equals(mAuthTokenType)) {\r
+        if (AccountTypeUtils.getAuthTokenTypeAccessToken(MainApp.getAccountType()).equals(mAuthTokenType)) {\r
             // OAuth 2 authorization\r
             mOAuthAuthEndpointText.setVisibility(View.VISIBLE);\r
             mOAuthTokenEndpointText.setVisibility(View.VISIBLE);\r
             mUsernameInput.setVisibility(View.GONE);\r
             mPasswordInput.setVisibility(View.GONE);\r
             \r
             // OAuth 2 authorization\r
             mOAuthAuthEndpointText.setVisibility(View.VISIBLE);\r
             mOAuthTokenEndpointText.setVisibility(View.VISIBLE);\r
             mUsernameInput.setVisibility(View.GONE);\r
             mPasswordInput.setVisibility(View.GONE);\r
             \r
-        } else if (MainApp.getAuthTokenTypeSamlSessionCookie().equals(mAuthTokenType)) {\r
+        } else if (AccountTypeUtils.getAuthTokenTypeSamlSessionCookie(MainApp.getAccountType()).equals(mAuthTokenType)) {\r
             // SAML-based web Single Sign On\r
             mOAuthAuthEndpointText.setVisibility(View.GONE);\r
             mOAuthTokenEndpointText.setVisibility(View.GONE);\r
             // SAML-based web Single Sign On\r
             mOAuthAuthEndpointText.setVisibility(View.GONE);\r
             mOAuthTokenEndpointText.setVisibility(View.GONE);\r
@@ -1551,7 +1548,7 @@ implements  OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList
             }\r
             \r
         } else if (actionId == EditorInfo.IME_ACTION_NEXT && inputField != null && inputField.equals(mHostUrlInput)) {\r
             }\r
             \r
         } else if (actionId == EditorInfo.IME_ACTION_NEXT && inputField != null && inputField.equals(mHostUrlInput)) {\r
-            if (MainApp.getAuthTokenTypeSamlSessionCookie().equals(mAuthTokenType)) {\r
+            if (AccountTypeUtils.getAuthTokenTypeSamlSessionCookie(MainApp.getAccountType()).equals(mAuthTokenType)) {\r
                 checkOcServer();\r
             }\r
         }\r
                 checkOcServer();\r
             }\r
         }\r
@@ -1648,16 +1645,9 @@ implements  OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList
         mAuthMessage.setVisibility(View.GONE);\r
     }\r
 \r
         mAuthMessage.setVisibility(View.GONE);\r
     }\r
 \r
-    private void syncAccount(){\r
-        /// immediately request for the synchronization of the new account\r
-        Bundle bundle = new Bundle();\r
-        bundle.putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, true);\r
-        ContentResolver.requestSync(mAccount, MainApp.getAuthTokenType(), bundle);\r
-    }\r
-    \r
     @Override\r
     public boolean onTouchEvent(MotionEvent event) {\r
     @Override\r
     public boolean onTouchEvent(MotionEvent event) {\r
-        if (MainApp.getAuthTokenTypeSamlSessionCookie().equals(mAuthTokenType) &&\r
+        if (AccountTypeUtils.getAuthTokenTypeSamlSessionCookie(MainApp.getAccountType()).equals(mAuthTokenType) &&\r
                 mHostUrlInput.hasFocus() && event.getAction() == MotionEvent.ACTION_DOWN) {\r
             checkOcServer();\r
         }\r
                 mHostUrlInput.hasFocus() && event.getAction() == MotionEvent.ACTION_DOWN) {\r
             checkOcServer();\r
         }\r