Fix quick search with magikeyboard

This commit is contained in:
J-Jamet
2018-07-28 09:37:26 +02:00
parent d6eae56d4f
commit 608f45677c
3 changed files with 30 additions and 10 deletions

View File

@@ -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;
}

View File

@@ -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);

View File

@@ -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) {