Merge "Set gesture exclusion rect for IMEs"

This commit is contained in:
Vinit Nayak
2019-10-22 16:23:21 +00:00
committed by Android (Google) Code Review
2 changed files with 14 additions and 22 deletions

View File

@@ -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

View File

@@ -54,9 +54,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;
@@ -70,15 +68,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
@@ -126,8 +115,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;
@@ -227,7 +214,6 @@ public class EdgeBackGestureHandler implements DisplayListener {
}
if (!mIsEnabled) {
WindowManagerWrapper.getInstance().removePinnedStackListener(mImeChangedListener);
mContext.getSystemService(DisplayManager.class).unregisterDisplayListener(this);
try {
@@ -244,7 +230,6 @@ public class EdgeBackGestureHandler implements DisplayListener {
mContext.getMainThreadHandler());
try {
WindowManagerWrapper.getInstance().addPinnedStackListener(mImeChangedListener);
WindowManagerGlobal.getWindowManagerService()
.registerSystemGestureExclusionListener(
mGestureExclusionListener, mDisplayId);
@@ -301,11 +286,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;
@@ -483,7 +463,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);
}