diff options
| author | Po Lu | 2023-03-05 19:58:28 +0800 |
|---|---|---|
| committer | Po Lu | 2023-03-05 19:58:28 +0800 |
| commit | 1cae464859341bfd5fc7d7ed4b503ef959af81dd (patch) | |
| tree | a6f45054eefef7df6688ebf460c10a75952fa1bd /java | |
| parent | 26b3b8433d933c9f8b26b83ca96ac1bb47711907 (diff) | |
| download | emacs-1cae464859341bfd5fc7d7ed4b503ef959af81dd.tar.gz emacs-1cae464859341bfd5fc7d7ed4b503ef959af81dd.zip | |
Update Android port
* java/org/gnu/emacs/EmacsActivity.java (onCreate):
* java/org/gnu/emacs/EmacsContextMenu.java:
* java/org/gnu/emacs/EmacsDocumentsProvider.java (getMimeType):
* java/org/gnu/emacs/EmacsDrawLine.java (perform):
* java/org/gnu/emacs/EmacsDrawRectangle.java (perform):
* java/org/gnu/emacs/EmacsFillPolygon.java:
* java/org/gnu/emacs/EmacsFontDriver.java:
* java/org/gnu/emacs/EmacsHandleObject.java:
* java/org/gnu/emacs/EmacsInputConnection.java:
* java/org/gnu/emacs/EmacsMultitaskActivity.java
(EmacsMultitaskActivity):
* java/org/gnu/emacs/EmacsNative.java:
* java/org/gnu/emacs/EmacsNoninteractive.java
(EmacsNoninteractive, main):
* java/org/gnu/emacs/EmacsOpenActivity.java (EmacsOpenActivity)
(startEmacsClient):
* java/org/gnu/emacs/EmacsSdk7FontDriver.java:
* java/org/gnu/emacs/EmacsSdk8Clipboard.java:
* java/org/gnu/emacs/EmacsService.java (EmacsService, onCreate):
* java/org/gnu/emacs/EmacsView.java (EmacsView, onLayout):
* java/org/gnu/emacs/EmacsWindow.java (EmacsWindow):
* java/org/gnu/emacs/EmacsWindowAttachmentManager.java
(EmacsWindowAttachmentManager): Remove redundant includes.
Reorganize some functions around, remove duplicate `getLibDir'
functions, and remove unused local variables.
Diffstat (limited to 'java')
19 files changed, 53 insertions, 117 deletions
diff --git a/java/org/gnu/emacs/EmacsActivity.java b/java/org/gnu/emacs/EmacsActivity.java index 13002d5d0e5..692d8a14e22 100644 --- a/java/org/gnu/emacs/EmacsActivity.java +++ b/java/org/gnu/emacs/EmacsActivity.java | |||
| @@ -24,18 +24,22 @@ import java.util.List; | |||
| 24 | import java.util.ArrayList; | 24 | import java.util.ArrayList; |
| 25 | 25 | ||
| 26 | import android.app.Activity; | 26 | import android.app.Activity; |
| 27 | |||
| 27 | import android.content.Context; | 28 | import android.content.Context; |
| 28 | import android.content.Intent; | 29 | import android.content.Intent; |
| 30 | |||
| 29 | import android.os.Build; | 31 | import android.os.Build; |
| 30 | import android.os.Bundle; | 32 | import android.os.Bundle; |
| 33 | |||
| 31 | import android.util.Log; | 34 | import android.util.Log; |
| 35 | |||
| 32 | import android.view.Menu; | 36 | import android.view.Menu; |
| 33 | import android.view.View; | 37 | import android.view.View; |
| 34 | import android.view.ViewTreeObserver; | 38 | import android.view.ViewTreeObserver; |
| 35 | import android.view.Window; | 39 | import android.view.Window; |
| 36 | import android.view.WindowInsets; | 40 | import android.view.WindowInsets; |
| 37 | import android.view.WindowInsetsController; | 41 | import android.view.WindowInsetsController; |
| 38 | import android.widget.FrameLayout.LayoutParams; | 42 | |
| 39 | import android.widget.FrameLayout; | 43 | import android.widget.FrameLayout; |
| 40 | 44 | ||
| 41 | public class EmacsActivity extends Activity | 45 | public class EmacsActivity extends Activity |
| @@ -187,6 +191,7 @@ public class EmacsActivity extends Activity | |||
| 187 | Intent intent; | 191 | Intent intent; |
| 188 | View decorView; | 192 | View decorView; |
| 189 | ViewTreeObserver observer; | 193 | ViewTreeObserver observer; |
| 194 | int matchParent; | ||
| 190 | 195 | ||
| 191 | /* See if Emacs should be started with -Q. */ | 196 | /* See if Emacs should be started with -Q. */ |
| 192 | intent = getIntent (); | 197 | intent = getIntent (); |
| @@ -194,8 +199,10 @@ public class EmacsActivity extends Activity | |||
| 194 | = intent.getBooleanExtra ("org.gnu.emacs.START_DASH_Q", | 199 | = intent.getBooleanExtra ("org.gnu.emacs.START_DASH_Q", |
| 195 | false); | 200 | false); |
| 196 | 201 | ||
| 197 | params = new FrameLayout.LayoutParams (LayoutParams.MATCH_PARENT, | 202 | matchParent = FrameLayout.LayoutParams.MATCH_PARENT; |
| 198 | LayoutParams.MATCH_PARENT); | 203 | params |
| 204 | = new FrameLayout.LayoutParams (matchParent, | ||
| 205 | matchParent); | ||
| 199 | 206 | ||
| 200 | /* Make the frame layout. */ | 207 | /* Make the frame layout. */ |
| 201 | layout = new FrameLayout (this); | 208 | layout = new FrameLayout (this); |
diff --git a/java/org/gnu/emacs/EmacsContextMenu.java b/java/org/gnu/emacs/EmacsContextMenu.java index d1a624e68d9..dec5e148a8e 100644 --- a/java/org/gnu/emacs/EmacsContextMenu.java +++ b/java/org/gnu/emacs/EmacsContextMenu.java | |||
| @@ -25,7 +25,6 @@ import java.util.ArrayList; | |||
| 25 | import android.content.Context; | 25 | import android.content.Context; |
| 26 | import android.content.Intent; | 26 | import android.content.Intent; |
| 27 | 27 | ||
| 28 | import android.os.Bundle; | ||
| 29 | import android.os.Build; | 28 | import android.os.Build; |
| 30 | 29 | ||
| 31 | import android.view.Menu; | 30 | import android.view.Menu; |
| @@ -35,8 +34,6 @@ import android.view.SubMenu; | |||
| 35 | 34 | ||
| 36 | import android.util.Log; | 35 | import android.util.Log; |
| 37 | 36 | ||
| 38 | import android.widget.PopupMenu; | ||
| 39 | |||
| 40 | /* Context menu implementation. This object is built from JNI and | 37 | /* Context menu implementation. This object is built from JNI and |
| 41 | describes a menu hiearchy. Then, `inflate' can turn it into an | 38 | describes a menu hiearchy. Then, `inflate' can turn it into an |
| 42 | Android menu, which can be turned into a popup (or other kind of) | 39 | Android menu, which can be turned into a popup (or other kind of) |
diff --git a/java/org/gnu/emacs/EmacsDocumentsProvider.java b/java/org/gnu/emacs/EmacsDocumentsProvider.java index 901c3b909e0..f70da6040ff 100644 --- a/java/org/gnu/emacs/EmacsDocumentsProvider.java +++ b/java/org/gnu/emacs/EmacsDocumentsProvider.java | |||
| @@ -160,6 +160,7 @@ public final class EmacsDocumentsProvider extends DocumentsProvider | |||
| 160 | { | 160 | { |
| 161 | String name, extension, mime; | 161 | String name, extension, mime; |
| 162 | int extensionSeparator; | 162 | int extensionSeparator; |
| 163 | MimeTypeMap singleton; | ||
| 163 | 164 | ||
| 164 | if (file.isDirectory ()) | 165 | if (file.isDirectory ()) |
| 165 | return Document.MIME_TYPE_DIR; | 166 | return Document.MIME_TYPE_DIR; |
| @@ -170,8 +171,9 @@ public final class EmacsDocumentsProvider extends DocumentsProvider | |||
| 170 | 171 | ||
| 171 | if (extensionSeparator > 0) | 172 | if (extensionSeparator > 0) |
| 172 | { | 173 | { |
| 174 | singleton = MimeTypeMap.getSingleton (); | ||
| 173 | extension = name.substring (extensionSeparator + 1); | 175 | extension = name.substring (extensionSeparator + 1); |
| 174 | mime = MimeTypeMap.getSingleton().getMimeTypeFromExtension (extension); | 176 | mime = singleton.getMimeTypeFromExtension (extension); |
| 175 | 177 | ||
| 176 | if (mime != null) | 178 | if (mime != null) |
| 177 | return mime; | 179 | return mime; |
diff --git a/java/org/gnu/emacs/EmacsDrawLine.java b/java/org/gnu/emacs/EmacsDrawLine.java index 0b23138a36c..92e03c48e26 100644 --- a/java/org/gnu/emacs/EmacsDrawLine.java +++ b/java/org/gnu/emacs/EmacsDrawLine.java | |||
| @@ -21,13 +21,9 @@ package org.gnu.emacs; | |||
| 21 | 21 | ||
| 22 | import java.lang.Math; | 22 | import java.lang.Math; |
| 23 | 23 | ||
| 24 | import android.graphics.Bitmap; | ||
| 25 | import android.graphics.Canvas; | 24 | import android.graphics.Canvas; |
| 26 | import android.graphics.Paint; | 25 | import android.graphics.Paint; |
| 27 | import android.graphics.PorterDuff.Mode; | ||
| 28 | import android.graphics.PorterDuffXfermode; | ||
| 29 | import android.graphics.Rect; | 26 | import android.graphics.Rect; |
| 30 | import android.graphics.Xfermode; | ||
| 31 | 27 | ||
| 32 | public final class EmacsDrawLine | 28 | public final class EmacsDrawLine |
| 33 | { | 29 | { |
| @@ -38,7 +34,6 @@ public final class EmacsDrawLine | |||
| 38 | Rect rect; | 34 | Rect rect; |
| 39 | Canvas canvas; | 35 | Canvas canvas; |
| 40 | Paint paint; | 36 | Paint paint; |
| 41 | int i; | ||
| 42 | 37 | ||
| 43 | /* TODO implement stippling. */ | 38 | /* TODO implement stippling. */ |
| 44 | if (gc.fill_style == EmacsGC.GC_FILL_OPAQUE_STIPPLED) | 39 | if (gc.fill_style == EmacsGC.GC_FILL_OPAQUE_STIPPLED) |
diff --git a/java/org/gnu/emacs/EmacsDrawRectangle.java b/java/org/gnu/emacs/EmacsDrawRectangle.java index ce5e94e4a76..3bd5779c54e 100644 --- a/java/org/gnu/emacs/EmacsDrawRectangle.java +++ b/java/org/gnu/emacs/EmacsDrawRectangle.java | |||
| @@ -33,7 +33,6 @@ public final class EmacsDrawRectangle | |||
| 33 | perform (EmacsDrawable drawable, EmacsGC gc, | 33 | perform (EmacsDrawable drawable, EmacsGC gc, |
| 34 | int x, int y, int width, int height) | 34 | int x, int y, int width, int height) |
| 35 | { | 35 | { |
| 36 | int i; | ||
| 37 | Paint maskPaint, paint; | 36 | Paint maskPaint, paint; |
| 38 | Canvas maskCanvas; | 37 | Canvas maskCanvas; |
| 39 | Bitmap maskBitmap; | 38 | Bitmap maskBitmap; |
diff --git a/java/org/gnu/emacs/EmacsFillPolygon.java b/java/org/gnu/emacs/EmacsFillPolygon.java index d55a0b3aca8..ea8324c543c 100644 --- a/java/org/gnu/emacs/EmacsFillPolygon.java +++ b/java/org/gnu/emacs/EmacsFillPolygon.java | |||
| @@ -21,7 +21,6 @@ package org.gnu.emacs; | |||
| 21 | 21 | ||
| 22 | import java.lang.Math; | 22 | import java.lang.Math; |
| 23 | 23 | ||
| 24 | import android.graphics.Bitmap; | ||
| 25 | import android.graphics.Canvas; | 24 | import android.graphics.Canvas; |
| 26 | import android.graphics.Paint; | 25 | import android.graphics.Paint; |
| 27 | import android.graphics.Path; | 26 | import android.graphics.Path; |
diff --git a/java/org/gnu/emacs/EmacsFontDriver.java b/java/org/gnu/emacs/EmacsFontDriver.java index e142a3121d3..ff52899a897 100644 --- a/java/org/gnu/emacs/EmacsFontDriver.java +++ b/java/org/gnu/emacs/EmacsFontDriver.java | |||
| @@ -19,8 +19,6 @@ 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.util.List; | ||
| 23 | |||
| 24 | import android.os.Build; | 22 | import android.os.Build; |
| 25 | 23 | ||
| 26 | /* This code is mostly unused. See sfntfont-android.c for the code | 24 | /* This code is mostly unused. See sfntfont-android.c for the code |
diff --git a/java/org/gnu/emacs/EmacsHandleObject.java b/java/org/gnu/emacs/EmacsHandleObject.java index a57a3bbdfa9..5b889895337 100644 --- a/java/org/gnu/emacs/EmacsHandleObject.java +++ b/java/org/gnu/emacs/EmacsHandleObject.java | |||
| @@ -19,9 +19,6 @@ 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.util.List; | ||
| 23 | import java.util.ArrayList; | ||
| 24 | import java.lang.Object; | ||
| 25 | import java.lang.IllegalStateException; | 22 | import java.lang.IllegalStateException; |
| 26 | 23 | ||
| 27 | /* This defines something that is a so-called ``handle''. Handles | 24 | /* This defines something that is a so-called ``handle''. Handles |
diff --git a/java/org/gnu/emacs/EmacsInputConnection.java b/java/org/gnu/emacs/EmacsInputConnection.java index ed64c368857..7b40fcff99e 100644 --- a/java/org/gnu/emacs/EmacsInputConnection.java +++ b/java/org/gnu/emacs/EmacsInputConnection.java | |||
| @@ -23,18 +23,13 @@ import android.view.inputmethod.BaseInputConnection; | |||
| 23 | import android.view.inputmethod.CompletionInfo; | 23 | import android.view.inputmethod.CompletionInfo; |
| 24 | import android.view.inputmethod.ExtractedText; | 24 | import android.view.inputmethod.ExtractedText; |
| 25 | import android.view.inputmethod.ExtractedTextRequest; | 25 | import android.view.inputmethod.ExtractedTextRequest; |
| 26 | import android.view.inputmethod.InputMethodManager; | ||
| 27 | import android.view.inputmethod.SurroundingText; | ||
| 28 | import android.view.inputmethod.TextSnapshot; | 26 | import android.view.inputmethod.TextSnapshot; |
| 29 | import android.view.KeyEvent; | 27 | import android.view.KeyEvent; |
| 30 | 28 | ||
| 31 | import android.text.Editable; | ||
| 32 | |||
| 33 | import android.util.Log; | 29 | import android.util.Log; |
| 34 | 30 | ||
| 35 | /* Android input methods, take number six. | 31 | /* Android input methods, take number six. See textconv.c for more |
| 36 | 32 | details; this is more-or-less a thin wrapper around that file. */ | |
| 37 | See EmacsEditable for more details. */ | ||
| 38 | 33 | ||
| 39 | public final class EmacsInputConnection extends BaseInputConnection | 34 | public final class EmacsInputConnection extends BaseInputConnection |
| 40 | { | 35 | { |
diff --git a/java/org/gnu/emacs/EmacsMultitaskActivity.java b/java/org/gnu/emacs/EmacsMultitaskActivity.java index dbdc99a3559..b1c48f03fba 100644 --- a/java/org/gnu/emacs/EmacsMultitaskActivity.java +++ b/java/org/gnu/emacs/EmacsMultitaskActivity.java | |||
| @@ -19,7 +19,11 @@ 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 | public class EmacsMultitaskActivity extends EmacsActivity | 22 | /* This class only exists because EmacsActivity is already defined as |
| 23 | an activity, and the system wants a new class in order to define a | ||
| 24 | new activity. */ | ||
| 25 | |||
| 26 | public final class EmacsMultitaskActivity extends EmacsActivity | ||
| 23 | { | 27 | { |
| 24 | 28 | ||
| 25 | } | 29 | } |
diff --git a/java/org/gnu/emacs/EmacsNative.java b/java/org/gnu/emacs/EmacsNative.java index b1205353090..38370d60727 100644 --- a/java/org/gnu/emacs/EmacsNative.java +++ b/java/org/gnu/emacs/EmacsNative.java | |||
| @@ -19,8 +19,6 @@ 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.lang.System; | ||
| 23 | |||
| 24 | import android.content.res.AssetManager; | 22 | import android.content.res.AssetManager; |
| 25 | import android.view.inputmethod.ExtractedText; | 23 | import android.view.inputmethod.ExtractedText; |
| 26 | import android.view.inputmethod.ExtractedTextRequest; | 24 | import android.view.inputmethod.ExtractedTextRequest; |
diff --git a/java/org/gnu/emacs/EmacsNoninteractive.java b/java/org/gnu/emacs/EmacsNoninteractive.java index f365037b311..aaba74d877c 100644 --- a/java/org/gnu/emacs/EmacsNoninteractive.java +++ b/java/org/gnu/emacs/EmacsNoninteractive.java | |||
| @@ -46,21 +46,6 @@ import java.lang.reflect.Method; | |||
| 46 | @SuppressWarnings ("unchecked") | 46 | @SuppressWarnings ("unchecked") |
| 47 | public final class EmacsNoninteractive | 47 | public final class EmacsNoninteractive |
| 48 | { | 48 | { |
| 49 | private static String | ||
| 50 | getLibraryDirectory (Context context) | ||
| 51 | { | ||
| 52 | int apiLevel; | ||
| 53 | |||
| 54 | apiLevel = Build.VERSION.SDK_INT; | ||
| 55 | |||
| 56 | if (apiLevel >= Build.VERSION_CODES.GINGERBREAD) | ||
| 57 | return context.getApplicationInfo().nativeLibraryDir; | ||
| 58 | else if (apiLevel >= Build.VERSION_CODES.DONUT) | ||
| 59 | return context.getApplicationInfo().dataDir + "/lib"; | ||
| 60 | |||
| 61 | return "/data/data/" + context.getPackageName() + "/lib"; | ||
| 62 | } | ||
| 63 | |||
| 64 | public static void | 49 | public static void |
| 65 | main (String[] args) | 50 | main (String[] args) |
| 66 | { | 51 | { |
| @@ -188,7 +173,7 @@ public final class EmacsNoninteractive | |||
| 188 | /* Now configure Emacs. The class path should already be set. */ | 173 | /* Now configure Emacs. The class path should already be set. */ |
| 189 | 174 | ||
| 190 | filesDir = context.getFilesDir ().getCanonicalPath (); | 175 | filesDir = context.getFilesDir ().getCanonicalPath (); |
| 191 | libDir = getLibraryDirectory (context); | 176 | libDir = EmacsService.getLibraryDirectory (context); |
| 192 | cacheDir = context.getCacheDir ().getCanonicalPath (); | 177 | cacheDir = context.getCacheDir ().getCanonicalPath (); |
| 193 | } | 178 | } |
| 194 | catch (Exception e) | 179 | catch (Exception e) |
| @@ -198,6 +183,7 @@ public final class EmacsNoninteractive | |||
| 198 | System.err.println ("and that Emacs needs adjustments in order to"); | 183 | System.err.println ("and that Emacs needs adjustments in order to"); |
| 199 | System.err.println ("obtain required system internal resources."); | 184 | System.err.println ("obtain required system internal resources."); |
| 200 | System.err.println ("Please report this bug to bug-gnu-emacs@gnu.org."); | 185 | System.err.println ("Please report this bug to bug-gnu-emacs@gnu.org."); |
| 186 | e.printStackTrace (); | ||
| 201 | 187 | ||
| 202 | System.exit (1); | 188 | System.exit (1); |
| 203 | } | 189 | } |
diff --git a/java/org/gnu/emacs/EmacsOpenActivity.java b/java/org/gnu/emacs/EmacsOpenActivity.java index ac643ae8a13..51335ddb2dd 100644 --- a/java/org/gnu/emacs/EmacsOpenActivity.java +++ b/java/org/gnu/emacs/EmacsOpenActivity.java | |||
| @@ -46,7 +46,6 @@ package org.gnu.emacs; | |||
| 46 | import android.app.AlertDialog; | 46 | import android.app.AlertDialog; |
| 47 | import android.app.Activity; | 47 | import android.app.Activity; |
| 48 | 48 | ||
| 49 | import android.content.Context; | ||
| 50 | import android.content.ContentResolver; | 49 | import android.content.ContentResolver; |
| 51 | import android.content.DialogInterface; | 50 | import android.content.DialogInterface; |
| 52 | import android.content.Intent; | 51 | import android.content.Intent; |
| @@ -301,23 +300,6 @@ public final class EmacsOpenActivity extends Activity | |||
| 301 | }); | 300 | }); |
| 302 | } | 301 | } |
| 303 | 302 | ||
| 304 | public String | ||
| 305 | getLibraryDirectory () | ||
| 306 | { | ||
| 307 | int apiLevel; | ||
| 308 | Context context; | ||
| 309 | |||
| 310 | context = getApplicationContext (); | ||
| 311 | apiLevel = Build.VERSION.SDK_INT; | ||
| 312 | |||
| 313 | if (apiLevel >= Build.VERSION_CODES.GINGERBREAD) | ||
| 314 | return context.getApplicationInfo().nativeLibraryDir; | ||
| 315 | else if (apiLevel >= Build.VERSION_CODES.DONUT) | ||
| 316 | return context.getApplicationInfo().dataDir + "/lib"; | ||
| 317 | |||
| 318 | return "/data/data/" + context.getPackageName() + "/lib"; | ||
| 319 | } | ||
| 320 | |||
| 321 | public void | 303 | public void |
| 322 | startEmacsClient (String fileName) | 304 | startEmacsClient (String fileName) |
| 323 | { | 305 | { |
| @@ -327,7 +309,7 @@ public final class EmacsOpenActivity extends Activity | |||
| 327 | EmacsClientThread thread; | 309 | EmacsClientThread thread; |
| 328 | File file; | 310 | File file; |
| 329 | 311 | ||
| 330 | libDir = getLibraryDirectory (); | 312 | libDir = EmacsService.getLibraryDirectory (this); |
| 331 | builder = new ProcessBuilder (libDir + "/libemacsclient.so", | 313 | builder = new ProcessBuilder (libDir + "/libemacsclient.so", |
| 332 | fileName, "--reuse-frame", | 314 | fileName, "--reuse-frame", |
| 333 | "--timeout=10", "--no-wait"); | 315 | "--timeout=10", "--no-wait"); |
diff --git a/java/org/gnu/emacs/EmacsSdk7FontDriver.java b/java/org/gnu/emacs/EmacsSdk7FontDriver.java index ae91c299de8..6df102f18a2 100644 --- a/java/org/gnu/emacs/EmacsSdk7FontDriver.java +++ b/java/org/gnu/emacs/EmacsSdk7FontDriver.java | |||
| @@ -20,7 +20,6 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */ | |||
| 20 | package org.gnu.emacs; | 20 | package org.gnu.emacs; |
| 21 | 21 | ||
| 22 | import java.io.File; | 22 | import java.io.File; |
| 23 | import java.io.IOException; | ||
| 24 | 23 | ||
| 25 | import java.util.LinkedList; | 24 | import java.util.LinkedList; |
| 26 | import java.util.List; | 25 | import java.util.List; |
| @@ -32,8 +31,6 @@ import android.graphics.Canvas; | |||
| 32 | 31 | ||
| 33 | import android.util.Log; | 32 | import android.util.Log; |
| 34 | 33 | ||
| 35 | import android.os.Build; | ||
| 36 | |||
| 37 | public class EmacsSdk7FontDriver extends EmacsFontDriver | 34 | public class EmacsSdk7FontDriver extends EmacsFontDriver |
| 38 | { | 35 | { |
| 39 | private static final String TOFU_STRING = "\uDB3F\uDFFD"; | 36 | private static final String TOFU_STRING = "\uDB3F\uDFFD"; |
diff --git a/java/org/gnu/emacs/EmacsSdk8Clipboard.java b/java/org/gnu/emacs/EmacsSdk8Clipboard.java index 818a722a908..5a40128b0ac 100644 --- a/java/org/gnu/emacs/EmacsSdk8Clipboard.java +++ b/java/org/gnu/emacs/EmacsSdk8Clipboard.java | |||
| @@ -19,7 +19,9 @@ 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 | /* Importing the entire package avoids the deprecation warning. */ | 22 | /* Importing the entire package instead of just the legacy |
| 23 | ClipboardManager class avoids the deprecation warning. */ | ||
| 24 | |||
| 23 | import android.text.*; | 25 | import android.text.*; |
| 24 | 26 | ||
| 25 | import android.content.Context; | 27 | import android.content.Context; |
diff --git a/java/org/gnu/emacs/EmacsService.java b/java/org/gnu/emacs/EmacsService.java index d9cb25f3e9c..d05ebce75dc 100644 --- a/java/org/gnu/emacs/EmacsService.java +++ b/java/org/gnu/emacs/EmacsService.java | |||
| @@ -24,22 +24,15 @@ import java.io.IOException; | |||
| 24 | import java.io.UnsupportedEncodingException; | 24 | import java.io.UnsupportedEncodingException; |
| 25 | 25 | ||
| 26 | import java.util.List; | 26 | import java.util.List; |
| 27 | import java.util.ArrayList; | ||
| 28 | 27 | ||
| 29 | import android.graphics.Canvas; | ||
| 30 | import android.graphics.Bitmap; | ||
| 31 | import android.graphics.Point; | 28 | import android.graphics.Point; |
| 32 | 29 | ||
| 33 | import android.view.View; | ||
| 34 | import android.view.InputDevice; | 30 | import android.view.InputDevice; |
| 35 | import android.view.KeyEvent; | 31 | import android.view.KeyEvent; |
| 36 | 32 | ||
| 37 | import android.annotation.TargetApi; | ||
| 38 | |||
| 39 | import android.app.Notification; | 33 | import android.app.Notification; |
| 40 | import android.app.NotificationManager; | 34 | import android.app.NotificationManager; |
| 41 | import android.app.NotificationChannel; | 35 | import android.app.NotificationChannel; |
| 42 | import android.app.PendingIntent; | ||
| 43 | import android.app.Service; | 36 | import android.app.Service; |
| 44 | 37 | ||
| 45 | import android.content.ClipboardManager; | 38 | import android.content.ClipboardManager; |
| @@ -51,9 +44,6 @@ import android.content.pm.PackageManager.ApplicationInfoFlags; | |||
| 51 | import android.content.pm.PackageManager; | 44 | import android.content.pm.PackageManager; |
| 52 | import android.content.res.AssetManager; | 45 | import android.content.res.AssetManager; |
| 53 | 46 | ||
| 54 | import android.database.Cursor; | ||
| 55 | import android.database.MatrixCursor; | ||
| 56 | |||
| 57 | import android.hardware.input.InputManager; | 47 | import android.hardware.input.InputManager; |
| 58 | 48 | ||
| 59 | import android.net.Uri; | 49 | import android.net.Uri; |
| @@ -68,9 +58,6 @@ import android.os.Vibrator; | |||
| 68 | import android.os.VibratorManager; | 58 | import android.os.VibratorManager; |
| 69 | import android.os.VibrationEffect; | 59 | import android.os.VibrationEffect; |
| 70 | 60 | ||
| 71 | import android.provider.DocumentsContract; | ||
| 72 | import android.provider.DocumentsContract.Document; | ||
| 73 | |||
| 74 | import android.util.Log; | 61 | import android.util.Log; |
| 75 | import android.util.DisplayMetrics; | 62 | import android.util.DisplayMetrics; |
| 76 | 63 | ||
| @@ -87,7 +74,6 @@ class Holder<T> | |||
| 87 | public final class EmacsService extends Service | 74 | public final class EmacsService extends Service |
| 88 | { | 75 | { |
| 89 | public static final String TAG = "EmacsService"; | 76 | public static final String TAG = "EmacsService"; |
| 90 | public static final int MAX_PENDING_REQUESTS = 256; | ||
| 91 | public static volatile EmacsService SERVICE; | 77 | public static volatile EmacsService SERVICE; |
| 92 | public static boolean needDashQ; | 78 | public static boolean needDashQ; |
| 93 | 79 | ||
| @@ -107,6 +93,22 @@ public final class EmacsService extends Service | |||
| 107 | information. */ | 93 | information. */ |
| 108 | public static final boolean DEBUG_IC = false; | 94 | public static final boolean DEBUG_IC = false; |
| 109 | 95 | ||
| 96 | /* Return the directory leading to the directory in which native | ||
| 97 | library files are stored on behalf of CONTEXT. */ | ||
| 98 | |||
| 99 | public static String | ||
| 100 | getLibraryDirectory (Context context) | ||
| 101 | { | ||
| 102 | int apiLevel; | ||
| 103 | |||
| 104 | apiLevel = Build.VERSION.SDK_INT; | ||
| 105 | |||
| 106 | if (apiLevel >= Build.VERSION_CODES.GINGERBREAD) | ||
| 107 | return context.getApplicationInfo ().nativeLibraryDir; | ||
| 108 | |||
| 109 | return context.getApplicationInfo ().dataDir + "/lib"; | ||
| 110 | } | ||
| 111 | |||
| 110 | @Override | 112 | @Override |
| 111 | public int | 113 | public int |
| 112 | onStartCommand (Intent intent, int flags, int startId) | 114 | onStartCommand (Intent intent, int flags, int startId) |
| @@ -178,23 +180,6 @@ public final class EmacsService extends Service | |||
| 178 | } | 180 | } |
| 179 | } | 181 | } |
| 180 | 182 | ||
| 181 | private String | ||
| 182 | getLibraryDirectory () | ||
| 183 | { | ||
| 184 | int apiLevel; | ||
| 185 | Context context; | ||
| 186 | |||
| 187 | context = getApplicationContext (); | ||
| 188 | apiLevel = Build.VERSION.SDK_INT; | ||
| 189 | |||
| 190 | if (apiLevel >= Build.VERSION_CODES.GINGERBREAD) | ||
| 191 | return context.getApplicationInfo().nativeLibraryDir; | ||
| 192 | else if (apiLevel >= Build.VERSION_CODES.DONUT) | ||
| 193 | return context.getApplicationInfo().dataDir + "/lib"; | ||
| 194 | |||
| 195 | return "/data/data/" + context.getPackageName() + "/lib"; | ||
| 196 | } | ||
| 197 | |||
| 198 | @Override | 183 | @Override |
| 199 | public void | 184 | public void |
| 200 | onCreate () | 185 | onCreate () |
| @@ -219,7 +204,7 @@ public final class EmacsService extends Service | |||
| 219 | /* Configure Emacs with the asset manager and other necessary | 204 | /* Configure Emacs with the asset manager and other necessary |
| 220 | parameters. */ | 205 | parameters. */ |
| 221 | filesDir = app_context.getFilesDir ().getCanonicalPath (); | 206 | filesDir = app_context.getFilesDir ().getCanonicalPath (); |
| 222 | libDir = getLibraryDirectory (); | 207 | libDir = getLibraryDirectory (this); |
| 223 | cacheDir = app_context.getCacheDir ().getCanonicalPath (); | 208 | cacheDir = app_context.getCacheDir ().getCanonicalPath (); |
| 224 | 209 | ||
| 225 | /* Now provide this application's apk file, so a recursive | 210 | /* Now provide this application's apk file, so a recursive |
diff --git a/java/org/gnu/emacs/EmacsView.java b/java/org/gnu/emacs/EmacsView.java index 617836d8811..aefc79c4fb7 100644 --- a/java/org/gnu/emacs/EmacsView.java +++ b/java/org/gnu/emacs/EmacsView.java | |||
| @@ -20,7 +20,6 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */ | |||
| 20 | package org.gnu.emacs; | 20 | package org.gnu.emacs; |
| 21 | 21 | ||
| 22 | import android.content.Context; | 22 | import android.content.Context; |
| 23 | import android.content.res.ColorStateList; | ||
| 24 | 23 | ||
| 25 | import android.text.InputType; | 24 | import android.text.InputType; |
| 26 | 25 | ||
| @@ -116,6 +115,7 @@ public final class EmacsView extends ViewGroup | |||
| 116 | super (EmacsService.SERVICE); | 115 | super (EmacsService.SERVICE); |
| 117 | 116 | ||
| 118 | Object tem; | 117 | Object tem; |
| 118 | Context context; | ||
| 119 | 119 | ||
| 120 | this.window = window; | 120 | this.window = window; |
| 121 | this.damageRegion = new Region (); | 121 | this.damageRegion = new Region (); |
| @@ -133,7 +133,8 @@ public final class EmacsView extends ViewGroup | |||
| 133 | setDefaultFocusHighlightEnabled (false); | 133 | setDefaultFocusHighlightEnabled (false); |
| 134 | 134 | ||
| 135 | /* Obtain the input method manager. */ | 135 | /* Obtain the input method manager. */ |
| 136 | tem = getContext ().getSystemService (Context.INPUT_METHOD_SERVICE); | 136 | context = getContext (); |
| 137 | tem = context.getSystemService (Context.INPUT_METHOD_SERVICE); | ||
| 137 | imManager = (InputMethodManager) tem; | 138 | imManager = (InputMethodManager) tem; |
| 138 | } | 139 | } |
| 139 | 140 | ||
| @@ -281,7 +282,6 @@ public final class EmacsView extends ViewGroup | |||
| 281 | int count, i; | 282 | int count, i; |
| 282 | View child; | 283 | View child; |
| 283 | Rect windowRect; | 284 | Rect windowRect; |
| 284 | int wantedWidth, wantedHeight; | ||
| 285 | 285 | ||
| 286 | count = getChildCount (); | 286 | count = getChildCount (); |
| 287 | 287 | ||
| @@ -422,7 +422,6 @@ public final class EmacsView extends ViewGroup | |||
| 422 | } | 422 | } |
| 423 | } | 423 | } |
| 424 | 424 | ||
| 425 | |||
| 426 | /* The following two functions must not be called if the view has no | 425 | /* The following two functions must not be called if the view has no |
| 427 | parent, or is parented to an activity. */ | 426 | parent, or is parented to an activity. */ |
| 428 | 427 | ||
diff --git a/java/org/gnu/emacs/EmacsWindow.java b/java/org/gnu/emacs/EmacsWindow.java index ea4cf48090d..ffc7476f010 100644 --- a/java/org/gnu/emacs/EmacsWindow.java +++ b/java/org/gnu/emacs/EmacsWindow.java | |||
| @@ -31,19 +31,16 @@ import android.content.Context; | |||
| 31 | import android.graphics.Rect; | 31 | import android.graphics.Rect; |
| 32 | import android.graphics.Canvas; | 32 | import android.graphics.Canvas; |
| 33 | import android.graphics.Bitmap; | 33 | import android.graphics.Bitmap; |
| 34 | import android.graphics.Point; | ||
| 35 | import android.graphics.PixelFormat; | 34 | import android.graphics.PixelFormat; |
| 36 | 35 | ||
| 37 | import android.view.View; | 36 | import android.view.View; |
| 38 | import android.view.ViewManager; | 37 | import android.view.ViewManager; |
| 39 | import android.view.ViewGroup; | ||
| 40 | import android.view.Gravity; | 38 | import android.view.Gravity; |
| 41 | import android.view.KeyEvent; | 39 | import android.view.KeyEvent; |
| 42 | import android.view.MotionEvent; | 40 | import android.view.MotionEvent; |
| 43 | import android.view.InputDevice; | 41 | import android.view.InputDevice; |
| 44 | import android.view.WindowManager; | 42 | import android.view.WindowManager; |
| 45 | 43 | ||
| 46 | import android.content.Intent; | ||
| 47 | import android.util.Log; | 44 | import android.util.Log; |
| 48 | 45 | ||
| 49 | import android.os.Build; | 46 | import android.os.Build; |
| @@ -87,7 +84,7 @@ public final class EmacsWindow extends EmacsHandleObject | |||
| 87 | public EmacsWindow parent; | 84 | public EmacsWindow parent; |
| 88 | 85 | ||
| 89 | /* List of all children in stacking order. This must be kept | 86 | /* List of all children in stacking order. This must be kept |
| 90 | consistent! */ | 87 | consistent with their Z order! */ |
| 91 | public ArrayList<EmacsWindow> children; | 88 | public ArrayList<EmacsWindow> children; |
| 92 | 89 | ||
| 93 | /* Map between pointer identifiers and last known position. Used to | 90 | /* Map between pointer identifiers and last known position. Used to |
| @@ -105,9 +102,8 @@ public final class EmacsWindow extends EmacsHandleObject | |||
| 105 | last button press or release event. */ | 102 | last button press or release event. */ |
| 106 | public int lastButtonState, lastModifiers; | 103 | public int lastButtonState, lastModifiers; |
| 107 | 104 | ||
| 108 | /* Whether or not the window is mapped, and whether or not it is | 105 | /* Whether or not the window is mapped. */ |
| 109 | deiconified. */ | 106 | private boolean isMapped; |
| 110 | private boolean isMapped, isIconified; | ||
| 111 | 107 | ||
| 112 | /* Whether or not to ask for focus upon being mapped, and whether or | 108 | /* Whether or not to ask for focus upon being mapped, and whether or |
| 113 | not the window should be focusable. */ | 109 | not the window should be focusable. */ |
| @@ -122,7 +118,8 @@ public final class EmacsWindow extends EmacsHandleObject | |||
| 122 | private WindowManager windowManager; | 118 | private WindowManager windowManager; |
| 123 | 119 | ||
| 124 | /* The time of the last KEYCODE_VOLUME_DOWN release. This is used | 120 | /* The time of the last KEYCODE_VOLUME_DOWN release. This is used |
| 125 | to quit Emacs. */ | 121 | to quit Emacs upon two rapid clicks of the volume down |
| 122 | button. */ | ||
| 126 | private long lastVolumeButtonRelease; | 123 | private long lastVolumeButtonRelease; |
| 127 | 124 | ||
| 128 | /* Linked list of character strings which were recently sent as | 125 | /* Linked list of character strings which were recently sent as |
| @@ -1103,14 +1100,12 @@ public final class EmacsWindow extends EmacsHandleObject | |||
| 1103 | public void | 1100 | public void |
| 1104 | noticeIconified () | 1101 | noticeIconified () |
| 1105 | { | 1102 | { |
| 1106 | isIconified = true; | ||
| 1107 | EmacsNative.sendIconified (this.handle); | 1103 | EmacsNative.sendIconified (this.handle); |
| 1108 | } | 1104 | } |
| 1109 | 1105 | ||
| 1110 | public void | 1106 | public void |
| 1111 | noticeDeiconified () | 1107 | noticeDeiconified () |
| 1112 | { | 1108 | { |
| 1113 | isIconified = false; | ||
| 1114 | EmacsNative.sendDeiconified (this.handle); | 1109 | EmacsNative.sendDeiconified (this.handle); |
| 1115 | } | 1110 | } |
| 1116 | 1111 | ||
diff --git a/java/org/gnu/emacs/EmacsWindowAttachmentManager.java b/java/org/gnu/emacs/EmacsWindowAttachmentManager.java index 1548bf28087..30f29250970 100644 --- a/java/org/gnu/emacs/EmacsWindowAttachmentManager.java +++ b/java/org/gnu/emacs/EmacsWindowAttachmentManager.java | |||
| @@ -20,7 +20,6 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */ | |||
| 20 | package org.gnu.emacs; | 20 | package org.gnu.emacs; |
| 21 | 21 | ||
| 22 | import java.util.ArrayList; | 22 | import java.util.ArrayList; |
| 23 | import java.util.LinkedList; | ||
| 24 | import java.util.List; | 23 | import java.util.List; |
| 25 | 24 | ||
| 26 | import android.content.Intent; | 25 | import android.content.Intent; |
| @@ -74,8 +73,8 @@ public final class EmacsWindowAttachmentManager | |||
| 74 | public | 73 | public |
| 75 | EmacsWindowAttachmentManager () | 74 | EmacsWindowAttachmentManager () |
| 76 | { | 75 | { |
| 77 | consumers = new LinkedList<WindowConsumer> (); | 76 | consumers = new ArrayList<WindowConsumer> (); |
| 78 | windows = new LinkedList<EmacsWindow> (); | 77 | windows = new ArrayList<EmacsWindow> (); |
| 79 | } | 78 | } |
| 80 | 79 | ||
| 81 | public void | 80 | public void |