Merge branch 'setup_multiaccount' into setup_app_name
authormasensio <masensio@solidgear.es>
Fri, 18 Oct 2013 10:32:22 +0000 (12:32 +0200)
committermasensio <masensio@solidgear.es>
Fri, 18 Oct 2013 10:32:22 +0000 (12:32 +0200)
Conflicts:
res/values/setup.xml
src/com/owncloud/android/authentication/AccountAuthenticator.java

1  2 
res/values/setup.xml
res/values/strings.xml
src/com/owncloud/android/authentication/AccountAuthenticator.java
src/com/owncloud/android/authentication/AuthenticatorActivity.java
src/com/owncloud/android/ui/activity/AccountSelectActivity.java

diff --combined res/values/setup.xml
@@@ -1,15 -1,5 +1,15 @@@
  <?xml version="1.0" encoding="utf-8"?>
  <resources>
 +    <!-- App name  and other strings-->
 +    <string name="app_name">ownCloud</string>
 +    <string name="account_type">owncloud</string>
 +    <string name="authority">org.owncloud</string>
 +    <string name ="db_file">owncloud.db</string>
 +    <string name ="db_name">ownCloud</string>
 +    <string name ="data_folder"></string>
 +    <string name ="log_name">Owncloud_</string>
 +    
 +    <!-- Server URL -->
      <string name="server_url"></string>
      <bool name="show_server_url_input">true</bool>
      
@@@ -17,9 -7,7 +17,12 @@@
      <string name="auth_method_oauth2">off</string>
      <string name="auth_method_saml_web_sso">off</string>
      
 +    <!-- Colors -->
 +    <color name="background_color">#F7F7F7</color>
 +    <color name="actionbar_start_color">#1D2D44</color>
 +    <color name="actionbar_end_color">#1D2D44</color>
 +    
+     <!-- Multiaccount support -->
+     <bool name="multiaccount_support">true</bool>
+     
  </resources>
diff --combined res/values/strings.xml
@@@ -1,6 -1,7 +1,6 @@@
  <?xml version="1.0" encoding="utf-8"?>
  <resources>
  
 -    <string name="app_name">ownCloud</string>
      <string name="main_password">Password:</string>
      <string name="main_login">Username:</string>
      <string name="main_button_login">Login</string>
        <string name="auth_connecting_auth_server">Connecting to authentication server…</string>
        <string name="auth_follow_auth_server">Follow instructions above to get authenticated</string>
        <string name="auth_unsupported_auth_method">The server does not support this authentication method</string>    
+       <string name="auth_unsupported_multiaccount">This version of ownCloud doesn\'t support multiaccount</string>
      
      <string name="crashlog_message">Application terminated unexpectedly. Would you like to submit a crash report?</string>
      <string name="crashlog_send_report">Send report</string>
@@@ -22,9 -22,12 +22,15 @@@ import android.accounts.*
  import android.content.Context;
  import android.content.Intent;
  import android.os.Bundle;
+ import android.os.Handler;
+ import android.widget.Toast;
  import com.owncloud.android.Log_OC;
 +import com.owncloud.android.MainApp;
 +
+ import com.owncloud.android.R;
++
  /**
   *  Authenticator for ownCloud accounts.
   * 
@@@ -41,15 -44,14 +47,15 @@@ public class AccountAuthenticator exten
       * 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";
      private static final String TAG = AccountAuthenticator.class.getSimpleName();
      
      private Context mContext;
+     
+     private Handler mHandler;
  
      public AccountAuthenticator(Context context) {
          super(context);
          mContext = context;
+         mHandler = new Handler();
      }
  
      /**
              throws NetworkErrorException {
          Log_OC.i(TAG, "Adding account with type " + accountType
                  + " and auth token " + authTokenType);
-         try {
-             validateAccountType(accountType);
-         } catch (AuthenticatorException e) {
-             Log_OC.e(TAG, "Failed to validate account type " + accountType + ": "
-                     + e.getMessage());
-             e.printStackTrace();
-             return e.getFailureBundle();
-         }
-         final Intent intent = new Intent(mContext, AuthenticatorActivity.class);
-         intent.putExtra(AccountManager.KEY_ACCOUNT_AUTHENTICATOR_RESPONSE, response);
-         intent.putExtra(KEY_AUTH_TOKEN_TYPE, authTokenType);
-         intent.putExtra(KEY_REQUIRED_FEATURES, requiredFeatures);
-         intent.putExtra(KEY_LOGIN_OPTIONS, options);
-         intent.putExtra(AuthenticatorActivity.EXTRA_ACTION, AuthenticatorActivity.ACTION_CREATE);
-         setIntentFlags(intent);
          
          final Bundle bundle = new Bundle();
-         bundle.putParcelable(AccountManager.KEY_INTENT, intent);
+         
+         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 {
+                 validateAccountType(accountType);
+             } catch (AuthenticatorException e) {
+                 Log_OC.e(TAG, "Failed to validate account type " + accountType + ": "
+                         + e.getMessage());
+                 e.printStackTrace();
+                 return e.getFailureBundle();
+             }
+             
+             final Intent intent = new Intent(mContext, AuthenticatorActivity.class);
+             intent.putExtra(AccountManager.KEY_ACCOUNT_AUTHENTICATOR_RESPONSE, response);
+             intent.putExtra(KEY_AUTH_TOKEN_TYPE, authTokenType);
+             intent.putExtra(KEY_REQUIRED_FEATURES, requiredFeatures);
+             intent.putExtra(KEY_LOGIN_OPTIONS, options);
+             intent.putExtra(AuthenticatorActivity.EXTRA_ACTION, AuthenticatorActivity.ACTION_CREATE);
+             setIntentFlags(intent);
+             
+             bundle.putParcelable(AccountManager.KEY_INTENT, intent);
+         
+         } else {
+             // Return an error
+             bundle.putInt(AccountManager.KEY_ERROR_CODE, AccountManager.ERROR_CODE_UNSUPPORTED_OPERATION);
+             bundle.putString(AccountManager.KEY_ERROR_MESSAGE, mContext.getString(R.string.auth_unsupported_multiaccount));
+            
+             mHandler.post(new Runnable() {
+                 @Override
+                 public void run() {
+                     Toast.makeText(mContext, R.string.auth_unsupported_multiaccount, Toast.LENGTH_SHORT).show();
+                 }
+             });
+             
+         }
+         
          return bundle;
      }
  
          /// 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);
          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;
          }
  
      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
 -        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
@@@ -49,10 -49,10 +49,11 @@@ import android.widget.CheckBox
  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
  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.network.OwnCloudClientUtils;\r
@@@ -273,7 -273,7 +274,7 @@@ implements  OnRemoteOperationListener, 
              mAccount = savedInstanceState.getParcelable(KEY_ACCOUNT);\r
              mAuthTokenType = savedInstanceState.getString(AccountAuthenticator.KEY_AUTH_TOKEN_TYPE);\r
              if (mAuthTokenType == null) {\r
 -                mAuthTokenType =  AccountAuthenticator.AUTH_TOKEN_TYPE_PASSWORD;\r
 +                mAuthTokenType =  MainApp.getAuthTokenTypePass();\r
                  \r
              }\r
  \r
          if (mServerIsChecked && !mServerIsValid && refreshButtonEnabled) showRefreshButton();\r
          mOkButton.setEnabled(mServerIsValid); // state not automatically recovered in configuration changes\r
  \r
 -        if (AccountAuthenticator.AUTH_TOKEN_TYPE_SAML_WEB_SSO_SESSION_COOKIE.equals(mAuthTokenType) || \r
 +        if (MainApp.getAuthTokenTypeSamlSessionCookie().equals(mAuthTokenType) || \r
                  !AUTH_OPTIONAL.equals(getString(R.string.auth_method_oauth2))) {\r
              mOAuth2Check.setVisibility(View.GONE);\r
          }\r
              @Override\r
              public boolean onTouch(View view, MotionEvent event) {\r
                  if (event.getAction() == MotionEvent.ACTION_DOWN) {\r
 -                    if (AccountAuthenticator.AUTH_TOKEN_TYPE_SAML_WEB_SSO_SESSION_COOKIE.equals(mAuthTokenType) &&\r
 +                    if (MainApp.getAuthTokenTypeSamlSessionCookie().equals(mAuthTokenType) &&\r
                              mHostUrlInput.hasFocus()) {\r
                          checkOcServer();\r
                      }\r
                  samlWebSsoRequired = AUTH_ON.equals(getString(R.string.auth_method_saml_web_sso));            \r
              }\r
              if (oAuthRequired) {\r
 -                mAuthTokenType = AccountAuthenticator.AUTH_TOKEN_TYPE_ACCESS_TOKEN;\r
 +                mAuthTokenType = MainApp.getAuthTokenTypeAccessToken();\r
              } else if (samlWebSsoRequired) {\r
 -                mAuthTokenType = AccountAuthenticator.AUTH_TOKEN_TYPE_SAML_WEB_SSO_SESSION_COOKIE;\r
 +                mAuthTokenType = MainApp.getAuthTokenTypeSamlSessionCookie();\r
              } else {\r
 -                mAuthTokenType = AccountAuthenticator.AUTH_TOKEN_TYPE_PASSWORD;\r
 +                mAuthTokenType = MainApp.getAuthTokenTypePass();\r
              }\r
          }\r
      \r
              mUsernameInput.setText(userName);\r
          }\r
          \r
 -        mOAuth2Check.setChecked(AccountAuthenticator.AUTH_TOKEN_TYPE_ACCESS_TOKEN.equals(mAuthTokenType));\r
 +        mOAuth2Check.setChecked(MainApp.getAuthTokenTypeAccessToken().equals(mAuthTokenType));\r
          \r
      }\r
  \r
      protected void onResume() {\r
          super.onResume();\r
          if (mAction == ACTION_UPDATE_TOKEN && mJustCreated && getIntent().getBooleanExtra(EXTRA_ENFORCED_UPDATE, false)) {\r
 -            if (AccountAuthenticator.AUTH_TOKEN_TYPE_ACCESS_TOKEN.equals(mAuthTokenType)) {\r
 +            if (MainApp.getAuthTokenTypeAccessToken().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
 -            } else if (AccountAuthenticator.AUTH_TOKEN_TYPE_SAML_WEB_SSO_SESSION_COOKIE.equals(mAuthTokenType)) {\r
 +            } else if (MainApp.getAuthTokenTypeSamlSessionCookie().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
              return;\r
          }\r
  \r
 -        if (AccountAuthenticator.AUTH_TOKEN_TYPE_ACCESS_TOKEN.equals(mAuthTokenType)) {\r
 +        if (MainApp.getAuthTokenTypeAccessToken().equals(mAuthTokenType)) {\r
              startOauthorization();\r
 -        } else if (AccountAuthenticator.AUTH_TOKEN_TYPE_SAML_WEB_SSO_SESSION_COOKIE.equals(mAuthTokenType)) { \r
 +        } else if (MainApp.getAuthTokenTypeSamlSessionCookie().equals(mAuthTokenType)) { \r
              startSamlBasedFederatedSingleSignOnAuthorization();\r
          } else {\r
              checkBasicAuthorization();\r
              onGetOAuthAccessTokenFinish((OAuth2GetAccessToken)operation, result);\r
  \r
          } else if (operation instanceof ExistenceCheckOperation)  {\r
 -            if (AccountAuthenticator.AUTH_TOKEN_TYPE_SAML_WEB_SSO_SESSION_COOKIE.equals(mAuthTokenType)) {\r
 +            if (MainApp.getAuthTokenTypeSamlSessionCookie().equals(mAuthTokenType)) {\r
                  onSamlBasedFederatedSingleSignOnAuthorizationStart(operation, result);\r
                  \r
              } else {\r
          response.putString(AccountManager.KEY_ACCOUNT_NAME, mAccount.name);\r
          response.putString(AccountManager.KEY_ACCOUNT_TYPE, mAccount.type);\r
          \r
 -        if (AccountAuthenticator.AUTH_TOKEN_TYPE_ACCESS_TOKEN.equals(mAuthTokenType)) { \r
 +        if (MainApp.getAuthTokenTypeAccessToken().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
 -        } else if (AccountAuthenticator.AUTH_TOKEN_TYPE_SAML_WEB_SSO_SESSION_COOKIE.equals(mAuthTokenType)) {\r
 +        } else if (MainApp.getAuthTokenTypeSamlSessionCookie().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
       */\r
      private boolean createAccount() {\r
          /// create and save new ownCloud account\r
 -        boolean isOAuth = AccountAuthenticator.AUTH_TOKEN_TYPE_ACCESS_TOKEN.equals(mAuthTokenType);\r
 -        boolean isSaml =  AccountAuthenticator.AUTH_TOKEN_TYPE_SAML_WEB_SSO_SESSION_COOKIE.equals(mAuthTokenType);\r
 +        boolean isOAuth = MainApp.getAuthTokenTypeAccessToken().equals(mAuthTokenType);\r
 +        boolean isSaml =  MainApp.getAuthTokenTypeSamlSessionCookie().equals(mAuthTokenType);\r
  \r
          Uri uri = Uri.parse(mHostBaseUrl);\r
          String username = mUsernameInput.getText().toString().trim();\r
          if (uri.getPort() >= 0) {\r
              accountName += ":" + uri.getPort();\r
          }\r
 -        mAccount = new Account(accountName, AccountAuthenticator.ACCOUNT_TYPE);\r
 +        mAccount = new Account(accountName, MainApp.getAccountType());\r
          if (AccountUtils.exists(mAccount, getApplicationContext())) {\r
              // fail - not a new account, but an existing one; disallow\r
              RemoteOperationResult result = new RemoteOperationResult(ResultCode.ACCOUNT_NOT_NEW); \r
              /// prepare result to return to the Authenticator\r
              //  TODO check again what the Authenticator makes with it; probably has the same effect as addAccountExplicitly, but it's not well done\r
              final Intent intent = new Intent();       \r
 -            intent.putExtra(AccountManager.KEY_ACCOUNT_TYPE,    AccountAuthenticator.ACCOUNT_TYPE);\r
 +            intent.putExtra(AccountManager.KEY_ACCOUNT_TYPE,    MainApp.getAccountType());\r
              intent.putExtra(AccountManager.KEY_ACCOUNT_NAME,    mAccount.name);\r
              /*if (!isOAuth)\r
 -                intent.putExtra(AccountManager.KEY_AUTHTOKEN,   AccountAuthenticator.ACCOUNT_TYPE); */\r
 +                intent.putExtra(AccountManager.KEY_AUTHTOKEN,   MainApp.getAccountType()); */\r
              intent.putExtra(AccountManager.KEY_USERDATA,        username);\r
              if (isOAuth || isSaml) {\r
                  mAccountMgr.setAuthToken(mAccount, mAuthTokenType, mAuthToken);\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, AccountAuthenticator.AUTHORITY, bundle);\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, AccountAuthenticator.AUTHORITY, bundle);\r
 +//          ContentResolver.requestSync(mAccount, MainApp.getAuthTokenType(), bundle);\r
              return true;\r
          }\r
      }\r
      public void onCheckClick(View view) {\r
          CheckBox oAuth2Check = (CheckBox)view;\r
          if (oAuth2Check.isChecked()) {\r
 -            mAuthTokenType = AccountAuthenticator.AUTH_TOKEN_TYPE_ACCESS_TOKEN;\r
 +            mAuthTokenType = MainApp.getAuthTokenTypeAccessToken();\r
          } else {\r
 -            mAuthTokenType = AccountAuthenticator.AUTH_TOKEN_TYPE_PASSWORD;\r
 +            mAuthTokenType = MainApp.getAuthTokenTypePass();\r
          }\r
          adaptViewAccordingToAuthenticationMethod();\r
      }\r
       * the current authorization method.\r
       */\r
      private void adaptViewAccordingToAuthenticationMethod () {\r
 -        if (AccountAuthenticator.AUTH_TOKEN_TYPE_ACCESS_TOKEN.equals(mAuthTokenType)) {\r
 +        if (MainApp.getAuthTokenTypeAccessToken().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
 -        } else if (AccountAuthenticator.AUTH_TOKEN_TYPE_SAML_WEB_SSO_SESSION_COOKIE.equals(mAuthTokenType)) {\r
 +        } else if (MainApp.getAuthTokenTypeSamlSessionCookie().equals(mAuthTokenType)) {\r
              // SAML-based web Single Sign On\r
              mOAuthAuthEndpointText.setVisibility(View.GONE);\r
              mOAuthTokenEndpointText.setVisibility(View.GONE);\r
              }\r
              \r
          } else if (actionId == EditorInfo.IME_ACTION_NEXT && inputField != null && inputField.equals(mHostUrlInput)) {\r
 -            if (AccountAuthenticator.AUTH_TOKEN_TYPE_SAML_WEB_SSO_SESSION_COOKIE.equals(mAuthTokenType)) {\r
 +            if (MainApp.getAuthTokenTypeSamlSessionCookie().equals(mAuthTokenType)) {\r
                  checkOcServer();\r
              }\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, AccountAuthenticator.AUTHORITY, bundle);\r
 +        ContentResolver.requestSync(mAccount, MainApp.getAuthTokenType(), bundle);\r
      }\r
      \r
      @Override\r
      public boolean onTouchEvent(MotionEvent event) {\r
 -        if (AccountAuthenticator.AUTH_TOKEN_TYPE_SAML_WEB_SSO_SESSION_COOKIE.equals(mAuthTokenType) &&\r
 +        if (MainApp.getAuthTokenTypeSamlSessionCookie().equals(mAuthTokenType) &&\r
                  mHostUrlInput.hasFocus() && event.getAction() == MotionEvent.ACTION_DOWN) {\r
              checkOcServer();\r
          }\r
@@@ -51,7 -51,6 +51,7 @@@ import com.owncloud.android.authenticat
  import com.owncloud.android.authentication.AuthenticatorActivity;
  import com.owncloud.android.authentication.AccountUtils;
  import com.owncloud.android.Log_OC;
 +import com.owncloud.android.MainApp;
  
  import com.owncloud.android.R;
  
@@@ -96,10 -95,10 +96,10 @@@ public class AccountSelectActivity exte
                  /// the account set as default changed since this activity was created 
              
                  // trigger synchronization
 -                ContentResolver.cancelSync(null, AccountAuthenticator.AUTHORITY);
 +                ContentResolver.cancelSync(null, MainApp.getAuthTokenType());
                  Bundle bundle = new Bundle();
                  bundle.putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, true);
 -                ContentResolver.requestSync(AccountUtils.getCurrentOwnCloudAccount(this), AccountAuthenticator.AUTHORITY, bundle);
 +                ContentResolver.requestSync(AccountUtils.getCurrentOwnCloudAccount(this), MainApp.getAuthTokenType(), bundle);
                  
                  // restart the main activity
                  Intent i = new Intent(this, FileDisplayActivity.class);
  
      @Override
      public boolean onCreateOptionsMenu(Menu menu) {
-         MenuInflater inflater = getSherlock().getMenuInflater();
-         inflater.inflate(R.menu.account_picker, menu);
+         // Show Create Account if Multiaccount is enabled
+         if (getResources().getBoolean(R.bool.multiaccount_support)) {
+             MenuInflater inflater = getSherlock().getMenuInflater();
+             inflater.inflate(R.menu.account_picker, menu);
+         }
          return true;
      }
  
              /*Intent intent = new Intent(
                      android.provider.Settings.ACTION_ADD_ACCOUNT);
              intent.putExtra("authorities",
 -                    new String[] { AccountAuthenticator.AUTHORITY });
 +                    new String[] { MainApp.getAuthTokenType() });
              startActivity(intent);*/
              AccountManager am = AccountManager.get(getApplicationContext());
 -            am.addAccount(AccountAuthenticator.ACCOUNT_TYPE
 +            am.addAccount(MainApp.getAccountType()
                              null,
                              null, 
                              null, 
                              this, 
                              null,                        
                              null);
-             
              return true;
          }
          return false;
          
          String accountName = map.get("NAME");
          AccountManager am = (AccountManager) getSystemService(ACCOUNT_SERVICE);
 -        Account accounts[] = am.getAccountsByType(AccountAuthenticator.ACCOUNT_TYPE);
 +        Account accounts[] = am.getAccountsByType(MainApp.getAccountType());
          for (Account a : accounts) {
              if (a.name.equals(accountName)) {
                  if (item.getItemId() == R.id.change_password) {
      private void populateAccountList() {
          AccountManager am = (AccountManager) getSystemService(ACCOUNT_SERVICE);
          Account accounts[] = am
 -                .getAccountsByType(AccountAuthenticator.ACCOUNT_TYPE);
 +                .getAccountsByType(MainApp.getAccountType());
          LinkedList<HashMap<String, String>> ll = new LinkedList<HashMap<String, String>>();
          for (Account a : accounts) {
              HashMap<String, String> h = new HashMap<String, String>();
                  android.R.layout.simple_list_item_single_choice,
                  new String[] { "NAME" }, new int[] { android.R.id.text1 }));
          registerForContextMenu(getListView());
+         
      }
  
      @Override
              String accountName = "";
              if (a == null) {
                  Account[] accounts = AccountManager.get(this)
 -                        .getAccountsByType(AccountAuthenticator.ACCOUNT_TYPE);
 +                        .getAccountsByType(MainApp.getAccountType());
                  if (accounts.length != 0)
                      accountName = accounts[0].name;
                  AccountUtils.setCurrentOwnCloudAccount(this, accountName);