Merge branch 'develop' into login_view_layout_improvements
[pub/Android/ownCloud.git] / src / com / owncloud / android / authentication / AuthenticatorActivity.java
index 80cf894..375ef3b 100644 (file)
@@ -48,7 +48,9 @@ import android.net.Uri;
 import android.os.Bundle;\r
 import android.os.Handler;\r
 import android.preference.PreferenceManager;\r
+import android.text.Editable;\r
 import android.text.InputType;\r
+import android.text.TextWatcher;\r
 import android.view.KeyEvent;\r
 import android.view.MotionEvent;\r
 import android.view.View;\r
@@ -263,6 +265,22 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
                 return true;\r
             }\r
         });\r
+        mHostUrlInput.addTextChangedListener(new TextWatcher() {\r
+\r
+            @Override\r
+            public void afterTextChanged(Editable s) {\r
+                if (!mHostBaseUrl.equals(normalizeUrl(mHostUrlInput.getText().toString()))) {\r
+                    mOkButton.setEnabled(false);\r
+                }\r
+            }\r
+\r
+            @Override\r
+            public void beforeTextChanged(CharSequence s, int start, int count, int after) {}\r
+\r
+            @Override\r
+            public void onTextChanged(CharSequence s, int start, int before, int count) {}\r
+            \r
+        });\r
         mPasswordInput.setOnFocusChangeListener(this);\r
         mPasswordInput.setImeOptions(EditorInfo.IME_ACTION_DONE);\r
         mPasswordInput.setOnEditorActionListener(this);\r
@@ -396,6 +414,8 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
     private void onUrlInputFocusLost(TextView hostInput) {\r
         if (!mHostBaseUrl.equals(normalizeUrl(mHostUrlInput.getText().toString()))) {\r
             checkOcServer();\r
+        } else {\r
+            mOkButton.setEnabled(mServerIsValid);\r
         }\r
     }\r
 \r
@@ -622,7 +642,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
                 url = url.substring(0, url.length() - 1);\r
             }\r
         }\r
-        return url;\r
+        return (url != null ? url : "");\r
     }\r
 \r
     /**\r