Added notification for failures in manual synchronizations; some improvements in...
[pub/Android/ownCloud.git] / src / com / owncloud / android / ui / activity / AuthenticatorActivity.java
index a71f65b..4f4cb96 100644 (file)
@@ -41,6 +41,7 @@ import android.content.ContentResolver;
 import android.content.DialogInterface;\r
 import android.content.Intent;\r
 import android.content.SharedPreferences;\r
+import android.net.Uri;\r
 import android.os.Bundle;\r
 import android.os.Handler;\r
 import android.preference.PreferenceManager;\r
@@ -222,12 +223,17 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
 \r
             finish();\r
         } else {\r
-            dismissDialog(DIALOG_LOGIN_PROGRESS);\r
+            try {\r
+                dismissDialog(DIALOG_LOGIN_PROGRESS);\r
+            } catch (IllegalArgumentException e) {\r
+                // 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
             TextView tv = (TextView) findViewById(R.id.account_username);\r
             tv.setError(message);\r
         }\r
     }\r
     public void onCancelClick(View view) {\r
+        setResult(RESULT_CANCELED);\r
         finish();\r
     }\r
     \r
@@ -246,6 +252,12 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
         }\r
         continueConnection(prefix);\r
     }\r
+    \r
+    public void onRegisterClick(View view) {\r
+        Intent register = new Intent(Intent.ACTION_VIEW, Uri.parse("https://owncloud.com/mobile/new"));\r
+        setResult(RESULT_CANCELED);\r
+        startActivity(register);\r
+    }\r
 \r
     private void continueConnection(String prefix) {\r
         String url = ((TextView) findViewById(R.id.host_URL)).getText()\r
@@ -260,14 +272,19 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
         URL uri = null;\r
         String webdav_path = AccountUtils.getWebdavPath(mConnChkRunnable\r
                 .getDiscoveredVersion());\r
-\r
+        if (webdav_path == null) {\r
+            onAuthenticationResult(false, getString(R.string.auth_bad_oc_version_title));\r
+            return;\r
+        }\r
+        \r
         try {\r
             mBaseUrl = prefix + url;\r
             String url_str = prefix + url + webdav_path;\r
             uri = new URL(url_str);\r
         } catch (MalformedURLException e) {\r
-            // should not happen\r
-            e.printStackTrace();\r
+            // should never happen\r
+            onAuthenticationResult(false, getString(R.string.auth_incorrect_address_title));\r
+            return;\r
         }\r
 \r
         showDialog(DIALOG_LOGIN_PROGRESS);\r
@@ -366,7 +383,6 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
                 if (uri.length() != 0) {\r
                     setResultIconAndText(R.drawable.progress_small,\r
                             R.string.auth_testing_connection);\r
-                    findViewById(R.id.buttonOK).setEnabled(false);  // avoid connect can be clicked if the test was previously passed\r
                     mConnChkRunnable = new ConnectionCheckerRunnable(uri, this);\r
                     mConnChkRunnable.setListener(this, mHandler);\r
                     mAuthThread = new Thread(mConnChkRunnable);\r
@@ -376,6 +392,9 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
                             View.INVISIBLE);\r
                     setResultIconAndText(0, 0);\r
                 }\r
+            } else {\r
+                // avoids that the 'connect' button can be clicked if the test was previously passed\r
+                findViewById(R.id.buttonOK).setEnabled(false); \r
             }\r
         } else if (view.getId() == R.id.account_password) {\r
             ImageView iv = (ImageView) findViewById(R.id.viewPassword);\r