diff options
author | Robin Watts <robin.watts@artifex.com> | 2013-01-11 12:25:10 +0000 |
---|---|---|
committer | Robin Watts <robin.watts@artifex.com> | 2013-01-11 15:20:14 +0000 |
commit | 575d606b8ee1b1cac02be42ba237f1f959d419d8 (patch) | |
tree | b1dfbfc9647b5322114c2bf23edc522ff2f93025 | |
parent | f30db116a89652de0da03e27513753f0e432fd1a (diff) | |
download | mupdf-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 é 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.java | 51 |
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); |