diff options
author | Dominik <dominik@dominikschuermann.de> | 2012-03-12 14:28:35 +0100 |
---|---|---|
committer | Dominik <dominik@dominikschuermann.de> | 2012-03-12 14:28:35 +0100 |
commit | 87e456e77c570f3e17cfdadf5db23cd1733033ea (patch) | |
tree | b05c30af8351d723cf9a385f7f7d55ed05db2792 /org_apg/src/org/apg/ui/SelectPublicKeyListAdapter.java | |
parent | f350c266795e7824b009807d30fbcd6a9a32e0dd (diff) | |
download | open-keychain-87e456e77c570f3e17cfdadf5db23cd1733033ea.tar.gz open-keychain-87e456e77c570f3e17cfdadf5db23cd1733033ea.tar.bz2 open-keychain-87e456e77c570f3e17cfdadf5db23cd1733033ea.zip |
refactoring...
Diffstat (limited to 'org_apg/src/org/apg/ui/SelectPublicKeyListAdapter.java')
-rw-r--r-- | org_apg/src/org/apg/ui/SelectPublicKeyListAdapter.java | 70 |
1 files changed, 30 insertions, 40 deletions
diff --git a/org_apg/src/org/apg/ui/SelectPublicKeyListAdapter.java b/org_apg/src/org/apg/ui/SelectPublicKeyListAdapter.java index b2f49f74a..93844601b 100644 --- a/org_apg/src/org/apg/ui/SelectPublicKeyListAdapter.java +++ b/org_apg/src/org/apg/ui/SelectPublicKeyListAdapter.java @@ -20,7 +20,6 @@ import java.util.Date; import org.apg.Apg; import org.apg.Id; -import org.apg.Id.database; import org.apg.provider.KeyRings; import org.apg.provider.Keys; import org.apg.provider.UserIds; @@ -48,25 +47,23 @@ public class SelectPublicKeyListAdapter extends BaseAdapter { protected String mSearchString; protected Activity mActivity; - public SelectPublicKeyListAdapter(Activity activity, ListView parent, - String searchString, long selectedKeyIds[]) { + public SelectPublicKeyListAdapter(Activity activity, ListView parent, String searchString, + long selectedKeyIds[]) { mSearchString = searchString; mActivity = activity; mParent = parent; - mDatabase = Apg.getDatabase().db(); - mInflater = (LayoutInflater) parent.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); + mDatabase = Apg.getDatabase().db(); + mInflater = (LayoutInflater) parent.getContext().getSystemService( + Context.LAYOUT_INFLATER_SERVICE); long now = new Date().getTime() / 1000; SQLiteQueryBuilder qb = new SQLiteQueryBuilder(); - 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') "); + 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') "); String inIdList = null; @@ -83,10 +80,9 @@ public class SelectPublicKeyListAdapter extends BaseAdapter { if (searchString != null && searchString.trim().length() > 0) { String[] chunks = searchString.trim().split(" +"); - qb.appendWhere("(EXISTS (SELECT tmp." + UserIds._ID + " FROM " + - UserIds.TABLE_NAME + " AS tmp WHERE " + - "tmp." + UserIds.KEY_ID + " = " + - Keys.TABLE_NAME + "." + Keys._ID); + qb.appendWhere("(EXISTS (SELECT tmp." + UserIds._ID + " FROM " + UserIds.TABLE_NAME + + " AS tmp WHERE " + "tmp." + UserIds.KEY_ID + " = " + Keys.TABLE_NAME + "." + + Keys._ID); for (int i = 0; i < chunks.length; ++i) { qb.appendWhere(" AND tmp." + UserIds.USER_ID + " LIKE "); qb.appendWhereEscapeString("%" + chunks[i] + "%"); @@ -103,28 +99,22 @@ public class SelectPublicKeyListAdapter extends BaseAdapter { orderBy = inIdList + " DESC, " + orderBy; } - mCursor = qb.query(mDatabase, - new String[] { - KeyRings.TABLE_NAME + "." + KeyRings._ID, // 0 - KeyRings.TABLE_NAME + "." + KeyRings.MASTER_KEY_ID, // 1 - UserIds.TABLE_NAME + "." + UserIds.USER_ID, // 2 - "(SELECT COUNT(tmp." + Keys._ID + ") FROM " + Keys.TABLE_NAME + " AS tmp WHERE " + - "tmp." + Keys.KEY_RING_ID + " = " + - KeyRings.TABLE_NAME + "." + KeyRings._ID + " AND " + - "tmp." + Keys.IS_REVOKED + " = '0' AND " + - "tmp." + Keys.CAN_ENCRYPT + " = '1')", // 3 - "(SELECT COUNT(tmp." + Keys._ID + ") FROM " + Keys.TABLE_NAME + " AS tmp WHERE " + - "tmp." + Keys.KEY_RING_ID + " = " + - KeyRings.TABLE_NAME + "." + KeyRings._ID + " AND " + - "tmp." + Keys.IS_REVOKED + " = '0' AND " + - "tmp." + Keys.CAN_ENCRYPT + " = '1' AND " + - "tmp." + Keys.CREATION + " <= '" + now + "' AND " + - "(tmp." + Keys.EXPIRY + " IS NULL OR " + - "tmp." + Keys.EXPIRY + " >= '" + now + "'))", // 4 - }, - KeyRings.TABLE_NAME + "." + KeyRings.TYPE + " = ?", - new String[] { "" + Id.database.type_public }, - null, null, orderBy); + mCursor = qb.query(mDatabase, new String[] { + KeyRings.TABLE_NAME + "." + KeyRings._ID, // 0 + KeyRings.TABLE_NAME + "." + KeyRings.MASTER_KEY_ID, // 1 + UserIds.TABLE_NAME + "." + UserIds.USER_ID, // 2 + "(SELECT COUNT(tmp." + Keys._ID + ") FROM " + Keys.TABLE_NAME + " AS tmp WHERE " + + "tmp." + Keys.KEY_RING_ID + " = " + KeyRings.TABLE_NAME + "." + + KeyRings._ID + " AND " + "tmp." + Keys.IS_REVOKED + " = '0' AND " + + "tmp." + Keys.CAN_ENCRYPT + " = '1')", // 3 + "(SELECT COUNT(tmp." + Keys._ID + ") FROM " + Keys.TABLE_NAME + " AS tmp WHERE " + + "tmp." + Keys.KEY_RING_ID + " = " + KeyRings.TABLE_NAME + "." + + KeyRings._ID + " AND " + "tmp." + Keys.IS_REVOKED + " = '0' AND " + + "tmp." + Keys.CAN_ENCRYPT + " = '1' AND " + "tmp." + Keys.CREATION + + " <= '" + now + "' AND " + "(tmp." + Keys.EXPIRY + " IS NULL OR " + + "tmp." + Keys.EXPIRY + " >= '" + now + "'))", // 4 + }, KeyRings.TABLE_NAME + "." + KeyRings.TYPE + " = ?", new String[] { "" + + Id.database.type_public }, null, null, orderBy); activity.startManagingCursor(mCursor); } |