mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-01-10 05:30:45 -08:00
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.
This commit is contained in:
parent
f69b822fb0
commit
231c4f20ea
5 changed files with 100 additions and 3 deletions
|
|
@ -50,6 +50,11 @@ import android.view.WindowInsetsController;
|
|||
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
import android.window.BackEvent;
|
||||
import android.window.OnBackAnimationCallback;
|
||||
import android.window.OnBackInvokedCallback;
|
||||
import android.window.OnBackInvokedDispatcher;
|
||||
|
||||
public class EmacsActivity extends Activity
|
||||
implements EmacsWindowManager.WindowConsumer,
|
||||
ViewTreeObserver.OnGlobalLayoutListener
|
||||
|
|
@ -252,6 +257,59 @@ public class EmacsActivity extends Activity
|
|||
return window;
|
||||
}
|
||||
|
||||
private void
|
||||
interceptBackGesture ()
|
||||
{
|
||||
OnBackInvokedDispatcher dispatcher;
|
||||
int priority = OnBackInvokedDispatcher.PRIORITY_DEFAULT;
|
||||
OnBackInvokedCallback callback;
|
||||
|
||||
dispatcher = getOnBackInvokedDispatcher ();
|
||||
callback = new OnBackAnimationCallback () {
|
||||
@Override
|
||||
public void
|
||||
onBackInvoked ()
|
||||
{
|
||||
View view = EmacsActivity.this.getCurrentFocus ();
|
||||
EmacsWindow window;
|
||||
|
||||
if (view instanceof EmacsView)
|
||||
{
|
||||
window = ((EmacsView) view).window;
|
||||
window.onBackInvoked ();
|
||||
}
|
||||
}
|
||||
|
||||
/* The three functions are overridden to prevent a misleading
|
||||
back animation from being displayed, as Emacs intercepts all
|
||||
back gestures and will not return to the home screen. */
|
||||
|
||||
@Override
|
||||
public void
|
||||
onBackCancelled ()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void
|
||||
onBackProgressed (BackEvent gestureEvent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void
|
||||
onBackStarted (BackEvent gestureEvent)
|
||||
{
|
||||
|
||||
}
|
||||
};
|
||||
dispatcher.registerOnBackInvokedCallback (priority, callback);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void
|
||||
onCreate (Bundle savedInstanceState)
|
||||
|
|
@ -286,6 +344,11 @@ public class EmacsActivity extends Activity
|
|||
if (Build.VERSION.SDK_INT >= 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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue