Tweaks to accessibility autofill overlay (#818)

This commit is contained in:
Matt Portune 2020-04-02 19:24:31 -04:00 committed by GitHub
parent 5d64bab719
commit 44999557c0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -404,25 +404,22 @@ namespace Bit.Droid.Accessibility
// node.VisibleToUser doesn't always give us exactly what we want, so attempt to tighten up the range // node.VisibleToUser doesn't always give us exactly what we want, so attempt to tighten up the range
// of visibility // of visibility
var minY = 0; var inputMethodHeight = 0;
int maxY;
if (windows != null) if (windows != null)
{ {
if (IsStatusBarExpanded(windows)) if (IsStatusBarExpanded(windows))
{ {
return new Point(-1, -1); return new Point(-1, -1);
} }
maxY = GetApplicationVisibleHeight(windows); inputMethodHeight = GetInputMethodHeight(windows);
} }
else var minY = 0;
{
var rootNodeHeight = GetNodeHeight(root); var rootNodeHeight = GetNodeHeight(root);
if (rootNodeHeight == -1) if (rootNodeHeight == -1)
{ {
return null; return null;
} }
maxY = rootNodeHeight - GetNavigationBarHeight(); var maxY = rootNodeHeight - GetNavigationBarHeight() - GetStatusBarHeight() - inputMethodHeight;
}
point = GetOverlayAnchorPosition(anchorNode, overlayViewHeight, isOverlayAboveAnchor); point = GetOverlayAnchorPosition(anchorNode, overlayViewHeight, isOverlayAboveAnchor);
if (point.Y < minY) if (point.Y < minY)
@ -440,7 +437,7 @@ namespace Bit.Droid.Accessibility
point.Y = -1; point.Y = -1;
} }
} }
else if (point.Y > maxY) else if (point.Y > (maxY - overlayViewHeight))
{ {
if (isOverlayAboveAnchor) if (isOverlayAboveAnchor)
{ {
@ -455,7 +452,7 @@ namespace Bit.Droid.Accessibility
point.Y = -1; point.Y = -1;
} }
} }
else if (isOverlayAboveAnchor && point.Y < (maxY - overlayViewHeight - GetNodeHeight(anchorNode))) else if (isOverlayAboveAnchor && point.Y < (maxY - (overlayViewHeight * 2) - GetNodeHeight(anchorNode)))
{ {
// This else block forces the overlay to return to bottom alignment as soon as space is available // This else block forces the overlay to return to bottom alignment as soon as space is available
// below the anchor view. Removing this will change the behavior to wait until there isn't enough // below the anchor view. Removing this will change the behavior to wait until there isn't enough
@ -485,27 +482,23 @@ namespace Bit.Droid.Accessibility
return false; return false;
} }
public static int GetApplicationVisibleHeight(IEnumerable<AccessibilityWindowInfo> windows) public static int GetInputMethodHeight(IEnumerable<AccessibilityWindowInfo> windows)
{ {
var appWindowHeight = 0; var inputMethodWindowHeight = 0;
var nonAppWindowHeight = 0;
if (windows != null) if (windows != null)
{ {
foreach (var window in windows) foreach (var window in windows)
{
if (window.Type == AccessibilityWindowType.InputMethod)
{ {
var windowRect = new Rect(); var windowRect = new Rect();
window.GetBoundsInScreen(windowRect); window.GetBoundsInScreen(windowRect);
if (window.Type == AccessibilityWindowType.Application) inputMethodWindowHeight = windowRect.Height();
{ break;
appWindowHeight += windowRect.Height();
}
else
{
nonAppWindowHeight += windowRect.Height();
} }
} }
} }
return appWindowHeight - nonAppWindowHeight; return inputMethodWindowHeight;
} }
public static int GetNodeHeight(AccessibilityNodeInfo node) public static int GetNodeHeight(AccessibilityNodeInfo node)