From 231c4f20ea17a406519d5797e8ea1afdd0111a7c Mon Sep 17 00:00:00 2001
From: Po Lu
Date: Wed, 11 Jun 2025 10:34:49 +0800
Subject: 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.
---
java/AndroidManifest.xml.in | 2 +-
java/INSTALL | 4 +--
java/org/gnu/emacs/EmacsActivity.java | 63 +++++++++++++++++++++++++++++++++++
java/org/gnu/emacs/EmacsWindow.java | 15 +++++++++
4 files changed, 81 insertions(+), 3 deletions(-)
(limited to 'java')
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 . -->
+ android:targetSdkVersion="36"/>
= Build.VERSION_CODES.VANILLA_ICE_CREAM)
layout.setFitsSystemWindows (true);
+ /* Android 16 replaces KEYCODE_BACK with a callback registered at
+ the window level. */
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.BAKLAVA)
+ interceptBackGesture ();
+
/* Maybe start the Emacs service if necessary. */
EmacsService.startEmacsService (this);
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;
import android.util.Log;
import android.os.Build;
+import android.os.SystemClock;
/* This defines a window, which is a handle. Windows represent a
rectangular subset of the screen with their own contents.
@@ -890,6 +891,20 @@ public final class EmacsWindow extends EmacsHandleObject
EmacsNative.sendWindowAction (this.handle, 0);
}
+ /* Dispatch a back gesture invocation as a KeyPress event. Lamentably
+ the platform does not appear to support reporting keyboard
+ modifiers with these events. */
+
+ public void
+ onBackInvoked ()
+ {
+ long time = SystemClock.uptimeMillis ();
+ EmacsNative.sendKeyPress (this.handle, time, 0,
+ KeyEvent.KEYCODE_BACK, 0);
+ EmacsNative.sendKeyRelease (this.handle, time, 0,
+ KeyEvent.KEYCODE_BACK, 0);
+ }
+
/* Mouse and touch event handling.
--
cgit v1.2.1