summaryrefslogtreecommitdiff
path: root/android/src/com/artifex/mupdfdemo
diff options
context:
space:
mode:
authorPaul Gardiner <paulg.artifex@glidos.net>2013-02-25 15:29:07 +0000
committerRobin Watts <robin.watts@artifex.com>2013-02-26 19:02:02 +0000
commit08dd51d661b7e1adf925a667a548755fadbfbef7 (patch)
tree4626edb1aa0b1f9df728183cc5029e2be6e78fca /android/src/com/artifex/mupdfdemo
parent5bf497485a597a866bb5c149ef02f2b10b74e1ea (diff)
downloadmupdf-08dd51d661b7e1adf925a667a548755fadbfbef7.tar.xz
Android: add support for highlight and underline markup annotations.
Highlight annotations currently come out opaque so aren't a lot of use.
Diffstat (limited to 'android/src/com/artifex/mupdfdemo')
-rw-r--r--android/src/com/artifex/mupdfdemo/MuPDFActivity.java28
-rw-r--r--android/src/com/artifex/mupdfdemo/MuPDFCore.java6
-rw-r--r--android/src/com/artifex/mupdfdemo/MuPDFPageView.java8
-rw-r--r--android/src/com/artifex/mupdfdemo/MuPDFReflowView.java2
-rw-r--r--android/src/com/artifex/mupdfdemo/MuPDFView.java2
-rw-r--r--android/src/com/artifex/mupdfdemo/PageView.java2
6 files changed, 37 insertions, 11 deletions
diff --git a/android/src/com/artifex/mupdfdemo/MuPDFActivity.java b/android/src/com/artifex/mupdfdemo/MuPDFActivity.java
index 2e1b310c..4f10e991 100644
--- a/android/src/com/artifex/mupdfdemo/MuPDFActivity.java
+++ b/android/src/com/artifex/mupdfdemo/MuPDFActivity.java
@@ -62,6 +62,8 @@ public class MuPDFActivity extends Activity
private ImageButton mSelectButton;
private ImageButton mCancelSelectButton;
private ImageButton mCopySelectButton;
+ private ImageButton mHighlightButton;
+ private ImageButton mUnderlineButton;
private ImageButton mStrikeOutButton;
private ImageButton mCancelButton;
private ImageButton mOutlineButton;
@@ -527,11 +529,33 @@ public class MuPDFActivity extends Activity
}
});
+ mHighlightButton.setOnClickListener(new View.OnClickListener() {
+ public void onClick(View v) {
+ MuPDFView pageView = (MuPDFView) mDocView.getDisplayedView();
+ if (pageView != null)
+ pageView.markupSelection(Annotation.Type.HIGHLIGHT);
+ mDocView.setSelectionMode(false);
+ mTopBarMode = TopBarMode.Main;
+ mTopBarSwitcher.setDisplayedChild(mTopBarMode.ordinal());
+ }
+ });
+
+ mUnderlineButton.setOnClickListener(new View.OnClickListener() {
+ public void onClick(View v) {
+ MuPDFView pageView = (MuPDFView) mDocView.getDisplayedView();
+ if (pageView != null)
+ pageView.markupSelection(Annotation.Type.UNDERLINE);
+ mDocView.setSelectionMode(false);
+ mTopBarMode = TopBarMode.Main;
+ mTopBarSwitcher.setDisplayedChild(mTopBarMode.ordinal());
+ }
+ });
+
mStrikeOutButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
MuPDFView pageView = (MuPDFView) mDocView.getDisplayedView();
if (pageView != null)
- pageView.strikeOutSelection();
+ pageView.markupSelection(Annotation.Type.STRIKEOUT);
mDocView.setSelectionMode(false);
mTopBarMode = TopBarMode.Main;
mTopBarSwitcher.setDisplayedChild(mTopBarMode.ordinal());
@@ -852,6 +876,8 @@ public class MuPDFActivity extends Activity
mSelectButton = (ImageButton)mButtonsView.findViewById(R.id.selectButton);
mCancelSelectButton = (ImageButton)mButtonsView.findViewById(R.id.cancelSelectButton);
mCopySelectButton = (ImageButton)mButtonsView.findViewById(R.id.copySelectButton);
+ mHighlightButton = (ImageButton)mButtonsView.findViewById(R.id.highlightButton);
+ mUnderlineButton = (ImageButton)mButtonsView.findViewById(R.id.underlineButton);
mStrikeOutButton = (ImageButton)mButtonsView.findViewById(R.id.strikeOutButton);
mCancelButton = (ImageButton)mButtonsView.findViewById(R.id.cancel);
mOutlineButton = (ImageButton)mButtonsView.findViewById(R.id.outlineButton);
diff --git a/android/src/com/artifex/mupdfdemo/MuPDFCore.java b/android/src/com/artifex/mupdfdemo/MuPDFCore.java
index bfcb3582..424e3536 100644
--- a/android/src/com/artifex/mupdfdemo/MuPDFCore.java
+++ b/android/src/com/artifex/mupdfdemo/MuPDFCore.java
@@ -39,7 +39,7 @@ public class MuPDFCore
private native RectF[] searchPage(String text);
private native TextChar[][][][] text();
private native byte[] textAsHtml();
- private native void addStrikeOutAnnotationInternal(PointF[] quadPoints);
+ private native void addMarkupAnnotationInternal(PointF[] quadPoints, int type);
private native void deleteAnnotationInternal(int annot_index);
private native int passClickEventInternal(int page, float x, float y);
private native void setFocusedWidgetChoiceSelectedInternal(String [] selected);
@@ -248,9 +248,9 @@ public class MuPDFCore
return lns.toArray(new TextWord[lns.size()][]);
}
- public synchronized void addStrikeOutAnnotation(int page, PointF[] quadPoints) {
+ public synchronized void addMarkupAnnotation(int page, PointF[] quadPoints, Annotation.Type type) {
gotoPage(page);
- addStrikeOutAnnotationInternal(quadPoints);
+ addMarkupAnnotationInternal(quadPoints, type.ordinal());
}
public synchronized void deleteAnnotation(int page, int annot_index) {
diff --git a/android/src/com/artifex/mupdfdemo/MuPDFPageView.java b/android/src/com/artifex/mupdfdemo/MuPDFPageView.java
index d82b2d0a..092af33b 100644
--- a/android/src/com/artifex/mupdfdemo/MuPDFPageView.java
+++ b/android/src/com/artifex/mupdfdemo/MuPDFPageView.java
@@ -279,7 +279,7 @@ public class MuPDFPageView extends PageView implements MuPDFView {
return true;
}
- public void strikeOutSelection() {
+ public void markupSelection(final Annotation.Type type) {
final ArrayList<PointF> quadPoints = new ArrayList<PointF>();
processSelectedText(new TextProcessor() {
RectF rect;
@@ -305,7 +305,7 @@ public class MuPDFPageView extends PageView implements MuPDFView {
mAddStrikeOut = new AsyncTask<PointF[],Void,Void>() {
@Override
protected Void doInBackground(PointF[]... params) {
- addStrikeOut(params[0]);
+ addMarkup(params[0], type);
return null;
}
@@ -375,8 +375,8 @@ public class MuPDFPageView extends PageView implements MuPDFView {
}
@Override
- protected void addStrikeOut(PointF[] quadPoints) {
- mCore.addStrikeOutAnnotation(mPageNumber, quadPoints);
+ protected void addMarkup(PointF[] quadPoints, Annotation.Type type) {
+ mCore.addMarkupAnnotation(mPageNumber, quadPoints, type);
}
private void loadAnnotations() {
diff --git a/android/src/com/artifex/mupdfdemo/MuPDFReflowView.java b/android/src/com/artifex/mupdfdemo/MuPDFReflowView.java
index 0cc2960a..d21140f4 100644
--- a/android/src/com/artifex/mupdfdemo/MuPDFReflowView.java
+++ b/android/src/com/artifex/mupdfdemo/MuPDFReflowView.java
@@ -99,7 +99,7 @@ public class MuPDFReflowView extends WebView implements MuPDFView {
return false;
}
- public void strikeOutSelection() {
+ public void markupSelection(Annotation.Type type) {
}
public void setSearchBoxes(RectF[] searchBoxes) {
diff --git a/android/src/com/artifex/mupdfdemo/MuPDFView.java b/android/src/com/artifex/mupdfdemo/MuPDFView.java
index a213b349..fe93b532 100644
--- a/android/src/com/artifex/mupdfdemo/MuPDFView.java
+++ b/android/src/com/artifex/mupdfdemo/MuPDFView.java
@@ -15,7 +15,7 @@ public interface MuPDFView {
public void selectText(float x0, float y0, float x1, float y1);
public void deselectText();
public boolean copySelection();
- public void strikeOutSelection();
+ public void markupSelection(Annotation.Type type);
public void deleteSelectedAnnotation();
public void setSearchBoxes(RectF searchBoxes[]);
public void setLinkHighlighting(boolean f);
diff --git a/android/src/com/artifex/mupdfdemo/PageView.java b/android/src/com/artifex/mupdfdemo/PageView.java
index 2412253f..3eb1e5a3 100644
--- a/android/src/com/artifex/mupdfdemo/PageView.java
+++ b/android/src/com/artifex/mupdfdemo/PageView.java
@@ -146,7 +146,7 @@ public abstract class PageView extends ViewGroup {
protected abstract Bitmap updatePage(BitmapHolder h, int sizeX, int sizeY, int patchX, int patchY, int patchWidth, int patchHeight);
protected abstract LinkInfo[] getLinkInfo();
protected abstract TextWord[][] getText();
- protected abstract void addStrikeOut(PointF[] quadPoints);
+ protected abstract void addMarkup(PointF[] quadPoints, Annotation.Type type);
private void reinit() {
// Cancel pending render task