mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-04 10:19:33 +02:00
AuthenticationActivity checks username length
This commit is contained in:
parent
9ebafe1081
commit
1f56a9d831
3 changed files with 39 additions and 14 deletions
|
@ -19,6 +19,8 @@
|
||||||
|
|
||||||
package org.geometerplus.android.fbreader.network;
|
package org.geometerplus.android.fbreader.network;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
|
@ -105,6 +107,9 @@ public class AuthenticationActivity extends Activity {
|
||||||
|
|
||||||
private ZLResource myResource;
|
private ZLResource myResource;
|
||||||
private INetworkLink myLink;
|
private INetworkLink myLink;
|
||||||
|
private Button myOkButton;
|
||||||
|
private Timer myOkButtonUpdater;
|
||||||
|
private TextView myUsernameView;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle icicle) {
|
public void onCreate(Bundle icicle) {
|
||||||
|
@ -148,8 +153,8 @@ public class AuthenticationActivity extends Activity {
|
||||||
myResource.getResource("password").getValue()
|
myResource.getResource("password").getValue()
|
||||||
);
|
);
|
||||||
|
|
||||||
final TextView usernameView = findTextView(R.id.authentication_username);
|
myUsernameView = findTextView(R.id.authentication_username);
|
||||||
usernameView.setText(username);
|
myUsernameView.setText(username);
|
||||||
|
|
||||||
final TextView errorView = findTextView(R.id.authentication_error);
|
final TextView errorView = findTextView(R.id.authentication_error);
|
||||||
if (error != null && !"".equals(error)) {
|
if (error != null && !"".equals(error)) {
|
||||||
|
@ -175,14 +180,14 @@ public class AuthenticationActivity extends Activity {
|
||||||
|
|
||||||
final ZLResource buttonResource = ZLResource.resource("dialog").getResource("button");
|
final ZLResource buttonResource = ZLResource.resource("dialog").getResource("button");
|
||||||
|
|
||||||
final Button okButton = findButton(R.id.authentication_ok_button);
|
myOkButton = findButton(R.id.authentication_ok_button);
|
||||||
okButton.setText(buttonResource.getResource("ok").getValue());
|
myOkButton.setText(buttonResource.getResource("ok").getValue());
|
||||||
okButton.setOnClickListener(new Button.OnClickListener() {
|
myOkButton.setOnClickListener(new Button.OnClickListener() {
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
final Intent data = Util.intentByLink(new Intent(), myLink);
|
final Intent data = Util.intentByLink(new Intent(), myLink);
|
||||||
data.putExtra(
|
data.putExtra(
|
||||||
USERNAME_KEY,
|
USERNAME_KEY,
|
||||||
usernameView.getText().toString()
|
myUsernameView.getText().toString()
|
||||||
);
|
);
|
||||||
data.putExtra(
|
data.putExtra(
|
||||||
PASSWORD_KEY,
|
PASSWORD_KEY,
|
||||||
|
@ -209,4 +214,31 @@ public class AuthenticationActivity extends Activity {
|
||||||
private Button findButton(int resourceId) {
|
private Button findButton(int resourceId) {
|
||||||
return (Button)findViewById(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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -135,13 +135,6 @@ public abstract class Util implements UserRegistrationConstants {
|
||||||
data.getStringExtra(AuthenticationActivity.USERNAME_KEY);
|
data.getStringExtra(AuthenticationActivity.USERNAME_KEY);
|
||||||
final String password =
|
final String password =
|
||||||
data.getStringExtra(AuthenticationActivity.PASSWORD_KEY);
|
data.getStringExtra(AuthenticationActivity.PASSWORD_KEY);
|
||||||
if (username.length() == 0) {
|
|
||||||
runAuthenticationDialog(
|
|
||||||
activity, link,
|
|
||||||
resource.getResource("loginIsEmpty").getValue(),
|
|
||||||
onSuccess
|
|
||||||
);
|
|
||||||
}
|
|
||||||
final NetworkAuthenticationManager mgr = link.authenticationManager();
|
final NetworkAuthenticationManager mgr = link.authenticationManager();
|
||||||
mgr.UserNameOption.setValue(username);
|
mgr.UserNameOption.setValue(username);
|
||||||
final Runnable runnable = new Runnable() {
|
final Runnable runnable = new Runnable() {
|
||||||
|
|
|
@ -42,7 +42,7 @@ public class SignInAction extends Action {
|
||||||
|
|
||||||
final NetworkCatalogItem item = ((NetworkCatalogRootTree)tree).Item;
|
final NetworkCatalogItem item = ((NetworkCatalogRootTree)tree).Item;
|
||||||
final NetworkAuthenticationManager mgr = item.Link.authenticationManager();
|
final NetworkAuthenticationManager mgr = item.Link.authenticationManager();
|
||||||
return mgr != null && mgr.mayBeAuthorised(false);
|
return mgr != null && !mgr.mayBeAuthorised(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue