X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/blobdiff_plain/2946d8dd69cf8d30a3fc2447ac931675989e8eff..842f46d7caed7de94c5e230321a5ea675857f320:/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 ef5c21b5..dd3b4a0e 100644 --- a/src/com/owncloud/android/authentication/AuthenticatorActivity.java +++ b/src/com/owncloud/android/authentication/AuthenticatorActivity.java @@ -47,15 +47,18 @@ import android.os.Bundle; import android.os.Handler; import android.preference.PreferenceManager; import android.text.InputType; +import android.view.KeyEvent; import android.view.View; import android.view.View.OnFocusChangeListener; import android.view.Window; +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; import com.owncloud.android.R; @@ -68,7 +71,7 @@ import eu.alefzero.webdav.WebdavClient; * @author David A. Velasco */ public class AuthenticatorActivity extends AccountAuthenticatorActivity - implements OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeListener { + implements OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeListener, OnEditorActionListener { private static final String TAG = AuthenticatorActivity.class.getSimpleName(); @@ -166,6 +169,8 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity /// bind view elements to listeners mHostUrlInput.setOnFocusChangeListener(this); mPasswordInput.setOnFocusChangeListener(this); + mPasswordInput.setImeOptions(EditorInfo.IME_ACTION_DONE); + mPasswordInput.setOnEditorActionListener(this); /// initialization mAccountMgr = AccountManager.get(this); @@ -178,6 +183,8 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity mStatusText = mStatusIcon = 0; mStatusCorrect = false; mIsSslConn = false; + updateConnStatus(); + updateAuthStatus(); /// retrieve extras from intent String tokenType = getIntent().getExtras().getString(AccountAuthenticator.KEY_AUTH_TOKEN_TYPE); @@ -270,7 +277,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity updateConnStatus(); /// UI settings depending upon connection - mOkButton.setEnabled(mStatusCorrect); // TODO really necessary? + mOkButton.setEnabled(mStatusCorrect); if (!mStatusCorrect) mRefreshButton.setVisibility(View.VISIBLE); // seems that setting visibility is necessary else @@ -347,7 +354,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity /// GET ACCESS TOKEN to the oAuth server RemoteOperation operation = new OAuth2GetAccessToken( getString(R.string.oauth2_client_id), - getString(R.string.oauth2_redirect_uri), // TODO check - necessary here? + getString(R.string.oauth2_redirect_uri), getString(R.string.oauth2_grant_type), queryParameters); //WebdavClient client = OwnCloudClientUtils.createOwnCloudClient(Uri.parse(getString(R.string.oauth2_url_endpoint_access)), getApplicationContext()); @@ -964,16 +971,13 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity * to the last check on the ownCloud server. */ private void updateConnStatus() { - ImageView iv = (ImageView) findViewById(R.id.action_indicator); - TextView tv = (TextView) findViewById(R.id.status_text); + TextView tv = (TextView) findViewById(R.id.server_status_text); if (mStatusIcon == 0 && mStatusText == 0) { - iv.setVisibility(View.INVISIBLE); tv.setVisibility(View.INVISIBLE); } else { - iv.setImageResource(mStatusIcon); tv.setText(mStatusText); - iv.setVisibility(View.VISIBLE); + tv.setCompoundDrawablesWithIntrinsicBounds(mStatusIcon, 0, 0, 0); tv.setVisibility(View.VISIBLE); } } @@ -1082,4 +1086,21 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity showDialog(DIALOG_CERT_NOT_SAVED); } + + /** + * Called when the 'action' button in an IME is pressed ('enter' in software keyboard). + * + * Used to trigger the authorization check when the user presses 'enter' after writing the password. + */ + @Override + public boolean onEditorAction(TextView inputField, int actionId, KeyEvent event) { + if (inputField != null && inputField.equals(mPasswordInput) && + actionId == EditorInfo.IME_ACTION_DONE) { + if (mOkButton.isEnabled()) { + mOkButton.performClick(); + } + } + return false; // always return false to grant that the software keyboard is hidden anyway + } + }