summaryrefslogtreecommitdiff
path: root/java/org
diff options
context:
space:
mode:
authorPo Lu <luangruo@yahoo.com>2024-05-22 22:00:02 +0800
committerPo Lu <luangruo@yahoo.com>2024-05-22 22:00:26 +0800
commit70effed88df2e99287cfdabb924854f69ed668e2 (patch)
treeb12021886d96343641a21dab7138e1c30834332b /java/org
parent394aac7b187628303aa2b772b29ffb5718910f94 (diff)
Improve compatibility with Android's default text editor
* java/org/gnu/emacs/EmacsView.java (showOnScreenKeyboard): Request a selection update if `inputConnection' has been established, to more closely emulate the OS text editing widget. (onCreateInputConnection) [EmacsService.DEBUG_IC]: Print current selection values before reporting them.
Diffstat (limited to 'java/org')
-rw-r--r--java/org/gnu/emacs/EmacsView.java17
1 files changed, 17 insertions, 0 deletions
diff --git a/java/org/gnu/emacs/EmacsView.java b/java/org/gnu/emacs/EmacsView.java
index 074e7242540..db270b796e8 100644
--- a/java/org/gnu/emacs/EmacsView.java
+++ b/java/org/gnu/emacs/EmacsView.java
@@ -45,6 +45,8 @@ import android.graphics.Paint;
import android.os.Build;
import android.util.Log;
+import java.util.Arrays;
+
/* This is an Android view which has a back and front buffer. When
swapBuffers is called, the back buffer is swapped to the front
buffer, and any damage is invalidated. frontBitmap and backBitmap
@@ -775,6 +777,15 @@ public final class EmacsView extends ViewGroup
imManager.showSoftInput (this, 0);
isCurrentlyTextEditor = true;
+
+ /* The OS text editing widget unconditionally reports the current
+ values of the selection to the input method after calls to
+ showSoftInput, which is redundant if inputConnection exists but
+ is now relied upon in such circumstances by the OS's default
+ input method, and must therefore be faithfully reproduced on our
+ part. */
+ if (inputConnection != null)
+ EmacsNative.requestSelectionUpdate (window.handle);
}
public void
@@ -831,6 +842,12 @@ public final class EmacsView extends ViewGroup
selection = EmacsService.viewGetSelection (window.handle);
+ if (EmacsService.DEBUG_IC)
+ Log.d (TAG, ("onCreateInputConnection: "
+ + (selection != null
+ ? Arrays.toString (selection)
+ : "(unavailable)")));
+
if (selection == null)
{
/* If the selection could not be obtained, return 0 by 0.