From 873ebee256510f31872d7977c1fa3ba8504f3257 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Fri, 26 Aug 2016 18:56:09 -0400 Subject: [PATCH] Rename accessibility service to AutofillService. Remove autofill service from app for now until it is being worked on again. --- src/Android/Android.csproj | 2 +- src/Android/AutofillService.cs | 45 ++++++++++++++++++ src/Android/LoginService.cs | 86 ---------------------------------- 3 files changed, 46 insertions(+), 87 deletions(-) create mode 100644 src/Android/AutofillService.cs delete mode 100644 src/Android/LoginService.cs diff --git a/src/Android/Android.csproj b/src/Android/Android.csproj index 19527e39d..007bb8c13 100644 --- a/src/Android/Android.csproj +++ b/src/Android/Android.csproj @@ -289,7 +289,7 @@ - + diff --git a/src/Android/AutofillService.cs b/src/Android/AutofillService.cs new file mode 100644 index 000000000..a946cadf6 --- /dev/null +++ b/src/Android/AutofillService.cs @@ -0,0 +1,45 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Android.AccessibilityServices; +using Android.App; +using Android.Content; +using Android.Graphics; +using Android.OS; +using Android.Runtime; +using Android.Views; +using Android.Views.Accessibility; +using Android.Widget; + +namespace Bit.Android +{ + //[Service(Permission = "android.permission.BIND_ACCESSIBILITY_SERVICE", Label = "bitwarden")] + //[IntentFilter(new string[] { "android.accessibilityservice.AccessibilityService" })] + //[MetaData("android.accessibilityservice", Resource = "@xml/accessibilityservice")] + public class AutofillService : AccessibilityService + { + public override void OnAccessibilityEvent(AccessibilityEvent e) + { + var eventType = e.EventType; + switch(eventType) + { + case EventTypes.ViewTextSelectionChanged: + if(e.Source.Password && string.IsNullOrWhiteSpace(e.Source.Text)) + { + var bundle = new Bundle(); + bundle.PutCharSequence(AccessibilityNodeInfo.ActionArgumentSetTextCharsequence, "mypassword"); + e.Source.PerformAction(global::Android.Views.Accessibility.Action.SetText, bundle); + } + break; + default: + break; + } + } + + public override void OnInterrupt() + { + + } + } +} \ No newline at end of file diff --git a/src/Android/LoginService.cs b/src/Android/LoginService.cs deleted file mode 100644 index 1f9cbb2b9..000000000 --- a/src/Android/LoginService.cs +++ /dev/null @@ -1,86 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Android.AccessibilityServices; -using Android.App; -using Android.Content; -using Android.Graphics; -using Android.OS; -using Android.Runtime; -using Android.Views; -using Android.Views.Accessibility; -using Android.Widget; - -namespace Bit.Android -{ - [Service(Permission = "android.permission.BIND_ACCESSIBILITY_SERVICE", Label = "bitwarden")] - [IntentFilter(new string[] { "android.accessibilityservice.AccessibilityService" })] - [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 && 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); - } - break; - default: - break; - } - } - - public override void OnInterrupt() - { - - } - - 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