Implemented moving of groups

This commit is contained in:
Philipp Crocoll 2013-08-30 22:58:29 +02:00
parent e1de3e2cbf
commit e8ad5f0845
6 changed files with 53 additions and 28 deletions

View File

@ -42,6 +42,7 @@ namespace keepass2android
SynchronizedDatabaseSuccessfully,
RestoringRemoteFile,
CheckingDatabaseForChanges,
RemoteDatabaseUnchanged
RemoteDatabaseUnchanged,
CannotMoveGroupHere
}
}

View File

@ -42,6 +42,11 @@ namespace keepass2android.database.edit
else
{
PwGroup group = (PwGroup)_elementToMove;
if ((_targetGroup == group) || (_targetGroup.IsContainedIn(group)))
{
Finish(false, _app.GetResourceString(UiStringKey.CannotMoveGroupHere));
return;
}
pgParent.Groups.Remove(group);
_targetGroup.AddGroup(group, true, true);
}

View File

@ -156,7 +156,7 @@ namespace keepass2android
IStructureItem elementToMove = App.Kp2a.GetDb().KpDatabase.RootGroup.FindObject(moveElementTask.Uuid, true, null);
var moveElement = new MoveElement(elementToMove, Group, this, App.Kp2a, new ActionOnFinish((success, message) => { StopMovingElement(); }));
var moveElement = new MoveElement(elementToMove, Group, this, App.Kp2a, new ActionOnFinish((success, message) => { StopMovingElement(); if (!String.IsNullOrEmpty(message)) Toast.MakeText(this, message, ToastLength.Long).Show();}));
var progressTask = new ProgressTask(App.Kp2a, this, moveElement);
progressTask.Run();

View File

@ -1323,35 +1323,38 @@ namespace keepass2android
// aapt resource value: 0x7f0800ff
public const int BinaryDirectory_title = 2131230975;
// aapt resource value: 0x7f080152
public const int CannotMoveGroupHere = 2131231058;
// aapt resource value: 0x7f08015c
public const int ChangeLog = 2131231068;
// aapt resource value: 0x7f08015b
public const int ChangeLog = 2131231067;
// aapt resource value: 0x7f08015a
public const int ChangeLog_0_7 = 2131231066;
// aapt resource value: 0x7f080158
public const int ChangeLog_0_8 = 2131231064;
// aapt resource value: 0x7f080157
public const int ChangeLog_0_8_1 = 2131231063;
// aapt resource value: 0x7f080156
public const int ChangeLog_0_8_2 = 2131231062;
// aapt resource value: 0x7f080155
public const int ChangeLog_0_8_3 = 2131231061;
// aapt resource value: 0x7f080154
public const int ChangeLog_0_8_4 = 2131231060;
// aapt resource value: 0x7f080153
public const int ChangeLog_0_8_5 = 2131231059;
public const int ChangeLog_0_7 = 2131231067;
// aapt resource value: 0x7f080159
public const int ChangeLog_keptDonate = 2131231065;
public const int ChangeLog_0_8 = 2131231065;
// aapt resource value: 0x7f080152
public const int ChangeLog_title = 2131231058;
// aapt resource value: 0x7f080158
public const int ChangeLog_0_8_1 = 2131231064;
// aapt resource value: 0x7f080157
public const int ChangeLog_0_8_2 = 2131231063;
// aapt resource value: 0x7f080156
public const int ChangeLog_0_8_3 = 2131231062;
// aapt resource value: 0x7f080155
public const int ChangeLog_0_8_4 = 2131231061;
// aapt resource value: 0x7f080154
public const int ChangeLog_0_8_5 = 2131231060;
// aapt resource value: 0x7f08015a
public const int ChangeLog_keptDonate = 2131231066;
// aapt resource value: 0x7f080153
public const int ChangeLog_title = 2131231059;
// aapt resource value: 0x7f08002a
public const int CheckForFileChangesOnSave_key = 2131230762;

View File

@ -296,6 +296,8 @@
<string name="synchronize_database_menu">Synchronize database…</string>
<string name="CannotMoveGroupHere">Cannot move group to this group.</string>
<string name="ChangeLog_title">Change log</string>
<string name="ChangeLog_0_8_5">
<b>Version 0.8.5</b>\n

View File

@ -16,6 +16,7 @@ This file is part of Keepass2Android, Copyright 2013 Philipp Crocoll. This file
*/
using System;
using Android.Graphics;
using Android.OS;
using Android.Runtime;
using Android.Views;
@ -33,6 +34,7 @@ namespace keepass2android.view
private const int MenuOpen = Menu.First;
private const int MenuDelete = MenuOpen + 1;
private const int MenuMove = MenuDelete + 1;
public static PwGroupView GetInstance(GroupBaseActivity act, PwGroup pw) {
@ -57,7 +59,7 @@ namespace keepass2android.view
TextView label = (TextView) gv.FindViewById(Resource.Id.group_label);
label.TextSize = size-8;
PopulateView(gv, pw);
LayoutParams lp = new LayoutParams(ViewGroup.LayoutParams.FillParent, ViewGroup.LayoutParams.WrapContent);
@ -72,6 +74,14 @@ namespace keepass2android.view
App.Kp2a.GetDb().DrawableFactory.AssignDrawableTo(iv, Resources, App.Kp2a.GetDb().KpDatabase, pw.IconId, pw.CustomIconUuid);
_textview.Text = pw.Name;
//todo: get colors from resources
if (_groupBaseActivity.IsBeingMoved(_pwGroup.Uuid))
_textview.SetTextColor(new Color(180, 180, 180));
else
_textview.SetTextColor(new Color(0, 0, 0));
}
public void ConvertView(PwGroup pw) {
@ -91,6 +101,7 @@ namespace keepass2android.view
public override void OnCreateMenu(IContextMenu menu, IContextMenuContextMenuInfo menuInfo) {
menu.Add(0, MenuOpen, 0, Resource.String.menu_open);
menu.Add(0, MenuDelete, 0, Resource.String.menu_delete);
menu.Add(0, MenuMove, 0, Resource.String.menu_move);
}
public override bool OnContextItemSelected(IMenuItem item)
@ -106,6 +117,9 @@ namespace keepass2android.view
DeleteGroup task = new DeleteGroup(Context, App.Kp2a, _pwGroup, new GroupBaseActivity.AfterDeleteGroup(handler, _groupBaseActivity));
task.Start();
return true;
case MenuMove:
_groupBaseActivity.StartTask(new MoveElementTask { Uuid = _pwGroup.Uuid });
return true;
default:
return false;
}