mirror of
https://github.com/moparisthebest/keepass2android
synced 2025-01-09 12:38:02 -05:00
extract correct app name
fix cancel notification behavior
This commit is contained in:
parent
b0d03be123
commit
95fe89f020
@ -40,13 +40,16 @@ namespace keepass2android.AutoFillPlugin
|
|||||||
{
|
{
|
||||||
|
|
||||||
Android.Util.Log.Debug(_logTag, "OnAccEvent");
|
Android.Util.Log.Debug(_logTag, "OnAccEvent");
|
||||||
bool cancelNotification = true;
|
|
||||||
if (e.EventType == EventTypes.WindowContentChanged || e.EventType == EventTypes.WindowStateChanged)
|
if (e.EventType == EventTypes.WindowContentChanged || e.EventType == EventTypes.WindowStateChanged)
|
||||||
{
|
{
|
||||||
Android.Util.Log.Debug(_logTag, "event: " + e.EventType + ", package = " + e.PackageName);
|
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;
|
var root = RootInActiveWindow;
|
||||||
if ((ExistsNodeOrChildren(root, n => n.WindowId == e.WindowId) && !ExistsNodeOrChildren(root, n => (n.ViewIdResourceName != null) && (n.ViewIdResourceName.StartsWith("com.android.systemui")))))
|
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 allEditTexts = GetNodeOrChildren(root, n=> { return IsEditText(n); });
|
||||||
|
|
||||||
var usernameEdit = allEditTexts.TakeWhile(edit => (edit.Password == false)).LastOrDefault();
|
var usernameEdit = allEditTexts.TakeWhile(edit => (edit.Password == false)).LastOrDefault();
|
||||||
@ -72,21 +75,32 @@ namespace keepass2android.AutoFillPlugin
|
|||||||
{
|
{
|
||||||
if ((LookupCredentialsActivity.LastReceivedCredentials != null) && (LookupCredentialsActivity.LastReceivedCredentials.Url == url))
|
if ((LookupCredentialsActivity.LastReceivedCredentials != null) && (LookupCredentialsActivity.LastReceivedCredentials.Url == url))
|
||||||
{
|
{
|
||||||
|
Android.Util.Log.Debug ("KP2AAS", "Filling credentials for " + url);
|
||||||
|
|
||||||
FillPassword(url, usernameEdit, emptyPasswordFields);
|
FillPassword(url, usernameEdit, emptyPasswordFields);
|
||||||
}
|
}
|
||||||
else
|
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);
|
AskFillPassword(url, usernameEdit, emptyPasswordFields);
|
||||||
cancelNotification = false;
|
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)
|
private static void UrlFromAddressField(ref string url, AccessibilityNodeInfo addressField)
|
||||||
@ -128,7 +142,8 @@ namespace keepass2android.AutoFillPlugin
|
|||||||
var packageName = url.Substring(androidAppPrefix.Length);
|
var packageName = url.Substring(androidAppPrefix.Length);
|
||||||
try
|
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)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
@ -45,7 +45,7 @@ namespace keepass2android.AutoFillPlugin
|
|||||||
string user = "", password = "";
|
string user = "", password = "";
|
||||||
output.TryGetValue(KeePassLib.PwDefs.UserNameField, out user);
|
output.TryGetValue(KeePassLib.PwDefs.UserNameField, out user);
|
||||||
output.TryGetValue(KeePassLib.PwDefs.PasswordField, out password);
|
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 };
|
LastReceivedCredentials = new Credentials() { User = user, Password = password, Url = _lastQueriedUrl };
|
||||||
|
|
||||||
Finish();
|
Finish();
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?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">
|
<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="21" android:targetSdkVersion="21" />
|
<uses-sdk android:minSdkVersion="19" android:targetSdkVersion="21" />
|
||||||
<application android:label="KP2A AutoFillPlugin" android:icon="@drawable/Icon"></application>
|
<application android:label="KP2A AutoFillPlugin" android:icon="@drawable/Icon"></application>
|
||||||
</manifest>
|
</manifest>
|
Binary file not shown.
After Width: | Height: | Size: 15 KiB |
BIN
src/AutoFillPlugin/Resources/drawable/Icon.png
Normal file
BIN
src/AutoFillPlugin/Resources/drawable/Icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.0 KiB |
Loading…
Reference in New Issue
Block a user