diff options
| author | Po Lu | 2024-05-22 22:00:02 +0800 |
|---|---|---|
| committer | Po Lu | 2024-05-22 22:00:26 +0800 |
| commit | 70effed88df2e99287cfdabb924854f69ed668e2 (patch) | |
| tree | b12021886d96343641a21dab7138e1c30834332b /java | |
| parent | 394aac7b187628303aa2b772b29ffb5718910f94 (diff) | |
| download | emacs-70effed88df2e99287cfdabb924854f69ed668e2.tar.gz emacs-70effed88df2e99287cfdabb924854f69ed668e2.zip | |
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')
| -rw-r--r-- | java/org/gnu/emacs/EmacsView.java | 17 |
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; | |||
| 45 | import android.os.Build; | 45 | import android.os.Build; |
| 46 | import android.util.Log; | 46 | import android.util.Log; |
| 47 | 47 | ||
| 48 | import java.util.Arrays; | ||
| 49 | |||
| 48 | /* This is an Android view which has a back and front buffer. When | 50 | /* This is an Android view which has a back and front buffer. When |
| 49 | swapBuffers is called, the back buffer is swapped to the front | 51 | swapBuffers is called, the back buffer is swapped to the front |
| 50 | buffer, and any damage is invalidated. frontBitmap and backBitmap | 52 | buffer, and any damage is invalidated. frontBitmap and backBitmap |
| @@ -775,6 +777,15 @@ public final class EmacsView extends ViewGroup | |||
| 775 | 777 | ||
| 776 | imManager.showSoftInput (this, 0); | 778 | imManager.showSoftInput (this, 0); |
| 777 | isCurrentlyTextEditor = true; | 779 | isCurrentlyTextEditor = true; |
| 780 | |||
| 781 | /* The OS text editing widget unconditionally reports the current | ||
| 782 | values of the selection to the input method after calls to | ||
| 783 | showSoftInput, which is redundant if inputConnection exists but | ||
| 784 | is now relied upon in such circumstances by the OS's default | ||
| 785 | input method, and must therefore be faithfully reproduced on our | ||
| 786 | part. */ | ||
| 787 | if (inputConnection != null) | ||
| 788 | EmacsNative.requestSelectionUpdate (window.handle); | ||
| 778 | } | 789 | } |
| 779 | 790 | ||
| 780 | public void | 791 | public void |
| @@ -831,6 +842,12 @@ public final class EmacsView extends ViewGroup | |||
| 831 | 842 | ||
| 832 | selection = EmacsService.viewGetSelection (window.handle); | 843 | selection = EmacsService.viewGetSelection (window.handle); |
| 833 | 844 | ||
| 845 | if (EmacsService.DEBUG_IC) | ||
| 846 | Log.d (TAG, ("onCreateInputConnection: " | ||
| 847 | + (selection != null | ||
| 848 | ? Arrays.toString (selection) | ||
| 849 | : "(unavailable)"))); | ||
| 850 | |||
| 834 | if (selection == null) | 851 | if (selection == null) |
| 835 | { | 852 | { |
| 836 | /* If the selection could not be obtained, return 0 by 0. | 853 | /* If the selection could not be obtained, return 0 by 0. |