diff --git a/src/keepass2android/GroupBaseActivity.cs b/src/keepass2android/GroupBaseActivity.cs
index a0dbd849..5c82fddd 100644
--- a/src/keepass2android/GroupBaseActivity.cs
+++ b/src/keepass2android/GroupBaseActivity.cs
@@ -53,6 +53,7 @@ namespace keepass2android
{ Resource.Id.cancel_insert_element, 20 },
{ Resource.Id.insert_element, 20 },
{ Resource.Id.autofill_infotext, 10 },
+ { Resource.Id.notification_info_android8_infotext, 10 },
{ Resource.Id.infotext, 11 },
{ Resource.Id.select_other_entry, 20},
{ Resource.Id.add_url_entry, 20},
@@ -240,9 +241,26 @@ namespace keepass2android
UpdateAutofillInfo();
+ UpdateAndroid8NotificationInfo();
+
RefreshIfDirty();
+ }
+
+ private void UpdateAndroid8NotificationInfo(bool hideForever = false)
+ {
+ const string prefsKey = "DidShowAndroid8NotificationInfo";
+
+ bool canShowNotificationInfo = (Build.VERSION.SdkInt >= BuildVersionCodes.O) && (!_prefs.GetBoolean(prefsKey, false));
+ if ((canShowNotificationInfo) && hideForever)
+ {
+ _prefs.Edit().PutBoolean(prefsKey, true).Commit();
+ canShowNotificationInfo = false;
+ }
+ UpdateBottomBarElementVisibility(Resource.Id.notification_info_android8_infotext, canShowNotificationInfo);
+
+
}
public override bool OnSearchRequested()
@@ -340,6 +358,35 @@ namespace keepass2android
Util.MoveBottomBarButtons(Resource.Id.show_autofill_info, Resource.Id.enable_autofill, Resource.Id.autofill_buttons, this);
}
+ if (FindViewById(Resource.Id.configure_notification_channels) != null)
+ {
+ FindViewById(Resource.Id.configure_notification_channels).Click += (sender, args) =>
+ {
+ Intent intent = new Intent(Settings.ActionChannelNotificationSettings);
+ intent.PutExtra(Settings.ExtraChannelId, App.NotificationChannelIdQuicklocked);
+ intent.PutExtra(Settings.ExtraAppPackage, PackageName);
+ try
+ {
+ StartActivity(intent);
+ }
+ catch (Exception e)
+ {
+ new AlertDialog.Builder(this)
+ .SetTitle("Unexpected error")
+ .SetMessage(
+ "Opening the settings failed. Please report this to crocoapps@gmail.com including information about your device vendor and OS. Please try to configure the notifications by long pressing a KP2A notification. Details: " + e.ToString())
+ .Show();
+ }
+ UpdateAndroid8NotificationInfo(true);
+ };
+ FindViewById(Resource.Id.ignore_notification_channel).Click += (sender, args) =>
+ {
+ UpdateAndroid8NotificationInfo(true);
+ };
+
+ }
+
+
string lastInfoText;
if (IsTimeForInfotext(out lastInfoText))
diff --git a/src/keepass2android/Resources/layout/group.xml b/src/keepass2android/Resources/layout/group.xml
index cf3d5a10..aa74430a 100644
--- a/src/keepass2android/Resources/layout/group.xml
+++ b/src/keepass2android/Resources/layout/group.xml
@@ -77,7 +77,47 @@
style="@style/BottomBarButton" />
+
+
+
+
+
+
+
+
+
+
Notification icon while unlocked
Show a notification icon while the database is unlocked.
+
+ Android 8 has introduced new behavior for notifications. If you want to hide the icon for Keepass2Android\'s notifications, please configure this through the system settings. Set the importance of the notification category to Minimum.
+ Open settings
+ I don\'t care
Pre-load database file
Start background loading or downloading of the database file during password entry.
diff --git a/src/keepass2android/settings/DatabaseSettingsActivity.cs b/src/keepass2android/settings/DatabaseSettingsActivity.cs
index e54ad6de..2cb3adea 100644
--- a/src/keepass2android/settings/DatabaseSettingsActivity.cs
+++ b/src/keepass2android/settings/DatabaseSettingsActivity.cs
@@ -364,9 +364,16 @@ namespace keepass2android
// Re-use the change handlers for the application settings
FindPreference(GetString(Resource.String.keyfile_key)).PreferenceChange += OnRememberKeyFileHistoryChanged;
- FindPreference(GetString(Resource.String.ShowUnlockedNotification_key)).PreferenceChange += OnShowUnlockedNotificationChanged;
- FindPreference(GetString(Resource.String.ShowUnlockedNotification_key)).PreferenceChange += OnShowUnlockedNotificationChanged;
- FindPreference(GetString(Resource.String.DebugLog_key)).PreferenceChange += OnDebugLogChanged;
+ var unlockedNotificationPref = FindPreference(GetString(Resource.String.ShowUnlockedNotification_key));
+ unlockedNotificationPref.PreferenceChange += OnShowUnlockedNotificationChanged;
+ if ((int)Build.VERSION.SdkInt >= 26)
+ {
+ //use system notification channels to control notification visibility
+ unlockedNotificationPref.Parent.RemovePreference(unlockedNotificationPref);
+ }
+
+
+ FindPreference(GetString(Resource.String.DebugLog_key)).PreferenceChange += OnDebugLogChanged;
FindPreference(GetString(Resource.String.DebugLog_send_key)).PreferenceClick += OnSendDebug;
UpdateAutofillPref();
@@ -422,10 +429,16 @@ namespace keepass2android
Preference hideQuickUnlockTranspIconPref = FindPreference(GetString(Resource.String.QuickUnlockIconHidden_key));
Preference hideQuickUnlockIconPref = FindPreference(GetString(Resource.String.QuickUnlockIconHidden16_key));
var quickUnlockScreen = ((PreferenceScreen)FindPreference(GetString(Resource.String.QuickUnlock_prefs_key)));
- if ((int)Android.OS.Build.VERSION.SdkInt >= 16)
+ if ((int)Android.OS.Build.VERSION.SdkInt >= 26)
+ {
+ //use notification channels
+ quickUnlockScreen.RemovePreference(hideQuickUnlockTranspIconPref);
+ quickUnlockScreen.RemovePreference(hideQuickUnlockIconPref);
+ }
+ else if ((int)Android.OS.Build.VERSION.SdkInt >= 16)
{
quickUnlockScreen.RemovePreference(hideQuickUnlockTranspIconPref);
- FindPreference(GetString(Resource.String.ShowUnlockedNotification_key)).PreferenceChange += (sender, args) => App.Kp2a.UpdateOngoingNotification();
+ unlockedNotificationPref.PreferenceChange += (sender, args) => App.Kp2a.UpdateOngoingNotification();
hideQuickUnlockIconPref.PreferenceChange += delegate { App.Kp2a.UpdateOngoingNotification(); };
}
else
@@ -436,7 +449,7 @@ namespace keepass2android
delegate { App.Kp2a.UpdateOngoingNotification(); };
((PreferenceScreen)FindPreference(GetString(Resource.String.display_prefs_key))).RemovePreference(
- FindPreference(GetString(Resource.String.ShowUnlockedNotification_key)));
+ unlockedNotificationPref);
}
}
catch (Exception ex)