diff options
Diffstat (limited to 'java/org')
| -rw-r--r-- | java/org/gnu/emacs/EmacsApplication.java | 54 | ||||
| -rw-r--r-- | java/org/gnu/emacs/EmacsNative.java | 4 | ||||
| -rw-r--r-- | java/org/gnu/emacs/EmacsPreferencesActivity.java | 27 | ||||
| -rw-r--r-- | java/org/gnu/emacs/EmacsService.java | 25 | ||||
| -rw-r--r-- | java/org/gnu/emacs/EmacsThread.java | 19 |
5 files changed, 124 insertions, 5 deletions
diff --git a/java/org/gnu/emacs/EmacsApplication.java b/java/org/gnu/emacs/EmacsApplication.java index 125da05cfd4..87085c32d62 100644 --- a/java/org/gnu/emacs/EmacsApplication.java +++ b/java/org/gnu/emacs/EmacsApplication.java | |||
| @@ -19,9 +19,59 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */ | |||
| 19 | 19 | ||
| 20 | package org.gnu.emacs; | 20 | package org.gnu.emacs; |
| 21 | 21 | ||
| 22 | import java.io.File; | ||
| 23 | import java.io.FileFilter; | ||
| 24 | |||
| 22 | import android.app.Application; | 25 | import android.app.Application; |
| 26 | import android.util.Log; | ||
| 23 | 27 | ||
| 24 | public class EmacsApplication extends Application | 28 | public class EmacsApplication extends Application implements FileFilter |
| 25 | { | 29 | { |
| 26 | /* This class currently does nothing. */ | 30 | private static final String TAG = "EmacsApplication"; |
| 31 | |||
| 32 | /* The name of the dump file to use. */ | ||
| 33 | public static String dumpFileName; | ||
| 34 | |||
| 35 | @Override | ||
| 36 | public boolean | ||
| 37 | accept (File file) | ||
| 38 | { | ||
| 39 | return (!file.isDirectory () | ||
| 40 | && file.getName ().endsWith (".pdmp")); | ||
| 41 | } | ||
| 42 | |||
| 43 | @Override | ||
| 44 | public void | ||
| 45 | onCreate () | ||
| 46 | { | ||
| 47 | File filesDirectory; | ||
| 48 | File[] allFiles; | ||
| 49 | String wantedDumpFile; | ||
| 50 | int i; | ||
| 51 | |||
| 52 | wantedDumpFile = ("emacs-" + EmacsNative.getFingerprint () | ||
| 53 | + ".pdmp"); | ||
| 54 | |||
| 55 | Log.d (TAG, "onCreate: looking for " + wantedDumpFile); | ||
| 56 | |||
| 57 | /* Obtain a list of all files ending with ``.pdmp''. Then, look | ||
| 58 | for a file named ``emacs-<fingerprint>.pdmp'' and delete the | ||
| 59 | rest. */ | ||
| 60 | filesDirectory = getFilesDir (); | ||
| 61 | allFiles = filesDirectory.listFiles (this); | ||
| 62 | |||
| 63 | /* Now try to find the right dump file. */ | ||
| 64 | for (i = 0; i < allFiles.length; ++i) | ||
| 65 | { | ||
| 66 | if (allFiles[i].getName ().equals (wantedDumpFile)) | ||
| 67 | dumpFileName = allFiles[i].getAbsolutePath (); | ||
| 68 | else | ||
| 69 | /* Delete this outdated dump file. */ | ||
| 70 | allFiles[i].delete (); | ||
| 71 | } | ||
| 72 | |||
| 73 | Log.d (TAG, "onCreate: found " + dumpFileName); | ||
| 74 | |||
| 75 | super.onCreate (); | ||
| 76 | } | ||
| 27 | }; | 77 | }; |
diff --git a/java/org/gnu/emacs/EmacsNative.java b/java/org/gnu/emacs/EmacsNative.java index 962538bef7b..9636561a524 100644 --- a/java/org/gnu/emacs/EmacsNative.java +++ b/java/org/gnu/emacs/EmacsNative.java | |||
| @@ -25,6 +25,10 @@ import android.content.res.AssetManager; | |||
| 25 | 25 | ||
| 26 | public class EmacsNative | 26 | public class EmacsNative |
| 27 | { | 27 | { |
| 28 | /* Obtain the fingerprint of this build of Emacs. The fingerprint | ||
| 29 | can be used to determine the dump file name. */ | ||
| 30 | public static native String getFingerprint (); | ||
| 31 | |||
| 28 | /* Set certain parameters before initializing Emacs. This proves | 32 | /* Set certain parameters before initializing Emacs. This proves |
| 29 | that libemacs.so is being loaded from Java code. | 33 | that libemacs.so is being loaded from Java code. |
| 30 | 34 | ||
diff --git a/java/org/gnu/emacs/EmacsPreferencesActivity.java b/java/org/gnu/emacs/EmacsPreferencesActivity.java index 0db983984fd..ed1db68f732 100644 --- a/java/org/gnu/emacs/EmacsPreferencesActivity.java +++ b/java/org/gnu/emacs/EmacsPreferencesActivity.java | |||
| @@ -19,6 +19,8 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */ | |||
| 19 | 19 | ||
| 20 | package org.gnu.emacs; | 20 | package org.gnu.emacs; |
| 21 | 21 | ||
| 22 | import java.io.File; | ||
| 23 | |||
| 22 | import android.app.Activity; | 24 | import android.app.Activity; |
| 23 | import android.content.Intent; | 25 | import android.content.Intent; |
| 24 | import android.os.Bundle; | 26 | import android.os.Bundle; |
| @@ -93,6 +95,31 @@ public class EmacsPreferencesActivity extends Activity | |||
| 93 | }); | 95 | }); |
| 94 | layout.addView (textView); | 96 | layout.addView (textView); |
| 95 | 97 | ||
| 98 | textView = new TextView (this); | ||
| 99 | textView.setPadding (8, 20, 20, 8); | ||
| 100 | |||
| 101 | params = new LinearLayout.LayoutParams (LayoutParams.MATCH_PARENT, | ||
| 102 | LayoutParams.WRAP_CONTENT); | ||
| 103 | textView.setLayoutParams (params); | ||
| 104 | textView.setText ("Erase dump file"); | ||
| 105 | textView.setOnClickListener (new View.OnClickListener () { | ||
| 106 | @Override | ||
| 107 | public void | ||
| 108 | onClick (View view) | ||
| 109 | { | ||
| 110 | String wantedDumpFile; | ||
| 111 | File file; | ||
| 112 | |||
| 113 | wantedDumpFile = ("emacs-" + EmacsNative.getFingerprint () | ||
| 114 | + ".pdmp"); | ||
| 115 | file = new File (getFilesDir (), wantedDumpFile); | ||
| 116 | |||
| 117 | if (file.exists ()) | ||
| 118 | file.delete (); | ||
| 119 | } | ||
| 120 | }); | ||
| 121 | layout.addView (textView); | ||
| 122 | |||
| 96 | super.onCreate (savedInstanceState); | 123 | super.onCreate (savedInstanceState); |
| 97 | } | 124 | } |
| 98 | }; | 125 | }; |
diff --git a/java/org/gnu/emacs/EmacsService.java b/java/org/gnu/emacs/EmacsService.java index 95f21b211a3..4db1ea5359f 100644 --- a/java/org/gnu/emacs/EmacsService.java +++ b/java/org/gnu/emacs/EmacsService.java | |||
| @@ -43,6 +43,8 @@ import android.content.Context; | |||
| 43 | import android.content.Intent; | 43 | import android.content.Intent; |
| 44 | import android.content.res.AssetManager; | 44 | import android.content.res.AssetManager; |
| 45 | 45 | ||
| 46 | import android.net.Uri; | ||
| 47 | |||
| 46 | import android.os.Build; | 48 | import android.os.Build; |
| 47 | import android.os.Looper; | 49 | import android.os.Looper; |
| 48 | import android.os.IBinder; | 50 | import android.os.IBinder; |
| @@ -504,4 +506,27 @@ public class EmacsService extends Service | |||
| 504 | EmacsService.class)); | 506 | EmacsService.class)); |
| 505 | } | 507 | } |
| 506 | } | 508 | } |
| 509 | |||
| 510 | /* Ask the system to open the specified URL. | ||
| 511 | Value is NULL upon success, or a string describing the error | ||
| 512 | upon failure. */ | ||
| 513 | |||
| 514 | public String | ||
| 515 | browseUrl (String url) | ||
| 516 | { | ||
| 517 | Intent intent; | ||
| 518 | |||
| 519 | try | ||
| 520 | { | ||
| 521 | intent = new Intent (Intent.ACTION_VIEW, Uri.parse (url)); | ||
| 522 | intent.setFlags (Intent.FLAG_ACTIVITY_NEW_TASK); | ||
| 523 | startActivity (intent); | ||
| 524 | } | ||
| 525 | catch (Exception e) | ||
| 526 | { | ||
| 527 | return e.toString (); | ||
| 528 | } | ||
| 529 | |||
| 530 | return null; | ||
| 531 | } | ||
| 507 | }; | 532 | }; |
diff --git a/java/org/gnu/emacs/EmacsThread.java b/java/org/gnu/emacs/EmacsThread.java index 21d8612703a..5b76d11db4b 100644 --- a/java/org/gnu/emacs/EmacsThread.java +++ b/java/org/gnu/emacs/EmacsThread.java | |||
| @@ -38,10 +38,23 @@ public class EmacsThread extends Thread | |||
| 38 | { | 38 | { |
| 39 | String args[]; | 39 | String args[]; |
| 40 | 40 | ||
| 41 | if (!startDashQ) | 41 | if (EmacsApplication.dumpFileName == null) |
| 42 | args = new String[] { "libandroid-emacs.so", }; | 42 | { |
| 43 | if (!startDashQ) | ||
| 44 | args = new String[] { "libandroid-emacs.so", }; | ||
| 45 | else | ||
| 46 | args = new String[] { "libandroid-emacs.so", "-Q", }; | ||
| 47 | } | ||
| 43 | else | 48 | else |
| 44 | args = new String[] { "libandroid-emacs.so", "-Q", }; | 49 | { |
| 50 | if (!startDashQ) | ||
| 51 | args = new String[] { "libandroid-emacs.so", "--dump-file", | ||
| 52 | EmacsApplication.dumpFileName, }; | ||
| 53 | else | ||
| 54 | args = new String[] { "libandroid-emacs.so", "-Q", | ||
| 55 | "--dump-file", | ||
| 56 | EmacsApplication.dumpFileName, }; | ||
| 57 | } | ||
| 45 | 58 | ||
| 46 | /* Run the native code now. */ | 59 | /* Run the native code now. */ |
| 47 | EmacsNative.initEmacs (args); | 60 | EmacsNative.initEmacs (args); |