Locked edition of URL and password in redirection due to expired credentials; error...
authorDavid A. Velasco <dvelasco@solidgear.es>
Fri, 25 Jan 2013 14:11:10 +0000 (15:11 +0100)
committerDavid A. Velasco <dvelasco@solidgear.es>
Fri, 25 Jan 2013 14:11:10 +0000 (15:11 +0100)
res/layout-land/account_setup.xml
res/layout/account_setup.xml
res/values/strings.xml
src/com/owncloud/android/authenticator/AccountAuthenticator.java
src/com/owncloud/android/ui/activity/AuthenticatorActivity.java

index b30c515..2f54c96 100644 (file)
@@ -61,7 +61,6 @@
                         android:id="@+id/hostUrlInput"
                         android:layout_width="match_parent"
                         android:layout_height="wrap_content"
-                        android:layout_weight="1"
                         android:ems="10"
                         android:hint="@string/auth_host_url"
                         android:inputType="textNoSuggestions">
                        <requestFocus />
                    </EditText>            
        
-                <LinearLayout
-                    android:layout_width="match_parent"
-                    android:layout_height="wrap_content"
-                    android:layout_weight="1" >
-
-                    <ImageView
-                        android:id="@+id/auth2_action_indicator"
-                        android:layout_width="wrap_content"
-                        android:layout_height="wrap_content"
-                        android:layout_marginLeft="5dp"
-                        android:layout_marginRight="5dp"
-                        android:src="@android:drawable/stat_notify_sync"
-                        android:visibility="gone" />
-
-                    <TextView
-                        android:id="@+id/oauth2_status_text"
-                        android:layout_width="wrap_content"
-                        android:layout_height="wrap_content"
-                        android:text="TextView"
-                        android:visibility="gone" />
-                </LinearLayout>
-                
                 <EditText
                     android:id="@+id/account_username"
                     android:layout_width="match_parent"
                         android:id="@+id/account_password"
                         android:layout_width="match_parent"
                         android:layout_height="wrap_content"
-                        android:layout_weight="1"
                         android:ems="10"
                         android:hint="@string/auth_password"
                         android:inputType="textPassword"/>
                         android:visibility="invisible" />
                 </FrameLayout>
             </LinearLayout>
+            
+            <!-- LinearLayout
+                android:id="@+id/auth_status_layout"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_weight="1"
+                android:visibility="invisible" 
+                >
+
+                <ImageView
+                    android:id="@+id/auth_status_icon"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:layout_marginLeft="5dp"
+                    android:layout_marginRight="5dp"
+                    android:src="@android:drawable/stat_notify_sync"
+                    />
+
+                <TextView
+                    android:id="@+id/auth_status_text"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:text="@string/text_placeholder"
+                    />
+                
+            </LinearLayout -->
+                
+            <TextView
+                android:id="@+id/auth_status_text"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_weight="1" 
+                android:text="@string/text_placeholder"
+                android:layout_marginLeft="5dp"
+                android:layout_marginRight="5dp"
+                               android:drawableLeft="@android:drawable/stat_notify_sync"
+                       android:drawablePadding="5dip"
+                       android:visibility="invisible"                
+                />
+                    
+            
         </LinearLayout>
     </FrameLayout>
 
index 7d77e51..62eac2b 100644 (file)
@@ -36,7 +36,6 @@
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
             android:layout_gravity="center"
-            android:layout_weight="1"
             android:orientation="vertical" >
 
             <ImageView
@@ -56,7 +55,6 @@
                     android:id="@+id/hostUrlInput"
                     android:layout_width="match_parent"
                     android:layout_height="wrap_content"
-                    android:layout_weight="1"
                     android:ems="10"
                     android:hint="@string/auth_host_url"
                     android:inputType="textNoSuggestions" >
                 <requestFocus />
             </EditText>            
 
-            <LinearLayout
-                android:layout_width="match_parent"
-                android:layout_height="wrap_content"
-                android:layout_weight="1" >
-
-                <ImageView
-                    android:id="@+id/auth2_action_indicator"
-                    android:layout_width="wrap_content"
-                    android:layout_height="wrap_content"
-                    android:layout_marginLeft="5dp"
-                    android:layout_marginRight="5dp"
-                    android:src="@android:drawable/stat_notify_sync"
-                    android:visibility="gone" />
-
-                <TextView
-                    android:id="@+id/oauth2_status_text"
-                    android:layout_width="wrap_content"
-                    android:layout_height="wrap_content"
-                    android:text="TextView"
-                    android:visibility="gone" />
-            </LinearLayout>            
             <EditText
                 android:id="@+id/account_username"
                 android:layout_width="match_parent"
                     android:id="@+id/account_password"
                     android:layout_width="match_parent"
                     android:layout_height="wrap_content"
-                    android:layout_weight="1"
                     android:ems="10"
                     android:hint="@string/auth_password"
                     android:inputType="textPassword"/>
 
             </FrameLayout>
 
-            </LinearLayout>
+            <!-- LinearLayout
+                android:id="@+id/auth_status_layout"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_weight="1" 
+                android:visibility="invisible"
+                >
+
+                <ImageView
+                    android:id="@+id/auth_status_icon"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:layout_marginLeft="5dp"
+                    android:layout_marginRight="5dp"
+                    android:src="@android:drawable/stat_notify_sync"
+                    />
+
+                <TextView
+                    android:id="@+id/auth_status_text"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:text="@string/text_placeholder"
+                    >
+                
+            </LinearLayout -->
+            
+            <TextView
+                android:id="@+id/auth_status_text"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_weight="1" 
+                android:text="@string/text_placeholder"
+                android:layout_marginLeft="5dp"
+                android:layout_marginRight="5dp"
+                               android:drawableLeft="@android:drawable/stat_notify_sync"
+                       android:drawablePadding="5dip"
+                       android:visibility="invisible"                
+                />
+                    
+               </LinearLayout>
 
     </FrameLayout>
 
index 3609f56..009bd7f 100644 (file)
        <string name="auth_wrong_connection_title">Couldn\'t establish connection</string>
        <string name="auth_secure_connection">Secure connection established</string>
     <string name="auth_login_details">Login details</string>
-    <string name="auth_unauthorized">Invalid login / password</string>
+    <string name="auth_unauthorized">Invalid credentials</string>
+       <string name="auth_bad_oauth_token">Bad response from authorization server</string>
     <string name="auth_not_found">Wrong path given</string>
     <string name="auth_internal">Internal server error, code %1$d</string>
     <string name="auth_wtf_reenter_URL">Unexpected state; please, enter the server URL again</string>
index c6ad9e7..8b85392 100644 (file)
@@ -98,6 +98,7 @@ public class AccountAuthenticator extends AbstractAccountAuthenticator {
         intent.putExtra(KEY_AUTH_TOKEN_TYPE, authTokenType);\r
         intent.putExtra(KEY_REQUIRED_FEATURES, requiredFeatures);\r
         intent.putExtra(KEY_LOGIN_OPTIONS, options);\r
+        intent.putExtra(AuthenticatorActivity.EXTRA_ACTION, AuthenticatorActivity.ACTION_CREATE);\r
 \r
         setIntentFlags(intent);\r
         \r
@@ -173,12 +174,14 @@ public class AccountAuthenticator extends AbstractAccountAuthenticator {
             return result;\r
         }\r
         \r
-        /// if not stored, return Intent to access the AuthenticatorActivity\r
+        /// if not stored, return Intent to access the AuthenticatorActivity and UPDATE the token for the account\r
         final Intent intent = new Intent(mContext, AuthenticatorActivity.class);\r
         intent.putExtra(AccountManager.KEY_ACCOUNT_AUTHENTICATOR_RESPONSE, response);\r
         intent.putExtra(KEY_AUTH_TOKEN_TYPE, authTokenType);\r
         intent.putExtra(KEY_LOGIN_OPTIONS, options);\r
         intent.putExtra(AuthenticatorActivity.EXTRA_ACCOUNT, account);\r
+        intent.putExtra(AuthenticatorActivity.EXTRA_ACTION, AuthenticatorActivity.ACTION_UPDATE_TOKEN);\r
+        \r
 \r
         final Bundle bundle = new Bundle();\r
         bundle.putParcelable(AccountManager.KEY_INTENT, intent);\r
@@ -224,8 +227,8 @@ public class AccountAuthenticator extends AbstractAccountAuthenticator {
 \r
     private void setIntentFlags(Intent intent) {\r
         intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);\r
-        intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);\r
-        intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY); // incompatible with the authorization code grant in OAuth\r
+        //intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);\r
+        //intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY); // incompatible with the authorization code grant in OAuth\r
         intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);\r
         intent.addFlags(Intent.FLAG_FROM_BACKGROUND);\r
     }\r
index 1185307..6500ce5 100644 (file)
@@ -35,6 +35,7 @@ import com.owncloud.android.operations.OAuth2GetAccessToken;
 import com.owncloud.android.operations.OnRemoteOperationListener;\r
 import com.owncloud.android.operations.RemoteOperation;\r
 import com.owncloud.android.operations.RemoteOperationResult;\r
+import com.owncloud.android.operations.RemoteOperationResult.ResultCode;\r
 \r
 import android.accounts.Account;\r
 import android.accounts.AccountAuthenticatorActivity;\r
@@ -78,7 +79,8 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
     public static final String EXTRA_ACCOUNT = "ACCOUNT";\r
     public static final String EXTRA_USER_NAME = "USER_NAME";\r
     public static final String EXTRA_HOST_NAME = "HOST_NAME";\r
-\r
+    public static final String EXTRA_ACTION = "ACTION";\r
+    \r
     private static final String KEY_HOST_URL_TEXT = "HOST_URL_TEXT";\r
     private static final String KEY_OC_VERSION = "OC_VERSION";\r
     private static final String KEY_STATUS_TEXT = "STATUS_TEXT";\r
@@ -93,6 +95,9 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
     private static final int DIALOG_CERT_NOT_SAVED = 2;\r
     private static final int DIALOG_OAUTH2_LOGIN_PROGRESS = 3;\r
 \r
+    public static final byte ACTION_CREATE = 0;\r
+    public static final byte ACTION_UPDATE_TOKEN = 1;\r
+    \r
     \r
     private String mHostBaseUrl;\r
     private OwnCloudVersion mDiscoveredVersion;\r
@@ -123,6 +128,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
     private CheckBox mOAuth2Check;\r
     private String mOAuthAccessToken;\r
     private View mOkButton;\r
+    private TextView mAuthStatusLayout;\r
     \r
     private TextView mOAuthAuthEndpointText;\r
     private TextView mOAuthTokenEndpointText;\r
@@ -149,6 +155,8 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
         mOAuthTokenEndpointText = (TextView)findViewById(R.id.oAuthEntryPoint_2);\r
         mOAuth2Check = (CheckBox) findViewById(R.id.oauth_onOff_check);\r
         mOkButton = findViewById(R.id.buttonOK);\r
+        mAuthStatusLayout = (TextView) findViewById(R.id.auth_status_text); \r
+        \r
 \r
         /// complete label for 'register account' button\r
         Button b = (Button) findViewById(R.id.account_register);\r
@@ -192,6 +200,14 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
             loadSavedInstanceState(savedInstanceState);\r
         }\r
         \r
+        if (getIntent().getByteExtra(EXTRA_ACTION, ACTION_CREATE) == ACTION_UPDATE_TOKEN) {\r
+            /// lock things that should not change\r
+            mHostUrlInput.setEnabled(false);\r
+            mUsernameInput.setEnabled(false);\r
+            mOAuth2Check.setVisibility(View.GONE);\r
+            checkOcServer(); \r
+        }\r
+        \r
         mPasswordInput.setText("");     // clean password to avoid social hacking (disadvantage: password in removed if the device is turned aside)\r
     }\r
 \r
@@ -244,7 +260,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
         mIsSslConn = savedInstanceState.getBoolean(KEY_IS_SSL_CONN);\r
         mStatusText = savedInstanceState.getInt(KEY_STATUS_TEXT);\r
         mStatusIcon = savedInstanceState.getInt(KEY_STATUS_ICON);\r
-        updateOcServerCheckIconAndText();\r
+        updateConnStatus();\r
         \r
         /// UI settings depending upon connection\r
         mOkButton.setEnabled(mStatusCorrect);   // TODO really necessary?\r
@@ -370,8 +386,12 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
             i++;\r
         }\r
         \r
-        /// Updating status widget to OK.\r
-        updateOAuth2IconAndText(R.drawable.ic_ok, R.string.auth_connection_established);\r
+        /// Updating status widget to OK. -- TODO REMOVE, UNNECESSARY\r
+        /*\r
+        mStatusIcon = R.drawable.ic_ok;\r
+        mStatusText = R.string.auth_connection_established;\r
+        updateAuthStatus();\r
+        */\r
         \r
         /// Showing the dialog with instructions for the user.\r
         showDialog(DIALOG_OAUTH2_LOGIN_PROGRESS);\r
@@ -411,26 +431,8 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
      */\r
     private void onUrlInputFocusChanged(TextView hostInput, boolean hasFocus) {\r
         if (!hasFocus) {\r
-            String uri = hostInput.getText().toString().trim();\r
-            if (uri.length() != 0) {\r
-                mStatusText = R.string.auth_testing_connection;\r
-                mStatusIcon = R.drawable.progress_small;\r
-                updateOcServerCheckIconAndText();\r
-                /** TODO cancel previous connection check if the user tries to ammend a wrong URL  \r
-                if(mConnChkOperation != null) {\r
-                    mConnChkOperation.cancel();\r
-                } */\r
-                mOcServerChkOperation = new  OwnCloudServerCheckOperation(uri, this);\r
-                WebdavClient client = OwnCloudClientUtils.createOwnCloudClient(Uri.parse(uri), this);\r
-                mHostBaseUrl = "";\r
-                mDiscoveredVersion = null;\r
-                mOperationThread = mOcServerChkOperation.execute(client, this, mHandler);\r
-            } else {\r
-                mRefreshButton.setVisibility(View.INVISIBLE);\r
-                mStatusText = 0;\r
-                mStatusIcon = 0;\r
-                updateOcServerCheckIconAndText();\r
-            }\r
+            checkOcServer();\r
+            \r
         } else {\r
             // avoids that the 'connect' button can be clicked if the test was previously passed\r
             mOkButton.setEnabled(false); \r
@@ -438,6 +440,30 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
     }\r
 \r
 \r
+    private void checkOcServer() {\r
+        String uri = mHostUrlInput.getText().toString().trim();\r
+        if (uri.length() != 0) {\r
+            mStatusText = R.string.auth_testing_connection;\r
+            mStatusIcon = R.drawable.progress_small;\r
+            updateConnStatus();\r
+            /** TODO cancel previous connection check if the user tries to ammend a wrong URL  \r
+            if(mConnChkOperation != null) {\r
+                mConnChkOperation.cancel();\r
+            } */\r
+            mOcServerChkOperation = new  OwnCloudServerCheckOperation(uri, this);\r
+            WebdavClient client = OwnCloudClientUtils.createOwnCloudClient(Uri.parse(uri), this);\r
+            mHostBaseUrl = "";\r
+            mDiscoveredVersion = null;\r
+            mOperationThread = mOcServerChkOperation.execute(client, this, mHandler);\r
+        } else {\r
+            mRefreshButton.setVisibility(View.INVISIBLE);\r
+            mStatusText = 0;\r
+            mStatusIcon = 0;\r
+            updateConnStatus();\r
+        }\r
+    }\r
+\r
+\r
     /**\r
      * Handles changes in focus on the text input for the password (basic authorization).\r
      * \r
@@ -495,7 +521,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
         if (mDiscoveredVersion == null || !mDiscoveredVersion.isVersionValid()  || mHostBaseUrl == null || mHostBaseUrl.length() == 0) {\r
             mStatusIcon = R.drawable.common_error;\r
             mStatusText = R.string.auth_wtf_reenter_URL;\r
-            updateOcServerCheckIconAndText();\r
+            updateConnStatus();\r
             mOkButton.setEnabled(false);\r
             Log.wtf(TAG,  "The user was allowed to click 'connect' to an unchecked server!!");\r
             return;\r
@@ -539,7 +565,9 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
      */\r
     private void startOauthorization() {\r
         // be gentle with the user\r
-        updateOAuth2IconAndText(R.drawable.progress_small, R.string.oauth_login_connection);\r
+        mStatusIcon = R.drawable.progress_small;\r
+        mStatusText = R.string.oauth_login_connection;\r
+        updateAuthStatus();\r
         \r
         // GET AUTHORIZATION request\r
         /*\r
@@ -594,86 +622,19 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
      * @param result        Result of the check.\r
      */\r
     private void onOcServerCheckFinish(OwnCloudServerCheckOperation operation, RemoteOperationResult result) {\r
-        /// update status connection icon and text\r
-        mStatusText = mStatusIcon = 0;\r
-        mStatusCorrect = false;\r
+        /// update status icon and text\r
+        updateStatusIconAndText(result);\r
+        updateConnStatus();\r
+\r
+        /// save result state\r
+        mStatusCorrect = result.isSuccess();\r
+        mIsSslConn = (result.getCode() == ResultCode.OK_SSL);\r
         \r
-        switch (result.getCode()) {\r
-            case OK_SSL:\r
-                mIsSslConn = true;\r
-                mStatusIcon = android.R.drawable.ic_secure;\r
-                mStatusText = R.string.auth_secure_connection;\r
-                mStatusCorrect = true;\r
-                break;\r
-                \r
-            case OK_NO_SSL:\r
-            case OK:\r
-                mIsSslConn = false;\r
-                mStatusCorrect = true;\r
-                if (mHostUrlInput.getText().toString().trim().toLowerCase().startsWith("http://") ) {\r
-                    mStatusText = R.string.auth_connection_established;\r
-                    mStatusIcon = R.drawable.ic_ok;\r
-                } else {\r
-                    mStatusText = R.string.auth_nossl_plain_ok_title;\r
-                    mStatusIcon = android.R.drawable.ic_partial_secure;\r
-                }\r
-                break;\r
-                \r
-            /// very special case (TODO: move to a common place for all the remote operations)\r
-            case SSL_RECOVERABLE_PEER_UNVERIFIED:\r
-                mStatusIcon = R.drawable.common_error;\r
-                mStatusText = R.string.auth_ssl_unverified_server_title;\r
-                mLastSslUntrustedServerResult = result;\r
-                showDialog(DIALOG_SSL_VALIDATOR); \r
-                break;\r
-                    \r
-            case BAD_OC_VERSION:\r
-                mStatusIcon = R.drawable.common_error;\r
-                mStatusText = R.string.auth_bad_oc_version_title;\r
-                break;\r
-            case WRONG_CONNECTION:\r
-                mStatusIcon = R.drawable.common_error;\r
-                mStatusText = R.string.auth_wrong_connection_title;\r
-                break;\r
-            case TIMEOUT:\r
-                mStatusIcon = R.drawable.common_error;\r
-                mStatusText = R.string.auth_timeout_title;\r
-                break;\r
-            case INCORRECT_ADDRESS:\r
-                mStatusIcon = R.drawable.common_error;\r
-                mStatusText = R.string.auth_incorrect_address_title;\r
-                break;\r
-                \r
-            case SSL_ERROR:\r
-                mStatusIcon = R.drawable.common_error;\r
-                mStatusText = R.string.auth_ssl_general_error_title;\r
-                break;\r
-                \r
-            case HOST_NOT_AVAILABLE:\r
-                mStatusIcon = R.drawable.common_error;\r
-                mStatusText = R.string.auth_unknown_host_title;\r
-                break;\r
-            case NO_NETWORK_CONNECTION:\r
-                mStatusIcon = R.drawable.no_network;\r
-                mStatusText = R.string.auth_no_net_conn_title;\r
-                break;\r
-            case INSTANCE_NOT_CONFIGURED:\r
-                mStatusIcon = R.drawable.common_error;\r
-                mStatusText = R.string.auth_not_configured_title;\r
-                break;\r
-            case FILE_NOT_FOUND:\r
-                mStatusIcon = R.drawable.common_error;\r
-                mStatusText = R.string.auth_incorrect_path_title;\r
-                break;\r
-            case UNHANDLED_HTTP_CODE:\r
-            case UNKNOWN_ERROR:\r
-                mStatusIcon = R.drawable.common_error;\r
-                mStatusText = R.string.auth_unknown_error_title;\r
-                break;\r
-            default:\r
-                Log.e(TAG, "Incorrect connection checker result type: " + result.getHttpCode());\r
+        /// very special case (TODO: move to a common place for all the remote operations)\r
+        if (result.getCode() == ResultCode.SSL_RECOVERABLE_PEER_UNVERIFIED) {\r
+            mLastSslUntrustedServerResult = result;\r
+            showDialog(DIALOG_SSL_VALIDATOR); \r
         }\r
-        updateOcServerCheckIconAndText();\r
         \r
         /// update the visibility of the 'retry connection' button\r
         if (!mStatusCorrect)\r
@@ -703,6 +664,94 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
 \r
 \r
     /**\r
+     * Chooses the right icon and text to show to the user for the received operation result.\r
+     * \r
+     * @param result    Result of a remote operation performed in this activity\r
+     */\r
+    private void updateStatusIconAndText(RemoteOperationResult result) {\r
+        mStatusText = mStatusIcon = 0;\r
+\r
+        switch (result.getCode()) {\r
+        case OK_SSL:\r
+            mStatusIcon = android.R.drawable.ic_secure;\r
+            mStatusText = R.string.auth_secure_connection;\r
+            break;\r
+            \r
+        case OK_NO_SSL:\r
+        case OK:\r
+            if (mHostUrlInput.getText().toString().trim().toLowerCase().startsWith("http://") ) {\r
+                mStatusText = R.string.auth_connection_established;\r
+                mStatusIcon = R.drawable.ic_ok;\r
+            } else {\r
+                mStatusText = R.string.auth_nossl_plain_ok_title;\r
+                mStatusIcon = android.R.drawable.ic_partial_secure;\r
+            }\r
+            break;\r
+            \r
+        case SSL_RECOVERABLE_PEER_UNVERIFIED:\r
+            mStatusIcon = R.drawable.common_error;\r
+            mStatusText = R.string.auth_ssl_unverified_server_title;\r
+            break;\r
+                \r
+        case BAD_OC_VERSION:\r
+            mStatusIcon = R.drawable.common_error;\r
+            mStatusText = R.string.auth_bad_oc_version_title;\r
+            break;\r
+        case WRONG_CONNECTION:\r
+            mStatusIcon = R.drawable.common_error;\r
+            mStatusText = R.string.auth_wrong_connection_title;\r
+            break;\r
+        case TIMEOUT:\r
+            mStatusIcon = R.drawable.common_error;\r
+            mStatusText = R.string.auth_timeout_title;\r
+            break;\r
+        case INCORRECT_ADDRESS:\r
+            mStatusIcon = R.drawable.common_error;\r
+            mStatusText = R.string.auth_incorrect_address_title;\r
+            break;\r
+            \r
+        case SSL_ERROR:\r
+            mStatusIcon = R.drawable.common_error;\r
+            mStatusText = R.string.auth_ssl_general_error_title;\r
+            break;\r
+            \r
+        case UNAUTHORIZED:\r
+            mStatusIcon = R.drawable.common_error;\r
+            mStatusText = R.string.auth_unauthorized;\r
+            break;\r
+        case HOST_NOT_AVAILABLE:\r
+            mStatusIcon = R.drawable.common_error;\r
+            mStatusText = R.string.auth_unknown_host_title;\r
+            break;\r
+        case NO_NETWORK_CONNECTION:\r
+            mStatusIcon = R.drawable.no_network;\r
+            mStatusText = R.string.auth_no_net_conn_title;\r
+            break;\r
+        case INSTANCE_NOT_CONFIGURED:\r
+            mStatusIcon = R.drawable.common_error;\r
+            mStatusText = R.string.auth_not_configured_title;\r
+            break;\r
+        case FILE_NOT_FOUND:\r
+            mStatusIcon = R.drawable.common_error;\r
+            mStatusText = R.string.auth_incorrect_path_title;\r
+            break;\r
+        case OAUTH2_ERROR:\r
+            mStatusIcon = R.drawable.common_error;\r
+            mStatusText = R.string.auth_bad_oauth_token;\r
+            break;\r
+        case UNHANDLED_HTTP_CODE:\r
+        case UNKNOWN_ERROR:\r
+            mStatusIcon = R.drawable.common_error;\r
+            mStatusText = R.string.auth_unknown_error_title;\r
+            break;\r
+            \r
+        default:\r
+            break;\r
+        }\r
+    }\r
+\r
+\r
+    /**\r
      * Processes the result of the request for and access token send \r
      * to an OAuth authorization server.\r
      * \r
@@ -716,7 +765,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
             // NOTHING TO DO ; can't find out what situation that leads to the exception in this code, but user logs signal that it happens\r
         }\r
 \r
-        String webdav_path = AccountUtils.getWebdavPath(mDiscoveredVersion, false);\r
+        String webdav_path = AccountUtils.getWebdavPath(mDiscoveredVersion, true);\r
         if (result.isSuccess() && webdav_path != null) {\r
             /// be gentle with the user\r
             showDialog(DIALOG_LOGIN_PROGRESS);\r
@@ -815,6 +864,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
             finish();\r
                 \r
         } else {\r
+            /*\r
             if (!isOAuth) {\r
                 mUsernameInput.setError(result.getLogMessage() + "        ");  \r
                                                     // the extra spaces are a workaround for an ugly bug: \r
@@ -825,7 +875,9 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
             \r
             } else {\r
                 mOAuthAuthEndpointText.setError(result.getLogMessage() + "        ");\r
-            }\r
+            }*/\r
+            updateStatusIconAndText(result);\r
+            updateAuthStatus();\r
             Log.d(TAG, "Access failed: " + result.getLogMessage());\r
         }\r
     }\r
@@ -963,7 +1015,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
      * Updates the content and visibility state of the icon and text associated\r
      * to the last check on the ownCloud server.\r
      */\r
-    private void updateOcServerCheckIconAndText() {\r
+    private void updateConnStatus() {\r
         ImageView iv = (ImageView) findViewById(R.id.action_indicator);\r
         TextView tv = (TextView) findViewById(R.id.status_text);\r
 \r
@@ -977,6 +1029,30 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
             tv.setVisibility(View.VISIBLE);\r
         }\r
     }\r
+    \r
+    \r
+    /**\r
+     * Updates the content and visibility state of the icon and text associated\r
+     * to the interactions with the OAuth authorization server.\r
+     */\r
+    private void updateAuthStatus() {\r
+        /*ImageView iv = (ImageView) findViewById(R.id.auth_status_icon);\r
+        TextView tv = (TextView) findViewById(R.id.auth_status_text);*/\r
+\r
+        if (mStatusIcon == 0 && mStatusText == 0) {\r
+            mAuthStatusLayout.setVisibility(View.INVISIBLE);\r
+            /*iv.setVisibility(View.INVISIBLE);\r
+            tv.setVisibility(View.INVISIBLE);*/\r
+        } else {\r
+            mAuthStatusLayout.setText(mStatusText);\r
+            mAuthStatusLayout.setCompoundDrawablesWithIntrinsicBounds(mStatusIcon, 0, 0, 0);\r
+            /*iv.setImageResource(mStatusIcon);\r
+            tv.setText(mStatusText);\r
+            /*iv.setVisibility(View.VISIBLE);\r
+            tv.setVisibility(View.VISIBLE);^*/\r
+            mAuthStatusLayout.setVisibility(View.VISIBLE);\r
+        }\r
+    }     \r
 \r
     \r
     /**\r
@@ -1035,51 +1111,22 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
      */\r
     public void changeViewByOAuth2Check(Boolean checked) {\r
         \r
-        ImageView auth2ActionIndicator = (ImageView) findViewById(R.id.auth2_action_indicator); \r
-        TextView oauth2StatusText = (TextView) findViewById(R.id.oauth2_status_text);         \r
-\r
         if (checked) {\r
             mOAuthAuthEndpointText.setVisibility(View.VISIBLE);\r
             mOAuthTokenEndpointText.setVisibility(View.VISIBLE);\r
             mUsernameInput.setVisibility(View.GONE);\r
             mPasswordInput.setVisibility(View.GONE);\r
             mViewPasswordButton.setVisibility(View.GONE);\r
-            auth2ActionIndicator.setVisibility(View.INVISIBLE);\r
-            oauth2StatusText.setVisibility(View.INVISIBLE);\r
         } else {\r
             mOAuthAuthEndpointText.setVisibility(View.GONE);\r
             mOAuthTokenEndpointText.setVisibility(View.GONE);\r
             mUsernameInput.setVisibility(View.VISIBLE);\r
             mPasswordInput.setVisibility(View.VISIBLE);\r
             mViewPasswordButton.setVisibility(View.INVISIBLE);\r
-            auth2ActionIndicator.setVisibility(View.GONE);\r
-            oauth2StatusText.setVisibility(View.GONE);\r
         }     \r
 \r
     }    \r
     \r
-    /**\r
-     * Updates the content and visibility state of the icon and text associated\r
-     * to the interactions with the OAuth authorization server.\r
-     * \r
-     * @param   drawable_id     Resource id for the icon.\r
-     * @param   text_id         Resource id for the text.\r
-     */\r
-    private void updateOAuth2IconAndText(int drawable_id, int text_id) {\r
-        ImageView iv = (ImageView) findViewById(R.id.auth2_action_indicator);\r
-        TextView tv = (TextView) findViewById(R.id.oauth2_status_text);\r
-\r
-        if (drawable_id == 0 && text_id == 0) {\r
-            iv.setVisibility(View.INVISIBLE);\r
-            tv.setVisibility(View.INVISIBLE);\r
-        } else {\r
-            iv.setImageResource(drawable_id);\r
-            tv.setText(text_id);\r
-            iv.setVisibility(View.VISIBLE);\r
-            tv.setVisibility(View.VISIBLE);\r
-        }\r
-    }     \r
-    \r
     /* Leave the old OAuth flow\r
     // Results from the first call to oAuth2 server : getting the user_code and verification_url.\r
     @Override\r