added option whether the group name should be displayed in Entry View or not

minor refactoring in AppTask
changed AppTask.StartInGroupActivity to OnResume because this is always called, also when a new app task is retrieved from Activity Result
This commit is contained in:
Philipp Crocoll 2014-05-28 17:24:43 +02:00
parent 54f2abdb31
commit 87fe6abd38
7 changed files with 956 additions and 966 deletions

View File

@ -23,8 +23,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KP2AKdbLibraryBinding", "KP
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ArtTestApp", "ArtTestApp\ArtTestApp.csproj", "{1FF6C335-A627-43C9-AAA7-CBAC2E74CD18}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PluginHostTest", "PluginHostTest\PluginHostTest.csproj", "{C9F4AE81-0996-4E17-B3F2-D0F652F6AC50}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PluginSdkBinding", "PluginSdkBinding\PluginSdkBinding.csproj", "{3DA3911E-36DE-465E-8F15-F1991B6437E5}"
EndProject
Global
@ -268,30 +266,6 @@ Global
{1FF6C335-A627-43C9-AAA7-CBAC2E74CD18}.ReleaseNoNet|Mixed Platforms.Deploy.0 = Release|Any CPU
{1FF6C335-A627-43C9-AAA7-CBAC2E74CD18}.ReleaseNoNet|Win32.ActiveCfg = Release|Any CPU
{1FF6C335-A627-43C9-AAA7-CBAC2E74CD18}.ReleaseNoNet|x64.ActiveCfg = Release|Any CPU
{C9F4AE81-0996-4E17-B3F2-D0F652F6AC50}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C9F4AE81-0996-4E17-B3F2-D0F652F6AC50}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C9F4AE81-0996-4E17-B3F2-D0F652F6AC50}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
{C9F4AE81-0996-4E17-B3F2-D0F652F6AC50}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{C9F4AE81-0996-4E17-B3F2-D0F652F6AC50}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{C9F4AE81-0996-4E17-B3F2-D0F652F6AC50}.Debug|Mixed Platforms.Deploy.0 = Debug|Any CPU
{C9F4AE81-0996-4E17-B3F2-D0F652F6AC50}.Debug|Win32.ActiveCfg = Debug|Any CPU
{C9F4AE81-0996-4E17-B3F2-D0F652F6AC50}.Debug|x64.ActiveCfg = Debug|Any CPU
{C9F4AE81-0996-4E17-B3F2-D0F652F6AC50}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C9F4AE81-0996-4E17-B3F2-D0F652F6AC50}.Release|Any CPU.Build.0 = Release|Any CPU
{C9F4AE81-0996-4E17-B3F2-D0F652F6AC50}.Release|Any CPU.Deploy.0 = Release|Any CPU
{C9F4AE81-0996-4E17-B3F2-D0F652F6AC50}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{C9F4AE81-0996-4E17-B3F2-D0F652F6AC50}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{C9F4AE81-0996-4E17-B3F2-D0F652F6AC50}.Release|Mixed Platforms.Deploy.0 = Release|Any CPU
{C9F4AE81-0996-4E17-B3F2-D0F652F6AC50}.Release|Win32.ActiveCfg = Release|Any CPU
{C9F4AE81-0996-4E17-B3F2-D0F652F6AC50}.Release|x64.ActiveCfg = Release|Any CPU
{C9F4AE81-0996-4E17-B3F2-D0F652F6AC50}.ReleaseNoNet|Any CPU.ActiveCfg = Release|Any CPU
{C9F4AE81-0996-4E17-B3F2-D0F652F6AC50}.ReleaseNoNet|Any CPU.Build.0 = Release|Any CPU
{C9F4AE81-0996-4E17-B3F2-D0F652F6AC50}.ReleaseNoNet|Any CPU.Deploy.0 = Release|Any CPU
{C9F4AE81-0996-4E17-B3F2-D0F652F6AC50}.ReleaseNoNet|Mixed Platforms.ActiveCfg = Release|Any CPU
{C9F4AE81-0996-4E17-B3F2-D0F652F6AC50}.ReleaseNoNet|Mixed Platforms.Build.0 = Release|Any CPU
{C9F4AE81-0996-4E17-B3F2-D0F652F6AC50}.ReleaseNoNet|Mixed Platforms.Deploy.0 = Release|Any CPU
{C9F4AE81-0996-4E17-B3F2-D0F652F6AC50}.ReleaseNoNet|Win32.ActiveCfg = Release|Any CPU
{C9F4AE81-0996-4E17-B3F2-D0F652F6AC50}.ReleaseNoNet|x64.ActiveCfg = Release|Any CPU
{3DA3911E-36DE-465E-8F15-F1991B6437E5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3DA3911E-36DE-465E-8F15-F1991B6437E5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3DA3911E-36DE-465E-8F15-F1991B6437E5}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU

View File

@ -828,7 +828,13 @@ namespace keepass2android
private void PopulateGroupText(int viewId, int containerViewId, String key)
{
PopulateText(viewId, containerViewId, Entry.ParentGroup.GetFullPath());
string groupName = null;
if (PreferenceManager.GetDefaultSharedPreferences(this).GetBoolean(
"ShowGroupInEntry", false))
{
groupName = Entry.ParentGroup.GetFullPath();
}
PopulateText(viewId, containerViewId, groupName);
_stringViews.Add (key, new StandardStringView (viewId, containerViewId, this));
}

View File

@ -74,6 +74,7 @@ namespace keepass2android
{
//make sure the app task is passed to the calling activity
AppTask.SetActivityResult(this, KeePass.ExitNormal);
}
if (resultCode == Result.Ok)
@ -134,7 +135,7 @@ namespace keepass2android
protected override void OnResume() {
base.OnResume();
AppTask.StartInGroupActivity(this);
AppTask.SetupGroupBaseActivityButtons(this);
RefreshIfDirty();
@ -192,12 +193,6 @@ namespace keepass2android
}
protected override void OnStart()
{
base.OnStart();
AppTask.StartInGroupActivity(this);
}
private void InsertElement()
{
MoveElementTask moveElementTask = (MoveElementTask)AppTask;

File diff suppressed because it is too large Load Diff

View File

@ -26,9 +26,11 @@
<string name="show_kill_app_summary">Show a button in password screen to kill the application process (for paranoid users)</string>
<string name="application">Application</string>
<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="ShowGroupnameInSearchResult_title">Display group name in search result</string>
<string name="ShowGroupnameInSearchResult_resume">Display group name below entry titles in search results. Useful if several entries have the same name.</string>
<string name="NavigationToGroupCompleted_message">Display group is now: %1$s</string>
<string name="ShowGroupInEntry_title">Show group name in entry view</string>
<string name="security_prefs">Security</string>
<string name="display_prefs">Display</string>

View File

@ -147,7 +147,10 @@
android:title="@string/ShowGroupnameInSearchResult_title"
android:summary="@string/ShowGroupnameInSearchResult_resume"
android:defaultValue="@bool/ShowGroupnameInSearchResult_default"/>
<CheckBoxPreference
android:key="ShowGroupInEntry"
android:title="@string/ShowGroupInEntry_title"
android:defaultValue="false"/>
<ListPreference
android:key="@string/list_size_key"
android:title="@string/list_size_title"

View File

@ -1,4 +1,5 @@
using System;
using System.Globalization;
using Android.App;
using Android.Content;
using Android.OS;
@ -277,7 +278,6 @@ namespace keepass2android
public virtual void StartInGroupActivity(GroupBaseActivity groupBaseActivity)
{
return;
}
public virtual void SetupGroupBaseActivityButtons(GroupBaseActivity groupBaseActivity)
@ -675,7 +675,7 @@ namespace keepass2android
public override void AfterAddNewEntry(EntryEditActivity entryEditActivity, PwEntry newEntry)
{
EntryActivity.Launch(entryEditActivity, newEntry, -1,
new SelectEntryTask() { ShowUserNotifications = this.ShowUserNotifications},
new SelectEntryTask { ShowUserNotifications = this.ShowUserNotifications},
ActivityFlags.ForwardResult);
//no need to call Finish here, that's done in EntryEditActivity ("closeOrShowError")
}
@ -695,65 +695,65 @@ namespace keepass2android
{
// All group Uuid are stored in guuidKey + indice
// The last one is the destination group
public const String numberOfGroupsKey = "NumberOfGroups";
public const String gUuidKey = "gUuidKey";
public const String fullGroupNameKey = "fullGroupNameKey";
public const String toastEnableKey = "toastEnableKey";
public const String NumberOfGroupsKey = "NumberOfGroups";
public const String GUuidKey = "gUuidKey";
public const String FullGroupNameKey = "fullGroupNameKey";
public const String ToastEnableKey = "toastEnableKey";
#if INCLUDE_DEBUG_MOVE_GROUPNAME
public const String gNameKey = "gNameKey";
private LinkedList<string> groupNameList;
#endif
private LinkedList<string> groupUuid;
protected AppTask taskToBeLaunchAfterNavigation;
private LinkedList<string> _groupUuid;
protected AppTask TaskToBeLaunchedAfterNavigation;
protected String fullGroupName {
protected String FullGroupName {
get ;
set ;
}
protected bool toastEnable {
protected bool ToastEnable {
get;
set;
}
public NavigateAndLaunchTask() {
this.taskToBeLaunchAfterNavigation = new NullTask();
fullGroupName = "";
toastEnable = false;
protected NavigateAndLaunchTask() {
TaskToBeLaunchedAfterNavigation = new NullTask();
FullGroupName = "";
ToastEnable = false;
}
/// <summary>
/// Initializes a new instance of the <see cref="keepass2android.NavigateAndLaunchTask"/> class.
/// </summary>
/// <param name="groups">Groups.</param>
/// <param name="taskToBeLaunchAfterNavigation">Task to be launched after navigation.</param>
/// <param name="taskToBeLaunchedAfterNavigation">Task to be launched after navigation.</param>
/// <param name="toastEnable">If set to <c>true</c>, toast will be displayed after navigation.</param>
protected NavigateAndLaunchTask(PwGroup groups, AppTask taskToBeLaunchAfterNavigation, bool toastEnable = false) {
this.taskToBeLaunchAfterNavigation = taskToBeLaunchAfterNavigation;
populateGroups (groups);
this.toastEnable = toastEnable;
protected NavigateAndLaunchTask(PwGroup groups, AppTask taskToBeLaunchedAfterNavigation, bool toastEnable = false) {
TaskToBeLaunchedAfterNavigation = taskToBeLaunchedAfterNavigation;
PopulateGroups (groups);
ToastEnable = toastEnable;
}
public void populateGroups(PwGroup groups) {
public void PopulateGroups(PwGroup groups) {
groupUuid = new LinkedList<String>{};
_groupUuid = new LinkedList<String>();
#if INCLUDE_DEBUG_MOVE_GROUPNAME
groupNameList = new LinkedList<String>{};
#endif
fullGroupName = "";
FullGroupName = "";
PwGroup readGroup = groups;
while (readGroup != null) {
if ( (readGroup.ParentGroup != null) ||
(readGroup.ParentGroup == null) && (readGroup == groups) ) {
fullGroupName = readGroup.Name + "." + fullGroupName;
FullGroupName = readGroup.Name + "." + FullGroupName;
}
groupUuid.AddFirst (MemUtil.ByteArrayToHexString (readGroup.Uuid.UuidBytes));
_groupUuid.AddFirst (MemUtil.ByteArrayToHexString (readGroup.Uuid.UuidBytes));
#if INCLUDE_DEBUG_MOVE_GROUPNAME
groupNameList.AddFirst (readGroup.Name);
@ -772,9 +772,9 @@ namespace keepass2android
/// <param name="b">The bundle component.</param>
public override void Setup(Bundle b)
{
int numberOfGroups = b.GetInt(numberOfGroupsKey);
int numberOfGroups = b.GetInt(NumberOfGroupsKey);
groupUuid = new LinkedList<String>{};
_groupUuid = new LinkedList<String>();
#if INCLUDE_DEBUG_MOVE_GROUPNAME
groupNameList = new LinkedList<String>{};
#endif
@ -783,7 +783,7 @@ namespace keepass2android
while (i < numberOfGroups) {
groupUuid.AddLast ( b.GetString (gUuidKey + i) ) ;
_groupUuid.AddLast ( b.GetString (GUuidKey + i) ) ;
#if INCLUDE_DEBUG_MOVE_GROUPNAME
groupNameList.AddLast ( b.GetString (gNameKey + i);
@ -791,8 +791,8 @@ namespace keepass2android
i++;
}
fullGroupName = b.GetString (fullGroupNameKey);
toastEnable = b.GetBoolean (toastEnableKey);
FullGroupName = b.GetString (FullGroupNameKey);
ToastEnable = b.GetBoolean (ToastEnableKey);
}
@ -801,7 +801,7 @@ namespace keepass2android
get
{
// Return Navigate group Extras
IEnumerator<String> eGroupKeys = groupUuid.GetEnumerator ();
IEnumerator<String> eGroupKeys = _groupUuid.GetEnumerator ();
#if INCLUDE_DEBUG_MOVE_GROUPNAME
IEnumerator<String> eGroupName = groupNameList.GetEnumerator ();
@ -809,7 +809,7 @@ namespace keepass2android
int i = 0;
while (eGroupKeys.MoveNext()) {
yield return new StringExtra { Key = gUuidKey + i.ToString (), Value = eGroupKeys.Current };
yield return new StringExtra { Key = GUuidKey + i.ToString (CultureInfo.InvariantCulture), Value = eGroupKeys.Current };
#if INCLUDE_DEBUG_MOVE_GROUPNAME
eGroupName.MoveNext();
@ -819,14 +819,14 @@ namespace keepass2android
i++;
}
yield return new IntExtra{ Key = numberOfGroupsKey, Value = i };
yield return new StringExtra{ Key = fullGroupNameKey, Value = fullGroupName };
yield return new BoolExtra{ Key = toastEnableKey, Value = toastEnable };
yield return new IntExtra{ Key = NumberOfGroupsKey, Value = i };
yield return new StringExtra{ Key = FullGroupNameKey, Value = FullGroupName };
yield return new BoolExtra{ Key = ToastEnableKey, Value = ToastEnable };
// Return afterTaskExtras
IEnumerator<IExtra> afterTaskExtras = taskToBeLaunchAfterNavigation.Extras.GetEnumerator();
while (afterTaskExtras.MoveNext ()) {
yield return afterTaskExtras.Current;
foreach (var extra in TaskToBeLaunchedAfterNavigation.Extras)
{
yield return extra;
}
}
@ -838,24 +838,30 @@ namespace keepass2android
if (GroupIsFound(groupBaseActivity) ){ // Group has been found: display toaster and stop here
if (toastEnable) {
String toastMessage = groupBaseActivity.GetString (Resource.String.NavigationToGroupCompleted_message);
toastMessage = toastMessage.Replace ("%0", this.fullGroupName);
if (ToastEnable) {
String toastMessage = groupBaseActivity.GetString (Resource.String.NavigationToGroupCompleted_message, new Java.Lang.Object[] { FullGroupName});
Toast.MakeText (groupBaseActivity, toastMessage, ToastLength.Long).Show ();
}
groupBaseActivity.StartTask (taskToBeLaunchAfterNavigation);
groupBaseActivity.StartTask (TaskToBeLaunchedAfterNavigation);
return;
} else if (groupUuid.Contains(groupBaseActivity.UuidGroup)) { // Need to go up in groups tree
} else if (_groupUuid.Contains(groupBaseActivity.UuidGroup)) { // Need to go up in groups tree
// Get next Group Uuid
String nextGroupUuid = groupUuid.Find (groupBaseActivity.UuidGroup).Next.Value;
PwUuid nextGroupPwUuid = new PwUuid (MemUtil.HexStringToByteArray (nextGroupUuid));
var linkedListNode = _groupUuid.Find(groupBaseActivity.UuidGroup);
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 nextGroupUuid = linkedListNode.Next.Value;
PwUuid nextGroupPwUuid = new PwUuid (MemUtil.HexStringToByteArray (nextGroupUuid));
// Create Group Activity
PwGroup nextGroup = App.Kp2a.GetDb ().Groups [nextGroupPwUuid];
GroupActivity.Launch (groupBaseActivity, nextGroup, this);
// Create Group Activity
PwGroup nextGroup = App.Kp2a.GetDb ().Groups [nextGroupPwUuid];
GroupActivity.Launch (groupBaseActivity, nextGroup, this);
}
return;
} else { // Need to go down in groups tree
@ -867,23 +873,24 @@ namespace keepass2android
}
public override void SetupGroupBaseActivityButtons(GroupBaseActivity groupBaseActivity)
{
return;
}
public bool GroupIsFound(GroupBaseActivity groupBaseActivity)
{
return groupUuid.Last.Value.Equals (groupBaseActivity.UuidGroup);
return _groupUuid.Last.Value.Equals (groupBaseActivity.UuidGroup);
}
}
public class NavigateToFolder: NavigateAndLaunchTask {
public NavigateToFolder():base() {
public NavigateToFolder()
{
}
public NavigateToFolder(PwGroup groups, bool toastEnable = false)
: base(groups, new NullTask(), toastEnable) {
return;
: base(groups, new NullTask(), toastEnable)
{
}
}
@ -895,15 +902,15 @@ namespace keepass2android
}
public NavigateToFolderAndLaunchMoveElementTask(PwGroup groups, PwUuid Uuid, bool toastEnable = false)
:base(groups, new MoveElementTask() { Uuid = Uuid }, toastEnable) {
public NavigateToFolderAndLaunchMoveElementTask(PwGroup groups, PwUuid uuid, bool toastEnable = false)
:base(groups, new MoveElementTask() { Uuid = uuid }, toastEnable) {
}
public override void Setup(Bundle b) {
base.Setup(b);
taskToBeLaunchAfterNavigation = new MoveElementTask ();
taskToBeLaunchAfterNavigation.Setup (b);
TaskToBeLaunchedAfterNavigation = new MoveElementTask ();
TaskToBeLaunchedAfterNavigation.Setup (b);
}