aboutsummaryrefslogtreecommitdiffstats
path: root/src/org/thialfihar/android/apg/provider/DataProvider.java
diff options
context:
space:
mode:
authorThialfihar <thialfihar@gmail.com>2010-06-05 21:47:16 +0000
committerThialfihar <thialfihar@gmail.com>2010-06-05 21:47:16 +0000
commit84d00abea113c6561519c2481245eff0253b15a2 (patch)
treed4e6b9056ef856f8ab6a96c7375ff45b3a1945a4 /src/org/thialfihar/android/apg/provider/DataProvider.java
parenta089dbbb73b3bddb122e14db2165cb1cded269e1 (diff)
downloadopen-keychain-84d00abea113c6561519c2481245eff0253b15a2.tar.gz
open-keychain-84d00abea113c6561519c2481245eff0253b15a2.tar.bz2
open-keychain-84d00abea113c6561519c2481245eff0253b15a2.zip
added search feature for key management and select Activities
Diffstat (limited to 'src/org/thialfihar/android/apg/provider/DataProvider.java')
-rw-r--r--src/org/thialfihar/android/apg/provider/DataProvider.java40
1 files changed, 18 insertions, 22 deletions
diff --git a/src/org/thialfihar/android/apg/provider/DataProvider.java b/src/org/thialfihar/android/apg/provider/DataProvider.java
index 8a3fefdff..0667d82dd 100644
--- a/src/org/thialfihar/android/apg/provider/DataProvider.java
+++ b/src/org/thialfihar/android/apg/provider/DataProvider.java
@@ -72,6 +72,7 @@ public class DataProvider extends ContentProvider {
private static final String USER_ID_CONTENT_ITEM_TYPE =
"vnd.android.cursor.item/vnd.thialfihar.apg.user_id";
+ public static final String _ID = "_id";
public static final String MASTER_KEY_ID = "master_key_id";
public static final String KEY_ID = "key_id";
public static final String USER_ID = "user_id";
@@ -117,6 +118,7 @@ public class DataProvider extends ContentProvider {
// TODO: implement the others, then use them for the lists
SQLiteQueryBuilder qb = new SQLiteQueryBuilder();
HashMap<String, String> projectionMap = new HashMap<String, String>();
+
int match = mUriMatcher.match(uri);
int type;
switch (match) {
@@ -148,28 +150,17 @@ public class DataProvider extends ContentProvider {
qb.appendWhere(KeyRings.TABLE_NAME + "." + KeyRings.TYPE + " = " + type);
switch (match) {
- case PUBLIC_KEY_RINGS:
- case SECRET_KEY_RINGS: {
- qb.setTables(KeyRings.TABLE_NAME + " INNER JOIN " + Keys.TABLE_NAME + " ON " +
- "(" + KeyRings.TABLE_NAME + "." + KeyRings._ID + " = " +
- Keys.TABLE_NAME + "." + Keys.KEY_RING_ID + " AND " +
- Keys.TABLE_NAME + "." + Keys.IS_MASTER_KEY + " = '1'" +
- ") " +
- " INNER JOIN " + UserIds.TABLE_NAME + " ON " +
- "(" + Keys.TABLE_NAME + "." + Keys._ID + " = " +
- UserIds.TABLE_NAME + "." + UserIds.KEY_ID + " AND " +
- UserIds.TABLE_NAME + "." + UserIds.RANK + " = '0') ");
-
- projectionMap.put(MASTER_KEY_ID,
- KeyRings.TABLE_NAME + "." + KeyRings.MASTER_KEY_ID);
- projectionMap.put(USER_ID,
- UserIds.TABLE_NAME + "." + UserIds.USER_ID);
+ case PUBLIC_KEY_RING_ID:
+ case SECRET_KEY_RING_ID: {
+ qb.appendWhere(" AND " +
+ KeyRings.TABLE_NAME + "." + KeyRings.MASTER_KEY_ID + " = ");
+ qb.appendWhereEscapeString(uri.getPathSegments().get(2));
- break;
+ // break omitted intentionally
}
- case PUBLIC_KEY_RING_ID:
- case SECRET_KEY_RING_ID: {
+ case PUBLIC_KEY_RINGS:
+ case SECRET_KEY_RINGS: {
qb.setTables(KeyRings.TABLE_NAME + " INNER JOIN " + Keys.TABLE_NAME + " ON " +
"(" + KeyRings.TABLE_NAME + "." + KeyRings._ID + " = " +
Keys.TABLE_NAME + "." + Keys.KEY_RING_ID + " AND " +
@@ -180,14 +171,17 @@ public class DataProvider extends ContentProvider {
UserIds.TABLE_NAME + "." + UserIds.KEY_ID + " AND " +
UserIds.TABLE_NAME + "." + UserIds.RANK + " = '0') ");
+ projectionMap.put(_ID,
+ KeyRings.TABLE_NAME + "." + KeyRings._ID);
projectionMap.put(MASTER_KEY_ID,
KeyRings.TABLE_NAME + "." + KeyRings.MASTER_KEY_ID);
projectionMap.put(USER_ID,
UserIds.TABLE_NAME + "." + UserIds.USER_ID);
- qb.appendWhere(" AND " +
- KeyRings.TABLE_NAME + "." + KeyRings.MASTER_KEY_ID + " = ");
- qb.appendWhereEscapeString(uri.getPathSegments().get(2));
+ if (TextUtils.isEmpty(sortOrder)) {
+ sortOrder = UserIds.TABLE_NAME + "." + UserIds.USER_ID + " ASC";
+ }
+
break;
}
@@ -207,6 +201,8 @@ public class DataProvider extends ContentProvider {
UserIds.TABLE_NAME + "." + UserIds.KEY_ID + " AND " +
UserIds.TABLE_NAME + "." + UserIds.RANK + " = '0') ");
+ projectionMap.put(_ID,
+ KeyRings.TABLE_NAME + "." + KeyRings._ID);
projectionMap.put(MASTER_KEY_ID,
KeyRings.TABLE_NAME + "." + KeyRings.MASTER_KEY_ID);
projectionMap.put(USER_ID,