diff --git a/src/Android/LoginService.cs b/src/Android/LoginService.cs index 6dda5a6e3..1f9cbb2b9 100644 --- a/src/Android/LoginService.cs +++ b/src/Android/LoginService.cs @@ -5,6 +5,7 @@ using System.Text; using Android.AccessibilityServices; using Android.App; using Android.Content; +using Android.Graphics; using Android.OS; using Android.Runtime; using Android.Views; @@ -18,14 +19,20 @@ namespace Bit.Android [MetaData("android.accessibilityservice", Resource = "@xml/accessibilityservice")] public class LoginService : AccessibilityService { + private View mView; + + private WindowManagerLayoutParams mParams; + private IWindowManager mWindowManager; + public override void OnAccessibilityEvent(AccessibilityEvent e) { var eventType = e.EventType; switch(eventType) { case EventTypes.ViewTextSelectionChanged: - if(e.Source.Password) + if(e.Source.Password && string.IsNullOrWhiteSpace(e.Source.Text)) { + MakeWindow(); var bundle = new Bundle(); bundle.PutCharSequence(AccessibilityNodeInfo.ActionArgumentSetTextCharsequence, "mypassword"); e.Source.PerformAction(global::Android.Views.Accessibility.Action.SetText, bundle); @@ -40,5 +47,40 @@ namespace Bit.Android { } + + public void MakeWindow() + { + mView = new MyLoadView(this); + + mParams = new WindowManagerLayoutParams( + WindowManagerTypes.SystemOverlay, + WindowManagerFlags.WatchOutsideTouch, + Format.Translucent); + + mParams.Gravity = GravityFlags.Top | GravityFlags.Right; + mParams.Title = "Test window"; + + mWindowManager = GetSystemService(WindowService).JavaCast(); + mWindowManager.AddView(mView, mParams); + } + + public class MyLoadView : View + { + private Paint mPaint; + + public MyLoadView(Context context) + : base(context) + { + mPaint = new Paint(); + mPaint.TextSize = 50; + mPaint.SetARGB(200, 200, 200, 200); + } + + protected override void OnDraw(Canvas canvas) + { + base.OnDraw(canvas); + canvas.DrawText("test test test", 0, 100, mPaint); + } + } } } \ No newline at end of file diff --git a/src/Android/Properties/AndroidManifest.xml b/src/Android/Properties/AndroidManifest.xml index 3abd5cf3a..95a679e48 100644 --- a/src/Android/Properties/AndroidManifest.xml +++ b/src/Android/Properties/AndroidManifest.xml @@ -3,5 +3,6 @@ + \ No newline at end of file