Merge "Only use system gesture insets for exclusion rects with root ime view" into rvc-qpr-dev

This commit is contained in:
TreeHugger Robot
2020-11-03 19:12:15 +00:00
committed by Android (Google) Code Review

View File

@@ -71,6 +71,7 @@ import android.view.ViewTreeObserver;
import android.view.Window; import android.view.Window;
import android.view.WindowInsets; import android.view.WindowInsets;
import android.view.WindowInsets.Side; import android.view.WindowInsets.Side;
import android.view.WindowInsets.Type;
import android.view.WindowManager; import android.view.WindowManager;
import android.view.animation.AnimationUtils; import android.view.animation.AnimationUtils;
import android.view.inputmethod.CompletionInfo; import android.view.inputmethod.CompletionInfo;
@@ -104,7 +105,7 @@ import java.io.FileDescriptor;
import java.io.PrintWriter; import java.io.PrintWriter;
import java.lang.annotation.Retention; import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy; import java.lang.annotation.RetentionPolicy;
import java.util.Collections; import java.util.ArrayList;
/** /**
* InputMethodService provides a standard implementation of an InputMethod, * InputMethodService provides a standard implementation of an InputMethod,
@@ -850,10 +851,19 @@ public class InputMethodService extends AbstractInputMethodService {
/** Set region of the keyboard to be avoided from back gesture */ /** Set region of the keyboard to be avoided from back gesture */
private void setImeExclusionRect(int visibleTopInsets) { private void setImeExclusionRect(int visibleTopInsets) {
View inputFrameRootView = mInputFrame.getRootView(); View rootView = mInputFrame.getRootView();
Rect r = new Rect(0, visibleTopInsets, inputFrameRootView.getWidth(), android.graphics.Insets systemGesture =
inputFrameRootView.getHeight()); rootView.getRootWindowInsets().getInsetsIgnoringVisibility(Type.systemGestures());
inputFrameRootView.setSystemGestureExclusionRects(Collections.singletonList(r)); ArrayList<Rect> exclusionRects = new ArrayList<>();
exclusionRects.add(new Rect(0,
visibleTopInsets,
systemGesture.left,
rootView.getHeight()));
exclusionRects.add(new Rect(rootView.getWidth() - systemGesture.right,
visibleTopInsets,
rootView.getWidth(),
rootView.getHeight()));
rootView.setSystemGestureExclusionRects(exclusionRects);
} }
/** /**