From 575d606b8ee1b1cac02be42ba237f1f959d419d8 Mon Sep 17 00:00:00 2001 From: Robin Watts Date: Fri, 11 Jan 2013 12:25:10 +0000 Subject: 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). --- android/src/com/artifex/mupdf/MuPDFActivity.java | 51 +++++++++++------------- 1 file changed, 24 insertions(+), 27 deletions(-) (limited to 'android/src') 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); -- cgit v1.2.3