mirror of
https://github.com/moparisthebest/keepass2android
synced 2024-12-23 07:28:48 -05:00
Add toaster after navigation to parent group
This commit is contained in:
parent
8db8b27423
commit
5b6786d0a2
1757
src/keepass2android/Resources/Resource.designer.cs
generated
1757
src/keepass2android/Resources/Resource.designer.cs
generated
File diff suppressed because it is too large
Load Diff
@ -28,6 +28,7 @@
|
||||
<string name="application_settings">Application settings</string>
|
||||
<string name="ShowGroupnameInSearchResult_title">Display groupname in search result</string>
|
||||
<string name="ShowGroupnameInSearchResult_resume">Display groupname below entry titles. Usefull if several entries have the same name.</string>
|
||||
<string name="NavigationToGroupCompleted_message">Display group is now : %0</string>
|
||||
|
||||
<string name="security_prefs">Security</string>
|
||||
<string name="display_prefs">Display</string>
|
||||
|
@ -2,6 +2,7 @@ using System;
|
||||
using Android.App;
|
||||
using Android.Content;
|
||||
using Android.OS;
|
||||
using Android.Widget;
|
||||
using System.Collections.Generic;
|
||||
using KeePassLib;
|
||||
using KeePassLib.Security;
|
||||
@ -673,46 +674,61 @@ namespace keepass2android
|
||||
// The last one is the destination group
|
||||
public const String numberOfGroupsKey = "NumberOfGroups";
|
||||
public const String gUuidKey = "gUuidKey";
|
||||
public const String fullGroupNameKey = "fullGroupNameKey";
|
||||
|
||||
#if INCLUDE_DEBUG_MOVE_GROUPNAME
|
||||
public const String gNameKey = "gNameKey";
|
||||
private LinkedList<string> groupName;
|
||||
private LinkedList<string> groupNameList;
|
||||
#endif
|
||||
|
||||
private LinkedList<string> groupUuid;
|
||||
protected AppTask taskToBeLaunchAfterNavigation;
|
||||
|
||||
protected String fullGroupName {
|
||||
get ;
|
||||
set ;
|
||||
}
|
||||
|
||||
public NavigateAndLaunchTask() {
|
||||
this.taskToBeLaunchAfterNavigation = new NullTask();
|
||||
fullGroupName = "";
|
||||
}
|
||||
|
||||
protected NavigateAndLaunchTask(PwGroup groups, AppTask taskToBeLaunchAfterNavigation) {
|
||||
this.taskToBeLaunchAfterNavigation = taskToBeLaunchAfterNavigation;
|
||||
populateGroupsUuid (groups);
|
||||
populateGroups (groups);
|
||||
}
|
||||
|
||||
public void populateGroupsUuid(PwGroup groups) {
|
||||
public void populateGroups(PwGroup groups) {
|
||||
|
||||
groupUuid = new LinkedList<String>{};
|
||||
|
||||
#if INCLUDE_DEBUG_MOVE_GROUPNAME
|
||||
groupName = new LinkedList<String>{};
|
||||
groupNameList = new LinkedList<String>{};
|
||||
#endif
|
||||
|
||||
fullGroupName = "";
|
||||
PwGroup readGroup = groups;
|
||||
while (readGroup != null) {
|
||||
|
||||
if ( (readGroup.ParentGroup != null) ||
|
||||
(readGroup.ParentGroup == null) && (readGroup == groups) ) {
|
||||
fullGroupName = readGroup.Name + "." + fullGroupName;
|
||||
}
|
||||
|
||||
groupUuid.AddFirst (MemUtil.ByteArrayToHexString (readGroup.Uuid.UuidBytes));
|
||||
|
||||
#if INCLUDE_DEBUG_MOVE_GROUPNAME
|
||||
groupName.AddFirst (readGroup.Name);
|
||||
groupNameList.AddFirst (readGroup.Name);
|
||||
#endif
|
||||
|
||||
readGroup = readGroup.ParentGroup;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Loads the parameters of the task from the given bundle. Embeded task is not setup from this bundle
|
||||
/// </summary>
|
||||
@ -722,20 +738,24 @@ namespace keepass2android
|
||||
int numberOfGroups = b.GetInt(numberOfGroupsKey);
|
||||
groupUuid = new LinkedList<String>{};
|
||||
#if INCLUDE_DEBUG_MOVE_GROUPNAME
|
||||
groupName = new LinkedList<String>{};
|
||||
groupNameList = new LinkedList<String>{};
|
||||
#endif
|
||||
|
||||
int i = 0;
|
||||
fullGroupName = "";
|
||||
|
||||
while (i < numberOfGroups) {
|
||||
|
||||
groupUuid.AddLast ( b.GetString (gUuidKey + i) ) ;
|
||||
#if INCLUDE_DEBUG_MOVE_GROUPNAME
|
||||
groupName.AddLast ( b.GetString (gNameKey + i) );
|
||||
#endif
|
||||
|
||||
#if INCLUDE_DEBUG_MOVE_GROUPNAME
|
||||
groupNameList.AddLast ( b.GetString (gNameKey + i);
|
||||
#endif
|
||||
i++;
|
||||
}
|
||||
|
||||
this.fullGroupName = b.GetString (fullGroupNameKey);
|
||||
|
||||
}
|
||||
|
||||
public override IEnumerable<IExtra> Extras
|
||||
@ -744,13 +764,15 @@ namespace keepass2android
|
||||
{
|
||||
// Return Navigate group Extras
|
||||
IEnumerator<String> eGroupKeys = groupUuid.GetEnumerator ();
|
||||
|
||||
#if INCLUDE_DEBUG_MOVE_GROUPNAME
|
||||
IEnumerator<String> eGroupName = groupName.GetEnumerator ();
|
||||
IEnumerator<String> eGroupName = groupNameList.GetEnumerator ();
|
||||
#endif
|
||||
|
||||
int i = 0;
|
||||
while (eGroupKeys.MoveNext()) {
|
||||
yield return new StringExtra { Key = gUuidKey + i.ToString (), Value = eGroupKeys.Current };
|
||||
|
||||
#if INCLUDE_DEBUG_MOVE_GROUPNAME
|
||||
eGroupName.MoveNext();
|
||||
yield return new StringExtra { Key = gNameKey + i.ToString (), Value = eGroupName.Current };
|
||||
@ -760,6 +782,7 @@ namespace keepass2android
|
||||
}
|
||||
|
||||
yield return new IntExtra{ Key = numberOfGroupsKey, Value = i };
|
||||
yield return new StringExtra{ Key = fullGroupNameKey, Value = fullGroupName };
|
||||
|
||||
// Return afterTaskExtras
|
||||
IEnumerator<IExtra> afterTaskExtras = taskToBeLaunchAfterNavigation.Extras.GetEnumerator();
|
||||
@ -774,7 +797,12 @@ namespace keepass2android
|
||||
{
|
||||
base.StartInGroupActivity(groupBaseActivity);
|
||||
|
||||
if (GroupIsFound(groupBaseActivity) ){ // Group has been found: stop here
|
||||
if (GroupIsFound(groupBaseActivity) ){ // Group has been found: display toaster and stop here
|
||||
|
||||
String toastMessage = groupBaseActivity.GetString(Resource.String.NavigationToGroupCompleted_message);
|
||||
toastMessage = toastMessage.Replace ("%0", this.fullGroupName);
|
||||
Toast.MakeText (groupBaseActivity, toastMessage, ToastLength.Long).Show ();
|
||||
|
||||
groupBaseActivity.StartTask (taskToBeLaunchAfterNavigation);
|
||||
return;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user