summaryrefslogtreecommitdiff
path: root/android/src/com/artifex/mupdfdemo/MuPDFActivity.java
diff options
context:
space:
mode:
authorRobin Watts <robin.watts@artifex.com>2013-01-23 16:33:41 +0000
committerRobin Watts <robin.watts@artifex.com>2013-01-24 14:33:43 +0000
commit6cd85db89ff9a95c1d9833a0ec20ddc65adb98c4 (patch)
tree004bc9c4f20c2104e4ed5771ed20ad355f28e977 /android/src/com/artifex/mupdfdemo/MuPDFActivity.java
parent0e9c3462598dedc22ba7520865c83d29ffb160b9 (diff)
downloadmupdf-6cd85db89ff9a95c1d9833a0ec20ddc65adb98c4.tar.xz
Android: Implement 'Smart Motion'.
Currently, when the edges of the screen are tapped, we move just enough to bring the next/previous page onto the screen. When we are zoomed out, this is exactly what we want. When we are zoomed in, however, it rarely is, as 1) it doesn't allow for their being more content on the same page that we might want to view, and 2) it doesn't take us the the same region of the next page, but rather to the 'nearest edge' of the next page at the same zoom. This is particularly annoying as if we accidentally hit 'right', we can't then hit 'left' to go back to where we were. Smart Motion is an attempt to more neatly advance/retreat through the document in a logical fashion. When we are asked to 'advance', we try to advance down the page by 90% of the screen height; this will bring the next pageful of information into view, allowing for lines that might have been split over the edge of the screen before. If that would take us past the bottom of the page, we just move to the bottom of the page. If we are already at the bottom of the page, however, we consider advancing to the next 'column' of content on this page (i.e. we look to see if we have another screenful of content to the right of this one). If we do, we move to the top of the same page, at the top. If we don't, we move to the next page. When we move to the next page, we always move to the top, but our X position is chosen to match the first column of text (as calculated from the current screen position) on the next page. We assign the right hand side and bottom edges of the screen to 'advance', and the left and top edges to 'retreat'. Common use cases: * When the screen is zoomed out, left/right act precisely as they always have. * When the screen is zoomed in to avoid the margins of the page, left/right jump to the next/previous pages, with the same zoom, an improvement on the current mechanism. * When the screen is zoomed in to view a portrait file in landscape mode so that a line of text just fills the screen, left/right move nicely down the page a screenful at a time, and advances to do the same on the next page. We had no way of doing this before. * When the page is in 2 (or more) columns, and the user zooms to fit a single column in, advance nicely follows the flow across multiple pages. We had no way to do this before.
Diffstat (limited to 'android/src/com/artifex/mupdfdemo/MuPDFActivity.java')
-rw-r--r--android/src/com/artifex/mupdfdemo/MuPDFActivity.java8
1 files changed, 6 insertions, 2 deletions
diff --git a/android/src/com/artifex/mupdfdemo/MuPDFActivity.java b/android/src/com/artifex/mupdfdemo/MuPDFActivity.java
index bfe0e135..f41b6178 100644
--- a/android/src/com/artifex/mupdfdemo/MuPDFActivity.java
+++ b/android/src/com/artifex/mupdfdemo/MuPDFActivity.java
@@ -393,9 +393,13 @@ public class MuPDFActivity extends Activity
}
});
} else if (e.getX() < tapPageMargin) {
- super.moveToPrevious();
+ super.smartMoveBackwards();
} else if (e.getX() > super.getWidth()-tapPageMargin) {
- super.moveToNext();
+ super.smartMoveForwards();
+ } else if (e.getY() < tapPageMargin) {
+ super.smartMoveBackwards();
+ } else if (e.getY() > super.getHeight()-tapPageMargin) {
+ super.smartMoveForwards();
} else if (!mButtonsVisible) {
showButtons();
} else {