summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin Watts <robin.watts@artifex.com>2013-01-11 12:25:10 +0000
committerRobin Watts <robin.watts@artifex.com>2013-01-11 15:20:14 +0000
commit575d606b8ee1b1cac02be42ba237f1f959d419d8 (patch)
treeb1dfbfc9647b5322114c2bf23edc522ff2f93025
parentf30db116a89652de0da03e27513753f0e432fd1a (diff)
downloadmupdf-575d606b8ee1b1cac02be42ba237f1f959d419d8.tar.xz
Bug 693547: Android external hyperlink support
Paul had written code before to detect clicks on hyperlinks, but we hadn't actually done anything with these clicks once detected. Andre Ferreira supplied a couple of lines of Android magic to form the Intent from the URL and execute it. Incorporate that here. (Andre should have &eacute; but this upsets git/my editor, sorry) As part of this patch, we now respond to links at a higher priority than the left/right clicks to flip pages (but only if link following mode is enabled).
-rw-r--r--android/src/com/artifex/mupdf/MuPDFActivity.java51
1 files changed, 24 insertions, 27 deletions
diff --git a/android/src/com/artifex/mupdf/MuPDFActivity.java b/android/src/com/artifex/mupdf/MuPDFActivity.java
index 0cf14413..0f20f580 100644
--- a/android/src/com/artifex/mupdf/MuPDFActivity.java
+++ b/android/src/com/artifex/mupdf/MuPDFActivity.java
@@ -351,42 +351,39 @@ public class MuPDFActivity extends Activity
private boolean showButtonsDisabled;
public boolean onSingleTapUp(MotionEvent e) {
+ LinkInfo link = null;
+
if (!mSelecting && !showButtonsDisabled) {
MuPDFPageView pageView = (MuPDFPageView) mDocView.getDisplayedView();
if (MuPDFCore.javascriptSupported() && pageView.passClickEvent(e.getX(), e.getY())) {
// If the page consumes the event do nothing else
+ } else if (mLinkHighlight && pageView != null && (link = pageView.hitLink(e.getX(), e.getY())) != null) {
+ link.acceptVisitor(new LinkInfoVisitor() {
+ @Override
+ public void visitInternal(LinkInfoInternal li) {
+ // Clicked on an internal (GoTo) link
+ mDocView.setDisplayedViewIndex(li.pageNumber);
+ }
+
+ @Override
+ public void visitExternal(LinkInfoExternal li) {
+ Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(li.url));
+ startActivity(intent);
+ }
+
+ @Override
+ public void visitRemote(LinkInfoRemote li) {
+ // Clicked on a remote (GoToR) link
+ }
+ });
} else if (e.getX() < super.getWidth()/TAP_PAGE_MARGIN) {
super.moveToPrevious();
} else if (e.getX() > super.getWidth()*(TAP_PAGE_MARGIN-1)/TAP_PAGE_MARGIN) {
super.moveToNext();
+ } else if (!mButtonsVisible) {
+ showButtons();
} else {
- LinkInfo link = null;
- if (mLinkHighlight && pageView != null) {
- link = pageView.hitLink(e.getX(), e.getY());
- }
- if (link != null) {
- link.acceptVisitor(new LinkInfoVisitor() {
- @Override
- public void visitInternal(LinkInfoInternal li) {
- // Clicked on an internal (GoTo) link
- mDocView.setDisplayedViewIndex(li.pageNumber);
- }
- @Override
- public void visitExternal(LinkInfoExternal li) {
- // Clicked on an external (URI) link: li.url
- }
- @Override
- public void visitRemote(LinkInfoRemote li) {
- // Clicked on a remote (GoToR) link
- }
- });
- } else {
- if (!mButtonsVisible) {
- showButtons();
- } else {
- hideButtons();
- }
- }
+ hideButtons();
}
}
return super.onSingleTapUp(e);