File tree Expand file tree Collapse file tree
app/src/main/java/fr/gaulupeau/apps/Poche Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -31,23 +31,34 @@ public class FtsDao {
3131 "article_content_after_delete_tr"
3232 };
3333
34+ public static boolean isFtsSupported () {
35+ // https://www.sqlite.org/changes.html#version_3_7_9 is required for the 'content' option
36+ return Build .VERSION .SDK_INT >= Build .VERSION_CODES .JELLY_BEAN ; // https://stackoverflow.com/a/4377116
37+ }
38+
3439 public static String getQueryString () {
3540 return "select " + COLUMN_ID + " from " + TABLE_NAME + " where " + TABLE_NAME + " match " ;
3641 }
3742
3843 public static void createAll (Database db , boolean ifNotExists ) {
44+ if (!isFtsSupported ()) return ;
45+
3946 createViewForFts (db , ifNotExists );
4047 createTable (db , ifNotExists );
4148 createTriggers (db , ifNotExists );
4249 }
4350
4451 public static void dropAll (Database db , boolean ifExists ) {
52+ if (!isFtsSupported ()) return ;
53+
4554 dropTriggers (db , ifExists );
4655 dropTable (db , ifExists );
4756 dropViewForFts (db , ifExists );
4857 }
4958
5059 public static void deleteAllArticles (Database db ) {
60+ if (!isFtsSupported ()) return ;
61+
5162 dropTable (db , true );
5263 createTable (db , true );
5364 }
Original file line number Diff line number Diff line change @@ -219,8 +219,12 @@ private QueryBuilder<Article> getQueryBuilder() {
219219 }
220220
221221 if (!TextUtils .isEmpty (searchQuery )) {
222- qb .where (new WhereCondition .PropertyCondition (ArticleDao .Properties .Id , " IN (" +
223- FtsDao .getQueryString () + DatabaseUtils .sqlEscapeString (searchQuery ) + ")" ));
222+ if (FtsDao .isFtsSupported ()) {
223+ qb .where (new WhereCondition .PropertyCondition (ArticleDao .Properties .Id , " IN (" +
224+ FtsDao .getQueryString () + DatabaseUtils .sqlEscapeString (searchQuery ) + ")" ));
225+ } else {
226+ qb .where (ArticleDao .Properties .Title .like ("%" + searchQuery + "%" ));
227+ }
224228 }
225229
226230 switch (sortOrder ) {
You can’t perform that action at this time.
0 commit comments