From: David A. Velasco Date: Wed, 19 Jun 2013 15:02:50 +0000 (-0700) Subject: Merge pull request #186 from owncloud/fixed_contradicted_messages_in_login_view X-Git-Tag: oc-android-1.4.3~15^2 X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/commitdiff_plain/5dc43aab3cc1243f9989dd6a0c7dd3350c3f709b?hp=-c Merge pull request #186 from owncloud/fixed_contradicted_messages_in_login_view Fixed contradicted messages in login view --- 5dc43aab3cc1243f9989dd6a0c7dd3350c3f709b diff --combined src/com/owncloud/android/authentication/AuthenticatorActivity.java index e4839707,c1ca6050..3c34be61 --- a/src/com/owncloud/android/authentication/AuthenticatorActivity.java +++ b/src/com/owncloud/android/authentication/AuthenticatorActivity.java @@@ -97,7 -97,6 +97,7 @@@ implements OnRemoteOperationListener, private static final String KEY_PASSWORD_VISIBLE = "PASSWORD_VISIBLE"; private static final String KEY_AUTH_STATUS_TEXT = "AUTH_STATUS_TEXT"; private static final String KEY_AUTH_STATUS_ICON = "AUTH_STATUS_ICON"; + private static final String KEY_REFRESH_BUTTON_ENABLED = "KEY_REFRESH_BUTTON_ENABLED"; private static final String OAUTH_MODE_ON = "on"; private static final String OAUTH_MODE_OFF = "off"; @@@ -110,7 -109,8 +110,7 @@@ public static final byte ACTION_CREATE = 0; public static final byte ACTION_UPDATE_TOKEN = 1; - - + private String mHostBaseUrl; private OwnCloudVersion mDiscoveredVersion; @@@ -141,8 -141,6 +141,8 @@@ private TextView mOAuthAuthEndpointText; private TextView mOAuthTokenEndpointText; + + private boolean mRefreshButtonEnabled; /** @@@ -233,16 -231,13 +233,16 @@@ // check if server check was interrupted by a configuration change if (savedInstanceState.getBoolean(KEY_SERVER_CHECK_IN_PROGRESS, false)) { checkOcServer(); - } + } + + // refresh button enabled + mRefreshButtonEnabled = savedInstanceState.getBoolean(KEY_REFRESH_BUTTON_ENABLED); } showServerStatus(); showAuthStatus(); - if (mServerIsChecked && !mServerIsValid) showRefreshButton(); + if (mServerIsChecked && !mServerIsValid && mRefreshButtonEnabled) showRefreshButton(); mOkButton.setEnabled(mServerIsValid); // state not automatically recovered in configuration changes if (!OAUTH_MODE_OPTIONAL.equals(getString(R.string.oauth2_mode))) { @@@ -291,7 -286,7 +291,7 @@@ }); mPasswordInput.setOnFocusChangeListener(this); mPasswordInput.setImeOptions(EditorInfo.IME_ACTION_DONE); - mPasswordInput.setOnEditorActionListener(this); + mPasswordInput.setOnEditorActionListener(this); mPasswordInput.setOnTouchListener(new RightDrawableOnTouchListener() { @Override public boolean onDrawableTouch(final MotionEvent event) { @@@ -300,7 -295,7 +300,7 @@@ } return true; } - }); + }); } /** @@@ -336,9 -331,6 +336,9 @@@ if (mAccount != null) { outState.putParcelable(KEY_ACCOUNT, mAccount); } + + // refresh button enabled + outState.putBoolean(KEY_REFRESH_BUTTON_ENABLED, mRefreshButtonEnabled); } @@@ -415,9 -407,6 +415,9 @@@ if (view.getId() == R.id.hostUrlInput) { if (!hasFocus) { onUrlInputFocusLost((TextView) view); + if (!mServerIsValid) { + showRefreshButton(); + } } else { hideRefreshButton(); @@@ -450,7 -439,7 +450,7 @@@ private void checkOcServer() { - String uri = mHostUrlInput.getText().toString().trim(); + String uri = trimUrlWebdav(mHostUrlInput.getText().toString().trim()); mServerIsValid = false; mServerIsChecked = false; mOkButton.setEnabled(false); @@@ -692,33 -681,15 +692,33 @@@ } else { url = "http://" + url; } - } + + // OC-208: Add suffix remote.php/webdav to normalize (OC-34) + url = trimUrlWebdav(url); + if (url.endsWith("/")) { url = url.substring(0, url.length() - 1); } + } + Log_OC.d(TAG, "URL Normalize " + url); return (url != null ? url : ""); } + + private String trimUrlWebdav(String url){ + if(url.toLowerCase().endsWith(AccountUtils.WEBDAV_PATH_4_0)){ + url = url.substring(0, url.length() - AccountUtils.WEBDAV_PATH_4_0.length()); + } else if(url.toLowerCase().endsWith(AccountUtils.WEBDAV_PATH_2_0)){ + url = url.substring(0, url.length() - AccountUtils.WEBDAV_PATH_2_0.length()); + } else if (url.toLowerCase().endsWith(AccountUtils.WEBDAV_PATH_1_2)){ + url = url.substring(0, url.length() - AccountUtils.WEBDAV_PATH_1_2.length()); + } + return (url != null ? url : ""); + } + + /** * Chooses the right icon and text to show to the user for the received operation result. * @@@ -935,7 -906,33 +935,33 @@@ finish(); - } else { + } else if (result.isServerFail() || result.isException()) { + /// if server fail or exception in authorization, the UI is updated as when a server check failed + mServerIsChecked = true; + mServerIsValid = false; + mIsSslConn = false; + mOcServerChkOperation = null; + mDiscoveredVersion = null; + mHostBaseUrl = normalizeUrl(mHostUrlInput.getText().toString()); + + // update status icon and text + updateServerStatusIconAndText(result); + showServerStatus(); + mAuthStatusIcon = 0; + mAuthStatusText = 0; + showAuthStatus(); + + // update input controls state + showRefreshButton(); + mOkButton.setEnabled(false); + + // very special case (TODO: move to a common place for all the remote operations) (dangerous here?) + if (result.getCode() == ResultCode.SSL_RECOVERABLE_PEER_UNVERIFIED) { + mLastSslUntrustedServerResult = result; + showDialog(DIALOG_SSL_VALIDATOR); + } + + } else { // authorization fail due to client side - probably wrong credentials updateAuthStatusIconAndText(result); showAuthStatus(); Log_OC.d(TAG, "Access failed: " + result.getLogMessage()); @@@ -1169,12 -1166,10 +1195,12 @@@ private void showRefreshButton() { mHostUrlInput.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.ic_action_refresh_black, 0); + mRefreshButtonEnabled = true; } private void hideRefreshButton() { mHostUrlInput.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0); + mRefreshButtonEnabled = false; } /**