extract correct app name

fix cancel notification behavior
This commit is contained in:
Philipp Crocoll 2015-10-09 22:17:24 +02:00
parent b0d03be123
commit 95fe89f020
5 changed files with 23 additions and 8 deletions

View File

@ -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)
{

View File

@ -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();

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="keepass2android.AutoFillPlugin" android:versionCode="1" android:versionName="1.0" android:installLocation="auto">
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="21" />
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="kp2a.plugin.AutoFill" android:versionCode="1" android:versionName="1.0" android:installLocation="auto">
<uses-sdk android:minSdkVersion="19" android:targetSdkVersion="21" />
<application android:label="KP2A AutoFillPlugin" android:icon="@drawable/Icon"></application>
</manifest>

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB