diff options
author | Paul Gardiner <paulg.artifex@glidos.net> | 2013-03-06 11:10:29 +0000 |
---|---|---|
committer | Paul Gardiner <paulg.artifex@glidos.net> | 2013-03-24 16:53:14 +0000 |
commit | 03a7b530fc05426f4b9537784b6dab5e45a337f6 (patch) | |
tree | 05c38df0a9282642f3c2c5d9619a2d41e6e2ce75 /android | |
parent | 8a11586f923bf202083e37a98f7f1140dc1a8cdb (diff) | |
download | mupdf-03a7b530fc05426f4b9537784b6dab5e45a337f6.tar.xz |
Add another input mode for drawing ink annotations
Diffstat (limited to 'android')
-rw-r--r-- | android/src/com/artifex/mupdfdemo/MuPDFActivity.java | 12 | ||||
-rw-r--r-- | android/src/com/artifex/mupdfdemo/MuPDFReaderView.java | 32 |
2 files changed, 30 insertions, 14 deletions
diff --git a/android/src/com/artifex/mupdfdemo/MuPDFActivity.java b/android/src/com/artifex/mupdfdemo/MuPDFActivity.java index be8dca89..41a71405 100644 --- a/android/src/com/artifex/mupdfdemo/MuPDFActivity.java +++ b/android/src/com/artifex/mupdfdemo/MuPDFActivity.java @@ -471,7 +471,7 @@ public class MuPDFActivity extends Activity // Activate the select button mSelectButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { - mDocView.setSelectionMode(true); + mDocView.setMode(MuPDFReaderView.Mode.Selecting); mTopBarMode = TopBarMode.Text; mTopBarSwitcher.setDisplayedChild(mTopBarMode.ordinal()); } @@ -482,7 +482,7 @@ public class MuPDFActivity extends Activity MuPDFView pageView = (MuPDFView) mDocView.getDisplayedView(); if (pageView != null) pageView.deselectText(); - mDocView.setSelectionMode(false); + mDocView.setMode(MuPDFReaderView.Mode.Viewing); mTopBarMode = TopBarMode.Main; mTopBarSwitcher.setDisplayedChild(mTopBarMode.ordinal()); } @@ -495,7 +495,7 @@ public class MuPDFActivity extends Activity boolean copied = false; if (pageView != null) copied = pageView.copySelection(); - mDocView.setSelectionMode(false); + mDocView.setMode(MuPDFReaderView.Mode.Viewing); mTopBarMode = TopBarMode.Main; mTopBarSwitcher.setDisplayedChild(mTopBarMode.ordinal()); mInfoView.setText(copied?"Copied to clipboard":"No text selected"); @@ -536,7 +536,7 @@ public class MuPDFActivity extends Activity MuPDFView pageView = (MuPDFView) mDocView.getDisplayedView(); if (pageView != null) pageView.markupSelection(Annotation.Type.HIGHLIGHT); - mDocView.setSelectionMode(false); + mDocView.setMode(MuPDFReaderView.Mode.Viewing); mTopBarMode = TopBarMode.Main; mTopBarSwitcher.setDisplayedChild(mTopBarMode.ordinal()); } @@ -547,7 +547,7 @@ public class MuPDFActivity extends Activity MuPDFView pageView = (MuPDFView) mDocView.getDisplayedView(); if (pageView != null) pageView.markupSelection(Annotation.Type.UNDERLINE); - mDocView.setSelectionMode(false); + mDocView.setMode(MuPDFReaderView.Mode.Viewing); mTopBarMode = TopBarMode.Main; mTopBarSwitcher.setDisplayedChild(mTopBarMode.ordinal()); } @@ -558,7 +558,7 @@ public class MuPDFActivity extends Activity MuPDFView pageView = (MuPDFView) mDocView.getDisplayedView(); if (pageView != null) pageView.markupSelection(Annotation.Type.STRIKEOUT); - mDocView.setSelectionMode(false); + mDocView.setMode(MuPDFReaderView.Mode.Viewing); mTopBarMode = TopBarMode.Main; mTopBarSwitcher.setDisplayedChild(mTopBarMode.ordinal()); } diff --git a/android/src/com/artifex/mupdfdemo/MuPDFReaderView.java b/android/src/com/artifex/mupdfdemo/MuPDFReaderView.java index 13575dc7..6ddb69da 100644 --- a/android/src/com/artifex/mupdfdemo/MuPDFReaderView.java +++ b/android/src/com/artifex/mupdfdemo/MuPDFReaderView.java @@ -10,9 +10,10 @@ import android.view.ScaleGestureDetector; import android.view.View; public class MuPDFReaderView extends ReaderView { + enum Mode {Viewing, Selecting, Drawing} private final Context mContext; private boolean mLinksEnabled = false; - private boolean mSelecting = false; + private Mode mMode = Mode.Viewing; private boolean tapDisabled = false; private int tapPageMargin; @@ -25,8 +26,8 @@ public class MuPDFReaderView extends ReaderView { resetupChildren(); } - public void setSelectionMode(boolean b) { - mSelecting = b; + public void setMode(Mode m) { + mMode = m; } public MuPDFReaderView(Activity act) { @@ -51,7 +52,7 @@ public class MuPDFReaderView extends ReaderView { public boolean onSingleTapUp(MotionEvent e) { LinkInfo link = null; - if (!mSelecting && !tapDisabled) { + if (mMode == Mode.Viewing && !tapDisabled) { MuPDFView pageView = (MuPDFView) getDisplayedView(); Hit item = pageView.passClickEvent(e.getX(), e.getY()); onHit(item); @@ -93,28 +94,43 @@ public class MuPDFReaderView extends ReaderView { return super.onSingleTapUp(e); } + @Override + public void onShowPress(MotionEvent e) { + switch (mMode) { + case Drawing: + break; + } + } + public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) { - if (!mSelecting) { + switch (mMode) { + case Viewing: if (!tapDisabled) onDocMotion(); return super.onScroll(e1, e2, distanceX, distanceY); - } else { + case Selecting: MuPDFView pageView = (MuPDFView)getDisplayedView(); if (pageView != null) pageView.selectText(e1.getX(), e1.getY(), e2.getX(), e2.getY()); return true; + case Drawing: + return true; + default: + return true; } } @Override public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { - if (!mSelecting) + switch (mMode) { + case Viewing: return super.onFling(e1, e2, velocityX, velocityY); - else + default: return true; + } } public boolean onScaleBegin(ScaleGestureDetector d) { |