mirror of
https://github.com/bitwarden/android.git
synced 2024-10-31 23:25:45 +03:00
Tweaks to accessibility autofill overlay (#818)
This commit is contained in:
parent
5d64bab719
commit
44999557c0
1 changed files with 17 additions and 24 deletions
|
@ -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
|
||||
// of visibility
|
||||
var minY = 0;
|
||||
int maxY;
|
||||
var inputMethodHeight = 0;
|
||||
if (windows != null)
|
||||
{
|
||||
if (IsStatusBarExpanded(windows))
|
||||
{
|
||||
return new Point(-1, -1);
|
||||
}
|
||||
maxY = GetApplicationVisibleHeight(windows);
|
||||
inputMethodHeight = GetInputMethodHeight(windows);
|
||||
}
|
||||
else
|
||||
{
|
||||
var minY = 0;
|
||||
var rootNodeHeight = GetNodeHeight(root);
|
||||
if (rootNodeHeight == -1)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
maxY = rootNodeHeight - GetNavigationBarHeight();
|
||||
}
|
||||
var maxY = rootNodeHeight - GetNavigationBarHeight() - GetStatusBarHeight() - inputMethodHeight;
|
||||
|
||||
point = GetOverlayAnchorPosition(anchorNode, overlayViewHeight, isOverlayAboveAnchor);
|
||||
if (point.Y < minY)
|
||||
|
@ -440,7 +437,7 @@ namespace Bit.Droid.Accessibility
|
|||
point.Y = -1;
|
||||
}
|
||||
}
|
||||
else if (point.Y > maxY)
|
||||
else if (point.Y > (maxY - overlayViewHeight))
|
||||
{
|
||||
if (isOverlayAboveAnchor)
|
||||
{
|
||||
|
@ -455,7 +452,7 @@ namespace Bit.Droid.Accessibility
|
|||
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
|
||||
// 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;
|
||||
}
|
||||
|
||||
public static int GetApplicationVisibleHeight(IEnumerable<AccessibilityWindowInfo> windows)
|
||||
public static int GetInputMethodHeight(IEnumerable<AccessibilityWindowInfo> windows)
|
||||
{
|
||||
var appWindowHeight = 0;
|
||||
var nonAppWindowHeight = 0;
|
||||
var inputMethodWindowHeight = 0;
|
||||
if (windows != null)
|
||||
{
|
||||
foreach (var window in windows)
|
||||
{
|
||||
if (window.Type == AccessibilityWindowType.InputMethod)
|
||||
{
|
||||
var windowRect = new Rect();
|
||||
window.GetBoundsInScreen(windowRect);
|
||||
if (window.Type == AccessibilityWindowType.Application)
|
||||
{
|
||||
appWindowHeight += windowRect.Height();
|
||||
}
|
||||
else
|
||||
{
|
||||
nonAppWindowHeight += windowRect.Height();
|
||||
inputMethodWindowHeight = windowRect.Height();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return appWindowHeight - nonAppWindowHeight;
|
||||
return inputMethodWindowHeight;
|
||||
}
|
||||
|
||||
public static int GetNodeHeight(AccessibilityNodeInfo node)
|
||||
|
|
Loading…
Reference in a new issue