Update to use Quads for search hits.
diff --git a/lib/src/main/java/com/artifex/mupdf/viewer/MuPDFCore.java b/lib/src/main/java/com/artifex/mupdf/viewer/MuPDFCore.java
index d1a913b..40c62be 100644
--- a/lib/src/main/java/com/artifex/mupdf/viewer/MuPDFCore.java
+++ b/lib/src/main/java/com/artifex/mupdf/viewer/MuPDFCore.java
@@ -1,20 +1,20 @@
package com.artifex.mupdf.viewer;
import com.artifex.mupdf.fitz.Cookie;
+import com.artifex.mupdf.fitz.DisplayList;
import com.artifex.mupdf.fitz.Document;
+import com.artifex.mupdf.fitz.Link;
+import com.artifex.mupdf.fitz.Matrix;
import com.artifex.mupdf.fitz.Outline;
import com.artifex.mupdf.fitz.Page;
-import com.artifex.mupdf.fitz.Link;
-import com.artifex.mupdf.fitz.DisplayList;
+import com.artifex.mupdf.fitz.Quad;
import com.artifex.mupdf.fitz.Rect;
import com.artifex.mupdf.fitz.RectI;
-import com.artifex.mupdf.fitz.Matrix;
import com.artifex.mupdf.fitz.android.AndroidDrawDevice;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.PointF;
-import android.graphics.RectF;
import java.util.ArrayList;
@@ -125,13 +125,9 @@
return page.getLinks();
}
- public synchronized RectF[] searchPage(int pageNum, String text) {
+ public synchronized Quad[] searchPage(int pageNum, String text) {
gotoPage(pageNum);
- Rect[] rs = page.search(text);
- RectF[] rfs = new RectF[rs.length];
- for (int i=0; i < rs.length; ++i)
- rfs[i] = new RectF(rs[i].x0, rs[i].y0, rs[i].x1, rs[i].y1);
- return rfs;
+ return page.search(text);
}
public synchronized boolean hasOutline() {
diff --git a/lib/src/main/java/com/artifex/mupdf/viewer/PageView.java b/lib/src/main/java/com/artifex/mupdf/viewer/PageView.java
index abdd23e..7ca5610 100644
--- a/lib/src/main/java/com/artifex/mupdf/viewer/PageView.java
+++ b/lib/src/main/java/com/artifex/mupdf/viewer/PageView.java
@@ -2,6 +2,7 @@
import com.artifex.mupdf.fitz.Cookie;
import com.artifex.mupdf.fitz.Link;
+import com.artifex.mupdf.fitz.Quad;
import java.util.ArrayList;
import java.util.Iterator;
@@ -21,7 +22,6 @@
import android.graphics.Point;
import android.graphics.PointF;
import android.graphics.Rect;
-import android.graphics.RectF;
import android.net.Uri;
import android.os.Build;
import android.os.Handler;
@@ -76,7 +76,7 @@
private ImageView mPatch;
private Bitmap mPatchBm;
private CancellableAsyncTask<Void,Void> mDrawPatch;
- private RectF mSearchBoxes[];
+ private Quad mSearchBoxes[];
protected Link mLinks[];
private View mSearchView;
private boolean mIsBlank;
@@ -263,10 +263,15 @@
if (!mIsBlank && mSearchBoxes != null) {
paint.setColor(HIGHLIGHT_COLOR);
- for (RectF rect : mSearchBoxes)
- canvas.drawRect(rect.left*scale, rect.top*scale,
- rect.right*scale, rect.bottom*scale,
- paint);
+ for (Quad q : mSearchBoxes) {
+ Path path = new Path();
+ path.moveTo(q.ul_x * scale, q.ul_y * scale);
+ path.lineTo(q.ll_x * scale, q.ll_y * scale);
+ path.lineTo(q.lr_x * scale, q.lr_y * scale);
+ path.lineTo(q.ur_x * scale, q.ur_y * scale);
+ path.close();
+ canvas.drawPath(path, paint);
+ }
}
if (!mIsBlank && mLinks != null && mHighlightLinks) {
@@ -284,7 +289,7 @@
requestLayout();
}
- public void setSearchBoxes(RectF searchBoxes[]) {
+ public void setSearchBoxes(Quad searchBoxes[]) {
mSearchBoxes = searchBoxes;
if (mSearchView != null)
mSearchView.invalidate();
diff --git a/lib/src/main/java/com/artifex/mupdf/viewer/SearchTask.java b/lib/src/main/java/com/artifex/mupdf/viewer/SearchTask.java
index 69b116c..08d341b 100644
--- a/lib/src/main/java/com/artifex/mupdf/viewer/SearchTask.java
+++ b/lib/src/main/java/com/artifex/mupdf/viewer/SearchTask.java
@@ -1,10 +1,11 @@
package com.artifex.mupdf.viewer;
+import com.artifex.mupdf.fitz.Quad;
+
import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface;
-import android.graphics.RectF;
import android.os.Handler;
import android.os.AsyncTask;
@@ -75,7 +76,7 @@
while (0 <= index && index < mCore.countPages() && !isCancelled()) {
publishProgress(index);
- RectF searchHits[] = mCore.searchPage(index, text);
+ Quad searchHits[] = mCore.searchPage(index, text);
if (searchHits != null && searchHits.length > 0)
return new SearchTaskResult(text, index, searchHits);
diff --git a/lib/src/main/java/com/artifex/mupdf/viewer/SearchTaskResult.java b/lib/src/main/java/com/artifex/mupdf/viewer/SearchTaskResult.java
index e70db39..0eb4d39 100644
--- a/lib/src/main/java/com/artifex/mupdf/viewer/SearchTaskResult.java
+++ b/lib/src/main/java/com/artifex/mupdf/viewer/SearchTaskResult.java
@@ -1,14 +1,14 @@
package com.artifex.mupdf.viewer;
-import android.graphics.RectF;
+import com.artifex.mupdf.fitz.Quad;
public class SearchTaskResult {
public final String txt;
public final int pageNumber;
- public final RectF searchBoxes[];
+ public final Quad searchBoxes[];
static private SearchTaskResult singleton;
- SearchTaskResult(String _txt, int _pageNumber, RectF _searchBoxes[]) {
+ SearchTaskResult(String _txt, int _pageNumber, Quad _searchBoxes[]) {
txt = _txt;
pageNumber = _pageNumber;
searchBoxes = _searchBoxes;