Add support for editing .kdbx from EntryEditActivity

This commit is contained in:
Brian Pellin committed 2013-01-27 21:02:09 -06:00
1 parent 3f5b607204
commit 80fd868cf6
11 files changed
+419 -138

No files matched your search

+3 -1
View File
@@ -76,7 +76,9 @@
android:theme="@style/NoTitleBar"></activity>
<activity android:name="com.keepassdroid.LockingActivity"
android:theme="@style/NoTitleBar"></activity>
<activity android:name="com.keepassdroid.EntryEditActivity" android:configChanges="orientation|keyboardHidden"
<activity android:name="com.keepassdroid.EntryEditActivityV3" android:configChanges="orientation|keyboardHidden"
android:theme="@style/NoTitleBar"></activity>
<activity android:name="com.keepassdroid.EntryEditActivityV4" android:configChanges="orientation|keyboardHidden"
android:theme="@style/NoTitleBar"></activity>
<activity android:name="com.keepassdroid.GroupEditActivity" android:theme="@style/Dialog"></activity>
<activity android:name="com.keepassdroid.IconPickerActivity" android:theme="@style/NoTitleBar"></activity>
+13 -1
View File
@@ -44,10 +44,22 @@
android:src="@drawable/ic99_blank"
style="@style/WhiteOnBlack"/>
</LinearLayout>
<Button android:id="@+id/entry_edit"
android:text="@string/menu_edit"
android:layout_width="100sp"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentBottom="true"/>
<ImageView android:id="@+id/entry_divider2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_above="@id/entry_edit"
android:scaleType="fitXY"
android:src="@android:drawable/divider_horizontal_dark"/>
<ScrollView android:id="@+id/entry_scroll"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentBottom="true"
android:layout_above="@id/entry_divider2"
android:layout_below="@id/title_block"
android:fillViewport="true"
android:scrollbarStyle="insideOverlay"
+4 -4
View File
@@ -228,11 +228,11 @@ public class EntryActivity extends LockCloseActivity {
populateText(R.id.entry_password, mEntry.getPassword());
setPasswordStyle();
populateText(R.id.entry_created, getDateTime(mEntry.getCreate()));
populateText(R.id.entry_modified, getDateTime(mEntry.getMod()));
populateText(R.id.entry_accessed, getDateTime(mEntry.getAccess()));
populateText(R.id.entry_created, getDateTime(mEntry.getCreationTime()));
populateText(R.id.entry_modified, getDateTime(mEntry.getLastModificationTime()));
populateText(R.id.entry_accessed, getDateTime(mEntry.getLastAccessTime()));
Date expires = mEntry.getExpire();
Date expires = mEntry.getExpiryTime();
if ( mEntry.expires() ) {
populateText(R.id.entry_expires, getDateTime(expires));
} else {
@@ -37,10 +37,12 @@ public class EntryActivityV4 extends EntryActivity {
setContentView(R.layout.entry_view_v4);
}
/*
@Override
protected void setupEditButtons() {
// No edit buttons yet
}
*/
@Override
protected void fillData() {
+59 -67
View File
@@ -1,5 +1,5 @@
/*
* Copyright 2009-2012 Brian Pellin.
* Copyright 2009-2013 Brian Pellin.
*
* This file is part of KeePassDroid.
*
@@ -19,7 +19,6 @@
*/
package com.keepassdroid;
import java.io.UnsupportedEncodingException;
import java.util.Calendar;
import java.util.Date;
import java.util.UUID;
@@ -46,11 +45,14 @@ import android.widget.Toast;
import com.android.keepass.KeePass;
import com.android.keepass.R;
import com.keepassdroid.app.App;
import com.keepassdroid.database.PwDate;
import com.keepassdroid.database.PwDatabase;
import com.keepassdroid.database.PwEntry;
import com.keepassdroid.database.PwEntryV3;
import com.keepassdroid.database.PwEntryV4;
import com.keepassdroid.database.PwGroup;
import com.keepassdroid.database.PwGroupId;
import com.keepassdroid.database.PwGroupV3;
import com.keepassdroid.database.PwGroupV4;
import com.keepassdroid.database.edit.AddEntry;
import com.keepassdroid.database.edit.OnFinish;
import com.keepassdroid.database.edit.RunnableOnFinish;
@@ -59,43 +61,53 @@ import com.keepassdroid.icons.Icons;
import com.keepassdroid.utils.Types;
import com.keepassdroid.utils.Util;
public class EntryEditActivity extends LockCloseActivity {
public abstract class EntryEditActivity extends LockCloseActivity {
public static final String KEY_ENTRY = "entry";
public static final String KEY_PARENT = "parent";
public static final int RESULT_OK_ICON_PICKER = 1000;
public static final int RESULT_OK_PASSWORD_GENERATOR = RESULT_OK_ICON_PICKER + 1;
private PwEntryV3 mEntry;
protected PwEntry mEntry;
private boolean mShowPassword = false;
private boolean mIsNew;
private int mSelectedIconID = -1;
public static void Launch(Activity act, PwEntry pw) {
if ( !(pw instanceof PwEntryV3) ) {
Intent i;
if (pw instanceof PwEntryV3) {
i = new Intent(act, EntryEditActivityV3.class);
}
else if (pw instanceof PwEntryV4) {
i = new Intent(act, EntryEditActivityV4.class);
}
else {
throw new RuntimeException("Not yet implemented.");
}
Intent i = new Intent(act, EntryEditActivity.class);
i.putExtra(KEY_ENTRY, Types.UUIDtoBytes(pw.getUUID()));
act.startActivityForResult(i, 0);
}
public static void Launch(Activity act, PwGroup pw) {
if ( !(pw instanceof PwGroupV3) ) {
Intent i;
if (pw instanceof PwGroupV3) {
i = new Intent(act, EntryEditActivityV3.class);
EntryEditActivityV3.putParentId(i, KEY_PARENT, (PwGroupV3)pw);
}
else if (pw instanceof PwGroupV4) {
i = new Intent(act, EntryEditActivityV4.class);
EntryEditActivityV4.putParentId(i, KEY_PARENT, (PwGroupV4)pw);
}
else {
throw new RuntimeException("Not yet implemented.");
}
Intent i = new Intent(act, EntryEditActivity.class);
PwGroupV3 parent = (PwGroupV3) pw;
i.putExtra(KEY_PARENT, parent.groupId);
act.startActivityForResult(i, 0);
}
protected abstract PwGroupId getParentGroupId(Intent i, String key);
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -117,16 +129,17 @@ public class EntryEditActivity extends LockCloseActivity {
byte[] uuidBytes = i.getByteArrayExtra(KEY_ENTRY);
if ( uuidBytes == null ) {
int groupId = i.getIntExtra(KEY_PARENT, -1);
mEntry = new PwEntryV3(db, groupId);
PwGroupId parentId = getParentGroupId(i, KEY_ENTRY);
PwGroup parent = db.groups.get(parentId);
mEntry = PwEntry.getInstance(parent);
mIsNew = true;
} else {
UUID uuid = Types.bytestoUUID(uuidBytes);
assert(uuid != null);
mEntry = (PwEntryV3) db.entries.get(uuid);
mEntry = db.entries.get(uuid);
mIsNew = false;
fillData();
@@ -147,13 +160,10 @@ public class EntryEditActivity extends LockCloseActivity {
generatePassword.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
//EntryEditActivity.Launch(EntryActivity.this, mEntry);
GeneratePasswordActivity.Launch(EntryEditActivity.this);
}
});
// Save button
Button save = (Button) findViewById(R.id.entry_save);
save.setOnClickListener(new View.OnClickListener() {
@@ -176,51 +186,9 @@ public class EntryEditActivity extends LockCloseActivity {
return;
}
PwEntryV3 newEntry = new PwEntryV3();
newEntry.binaryDesc = mEntry.binaryDesc;
newEntry.groupId = mEntry.groupId;
PwEntry newEntry = populateNewEntry();
if (mSelectedIconID == -1) {
if (mIsNew) {
newEntry.icon = App.getDB().pm.iconFactory.getIcon(0);
} else {
// Keep previous icon, if no new one was selected
newEntry.icon = mEntry.icon;
}
}
else {
newEntry.icon = App.getDB().pm.iconFactory.getIcon(mSelectedIconID);
}
newEntry.parent = mEntry.parent;
newEntry.tCreation = mEntry.tCreation;
newEntry.tExpire = mEntry.tExpire;
newEntry.setUUID(mEntry.getUUID());
Date now = Calendar.getInstance().getTime();
newEntry.tLastAccess = new PwDate(now);
newEntry.tLastMod = new PwDate(now);
byte[] binaryData = mEntry.getBinaryData();
if ( binaryData != null ) {
newEntry.setBinaryData(binaryData, 0, binaryData.length);
}
newEntry.title = Util.getEditText(act, R.id.entry_title);
newEntry.url = Util.getEditText(act, R.id.entry_url);
newEntry.username = Util.getEditText(act, R.id.entry_user_name);
newEntry.additional = Util.getEditText(act, R.id.entry_comment);
byte[] password;
try {
password = pass.getBytes("UTF-8");
} catch (UnsupportedEncodingException e) {
assert false;
password = pass.getBytes();
}
newEntry.setPassword(password, 0, password.length);
if ( newEntry.title.equals(mEntry.title) ) {
if ( newEntry.getTitle().equals(mEntry.getTitle()) ) {
setResult(KeePass.EXIT_REFRESH);
} else {
setResult(KeePass.EXIT_REFRESH_TITLE);
@@ -262,6 +230,30 @@ public class EntryEditActivity extends LockCloseActivity {
}
protected PwEntry populateNewEntry() {
PwEntry newEntry = mEntry.clone(true);
if (mSelectedIconID == -1 && mIsNew) {
newEntry.icon = App.getDB().pm.iconFactory.getIcon(0);
}
else {
newEntry.icon = App.getDB().pm.iconFactory.getIcon(mSelectedIconID);
}
Date now = Calendar.getInstance().getTime();
newEntry.setLastAccessTime(now);
newEntry.setLastModificationTime(now);
PwDatabase db = App.getDB().pm;
newEntry.setTitle(Util.getEditText(this, R.id.entry_title), db);
newEntry.setUrl(Util.getEditText(this, R.id.entry_url), db);
newEntry.setUsername(Util.getEditText(this, R.id.entry_user_name), db);
newEntry.setNotes(Util.getEditText(this, R.id.entry_comment), db);
newEntry.setPassword(Util.getEditText(this, R.id.entry_password), db);
return newEntry;
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
@@ -350,16 +342,16 @@ public class EntryEditActivity extends LockCloseActivity {
ImageButton currIconButton = (ImageButton) findViewById(R.id.icon_button);
App.getDB().drawFactory.assignDrawableTo(currIconButton, getResources(), mEntry.getIcon());
populateText(R.id.entry_title, mEntry.title);
populateText(R.id.entry_title, mEntry.getTitle());
populateText(R.id.entry_user_name, mEntry.getUsername());
populateText(R.id.entry_url, mEntry.url);
populateText(R.id.entry_url, mEntry.getUrl());
String password = new String(mEntry.getPassword());
populateText(R.id.entry_password, password);
populateText(R.id.entry_confpassword, password);
setPasswordStyle();
populateText(R.id.entry_comment, mEntry.additional);
populateText(R.id.entry_comment, mEntry.getNotes());
}
private void populateText(int viewId, String text) {
@@ -0,0 +1,40 @@
/*
* Copyright 2013 Brian Pellin.
*
* This file is part of KeePassDroid.
*
* KeePassDroid 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.
*
* KeePassDroid 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 KeePassDroid. If not, see <http://www.gnu.org/licenses/>.
*
*/
package com.keepassdroid;
import android.content.Intent;
import com.keepassdroid.database.PwGroupId;
import com.keepassdroid.database.PwGroupIdV3;
import com.keepassdroid.database.PwGroupV3;
public class EntryEditActivityV3 extends EntryEditActivity {
protected static void putParentId(Intent i, String parentKey, PwGroupV3 parent) {
i.putExtra(parentKey, parent.groupId);
}
@Override
protected PwGroupId getParentGroupId(Intent i, String key) {
int groupId = i.getIntExtra(key, -1);
return new PwGroupIdV3(groupId);
}
}
@@ -0,0 +1,48 @@
/*
* Copyright 2013 Brian Pellin.
*
* This file is part of KeePassDroid.
*
* KeePassDroid 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.
*
* KeePassDroid 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 KeePassDroid. If not, see <http://www.gnu.org/licenses/>.
*
*/
package com.keepassdroid;
import java.util.UUID;
import android.content.Intent;
import com.keepassdroid.database.PwGroupId;
import com.keepassdroid.database.PwGroupIdV4;
import com.keepassdroid.database.PwGroupV4;
import com.keepassdroid.utils.Types;
public class EntryEditActivityV4 extends EntryEditActivity {
protected static void putParentId(Intent i, String parentKey, PwGroupV4 parent) {
PwGroupId id = parent.getId();
PwGroupIdV4 id4 = (PwGroupIdV4) id;
i.putExtra(parentKey, Types.UUIDtoBytes(id4.getId()));
}
@Override
protected PwGroupId getParentGroupId(Intent i, String key) {
byte[] buf = i.getByteArrayExtra(key);
UUID id = Types.bytestoUUID(buf);
return new PwGroupIdV4(id);
}
}
+36 -5
View File
@@ -1,5 +1,5 @@
/*
* Copyright 2009-2012 Brian Pellin.
* Copyright 2009-2013 Brian Pellin.
*
* This file is part of KeePassDroid.
*
@@ -43,6 +43,22 @@ public abstract class PwEntry implements Cloneable {
}
public static PwEntry getInstance(PwGroup parent) {
return PwEntry.getInstance(parent, true, true);
}
public static PwEntry getInstance(PwGroup parent, boolean initId, boolean initDates) {
if (parent instanceof PwGroupV3) {
return new PwEntryV3((PwGroupV3)parent);
}
else if (parent instanceof PwGroupV4) {
return new PwEntryV4((PwGroupV4)parent);
}
else {
throw new RuntimeException("Unknow PwGroup instance.");
}
}
@Override
public Object clone() {
PwEntry newEntry;
@@ -56,6 +72,10 @@ public abstract class PwEntry implements Cloneable {
return newEntry;
}
public PwEntry clone(boolean deepStrings) {
return (PwEntry) clone();
}
public void assign(PwEntry source) {
icon = source.icon;
}
@@ -69,13 +89,24 @@ public abstract class PwEntry implements Cloneable {
public abstract String getPassword();
public abstract String getUrl();
public abstract String getNotes();
public abstract Date getCreate();
public abstract Date getMod();
public abstract Date getAccess();
public abstract Date getExpire();
public abstract Date getCreationTime();
public abstract Date getLastModificationTime();
public abstract Date getLastAccessTime();
public abstract Date getExpiryTime();
public abstract boolean expires();
public abstract PwGroup getParent();
public abstract void setTitle(String title, PwDatabase db);
public abstract void setUsername(String user, PwDatabase db);
public abstract void setPassword(String pass, PwDatabase db);
public abstract void setUrl(String url, PwDatabase db);
public abstract void setNotes(String notes, PwDatabase db);
public abstract void setCreationTime(Date create);
public abstract void setLastModificationTime(Date mod);
public abstract void setLastAccessTime(Date access);
public abstract void setExpires(boolean exp);
public abstract void setExpiryTime(Date expires);
public PwIcon getIcon() {
return icon;
+108 -22
View File
@@ -1,5 +1,23 @@
/*
KeePass for J2ME
* Copyright 2010-2013 Brian Pellin.
*
* This file is part of KeePassDroid.
*
* KeePassDroid 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.
*
* KeePassDroid 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 KeePassDroid. If not, see <http://www.gnu.org/licenses/>.
*
This file was derived from
Copyright 2007 Naomaru Itoi <[email protected]>
@@ -25,13 +43,12 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
package com.keepassdroid.database;
// PhoneID
import java.io.UnsupportedEncodingException;
import java.util.Calendar;
import java.util.Date;
import java.util.Random;
import java.util.UUID;
import com.keepassdroid.Database;
import com.keepassdroid.utils.Types;
@@ -150,24 +167,30 @@ public class PwEntryV3 extends PwEntry {
assign(source);
}
*/
public PwEntryV3(PwGroupV3 p) {
this(p, true, true);
}
public PwEntryV3(Database db, int parentId) {
public PwEntryV3(PwGroupV3 p, boolean initId, boolean initDates) {
parent = p;
groupId = ((PwGroupIdV3)parent.getId()).getId();
if (initId) {
Random random = new Random();
uuid = new byte[16];
random.nextBytes(uuid);
}
parent = (PwGroupV3) db.groups.get(new PwGroupIdV3(parentId));
groupId = parentId;
Random random = new Random();
uuid = new byte[16];
random.nextBytes(uuid);
Calendar cal = Calendar.getInstance();
Date now = cal.getTime();
tCreation = new PwDate(now);
tLastAccess = new PwDate(now);
tLastMod = new PwDate(now);
tExpire = new PwDate(NEVER_EXPIRE);
if (initDates) {
Calendar cal = Calendar.getInstance();
Date now = cal.getTime();
tCreation = new PwDate(now);
tLastAccess = new PwDate(now);
tLastMod = new PwDate(now);
tExpire = new PwDate(NEVER_EXPIRE);
}
}
@@ -210,6 +233,19 @@ public class PwEntryV3 extends PwEntry {
@Override
public void setPassword(String pass, PwDatabase db) {
byte[] password;
try {
password = pass.getBytes("UTF-8");
setPassword(password, 0, password.length);
} catch (UnsupportedEncodingException e) {
assert false;
password = pass.getBytes();
setPassword(password, 0, password.length);
}
}
/**
* @return the actual binaryData byte array.
*/
@@ -327,25 +363,55 @@ public class PwEntryV3 extends PwEntry {
}
@Override
public Date getAccess() {
public Date getLastAccessTime() {
return tLastAccess.getJDate();
}
@Override
public Date getCreate() {
public Date getCreationTime() {
return tCreation.getJDate();
}
@Override
public Date getExpire() {
public Date getExpiryTime() {
return tExpire.getJDate();
}
@Override
public Date getMod() {
public Date getLastModificationTime() {
return tLastMod.getJDate();
}
@Override
public void setCreationTime(Date create) {
tCreation = new PwDate(create);
}
@Override
public void setLastModificationTime(Date mod) {
tLastMod = new PwDate(mod);
}
@Override
public void setLastAccessTime(Date access) {
tLastAccess = new PwDate(access);
}
@Override
public void setExpires(boolean expires) {
if (!expires) {
tExpire = PW_NEVER_EXPIRE;
}
}
@Override
public void setExpiryTime(Date expires) {
tExpire = new PwDate(expires);
}
@Override
public PwGroupV3 getParent() {
return parent;
@@ -370,21 +436,41 @@ public class PwEntryV3 extends PwEntry {
return username;
}
@Override
public void setUsername(String user, PwDatabase db) {
username = user;
}
@Override
public String getTitle() {
return title;
}
@Override
public void setTitle(String title, PwDatabase db) {
this.title = title;
}
@Override
public String getNotes() {
return additional;
}
@Override
public void setNotes(String notes, PwDatabase db) {
additional = notes;
}
@Override
public String getUrl() {
return url;
}
@Override
public void setUrl(String url, PwDatabase db) {
this.url = url;
}
@Override
public boolean expires() {
return ! IsNever(tExpire.getJDate());
+98 -36
View File
@@ -20,6 +20,7 @@
package com.keepassdroid.database;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
@@ -40,7 +41,7 @@ public class PwEntryV4 extends PwEntry implements ITimeLogger {
public PwGroupV4 parent;
public UUID uuid = PwDatabaseV4.UUID_ZERO;
public Map<String, ProtectedString> strings = new HashMap<String, ProtectedString>();
public HashMap<String, ProtectedString> strings = new HashMap<String, ProtectedString>();
public Map<String, ProtectedBinary> binaries = new HashMap<String, ProtectedBinary>();
public PwIconCustom customIcon = PwIconCustom.ZERO;
public String foregroundColor = "";
@@ -82,6 +83,39 @@ public class PwEntryV4 extends PwEntry implements ITimeLogger {
public PwEntryV4() {
}
public PwEntryV4(PwGroupV4 p) {
this(p, true, true);
}
public PwEntryV4(PwGroupV4 p, boolean initId, boolean initDates) {
parent = p;
if (initId) {
uuid = UUID.randomUUID();
}
if (initDates) {
Calendar cal = Calendar.getInstance();
Date now = cal.getTime();
creation = now;
lastAccess = now;
lastMod = now;
expires = false;
}
}
@SuppressWarnings("unchecked")
@Override
public PwEntry clone(boolean deepStrings) {
PwEntryV4 entry = (PwEntryV4) super.clone(deepStrings);
if (deepStrings) {
entry.strings = (HashMap<String, ProtectedString>) strings.clone();
}
return entry;
}
@Override
public void assign(PwEntry source) {
@@ -147,25 +181,81 @@ public class PwEntryV4 extends PwEntry implements ITimeLogger {
}
@Override
public Date getAccess() {
public Date getLastAccessTime() {
return lastAccess;
}
@Override
public Date getCreate() {
public Date getCreationTime() {
return creation;
}
@Override
public Date getExpire() {
public Date getExpiryTime() {
return expireDate;
}
@Override
public Date getMod() {
public Date getLastModificationTime() {
return lastMod;
}
@Override
public void setTitle(String title, PwDatabase d) {
PwDatabaseV4 db = (PwDatabaseV4) d;
boolean protect = db.memoryProtection.protectTitle;
setString(STR_TITLE, title, protect);
}
@Override
public void setUsername(String user, PwDatabase d) {
PwDatabaseV4 db = (PwDatabaseV4) d;
boolean protect = db.memoryProtection.protectUserName;
setString(STR_USERNAME, user, protect);
}
@Override
public void setPassword(String pass, PwDatabase d) {
PwDatabaseV4 db = (PwDatabaseV4) d;
boolean protect = db.memoryProtection.protectPassword;
setString(STR_PASSWORD, pass, protect);
}
@Override
public void setUrl(String url, PwDatabase d) {
PwDatabaseV4 db = (PwDatabaseV4) d;
boolean protect = db.memoryProtection.protectUrl;
setString(STR_URL, url, protect);
}
@Override
public void setNotes(String notes, PwDatabase d) {
PwDatabaseV4 db = (PwDatabaseV4) d;
boolean protect = db.memoryProtection.protectNotes;
setString(STR_NOTES, notes, protect);
}
public void setCreationTime(Date date) {
creation = date;
}
public void setExpiryTime(Date date) {
expireDate = date;
}
public void setLastAccessTime(Date date) {
lastAccess = date;
}
public void setLastModificationTime(Date date) {
lastMod = date;
}
@Override
public PwGroupV4 getParent() {
return parent;
@@ -190,20 +280,9 @@ public class PwEntryV4 extends PwEntry implements ITimeLogger {
return value.toString();
}
public Date getCreationTime() {
return creation;
}
public Date getExpiryTime() {
return expireDate;
}
public Date getLastAccessTime() {
return lastAccess;
}
public Date getLastModificationTime() {
return lastMod;
public void setString(String key, String value, boolean protect) {
ProtectedString ps = new ProtectedString(protect, value);
strings.put(key, ps);
}
public Date getLocationChanged() {
@@ -214,23 +293,6 @@ public class PwEntryV4 extends PwEntry implements ITimeLogger {
return usageCount;
}
public void setCreationTime(Date date) {
creation = date;
}
public void setExpiryTime(Date date) {
expireDate = date;
}
public void setLastAccessTime(Date date) {
lastAccess = date;
}
public void setLastModificationTime(Date date) {
lastMod = date;
}
public void setLocationChanged(Date date) {
parentGroupLastMod = date;
}
@@ -1,5 +1,5 @@
/*
* Copyright 2010 Brian Pellin.
* Copyright 2010-2013 Brian Pellin.
*
* This file is part of KeePassDroid.
*
@@ -21,6 +21,7 @@ package com.keepassdroid.tests.database;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
@@ -36,6 +37,7 @@ import com.keepassdroid.database.load.ImporterFactory;
import com.keepassdroid.database.load.ImporterV4;
import com.keepassdroid.database.save.PwDbOutput;
import com.keepassdroid.database.save.PwDbV4Output;
import com.keepassdroid.stream.CopyInputStream;
import com.keepassdroid.tests.TestUtil;
public class Kdb4 extends AndroidTestCase {
@@ -84,11 +86,15 @@ public class Kdb4 extends AndroidTestCase {
byte[] data = bos.toByteArray();
ByteArrayInputStream bis = new ByteArrayInputStream(data);
FileOutputStream fos = new FileOutputStream("/sdcard/test-out.kdbx", false);
InputStream bis = new ByteArrayInputStream(data);
bis = new CopyInputStream(bis, fos);
importer = new ImporterV4();
db = importer.openDatabase(bis, "12345", "");
bis.close();
fos.close();
}