Skip to content

Commit

Permalink
Support scope queries
Browse files Browse the repository at this point in the history
  • Loading branch information
appml committed Dec 14, 2023
1 parent 9f6bd87 commit 511b1ae
Show file tree
Hide file tree
Showing 7 changed files with 356 additions and 285 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ android {
minSdkVersion 26
targetSdkVersion 34
multiDexEnabled true
versionCode 1312
versionName "4.4.9"
versionCode 1313
versionName "4.4.9a"
}

buildTypes {
Expand Down
574 changes: 293 additions & 281 deletions app/mapping.txt

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions app/release/output-metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
"type": "SINGLE",
"filters": [],
"attributes": [],
"versionCode": 1311,
"versionName": "4.4.8c",
"versionCode": 1312,
"versionName": "4.4.9",
"outputFile": "app-release.apk"
}
],
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/java/com/appmindlab/nano/Const.java
Original file line number Diff line number Diff line change
Expand Up @@ -636,6 +636,8 @@ public class Const {
protected final static String ORGQUERY = "org:";
protected final static String JOINQUERY = "join:";
protected final static String INQUERY = "in:";

protected final static String SCOPEQUERY = "scope:";
protected final static String SHOW_PATTERN = "/%";
protected final static String HIDE_PATTERN = "~%";
protected final static String HIDE_PATTERN_PREFIX = "~";
Expand Down
41 changes: 41 additions & 0 deletions app/src/main/java/com/appmindlab/nano/DataSource.java
Original file line number Diff line number Diff line change
Expand Up @@ -1672,6 +1672,47 @@ else if (criteria.startsWith(Const.INQUERY)) {
null,
orderBy + " " + orderDirection);
}
else if (criteria.startsWith(Const.SCOPEQUERY)) {
criteria = Utils.cleanCriteria(criteria);

String[] parts = criteria.split(",");
String temp = "";
String qry;

// Build template
if (parts.length == 1) { // Only search the metadata
qry = "(" + DBHelper.COLUMN_METADATA + " LIKE ?)";
parts[0] = "%" + parts[0].trim() + "%";
}

else {
for (int i=1; i < parts.length; i++) { // The first must match metadata
if (i == parts.length-1) {
temp = temp + DBHelper.COLUMN_CONTENT + " LIKE ? ";
}
else {
temp = temp + DBHelper.COLUMN_CONTENT + " LIKE ? OR ";
}
}

// Query template
qry = "(" + DBHelper.COLUMN_METADATA + " LIKE ?) AND (" + temp + ")";

// Build criteria
parts[0] = "%" + parts[0].trim() + "%";
for (int i=1; i < parts.length; i++) {
parts[i] = '%' + parts[i].trim() + '%';
}
}

cursor = mDatabase.query(DBHelper.TABLE,
getSearchColumns(mode),
qry,
parts,
null,
null,
orderBy + " " + orderDirection);
}
else if (criteria.equals(Const.STARRED_SYM)) {
cursor = mDatabase.query(DBHelper.TABLE,
columns,
Expand Down
14 changes: 14 additions & 0 deletions app/src/main/java/com/appmindlab/nano/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,9 @@ else if (criteria.startsWith(Const.JOINQUERY))
else if (criteria.startsWith(Const.INQUERY))
criteria = criteria.substring(Const.INQUERY.length()).trim();

else if (criteria.startsWith(Const.SCOPEQUERY))
criteria = criteria.substring(Const.SCOPEQUERY.length()).trim();

else if (criteria.startsWith(Const.SIMILARQUERY))
return criteria.substring(Const.SIMILARQUERY.length()).trim();

Expand Down Expand Up @@ -3521,6 +3524,14 @@ else if (criteria.startsWith(Const.INQUERY)) {
else
criteria = parts[0];
}
else if (criteria.startsWith(Const.SCOPEQUERY)) {
criteria = criteria.substring(Const.SCOPEQUERY.length());
String[] parts = criteria.split(",");
if (parts.length > 1)
criteria = parts[1];
else
criteria = parts[0];
}

return criteria.trim();
}
Expand Down Expand Up @@ -4023,6 +4034,9 @@ protected static boolean validateLocalFindCriteria(String criteria) {
if (criteria.startsWith(Const.INQUERY))
return true;

if (criteria.startsWith(Const.SCOPEQUERY))
return true;

if (criteria.length() == 1)
return false;

Expand Down
2 changes: 2 additions & 0 deletions fastlane/metadata/android/en-US/changelogs/1313.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
v4.4.9c
- Search in notes with matching title or metadata patterns.

0 comments on commit 511b1ae

Please sign in to comment.