fix potential crash on newer Android versions when trying to close notification drawer

This commit is contained in:
Philipp Crocoll
2023-02-11 06:50:52 +01:00
parent 9958a73d4a
commit bcc17d91bd
3 changed files with 15 additions and 7 deletions

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
android:versionCode="189"
android:versionName="1.09e-r1"
android:versionCode="190"
android:versionName="1.09e-r2"
package="keepass2android.keepass2android"
xmlns:tools="http://schemas.android.com/tools"
android:installLocation="auto">

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
android:versionCode="189"
android:versionName="1.09e-r1"
android:versionCode="190"
android:versionName="1.09e-r2"
package="keepass2android.keepass2android_nonet"
xmlns:tools="http://schemas.android.com/tools"
android:installLocation="auto">

View File

@@ -241,6 +241,7 @@ namespace keepass2android
.SetWhen(Java.Lang.JavaSystem.CurrentTimeMillis())
.SetTicker(entryName + ": " + desc)
.SetVisibility((int)Android.App.NotificationVisibility.Secret)
.SetAutoCancel(true)
.SetContentIntent(pending);
if (entryIcon != null)
builder.SetLargeIcon(entryIcon);
@@ -951,7 +952,9 @@ namespace keepass2android
{
CopyToClipboardService.CopyValueToClipboardWithTimeout(context, username, false);
}
context.SendBroadcast(new Intent(Intent.ActionCloseSystemDialogs)); //close notification drawer
CloseNotificationDrawer(context);
}
else if (action.Equals(Intents.CopyPassword))
{
@@ -960,7 +963,7 @@ namespace keepass2android
{
CopyToClipboardService.CopyValueToClipboardWithTimeout(context, password, true);
}
context.SendBroadcast(new Intent(Intent.ActionCloseSystemDialogs)); //close notification drawer
CloseNotificationDrawer(context);
}
else if (action.Equals(Intents.CopyTotp))
{
@@ -969,7 +972,7 @@ namespace keepass2android
{
CopyToClipboardService.CopyValueToClipboardWithTimeout(context, totp, true);
}
context.SendBroadcast(new Intent(Intent.ActionCloseSystemDialogs)); //close notification drawer
CloseNotificationDrawer(context);
}
else if (action.Equals(Intents.CheckKeyboard))
{
@@ -977,6 +980,11 @@ namespace keepass2android
}
}
private static void CloseNotificationDrawer(Context context)
{
if ((int)Build.VERSION.SdkInt < 31) //sending this intent is no longer allowed since Android 31
context.SendBroadcast(new Intent(Intent.ActionCloseSystemDialogs)); //close notification drawer
}
};
}