mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-01-18 17:01:01 -08:00
Update Android port
* java/org/gnu/emacs/EmacsActivity.java (attachWindow, onDestroy) (onWindowFocusChanged, onContextMenuClosed): * java/org/gnu/emacs/EmacsContextMenu.java (onMenuItemClick): * java/org/gnu/emacs/EmacsDialog.java (onClick, display1, onDismiss): * java/org/gnu/emacs/EmacsOpenActivity.java (checkReadableOrCopy) (onDestroy, onWindowFocusChanged, onPause): * java/org/gnu/emacs/EmacsWindowAttachmentManager.java (registerWindow, removeWindowConsumer, detachWindow) (noticeIconified, noticeDeiconified): Remove superfluous debugging code now that the Android port is stable. * java/org/gnu/emacs/EmacsView.java (onLayout): Detect if the IME is hidden while a toplevel window is focused, and clear isCurrentlyTextEditor in that case. (onApplyWindowInsets): New function. (raise, lower, popupMenu, onCreateInputConnection): Delete aforementioned debugging code.
This commit is contained in:
parent
967fa846fc
commit
2134fd9f27
6 changed files with 79 additions and 76 deletions
|
|
@ -29,6 +29,7 @@ import android.view.KeyEvent;
|
|||
import android.view.MotionEvent;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewTreeObserver;
|
||||
import android.view.WindowInsets;
|
||||
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import android.view.inputmethod.InputConnection;
|
||||
|
|
@ -302,6 +303,26 @@ public final class EmacsView extends ViewGroup
|
|||
super.setMeasuredDimension (width, height);
|
||||
}
|
||||
|
||||
/* Return whether this view's window is focused. This is made
|
||||
necessary by Android 11's unreliable dispatch of
|
||||
onWindowFocusChanged prior to gesture navigation away from a
|
||||
frame. */
|
||||
|
||||
public boolean
|
||||
checkWindowFocus ()
|
||||
{
|
||||
EmacsActivity activity;
|
||||
Object consumer;
|
||||
|
||||
consumer = window.getAttachedConsumer ();
|
||||
|
||||
if (!(consumer instanceof EmacsActivity))
|
||||
return false;
|
||||
|
||||
activity = (EmacsActivity) consumer;
|
||||
return activity.hasWindowFocus ();
|
||||
}
|
||||
|
||||
/* Note that the monitor lock for the window must never be held from
|
||||
within the lock for the view, because the window also locks the
|
||||
other way around. */
|
||||
|
|
@ -315,6 +336,7 @@ public final class EmacsView extends ViewGroup
|
|||
View child;
|
||||
Rect windowRect;
|
||||
boolean needExpose;
|
||||
WindowInsets rootWindowInsets;
|
||||
|
||||
count = getChildCount ();
|
||||
needExpose = false;
|
||||
|
|
@ -349,14 +371,37 @@ public final class EmacsView extends ViewGroup
|
|||
if (right - left > oldMeasuredWidth
|
||||
|| bottom - top > oldMeasuredHeight)
|
||||
needExpose = true;
|
||||
|
||||
/* This might return NULL if this view is not attached. */
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R)
|
||||
{
|
||||
/* If a toplevel view is focused and isCurrentlyTextEditor
|
||||
is enabled when the IME is hidden, clear
|
||||
isCurrentlyTextEditor so it isn't shown again if the
|
||||
user dismisses Emacs before returning. */
|
||||
rootWindowInsets = getRootWindowInsets ();
|
||||
|
||||
if (isCurrentlyTextEditor
|
||||
&& rootWindowInsets != null
|
||||
&& isAttachedToWindow
|
||||
&& !rootWindowInsets.isVisible (WindowInsets.Type.ime ())
|
||||
/* N.B. that the keyboard is dismissed during gesture
|
||||
navigation under Android 30, but the system is
|
||||
quite tempermental regarding whether the window is
|
||||
focused at that point. Ideally
|
||||
isCurrentlyTextEditor shouldn't be reset in that
|
||||
case, but detecting that situation appears to be
|
||||
impossible. Sigh. */
|
||||
&& (window == EmacsActivity.focusedWindow
|
||||
&& hasWindowFocus ()))
|
||||
isCurrentlyTextEditor = false;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < count; ++i)
|
||||
{
|
||||
child = getChildAt (i);
|
||||
|
||||
Log.d (TAG, "onLayout: " + child);
|
||||
|
||||
if (child == surfaceView)
|
||||
child.layout (0, 0, right - left, bottom - top);
|
||||
else if (child.getVisibility () != GONE)
|
||||
|
|
@ -491,6 +536,8 @@ public final class EmacsView extends ViewGroup
|
|||
return window.onTouchEvent (motion);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void
|
||||
moveChildToBack (View child)
|
||||
{
|
||||
|
|
@ -518,8 +565,6 @@ public final class EmacsView extends ViewGroup
|
|||
|
||||
parent = (EmacsView) getParent ();
|
||||
|
||||
Log.d (TAG, "raise: parent " + parent);
|
||||
|
||||
if (parent.indexOfChild (this)
|
||||
== parent.getChildCount () - 1)
|
||||
return;
|
||||
|
|
@ -534,8 +579,6 @@ public final class EmacsView extends ViewGroup
|
|||
|
||||
parent = (EmacsView) getParent ();
|
||||
|
||||
Log.d (TAG, "lower: parent " + parent);
|
||||
|
||||
if (parent.indexOfChild (this) == 1)
|
||||
return;
|
||||
|
||||
|
|
@ -562,9 +605,6 @@ public final class EmacsView extends ViewGroup
|
|||
contextMenu = menu;
|
||||
popupActive = true;
|
||||
|
||||
Log.d (TAG, "popupMenu: " + menu + " @" + xPosition
|
||||
+ ", " + yPosition + " " + force);
|
||||
|
||||
/* Use showContextMenu (float, float) on N to get actual popup
|
||||
behavior. */
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
|
||||
|
|
@ -700,14 +740,8 @@ public final class EmacsView extends ViewGroup
|
|||
|
||||
selection = EmacsService.viewGetSelection (window.handle);
|
||||
|
||||
if (selection != null)
|
||||
Log.d (TAG, "onCreateInputConnection: current selection is: "
|
||||
+ selection[0] + ", by " + selection[1]);
|
||||
else
|
||||
if (selection == null)
|
||||
{
|
||||
Log.d (TAG, "onCreateInputConnection: current selection could"
|
||||
+ " not be retrieved.");
|
||||
|
||||
/* If the selection could not be obtained, return 0 by 0.
|
||||
However, ask for the selection position to be updated as
|
||||
soon as possible. */
|
||||
|
|
@ -780,4 +814,33 @@ public final class EmacsView extends ViewGroup
|
|||
window.notifyContentRectPosition (locations[0],
|
||||
locations[1]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WindowInsets
|
||||
onApplyWindowInsets (WindowInsets insets)
|
||||
{
|
||||
WindowInsets rootWindowInsets;
|
||||
|
||||
/* This function is called when window insets change, which
|
||||
encompasses input method visibility changes under Android 30
|
||||
and later. If a toplevel view is focused and
|
||||
isCurrentlyTextEditor is enabled when the IME is hidden, clear
|
||||
isCurrentlyTextEditor so it isn't shown again if the user
|
||||
dismisses Emacs before returning. */
|
||||
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.R)
|
||||
return super.onApplyWindowInsets (insets);
|
||||
|
||||
/* This might return NULL if this view is not attached. */
|
||||
rootWindowInsets = getRootWindowInsets ();
|
||||
|
||||
if (isCurrentlyTextEditor
|
||||
&& rootWindowInsets != null
|
||||
&& isAttachedToWindow
|
||||
&& !rootWindowInsets.isVisible (WindowInsets.Type.ime ())
|
||||
&& window == EmacsActivity.focusedWindow)
|
||||
isCurrentlyTextEditor = false;
|
||||
|
||||
return super.onApplyWindowInsets (insets);
|
||||
}
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue