public void DisplayAccessNotifications(PwEntryOutput entry, bool closeAfterCreate, string searchUrl) { var hadKeyboardData = ClearNotifications(); String entryName = entry.OutputStrings.ReadSafe(PwDefs.TitleField); var bmp = Util.DrawableToBitmap(App.Kp2a.GetDb().DrawableFactory.GetIconDrawable(this, App.Kp2a.GetDb().KpDatabase, entry.Entry.IconId, entry.Entry.CustomIconUuid, false)); if (!(((entry.Entry.CustomIconUuid != null) && (!entry.Entry.CustomIconUuid.Equals(PwUuid.Zero)))) && PreferenceManager.GetDefaultSharedPreferences(this).GetString("IconSetKey", PackageName) == PackageName) { Color drawingColor = new Color(189, 189, 189); bmp = Util.ChangeImageColor(bmp, drawingColor); } Bitmap entryIcon = Util.MakeLargeIcon(bmp, this); ISharedPreferences prefs = PreferenceManager.GetDefaultSharedPreferences(this); var notBuilder = new PasswordAccessNotificationBuilder(this, _notificationManager); if (prefs.GetBoolean(GetString(Resource.String.CopyToClipboardNotification_key), Resources.GetBoolean(Resource.Boolean.CopyToClipboardNotification_default))) { if (entry.OutputStrings.ReadSafe(PwDefs.PasswordField).Length > 0) { notBuilder.AddPasswordAccess(); } if (entry.OutputStrings.ReadSafe(PwDefs.UserNameField).Length > 0) { notBuilder.AddUsernameAccess(); } } bool hasKeyboardDataNow = false; if (prefs.GetBoolean(GetString(Resource.String.UseKp2aKeyboard_key), Resources.GetBoolean(Resource.Boolean.UseKp2aKeyboard_default))) { //keyboard hasKeyboardDataNow = MakeAccessibleForKeyboard(entry, searchUrl); if (hasKeyboardDataNow) { notBuilder.AddKeyboardAccess(); if (prefs.GetBoolean("kp2a_switch_rooted", false)) { //switch rooted bool onlySwitchOnSearch = prefs.GetBoolean(GetString(Resource.String.OpenKp2aKeyboardAutomaticallyOnlyAfterSearch_key), false); if (closeAfterCreate || (!onlySwitchOnSearch)) { ActivateKp2aKeyboard(); } } else { //if the app is about to be closed again (e.g. after searching for a URL and returning to the browser: // automatically bring up the Keyboard selection dialog if ((closeAfterCreate) && prefs.GetBoolean(GetString(Resource.String.OpenKp2aKeyboardAutomatically_key), Resources.GetBoolean(Resource.Boolean.OpenKp2aKeyboardAutomatically_default))) { ActivateKp2aKeyboard(); } } } } if ((!hasKeyboardDataNow) && (hadKeyboardData)) { ClearKeyboard(true); //this clears again and then (this is the point) broadcasts that we no longer have keyboard data } _numElementsToWaitFor = notBuilder.CreateNotifications(entryName, entryIcon); if (_numElementsToWaitFor == 0) { StopSelf(); return; } //register receiver to get notified when notifications are discarded in which case we can shutdown the service _notificationDeletedBroadcastReceiver = new NotificationDeletedBroadcastReceiver(this); IntentFilter deletefilter = new IntentFilter(); deletefilter.AddAction(ActionNotificationCancelled); RegisterReceiver(_notificationDeletedBroadcastReceiver, deletefilter); }