More robust instant photo uploads
[pub/Android/ownCloud.git] / src / com / owncloud / android / ui / activity / AuthenticatorActivity.java
index 4aa7cdd..a109809 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
@@ -228,13 +229,14 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
         }\r
     }\r
     public void onCancelClick(View view) {\r
+        setResult(RESULT_CANCELED);\r
         finish();\r
     }\r
     \r
     public void onOkClick(View view) {\r
         String prefix = "";\r
         String url = ((TextView) findViewById(R.id.host_URL)).getText()\r
-                .toString();\r
+                .toString().trim();\r
         if (mIsSslConn) {\r
             prefix = "https://";\r
         } else {\r
@@ -246,10 +248,16 @@ 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
-                .toString();\r
+                .toString().trim();\r
         String username = ((TextView) findViewById(R.id.account_username))\r
                 .getText().toString();\r
         String password = ((TextView) findViewById(R.id.account_password))\r
@@ -266,7 +274,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
             String url_str = prefix + url + webdav_path;\r
             uri = new URL(url_str);\r
         } catch (MalformedURLException e) {\r
-            // should not happend\r
+            // should not happen\r
             e.printStackTrace();\r
         }\r
 \r
@@ -282,7 +290,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
         mStatusText = mStatusIcon = 0;\r
         mStatusCorrect = false;\r
         String t_url = ((TextView) findViewById(R.id.host_URL)).getText()\r
-                .toString().toLowerCase();\r
+                .toString().trim().toLowerCase();\r
 \r
         switch (type) {\r
         case OK_SSL:\r
@@ -302,12 +310,33 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
                 mStatusIcon = android.R.drawable.ic_partial_secure;\r
             }\r
             break;\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
-        case INORRECT_ADDRESS:\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
+        case SSL_UNVERIFIED_SERVER:\r
+            mStatusIcon = R.drawable.common_error;\r
+            mStatusText = R.string.auth_ssl_unverified_server_title;\r
+            break;\r
         case SSL_INIT_ERROR:\r
+            mStatusIcon = R.drawable.common_error;\r
+            mStatusText = R.string.auth_ssl_general_error_title;\r
+            break;\r
         case HOST_NOT_AVAILABLE:\r
             mStatusIcon = R.drawable.common_error;\r
-            mStatusText = R.string.auth_unknow_host_title;\r
+            mStatusText = R.string.auth_unknown_host_title;\r
             break;\r
         case NO_NETWORK_CONNECTION:\r
             mStatusIcon = R.drawable.no_network;\r
@@ -319,7 +348,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
             break;\r
         case UNKNOWN_ERROR:\r
             mStatusIcon = R.drawable.common_error;\r
-            mStatusText = R.string.auth_unknow_error;\r
+            mStatusText = R.string.auth_unknown_error_title;\r
             break;\r
         case FILE_NOT_FOUND:\r
             mStatusIcon = R.drawable.common_error;\r
@@ -341,7 +370,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
         if (view.getId() == R.id.host_URL) {\r
             if (!hasFocus) {\r
                 TextView tv = ((TextView) findViewById(R.id.host_URL));\r
-                String uri = tv.getText().toString();\r
+                String uri = tv.getText().toString().trim();\r
                 if (uri.length() != 0) {\r
                     setResultIconAndText(R.drawable.progress_small,\r
                             R.string.auth_testing_connection);\r