diff options
| -rw-r--r-- | core/java/android/inputmethodservice/InputMethodService.java | 15 | ||||
| -rw-r--r-- | packages/SystemUI/src/com/android/systemui/statusbar/phone/EdgeBackGestureHandler.java | 21 |
2 files changed, 14 insertions, 22 deletions
diff --git a/core/java/android/inputmethodservice/InputMethodService.java b/core/java/android/inputmethodservice/InputMethodService.java index 83391f368ac1..43842c5c3403 100644 --- a/core/java/android/inputmethodservice/InputMethodService.java +++ b/core/java/android/inputmethodservice/InputMethodService.java @@ -94,6 +94,7 @@ import java.io.FileDescriptor; import java.io.PrintWriter; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; +import java.util.Collections; /** * InputMethodService provides a standard implementation of an InputMethod, @@ -434,6 +435,7 @@ public class InputMethodService extends AbstractInputMethodService { final int[] mTmpLocation = new int[2]; final ViewTreeObserver.OnComputeInternalInsetsListener mInsetsComputer = info -> { + onComputeInsets(mTmpInsets); if (isExtractViewShown()) { // In true fullscreen mode, we just say the window isn't covering // any content so we don't impact whatever is behind. @@ -442,12 +444,15 @@ public class InputMethodService extends AbstractInputMethodService { info.touchableRegion.setEmpty(); info.setTouchableInsets(ViewTreeObserver.InternalInsetsInfo.TOUCHABLE_INSETS_FRAME); } else { - onComputeInsets(mTmpInsets); info.contentInsets.top = mTmpInsets.contentTopInsets; info.visibleInsets.top = mTmpInsets.visibleTopInsets; info.touchableRegion.set(mTmpInsets.touchableRegion); info.setTouchableInsets(mTmpInsets.touchableInsets); } + + if (mInputFrame != null) { + setImeExclusionRect(mTmpInsets.visibleTopInsets); + } }; final View.OnClickListener mActionClickListener = v -> { @@ -672,6 +677,14 @@ public class InputMethodService extends AbstractInputMethodService { mPrivOps.setImeWindowStatus(visibilityFlags, backDisposition); } + /** Set region of the keyboard to be avoided from back gesture */ + private void setImeExclusionRect(int visibleTopInsets) { + View inputFrameRootView = mInputFrame.getRootView(); + Rect r = new Rect(0, visibleTopInsets, inputFrameRootView.getWidth(), + inputFrameRootView.getHeight()); + inputFrameRootView.setSystemGestureExclusionRects(Collections.singletonList(r)); + } + /** * Concrete implementation of * {@link AbstractInputMethodService.AbstractInputMethodSessionImpl} that provides diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/EdgeBackGestureHandler.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/EdgeBackGestureHandler.java index 442c08991581..e0538d3d5ff7 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/EdgeBackGestureHandler.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/EdgeBackGestureHandler.java @@ -56,9 +56,7 @@ import com.android.systemui.R; import com.android.systemui.bubbles.BubbleController; import com.android.systemui.model.SysUiState; import com.android.systemui.recents.OverviewProxyService; -import com.android.systemui.shared.system.PinnedStackListenerForwarder.PinnedStackListener; import com.android.systemui.shared.system.QuickStepContract; -import com.android.systemui.shared.system.WindowManagerWrapper; import java.io.PrintWriter; import java.util.concurrent.Executor; @@ -72,15 +70,6 @@ public class EdgeBackGestureHandler implements DisplayListener { private static final int MAX_LONG_PRESS_TIMEOUT = SystemProperties.getInt( "gestures.back_timeout", 250); - private final PinnedStackListener mImeChangedListener = new PinnedStackListener() { - @Override - public void onImeVisibilityChanged(boolean imeVisible, int imeHeight) { - // No need to thread jump, assignments are atomic - mImeHeight = imeVisible ? imeHeight : 0; - // TODO: Probably cancel any existing gesture - } - }; - private ISystemGestureExclusionListener mGestureExclusionListener = new ISystemGestureExclusionListener.Stub() { @Override @@ -128,8 +117,6 @@ public class EdgeBackGestureHandler implements DisplayListener { private boolean mInRejectedExclusion = false; private boolean mIsOnLeftEdge; - private int mImeHeight = 0; - private boolean mIsAttached; private boolean mIsGesturalModeEnabled; private boolean mIsEnabled; @@ -231,7 +218,6 @@ public class EdgeBackGestureHandler implements DisplayListener { } if (!mIsEnabled) { - WindowManagerWrapper.getInstance().removePinnedStackListener(mImeChangedListener); mContext.getSystemService(DisplayManager.class).unregisterDisplayListener(this); try { @@ -248,7 +234,6 @@ public class EdgeBackGestureHandler implements DisplayListener { mContext.getMainThreadHandler()); try { - WindowManagerWrapper.getInstance().addPinnedStackListener(mImeChangedListener); WindowManagerGlobal.getWindowManagerService() .registerSystemGestureExclusionListener( mGestureExclusionListener, mDisplayId); @@ -305,11 +290,6 @@ public class EdgeBackGestureHandler implements DisplayListener { } private boolean isWithinTouchRegion(int x, int y) { - // Disallow if over the IME - if (y > (mDisplaySize.y - Math.max(mImeHeight, mNavBarHeight))) { - return false; - } - // Disallow if too far from the edge if (x > mEdgeWidth + mLeftInset && x < (mDisplaySize.x - mEdgeWidth - mRightInset)) { return false; @@ -487,7 +467,6 @@ public class EdgeBackGestureHandler implements DisplayListener { pw.println(" mInRejectedExclusion" + mInRejectedExclusion); pw.println(" mExcludeRegion=" + mExcludeRegion); pw.println(" mUnrestrictedExcludeRegion=" + mUnrestrictedExcludeRegion); - pw.println(" mImeHeight=" + mImeHeight); pw.println(" mIsAttached=" + mIsAttached); pw.println(" mEdgeWidth=" + mEdgeWidth); } |