summaryrefslogtreecommitdiff
path: root/android/src
diff options
context:
space:
mode:
Diffstat (limited to 'android/src')
-rw-r--r--android/src/com/artifex/mupdf/MuPDFActivity.java22
-rw-r--r--android/src/com/artifex/mupdf/MuPDFCore.java10
2 files changed, 32 insertions, 0 deletions
diff --git a/android/src/com/artifex/mupdf/MuPDFActivity.java b/android/src/com/artifex/mupdf/MuPDFActivity.java
index 194bc3d9..a177d092 100644
--- a/android/src/com/artifex/mupdf/MuPDFActivity.java
+++ b/android/src/com/artifex/mupdf/MuPDFActivity.java
@@ -919,4 +919,26 @@ public class MuPDFActivity extends Activity
super.onStop();
}
+
+ @Override
+ public void onBackPressed() {
+ if (core.hasChanges()) {
+ DialogInterface.OnClickListener listener = new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int which) {
+ if (which == AlertDialog.BUTTON_POSITIVE)
+ core.save();
+
+ finish();
+ }
+ };
+ AlertDialog alert = mAlertBuilder.create();
+ alert.setTitle("MuPDF");
+ alert.setMessage("Document has changes. Save them?");
+ alert.setButton(AlertDialog.BUTTON_POSITIVE, "Yes", listener);
+ alert.setButton(AlertDialog.BUTTON_NEGATIVE, "No", listener);
+ alert.show();
+ } else {
+ super.onBackPressed();
+ }
+ }
}
diff --git a/android/src/com/artifex/mupdf/MuPDFCore.java b/android/src/com/artifex/mupdf/MuPDFCore.java
index 98413504..13718508 100644
--- a/android/src/com/artifex/mupdf/MuPDFCore.java
+++ b/android/src/com/artifex/mupdf/MuPDFCore.java
@@ -48,6 +48,8 @@ public class MuPDFCore
private static native void startAlertsInternal();
private static native void stopAlertsInternal();
private static native void destroying();
+ private static native boolean hasChangesInternal();
+ private static native void saveInternal();
public static native boolean javascriptSupported();
@@ -196,4 +198,12 @@ public class MuPDFCore
public synchronized boolean authenticatePassword(String password) {
return authenticatePasswordInternal(password);
}
+
+ public synchronized boolean hasChanges() {
+ return hasChangesInternal();
+ }
+
+ public synchronized void save() {
+ saveInternal();
+ }
}