summaryrefslogtreecommitdiff
path: root/core/java/android/inputmethodservice/NavigationBarController.java
diff options
context:
space:
mode:
authorMing-Shin Lu <lumark@google.com>2022-04-27 06:00:17 +0000
committerMing-Shin Lu <lumark@google.com>2022-04-27 06:00:17 +0000
commitc65819d83970c9aa8d80f04ec397d3efa22fe4c1 (patch)
tree252cb9b0b6ca0c91bbfa3511391204f314eefaf9 /core/java/android/inputmethodservice/NavigationBarController.java
parent57edb1f7894405477d377ccffdf42ac27eeffbbe (diff)
Fix touchable region calculation in NavigationBarController (2nd)
As ViewTreeObserver.InternelInsetsInfo.touchableRegion with setting TOUCHABLE_INSETS_REGION requires setting the region that relative the window position, but CL[1] uses the global screen position to calculate the touch region, which will affect the end result, To fix this, we should use getLocationInWindow to get the relative position of the window. [1]: I0fe54efac80dd0d55f4ba37cfa7d7188b642abb0 Fix: 229562319 Test: manually verified with the IME mentioned in the bug. Test: ensure Bug 226566506 is verified. Change-Id: I9e3fe45dccb263445d378b5ac17b0e450bdb1c24
Diffstat (limited to 'core/java/android/inputmethodservice/NavigationBarController.java')
-rw-r--r--core/java/android/inputmethodservice/NavigationBarController.java18
1 files changed, 13 insertions, 5 deletions
diff --git a/core/java/android/inputmethodservice/NavigationBarController.java b/core/java/android/inputmethodservice/NavigationBarController.java
index dc38db2134f4..69105016e0ea 100644
--- a/core/java/android/inputmethodservice/NavigationBarController.java
+++ b/core/java/android/inputmethodservice/NavigationBarController.java
@@ -152,6 +152,7 @@ final class NavigationBarController {
private boolean mDrawLegacyNavigationBarBackground;
private final Rect mTempRect = new Rect();
+ private final int[] mTempPos = new int[2];
Impl(@NonNull InputMethodService inputMethodService) {
mService = inputMethodService;
@@ -259,21 +260,28 @@ final class NavigationBarController {
switch (originalInsets.touchableInsets) {
case ViewTreeObserver.InternalInsetsInfo.TOUCHABLE_INSETS_FRAME:
if (inputFrame.getVisibility() == View.VISIBLE) {
- inputFrame.getBoundsOnScreen(mTempRect);
+ inputFrame.getLocationInWindow(mTempPos);
+ mTempRect.set(mTempPos[0], mTempPos[1],
+ mTempPos[0] + inputFrame.getWidth(),
+ mTempPos[1] + inputFrame.getHeight());
touchableRegion = new Region(mTempRect);
}
break;
case ViewTreeObserver.InternalInsetsInfo.TOUCHABLE_INSETS_CONTENT:
if (inputFrame.getVisibility() == View.VISIBLE) {
- inputFrame.getBoundsOnScreen(mTempRect);
- mTempRect.top = originalInsets.contentTopInsets;
+ inputFrame.getLocationInWindow(mTempPos);
+ mTempRect.set(mTempPos[0], originalInsets.contentTopInsets,
+ mTempPos[0] + inputFrame.getWidth() ,
+ mTempPos[1] + inputFrame.getHeight());
touchableRegion = new Region(mTempRect);
}
break;
case ViewTreeObserver.InternalInsetsInfo.TOUCHABLE_INSETS_VISIBLE:
if (inputFrame.getVisibility() == View.VISIBLE) {
- inputFrame.getBoundsOnScreen(mTempRect);
- mTempRect.top = originalInsets.visibleTopInsets;
+ inputFrame.getLocationInWindow(mTempPos);
+ mTempRect.set(mTempPos[0], originalInsets.visibleTopInsets,
+ mTempPos[0] + inputFrame.getWidth(),
+ mTempPos[1] + inputFrame.getHeight());
touchableRegion = new Region(mTempRect);
}
break;