mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-06 03:50:19 +02:00
fixed basic auth
This commit is contained in:
parent
dec2e84b5f
commit
557d938a55
3 changed files with 25 additions and 12 deletions
|
@ -138,18 +138,25 @@ public class AuthenticationActivity extends Activity {
|
|||
setContentView(R.layout.authentication);
|
||||
|
||||
final Intent intent = getIntent();
|
||||
myLink = Util.linkByIntent(intent);
|
||||
if (myLink == null) {
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
setResult(RESULT_CANCELED, Util.intentByLink(new Intent(), myLink));
|
||||
|
||||
final String host = intent.getStringExtra(HOST_KEY);
|
||||
final String area = intent.getStringExtra(AREA_KEY);
|
||||
final String username = intent.getStringExtra(USERNAME_KEY);
|
||||
final String error = intent.getStringExtra(ERROR_KEY);
|
||||
myCustomAuthentication = intent.getBooleanExtra(CUSTOM_AUTH_KEY, false);
|
||||
|
||||
if (myCustomAuthentication) {
|
||||
myLink = Util.linkByIntent(intent);
|
||||
if (myLink == null) {
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
setResult(RESULT_CANCELED, Util.intentByLink(new Intent(), myLink));
|
||||
} else {
|
||||
myLink = null;
|
||||
setResult(RESULT_CANCELED);
|
||||
}
|
||||
|
||||
myOnSuccessRunnable = ourOnSuccessRunnableMap.remove(intent.getLongExtra(RUNNABLE_KEY, -1));
|
||||
|
||||
myResource = ZLResource.resource("dialog").getResource("AuthenticationDialog");
|
||||
|
@ -201,9 +208,11 @@ public class AuthenticationActivity extends Activity {
|
|||
public void onClick(View v) {
|
||||
runOnUiThread(new Runnable() {
|
||||
public void run() {
|
||||
final NetworkAuthenticationManager mgr = myLink.authenticationManager();
|
||||
if (mgr.mayBeAuthorised(false)) {
|
||||
mgr.logOut();
|
||||
if (myLink != null) {
|
||||
final NetworkAuthenticationManager mgr = myLink.authenticationManager();
|
||||
if (mgr.mayBeAuthorised(false)) {
|
||||
mgr.logOut();
|
||||
}
|
||||
}
|
||||
final NetworkLibrary library = NetworkLibrary.Instance();
|
||||
library.invalidateVisibility();
|
||||
|
|
|
@ -127,7 +127,7 @@ public class NetworkLibraryActivity extends TreeActivity implements NetworkLibra
|
|||
final NetworkTree tree =
|
||||
NetworkLibrary.Instance().getCatalogTreeByUrl(intent.getData().toString());
|
||||
if (tree != null) {
|
||||
openTree(tree);
|
||||
new OpenCatalogAction(this).run(tree);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,11 +43,15 @@ public abstract class Util implements UserRegistrationConstants {
|
|||
"android.fbreader.action.NETWORK_LIBRARY_AUTOSIGNIN";
|
||||
|
||||
static INetworkLink linkByIntent(Intent intent) {
|
||||
return NetworkLibrary.Instance().getLinkByUrl(intent.getData().toString());
|
||||
final Uri uri = intent.getData();
|
||||
return uri != null ? NetworkLibrary.Instance().getLinkByUrl(uri.toString()) : null;
|
||||
}
|
||||
|
||||
static Intent intentByLink(Intent intent, INetworkLink link) {
|
||||
return intent.setData(Uri.parse(link.getUrl(UrlInfo.Type.Catalog)));
|
||||
if (link != null) {
|
||||
intent.setData(Uri.parse(link.getUrl(UrlInfo.Type.Catalog)));
|
||||
}
|
||||
return intent;
|
||||
}
|
||||
|
||||
static void initLibrary(Activity activity) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue