* fixed bug in SearchResults.cs: _db was always null

* refactoring of GroupView: removed GroupAddEntryView.cs, renamed GroupViewOnlyView.cs to GroupView with added method to set button visibility
* introduced AppTask for moving an element (but not yet implemented/used)
This commit is contained in:
Philipp Crocoll
2013-08-16 14:26:06 +02:00
parent 4cbc4542c2
commit 55e81ab25b
11 changed files with 518 additions and 500 deletions

View File

@@ -110,16 +110,12 @@ namespace keepass2android
} }
SetupButtons (); SetupButtons ();
GroupView groupView = new GroupView(this);
SetContentView (groupView);
groupView.SetNormalButtonVisibility(AddGroupEnabled, AddEntryEnabled);
if (AddGroupEnabled && AddEntryEnabled) {
SetContentView (new GroupAddEntryView (this));
} else if (AddGroupEnabled) {
SetContentView (new GroupRootView (this));
} else if (AddEntryEnabled) {
throw new Exception ("This mode is not supported.");
} else {
SetContentView (new GroupViewOnlyView (this));
}
if (AddGroupEnabled) { if (AddGroupEnabled) {
// Add Group button // Add Group button
View addGroup = FindViewById (Resource.Id.add_group); View addGroup = FindViewById (Resource.Id.add_group);

View File

@@ -75,7 +75,8 @@ namespace keepass2android
protected PwGroup Group; protected PwGroup Group;
internal AppTask AppTask; internal AppTask AppTask;
private GroupView _groupView;
protected override void OnResume() { protected override void OnResume() {
base.OnResume(); base.OnResume();
@@ -119,8 +120,10 @@ namespace keepass2android
} }
_prefs = PreferenceManager.GetDefaultSharedPreferences(this); _prefs = PreferenceManager.GetDefaultSharedPreferences(this);
SetContentView(new GroupViewOnlyView(this)); _groupView = new GroupView(this);
SetContentView(_groupView);
_groupView.SetNormalButtonVisibility(false, false);
SetResult(KeePass.ExitNormal); SetResult(KeePass.ExitNormal);
StyleScrollBars(); StyleScrollBars();

File diff suppressed because it is too large Load Diff

View File

@@ -32,6 +32,27 @@
android:text="@string/add_entry" android:text="@string/add_entry"
android:drawableLeft="@drawable/device_access_new_account" android:drawableLeft="@drawable/device_access_new_account"
/> />
<Button
android:id="@+id/insert_element"
android:layout_width="0px"
android:layout_weight="1"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:text="@string/insert_element_here"
android:visibility="gone"
android:drawableLeft="@drawable/btn_new_group"
/>
<Button
android:id="@+id/cancel_insert_element"
android:layout_width="0px"
android:layout_weight="1"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/insert_element"
android:layout_alignParentBottom="true"
android:text="@string/cancel"
android:visibility="gone"
android:drawableLeft="@android:drawable/ic_menu_close_clear_cancel"
/>
</LinearLayout> </LinearLayout>
<ImageView <ImageView
android:id="@+id/divider2" android:id="@+id/divider2"

View File

@@ -168,6 +168,7 @@
<string name="search_in">Search in</string> <string name="search_in">Search in</string>
<string name="select_other_entry">Select another entry</string> <string name="select_other_entry">Select another entry</string>
<string name="select_group_then_add">Open the desired group, then press "%1$s"!</string> <string name="select_group_then_add">Open the desired group, then press "%1$s"!</string>
<string name="insert_element_here">Insert here</string>
<string name="twofish">Twofish</string> <string name="twofish">Twofish</string>
<string name="underline">Underline</string> <string name="underline">Underline</string>
<string name="unsupported_db_version">Unsupported database version.</string> <string name="unsupported_db_version">Unsupported database version.</string>
@@ -296,14 +297,13 @@
<string name="ChangeLog_title">Change log</string> <string name="ChangeLog_title">Change log</string>
<string name="ChangeLog_0_8_5"> <string name="ChangeLog_0_8_5">
<b>Version 0.8.5 preview</b>\n <b>Version 0.8.5</b>\n
* Remote files are stored in the local application cache to allow offline usage (including editing and later synchronization). See settings. \n * Remote files are stored in the local application cache to allow offline usage (including editing and later synchronization). See settings. \n
* Notification icon to visualize the lock-state of the database (see settings)\n * Notification icon to visualize the lock-state of the database (see settings)\n
* Improved determination of lock-state in some situations\n * Improved determination of lock-state in some situations\n
* Database files are loaded to memory while you are typing your password for increased loading speed (see settings)\n * Database files are loaded to memory while you are typing your password for increased loading speed (see settings)\n
* Entries can be added to root group\n * Entries can be added to root group\n
* Bug fixes (resolving reference fields, problems with keyboard on Italian an Chinese devices)\n * Bug fixes (resolving reference fields, problems with keyboard on Italian an Chinese devices)
Please Note: this is a preview intended for testing! Please report any problems on keepass2android.codeplex.com.
</string> </string>
<string name="ChangeLog_0_8_4"> <string name="ChangeLog_0_8_4">
<b>Version 0.8.4</b>\n <b>Version 0.8.4</b>\n

View File

@@ -143,12 +143,10 @@ namespace keepass2android
//show results: //show results:
if (Group == null || (!Group.Entries.Any())) if (Group == null || (!Group.Entries.Any()))
{ {
//SetContentView(new GroupEmptyView(this));
SetContentView(Resource.Layout.searchurlresults_empty); SetContentView(Resource.Layout.searchurlresults_empty);
} else } else
{ {
SetContentView(Resource.Layout.searchurlresults); SetContentView(Resource.Layout.searchurlresults);
//SetContentView(new GroupViewOnlyView(this));
} }
SetGroupTitle(); SetGroupTitle();

View File

@@ -20,6 +20,7 @@ using Android.OS;
using System.Collections.Generic; using System.Collections.Generic;
using KeePassLib; using KeePassLib;
using KeePassLib.Security; using KeePassLib.Security;
using KeePassLib.Utility;
namespace keepass2android namespace keepass2android
{ {
@@ -253,6 +254,32 @@ namespace keepass2android
} }
} }
/// <summary>
/// User is about to move an entry or group to another group
/// </summary>
public class MoveElementTask: AppTask
{
public const String UuidKey = "MoveElement_Uuid";
public PwUuid Uuid
{
get;
set;
}
public override void Setup(Bundle b)
{
Uuid = new PwUuid(MemUtil.HexStringToByteArray(b.GetString(UuidKey)));
}
public override IEnumerable<IExtra> Extras
{
get
{
yield return new StringExtra { Key = UuidKey, Value = MemUtil.ByteArrayToHexString(Uuid.UuidBytes) };
}
}
}
/// <summary> /// <summary>
/// User is about to create a new entry. The task might already "know" some information about the contents. /// User is about to create a new entry. The task might already "know" some information about the contents.

View File

@@ -99,8 +99,7 @@
<Compile Include="LockCloseListActivity.cs" /> <Compile Include="LockCloseListActivity.cs" />
<Compile Include="LockingListActivity.cs" /> <Compile Include="LockingListActivity.cs" />
<Compile Include="views\ClickView.cs" /> <Compile Include="views\ClickView.cs" />
<Compile Include="views\GroupViewOnlyView.cs" /> <Compile Include="views\GroupView.cs" />
<Compile Include="views\GroupAddEntryView.cs" />
<Compile Include="views\GroupRootView.cs" /> <Compile Include="views\GroupRootView.cs" />
<Compile Include="PwGroupListAdapter.cs" /> <Compile Include="PwGroupListAdapter.cs" />
<Compile Include="views\PwGroupView.cs" /> <Compile Include="views\PwGroupView.cs" />

View File

@@ -34,7 +34,7 @@ namespace keepass2android.search
[IntentFilter(new[]{Intent.ActionSearch}, Categories=new[]{Intent.CategoryDefault})] [IntentFilter(new[]{Intent.ActionSearch}, Categories=new[]{Intent.CategoryDefault})]
public class SearchResults : GroupBaseActivity public class SearchResults : GroupBaseActivity
{ {
private Database _db; private GroupView _groupView;
protected override void OnCreate (Bundle bundle) protected override void OnCreate (Bundle bundle)
{ {
@@ -80,8 +80,9 @@ namespace keepass2android.search
private void Query (SearchParameters searchParams) private void Query (SearchParameters searchParams)
{ {
try { try {
Group = _db.Search (searchParams, null); Group = App.Kp2a.GetDb().Search (searchParams, null);
} catch (Exception e) { } catch (Exception e) {
Kp2aLog.Log(e.ToString());
Toast.MakeText(this,e.Message, ToastLength.Long).Show(); Toast.MakeText(this,e.Message, ToastLength.Long).Show();
Finish(); Finish();
return; return;
@@ -91,10 +92,14 @@ namespace keepass2android.search
if ( Group == null || (!Group.Entries.Any()) ) { if ( Group == null || (!Group.Entries.Any()) ) {
SetContentView(new GroupEmptyView(this)); SetContentView(new GroupEmptyView(this));
} else { } else
SetContentView(new GroupViewOnlyView(this)); {
_groupView = new GroupView(this);
SetContentView(_groupView);
_groupView.SetNormalButtonVisibility(false, false);
} }
SetGroupTitle(); SetGroupTitle();
ListAdapter = new PwGroupListAdapter(this, Group); ListAdapter = new PwGroupListAdapter(this, Group);

View File

@@ -1,55 +0,0 @@
/*
This file is part of Keepass2Android, Copyright 2013 Philipp Crocoll. This file is based on Keepassdroid, Copyright Brian Pellin.
Keepass2Android is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
Keepass2Android is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Keepass2Android. If not, see <http://www.gnu.org/licenses/>.
*/
using System;
using Android.Content;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.Util;
namespace keepass2android.view
{
public class GroupAddEntryView : RelativeLayout
{
public GroupAddEntryView (IntPtr javaReference, JniHandleOwnership transfer)
: base(javaReference, transfer)
{
}
public GroupAddEntryView(Context context): base(context) {
Inflate(context);
}
public GroupAddEntryView(Context context, IAttributeSet attrs): base(context, attrs) {
Inflate(context);
}
private void Inflate(Context context) {
LayoutInflater inflater = (LayoutInflater) context.GetSystemService(Context.LayoutInflaterService);
inflater.Inflate(Resource.Layout.group_add_entry, this);
}
}
}

View File

@@ -24,48 +24,63 @@ using Android.Widget;
namespace keepass2android.view namespace keepass2android.view
{ {
public class GroupViewOnlyView : RelativeLayout public class GroupView : RelativeLayout
{ {
public GroupViewOnlyView (IntPtr javaReference, JniHandleOwnership transfer) public GroupView (IntPtr javaReference, JniHandleOwnership transfer)
: base(javaReference, transfer) : base(javaReference, transfer)
{ {
} }
public GroupViewOnlyView(Context context): base(context) { public GroupView(Context context): base(context) {
Inflate(context); Inflate(context);
} }
public GroupViewOnlyView(Context context, IAttributeSet attrs): base(context, attrs) { public GroupView(Context context, IAttributeSet attrs): base(context, attrs) {
Inflate(context); Inflate(context);
} }
private void Inflate(Context context) { private void Inflate(Context context) {
LayoutInflater inflater = (LayoutInflater) context.GetSystemService(Context.LayoutInflaterService); LayoutInflater inflater = (LayoutInflater) context.GetSystemService(Context.LayoutInflaterService);
inflater.Inflate(Resource.Layout.group_add_entry, this); inflater.Inflate(Resource.Layout.group_add_entry, this);
// Hide the buttons
}
public void SetNormalButtonVisibility(bool showAddGroup, bool showAddEntry)
{
if (!showAddGroup)
{
View addGroup = FindViewById(Resource.Id.add_group); View addGroup = FindViewById(Resource.Id.add_group);
addGroup.Visibility = ViewStates.Invisible; addGroup.Visibility = ViewStates.Invisible;
}
if (!showAddEntry)
{
View addEntry = FindViewById(Resource.Id.add_entry); View addEntry = FindViewById(Resource.Id.add_entry);
addEntry.Visibility = ViewStates.Invisible; addEntry.Visibility = ViewStates.Invisible;
}
if (!showAddEntry && !showAddGroup)
{
View divider2 = FindViewById(Resource.Id.divider2); View divider2 = FindViewById(Resource.Id.divider2);
divider2.Visibility = ViewStates.Invisible; divider2.Visibility = ViewStates.Invisible;
FindViewById(Resource.Id.bottom_bar).Visibility = ViewStates.Invisible; FindViewById(Resource.Id.bottom_bar).Visibility = ViewStates.Invisible;
View list = FindViewById(Android.Resource.Id.List); View list = FindViewById(Android.Resource.Id.List);
LayoutParams lp = (RelativeLayout.LayoutParams) list.LayoutParameters; LayoutParams lp = (RelativeLayout.LayoutParams) list.LayoutParameters;
lp.AddRule(LayoutRules.AlignParentBottom, (int)LayoutRules.True); lp.AddRule(LayoutRules.AlignParentBottom, (int) LayoutRules.True);
} }
}
public void ShowInsertButtons()
{
} }
}
} }