summaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2015-04-14 16:08:28 +0200
committerRobin Watts <robin.watts@artifex.com>2015-04-14 16:14:01 +0100
commit3fdc712c45c2f91d04e44295cc7586434e23ffe7 (patch)
tree9b9cc1f9596d8ab4a955eea1359b8483be1d8ec3 /platform
parent8ee81ce0d031c3f00761c4b356cd227f31157a59 (diff)
downloadmupdf-3fdc712c45c2f91d04e44295cc7586434e23ffe7.tar.xz
android: Add EPUB support to file chooser. Fix crash on non-pdf documents.
Diffstat (limited to 'platform')
-rw-r--r--platform/android/AndroidManifest.xml14
-rw-r--r--platform/android/jni/mupdf.c5
-rw-r--r--platform/android/src/com/artifex/mupdfdemo/ChoosePDFActivity.java2
-rw-r--r--platform/android/src/com/artifex/mupdfdemo/MuPDFCore.java3
4 files changed, 21 insertions, 3 deletions
diff --git a/platform/android/AndroidManifest.xml b/platform/android/AndroidManifest.xml
index 1e07779e..de914658 100644
--- a/platform/android/AndroidManifest.xml
+++ b/platform/android/AndroidManifest.xml
@@ -48,6 +48,11 @@
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
+ <data android:mimeType="application/epub+zip"/>
+ </intent-filter>
+ <intent-filter>
+ <action android:name="android.intent.action.VIEW"/>
+ <category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data android:scheme="file"/>
<data android:mimeType="*/*"/>
@@ -72,6 +77,15 @@
<data android:pathPattern=".*\\.cbz"/>
<data android:host="*"/>
</intent-filter>
+ <intent-filter>
+ <action android:name="android.intent.action.VIEW"/>
+ <category android:name="android.intent.category.DEFAULT"/>
+ <category android:name="android.intent.category.BROWSABLE"/>
+ <data android:scheme="file"/>
+ <data android:mimeType="*/*"/>
+ <data android:pathPattern=".*\\.epub"/>
+ <data android:host="*"/>
+ </intent-filter>
</activity>
<activity
android:name="OutlineActivity"
diff --git a/platform/android/jni/mupdf.c b/platform/android/jni/mupdf.c
index d351ee6c..7a5b90f8 100644
--- a/platform/android/jni/mupdf.c
+++ b/platform/android/jni/mupdf.c
@@ -640,7 +640,9 @@ JNI_FN(MuPDFCore_javascriptSupported)(JNIEnv *env, jobject thiz)
globals *glo = get_globals(env, thiz);
fz_context *ctx = glo->ctx;
pdf_document *idoc = pdf_specifics(ctx, glo->doc);
- return pdf_js_supported(ctx, idoc);
+ if (idoc)
+ return pdf_js_supported(ctx, idoc);
+ return 0;
}
static void update_changed_rects(globals *glo, page_cache *pc, pdf_document *idoc)
@@ -847,6 +849,7 @@ static char *widget_type_string(int t)
default: return "non-widget";
}
}
+
JNIEXPORT jboolean JNICALL
JNI_FN(MuPDFCore_updatePageInternal)(JNIEnv *env, jobject thiz, jobject bitmap, int page,
int pageW, int pageH, int patchX, int patchY, int patchW, int patchH, jlong cookiePtr)
diff --git a/platform/android/src/com/artifex/mupdfdemo/ChoosePDFActivity.java b/platform/android/src/com/artifex/mupdfdemo/ChoosePDFActivity.java
index f74ccf4f..da7eafb8 100644
--- a/platform/android/src/com/artifex/mupdfdemo/ChoosePDFActivity.java
+++ b/platform/android/src/com/artifex/mupdfdemo/ChoosePDFActivity.java
@@ -106,6 +106,8 @@ public class ChoosePDFActivity extends ListActivity {
return true;
if (fname.endsWith(".cbz"))
return true;
+ if (fname.endsWith(".epub"))
+ return true;
if (fname.endsWith(".png"))
return true;
if (fname.endsWith(".jpe"))
diff --git a/platform/android/src/com/artifex/mupdfdemo/MuPDFCore.java b/platform/android/src/com/artifex/mupdfdemo/MuPDFCore.java
index 750540b7..be6f6fbf 100644
--- a/platform/android/src/com/artifex/mupdfdemo/MuPDFCore.java
+++ b/platform/android/src/com/artifex/mupdfdemo/MuPDFCore.java
@@ -128,11 +128,10 @@ public class MuPDFCore
wasOpenedFromBuffer = true;
}
- public int countPages()
+ public int countPages()
{
if (numPages < 0)
numPages = countPagesSynchronized();
-
return numPages;
}