Fix IME "Next" button handling in credentials screen

b/13544867

Change-Id: I63ba680a5551dd4bd860026b9110b20a2ae080b6
This commit is contained in:
Tony Mantler 2014-03-19 11:13:04 -07:00
parent e93b81a51a
commit cc82c7bae2
2 changed files with 24 additions and 19 deletions

View File

@ -50,7 +50,7 @@ import java.io.IOException;
import java.util.List;
public class AccountSetupCredentialsFragment extends AccountSetupFragment
implements OnClickListener, HostCallback {
implements OnClickListener, HostCallback, TextView.OnEditorActionListener {
private static final int CERTIFICATE_REQUEST = 1000;
@ -146,24 +146,8 @@ public class AccountSetupCredentialsFragment extends AccountSetupFragment
mClientCertificateSelector.setHostCallback(this);
mClientCertificateSelector.setCertificate(getArguments().getString(EXTRA_CLIENT_CERT));
TextView.OnEditorActionListener editorActionListener =
new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView view, int actionId, KeyEvent event) {
if (actionId == EditorInfo.IME_ACTION_DONE) {
final Callback callback = (Callback) getActivity();
if (callback != null) {
final Bundle results = getCredentialResults();
callback.onCredentialsComplete(results);
}
return true;
} else {
return false;
}
}
};
mImapPasswordText.setOnEditorActionListener(editorActionListener);
mRegularPasswordText.setOnEditorActionListener(editorActionListener);
mImapPasswordText.setOnEditorActionListener(this);
mRegularPasswordText.setOnEditorActionListener(this);
// After any text edits, call validateFields() which enables or disables the Next button
mValidationTextWatcher = new TextWatcher() {
@ -326,6 +310,22 @@ public class AccountSetupCredentialsFragment extends AccountSetupFragment
}
}
@Override
public boolean onEditorAction(TextView view, int actionId, KeyEvent event) {
if (actionId == EditorInfo.IME_ACTION_DONE) {
if (isNextButtonEnabled()) {
final Callback callback = (Callback) getActivity();
if (callback != null) {
final Bundle results = getCredentialResults();
callback.onCredentialsComplete(results);
}
}
return true;
} else {
return false;
}
}
public String getPassword() {
if (mOfferOAuth) {
return mImapPasswordText.getText().toString();

View File

@ -112,6 +112,11 @@ public class AccountSetupFragment extends Fragment implements View.OnClickListen
}
}
public boolean isNextButtonEnabled() {
return mNextButton.isEnabled();
}
/**
* Set visibility of the "previous" button
* @param visibility {@link View#INVISIBLE}, {@link View#VISIBLE}, {@link View#GONE}