public override void StartInGroupActivity(GroupBaseActivity groupBaseActivity) { base.StartInGroupActivity(groupBaseActivity); if (GroupIsFound(groupBaseActivity)) // Group has been found: display toaster and stop here { if (ToastEnable) { String toastMessage = groupBaseActivity.GetString(Resource.String.NavigationToGroupCompleted_message, new Java.Lang.Object[] { FullGroupName }); Toast.MakeText(groupBaseActivity, toastMessage, ToastLength.Long).Show(); } groupBaseActivity.StartTask(TaskToBeLaunchedAfterNavigation); return; } else if ((groupBaseActivity.FullGroupId != null) && _fullGroupIds.Contains(groupBaseActivity.FullGroupId.FullId)) // Need to down up in groups tree // Get next Group Uuid { var linkedListNode = _fullGroupIds.Find(groupBaseActivity.FullGroupId.FullId); if (linkedListNode != null) { //Note: Resharper says there is a possible NullRefException. //This is not the case because it was checked above if we're already there or not. String nextGroupFullId = linkedListNode.Next.Value; ElementAndDatabaseId fullId = new ElementAndDatabaseId(nextGroupFullId); PwUuid nextGroupPwUuid = new PwUuid(MemUtil.HexStringToByteArray(fullId.ElementIdString)); // Create Group Activity PwGroup nextGroup = App.Kp2a.GetDatabase(fullId.DatabaseId).GroupsById[nextGroupPwUuid]; GroupActivity.Launch(groupBaseActivity, nextGroup, this, new ActivityLaunchModeRequestCode(0)); } return; } else // Need to go up in groups tree { ElementAndDatabaseId fullId = new ElementAndDatabaseId(_fullGroupIds.Last.Value); var targetDb = App.Kp2a.GetDatabase(fullId.DatabaseId); if (App.Kp2a.CurrentDb != targetDb) { App.Kp2a.CurrentDb = targetDb; GroupActivity.Launch(groupBaseActivity, targetDb.Root, this, new ActivityLaunchModeForward()); } else { SetActivityResult(groupBaseActivity, KeePass.ExitNormal); } groupBaseActivity.Finish(); } }
protected override void OnCreate(Bundle savedInstanceState) { _activityDesign.ApplyTheme(); base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.ImageViewActivity); ElementAndDatabaseId fullId = new ElementAndDatabaseId(Intent.GetStringExtra("EntryId")); var uuid = new PwUuid(MemUtil.HexStringToByteArray(fullId.ElementIdString)); string key = Intent.GetStringExtra("EntryKey"); var binary = App.Kp2a.GetDatabase(fullId.DatabaseId).EntriesById[uuid].Binaries.Get(key); SupportActionBar.Title = key; byte[] pbdata = binary.ReadData(); var bmp = BitmapFactory.DecodeByteArray(pbdata, 0, pbdata.Length); FindViewById <ImageView>(Resource.Id.imageView).SetImageBitmap(bmp); }
public override StartCommandResult OnStartCommand(Intent intent, StartCommandFlags flags, int startId) { Kp2aLog.Log("Received intent to provide access to entry"); _stopOnLockBroadcastReceiver = new StopOnLockBroadcastReceiver(this); IntentFilter filter = new IntentFilter(); filter.AddAction(Intents.DatabaseLocked); RegisterReceiver(_stopOnLockBroadcastReceiver, filter); if ((intent.Action == Intents.ShowNotification) || (intent.Action == Intents.UpdateKeyboard)) { String entryId = intent.GetStringExtra(EntryActivity.KeyEntry); String searchUrl = intent.GetStringExtra(SearchUrlTask.UrlToSearchKey); if (entryId == null) { Kp2aLog.Log("received intent " + intent.Action + " without KeyEntry!"); #if DEBUG throw new Exception("invalid intent received!"); #endif return(StartCommandResult.NotSticky); } PwEntryOutput entry; try { ElementAndDatabaseId fullId = new ElementAndDatabaseId(entryId); if (((App.Kp2a.LastOpenedEntry != null) && (fullId.ElementId.Equals(App.Kp2a.LastOpenedEntry.Uuid)))) { entry = App.Kp2a.LastOpenedEntry; } else { Database entryDb = App.Kp2a.GetDatabase(fullId.DatabaseId); entry = new PwEntryOutput(entryDb.EntriesById[fullId.ElementId], entryDb); } } catch (Exception e) { Kp2aLog.LogUnexpectedError(e); //seems like restarting the service happened after closing the DB StopSelf(); return(StartCommandResult.NotSticky); } if (intent.Action == Intents.ShowNotification) { //first time opening the entry -> bring up the notifications bool closeAfterCreate = intent.GetBooleanExtra(EntryActivity.KeyCloseAfterCreate, false); DisplayAccessNotifications(entry, closeAfterCreate, searchUrl); } else //UpdateKeyboard { #if !EXCLUDE_KEYBOARD //this action is received when the data in the entry has changed (e.g. by plugins) //update the keyboard data. //Check if keyboard is (still) available if (Keepass2android.Kbbridge.KeyboardData.EntryId == entry.Uuid.ToHexString()) { MakeAccessibleForKeyboard(entry, searchUrl); } #endif } } if (intent.Action == Intents.CopyStringToClipboard) { TimeoutCopyToClipboard(intent.GetStringExtra(_stringtocopy)); } if (intent.Action == Intents.ActivateKeyboard) { ActivateKp2aKeyboard(); } if (intent.Action == Intents.ClearNotificationsAndData) { ClearNotifications(); } return(StartCommandResult.RedeliverIntent); }