From 95fe89f02080537f0a65a25009bb4421499ce45c Mon Sep 17 00:00:00 2001 From: Philipp Crocoll Date: Fri, 9 Oct 2015 22:17:24 +0200 Subject: [PATCH] extract correct app name fix cancel notification behavior --- .../Kp2aAccessibilityService.cs | 25 ++++++++++++++---- .../LookupCredentialsActivity.cs | 2 +- .../Properties/AndroidManifest.xml | 4 +-- .../drawable-xhdpi/ic_notify_keyboard.png | Bin 0 -> 15815 bytes .../Resources/drawable/Icon.png | Bin 0 -> 4147 bytes 5 files changed, 23 insertions(+), 8 deletions(-) create mode 100644 src/AutoFillPlugin/Resources/drawable-xhdpi/ic_notify_keyboard.png create mode 100644 src/AutoFillPlugin/Resources/drawable/Icon.png diff --git a/src/AutoFillPlugin/Kp2aAccessibilityService.cs b/src/AutoFillPlugin/Kp2aAccessibilityService.cs index 96297983..dbc84fc2 100644 --- a/src/AutoFillPlugin/Kp2aAccessibilityService.cs +++ b/src/AutoFillPlugin/Kp2aAccessibilityService.cs @@ -40,13 +40,16 @@ namespace keepass2android.AutoFillPlugin { Android.Util.Log.Debug(_logTag, "OnAccEvent"); - bool cancelNotification = true; if (e.EventType == EventTypes.WindowContentChanged || e.EventType == EventTypes.WindowStateChanged) { Android.Util.Log.Debug(_logTag, "event: " + e.EventType + ", package = " + e.PackageName); + if (e.PackageName == "com.android.systemui") + return; //avoid that the notification is cancelled when pulling down notif drawer var root = RootInActiveWindow; if ((ExistsNodeOrChildren(root, n => n.WindowId == e.WindowId) && !ExistsNodeOrChildren(root, n => (n.ViewIdResourceName != null) && (n.ViewIdResourceName.StartsWith("com.android.systemui"))))) { + bool cancelNotification = true; + var allEditTexts = GetNodeOrChildren(root, n=> { return IsEditText(n); }); var usernameEdit = allEditTexts.TakeWhile(edit => (edit.Password == false)).LastOrDefault(); @@ -72,21 +75,32 @@ namespace keepass2android.AutoFillPlugin { if ((LookupCredentialsActivity.LastReceivedCredentials != null) && (LookupCredentialsActivity.LastReceivedCredentials.Url == url)) { + Android.Util.Log.Debug ("KP2AAS", "Filling credentials for " + url); + FillPassword(url, usernameEdit, emptyPasswordFields); } else { + Android.Util.Log.Debug ("KP2AAS", "Notif for " + url ); + if (LookupCredentialsActivity.LastReceivedCredentials != null) { + Android.Util.Log.Debug ("KP2AAS", LookupCredentialsActivity.LastReceivedCredentials.Url); + + Android.Util.Log.Debug ("KP2AAS", url);} + AskFillPassword(url, usernameEdit, emptyPasswordFields); cancelNotification = false; } } - + if (cancelNotification) + { + ((NotificationManager)GetSystemService(NotificationService)).Cancel(autoFillNotificationId); + Android.Util.Log.Debug ("KP2AAS","Cancel notif"); + } } } - if (cancelNotification) - ((NotificationManager)GetSystemService(NotificationService)).Cancel(autoFillNotificationId); + } private static void UrlFromAddressField(ref string url, AccessibilityNodeInfo addressField) @@ -128,7 +142,8 @@ namespace keepass2android.AutoFillPlugin var packageName = url.Substring(androidAppPrefix.Length); try { - targetName = PackageManager.GetPackageInfo(packageName, 0).ApplicationInfo.Name; + var appInfo = PackageManager.GetApplicationInfo(packageName, 0); + targetName = (string) (appInfo != null ? PackageManager.GetApplicationLabel(appInfo) : packageName); } catch (Exception e) { diff --git a/src/AutoFillPlugin/LookupCredentialsActivity.cs b/src/AutoFillPlugin/LookupCredentialsActivity.cs index 9777df6e..e67eb849 100644 --- a/src/AutoFillPlugin/LookupCredentialsActivity.cs +++ b/src/AutoFillPlugin/LookupCredentialsActivity.cs @@ -45,7 +45,7 @@ namespace keepass2android.AutoFillPlugin string user = "", password = ""; output.TryGetValue(KeePassLib.PwDefs.UserNameField, out user); output.TryGetValue(KeePassLib.PwDefs.PasswordField, out password); - + Android.Util.Log.Debug ("KP2AAS", "Received credentials for " + _lastQueriedUrl); LastReceivedCredentials = new Credentials() { User = user, Password = password, Url = _lastQueriedUrl }; Finish(); diff --git a/src/AutoFillPlugin/Properties/AndroidManifest.xml b/src/AutoFillPlugin/Properties/AndroidManifest.xml index bf0d6032..273f2327 100644 --- a/src/AutoFillPlugin/Properties/AndroidManifest.xml +++ b/src/AutoFillPlugin/Properties/AndroidManifest.xml @@ -1,5 +1,5 @@  - - + + \ No newline at end of file diff --git a/src/AutoFillPlugin/Resources/drawable-xhdpi/ic_notify_keyboard.png b/src/AutoFillPlugin/Resources/drawable-xhdpi/ic_notify_keyboard.png new file mode 100644 index 0000000000000000000000000000000000000000..2e473aa2261de06a93d94931d7739bc8714a84fd GIT binary patch literal 15815 zcmeI3dsGuw9>)iA5Jb?nuxf!_vk_UXhRKtVAqhf&LLrI}1?r0-8N!q#6O%wfwkl|A zwXUq<10Tq-D|WTIt)=w%f`azpV_jRQ3$71jR~Hu#id}VAySVI30^|~i%oCxfe-`*r==!kk>5P(9Wajk%<+Bt9{Dxil$vLOpa~(= z+XvcRGZliQwYWOhnybn{G=w1<)e;3*wB2AL)et0$x0_H+F=k~KU^?6==k%Rw=CET1^NH+ibRIn=qO%>tMcADusChSRmk%3a+KhXhrQ@ zqh-3wWXLB8vuMn?$%+$3Hsy;J5G7VQheHiC{2H8>!8AOO(K5)6qzKzl6U>k1!CsP7 zs^_N}3}a?mtXY_QW@8R$QJ0x8I1957C1wpq%BPQY2^MQ|DLJJtAQ~+W*}26BnAGMb1@YWR>D$5cmX)v?G>XHFZ9BK>hYR}*>NvvRF5mo zSyQg1mXU>wD9spZCCqAq&?{W!nmKg!Y^Bm!p6r=9xKT^kEVE>=XNtRU+-_JBYQ+>( zVRQKcE>EE5^AVvK5esJX_y~^&n7EW49x6hM7nTiqh`Br=S0GXIB?!4c1VYdQP2>7%TZ2u%r9NQ2f|(mF*Tk_yBriIN0fGM}F;N)+)@lnJ~TzCb8Q zPE3q-vLkJQ)X}z>885}ODQ3dp+~X$HY{96lBj*h5o#8`aun?S^55Y%Ib?|y(yrzH)dQ@k75slNk6{5^1nEW&lZso& z{Zj^vPtBV;T(hwiBU^_$^!N)d%<%G%M;d}^sAF4ULCM9H!OmlDsLg#*t_*4*mtc%F zeX;T#mF|5ETM=fYw!62j>audGyqj2vLaPlmV+lHPN4&^MOE=G|UXgc^02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