-
Notifications
You must be signed in to change notification settings - Fork 61
Update to new pagination API #40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
dc5acd3
08cb26c
a95a287
4ec1945
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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<Page> openPages = paginationInfo.getOpenPages(); | ||
final PaginationInfo paginationInfo = PaginationInfo.fromJson(currentPagesInfo); | ||
final List<Page> 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())); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When isFixedLayout is true in PaginationInfo, the total page count is assumed to be getSpineItemCount(), rather than Page.getSpineItemPageCount() ... well, to be precise this works okay with most commercial EPUBs that are either reflow or fixed-layout, of course this calculation breaks when an EPUB contains mixed reflow-fxl spine items (known caveat). Obviously, the page index itself needs adjusting as well, so that when isFixedLayout is true in PaginationInfo, spineItemIndex is used instead of Page.getSpineItemPageIndex() References: |
||
} 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()); | ||
} | ||
}); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we rename the canGoXX field names, so that they do not overwrite the canGoXX() method names in the PaginationInfo object?
In iOS launcher we append '_':
https://github.com/readium/SDKLauncher-iOS/blob/develop/Resources/host_app_feedback.js#L94