summaryrefslogtreecommitdiff
path: root/core/java/android/inputmethodservice
diff options
context:
space:
mode:
authorJorim Jaggi <jjaggi@google.com>2020-03-06 00:13:57 +0100
committerJorim Jaggi <jjaggi@google.com>2020-03-10 12:23:58 +0000
commited35b1779bf92524fc52a0d98895b4b239f962c4 (patch)
tree3a0d275623dee03b017ed419c8b13138093fcbb4 /core/java/android/inputmethodservice
parented3c321c9fcd69694f7cf6f98ab4086f346cbbd2 (diff)
Add OnControllableInsetsChangedListener
It's useful for apps to know which inset types they can currently control, as otherwise they have to poll by calling controlInsetsAnimation repeatedly. This can be used when apps want to apply a custom animation immediately during startup as soon as possible. Fixes: 150780468 Test: InsetsControllerTest Test: CTS will be added soon Test: WindowInsetsActivity Change-Id: Ic0388c11d759843d3ac9edd8ef23904c9ce05c46
Diffstat (limited to 'core/java/android/inputmethodservice')
-rw-r--r--core/java/android/inputmethodservice/SoftInputWindow.java8
1 files changed, 8 insertions, 0 deletions
diff --git a/core/java/android/inputmethodservice/SoftInputWindow.java b/core/java/android/inputmethodservice/SoftInputWindow.java
index 0513feef801f..6efd03c44b9f 100644
--- a/core/java/android/inputmethodservice/SoftInputWindow.java
+++ b/core/java/android/inputmethodservice/SoftInputWindow.java
@@ -28,6 +28,7 @@ import android.util.Log;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.MotionEvent;
+import android.view.View;
import android.view.WindowManager;
import java.lang.annotation.Retention;
@@ -94,6 +95,13 @@ public class SoftInputWindow extends Dialog {
lp.token = token;
getWindow().setAttributes(lp);
updateWindowState(SoftInputWindowState.TOKEN_SET);
+
+ // As soon as we have a token, make sure the window is added (but not shown) by
+ // setting visibility to INVISIBLE and calling show() on Dialog. Note that
+ // WindowInsetsController.OnControllableInsetsChangedListener relies on the window
+ // being added to function.
+ getWindow().getDecorView().setVisibility(View.INVISIBLE);
+ show();
return;
case SoftInputWindowState.TOKEN_SET:
case SoftInputWindowState.SHOWN_AT_LEAST_ONCE: