Skip to content

Commit 4529801

Browse files
#244 Search should also include category of note
1 parent 186149b commit 4529801

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

app/src/main/java/it/niedermann/owncloud/notes/persistence/NoteSQLiteOpenHelper.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,9 @@ public DBNote getNote(long id) {
228228
*/
229229
private List<DBNote> getNotesCustom(String selection, String[] selectionArgs, String orderBy) {
230230
SQLiteDatabase db = getReadableDatabase();
231+
if(selectionArgs.length > 2) {
232+
Log.v("Note", selection + " ---- " + selectionArgs[0] + " " + selectionArgs[1] + " " + selectionArgs[2]);
233+
}
231234
Cursor cursor = db.query(table_notes, columns, selection, selectionArgs, null, null, orderBy);
232235
List<DBNote> notes = new ArrayList<>();
233236
while (cursor.moveToNext()) {
@@ -288,7 +291,15 @@ public List<DBNote> getNotes() {
288291
* @return List&lt;Note&gt;
289292
*/
290293
public List<DBNote> searchNotes(CharSequence query) {
291-
return getNotesCustom(key_status + " != ? AND " + key_content + " LIKE ?", new String[]{DBStatus.LOCAL_DELETED.getTitle(), "%" + query + "%"}, default_order);
294+
return getNotesCustom(
295+
key_status + " != ? AND ("
296+
+ key_content + " LIKE ? OR "
297+
+ key_category + " LIKE ?" +
298+
")", new String[]{
299+
DBStatus.LOCAL_DELETED.getTitle(),
300+
"%" + query + "%",
301+
"%" + query + "%"
302+
}, default_order);
292303
}
293304

294305
/**

0 commit comments

Comments
 (0)