Hide Meta-Info entries.

This commit is contained in:
Brian Pellin 2009-01-27 21:27:02 -06:00
parent c78cbccae5
commit 1d4825cbdc
3 changed files with 44 additions and 5 deletions

View file

@ -1,3 +1,7 @@
KeePassDroid (0.2.1)
* Hide Meta-Info entries
KeePassDroid (0.1.2)
* Fix crash when accessing the first root level group.

View file

@ -35,17 +35,31 @@ public class PwListAdapter extends BaseAdapter {
private Activity mAct;
private PwGroup mGroup;
private Vector<PwEntry> filteredEntries;
PwListAdapter(Activity act, PwGroup group) {
mAct = act;
mGroup = group;
filter();
}
private void filter() {
filteredEntries = new Vector<PwEntry>();
for (int i = 0; i < mGroup.childEntries.size(); i++) {
PwEntry entry = (PwEntry) mGroup.childEntries.elementAt(i);
if ( ! entry.isMetaStream() ) {
filteredEntries.add(entry);
}
}
}
@Override
public int getCount() {
return mGroup.childGroups.size() + mGroup.childEntries.size();
return mGroup.childGroups.size() + filteredEntries.size();
}
@Override
@ -85,10 +99,10 @@ public class PwListAdapter extends BaseAdapter {
private PwEntryView createEntryView(int position, View convertView) {
PwEntryView ev;
if (convertView == null || ! (convertView instanceof PwEntryView) ) {
ev = new PwEntryView(mAct, (PwEntry) mGroup.childEntries.elementAt(position));
ev = new PwEntryView(mAct, filteredEntries.elementAt(position));
} else {
ev = (PwEntryView) convertView;
ev.setEntry((PwEntry) mGroup.childEntries.elementAt(position));
ev.setEntry(filteredEntries.elementAt(position));
}
return ev;
}

View file

@ -53,8 +53,9 @@ import java.util.*;
*/
public class PwEntry {
// for tree traversing
public PwGroup parent = null;
// for tree traversing
public PwGroup parent = null;
public PwEntry() {
}
@ -101,10 +102,30 @@ public class PwEntry {
System.arraycopy( buf, offset, binaryData, 0, len );
}
// Determine if this is a MetaStream entrie
public boolean isMetaStream() {
if ( binaryData == null ) return false;
if ( additional == null || additional.length() == 0 ) return false;
if ( ! binaryDesc.equals(PMS_ID_BINDESC) ) return false;
if ( title == null ) return false;
if ( ! title.equals(PMS_ID_TITLE) ) return false;
if ( username == null ) return false;
if ( ! username.equals(PMS_ID_USER) ) return false;
if ( url == null ) return false;
if ( ! url.equals(PMS_ID_URL)) return false;
if ( imageId != 0 ) return false;
return true;
}
/** Size of byte buffer needed to hold this struct. */
public static final int BUF_SIZE = 124;
public static final String PMS_ID_BINDESC = "bin-stream";
public static final String PMS_ID_TITLE = "Meta-Info";
public static final String PMS_ID_USER = "SYSTEM";
public static final String PMS_ID_URL = "$";
public byte uuid[] = new byte[16];
public int groupId;