added option to copy an entry

This commit is contained in:
Philipp Crocoll 2015-12-27 09:39:30 +01:00
parent ec4fe32b29
commit 017675e16e
5 changed files with 34 additions and 3 deletions

View File

@ -55,6 +55,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="database\CheckDatabaseForChanges.cs" />
<Compile Include="database\edit\CopyEntry.cs" />
<Compile Include="database\edit\DeleteMultipleItems.cs" />
<Compile Include="database\edit\EditGroup.cs" />
<Compile Include="database\edit\MoveElements.cs" />

View File

@ -62,6 +62,7 @@ namespace keepass2android
DeletingItems,
AskDeletePermanentlyItems,
AskDeletePermanentlyItemsNoRecycle,
InOfflineMode
InOfflineMode,
DuplicateTitle
}
}

View File

@ -813,12 +813,12 @@ namespace keepass2android
{
return false;
}
Handler handler = new Handler();
switch (item.ItemId)
{
case Resource.Id.menu_delete:
Handler handler = new Handler();
DeleteMultipleItems task = new DeleteMultipleItems((GroupBaseActivity)Activity, App.Kp2a.GetDb(), checkedItems,
new GroupBaseActivity.RefreshTask(handler, ((GroupBaseActivity)Activity)), App.Kp2a);
task.Start();
@ -827,6 +827,15 @@ namespace keepass2android
var navMove = new NavigateToFolderAndLaunchMoveElementTask(checkedItems.First().ParentGroup, checkedItems.Select(i => i.Uuid).ToList(), ((GroupBaseActivity)Activity).IsSearchResult);
((GroupBaseActivity)Activity).StartTask(navMove);
break;
case Resource.Id.menu_copy:
var copyTask = new CopyEntry((GroupBaseActivity)Activity, App.Kp2a, (PwEntry) checkedItems.First(),
new GroupBaseActivity.RefreshTask(handler, ((GroupBaseActivity)Activity)));
ProgressTask pt = new ProgressTask(App.Kp2a, Activity, copyTask);
pt.Run();
break;
case Resource.Id.menu_navigate:
NavigateToFolder navNavigate = new NavigateToFolder(checkedItems.First().ParentGroup, true);
((GroupBaseActivity)Activity).StartTask(navNavigate);
@ -897,6 +906,12 @@ namespace keepass2android
{
menuItem.SetVisible(((GroupBaseActivity)Activity).IsSearchResult && IsOnlyOneItemChecked());
}
menuItem = mode.Menu.FindItem(Resource.Id.menu_copy);
if (menuItem != null)
{
menuItem.SetVisible(IsOnlyOneEntryChecked());
}
}
private bool IsOnlyOneGroupChecked()
@ -949,6 +964,11 @@ namespace keepass2android
}
return hadCheckedItem;
}
private bool IsOnlyOneEntryChecked()
{
return IsOnlyOneItemChecked() && !IsOnlyOneGroupChecked();
}
}
}

View File

@ -10,6 +10,12 @@
android:title="@string/menu_delete"
android:showAsAction="always"
/>
<item android:id="@+id/menu_copy"
android:icon="@drawable/ic_menu_copy_holo_light"
android:title="@string/menu_copy"
android:showAsAction="always"
/>
<item android:id="@+id/menu_move"
android:icon="@drawable/ic_menu_cut"
android:title="@string/menu_move"

View File

@ -156,6 +156,7 @@
<string name="menu_app_settings">Settings</string>
<string name="menu_db_settings">Database settings</string>
<string name="menu_delete">Delete</string>
<string name="menu_copy">Create duplicate</string>
<string name="menu_move">Move to another group</string>
<string name="menu_move_light">Move</string>
<string name="menu_navigate">Navigate to parent group</string>
@ -553,6 +554,8 @@
<string name="CopyingFile">Copying file...</string>
<string name="ChangeLog_title">Change log</string>
<string name="DuplicateTitle">Copy</string>
<string name="PreviewWarning">Please note! This is a preview release and might come with some flaws! If you experience *anything* unexpected, please let me know (on Codeplex or by email).</string>