import android.os.Handler;\r
import android.preference.PreferenceManager;\r
import android.text.InputType;\r
+import android.view.KeyEvent;\r
import android.view.View;\r
import android.view.View.OnFocusChangeListener;\r
import android.view.Window;\r
+import android.view.inputmethod.EditorInfo;\r
import android.widget.CheckBox;\r
import android.widget.EditText;\r
import android.widget.Button;\r
import android.widget.ImageView;\r
import android.widget.TextView;\r
import android.widget.Toast;\r
+import android.widget.TextView.OnEditorActionListener;\r
\r
import com.owncloud.android.R;\r
\r
* @author David A. Velasco\r
*/\r
public class AuthenticatorActivity extends AccountAuthenticatorActivity\r
- implements OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeListener {\r
+ implements OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeListener, OnEditorActionListener {\r
\r
private static final String TAG = AuthenticatorActivity.class.getSimpleName();\r
\r
/// bind view elements to listeners\r
mHostUrlInput.setOnFocusChangeListener(this);\r
mPasswordInput.setOnFocusChangeListener(this);\r
+ mPasswordInput.setImeOptions(EditorInfo.IME_ACTION_DONE);\r
+ mPasswordInput.setOnEditorActionListener(this);\r
\r
/// initialization\r
mAccountMgr = AccountManager.get(this);\r
mStatusText = mStatusIcon = 0;\r
mStatusCorrect = false;\r
mIsSslConn = false;\r
+ updateConnStatus();\r
+ updateAuthStatus();\r
\r
/// retrieve extras from intent\r
String tokenType = getIntent().getExtras().getString(AccountAuthenticator.KEY_AUTH_TOKEN_TYPE);\r
updateConnStatus();\r
\r
/// UI settings depending upon connection\r
- mOkButton.setEnabled(mStatusCorrect); // TODO really necessary?\r
+ mOkButton.setEnabled(mStatusCorrect); \r
if (!mStatusCorrect)\r
mRefreshButton.setVisibility(View.VISIBLE); // seems that setting visibility is necessary\r
else\r
\r
/// GET ACCESS TOKEN to the oAuth server \r
RemoteOperation operation = new OAuth2GetAccessToken( getString(R.string.oauth2_client_id), \r
- getString(R.string.oauth2_redirect_uri), // TODO check - necessary here? \r
+ getString(R.string.oauth2_redirect_uri), \r
getString(R.string.oauth2_grant_type),\r
queryParameters);\r
//WebdavClient client = OwnCloudClientUtils.createOwnCloudClient(Uri.parse(getString(R.string.oauth2_url_endpoint_access)), getApplicationContext());\r
* to the last check on the ownCloud server.\r
*/\r
private void updateConnStatus() {\r
- ImageView iv = (ImageView) findViewById(R.id.action_indicator);\r
- TextView tv = (TextView) findViewById(R.id.status_text);\r
+ TextView tv = (TextView) findViewById(R.id.server_status_text);\r
\r
if (mStatusIcon == 0 && mStatusText == 0) {\r
- iv.setVisibility(View.INVISIBLE);\r
tv.setVisibility(View.INVISIBLE);\r
} else {\r
- iv.setImageResource(mStatusIcon);\r
tv.setText(mStatusText);\r
- iv.setVisibility(View.VISIBLE);\r
+ tv.setCompoundDrawablesWithIntrinsicBounds(mStatusIcon, 0, 0, 0);\r
tv.setVisibility(View.VISIBLE);\r
}\r
}\r
showDialog(DIALOG_CERT_NOT_SAVED);\r
}\r
\r
+\r
+ /**\r
+ * Called when the 'action' button in an IME is pressed ('enter' in software keyboard).\r
+ * \r
+ * Used to trigger the authorization check when the user presses 'enter' after writing the password.\r
+ */\r
+ @Override\r
+ public boolean onEditorAction(TextView inputField, int actionId, KeyEvent event) {\r
+ if (inputField != null && inputField.equals(mPasswordInput) && \r
+ actionId == EditorInfo.IME_ACTION_DONE) {\r
+ if (mOkButton.isEnabled()) {\r
+ mOkButton.performClick();\r
+ }\r
+ }\r
+ return false; // always return false to grant that the software keyboard is hidden anyway\r
+ }\r
+\r
}\r