X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/blobdiff_plain/fe1b334ce6b23d495f10ba0240ab3892793fa0bc..9dc5a62e44952bdfb972bd46ff4b92ed2cba3d74:/src/com/owncloud/android/authentication/AuthenticatorActivity.java diff --git a/src/com/owncloud/android/authentication/AuthenticatorActivity.java b/src/com/owncloud/android/authentication/AuthenticatorActivity.java index 07c9d537..cc1adcf3 100644 --- a/src/com/owncloud/android/authentication/AuthenticatorActivity.java +++ b/src/com/owncloud/android/authentication/AuthenticatorActivity.java @@ -61,7 +61,6 @@ import android.view.inputmethod.EditorInfo; import android.widget.CheckBox; import android.widget.EditText; import android.widget.Button; -import android.widget.ImageView; import android.widget.TextView; import android.widget.Toast; import android.widget.TextView.OnEditorActionListener; @@ -89,11 +88,13 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity private static final String KEY_HOST_URL_TEXT = "HOST_URL_TEXT"; private static final String KEY_OC_VERSION = "OC_VERSION"; private static final String KEY_ACCOUNT = "ACCOUNT"; - private static final String KEY_SERVER_CHECKED_AND_VALID = "SERVER_CHECKED_AND_VALID"; + private static final String KEY_SERVER_VALID = "SERVER_VALID"; + private static final String KEY_SERVER_CHECKED = "SERVER_CHECKED"; private static final String KEY_SERVER_CHECK_IN_PROGRESS = "SERVER_CHECK_IN_PROGRESS"; private static final String KEY_SERVER_STATUS_TEXT = "SERVER_STATUS_TEXT"; private static final String KEY_SERVER_STATUS_ICON = "SERVER_STATUS_ICON"; private static final String KEY_IS_SSL_CONN = "IS_SSL_CONN"; + 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"; @@ -114,7 +115,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity private OwnCloudVersion mDiscoveredVersion; private int mServerStatusText, mServerStatusIcon; - private boolean mServerCheckedAndValid, mIsSslConn; + private boolean mServerIsChecked, mServerIsValid, mIsSslConn; private int mAuthStatusText, mAuthStatusIcon; private final Handler mHandler = new Handler(); @@ -130,7 +131,6 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity private byte mAction; private Account mAccount; - private ImageView mViewPasswordButton; private EditText mHostUrlInput; private EditText mUsernameInput; private EditText mPasswordInput; @@ -142,8 +142,6 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity private TextView mOAuthAuthEndpointText; private TextView mOAuthTokenEndpointText; - private HostUrlWatcher mHostUrlChangedListener; - /** * {@inheritDoc} @@ -157,7 +155,6 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity /// set view and get references to view elements setContentView(R.layout.account_setup); - mViewPasswordButton = (ImageView) findViewById(R.id.viewPasswordButton); mHostUrlInput = (EditText) findViewById(R.id.hostUrlInput); mUsernameInput = (EditText) findViewById(R.id.account_username); mPasswordInput = (EditText) findViewById(R.id.account_password); @@ -183,7 +180,8 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity if (savedInstanceState == null) { /// connection state and info mServerStatusText = mServerStatusIcon = 0; - mServerCheckedAndValid = false; + mServerIsValid = false; + mServerIsChecked = false; mIsSslConn = false; mAuthStatusText = mAuthStatusIcon = 0; @@ -209,12 +207,16 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity } else { /// connection state and info - mServerCheckedAndValid = savedInstanceState.getBoolean(KEY_SERVER_CHECKED_AND_VALID); + mServerIsValid = savedInstanceState.getBoolean(KEY_SERVER_VALID); + mServerIsChecked = savedInstanceState.getBoolean(KEY_SERVER_CHECKED); mServerStatusText = savedInstanceState.getInt(KEY_SERVER_STATUS_TEXT); mServerStatusIcon = savedInstanceState.getInt(KEY_SERVER_STATUS_ICON); mIsSslConn = savedInstanceState.getBoolean(KEY_IS_SSL_CONN); mAuthStatusText = savedInstanceState.getInt(KEY_AUTH_STATUS_TEXT); mAuthStatusIcon = savedInstanceState.getInt(KEY_AUTH_STATUS_ICON); + if (savedInstanceState.getBoolean(KEY_PASSWORD_VISIBLE, false)) { + showPassword(); + } /// server data String ocVersion = savedInstanceState.getString(KEY_OC_VERSION); @@ -235,6 +237,8 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity showServerStatus(); showAuthStatus(); + if (mServerIsChecked && !mServerIsValid) showRefreshButton(); + mOkButton.setEnabled(mServerIsValid); // state not automatically recovered in configuration changes if (!OAUTH_MODE_OPTIONAL.equals(getString(R.string.oauth2_mode))) { mOAuth2Check.setVisibility(View.GONE); @@ -245,7 +249,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity mHostUrlInput.setEnabled(false); mUsernameInput.setEnabled(false); mOAuth2Check.setVisibility(View.GONE); - if (!mServerCheckedAndValid && mOcServerChkOperation == null) { + if (!mServerIsValid && mOcServerChkOperation == null) { checkOcServer(); } } @@ -258,29 +262,42 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity mHostUrlInput.setOnTouchListener(new RightDrawableOnTouchListener() { @Override public boolean onDrawableTouch(final MotionEvent event) { - AuthenticatorActivity.this.onRefreshClick(mHostUrlInput); + if (event.getAction() == MotionEvent.ACTION_UP) { + AuthenticatorActivity.this.onRefreshClick(); + } return true; } }); + mHostUrlInput.addTextChangedListener(new TextWatcher() { + + @Override + public void afterTextChanged(Editable s) { + if (!mHostBaseUrl.equals(normalizeUrl(mHostUrlInput.getText().toString()))) { + mOkButton.setEnabled(false); + } + } + + @Override + public void beforeTextChanged(CharSequence s, int start, int count, int after) {} + + @Override + public void onTextChanged(CharSequence s, int start, int before, int count) {} + + }); mPasswordInput.setOnFocusChangeListener(this); mPasswordInput.setImeOptions(EditorInfo.IME_ACTION_DONE); mPasswordInput.setOnEditorActionListener(this); + mPasswordInput.setOnTouchListener(new RightDrawableOnTouchListener() { + @Override + public boolean onDrawableTouch(final MotionEvent event) { + if (event.getAction() == MotionEvent.ACTION_UP) { + AuthenticatorActivity.this.onViewPasswordClick(); + } + return true; + } + }); } - @Override - protected void onStart() { - super.onStart(); - //mHostUrlChangedListener = new HostUrlWatcher(); - //mHostUrlInput.addTextChangedListener(mHostUrlChangedListener); - } - - @Override - protected void onStop() { - super.onStop(); - mHostUrlInput.removeTextChangedListener(mHostUrlChangedListener); - } - - /** * Saves relevant state before {@link #onPause()} * @@ -296,9 +313,11 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity /// connection state and info outState.putInt(KEY_SERVER_STATUS_TEXT, mServerStatusText); outState.putInt(KEY_SERVER_STATUS_ICON, mServerStatusIcon); - outState.putBoolean(KEY_SERVER_CHECKED_AND_VALID, mServerCheckedAndValid); - outState.putBoolean(KEY_SERVER_CHECK_IN_PROGRESS, (!mServerCheckedAndValid && mOcServerChkOperation != null)); + outState.putBoolean(KEY_SERVER_VALID, mServerIsValid); + outState.putBoolean(KEY_SERVER_CHECKED, mServerIsChecked); + outState.putBoolean(KEY_SERVER_CHECK_IN_PROGRESS, (!mServerIsValid && mOcServerChkOperation != null)); outState.putBoolean(KEY_IS_SSL_CONN, mIsSslConn); + outState.putBoolean(KEY_PASSWORD_VISIBLE, isPasswordVisible()); outState.putInt(KEY_AUTH_STATUS_ICON, mAuthStatusIcon); outState.putInt(KEY_AUTH_STATUS_TEXT, mAuthStatusText); @@ -408,15 +427,19 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity private void onUrlInputFocusLost(TextView hostInput) { if (!mHostBaseUrl.equals(normalizeUrl(mHostUrlInput.getText().toString()))) { checkOcServer(); + } else { + mOkButton.setEnabled(mServerIsValid); } } private void checkOcServer() { String uri = mHostUrlInput.getText().toString().trim(); - mServerCheckedAndValid = false; + mServerIsValid = false; + mServerIsChecked = false; mOkButton.setEnabled(false); mDiscoveredVersion = null; + hideRefreshButton(); if (uri.length() != 0) { mServerStatusText = R.string.auth_testing_connection; mServerStatusIcon = R.drawable.progress_small; @@ -425,7 +448,6 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity WebdavClient client = OwnCloudClientUtils.createOwnCloudClient(Uri.parse(uri), this); mOperationThread = mOcServerChkOperation.execute(client, this, mHandler); } else { - mHostUrlInput.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0); mServerStatusText = 0; mServerStatusIcon = 0; showServerStatus(); @@ -445,15 +467,42 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity */ private void onPasswordFocusChanged(TextView passwordInput, boolean hasFocus) { if (hasFocus) { - mViewPasswordButton.setVisibility(View.VISIBLE); + showViewPasswordButton(); } else { - int input_type = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD; - passwordInput.setInputType(input_type); - mViewPasswordButton.setVisibility(View.INVISIBLE); + hidePassword(); + hidePasswordButton(); + } + } + + + private void showViewPasswordButton() { + //int drawable = android.R.drawable.ic_menu_view; + int drawable = R.drawable.ic_view; + if (isPasswordVisible()) { + //drawable = android.R.drawable.ic_secure; + drawable = R.drawable.ic_hide; } + mPasswordInput.setCompoundDrawablesWithIntrinsicBounds(0, 0, drawable, 0); } + private boolean isPasswordVisible() { + return ((mPasswordInput.getInputType() & InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD) == InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD); + } + + private void hidePasswordButton() { + mPasswordInput.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0); + } + private void showPassword() { + mPasswordInput.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD); + showViewPasswordButton(); + } + + private void hidePassword() { + mPasswordInput.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD); + showViewPasswordButton(); + } + /** * Cancels the authenticator activity @@ -534,8 +583,8 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity */ private void startOauthorization() { // be gentle with the user - mServerStatusIcon = R.drawable.progress_small; - mServerStatusText = R.string.oauth_login_connection; + mAuthStatusIcon = R.drawable.progress_small; + mAuthStatusText = R.string.oauth_login_connection; showAuthStatus(); // GET AUTHORIZATION request @@ -585,12 +634,18 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity private void onOcServerCheckFinish(OwnCloudServerCheckOperation operation, RemoteOperationResult result) { if (operation.equals(mOcServerChkOperation)) { /// save result state - mServerCheckedAndValid = result.isSuccess(); + mServerIsChecked = true; + mServerIsValid = result.isSuccess(); mIsSslConn = (result.getCode() == ResultCode.OK_SSL); mOcServerChkOperation = null; /// update status icon and text - updateStatusIconAndText(result); + if (mServerIsValid) { + hideRefreshButton(); + } else { + showRefreshButton(); + } + updateServerStatusIconAndText(result); showServerStatus(); /// very special case (TODO: move to a common place for all the remote operations) @@ -599,19 +654,12 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity showDialog(DIALOG_SSL_VALIDATOR); } - /// update the visibility of the 'retry connection' button - if (!mServerCheckedAndValid) { - mHostUrlInput.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.ic_action_refresh_black, 0); - } else { - mHostUrlInput.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0); - } - /// retrieve discovered version and normalize server URL mDiscoveredVersion = operation.getDiscoveredVersion(); mHostBaseUrl = normalizeUrl(mHostUrlInput.getText().toString()); /// allow or not the user try to access the server - mOkButton.setEnabled(mServerCheckedAndValid); + mOkButton.setEnabled(mServerIsValid); } // else nothing ; only the last check operation is considered; // multiple can be triggered if the user amends a URL before a previous check can be triggered @@ -634,7 +682,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity url = url.substring(0, url.length() - 1); } } - return url; + return (url != null ? url : ""); } /** @@ -642,8 +690,8 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity * * @param result Result of a remote operation performed in this activity */ - private void updateStatusIconAndText(RemoteOperationResult result) { - mServerStatusText = mServerStatusIcon = 0; + private void updateServerStatusIconAndText(RemoteOperationResult result) { + mServerStatusIcon = R.drawable.common_error; // the most common case in the switch below switch (result.getCode()) { case OK_SSL: @@ -662,69 +710,131 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity } break; + case NO_NETWORK_CONNECTION: + mServerStatusIcon = R.drawable.no_network; + mServerStatusText = R.string.auth_no_net_conn_title; + break; + case SSL_RECOVERABLE_PEER_UNVERIFIED: - mServerStatusIcon = R.drawable.common_error; mServerStatusText = R.string.auth_ssl_unverified_server_title; break; - case BAD_OC_VERSION: - mServerStatusIcon = R.drawable.common_error; mServerStatusText = R.string.auth_bad_oc_version_title; break; case WRONG_CONNECTION: - mServerStatusIcon = R.drawable.common_error; mServerStatusText = R.string.auth_wrong_connection_title; break; case TIMEOUT: - mServerStatusIcon = R.drawable.common_error; mServerStatusText = R.string.auth_timeout_title; break; case INCORRECT_ADDRESS: - mServerStatusIcon = R.drawable.common_error; mServerStatusText = R.string.auth_incorrect_address_title; break; - case SSL_ERROR: - mServerStatusIcon = R.drawable.common_error; mServerStatusText = R.string.auth_ssl_general_error_title; break; - case UNAUTHORIZED: - mServerStatusIcon = R.drawable.common_error; mServerStatusText = R.string.auth_unauthorized; break; case HOST_NOT_AVAILABLE: - mServerStatusIcon = R.drawable.common_error; mServerStatusText = R.string.auth_unknown_host_title; break; - case NO_NETWORK_CONNECTION: - mServerStatusIcon = R.drawable.no_network; - mServerStatusText = R.string.auth_no_net_conn_title; - break; case INSTANCE_NOT_CONFIGURED: - mServerStatusIcon = R.drawable.common_error; mServerStatusText = R.string.auth_not_configured_title; break; case FILE_NOT_FOUND: - mServerStatusIcon = R.drawable.common_error; mServerStatusText = R.string.auth_incorrect_path_title; break; case OAUTH2_ERROR: - mServerStatusIcon = R.drawable.common_error; mServerStatusText = R.string.auth_oauth_error; break; case OAUTH2_ERROR_ACCESS_DENIED: - mServerStatusIcon = R.drawable.common_error; mServerStatusText = R.string.auth_oauth_error_access_denied; break; case UNHANDLED_HTTP_CODE: case UNKNOWN_ERROR: - mServerStatusIcon = R.drawable.common_error; mServerStatusText = R.string.auth_unknown_error_title; break; - default: + mServerStatusText = 0; + mServerStatusIcon = 0; + } + } + + + /** + * Chooses the right icon and text to show to the user for the received operation result. + * + * @param result Result of a remote operation performed in this activity + */ + private void updateAuthStatusIconAndText(RemoteOperationResult result) { + mAuthStatusIcon = R.drawable.common_error; // the most common case in the switch below + + switch (result.getCode()) { + case OK_SSL: + mAuthStatusIcon = android.R.drawable.ic_secure; + mAuthStatusText = R.string.auth_secure_connection; + break; + + case OK_NO_SSL: + case OK: + if (mHostUrlInput.getText().toString().trim().toLowerCase().startsWith("http://") ) { + mAuthStatusText = R.string.auth_connection_established; + mAuthStatusIcon = R.drawable.ic_ok; + } else { + mAuthStatusText = R.string.auth_nossl_plain_ok_title; + mAuthStatusIcon = android.R.drawable.ic_partial_secure; + } + break; + + case NO_NETWORK_CONNECTION: + mAuthStatusIcon = R.drawable.no_network; + mAuthStatusText = R.string.auth_no_net_conn_title; + break; + + case SSL_RECOVERABLE_PEER_UNVERIFIED: + mAuthStatusText = R.string.auth_ssl_unverified_server_title; + break; + case BAD_OC_VERSION: + mAuthStatusText = R.string.auth_bad_oc_version_title; + break; + case WRONG_CONNECTION: + mAuthStatusText = R.string.auth_wrong_connection_title; + break; + case TIMEOUT: + mAuthStatusText = R.string.auth_timeout_title; + break; + case INCORRECT_ADDRESS: + mAuthStatusText = R.string.auth_incorrect_address_title; + break; + case SSL_ERROR: + mAuthStatusText = R.string.auth_ssl_general_error_title; + break; + case UNAUTHORIZED: + mAuthStatusText = R.string.auth_unauthorized; + break; + case HOST_NOT_AVAILABLE: + mAuthStatusText = R.string.auth_unknown_host_title; break; + case INSTANCE_NOT_CONFIGURED: + mAuthStatusText = R.string.auth_not_configured_title; + break; + case FILE_NOT_FOUND: + mAuthStatusText = R.string.auth_incorrect_path_title; + break; + case OAUTH2_ERROR: + mAuthStatusText = R.string.auth_oauth_error; + break; + case OAUTH2_ERROR_ACCESS_DENIED: + mAuthStatusText = R.string.auth_oauth_error_access_denied; + break; + case UNHANDLED_HTTP_CODE: + case UNKNOWN_ERROR: + mAuthStatusText = R.string.auth_unknown_error_title; + break; + default: + mAuthStatusText = 0; + mAuthStatusIcon = 0; } } @@ -757,7 +867,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity mAuthCheckOperation.execute(client, this, mHandler); } else { - updateStatusIconAndText(result); + updateAuthStatusIconAndText(result); showAuthStatus(); Log_OC.d(TAG, "Access failed: " + result.getLogMessage()); } @@ -792,7 +902,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity finish(); } else { - updateStatusIconAndText(result); + updateAuthStatusIconAndText(result); showAuthStatus(); Log_OC.d(TAG, "Access failed: " + result.getLogMessage()); } @@ -997,11 +1107,13 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity if (mServerStatusIcon == 0 && mServerStatusText == 0) { tv.setVisibility(View.INVISIBLE); + } else { tv.setText(mServerStatusText); tv.setCompoundDrawablesWithIntrinsicBounds(mServerStatusIcon, 0, 0, 0); tv.setVisibility(View.VISIBLE); } + } @@ -1012,6 +1124,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity private void showAuthStatus() { if (mAuthStatusIcon == 0 && mAuthStatusText == 0) { mAuthStatusLayout.setVisibility(View.INVISIBLE); + } else { mAuthStatusLayout.setText(mAuthStatusText); mAuthStatusLayout.setCompoundDrawablesWithIntrinsicBounds(mAuthStatusIcon, 0, 0, 0); @@ -1020,6 +1133,14 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity } + private void showRefreshButton() { + mHostUrlInput.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.ic_action_refresh_black, 0); + } + + private void hideRefreshButton() { + mHostUrlInput.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0); + } + /** * Called when the refresh button in the input field for ownCloud host is clicked. * @@ -1027,30 +1148,25 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity * * @param view Refresh 'button' */ - public void onRefreshClick(View view) { + public void onRefreshClick() { checkOcServer(); } + /** * Called when the eye icon in the password field is clicked. * * Toggles the visibility of the password in the field. - * - * @param view 'View password' 'button' */ - public void onViewPasswordClick(View view) { + public void onViewPasswordClick() { int selectionStart = mPasswordInput.getSelectionStart(); int selectionEnd = mPasswordInput.getSelectionEnd(); - int input_type = mPasswordInput.getInputType(); - if ((input_type & InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD) == InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD) { - input_type = InputType.TYPE_CLASS_TEXT - | InputType.TYPE_TEXT_VARIATION_PASSWORD; + if (isPasswordVisible()) { + hidePassword(); } else { - input_type = InputType.TYPE_CLASS_TEXT - | InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD; + showPassword(); } - mPasswordInput.setInputType(input_type); mPasswordInput.setSelection(selectionStart, selectionEnd); } @@ -1081,13 +1197,11 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity mOAuthTokenEndpointText.setVisibility(View.VISIBLE); mUsernameInput.setVisibility(View.GONE); mPasswordInput.setVisibility(View.GONE); - mViewPasswordButton.setVisibility(View.GONE); } else { mOAuthAuthEndpointText.setVisibility(View.GONE); mOAuthTokenEndpointText.setVisibility(View.GONE); mUsernameInput.setVisibility(View.VISIBLE); mPasswordInput.setVisibility(View.VISIBLE); - mViewPasswordButton.setVisibility(View.INVISIBLE); } } @@ -1128,30 +1242,28 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity private abstract static class RightDrawableOnTouchListener implements OnTouchListener { - private int fuzz = 10; + private int fuzz = 75; /** * {@inheritDoc} */ @Override public boolean onTouch(View view, MotionEvent event) { - if (event.getAction() == MotionEvent.ACTION_DOWN) { - Drawable rightDrawable = null; - if (view instanceof TextView) { - Drawable[] drawables = ((TextView)view).getCompoundDrawables(); - if (drawables.length > 2) { - rightDrawable = drawables[2]; - } + Drawable rightDrawable = null; + if (view instanceof TextView) { + Drawable[] drawables = ((TextView)view).getCompoundDrawables(); + if (drawables.length > 2) { + rightDrawable = drawables[2]; } - if (rightDrawable != null) { - final int x = (int) event.getX(); - final int y = (int) event.getY(); - final Rect bounds = rightDrawable.getBounds(); - if (x >= (view.getRight() - bounds.width() - fuzz) && x <= (view.getRight() - view.getPaddingRight() + fuzz) - && y >= (view.getPaddingTop() - fuzz) && y <= (view.getHeight() - view.getPaddingBottom()) + fuzz) { - - return onDrawableTouch(event); - } + } + if (rightDrawable != null) { + final int x = (int) event.getX(); + final int y = (int) event.getY(); + final Rect bounds = rightDrawable.getBounds(); + if (x >= (view.getRight() - bounds.width() - fuzz) && x <= (view.getRight() - view.getPaddingRight() + fuzz) + && y >= (view.getPaddingTop() - fuzz) && y <= (view.getHeight() - view.getPaddingBottom()) + fuzz) { + + return onDrawableTouch(event); } } return false; @@ -1160,24 +1272,4 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity public abstract boolean onDrawableTouch(final MotionEvent event); } - - private class HostUrlWatcher implements TextWatcher { - - @Override - public void afterTextChanged(Editable s) { - } - - @Override - public void beforeTextChanged(CharSequence s, int start, int count, int after) { - } - - @Override - public void onTextChanged(CharSequence s, int start, int before, int count) { - if (mServerCheckedAndValid) { - mServerCheckedAndValid = false; - mOkButton.setEnabled(false); // avoids that the 'connect' button can be clicked if the test was previously passed - } - } - - } }