summaryrefslogtreecommitdiff
path: root/core/java/android/inputmethodservice/InputMethodService.java
diff options
context:
space:
mode:
authorTarandeep Singh <tarandeep@google.com>2019-08-07 14:45:01 -0700
committerTarandeep Singh <tarandeep@google.com>2019-08-26 12:44:10 -0700
commit92d2dd36cdd44ddeb5db85a5c3aee6f2fd3000c0 (patch)
treebe3524179b96e6f442693969bc51d1511e042b90 /core/java/android/inputmethodservice/InputMethodService.java
parentf43ba0c1ea5643f7972c2a6ee2c96c58e6f090c7 (diff)
IME transitions without pre-rendering.
Support new IME inset api transitions without using pre-rendering. This would be the default behavior when ViewRootImpl#sNewInsetsMode > 0 and pre-rendering is not enabled. Bug: 111084606 Bug: 118599175 Test: Manually verify by just enabling Insets API and keeping pre-rendering off. 1. Build and flash 2. adb shell setprop persist.wm.new_insets 1 3. adb reboot 4. Make sure tapping on edit text brings keyboard up with new transition and back closes IME with various apps. 5. Make sure IME behavior is unchanged for apps with ADJUST_RESIZE like whatsapp. Test: atest CtsInputMethodTestCases CtsInputMethodServiceHostTestCases Change-Id: If33e9dd45e549e49757237fa66051351b858875d
Diffstat (limited to 'core/java/android/inputmethodservice/InputMethodService.java')
-rw-r--r--core/java/android/inputmethodservice/InputMethodService.java22
1 files changed, 16 insertions, 6 deletions
diff --git a/core/java/android/inputmethodservice/InputMethodService.java b/core/java/android/inputmethodservice/InputMethodService.java
index 82d4d1d10d7e..83391f368ac1 100644
--- a/core/java/android/inputmethodservice/InputMethodService.java
+++ b/core/java/android/inputmethodservice/InputMethodService.java
@@ -19,6 +19,7 @@ package android.inputmethodservice;
import static android.view.Display.DEFAULT_DISPLAY;
import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT;
+import static android.view.ViewRootImpl.NEW_INSETS_MODE_NONE;
import static android.view.WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS;
import static java.lang.annotation.RetentionPolicy.SOURCE;
@@ -62,6 +63,7 @@ import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
+import android.view.ViewRootImpl;
import android.view.ViewTreeObserver;
import android.view.Window;
import android.view.WindowManager;
@@ -595,12 +597,12 @@ public class InputMethodService extends AbstractInputMethodService {
if (DEBUG) Log.v(TAG, "hideSoftInput()");
final boolean wasVisible = mIsPreRendered
? mDecorViewVisible && mWindowVisible : isInputViewShown();
+ applyVisibilityInInsetsConsumerIfNecessary(false /* setVisible */);
if (mIsPreRendered) {
if (DEBUG) {
Log.v(TAG, "Making IME window invisible");
}
setImeWindowStatus(IME_ACTIVE | IME_INVISIBLE, mBackDisposition);
- applyVisibilityInInsetsConsumer(false /* setVisible */);
onPreRenderedWindowVisibilityChanged(false /* setVisible */);
} else {
mShowInputFlags = 0;
@@ -632,11 +634,11 @@ public class InputMethodService extends AbstractInputMethodService {
if (DEBUG) {
Log.v(TAG, "Making IME window visible");
}
- applyVisibilityInInsetsConsumer(true /* setVisible */);
onPreRenderedWindowVisibilityChanged(true /* setVisible */);
} else {
showWindow(true);
}
+ applyVisibilityInInsetsConsumerIfNecessary(true /* setVisible */);
}
// If user uses hard keyboard, IME button should always be shown.
setImeWindowStatus(mapToImeWindowStatus(), mBackDisposition);
@@ -1974,16 +1976,20 @@ public class InputMethodService extends AbstractInputMethodService {
/**
* Apply the IME visibility in {@link android.view.ImeInsetsSourceConsumer} when
- * pre-rendering is enabled.
+ * {@link ViewRootImpl.sNewInsetsMode} is enabled.
* @param setVisible {@code true} to make it visible, false to hide it.
*/
- private void applyVisibilityInInsetsConsumer(boolean setVisible) {
- if (!mIsPreRendered) {
+ private void applyVisibilityInInsetsConsumerIfNecessary(boolean setVisible) {
+ if (!isVisibilityAppliedUsingInsetsConsumer()) {
return;
}
mPrivOps.applyImeVisibility(setVisible);
}
+ private boolean isVisibilityAppliedUsingInsetsConsumer() {
+ return ViewRootImpl.sNewInsetsMode > NEW_INSETS_MODE_NONE;
+ }
+
private void finishViews(boolean finishingInput) {
if (mInputViewStarted) {
if (DEBUG) Log.v(TAG, "CALL: onFinishInputView");
@@ -2007,7 +2013,11 @@ public class InputMethodService extends AbstractInputMethodService {
mWindowVisible = false;
finishViews(false /* finishingInput */);
if (mDecorViewVisible) {
- mWindow.hide();
+ // When insets API is enabled, it is responsible for client and server side
+ // visibility of IME window.
+ if (!isVisibilityAppliedUsingInsetsConsumer()) {
+ mWindow.hide();
+ }
mDecorViewVisible = false;
onWindowHidden();
mDecorViewWasVisible = false;