mirror of
https://github.com/bitwarden/mobile
synced 2025-12-11 22:03:27 +00:00
cleanup on accessibility service
This commit is contained in:
@@ -187,7 +187,6 @@ namespace Bit.Droid.Accessibility
|
|||||||
return n?.ClassName?.Contains("EditText") ?? false;
|
return n?.ClassName?.Contains("EditText") ?? false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void FillCredentials(AccessibilityNodeInfo usernameNode,
|
public static void FillCredentials(AccessibilityNodeInfo usernameNode,
|
||||||
IEnumerable<AccessibilityNodeInfo> passwordNodes)
|
IEnumerable<AccessibilityNodeInfo> passwordNodes)
|
||||||
{
|
{
|
||||||
@@ -269,7 +268,7 @@ namespace Bit.Droid.Accessibility
|
|||||||
return allEditTexts.TakeWhile(n => !n.Password).LastOrDefault();
|
return allEditTexts.TakeWhile(n => !n.Password).LastOrDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Boolean OverlayPermitted(Context context)
|
public static bool OverlayPermitted(Context context)
|
||||||
{
|
{
|
||||||
if(Build.VERSION.SdkInt >= BuildVersionCodes.M)
|
if(Build.VERSION.SdkInt >= BuildVersionCodes.M)
|
||||||
{
|
{
|
||||||
@@ -282,7 +281,7 @@ namespace Bit.Droid.Accessibility
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Boolean OpenOverlaySettings(Context context, string packageName)
|
public static bool OpenOverlaySettings(Context context, string packageName)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -323,9 +322,7 @@ namespace Bit.Droid.Accessibility
|
|||||||
var eSrcRectTop = eSrcRect.Top;
|
var eSrcRectTop = eSrcRect.Top;
|
||||||
|
|
||||||
var navBarHeight = GetNavigationBarHeight();
|
var navBarHeight = GetNavigationBarHeight();
|
||||||
|
|
||||||
var calculatedTop = rootRectHeight - eSrcRectTop - navBarHeight;
|
var calculatedTop = rootRectHeight - eSrcRectTop - navBarHeight;
|
||||||
|
|
||||||
return new Point(eSrcRectLeft, calculatedTop);
|
return new Point(eSrcRectLeft, calculatedTop);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -339,10 +336,9 @@ namespace Bit.Droid.Accessibility
|
|||||||
return GetSystemResourceDimenPx("navigation_bar_height");
|
return GetSystemResourceDimenPx("navigation_bar_height");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int GetSystemResourceDimenPx(String resName)
|
private static int GetSystemResourceDimenPx(string resName)
|
||||||
{
|
{
|
||||||
var activity = (MainActivity)CrossCurrentActivity.Current.Activity;
|
var activity = (MainActivity)CrossCurrentActivity.Current.Activity;
|
||||||
|
|
||||||
var barHeight = 0;
|
var barHeight = 0;
|
||||||
var resourceId = activity.Resources.GetIdentifier(resName, "dimen", "android");
|
var resourceId = activity.Resources.GetIdentifier(resName, "dimen", "android");
|
||||||
if(resourceId > 0)
|
if(resourceId > 0)
|
||||||
|
|||||||
@@ -62,14 +62,13 @@ namespace Bit.Droid.Accessibility
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var isKnownBroswer = AccessibilityHelpers.SupportedBrowsers.ContainsKey(root.PackageName);
|
|
||||||
|
|
||||||
// AccessibilityHelpers.PrintTestData(root, e);
|
// AccessibilityHelpers.PrintTestData(root, e);
|
||||||
|
|
||||||
switch(e.EventType)
|
switch(e.EventType)
|
||||||
{
|
{
|
||||||
case EventTypes.ViewFocused:
|
case EventTypes.ViewFocused:
|
||||||
case EventTypes.ViewClicked:
|
case EventTypes.ViewClicked:
|
||||||
|
var isKnownBroswer = AccessibilityHelpers.SupportedBrowsers.ContainsKey(root.PackageName);
|
||||||
if(e.EventType == EventTypes.ViewClicked && isKnownBroswer)
|
if(e.EventType == EventTypes.ViewClicked && isKnownBroswer)
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
@@ -222,7 +221,7 @@ namespace Bit.Droid.Accessibility
|
|||||||
ViewGroup.LayoutParams.WrapContent,
|
ViewGroup.LayoutParams.WrapContent,
|
||||||
windowManagerType,
|
windowManagerType,
|
||||||
WindowManagerFlags.NotFocusable | WindowManagerFlags.NotTouchModal,
|
WindowManagerFlags.NotFocusable | WindowManagerFlags.NotTouchModal,
|
||||||
Android.Graphics.Format.Transparent);
|
Format.Transparent);
|
||||||
|
|
||||||
var anchorPosition = AccessibilityHelpers.GetOverlayAnchorPosition(root, e);
|
var anchorPosition = AccessibilityHelpers.GetOverlayAnchorPosition(root, e);
|
||||||
|
|
||||||
@@ -246,7 +245,8 @@ namespace Bit.Droid.Accessibility
|
|||||||
}
|
}
|
||||||
|
|
||||||
_overlayView = AccessibilityHelpers.GetOverlayView(this);
|
_overlayView = AccessibilityHelpers.GetOverlayView(this);
|
||||||
_overlayView.Click += (sender, eventArgs) => {
|
_overlayView.Click += (sender, eventArgs) =>
|
||||||
|
{
|
||||||
CancelOverlayPrompt();
|
CancelOverlayPrompt();
|
||||||
StartActivity(intent);
|
StartActivity(intent);
|
||||||
};
|
};
|
||||||
@@ -262,7 +262,8 @@ namespace Bit.Droid.Accessibility
|
|||||||
_windowManager.AddView(_overlayView, layoutParams);
|
_windowManager.AddView(_overlayView, layoutParams);
|
||||||
}
|
}
|
||||||
|
|
||||||
System.Diagnostics.Debug.WriteLine(">>> Accessibility Overlay View " + (updateView ? "Updated to" : "Added at") + " X:{0} Y:{1}", layoutParams.X, layoutParams.Y);
|
System.Diagnostics.Debug.WriteLine(">>> Accessibility Overlay View {0} X:{1} Y:{2}",
|
||||||
|
updateView ? "Updated to" : "Added at", layoutParams.X, layoutParams.Y);
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool SkipPackage(string eventPackageName)
|
private bool SkipPackage(string eventPackageName)
|
||||||
|
|||||||
Reference in New Issue
Block a user