From: David A. Velasco Date: Wed, 5 Jun 2013 09:39:34 +0000 (+0200) Subject: Merge branch 'login_view_layout_improvements' into login_toggle_password_icon X-Git-Tag: oc-android-1.4.3~16^2~1^2^2 X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/commitdiff_plain/dcae1fe167dac9a69102a0714fcd38a56340a332?ds=inline;hp=--cc Merge branch 'login_view_layout_improvements' into login_toggle_password_icon --- dcae1fe167dac9a69102a0714fcd38a56340a332 diff --cc src/com/owncloud/android/authentication/AuthenticatorActivity.java index cc1adcf3,13ffd2a9..919a40ad --- a/src/com/owncloud/android/authentication/AuthenticatorActivity.java +++ b/src/com/owncloud/android/authentication/AuthenticatorActivity.java @@@ -94,10 -95,9 +94,10 @@@ implements OnRemoteOperationListener, 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"; - + private static final String OAUTH_MODE_ON = "on"; private static final String OAUTH_MODE_OFF = "off"; private static final String OAUTH_MODE_OPTIONAL = "optional"; @@@ -130,7 -130,8 +130,7 @@@ private boolean mJustCreated; private byte mAction; private Account mAccount; - + - private ImageView mViewPasswordButton; private EditText mHostUrlInput; private EditText mUsernameInput; private EditText mPasswordInput; @@@ -152,9 -153,10 +152,9 @@@ protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getWindow().requestFeature(Window.FEATURE_NO_TITLE); - + /// 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); @@@ -287,17 -284,8 +287,17 @@@ 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; + } + }); } - + /** * Saves relevant state before {@link #onPause()} * @@@ -317,10 -305,9 +317,10 @@@ 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); - + /// server data if (mDiscoveredVersion != null) { outState.putString(KEY_OC_VERSION, mDiscoveredVersion.toString()); @@@ -1148,29 -1113,34 +1153,28 @@@ * * @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); } - - + + /** * Called when the checkbox for OAuth authorization is clicked. * @@@ -1239,11 -1211,11 +1243,11 @@@ return false; // always return false to grant that the software keyboard is hidden anyway } - + private abstract static class RightDrawableOnTouchListener implements OnTouchListener { - private int fuzz = 10; - + private int fuzz = 75; + /** * {@inheritDoc} */