mirror of
https://github.com/apache/cordova-android.git
synced 2025-01-19 15:12:51 +08:00
CB-849: Cannot search by birthday
This commit is contained in:
parent
5f93a26eea
commit
c21e8c9c87
@ -18,7 +18,6 @@ package org.apache.cordova;
|
|||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.webkit.WebView;
|
import android.webkit.WebView;
|
||||||
|
@ -25,7 +25,10 @@ import java.io.FileNotFoundException;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
import java.text.ParseException;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
@ -111,7 +114,7 @@ public class ContactAccessorSdk5 extends ContactAccessor {
|
|||||||
dbMap.put("organizations.name", ContactsContract.CommonDataKinds.Organization.COMPANY);
|
dbMap.put("organizations.name", ContactsContract.CommonDataKinds.Organization.COMPANY);
|
||||||
dbMap.put("organizations.department", ContactsContract.CommonDataKinds.Organization.DEPARTMENT);
|
dbMap.put("organizations.department", ContactsContract.CommonDataKinds.Organization.DEPARTMENT);
|
||||||
dbMap.put("organizations.title", ContactsContract.CommonDataKinds.Organization.TITLE);
|
dbMap.put("organizations.title", ContactsContract.CommonDataKinds.Organization.TITLE);
|
||||||
dbMap.put("birthday", ContactsContract.CommonDataKinds.Event.CONTENT_ITEM_TYPE);
|
dbMap.put("birthday", ContactsContract.CommonDataKinds.Event.START_DATE);
|
||||||
dbMap.put("note", ContactsContract.CommonDataKinds.Note.NOTE);
|
dbMap.put("note", ContactsContract.CommonDataKinds.Note.NOTE);
|
||||||
dbMap.put("photos.value", ContactsContract.CommonDataKinds.Photo.CONTENT_ITEM_TYPE);
|
dbMap.put("photos.value", ContactsContract.CommonDataKinds.Photo.CONTENT_ITEM_TYPE);
|
||||||
//dbMap.put("categories.value", null);
|
//dbMap.put("categories.value", null);
|
||||||
@ -579,10 +582,24 @@ public class ContactAccessorSdk5 extends ContactAccessor {
|
|||||||
whereArgs.add(searchTerm);
|
whereArgs.add(searchTerm);
|
||||||
whereArgs.add(ContactsContract.CommonDataKinds.Organization.CONTENT_ITEM_TYPE);
|
whereArgs.add(ContactsContract.CommonDataKinds.Organization.CONTENT_ITEM_TYPE);
|
||||||
}
|
}
|
||||||
// else if (key.startsWith("birthday")) {
|
else if (key.startsWith("birthday")) {
|
||||||
// where.add("(" + dbMap.get(key) + " LIKE ? AND "
|
try {
|
||||||
// + ContactsContract.Data.MIMETYPE + " = ? )");
|
SimpleDateFormat format = new SimpleDateFormat("EEEE, MMMM dd, yyyy");
|
||||||
// }
|
Date searchDate = format.parse(searchTerm.substring(1, searchTerm.length()-1));
|
||||||
|
// Have to subtract one from the month as JavaScript's January is 01
|
||||||
|
// while Java's January is 00.
|
||||||
|
searchDate.setMonth(searchDate.getMonth()-1);
|
||||||
|
SimpleDateFormat newFormat = new SimpleDateFormat("yyyy-MM-dd");
|
||||||
|
|
||||||
|
where.add("(" + dbMap.get(key) + " = ? AND "
|
||||||
|
+ ContactsContract.Data.MIMETYPE + " = ? )");
|
||||||
|
whereArgs.add(newFormat.format(searchDate));
|
||||||
|
whereArgs.add(ContactsContract.CommonDataKinds.Event.CONTENT_ITEM_TYPE);
|
||||||
|
}
|
||||||
|
catch (ParseException e) {
|
||||||
|
Log.d(LOG_TAG, "Bad romance format");
|
||||||
|
}
|
||||||
|
}
|
||||||
else if (key.startsWith("note")) {
|
else if (key.startsWith("note")) {
|
||||||
where.add("(" + dbMap.get(key) + " LIKE ? AND "
|
where.add("(" + dbMap.get(key) + " LIKE ? AND "
|
||||||
+ ContactsContract.Data.MIMETYPE + " = ? )");
|
+ ContactsContract.Data.MIMETYPE + " = ? )");
|
||||||
|
Loading…
Reference in New Issue
Block a user