aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPo Lu2023-03-02 09:27:37 +0800
committerPo Lu2023-03-02 09:27:37 +0800
commit7fb3c0d0397096f643f6239d50cf52eaf96e7b07 (patch)
tree53619775d86261a8210630f344c6eae8bbdd6aa9 /src
parent5e416d02c59e356e6f7677a9132896d824bcb337 (diff)
downloademacs-7fb3c0d0397096f643f6239d50cf52eaf96e7b07.tar.gz
emacs-7fb3c0d0397096f643f6239d50cf52eaf96e7b07.zip
Update Android port
* doc/emacs/android.texi (Android Windowing): Reword documentation. * java/org/gnu/emacs/EmacsActivity.java (EmacsActivity): * java/org/gnu/emacs/EmacsContextMenu.java (EmacsContextMenu): * java/org/gnu/emacs/EmacsFontDriver.java (EmacsFontDriver): * java/org/gnu/emacs/EmacsSdk7FontDriver.java (EmacsSdk7FontDriver): * java/org/gnu/emacs/EmacsService.java (queryBattery): * java/org/gnu/emacs/EmacsWindow.java (EmacsWindow): Make functions final and classes static where necessary. * src/android.c (struct android_emacs_service): New method `display_toast'. (android_init_emacs_service): Load new method. (android_display_toast): New function. * src/android.h: Export. * src/androidfns.c (Fandroid_detect_mouse): * src/androidselect.c (Fandroid_clipboard_owner_p) (Fandroid_set_clipboard, Fandroid_get_clipboard) (Fandroid_browse_url): Prevent crashes when called from libandroid-emacs.so. * src/androidterm.c (handle_one_android_event): Fix out of date commentary.
Diffstat (limited to 'src')
-rw-r--r--src/android.c28
-rw-r--r--src/android.h1
-rw-r--r--src/androidfns.c5
-rw-r--r--src/androidselect.c12
-rw-r--r--src/androidterm.c7
5 files changed, 48 insertions, 5 deletions
diff --git a/src/android.c b/src/android.c
index 3bccaab041a..daeb7ab70f6 100644
--- a/src/android.c
+++ b/src/android.c
@@ -112,6 +112,7 @@ struct android_emacs_service
112 jmethodID open_content_uri; 112 jmethodID open_content_uri;
113 jmethodID check_content_uri; 113 jmethodID check_content_uri;
114 jmethodID query_battery; 114 jmethodID query_battery;
115 jmethodID display_toast;
115}; 116};
116 117
117struct android_emacs_pixmap 118struct android_emacs_pixmap
@@ -2124,6 +2125,8 @@ android_init_emacs_service (void)
2124 FIND_METHOD (check_content_uri, "checkContentUri", 2125 FIND_METHOD (check_content_uri, "checkContentUri",
2125 "([BZZ)Z"); 2126 "([BZZ)Z");
2126 FIND_METHOD (query_battery, "queryBattery", "()[J"); 2127 FIND_METHOD (query_battery, "queryBattery", "()[J");
2128 FIND_METHOD (display_toast, "displayToast",
2129 "(Ljava/lang/String;)V");
2127#undef FIND_METHOD 2130#undef FIND_METHOD
2128} 2131}
2129 2132
@@ -5696,6 +5699,31 @@ android_query_battery (struct android_battery_state *status)
5696 return 0; 5699 return 0;
5697} 5700}
5698 5701
5702/* Display a small momentary notification on screen containing
5703 TEXT, which must be in the modified UTF encoding used by the
5704 JVM. */
5705
5706void
5707android_display_toast (const char *text)
5708{
5709 jstring string;
5710
5711 /* Make the string. */
5712 string = (*android_java_env)->NewStringUTF (android_java_env,
5713 text);
5714 android_exception_check ();
5715
5716 /* Display the toast. */
5717 (*android_java_env)->CallVoidMethod (android_java_env,
5718 emacs_service,
5719 service_class.display_toast,
5720 string);
5721 android_exception_check_1 (string);
5722
5723 /* Delete the local reference to the string. */
5724 ANDROID_DELETE_LOCAL_REF (string);
5725}
5726
5699 5727
5700 5728
5701/* Whether or not a query is currently being made. */ 5729/* Whether or not a query is currently being made. */
diff --git a/src/android.h b/src/android.h
index 806be4f9954..95206b77979 100644
--- a/src/android.h
+++ b/src/android.h
@@ -140,6 +140,7 @@ struct android_battery_state
140 140
141extern Lisp_Object android_browse_url (Lisp_Object); 141extern Lisp_Object android_browse_url (Lisp_Object);
142extern int android_query_battery (struct android_battery_state *); 142extern int android_query_battery (struct android_battery_state *);
143extern void android_display_toast (const char *);
143 144
144 145
145 146
diff --git a/src/androidfns.c b/src/androidfns.c
index dc68cef8a02..4837b00a21e 100644
--- a/src/androidfns.c
+++ b/src/androidfns.c
@@ -2357,6 +2357,11 @@ there is no mouse. */)
2357 (void) 2357 (void)
2358{ 2358{
2359#ifndef ANDROID_STUBIFY 2359#ifndef ANDROID_STUBIFY
2360 /* If no display connection is present, just return nil. */
2361
2362 if (!android_init_gui)
2363 return Qnil;
2364
2360 return android_detect_mouse () ? Qt : Qnil; 2365 return android_detect_mouse () ? Qt : Qnil;
2361#else 2366#else
2362 return Qnil; 2367 return Qnil;
diff --git a/src/androidselect.c b/src/androidselect.c
index 3947ab99166..f54a6d6f52c 100644
--- a/src/androidselect.c
+++ b/src/androidselect.c
@@ -110,6 +110,9 @@ determined. */)
110{ 110{
111 jint rc; 111 jint rc;
112 112
113 if (!android_init_gui)
114 error ("Accessing clipboard without display connection");
115
113 block_input (); 116 block_input ();
114 rc = (*android_java_env)->CallIntMethod (android_java_env, 117 rc = (*android_java_env)->CallIntMethod (android_java_env,
115 clipboard, 118 clipboard,
@@ -133,6 +136,9 @@ DEFUN ("android-set-clipboard", Fandroid_set_clipboard,
133{ 136{
134 jarray bytes; 137 jarray bytes;
135 138
139 if (!android_init_gui)
140 error ("Accessing clipboard without display connection");
141
136 CHECK_STRING (string); 142 CHECK_STRING (string);
137 string = ENCODE_UTF_8 (string); 143 string = ENCODE_UTF_8 (string);
138 144
@@ -167,6 +173,9 @@ Alternatively, return nil if the clipboard is empty. */)
167 size_t length; 173 size_t length;
168 jbyte *data; 174 jbyte *data;
169 175
176 if (!android_init_gui)
177 error ("No Android display connection!");
178
170 method = clipboard_class.get_clipboard; 179 method = clipboard_class.get_clipboard;
171 bytes 180 bytes
172 = (*android_java_env)->CallObjectMethod (android_java_env, 181 = (*android_java_env)->CallObjectMethod (android_java_env,
@@ -217,6 +226,9 @@ URL with a scheme specified. Signal an error upon failure. */)
217{ 226{
218 Lisp_Object value; 227 Lisp_Object value;
219 228
229 if (!android_init_gui)
230 error ("No Android display connection!");
231
220 CHECK_STRING (url); 232 CHECK_STRING (url);
221 value = android_browse_url (url); 233 value = android_browse_url (url);
222 234
diff --git a/src/androidterm.c b/src/androidterm.c
index 8a67d128348..814af87819b 100644
--- a/src/androidterm.c
+++ b/src/androidterm.c
@@ -866,9 +866,8 @@ handle_one_android_event (struct android_display_info *dpyinfo,
866 866
867 if (event->xaction.action == 0) 867 if (event->xaction.action == 0)
868 { 868 {
869 /* Action 0 either means to destroy a frame or to create a 869 /* Action 0 either means that a window has been destroyed
870 new frame, depending on whether or not 870 and its associated frame should be as well. */
871 event->xaction.window exists. */
872 871
873 if (event->xaction.window) 872 if (event->xaction.window)
874 { 873 {
@@ -878,8 +877,6 @@ handle_one_android_event (struct android_display_info *dpyinfo,
878 inev.ie.kind = DELETE_WINDOW_EVENT; 877 inev.ie.kind = DELETE_WINDOW_EVENT;
879 XSETFRAME (inev.ie.frame_or_window, f); 878 XSETFRAME (inev.ie.frame_or_window, f);
880 } 879 }
881 else
882 ((void) 0) /* A new frame must be created. */;
883 } 880 }
884 881
885 case ANDROID_ENTER_NOTIFY: 882 case ANDROID_ENTER_NOTIFY: