diff --git a/TODO.litres b/TODO.litres
index 44ed4c8d4..c26963ee2 100644
--- a/TODO.litres
+++ b/TODO.litres
@@ -1,6 +1,6 @@
-buy book after registration
-buy book after auto-sign-in
auto-sign-in
+resources synchronization
+honeycomb
do we cache cover images?
states:
diff --git a/assets/resources/application/en.xml b/assets/resources/application/en.xml
index fe00b022c..23c2defd2 100644
--- a/assets/resources/application/en.xml
+++ b/assets/resources/application/en.xml
@@ -91,7 +91,7 @@
-
+
@@ -135,6 +135,7 @@
+
@@ -254,6 +255,7 @@
+
diff --git a/assets/resources/application/ru.xml b/assets/resources/application/ru.xml
index 74dc40a95..971fad1fe 100644
--- a/assets/resources/application/ru.xml
+++ b/assets/resources/application/ru.xml
@@ -91,7 +91,7 @@
-
+
@@ -135,6 +135,7 @@
+
@@ -254,6 +255,7 @@
+
diff --git a/src/org/geometerplus/android/fbreader/network/AccountMenuActivity.java b/src/org/geometerplus/android/fbreader/network/AccountMenuActivity.java
index 94395c622..73f49a4a2 100644
--- a/src/org/geometerplus/android/fbreader/network/AccountMenuActivity.java
+++ b/src/org/geometerplus/android/fbreader/network/AccountMenuActivity.java
@@ -48,7 +48,7 @@ public class AccountMenuActivity extends MenuActivity {
@Override
protected void init() {
- setTitle(NetworkLibrary.resource().getResource("accountMenuTitle").getValue());
+ setTitle(NetworkLibrary.resource().getResource("authorizationMenuTitle").getValue());
final String url = getIntent().getData().toString();
myLink = NetworkLibrary.Instance().getLinkByUrl(url);
@@ -63,7 +63,7 @@ public class AccountMenuActivity extends MenuActivity {
@Override
protected String getAction() {
- return "android.fbreader.action.network.ACCOUNT";
+ return Util.AUTHORIZATION_ACTION;
}
@Override
diff --git a/src/org/geometerplus/android/fbreader/network/BuyBooksActivity.java b/src/org/geometerplus/android/fbreader/network/BuyBooksActivity.java
index 5156ca214..616c4622e 100644
--- a/src/org/geometerplus/android/fbreader/network/BuyBooksActivity.java
+++ b/src/org/geometerplus/android/fbreader/network/BuyBooksActivity.java
@@ -54,6 +54,16 @@ public class BuyBooksActivity extends Activity {
return;
}
+ final Intent intent = new Intent(activity, BuyBooksActivity.class);
+ final ArrayList keys =
+ new ArrayList(trees.size());
+ for (NetworkBookTree t : trees) {
+ keys.add(t.getUniqueKey());
+ }
+ intent.putExtra(NetworkLibraryActivity.TREE_KEY_KEY, keys);
+ activity.startActivity(intent);
+
+ /*
final INetworkLink link = trees.get(0).getLink();
final NetworkAuthenticationManager mgr = link.authenticationManager();
if (mgr == null) {
@@ -75,9 +85,11 @@ public class BuyBooksActivity extends Activity {
}
} catch (ZLNetworkException e) {
}
+ */
}
private NetworkLibrary myLibrary;
+ // we assume all the books are from the same catalog
private INetworkLink myLink;
private List myBooks;
private Money myCost;
@@ -87,7 +99,6 @@ public class BuyBooksActivity extends Activity {
protected void onCreate(Bundle bundle) {
super.onCreate(bundle);
Thread.setDefaultUncaughtExceptionHandler(new org.geometerplus.zlibrary.ui.android.library.UncaughtExceptionHandler(this));
- setContentView(R.layout.buy_book);
myLibrary = NetworkLibrary.Instance();
@@ -109,6 +120,23 @@ public class BuyBooksActivity extends Activity {
return;
}
}
+
+ myLink = myBooks.get(0).Link;
+ final NetworkAuthenticationManager mgr = myLink.authenticationManager();
+ if (mgr == null) {
+ finish();
+ return;
+ }
+
+ try {
+ if (!mgr.isAuthorised(true)) {
+ AccountMenuActivity.runMenu(this, myLink);
+ }
+ } catch (ZLNetworkException e) {
+ }
+
+ setContentView(R.layout.buy_book);
+
myCost = calculateCost();
if (myCost == null) {
// TODO: error message
@@ -116,19 +144,12 @@ public class BuyBooksActivity extends Activity {
return;
}
- // we assume all the books are from the same catalog
- myLink = myBooks.get(0).Link;
- final NetworkAuthenticationManager mgr = myLink.authenticationManager();
- if (mgr == null) {
- finish();
- return;
- }
myAccount = mgr.currentAccount();
- setupUI();
+ setupUI(true);
}
- private void setupUI() {
+ private void setupUI(boolean authorized) {
final ZLResource dialogResource = ZLResource.resource("dialog");
final ZLResource buttonResource = dialogResource.getResource("button");
@@ -145,7 +166,21 @@ public class BuyBooksActivity extends Activity {
setTitle(resource.getResource("title").getValue());
}
- if (myAccount == null) {
+ if (!authorized) {
+ textArea.setText(resource.getResource("notAuthorized").getValue());
+ okButton.setText(buttonResource.getResource("authorize").getValue());
+ cancelButton.setText(buttonResource.getResource("cancel").getValue());
+ okButton.setOnClickListener(new View.OnClickListener() {
+ public void onClick(View v) {
+ AccountMenuActivity.runMenu(BuyBooksActivity.this, myLink);
+ }
+ });
+ cancelButton.setOnClickListener(new View.OnClickListener() {
+ public void onClick(View v) {
+ finish();
+ }
+ });
+ } else if (myAccount == null) {
textArea.setText(resource.getResource("noAccountInformation").getValue());
okButton.setText(buttonResource.getResource("refresh").getValue());
cancelButton.setText(buttonResource.getResource("cancel").getValue());
@@ -212,7 +247,17 @@ public class BuyBooksActivity extends Activity {
@Override
protected void onResume() {
super.onResume();
- refreshAccountInformation();
+
+ final NetworkAuthenticationManager mgr = myLink.authenticationManager();
+ try {
+ if (mgr.isAuthorised(true)) {
+ refreshAccountInformation();
+ } else {
+ setupUI(false);
+ }
+ } catch (ZLNetworkException e) {
+ setupUI(false);
+ }
}
private Money calculateCost() {
@@ -255,7 +300,7 @@ public class BuyBooksActivity extends Activity {
if (updated) {
runOnUiThread(new Runnable() {
public void run() {
- setupUI();
+ setupUI(true);
}
});
}
diff --git a/src/org/geometerplus/android/fbreader/network/Util.java b/src/org/geometerplus/android/fbreader/network/Util.java
index a8a416c5c..0b23f2487 100644
--- a/src/org/geometerplus/android/fbreader/network/Util.java
+++ b/src/org/geometerplus/android/fbreader/network/Util.java
@@ -36,7 +36,7 @@ import org.geometerplus.android.util.UIUtil;
import org.geometerplus.android.util.PackageUtil;
public abstract class Util implements UserRegistrationConstants {
- static final String ACCOUNT_ACTION = "android.fbreader.action.network.ACCOUNT";
+ static final String AUTHORIZATION_ACTION = "android.fbreader.action.network.AUTHORIZATION";
public static Intent intentByLink(Intent intent, INetworkLink link) {
if (link != null) {
@@ -69,7 +69,7 @@ public abstract class Util implements UserRegistrationConstants {
public static boolean isRegistrationSupported(Activity activity, INetworkLink link) {
return testService(
activity,
- ACCOUNT_ACTION,
+ AUTHORIZATION_ACTION,
link.getUrl(UrlInfo.Type.Catalog) + "/register"
);
}
@@ -77,7 +77,7 @@ public abstract class Util implements UserRegistrationConstants {
public static void runRegistrationDialog(Activity activity, INetworkLink link) {
try {
final Intent intent = new Intent(
- ACCOUNT_ACTION,
+ AUTHORIZATION_ACTION,
Uri.parse(link.getUrl(UrlInfo.Type.Catalog) + "/register")
);
intent.putExtra(UserRegistrationConstants.SIGNUP_URL, link.getUrl(UrlInfo.Type.SignUp));