modify code to be simpler
[pub/Android/ownCloud.git] / src / com / owncloud / android / authentication / AuthenticatorActivity.java
index e7b3397..e8f42d9 100644 (file)
@@ -54,7 +54,6 @@ import android.view.MotionEvent;
 import android.view.View;\r
 import android.view.View.OnFocusChangeListener;\r
 import android.view.View.OnTouchListener;\r
 import android.view.View;\r
 import android.view.View.OnFocusChangeListener;\r
 import android.view.View.OnTouchListener;\r
-import android.view.Window;\r
 import android.view.inputmethod.EditorInfo;\r
 import android.webkit.HttpAuthHandler;\r
 import android.webkit.SslErrorHandler;\r
 import android.view.inputmethod.EditorInfo;\r
 import android.webkit.HttpAuthHandler;\r
 import android.webkit.SslErrorHandler;\r
@@ -348,11 +347,8 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
             if (mAccount != null) {\r
                 mServerInfo.mBaseUrl = mAccountMgr.getUserData(mAccount, Constants.KEY_OC_BASE_URL);\r
                 // TODO do next in a setter for mBaseUrl\r
             if (mAccount != null) {\r
                 mServerInfo.mBaseUrl = mAccountMgr.getUserData(mAccount, Constants.KEY_OC_BASE_URL);\r
                 // TODO do next in a setter for mBaseUrl\r
-                mServerInfo.mIsSslConn = mServerInfo.mBaseUrl.startsWith("https://");   \r
-                String ocVersion = mAccountMgr.getUserData(mAccount, Constants.KEY_OC_VERSION);\r
-                if (ocVersion != null) {\r
-                    mServerInfo.mVersion = new OwnCloudVersion(ocVersion);\r
-                }\r
+                mServerInfo.mIsSslConn = mServerInfo.mBaseUrl.startsWith("https://");\r
+                mServerInfo.mVersion = AccountUtils.getServerVersion(mAccount);\r
             } else {\r
                 mServerInfo.mBaseUrl = getString(R.string.server_url).trim();\r
                 mServerInfo.mIsSslConn = mServerInfo.mBaseUrl.startsWith("https://");\r
             } else {\r
                 mServerInfo.mBaseUrl = getString(R.string.server_url).trim();\r
                 mServerInfo.mIsSslConn = mServerInfo.mBaseUrl.startsWith("https://");\r
@@ -570,7 +566,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
      * intended to defer the processing of the redirection caught in \r
      * {@link #onNewIntent(Intent)} until {@link #onResume()} \r
      * \r
      * intended to defer the processing of the redirection caught in \r
      * {@link #onNewIntent(Intent)} until {@link #onResume()} \r
      * \r
-     * See {@link #onSaveInstanceState(Bundle)}\r
+     * See {@link super#onSaveInstanceState(Bundle)}\r
      */\r
     @Override\r
     protected void onSaveInstanceState(Bundle outState) {\r
      */\r
     @Override\r
     protected void onSaveInstanceState(Bundle outState) {\r
@@ -1136,7 +1132,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
         if(url.toLowerCase().endsWith(AccountUtils.WEBDAV_PATH_4_0_AND_LATER)){\r
             url = url.substring(0, url.length() - AccountUtils.WEBDAV_PATH_4_0_AND_LATER.length());\r
         }\r
         if(url.toLowerCase().endsWith(AccountUtils.WEBDAV_PATH_4_0_AND_LATER)){\r
             url = url.substring(0, url.length() - AccountUtils.WEBDAV_PATH_4_0_AND_LATER.length());\r
         }\r
-        return (url != null ? url : "");\r
+        return url;\r
     }\r
 \r
 \r
     }\r
 \r
 \r
@@ -1717,7 +1713,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
     }\r
 \r
 \r
     }\r
 \r
 \r
-    private void getRemoteUserNameOperation(String sessionCookie, boolean followRedirects) {\r
+    private void getRemoteUserNameOperation(String sessionCookie) {\r
         \r
         Intent getUserNameIntent = new Intent();\r
         getUserNameIntent.setAction(OperationsService.ACTION_GET_USER_NAME);\r
         \r
         Intent getUserNameIntent = new Intent();\r
         getUserNameIntent.setAction(OperationsService.ACTION_GET_USER_NAME);\r
@@ -1735,7 +1731,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
         if (sessionCookie != null && sessionCookie.length() > 0) {\r
             Log_OC.d(TAG, "Successful SSO - time to save the account");\r
             mAuthToken = sessionCookie;\r
         if (sessionCookie != null && sessionCookie.length() > 0) {\r
             Log_OC.d(TAG, "Successful SSO - time to save the account");\r
             mAuthToken = sessionCookie;\r
-            getRemoteUserNameOperation(sessionCookie, true);\r
+            getRemoteUserNameOperation(sessionCookie);\r
             Fragment fd = getSupportFragmentManager().findFragmentByTag(SAML_DIALOG_TAG);\r
             if (fd != null && fd instanceof DialogFragment) {\r
                 Dialog d = ((DialogFragment)fd).getDialog();\r
             Fragment fd = getSupportFragmentManager().findFragmentByTag(SAML_DIALOG_TAG);\r
             if (fd != null && fd instanceof DialogFragment) {\r
                 Dialog d = ((DialogFragment)fd).getDialog();\r
@@ -1769,7 +1765,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
             X509Certificate x509Certificate, SslError error, SslErrorHandler handler\r
         ) {\r
         // Show a dialog with the certificate info\r
             X509Certificate x509Certificate, SslError error, SslErrorHandler handler\r
         ) {\r
         // Show a dialog with the certificate info\r
-        SslUntrustedCertDialog dialog = null;\r
+        SslUntrustedCertDialog dialog;\r
         if (x509Certificate == null) {\r
             dialog = SslUntrustedCertDialog.newInstanceForEmptySslError(error, handler);\r
         } else {\r
         if (x509Certificate == null) {\r
             dialog = SslUntrustedCertDialog.newInstanceForEmptySslError(error, handler);\r
         } else {\r
@@ -1861,8 +1857,6 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
                 \r
                 doOnResumeAndBound();\r
                 \r
                 \r
                 doOnResumeAndBound();\r
                 \r
-            } else {\r
-                return;\r
             }\r
             \r
         }\r
             }\r
             \r
         }\r
@@ -1881,8 +1875,8 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
 \r
     /**\r
      * Create and show dialog for request authentication to the user\r
 \r
     /**\r
      * Create and show dialog for request authentication to the user\r
-     * @param webView\r
-     * @param handler\r
+     * @param webView   Web view to emebd into the authentication dialog.\r
+     * @param handler   Object responsible for catching and recovering HTTP authentication fails.\r
      */\r
     public void createAuthenticationDialog(WebView webView, HttpAuthHandler handler) {\r
 \r
      */\r
     public void createAuthenticationDialog(WebView webView, HttpAuthHandler handler) {\r
 \r