switch to TargetSDK 26, implement notification channels allowing customization of notification importance on Android 8, see #178
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="46" android:versionName="0.9.3-release-3" package="keepass2android.keepass2android_debug" android:installLocation="auto">
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="46" android:versionName="0.9.3-release-3" package="keepass2android.keepass2android_debug" android:installLocation="auto">
|
||||||
<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="23" />
|
<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="26" />
|
||||||
<permission android:description="@string/permission_desc2" android:icon="@drawable/ic_notify_locked" android:label="KP2A entry search" android:name="keepass2android.keepass2android_debug.permission.KP2aInternalSearch" android:protectionLevel="signature" />
|
<permission android:description="@string/permission_desc2" android:icon="@drawable/ic_notify_locked" android:label="KP2A entry search" android:name="keepass2android.keepass2android_debug.permission.KP2aInternalSearch" android:protectionLevel="signature" />
|
||||||
<permission android:description="@string/permission_desc3" android:icon="@drawable/ic_launcher_online" android:label="KP2A choose autofill dataset" android:name="keepass2android.keepass2android_debug.permission.Kp2aChooseAutofill" android:protectionLevel="signature" />
|
<permission android:description="@string/permission_desc3" android:icon="@drawable/ic_launcher_online" android:label="KP2A choose autofill dataset" android:name="keepass2android.keepass2android_debug.permission.Kp2aChooseAutofill" android:protectionLevel="signature" />
|
||||||
<application android:label="keepass2android" android:icon="@drawable/ic_launcher">
|
<application android:label="keepass2android" android:icon="@drawable/ic_launcher">
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
android:versionName="1.04"
|
android:versionName="1.04"
|
||||||
package="keepass2android.keepass2android"
|
package="keepass2android.keepass2android"
|
||||||
android:installLocation="auto">
|
android:installLocation="auto">
|
||||||
<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="23" />
|
<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="26" />
|
||||||
<permission android:description="@string/permission_desc2" android:icon="@drawable/ic_launcher_online" android:label="KP2A entry search" android:name="keepass2android.keepass2android.permission.KP2aInternalSearch" android:protectionLevel="signature" />
|
<permission android:description="@string/permission_desc2" android:icon="@drawable/ic_launcher_online" android:label="KP2A entry search" android:name="keepass2android.keepass2android.permission.KP2aInternalSearch" android:protectionLevel="signature" />
|
||||||
<permission android:description="@string/permission_desc3" android:icon="@drawable/ic_launcher_online" android:label="KP2A choose autofill dataset" android:name="keepass2android.keepass2android.permission.Kp2aChooseAutofill" android:protectionLevel="signature" />
|
<permission android:description="@string/permission_desc3" android:icon="@drawable/ic_launcher_online" android:label="KP2A choose autofill dataset" android:name="keepass2android.keepass2android.permission.Kp2aChooseAutofill" android:protectionLevel="signature" />
|
||||||
|
|
||||||
|
|||||||
@@ -689,6 +689,15 @@
|
|||||||
|
|
||||||
</string>
|
</string>
|
||||||
|
|
||||||
|
<string name="DbUnlockedChannel_name">Database unlocked</string>
|
||||||
|
<string name="DbUnlockedChannel_desc">Notification about the database being unlocked</string>
|
||||||
|
|
||||||
|
<string name="DbQuicklockedChannel_name">QuickUnlock</string>
|
||||||
|
<string name="DbQuicklockedChannel_desc">Notification about the database being locked with QuickUnlock</string>
|
||||||
|
|
||||||
|
<string name="EntryChannel_name">Entry notifications</string>
|
||||||
|
<string name="EntryChannel_desc">Notification to simplify access to the currently selected entry.</string>
|
||||||
|
|
||||||
<string name="ErrorReportTitle">Keepass2Android: An error occurred.</string>
|
<string name="ErrorReportTitle">Keepass2Android: An error occurred.</string>
|
||||||
<string name="ErrorReportText">An unexpected error occurred while running Keepass2Android. Please help us fix this by allowing the app to send error reports.</string>
|
<string name="ErrorReportText">An unexpected error occurred while running Keepass2Android. Please help us fix this by allowing the app to send error reports.</string>
|
||||||
<string name="ErrorReportPromise">Error reports will never contain any contents of your database or master password. You can disable them in the application settings.</string>
|
<string name="ErrorReportPromise">Error reports will never contain any contents of your database or master password. You can disable them in the application settings.</string>
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ using System.IO;
|
|||||||
using System.Net.Security;
|
using System.Net.Security;
|
||||||
using Android.App;
|
using Android.App;
|
||||||
using Android.Content;
|
using Android.Content;
|
||||||
|
using Android.Graphics;
|
||||||
using Android.Graphics.Drawables;
|
using Android.Graphics.Drawables;
|
||||||
using Android.OS;
|
using Android.OS;
|
||||||
using Android.Runtime;
|
using Android.Runtime;
|
||||||
@@ -845,7 +846,11 @@ namespace keepass2android
|
|||||||
#endif
|
#endif
|
||||||
public class App : Application {
|
public class App : Application {
|
||||||
|
|
||||||
public App (IntPtr javaReference, JniHandleOwnership transfer)
|
public const string NotificationChannelIdUnlocked = "channel_db_unlocked_3";
|
||||||
|
public const string NotificationChannelIdQuicklocked = "channel_db_quicklocked_3";
|
||||||
|
public const string NotificationChannelIdEntry = "channel_db_entry_3";
|
||||||
|
|
||||||
|
public App (IntPtr javaReference, JniHandleOwnership transfer)
|
||||||
: base(javaReference, transfer)
|
: base(javaReference, transfer)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -857,14 +862,53 @@ namespace keepass2android
|
|||||||
|
|
||||||
Kp2aLog.Log("Creating application "+PackageName+". Version=" + PackageManager.GetPackageInfo(PackageName, 0).VersionCode);
|
Kp2aLog.Log("Creating application "+PackageName+". Version=" + PackageManager.GetPackageInfo(PackageName, 0).VersionCode);
|
||||||
|
|
||||||
|
CreateNotificationChannels();
|
||||||
|
|
||||||
Kp2a.OnCreate(this);
|
Kp2a.OnCreate(this);
|
||||||
AndroidEnvironment.UnhandledExceptionRaiser += MyApp_UnhandledExceptionHandler;
|
AndroidEnvironment.UnhandledExceptionRaiser += MyApp_UnhandledExceptionHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void CreateNotificationChannels()
|
||||||
|
{
|
||||||
|
NotificationManager mNotificationManager =
|
||||||
|
(NotificationManager)GetSystemService(Context.NotificationService);
|
||||||
|
|
||||||
|
{
|
||||||
|
string name = GetString(Resource.String.DbUnlockedChannel_name);
|
||||||
public override void OnTerminate() {
|
string desc = GetString(Resource.String.DbUnlockedChannel_desc);
|
||||||
|
NotificationChannel mChannel =
|
||||||
|
new NotificationChannel(NotificationChannelIdUnlocked, name, NotificationImportance.Low);
|
||||||
|
mChannel.Description = desc;
|
||||||
|
mChannel.EnableLights(false);
|
||||||
|
mChannel.EnableVibration(false);
|
||||||
|
mNotificationManager.CreateNotificationChannel(mChannel);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
string name = GetString(Resource.String.DbQuicklockedChannel_name);
|
||||||
|
string desc = GetString(Resource.String.DbQuicklockedChannel_desc);
|
||||||
|
NotificationChannel mChannel =
|
||||||
|
new NotificationChannel(NotificationChannelIdQuicklocked, name, NotificationImportance.Min);
|
||||||
|
mChannel.Description = desc;
|
||||||
|
mChannel.EnableLights(false);
|
||||||
|
mChannel.EnableVibration(false);
|
||||||
|
mNotificationManager.CreateNotificationChannel(mChannel);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
string name = GetString(Resource.String.EntryChannel_name);
|
||||||
|
string desc = GetString(Resource.String.EntryChannel_desc);
|
||||||
|
NotificationChannel mChannel =
|
||||||
|
new NotificationChannel(NotificationChannelIdEntry, name, NotificationImportance.None);
|
||||||
|
mChannel.Description = desc;
|
||||||
|
mChannel.EnableLights(false);
|
||||||
|
mChannel.EnableVibration(false);
|
||||||
|
mNotificationManager.CreateNotificationChannel(mChannel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public override void OnTerminate() {
|
||||||
base.OnTerminate();
|
base.OnTerminate();
|
||||||
Kp2aLog.Log("Terminating application");
|
Kp2aLog.Log("Terminating application");
|
||||||
Kp2a.OnTerminate();
|
Kp2a.OnTerminate();
|
||||||
|
|||||||
@@ -198,7 +198,7 @@ namespace keepass2android
|
|||||||
pending = GetPendingIntent(intentText, descResId);
|
pending = GetPendingIntent(intentText, descResId);
|
||||||
}
|
}
|
||||||
|
|
||||||
var builder = new NotificationCompat.Builder(_ctx);
|
var builder = new NotificationCompat.Builder(_ctx, App.NotificationChannelIdEntry);
|
||||||
builder.SetSmallIcon(drawableResId)
|
builder.SetSmallIcon(drawableResId)
|
||||||
.SetContentText(desc)
|
.SetContentText(desc)
|
||||||
.SetContentTitle(entryName)
|
.SetContentTitle(entryName)
|
||||||
|
|||||||
@@ -139,7 +139,7 @@ namespace keepass2android
|
|||||||
grayIconResouceId = Resource.Drawable.transparent;
|
grayIconResouceId = Resource.Drawable.transparent;
|
||||||
}
|
}
|
||||||
NotificationCompat.Builder builder =
|
NotificationCompat.Builder builder =
|
||||||
new NotificationCompat.Builder(this)
|
new NotificationCompat.Builder(this, App.NotificationChannelIdQuicklocked)
|
||||||
.SetSmallIcon(grayIconResouceId)
|
.SetSmallIcon(grayIconResouceId)
|
||||||
.SetLargeIcon(MakeLargeIcon(BitmapFactory.DecodeResource(Resources, AppNames.NotificationLockedIcon)))
|
.SetLargeIcon(MakeLargeIcon(BitmapFactory.DecodeResource(Resources, AppNames.NotificationLockedIcon)))
|
||||||
.SetVisibility((int)Android.App.NotificationVisibility.Secret)
|
.SetVisibility((int)Android.App.NotificationVisibility.Secret)
|
||||||
@@ -183,7 +183,7 @@ namespace keepass2android
|
|||||||
private Notification GetUnlockedNotification()
|
private Notification GetUnlockedNotification()
|
||||||
{
|
{
|
||||||
NotificationCompat.Builder builder =
|
NotificationCompat.Builder builder =
|
||||||
new NotificationCompat.Builder(this)
|
new NotificationCompat.Builder(this, App.NotificationChannelIdUnlocked)
|
||||||
.SetOngoing(true)
|
.SetOngoing(true)
|
||||||
.SetSmallIcon(Resource.Drawable.ic_notify)
|
.SetSmallIcon(Resource.Drawable.ic_notify)
|
||||||
.SetLargeIcon(MakeLargeIcon(BitmapFactory.DecodeResource(Resources, AppNames.NotificationUnlockedIcon)))
|
.SetLargeIcon(MakeLargeIcon(BitmapFactory.DecodeResource(Resources, AppNames.NotificationUnlockedIcon)))
|
||||||
|
|||||||
Reference in New Issue
Block a user