diff --git a/README.md b/README.md index 181c786..8785855 100644 --- a/README.md +++ b/README.md @@ -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: @@ -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 diff --git a/android/src/main/java/com/react/SmsModule.java b/android/src/main/java/com/react/SmsModule.java index 7a27616..456d790 100644 --- a/android/src/main/java/com/react/SmsModule.java +++ b/android/src/main/java/com/react/SmsModule.java @@ -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; @@ -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)