mServerCheckedAndValid = false;\r
mOkButton.setEnabled(false);\r
mDiscoveredVersion = null;\r
+ hideRefreshButton();\r
if (uri.length() != 0) {\r
mServerStatusText = R.string.auth_testing_connection;\r
mServerStatusIcon = R.drawable.progress_small;\r
WebdavClient client = OwnCloudClientUtils.createOwnCloudClient(Uri.parse(uri), this);\r
mOperationThread = mOcServerChkOperation.execute(client, this, mHandler);\r
} else {\r
- mHostUrlInput.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0);\r
mServerStatusText = 0;\r
mServerStatusIcon = 0;\r
showServerStatus();\r
*/\r
private void startOauthorization() {\r
// be gentle with the user\r
- mServerStatusIcon = R.drawable.progress_small;\r
- mServerStatusText = R.string.oauth_login_connection;\r
+ mAuthStatusIcon = R.drawable.progress_small;\r
+ mAuthStatusText = R.string.oauth_login_connection;\r
showAuthStatus();\r
\r
// GET AUTHORIZATION request\r
mOcServerChkOperation = null;\r
\r
/// update status icon and text\r
- updateStatusIconAndText(result);\r
+ if (mServerCheckedAndValid) {\r
+ hideRefreshButton();\r
+ } else {\r
+ showRefreshButton();\r
+ }\r
+ updateServerStatusIconAndText(result);\r
showServerStatus();\r
\r
/// very special case (TODO: move to a common place for all the remote operations)\r
showDialog(DIALOG_SSL_VALIDATOR); \r
}\r
\r
- /// update the visibility of the 'retry connection' button\r
- if (!mServerCheckedAndValid) {\r
- mHostUrlInput.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.ic_action_refresh_black, 0);\r
- } else {\r
- mHostUrlInput.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0);\r
- }\r
- \r
/// retrieve discovered version and normalize server URL\r
mDiscoveredVersion = operation.getDiscoveredVersion();\r
mHostBaseUrl = normalizeUrl(mHostUrlInput.getText().toString());\r
* \r
* @param result Result of a remote operation performed in this activity\r
*/\r
- private void updateStatusIconAndText(RemoteOperationResult result) {\r
- mServerStatusText = mServerStatusIcon = 0;\r
+ private void updateServerStatusIconAndText(RemoteOperationResult result) {\r
+ mServerStatusIcon = R.drawable.common_error; // the most common case in the switch below\r
\r
switch (result.getCode()) {\r
case OK_SSL:\r
}\r
break;\r
\r
+ case NO_NETWORK_CONNECTION:\r
+ mServerStatusIcon = R.drawable.no_network;\r
+ mServerStatusText = R.string.auth_no_net_conn_title;\r
+ break;\r
+ \r
case SSL_RECOVERABLE_PEER_UNVERIFIED:\r
- mServerStatusIcon = R.drawable.common_error;\r
mServerStatusText = R.string.auth_ssl_unverified_server_title;\r
break;\r
- \r
case BAD_OC_VERSION:\r
- mServerStatusIcon = R.drawable.common_error;\r
mServerStatusText = R.string.auth_bad_oc_version_title;\r
break;\r
case WRONG_CONNECTION:\r
- mServerStatusIcon = R.drawable.common_error;\r
mServerStatusText = R.string.auth_wrong_connection_title;\r
break;\r
case TIMEOUT:\r
- mServerStatusIcon = R.drawable.common_error;\r
mServerStatusText = R.string.auth_timeout_title;\r
break;\r
case INCORRECT_ADDRESS:\r
- mServerStatusIcon = R.drawable.common_error;\r
mServerStatusText = R.string.auth_incorrect_address_title;\r
break;\r
- \r
case SSL_ERROR:\r
- mServerStatusIcon = R.drawable.common_error;\r
mServerStatusText = R.string.auth_ssl_general_error_title;\r
break;\r
- \r
case UNAUTHORIZED:\r
- mServerStatusIcon = R.drawable.common_error;\r
mServerStatusText = R.string.auth_unauthorized;\r
break;\r
case HOST_NOT_AVAILABLE:\r
- mServerStatusIcon = R.drawable.common_error;\r
mServerStatusText = R.string.auth_unknown_host_title;\r
break;\r
- case NO_NETWORK_CONNECTION:\r
- mServerStatusIcon = R.drawable.no_network;\r
- mServerStatusText = R.string.auth_no_net_conn_title;\r
- break;\r
case INSTANCE_NOT_CONFIGURED:\r
- mServerStatusIcon = R.drawable.common_error;\r
mServerStatusText = R.string.auth_not_configured_title;\r
break;\r
case FILE_NOT_FOUND:\r
- mServerStatusIcon = R.drawable.common_error;\r
mServerStatusText = R.string.auth_incorrect_path_title;\r
break;\r
case OAUTH2_ERROR:\r
- mServerStatusIcon = R.drawable.common_error;\r
mServerStatusText = R.string.auth_oauth_error;\r
break;\r
case OAUTH2_ERROR_ACCESS_DENIED:\r
- mServerStatusIcon = R.drawable.common_error;\r
mServerStatusText = R.string.auth_oauth_error_access_denied;\r
break;\r
case UNHANDLED_HTTP_CODE:\r
case UNKNOWN_ERROR:\r
- mServerStatusIcon = R.drawable.common_error;\r
mServerStatusText = R.string.auth_unknown_error_title;\r
break;\r
- \r
default:\r
+ mServerStatusText = 0;\r
+ mServerStatusIcon = 0;\r
+ }\r
+ }\r
+\r
+\r
+ /**\r
+ * Chooses the right icon and text to show to the user for the received operation result.\r
+ * \r
+ * @param result Result of a remote operation performed in this activity\r
+ */\r
+ private void updateAuthStatusIconAndText(RemoteOperationResult result) {\r
+ mAuthStatusIcon = R.drawable.common_error; // the most common case in the switch below\r
+\r
+ switch (result.getCode()) {\r
+ case OK_SSL:\r
+ mAuthStatusIcon = android.R.drawable.ic_secure;\r
+ mAuthStatusText = R.string.auth_secure_connection;\r
break;\r
+ \r
+ case OK_NO_SSL:\r
+ case OK:\r
+ if (mHostUrlInput.getText().toString().trim().toLowerCase().startsWith("http://") ) {\r
+ mAuthStatusText = R.string.auth_connection_established;\r
+ mAuthStatusIcon = R.drawable.ic_ok;\r
+ } else {\r
+ mAuthStatusText = R.string.auth_nossl_plain_ok_title;\r
+ mAuthStatusIcon = android.R.drawable.ic_partial_secure;\r
+ }\r
+ break;\r
+ \r
+ case NO_NETWORK_CONNECTION:\r
+ mAuthStatusIcon = R.drawable.no_network;\r
+ mAuthStatusText = R.string.auth_no_net_conn_title;\r
+ break;\r
+ \r
+ case SSL_RECOVERABLE_PEER_UNVERIFIED:\r
+ mAuthStatusText = R.string.auth_ssl_unverified_server_title;\r
+ break;\r
+ case BAD_OC_VERSION:\r
+ mAuthStatusText = R.string.auth_bad_oc_version_title;\r
+ break;\r
+ case WRONG_CONNECTION:\r
+ mAuthStatusText = R.string.auth_wrong_connection_title;\r
+ break;\r
+ case TIMEOUT:\r
+ mAuthStatusText = R.string.auth_timeout_title;\r
+ break;\r
+ case INCORRECT_ADDRESS:\r
+ mAuthStatusText = R.string.auth_incorrect_address_title;\r
+ break;\r
+ case SSL_ERROR:\r
+ mAuthStatusText = R.string.auth_ssl_general_error_title;\r
+ break;\r
+ case UNAUTHORIZED:\r
+ mAuthStatusText = R.string.auth_unauthorized;\r
+ break;\r
+ case HOST_NOT_AVAILABLE:\r
+ mAuthStatusText = R.string.auth_unknown_host_title;\r
+ break;\r
+ case INSTANCE_NOT_CONFIGURED:\r
+ mAuthStatusText = R.string.auth_not_configured_title;\r
+ break;\r
+ case FILE_NOT_FOUND:\r
+ mAuthStatusText = R.string.auth_incorrect_path_title;\r
+ break;\r
+ case OAUTH2_ERROR:\r
+ mAuthStatusText = R.string.auth_oauth_error;\r
+ break;\r
+ case OAUTH2_ERROR_ACCESS_DENIED:\r
+ mAuthStatusText = R.string.auth_oauth_error_access_denied;\r
+ break;\r
+ case UNHANDLED_HTTP_CODE:\r
+ case UNKNOWN_ERROR:\r
+ mAuthStatusText = R.string.auth_unknown_error_title;\r
+ break;\r
+ default:\r
+ mAuthStatusText = 0;\r
+ mAuthStatusIcon = 0;\r
}\r
}\r
\r
mAuthCheckOperation.execute(client, this, mHandler);\r
\r
} else {\r
- updateStatusIconAndText(result);\r
+ updateAuthStatusIconAndText(result);\r
showAuthStatus();\r
Log_OC.d(TAG, "Access failed: " + result.getLogMessage());\r
}\r
finish();\r
\r
} else {\r
- updateStatusIconAndText(result);\r
+ updateAuthStatusIconAndText(result);\r
showAuthStatus();\r
Log_OC.d(TAG, "Access failed: " + result.getLogMessage());\r
}\r
\r
if (mServerStatusIcon == 0 && mServerStatusText == 0) {\r
tv.setVisibility(View.INVISIBLE);\r
+ \r
} else {\r
tv.setText(mServerStatusText);\r
tv.setCompoundDrawablesWithIntrinsicBounds(mServerStatusIcon, 0, 0, 0);\r
tv.setVisibility(View.VISIBLE);\r
}\r
+ \r
}\r
\r
\r
private void showAuthStatus() {\r
if (mAuthStatusIcon == 0 && mAuthStatusText == 0) {\r
mAuthStatusLayout.setVisibility(View.INVISIBLE);\r
+ \r
} else {\r
mAuthStatusLayout.setText(mAuthStatusText);\r
mAuthStatusLayout.setCompoundDrawablesWithIntrinsicBounds(mAuthStatusIcon, 0, 0, 0);\r
} \r
\r
\r
+ private void showRefreshButton() {\r
+ mHostUrlInput.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.ic_action_refresh_black, 0);\r
+ }\r
+ \r
+ private void hideRefreshButton() {\r
+ mHostUrlInput.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0);\r
+ }\r
+ \r
/**\r
* Called when the refresh button in the input field for ownCloud host is clicked.\r
* \r