diff options
| author | Po Lu | 2025-06-11 10:34:49 +0800 |
|---|---|---|
| committer | Po Lu | 2025-06-11 10:34:49 +0800 |
| commit | 231c4f20ea17a406519d5797e8ea1afdd0111a7c (patch) | |
| tree | d974ea77ed5c8d8794185f77566078c63e04872d | |
| parent | f69b822fb0e804a13ff7a4eb55fc2ae618e0de72 (diff) | |
| download | emacs-231c4f20ea17a406519d5797e8ea1afdd0111a7c.tar.gz emacs-231c4f20ea17a406519d5797e8ea1afdd0111a7c.zip | |
Port to Android API 36
* java/AndroidManifest.xml.in: Update targetSdkVersion to 36.
* java/INSTALL: Document revised compilation dependencies.
* java/org/gnu/emacs/EmacsActivity.java (interceptBackGesture):
New function.
(onCreate): Invoke the same to register back gesture callbacks
on Android 16 or better.
* java/org/gnu/emacs/EmacsWindow.java (onBackInvoked): New
function.
* src/keyboard.c (lispy_function_keys): Amend with new symbols
introduced in Android API 36.
| -rw-r--r-- | java/AndroidManifest.xml.in | 2 | ||||
| -rw-r--r-- | java/INSTALL | 4 | ||||
| -rw-r--r-- | java/org/gnu/emacs/EmacsActivity.java | 63 | ||||
| -rw-r--r-- | java/org/gnu/emacs/EmacsWindow.java | 15 | ||||
| -rw-r--r-- | src/keyboard.c | 19 |
5 files changed, 100 insertions, 3 deletions
diff --git a/java/AndroidManifest.xml.in b/java/AndroidManifest.xml.in index ceec7a97b98..77abdf0e180 100644 --- a/java/AndroidManifest.xml.in +++ b/java/AndroidManifest.xml.in | |||
| @@ -207,7 +207,7 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. --> | |||
| 207 | <uses-permission android:name="android.permission.FOREGROUND_SERVICE_SPECIAL_USE"/> | 207 | <uses-permission android:name="android.permission.FOREGROUND_SERVICE_SPECIAL_USE"/> |
| 208 | 208 | ||
| 209 | <uses-sdk android:minSdkVersion="@ANDROID_MIN_SDK@" | 209 | <uses-sdk android:minSdkVersion="@ANDROID_MIN_SDK@" |
| 210 | android:targetSdkVersion="35"/> | 210 | android:targetSdkVersion="36"/> |
| 211 | 211 | ||
| 212 | <application android:name="org.gnu.emacs.EmacsApplication" | 212 | <application android:name="org.gnu.emacs.EmacsApplication" |
| 213 | android:label="Emacs" | 213 | android:label="Emacs" |
diff --git a/java/INSTALL b/java/INSTALL index 6fbf7ba5d6c..1c6195c6d08 100644 --- a/java/INSTALL +++ b/java/INSTALL | |||
| @@ -39,7 +39,7 @@ script like so: | |||
| 39 | Replacing the paths in the command line above with: | 39 | Replacing the paths in the command line above with: |
| 40 | 40 | ||
| 41 | - the path to the `android.jar' headers which come with the Android | 41 | - the path to the `android.jar' headers which come with the Android |
| 42 | SDK. They must correspond to Android version 15 (API level 35). | 42 | SDK. They must correspond to Android version 16 (API level 36). |
| 43 | 43 | ||
| 44 | - the path to the C compiler in the Android NDK, for the kind of CPU | 44 | - the path to the C compiler in the Android NDK, for the kind of CPU |
| 45 | you are building Emacs to run on. | 45 | you are building Emacs to run on. |
| @@ -116,7 +116,7 @@ DEX format employed by Android. There is one subdirectory for each | |||
| 116 | version of the build tools, but the version you opt for is not of | 116 | version of the build tools, but the version you opt for is not of |
| 117 | paramount significance: if your version does not work, configure will | 117 | paramount significance: if your version does not work, configure will |
| 118 | protest, so install a newer one. We anticipate that most recent | 118 | protest, so install a newer one. We anticipate that most recent |
| 119 | releases will work, such as those from the 34.0.x, and 35.0.x series. | 119 | releases will work, such as those from the 35.0.x and 36.0.x series. |
| 120 | 120 | ||
| 121 | 121 | ||
| 122 | BUILDING WITH OLD NDK VERSIONS | 122 | BUILDING WITH OLD NDK VERSIONS |
diff --git a/java/org/gnu/emacs/EmacsActivity.java b/java/org/gnu/emacs/EmacsActivity.java index 439a8defa32..6970728998b 100644 --- a/java/org/gnu/emacs/EmacsActivity.java +++ b/java/org/gnu/emacs/EmacsActivity.java | |||
| @@ -50,6 +50,11 @@ import android.view.WindowInsetsController; | |||
| 50 | 50 | ||
| 51 | import android.widget.FrameLayout; | 51 | import android.widget.FrameLayout; |
| 52 | 52 | ||
| 53 | import android.window.BackEvent; | ||
| 54 | import android.window.OnBackAnimationCallback; | ||
| 55 | import android.window.OnBackInvokedCallback; | ||
| 56 | import android.window.OnBackInvokedDispatcher; | ||
| 57 | |||
| 53 | public class EmacsActivity extends Activity | 58 | public class EmacsActivity extends Activity |
| 54 | implements EmacsWindowManager.WindowConsumer, | 59 | implements EmacsWindowManager.WindowConsumer, |
| 55 | ViewTreeObserver.OnGlobalLayoutListener | 60 | ViewTreeObserver.OnGlobalLayoutListener |
| @@ -252,6 +257,59 @@ public class EmacsActivity extends Activity | |||
| 252 | return window; | 257 | return window; |
| 253 | } | 258 | } |
| 254 | 259 | ||
| 260 | private void | ||
| 261 | interceptBackGesture () | ||
| 262 | { | ||
| 263 | OnBackInvokedDispatcher dispatcher; | ||
| 264 | int priority = OnBackInvokedDispatcher.PRIORITY_DEFAULT; | ||
| 265 | OnBackInvokedCallback callback; | ||
| 266 | |||
| 267 | dispatcher = getOnBackInvokedDispatcher (); | ||
| 268 | callback = new OnBackAnimationCallback () { | ||
| 269 | @Override | ||
| 270 | public void | ||
| 271 | onBackInvoked () | ||
| 272 | { | ||
| 273 | View view = EmacsActivity.this.getCurrentFocus (); | ||
| 274 | EmacsWindow window; | ||
| 275 | |||
| 276 | if (view instanceof EmacsView) | ||
| 277 | { | ||
| 278 | window = ((EmacsView) view).window; | ||
| 279 | window.onBackInvoked (); | ||
| 280 | } | ||
| 281 | } | ||
| 282 | |||
| 283 | /* The three functions are overridden to prevent a misleading | ||
| 284 | back animation from being displayed, as Emacs intercepts all | ||
| 285 | back gestures and will not return to the home screen. */ | ||
| 286 | |||
| 287 | @Override | ||
| 288 | public void | ||
| 289 | onBackCancelled () | ||
| 290 | { | ||
| 291 | |||
| 292 | } | ||
| 293 | |||
| 294 | @Override | ||
| 295 | public void | ||
| 296 | onBackProgressed (BackEvent gestureEvent) | ||
| 297 | { | ||
| 298 | |||
| 299 | } | ||
| 300 | |||
| 301 | @Override | ||
| 302 | public void | ||
| 303 | onBackStarted (BackEvent gestureEvent) | ||
| 304 | { | ||
| 305 | |||
| 306 | } | ||
| 307 | }; | ||
| 308 | dispatcher.registerOnBackInvokedCallback (priority, callback); | ||
| 309 | } | ||
| 310 | |||
| 311 | |||
| 312 | |||
| 255 | @Override | 313 | @Override |
| 256 | public void | 314 | public void |
| 257 | onCreate (Bundle savedInstanceState) | 315 | onCreate (Bundle savedInstanceState) |
| @@ -286,6 +344,11 @@ public class EmacsActivity extends Activity | |||
| 286 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.VANILLA_ICE_CREAM) | 344 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.VANILLA_ICE_CREAM) |
| 287 | layout.setFitsSystemWindows (true); | 345 | layout.setFitsSystemWindows (true); |
| 288 | 346 | ||
| 347 | /* Android 16 replaces KEYCODE_BACK with a callback registered at | ||
| 348 | the window level. */ | ||
| 349 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.BAKLAVA) | ||
| 350 | interceptBackGesture (); | ||
| 351 | |||
| 289 | /* Maybe start the Emacs service if necessary. */ | 352 | /* Maybe start the Emacs service if necessary. */ |
| 290 | EmacsService.startEmacsService (this); | 353 | EmacsService.startEmacsService (this); |
| 291 | 354 | ||
diff --git a/java/org/gnu/emacs/EmacsWindow.java b/java/org/gnu/emacs/EmacsWindow.java index 394b2c26414..fffa2cc5d49 100644 --- a/java/org/gnu/emacs/EmacsWindow.java +++ b/java/org/gnu/emacs/EmacsWindow.java | |||
| @@ -58,6 +58,7 @@ import android.util.SparseArray; | |||
| 58 | import android.util.Log; | 58 | import android.util.Log; |
| 59 | 59 | ||
| 60 | import android.os.Build; | 60 | import android.os.Build; |
| 61 | import android.os.SystemClock; | ||
| 61 | 62 | ||
| 62 | /* This defines a window, which is a handle. Windows represent a | 63 | /* This defines a window, which is a handle. Windows represent a |
| 63 | rectangular subset of the screen with their own contents. | 64 | rectangular subset of the screen with their own contents. |
| @@ -890,6 +891,20 @@ public final class EmacsWindow extends EmacsHandleObject | |||
| 890 | EmacsNative.sendWindowAction (this.handle, 0); | 891 | EmacsNative.sendWindowAction (this.handle, 0); |
| 891 | } | 892 | } |
| 892 | 893 | ||
| 894 | /* Dispatch a back gesture invocation as a KeyPress event. Lamentably | ||
| 895 | the platform does not appear to support reporting keyboard | ||
| 896 | modifiers with these events. */ | ||
| 897 | |||
| 898 | public void | ||
| 899 | onBackInvoked () | ||
| 900 | { | ||
| 901 | long time = SystemClock.uptimeMillis (); | ||
| 902 | EmacsNative.sendKeyPress (this.handle, time, 0, | ||
| 903 | KeyEvent.KEYCODE_BACK, 0); | ||
| 904 | EmacsNative.sendKeyRelease (this.handle, time, 0, | ||
| 905 | KeyEvent.KEYCODE_BACK, 0); | ||
| 906 | } | ||
| 907 | |||
| 893 | 908 | ||
| 894 | 909 | ||
| 895 | /* Mouse and touch event handling. | 910 | /* Mouse and touch event handling. |
diff --git a/src/keyboard.c b/src/keyboard.c index 5db11ad6379..8b2ebd215d2 100644 --- a/src/keyboard.c +++ b/src/keyboard.c | |||
| @@ -5099,6 +5099,25 @@ static const char *const lispy_function_keys[] = | |||
| 5099 | [285] = "browser-refresh", | 5099 | [285] = "browser-refresh", |
| 5100 | [28] = "clear", | 5100 | [28] = "clear", |
| 5101 | [300] = "XF86Forward", | 5101 | [300] = "XF86Forward", |
| 5102 | [319] = "dictate", | ||
| 5103 | [320] = "new", | ||
| 5104 | [321] = "close", | ||
| 5105 | [322] = "do-not-disturb", | ||
| 5106 | [323] = "print", | ||
| 5107 | [324] = "lock", | ||
| 5108 | [325] = "fullscreen", | ||
| 5109 | [326] = "f13", | ||
| 5110 | [327] = "f14", | ||
| 5111 | [328] = "f15", | ||
| 5112 | [329] = "f16", | ||
| 5113 | [330] = "f17", | ||
| 5114 | [331] = "f18", | ||
| 5115 | [332] = "f19", | ||
| 5116 | [333] = "f20", | ||
| 5117 | [334] = "f21", | ||
| 5118 | [335] = "f22", | ||
| 5119 | [336] = "f23", | ||
| 5120 | [337] = "f24", | ||
| 5102 | [4] = "XF86Back", | 5121 | [4] = "XF86Back", |
| 5103 | [61] = "tab", | 5122 | [61] = "tab", |
| 5104 | [66] = "return", | 5123 | [66] = "return", |