diff --git a/SDKLauncher-Android/assets/readium-shared-js/host_app_feedback.js b/SDKLauncher-Android/assets/readium-shared-js/host_app_feedback.js
index 73ed9080..3abe4e5e 100644
--- a/SDKLauncher-Android/assets/readium-shared-js/host_app_feedback.js
+++ b/SDKLauncher-Android/assets/readium-shared-js/host_app_feedback.js
@@ -87,10 +87,15 @@ ReadiumSDK.HostAppFeedback = function() {
}, this);
- this.onPaginationChanged = function(paginationInfo) {
+ this.onPaginationChanged = function(pageChangeData) {
if (window.LauncherUI) {
- window.LauncherUI.onPaginationChanged(JSON.stringify(paginationInfo.paginationInfo));
+ var staticPaginationInfo = pageChangeData.paginationInfo;
+ staticPaginationInfo.canGoLeft = staticPaginationInfo.canGoLeft();
+ staticPaginationInfo.canGoRight = staticPaginationInfo.canGoRight();
+ staticPaginationInfo.canGoNext = staticPaginationInfo.canGoNext();
+ staticPaginationInfo.canGoPrev = staticPaginationInfo.canGoPrev();
+ window.LauncherUI.onPaginationChanged(JSON.stringify(staticPaginationInfo));
if(window.LauncherUI.onIsMediaOverlayAvailable){
window.LauncherUI.onIsMediaOverlayAvailable(ReadiumSDK.reader.isMediaOverlayAvailable());
diff --git a/SDKLauncher-Android/res/values/strings.xml b/SDKLauncher-Android/res/values/strings.xml
index 0c270449..0214b843 100644
--- a/SDKLauncher-Android/res/values/strings.xml
+++ b/SDKLauncher-Android/res/values/strings.xml
@@ -28,6 +28,7 @@
Title: %1$s
Page List
Page %1$d of %2$d
+ Page %1$d-%2$d of %3$d
Spine Items
Table of Contents
WebViewActivity
diff --git a/SDKLauncher-Android/src/org/readium/sdk/android/launcher/WebViewActivity.java b/SDKLauncher-Android/src/org/readium/sdk/android/launcher/WebViewActivity.java
index d48210c4..65762dba 100644
--- a/SDKLauncher-Android/src/org/readium/sdk/android/launcher/WebViewActivity.java
+++ b/SDKLauncher-Android/src/org/readium/sdk/android/launcher/WebViewActivity.java
@@ -77,6 +77,7 @@
import android.webkit.WebResourceResponse;
import android.webkit.WebView;
import android.webkit.WebViewClient;
+import android.widget.Button;
import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.TextView;
@@ -133,6 +134,10 @@ public class WebViewActivity extends FragmentActivity implements ViewerSettingsD
private ViewerSettings mViewerSettings;
private ReadiumJSApi mReadiumJSApi;
private EpubServer mServer;
+
+ private Button mLeftButton;
+ private Button mRightButton;
+
private boolean mIsMoAvailable;
private boolean mIsMoPlaying;
@@ -148,7 +153,10 @@ protected void onCreate(Bundle savedInstanceState) {
&& 0 != (getApplicationInfo().flags &= ApplicationInfo.FLAG_DEBUGGABLE)) {
mWebview.setWebContentsDebuggingEnabled(true);
}
-
+
+ mLeftButton = (Button) findViewById(R.id.left);
+ mRightButton = (Button) findViewById(R.id.right);
+
mPageInfo = (TextView) findViewById(R.id.page_info);
initWebView();
@@ -497,19 +505,31 @@ public class EpubInterface {
public void onPaginationChanged(String currentPagesInfo) {
Log.d(TAG, "onPaginationChanged: "+currentPagesInfo);
try {
- PaginationInfo paginationInfo = PaginationInfo.fromJson(currentPagesInfo);
- List openPages = paginationInfo.getOpenPages();
+ final PaginationInfo paginationInfo = PaginationInfo.fromJson(currentPagesInfo);
+ final List openPages = paginationInfo.getOpenPages();
if (!openPages.isEmpty()) {
- final Page page = openPages.get(0);
+
+ final Page firstVisiblePage = openPages.get(0);
runOnUiThread(new Runnable() {
public void run() {
+ if(openPages.size() == 1){
mPageInfo.setText(getString(R.string.page_x_of_y,
- page.getSpineItemPageIndex() + 1,
- page.getSpineItemPageCount()));
- SpineItem spineItem = mPackage.getSpineItem(page.getIdref());
+ firstVisiblePage.getSpineItemPageIndex() + 1,
+ firstVisiblePage.getSpineItemPageCount()));
+ } else {
+ Page lastVisiblePage = openPages.get(openPages.size() - 1);
+ mPageInfo.setText(getString(R.string.page_x_dash_y_of_z,
+ firstVisiblePage.getSpineItemPageIndex() + 1,
+ lastVisiblePage.getSpineItemPageIndex() + 1,
+ firstVisiblePage.getSpineItemPageCount()));
+ }
+
+ SpineItem spineItem = mPackage.getSpineItem(firstVisiblePage.getIdref());
boolean isFixedLayout = spineItem.isFixedLayout();
mWebview.getSettings().setBuiltInZoomControls(isFixedLayout);
mWebview.getSettings().setDisplayZoomControls(false);
+ mLeftButton.setEnabled(paginationInfo.canGoLeft());
+ mRightButton.setEnabled(paginationInfo.canGoRight());
}
});
}
diff --git a/SDKLauncher-Android/src/org/readium/sdk/android/launcher/model/PaginationInfo.java b/SDKLauncher-Android/src/org/readium/sdk/android/launcher/model/PaginationInfo.java
index e970f7ca..1fd7affe 100644
--- a/SDKLauncher-Android/src/org/readium/sdk/android/launcher/model/PaginationInfo.java
+++ b/SDKLauncher-Android/src/org/readium/sdk/android/launcher/model/PaginationInfo.java
@@ -40,21 +40,29 @@
public class PaginationInfo {
- private final String pageProgressionDirection;
+ private final boolean isRightToLeft;
private final boolean isFixedLayout;
private final int spineItemCount;
private final List openPages;
-
- public PaginationInfo(String pageProgressionDirection,
- boolean isFixedLayout, int spineItemCount) {
- this.pageProgressionDirection = pageProgressionDirection;
- this.isFixedLayout = isFixedLayout;
- this.spineItemCount = spineItemCount;
- this.openPages = new ArrayList();
- }
+ private final boolean canGoLeft;
+ private final boolean canGoRight;
+ private final boolean canGoPrev;
+ private final boolean canGoNext;
+
+ public PaginationInfo(boolean isRightToLeft, boolean isFixedLayout, int spineItemCount, boolean canGoLeft, boolean canGoRight, boolean canGoPrev, boolean canGoNext) {
- public String getPageProgressionDirection() {
- return pageProgressionDirection;
+ this.isRightToLeft = isRightToLeft;
+ this.isFixedLayout = isFixedLayout;
+ this.spineItemCount = spineItemCount;
+ this.openPages = new ArrayList();
+ this.canGoLeft = canGoLeft;
+ this.canGoRight = canGoRight;
+ this.canGoPrev = canGoPrev;
+ this.canGoNext = canGoNext;
+ }
+
+ public boolean isRightToLeft() {
+ return isRightToLeft;
}
public boolean isFixedLayout() {
@@ -68,12 +76,32 @@ public int getSpineItemCount() {
public List getOpenPages() {
return openPages;
}
-
- public static PaginationInfo fromJson(String jsonString) throws JSONException {
+
+ public boolean canGoLeft() {
+ return canGoLeft;
+ }
+
+ public boolean canGoRight() {
+ return canGoRight;
+ }
+
+ public boolean canGoPrev() {
+ return canGoPrev;
+ }
+
+ public boolean canGoNext() {
+ return canGoNext;
+ }
+
+ public static PaginationInfo fromJson(String jsonString) throws JSONException {
JSONObject json = new JSONObject(jsonString);
- PaginationInfo paginationInfo = new PaginationInfo(json.optString("pageProgressionDirection", "ltr"),
- json.optBoolean("isFixedLayout"),
- json.optInt("spineItemCount"));
+ PaginationInfo paginationInfo = new PaginationInfo(json.optBoolean("isRightToLeft"),
+ json.optBoolean("isFixedLayout"),
+ json.optInt("spineItemCount"),
+ json.optBoolean("canGoLeft"),
+ json.optBoolean("canGoRight"),
+ json.optBoolean("canGoPrev"),
+ json.optBoolean("canGoNext"));
JSONArray openPages = json.getJSONArray("openPages");
for (int i = 0; i < openPages.length(); i++) {
JSONObject p = openPages.getJSONObject(i);