diff options
author | Artyom Palvelev <artyompp@google.com> | 2024-04-02 14:47:16 +0100 |
---|---|---|
committer | Artyom Palvelev <artyompp@google.com> | 2024-04-02 14:47:16 +0100 |
commit | ea1a3965f1d9e662e3ea03a0f306931ffbdcb440 (patch) | |
tree | 6dd4f1ed38222db7a8ff1416001fa3439f3a9eba | |
parent | feac0cf0fc08a685b43219306bd383d2a51077d1 (diff) | |
download | gamesdk-main.tar.gz |
With some IMEs window insets might be null sometimes, so we have to take
this into account.
Fix: 314924320
Test: build and run AGDKTunnel
Change-Id: I3f8edb39f1c4cb4a0a5cc61a8dfc4e4fb52015a8
-rw-r--r-- | game-text-input/src/main/java/com/google/androidgamesdk/gametextinput/InputConnection.java | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/game-text-input/src/main/java/com/google/androidgamesdk/gametextinput/InputConnection.java b/game-text-input/src/main/java/com/google/androidgamesdk/gametextinput/InputConnection.java index 70527626..2de0f9d5 100644 --- a/game-text-input/src/main/java/com/google/androidgamesdk/gametextinput/InputConnection.java +++ b/game-text-input/src/main/java/com/google/androidgamesdk/gametextinput/InputConnection.java @@ -601,7 +601,16 @@ public class InputConnection * @return The current IME insets */ public Insets getImeInsets() { + if (this.targetView == null) { + return Insets.NONE; + } + WindowInsetsCompat insets = ViewCompat.getRootWindowInsets(this.targetView); + + if (insets == null) { + return Insets.NONE; + } + return insets.getInsets(WindowInsetsCompat.Type.ime()); } @@ -611,7 +620,16 @@ public class InputConnection * @return whether software IME is visible or not. */ public boolean isSoftwareKeyboardVisible() { + if (this.targetView == null) { + return false; + } + WindowInsetsCompat insets = ViewCompat.getRootWindowInsets(this.targetView); + + if (insets == null) { + return false; + } + return insets.isVisible(WindowInsetsCompat.Type.ime()); } |