Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Support for AddressRegex #72

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ var filter = {
box: 'inbox', // 'inbox' (default), 'sent', 'draft', 'outbox', 'failed', 'queued', and '' for all

/**
* the next 3 filters can work together, they are AND-ed
* the next 4 filters can work together, they are AND-ed
*
* minDate, maxDate filters work like this:
* - If and only if you set a maxDate, it's like executing this SQL query:
Expand All @@ -100,7 +100,8 @@ var filter = {
minDate: 1554636310165, // timestamp (in milliseconds since UNIX epoch)
maxDate: 1556277910456, // timestamp (in milliseconds since UNIX epoch)
bodyRegex: '(.*)How are you(.*)', // content regex to match

addressRegex: '^[0-9]{12}$', // address regex to match

/** the next 5 filters should NOT be used together, they are OR-ed so pick one **/
read: 0, // 0 for unread SMS, 1 for SMS already read
_id: 1234, // specify the msg id
Expand Down
3 changes: 3 additions & 0 deletions android/src/main/java/com/react/SmsModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ public void list(String filter, final Callback errorCallback, final Callback suc
int fid = filterJ.has("_id") ? filterJ.optInt("_id") : -1;
int ftid = filterJ.has("thread_id") ? filterJ.optInt("thread_id") : -1;
String faddress = filterJ.optString("address");
String fAddressRegex = filterJ.optString("addressRegex");
String fcontent = filterJ.optString("body");
String fContentRegex = filterJ.optString("bodyRegex");
int indexFrom = filterJ.has("indexFrom") ? filterJ.optInt("indexFrom") : 0;
Expand Down Expand Up @@ -100,6 +101,8 @@ else if (fcontent != null && !fcontent.isEmpty())

if (fContentRegex != null && !fContentRegex.isEmpty())
matchFilter = matchFilter && cursor.getString(cursor.getColumnIndex("body")).matches(fContentRegex);
if (fAddressRegex != null && !fAddressRegex.isEmpty())
matchFilter = matchFilter && cursor.getString(cursor.getColumnIndex("address")).matches(fAddressRegex);
if (maxDate > -1)
matchFilter = matchFilter && maxDate >= cursor.getLong(cursor.getColumnIndex("date"));
if (minDate > -1)
Expand Down