aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/pixart/messenger/persistance
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2018-05-02 21:50:05 +0200
committerChristian Schneppe <christian@pix-art.de>2018-05-02 21:50:05 +0200
commit66835b12c35dad7a8ddbe816556635635b836e95 (patch)
treef870d5a7d98a42ddb0707edf8d55c2b6307293ad /src/main/java/de/pixart/messenger/persistance
parent536106b0793495a3635d641c78cedf65ec1723f7 (diff)
search term parsing + highlighting
Diffstat (limited to 'src/main/java/de/pixart/messenger/persistance')
-rw-r--r--src/main/java/de/pixart/messenger/persistance/DatabaseBackend.java10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/main/java/de/pixart/messenger/persistance/DatabaseBackend.java b/src/main/java/de/pixart/messenger/persistance/DatabaseBackend.java
index 16f0f6908..b7973aca6 100644
--- a/src/main/java/de/pixart/messenger/persistance/DatabaseBackend.java
+++ b/src/main/java/de/pixart/messenger/persistance/DatabaseBackend.java
@@ -50,6 +50,7 @@ import de.pixart.messenger.entities.Roster;
import de.pixart.messenger.entities.ServiceDiscoveryResult;
import de.pixart.messenger.services.ShortcutService;
import de.pixart.messenger.utils.CryptoHelper;
+import de.pixart.messenger.utils.FtsUtils;
import de.pixart.messenger.utils.Resolver;
import de.pixart.messenger.xmpp.mam.MamReference;
import rocks.xmpp.addr.Jid;
@@ -227,6 +228,10 @@ public class DatabaseBackend extends SQLiteOpenHelper {
db.execSQL(CREATE_IDENTITIES_STATEMENT);
db.execSQL(CREATE_PRESENCE_TEMPLATES_STATEMENT);
db.execSQL(CREATE_RESOLVER_RESULTS_TABLE);
+ db.execSQL(CREATE_MESSAGE_INDEX_TABLE);
+ db.execSQL(CREATE_MESSAGE_INSERT_TRIGGER);
+ db.execSQL(CREATE_MESSAGE_UPDATE_TRIGGER);
+ db.execSQL(CREATE_MESSAGE_DELETE_TRIGGER);
}
@Override
@@ -731,10 +736,11 @@ public class DatabaseBackend extends SQLiteOpenHelper {
return list;
}
- public Cursor getMessageSearchCursor(String term) {
+ public Cursor getMessageSearchCursor(List<String> term) {
SQLiteDatabase db = this.getReadableDatabase();
String SQL = "SELECT " + Message.TABLENAME + ".*," + Conversation.TABLENAME + '.' + Conversation.CONTACTJID + ',' + Conversation.TABLENAME + '.' + Conversation.ACCOUNT + ',' + Conversation.TABLENAME + '.' + Conversation.MODE + " FROM " + Message.TABLENAME + " join " + Conversation.TABLENAME + " on " + Message.TABLENAME + '.' + Message.CONVERSATION + '=' + Conversation.TABLENAME + '.' + Conversation.UUID + " join messages_index ON messages_index.uuid=messages.uuid where " + Message.ENCRYPTION + " NOT IN(" + Message.ENCRYPTION_AXOLOTL_NOT_FOR_THIS_DEVICE + ',' + Message.ENCRYPTION_PGP + ',' + Message.ENCRYPTION_DECRYPTION_FAILED + ") AND messages_index.body MATCH ? ORDER BY " + Message.TIME_SENT + " DESC limit " + Config.MAX_SEARCH_RESULTS;
- return db.rawQuery(SQL, new String[]{'%' + term + '%'});
+ Log.d(Config.LOGTAG, "search term: " + FtsUtils.toMatchString(term));
+ return db.rawQuery(SQL, new String[]{FtsUtils.toMatchString(term)});
}
public Iterable<Message> getMessagesIterable(final Conversation conversation) {