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

authorization while adding catalog fix

This commit is contained in:
dlmv 2011-12-14 17:22:32 +04:00
parent d8e8521dc1
commit fba4df1d88
4 changed files with 25 additions and 3 deletions

View file

@ -30,6 +30,7 @@ import android.widget.TextView;
import org.geometerplus.zlibrary.core.resources.ZLResource; import org.geometerplus.zlibrary.core.resources.ZLResource;
import org.geometerplus.zlibrary.core.network.ZLNetworkException; import org.geometerplus.zlibrary.core.network.ZLNetworkException;
import org.geometerplus.zlibrary.core.network.ZLNetworkManager;
import org.geometerplus.zlibrary.ui.android.R; import org.geometerplus.zlibrary.ui.android.R;
@ -39,9 +40,13 @@ import org.geometerplus.fbreader.network.urlInfo.*;
import org.geometerplus.android.util.UIUtil; import org.geometerplus.android.util.UIUtil;
import android.util.Log;
public class AddCustomCatalogActivity extends Activity { public class AddCustomCatalogActivity extends Activity {
public static String EDIT_KEY = "EditNotAdd"; public static String EDIT_KEY = "EditNotAdd";
protected static final int BASIC_AUTHENTICATION_CODE = 1;
private ZLResource myResource; private ZLResource myResource;
private volatile ICustomNetworkLink myLink; private volatile ICustomNetworkLink myLink;
private boolean myEditNotAdd; private boolean myEditNotAdd;
@ -221,7 +226,6 @@ public class AddCustomCatalogActivity extends Activity {
textUrl = "http://" + textUrl; textUrl = "http://" + textUrl;
uri = Uri.parse(textUrl); uri = Uri.parse(textUrl);
} }
setTextById(R.id.add_custom_catalog_url, textUrl); setTextById(R.id.add_custom_catalog_url, textUrl);
final String siteName = uri.getHost(); final String siteName = uri.getHost();
if (isEmptyString(siteName)) { if (isEmptyString(siteName)) {
@ -233,7 +237,6 @@ public class AddCustomCatalogActivity extends Activity {
myLink = new OPDSCustomNetworkLink( myLink = new OPDSCustomNetworkLink(
ICustomNetworkLink.INVALID_ID, siteName, null, null, null, infos ICustomNetworkLink.INVALID_ID, siteName, null, null, null, infos
); );
final Runnable loadInfoRunnable = new Runnable() { final Runnable loadInfoRunnable = new Runnable() {
private String myError; private String myError;
@ -260,4 +263,22 @@ public class AddCustomCatalogActivity extends Activity {
}; };
UIUtil.wait("loadingCatalogInfo", loadInfoRunnable, this); UIUtil.wait("loadingCatalogInfo", loadInfoRunnable, this);
} }
private final AuthenticationActivity.CredentialsCreator myCredentialsCreator =
new AuthenticationActivity.CredentialsCreator(this, BASIC_AUTHENTICATION_CODE);
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
switch (requestCode) {
case BASIC_AUTHENTICATION_CODE:
myCredentialsCreator.onDataReceived(resultCode, intent);
break;
}
}
@Override
public void onResume() {
super.onResume();
ZLNetworkManager.Instance().setCredentialsCreator(myCredentialsCreator);
}
} }

View file

@ -304,3 +304,4 @@ public class AuthenticationActivity extends Activity {
super.onPause(); super.onPause();
} }
} }

View file

@ -91,6 +91,7 @@ public abstract class Util implements UserRegistrationConstants {
} }
public static void runAuthenticationDialog(Activity activity, INetworkLink link, Runnable onSuccess) { public static void runAuthenticationDialog(Activity activity, INetworkLink link, Runnable onSuccess) {
final NetworkAuthenticationManager mgr = link.authenticationManager(); final NetworkAuthenticationManager mgr = link.authenticationManager();
final Intent intent = intentByLink(new Intent(activity, AuthenticationActivity.class), link); final Intent intent = intentByLink(new Intent(activity, AuthenticationActivity.class), link);

View file

@ -99,7 +99,6 @@ public class OPDSCustomNetworkLink extends OPDSNetworkLink implements ICustomNet
public void reloadInfo(final boolean urlsOnly) throws ZLNetworkException { public void reloadInfo(final boolean urlsOnly) throws ZLNetworkException {
final LinkedList<String> opensearchDescriptionURLs = new LinkedList<String>(); final LinkedList<String> opensearchDescriptionURLs = new LinkedList<String>();
final List<OpenSearchDescription> descriptions = Collections.synchronizedList(new LinkedList<OpenSearchDescription>()); final List<OpenSearchDescription> descriptions = Collections.synchronizedList(new LinkedList<OpenSearchDescription>());
ZLNetworkException error = null; ZLNetworkException error = null;
try { try {
ZLNetworkManager.Instance().perform(new ZLNetworkRequest(getUrl(UrlInfo.Type.Catalog)) { ZLNetworkManager.Instance().perform(new ZLNetworkRequest(getUrl(UrlInfo.Type.Catalog)) {