Merge branch 'develop' into refactor_update_filelist_from_database
[pub/Android/ownCloud.git] / src / com / owncloud / android / authentication / AuthenticatorActivity.java
index e0a0ba9..32bbcdc 100644 (file)
@@ -114,7 +114,7 @@ SsoWebViewClientListener, OnSslUntrustedCertListener {
     private static final String KEY_AUTH_STATUS_TEXT = "AUTH_STATUS_TEXT";\r
     private static final String KEY_AUTH_STATUS_ICON = "AUTH_STATUS_ICON";\r
     private static final String KEY_SERVER_AUTH_METHOD = "SERVER_AUTH_METHOD";\r
-    private static final String KEY_WAITING_FOR_OP_ID = "DETECT_AUTH_OP_ID";\r
+    private static final String KEY_WAITING_FOR_OP_ID = "WAITING_FOR_OP_ID";\r
     private static final String KEY_AUTH_TOKEN = "AUTH_TOKEN";\r
 \r
     private static final String AUTH_ON = "on";\r
@@ -153,6 +153,7 @@ SsoWebViewClientListener, OnSslUntrustedCertListener {
     \r
     private boolean mServerIsChecked = false;\r
     private boolean mServerIsValid = false;\r
+    private boolean mPendingAutoCheck = false;\r
 \r
     private GetServerInfoOperation.ServerInfo mServerInfo = \r
             new GetServerInfoOperation.ServerInfo();\r
@@ -174,7 +175,7 @@ SsoWebViewClientListener, OnSslUntrustedCertListener {
     \r
     /// Identifier of operation in progress which result shouldn't be lost \r
     private long mWaitingForOpId = Long.MAX_VALUE;\r
-    \r
+\r
     \r
     /**\r
      * {@inheritDoc}\r
@@ -219,6 +220,8 @@ SsoWebViewClientListener, OnSslUntrustedCertListener {
         /// initialize general UI elements\r
         initOverallUi(savedInstanceState);\r
         \r
+        mOkButton = findViewById(R.id.buttonOK);\r
+\r
         /// initialize block to be moved to single Fragment to check server and get info about it \r
         initServerPreFragment(savedInstanceState);\r
         \r
@@ -404,12 +407,9 @@ SsoWebViewClientListener, OnSslUntrustedCertListener {
         });\r
      \r
         \r
-        /// step 4 - automatic actions to start\r
-        if (savedInstanceState == null) {\r
-            if (mAction != ACTION_CREATE || !isUrlInputAllowed) {\r
-                checkOcServer(); \r
-            }\r
-        }\r
+        /// step 4 - mark automatic check to be started when OperationsService is ready\r
+        mPendingAutoCheck = (savedInstanceState == null && \r
+                (mAction != ACTION_CREATE || !isUrlInputAllowed));\r
     }\r
     \r
     \r
@@ -426,7 +426,6 @@ SsoWebViewClientListener, OnSslUntrustedCertListener {
         mUsernameInput = (EditText) findViewById(R.id.account_username);\r
         mPasswordInput = (EditText) findViewById(R.id.account_password);\r
         mAuthStatusView = (TextView) findViewById(R.id.auth_status_text); \r
-        mOkButton = findViewById(R.id.buttonOK);\r
         \r
         /// step 1 - load and process relevant inputs (resources, intent, savedInstanceState)\r
         String presetUserName = null;\r
@@ -728,6 +727,8 @@ SsoWebViewClientListener, OnSslUntrustedCertListener {
             if (mOperationsServiceBinder != null) {\r
                 //Log_OC.wtf(TAG, "checking server..." );\r
                 mWaitingForOpId = mOperationsServiceBinder.newOperation(getServerInfoIntent);\r
+            } else {\r
+              Log_OC.wtf(TAG, "Server check tried with OperationService unbound!" );\r
             }\r
             \r
         } else {\r
@@ -1744,6 +1745,10 @@ SsoWebViewClientListener, OnSslUntrustedCertListener {
         if (mWaitingForOpId <= Integer.MAX_VALUE) {\r
             mOperationsServiceBinder.dispatchResultIfFinished((int)mWaitingForOpId, this);\r
         }\r
+        \r
+        if (mPendingAutoCheck) {\r
+            checkOcServer();\r
+        }\r
     }\r
 \r
     \r