1
0
Fork 0
mirror of https://github.com/geometer/FBReaderJ.git synced 2025-10-04 18:29:23 +02:00

AuthenticationActivity checks username length

This commit is contained in:
Nikolay Pultsin 2011-08-20 18:29:54 +01:00
parent 9ebafe1081
commit 1f56a9d831
3 changed files with 39 additions and 14 deletions

View file

@ -19,6 +19,8 @@
package org.geometerplus.android.fbreader.network;
import java.util.*;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
@ -105,6 +107,9 @@ public class AuthenticationActivity extends Activity {
private ZLResource myResource;
private INetworkLink myLink;
private Button myOkButton;
private Timer myOkButtonUpdater;
private TextView myUsernameView;
@Override
public void onCreate(Bundle icicle) {
@ -148,8 +153,8 @@ public class AuthenticationActivity extends Activity {
myResource.getResource("password").getValue()
);
final TextView usernameView = findTextView(R.id.authentication_username);
usernameView.setText(username);
myUsernameView = findTextView(R.id.authentication_username);
myUsernameView.setText(username);
final TextView errorView = findTextView(R.id.authentication_error);
if (error != null && !"".equals(error)) {
@ -175,14 +180,14 @@ public class AuthenticationActivity extends Activity {
final ZLResource buttonResource = ZLResource.resource("dialog").getResource("button");
final Button okButton = findButton(R.id.authentication_ok_button);
okButton.setText(buttonResource.getResource("ok").getValue());
okButton.setOnClickListener(new Button.OnClickListener() {
myOkButton = findButton(R.id.authentication_ok_button);
myOkButton.setText(buttonResource.getResource("ok").getValue());
myOkButton.setOnClickListener(new Button.OnClickListener() {
public void onClick(View v) {
final Intent data = Util.intentByLink(new Intent(), myLink);
data.putExtra(
USERNAME_KEY,
usernameView.getText().toString()
myUsernameView.getText().toString()
);
data.putExtra(
PASSWORD_KEY,
@ -209,4 +214,31 @@ public class AuthenticationActivity extends Activity {
private Button findButton(int resourceId) {
return (Button)findViewById(resourceId);
}
@Override
protected void onResume() {
super.onResume();
if (myOkButtonUpdater == null) {
myOkButtonUpdater = new Timer();
myOkButtonUpdater.schedule(new TimerTask() {
public void run() {
runOnUiThread(new Runnable() {
public void run() {
myOkButton.setEnabled(myUsernameView.getText().length() > 0);
}
});
}
}, 0, 100);
}
}
@Override
protected void onPause() {
if (myOkButtonUpdater != null) {
myOkButtonUpdater.cancel();
myOkButtonUpdater.purge();
myOkButtonUpdater = null;
}
super.onPause();
}
}

View file

@ -135,13 +135,6 @@ public abstract class Util implements UserRegistrationConstants {
data.getStringExtra(AuthenticationActivity.USERNAME_KEY);
final String password =
data.getStringExtra(AuthenticationActivity.PASSWORD_KEY);
if (username.length() == 0) {
runAuthenticationDialog(
activity, link,
resource.getResource("loginIsEmpty").getValue(),
onSuccess
);
}
final NetworkAuthenticationManager mgr = link.authenticationManager();
mgr.UserNameOption.setValue(username);
final Runnable runnable = new Runnable() {

View file

@ -42,7 +42,7 @@ public class SignInAction extends Action {
final NetworkCatalogItem item = ((NetworkCatalogRootTree)tree).Item;
final NetworkAuthenticationManager mgr = item.Link.authenticationManager();
return mgr != null && mgr.mayBeAuthorised(false);
return mgr != null && !mgr.mayBeAuthorised(false);
}
@Override