mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 04:43:54 +01:00
Merge pull request #24 from brion/login-done
Log in on "Done" or enter press in password field
This commit is contained in:
commit
a931dd607a
1 changed files with 29 additions and 10 deletions
|
|
@ -4,6 +4,7 @@ import java.io.IOException;
|
||||||
|
|
||||||
import android.content.*;
|
import android.content.*;
|
||||||
import android.text.*;
|
import android.text.*;
|
||||||
|
import android.view.inputmethod.EditorInfo;
|
||||||
import de.keyboardsurfer.android.widget.crouton.*;
|
import de.keyboardsurfer.android.widget.crouton.*;
|
||||||
import android.os.*;
|
import android.os.*;
|
||||||
import android.accounts.*;
|
import android.accounts.*;
|
||||||
|
|
@ -127,7 +128,7 @@ public class LoginActivity extends AccountAuthenticatorActivity {
|
||||||
loginButton = (Button) findViewById(R.id.loginButton);
|
loginButton = (Button) findViewById(R.id.loginButton);
|
||||||
usernameEdit = (EditText) findViewById(R.id.loginUsername);
|
usernameEdit = (EditText) findViewById(R.id.loginUsername);
|
||||||
passwordEdit = (EditText) findViewById(R.id.loginPassword);
|
passwordEdit = (EditText) findViewById(R.id.loginPassword);
|
||||||
final Activity that = this;
|
final LoginActivity that = this;
|
||||||
|
|
||||||
TextWatcher loginEnabler = new TextWatcher() {
|
TextWatcher loginEnabler = new TextWatcher() {
|
||||||
public void beforeTextChanged(CharSequence charSequence, int start, int count, int after) { }
|
public void beforeTextChanged(CharSequence charSequence, int start, int count, int after) { }
|
||||||
|
|
@ -145,23 +146,41 @@ public class LoginActivity extends AccountAuthenticatorActivity {
|
||||||
|
|
||||||
usernameEdit.addTextChangedListener(loginEnabler);
|
usernameEdit.addTextChangedListener(loginEnabler);
|
||||||
passwordEdit.addTextChangedListener(loginEnabler);
|
passwordEdit.addTextChangedListener(loginEnabler);
|
||||||
|
passwordEdit.setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
||||||
|
public boolean onEditorAction(TextView textView, int actionId, KeyEvent keyEvent) {
|
||||||
|
if (loginButton.isEnabled()) {
|
||||||
|
if (actionId == EditorInfo.IME_ACTION_DONE) {
|
||||||
|
performLogin();
|
||||||
|
return true;
|
||||||
|
} else if ((keyEvent != null) && keyEvent.getKeyCode() == KeyEvent.KEYCODE_ENTER) {
|
||||||
|
performLogin();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
loginButton.setOnClickListener(new View.OnClickListener() {
|
loginButton.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
String username = usernameEdit.getText().toString();
|
that.performLogin();
|
||||||
// Because Mediawiki is upercase-first-char-then-case-sensitive :)
|
|
||||||
String canonicalUsername = username.substring(0,1).toUpperCase() + username.substring(1);
|
|
||||||
|
|
||||||
String password = passwordEdit.getText().toString();
|
|
||||||
|
|
||||||
Log.d("Commons", "Login to start!");
|
|
||||||
LoginTask task = new LoginTask(that);
|
|
||||||
task.execute(canonicalUsername, password);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void performLogin() {
|
||||||
|
String username = usernameEdit.getText().toString();
|
||||||
|
// Because Mediawiki is upercase-first-char-then-case-sensitive :)
|
||||||
|
String canonicalUsername = username.substring(0,1).toUpperCase() + username.substring(1);
|
||||||
|
|
||||||
|
String password = passwordEdit.getText().toString();
|
||||||
|
|
||||||
|
Log.d("Commons", "Login to start!");
|
||||||
|
LoginTask task = new LoginTask(this);
|
||||||
|
task.execute(canonicalUsername, password);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCreateOptionsMenu(Menu menu) {
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
getMenuInflater().inflate(R.menu.activity_login, menu);
|
getMenuInflater().inflate(R.menu.activity_login, menu);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue