diff --git a/app/src/main/java/com/kunzisoft/keepass/adapters/SearchEntryCursorAdapter.java b/app/src/main/java/com/kunzisoft/keepass/adapters/SearchEntryCursorAdapter.java index 85f5d09ce..533e76e81 100644 --- a/app/src/main/java/com/kunzisoft/keepass/adapters/SearchEntryCursorAdapter.java +++ b/app/src/main/java/com/kunzisoft/keepass/adapters/SearchEntryCursorAdapter.java @@ -35,7 +35,6 @@ import com.kunzisoft.keepass.database.Database; import com.kunzisoft.keepass.database.PwEntry; import com.kunzisoft.keepass.database.PwIcon; import com.kunzisoft.keepass.database.PwIconFactory; -import com.kunzisoft.keepass.database.PwIconStandard; import com.kunzisoft.keepass.database.cursor.EntryCursor; import com.kunzisoft.keepass.icons.IconPackChooser; @@ -119,7 +118,6 @@ public class SearchEntryCursorAdapter extends CursorAdapter { pwEntry = database.createEntry(); database.populateEntry(pwEntry, cursor); - } return pwEntry; } diff --git a/app/src/main/java/com/kunzisoft/keepass/database/Database.java b/app/src/main/java/com/kunzisoft/keepass/database/Database.java index 90cd2f868..1e11483fe 100644 --- a/app/src/main/java/com/kunzisoft/keepass/database/Database.java +++ b/app/src/main/java/com/kunzisoft/keepass/database/Database.java @@ -210,9 +210,9 @@ public class Database { try { switch (getPwDatabase().getVersion()) { case V3: - EntryCursor.addEntry(cursor, (PwEntryV3) entry, i); + EntryCursor.addEntry(cursor, i, (PwEntryV3) entry); case V4: - EntryCursor.addEntry(cursor, (PwEntryV4) entry, i); + EntryCursor.addEntry(cursor, i, (PwEntryV4) entry); } } catch (Exception e) { Log.e(TAG, "This version of PwGroup can't be populated", e); diff --git a/app/src/main/java/com/kunzisoft/keepass/database/cursor/EntryCursor.java b/app/src/main/java/com/kunzisoft/keepass/database/cursor/EntryCursor.java index cddbb0b41..9f3981bc8 100644 --- a/app/src/main/java/com/kunzisoft/keepass/database/cursor/EntryCursor.java +++ b/app/src/main/java/com/kunzisoft/keepass/database/cursor/EntryCursor.java @@ -3,7 +3,6 @@ package com.kunzisoft.keepass.database.cursor; import android.database.Cursor; import android.database.MatrixCursor; import android.provider.BaseColumns; -import android.util.Log; import com.kunzisoft.keepass.database.PwDatabase; import com.kunzisoft.keepass.database.PwEntry; @@ -24,6 +23,11 @@ public class EntryCursor extends MatrixCursor { public static final String COLUMN_INDEX_ICON_STANDARD = "iconStandard"; public static final String COLUMN_INDEX_ICON_CUSTOM_UUID_MOST_SIGNIFICANT_BITS = "iconCustomUUIDMostSignificantBits"; public static final String COLUMN_INDEX_ICON_CUSTOM_UUID_LEAST_SIGNIFICANT_BITS = "iconCustomUUIDLeastSignificantBits"; + public static final String COLUMN_INDEX_USERNAME = "username"; + public static final String COLUMN_INDEX_PASSWORD = "password"; + public static final String COLUMN_INDEX_URL = "URL"; + public static final String COLUMN_INDEX_NOTES = "notes"; + // TODO custom elements public EntryCursor() { super(new String[]{ _ID, @@ -32,27 +36,40 @@ public class EntryCursor extends MatrixCursor { COLUMN_INDEX_TITLE, COLUMN_INDEX_ICON_STANDARD, COLUMN_INDEX_ICON_CUSTOM_UUID_MOST_SIGNIFICANT_BITS, - COLUMN_INDEX_ICON_CUSTOM_UUID_LEAST_SIGNIFICANT_BITS}); + COLUMN_INDEX_ICON_CUSTOM_UUID_LEAST_SIGNIFICANT_BITS, + COLUMN_INDEX_USERNAME, + COLUMN_INDEX_PASSWORD, + COLUMN_INDEX_URL, + COLUMN_INDEX_NOTES}); } - public static void addEntry(MatrixCursor cursor, PwEntryV3 entry, int id) { + public static void addEntry(MatrixCursor cursor, int id, PwEntryV3 entry) { cursor.addRow(new Object[] {id, entry.getUUID().getMostSignificantBits(), entry.getUUID().getLeastSignificantBits(), entry.getTitle(), entry.getIconStandard().getIconId(), PwDatabase.UUID_ZERO.getMostSignificantBits(), - PwDatabase.UUID_ZERO.getLeastSignificantBits()}); + PwDatabase.UUID_ZERO.getLeastSignificantBits(), + entry.getUsername(), + entry.getPassword(), + entry.getUrl(), + entry.getNotes(), + }); } - public static void addEntry(MatrixCursor cursor, PwEntryV4 entry, int id) { + public static void addEntry(MatrixCursor cursor, int id, PwEntryV4 entry) { cursor.addRow(new Object[] {id, entry.getUUID().getMostSignificantBits(), entry.getUUID().getLeastSignificantBits(), entry.getTitle(), entry.getIconStandard().getIconId(), entry.getCustomIcon().getUUID().getMostSignificantBits(), - entry.getCustomIcon().getUUID().getLeastSignificantBits()}); + entry.getCustomIcon().getUUID().getLeastSignificantBits(), + entry.getUsername(), + entry.getPassword(), + entry.getUrl(), + entry.getNotes()}); } private static void populateEntryBaseVersion(Cursor cursor, PwEntry pwEntry, PwIconFactory iconFactory) { @@ -63,6 +80,11 @@ public class EntryCursor extends MatrixCursor { PwIconStandard iconStandard = iconFactory.getIcon(cursor.getInt(cursor.getColumnIndex(EntryCursor.COLUMN_INDEX_ICON_STANDARD))); pwEntry.setIcon(iconStandard); + + pwEntry.setUsername(cursor.getString(cursor.getColumnIndex(EntryCursor.COLUMN_INDEX_USERNAME))); + pwEntry.setPassword(cursor.getString(cursor.getColumnIndex(EntryCursor.COLUMN_INDEX_PASSWORD))); + pwEntry.setUrl(cursor.getString(cursor.getColumnIndex(EntryCursor.COLUMN_INDEX_URL))); + pwEntry.setNotes(cursor.getString(cursor.getColumnIndex(EntryCursor.COLUMN_INDEX_NOTES))); } public static void populateEntry(Cursor cursor, PwEntryV3 pwEntry, PwIconFactory iconFactory) {