public override View GetView(int position, View convertView, ViewGroup parent) { View v = base.GetView(position, convertView, parent); TextView tv = (TextView)v.FindViewById(Android.Resource.Id.Text1); tv.SetPadding(tv.PaddingLeft, 0, tv.PaddingRight, 0); PwEntry templateEntry = this.GetItem(position); int size = (int)(Util.convertDpToPixel(Util.convertDpToPixel(20, Context), Context)); var bmp = Bitmap.CreateScaledBitmap( Util.DrawableToBitmap(App.Kp2a.GetDb() .DrawableFactory.GetIconDrawable(Context, App.Kp2a.GetDb().KpDatabase, templateEntry.IconId, PwUuid.Zero, false)), size, size, true); Drawable icon = new BitmapDrawable(bmp); if ( PreferenceManager.GetDefaultSharedPreferences(Context) .GetString("IconSetKey", Context.PackageName) == Context.PackageName) { Android.Graphics.PorterDuff.Mode mMode = Android.Graphics.PorterDuff.Mode.SrcAtop; Color color = new Color(189, 189, 189); icon.SetColorFilter(color, mMode); } //Put the image on the TextView tv.SetCompoundDrawablesWithIntrinsicBounds(icon, null, null, null); tv.Text = templateEntry.Strings.ReadSafe(PwDefs.TitleField); tv.SetTextSize(ComplexUnitType.Dip, 20); tv.CompoundDrawablePadding = (int)Util.convertDpToPixel(8, Context); return(v); }
public void DisplayAccessNotifications(PwEntryOutput entry, bool closeAfterCreate, string searchUrl) { var hadKeyboardData = ClearNotifications(); String entryName = entry.OutputStrings.ReadSafe(PwDefs.TitleField); Database db = App.Kp2a.FindDatabaseForElement(entry.Entry); var bmp = Util.DrawableToBitmap(db.DrawableFactory.GetIconDrawable(this, db.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); }