From 1d4825cbdce02f1e85b40cc9b34a7451d92fc98c Mon Sep 17 00:00:00 2001 From: Brian Pellin Date: Tue, 27 Jan 2009 21:27:02 -0600 Subject: [PATCH] Hide Meta-Info entries. --- CHANGELOG | 4 ++++ src/com/android/keepass/PwListAdapter.java | 20 ++++++++++++++--- src/org/phoneid/keepassj2me/PwEntry.java | 25 ++++++++++++++++++++-- 3 files changed, 44 insertions(+), 5 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 0612b17d7..590b64c2c 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -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. diff --git a/src/com/android/keepass/PwListAdapter.java b/src/com/android/keepass/PwListAdapter.java index 47ce53f12..c9997671a 100644 --- a/src/com/android/keepass/PwListAdapter.java +++ b/src/com/android/keepass/PwListAdapter.java @@ -35,17 +35,31 @@ public class PwListAdapter extends BaseAdapter { private Activity mAct; private PwGroup mGroup; + private Vector filteredEntries; PwListAdapter(Activity act, PwGroup group) { mAct = act; mGroup = group; + filter(); + + } + + private void filter() { + filteredEntries = new Vector(); + + 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; } diff --git a/src/org/phoneid/keepassj2me/PwEntry.java b/src/org/phoneid/keepassj2me/PwEntry.java index beb575f54..d65ef44cd 100644 --- a/src/org/phoneid/keepassj2me/PwEntry.java +++ b/src/org/phoneid/keepassj2me/PwEntry.java @@ -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;