use of org.geometerplus.fbreader.network.authentication.NetworkAuthenticationManager in project FBReaderJ by geometer.
the class TopupAction method getContextLabel.
@Override
public String getContextLabel(NetworkTree tree) {
final INetworkLink link = tree.getLink();
Money account = null;
if (link != null) {
final NetworkAuthenticationManager mgr = link.authenticationManager();
if (mgr != null && mgr.mayBeAuthorised(false)) {
account = mgr.currentAccount();
}
}
return super.getContextLabel(tree).replace("%s", account != null ? account.toString() : "");
}
use of org.geometerplus.fbreader.network.authentication.NetworkAuthenticationManager in project FBReaderJ by geometer.
the class BuyBooksActivity method updateAuthorisationState.
private void updateAuthorisationState() {
new Thread(new Runnable() {
public void run() {
final NetworkAuthenticationManager mgr = myLink.authenticationManager();
try {
if (mgr.isAuthorised(true)) {
setupUI(AuthorisationState.Authorised);
refreshAccountInformation();
} else {
setupUI(AuthorisationState.NotAuthorised);
}
} catch (ZLNetworkException e) {
e.printStackTrace();
setupUI(AuthorisationState.NotAuthorised);
}
}
}).start();
}
use of org.geometerplus.fbreader.network.authentication.NetworkAuthenticationManager in project FBReaderJ by geometer.
the class Util method runAuthenticationDialog.
public static void runAuthenticationDialog(Activity activity, INetworkLink link, Runnable onSuccess) {
final NetworkAuthenticationManager mgr = link.authenticationManager();
final Intent intent = intentByLink(new Intent(activity, AuthenticationActivity.class), link);
AuthenticationActivity.registerRunnable(intent, onSuccess);
intent.putExtra(AuthenticationActivity.USERNAME_KEY, mgr.getUserName());
intent.putExtra(AuthenticationActivity.SCHEME_KEY, "https");
intent.putExtra(AuthenticationActivity.CUSTOM_AUTH_KEY, true);
activity.startActivity(intent);
}
use of org.geometerplus.fbreader.network.authentication.NetworkAuthenticationManager in project FBReaderJ by geometer.
the class SignOutAction method isVisible.
@Override
public boolean isVisible(NetworkTree tree) {
if (!(tree instanceof NetworkCatalogRootTree)) {
return false;
}
final INetworkLink link = tree.getLink();
if (link instanceof ISyncNetworkLink) {
return ((ISyncNetworkLink) link).isLoggedIn(myNetworkContext);
}
final NetworkAuthenticationManager mgr = link.authenticationManager();
return mgr != null && mgr.mayBeAuthorised(false);
}
use of org.geometerplus.fbreader.network.authentication.NetworkAuthenticationManager in project FBReaderJ by geometer.
the class SignOutAction method run.
@Override
public void run(NetworkTree tree) {
final INetworkLink link = tree.getLink();
if (link instanceof ISyncNetworkLink) {
((ISyncNetworkLink) link).logout(myNetworkContext);
((NetworkCatalogRootTree) tree).clearCatalog();
return;
}
final NetworkAuthenticationManager mgr = link.authenticationManager();
final Runnable runnable = new Runnable() {
public void run() {
if (mgr.mayBeAuthorised(false)) {
mgr.logOut();
myActivity.runOnUiThread(new Runnable() {
public void run() {
myLibrary.invalidateVisibility();
myLibrary.synchronize();
}
});
}
}
};
UIUtil.wait("signOut", runnable, myActivity);
}
Aggregations