aboutsummaryrefslogtreecommitdiffstats
path: root/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListFragment.java
diff options
context:
space:
mode:
authorVincent Breitmoser <valodim@mugenguild.com>2014-04-03 01:34:35 +0200
committerVincent Breitmoser <valodim@mugenguild.com>2014-04-03 01:34:35 +0200
commita7eff41ced8b5622f6ed96a5b834677314ae7ca8 (patch)
tree71318819663ee55d3466624be68377a237452800 /OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListFragment.java
parentacc2e208cf0ac4ecd5daaddfe844b37fa8057432 (diff)
downloadopen-keychain-a7eff41ced8b5622f6ed96a5b834677314ae7ca8.tar.gz
open-keychain-a7eff41ced8b5622f6ed96a5b834677314ae7ca8.tar.bz2
open-keychain-a7eff41ced8b5622f6ed96a5b834677314ae7ca8.zip
Break a lot of stuff. Also, database redesign.
Change entire database design. This introduces a lot of changes, notably all URIs and almost all projections. Some features (like key deletion) have been simply commented out for now since they need serious reconsideration. There are a couple of new TODOs marking places where more work is needed. The migration path works fine from what I tested. The old database is not deleted for now, ie, it is reimported at every start of the application making all intermediate changes transient. Tested and working (for me): - All activities in the main drawer - Multiselect and Search - ViewKeyActivity, with and without secret key available - CertifyKeyActivity - SelectSecretKeyActivity (from CertifyKeyActivity) - SelectPublicKeyActivity (from encrypt activity) What doesn't work: - Actually certifying keys (pending a TODO in ProviderHelper) - Importing keys doesn't preserve secret keys - "Encrypt to this contact" doesn't pass key - Editing keys. All controls are disabled, I'm not sure why... (is this even my fault?) - Deleting keys What I didn't test: - Key export - API stuff - Creating keys (since editing doesn't even work)
Diffstat (limited to 'OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListFragment.java')
-rw-r--r--OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListFragment.java31
1 files changed, 16 insertions, 15 deletions
diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListFragment.java
index 957c822d2..573ddd1a7 100644
--- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListFragment.java
+++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListFragment.java
@@ -186,6 +186,7 @@ public class KeyListFragment extends Fragment
case R.id.menu_key_list_multi_export: {
ids = mStickyList.getWrappedList().getCheckedItemIds();
long[] masterKeyIds = new long[2*ids.length];
+ /* TODO! redo
ArrayList<Long> allPubRowIds =
ProviderHelper.getPublicKeyRingsRowIds(getActivity());
for (int i = 0; i < ids.length; i++) {
@@ -194,7 +195,7 @@ public class KeyListFragment extends Fragment
} else {
masterKeyIds[i] = ProviderHelper.getSecretMasterKeyId(getActivity(), ids[i]);
}
- }
+ }*/
ExportHelper mExportHelper = new ExportHelper((ActionBarActivity) getActivity());
mExportHelper
.showExportKeysDialog(masterKeyIds, Id.type.public_key,
@@ -254,22 +255,22 @@ public class KeyListFragment extends Fragment
// These are the rows that we will retrieve.
static final String[] PROJECTION = new String[]{
KeychainContract.KeyRings._ID,
- KeychainContract.KeyRings.TYPE,
- KeychainContract.KeyRings.MASTER_KEY_ID,
+ KeychainContract.Keys.MASTER_KEY_ID,
KeychainContract.UserIds.USER_ID,
- KeychainContract.Keys.IS_REVOKED
+ KeychainContract.Keys.IS_REVOKED,
+ KeychainDatabase.Tables.KEY_RINGS_SECRET + "." + KeychainContract.KeyRings.MASTER_KEY_ID
};
- static final int INDEX_TYPE = 1;
- static final int INDEX_MASTER_KEY_ID = 2;
- static final int INDEX_USER_ID = 3;
- static final int INDEX_IS_REVOKED = 4;
+ static final int INDEX_MASTER_KEY_ID = 1;
+ static final int INDEX_USER_ID = 2;
+ static final int INDEX_IS_REVOKED = 3;
+ static final int INDEX_HAS_SECRET = 4;
static final String SORT_ORDER =
// show secret before public key
- KeychainDatabase.Tables.KEY_RINGS + "." + KeyRings.TYPE + " DESC, "
+ KeychainDatabase.Tables.KEY_RINGS_SECRET + "." + KeychainContract.KeyRings.MASTER_KEY_ID + " IS NULL ASC, " +
// sort by user id otherwise
- + UserIds.USER_ID + " ASC";
+ UserIds.USER_ID + " ASC";
@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
@@ -326,7 +327,7 @@ public class KeyListFragment extends Fragment
}
viewIntent.setData(
KeychainContract
- .KeyRings.buildPublicKeyRingsByMasterKeyIdUri(
+ .KeyRings.buildPublicKeyRingUri(
Long.toString(mAdapter.getMasterKeyId(position))));
startActivity(viewIntent);
}
@@ -503,7 +504,7 @@ public class KeyListFragment extends Fragment
Button button = (Button) view.findViewById(R.id.edit);
TextView revoked = (TextView) view.findViewById(R.id.revoked);
- if (cursor.getInt(KeyListFragment.INDEX_TYPE) == KeyTypes.SECRET) {
+ if (!cursor.isNull(KeyListFragment.INDEX_HAS_SECRET)) {
// this is a secret key - show the edit button
statusDivider.setVisibility(View.VISIBLE);
statusLayout.setVisibility(View.VISIBLE);
@@ -516,7 +517,7 @@ public class KeyListFragment extends Fragment
Intent editIntent = new Intent(getActivity(), EditKeyActivity.class);
editIntent.setData(
KeychainContract.KeyRings
- .buildSecretKeyRingsByMasterKeyIdUri(Long.toString(id)));
+ .buildSecretKeyRingUri(Long.toString(id)));
editIntent.setAction(EditKeyActivity.ACTION_EDIT_KEY);
startActivityForResult(editIntent, 0);
}
@@ -577,7 +578,7 @@ public class KeyListFragment extends Fragment
throw new IllegalStateException("couldn't move cursor to position " + position);
}
- if (mCursor.getInt(KeyListFragment.INDEX_TYPE) == KeyTypes.SECRET) {
+ if (!mCursor.isNull(KeyListFragment.INDEX_HAS_SECRET)) {
{ // set contact count
int num = mCursor.getCount();
String contactsTotal = getResources().getQuantityString(R.plurals.n_contacts, num, num);
@@ -617,7 +618,7 @@ public class KeyListFragment extends Fragment
}
// early breakout: all secret keys are assigned id 0
- if (mCursor.getInt(KeyListFragment.INDEX_TYPE) == KeyTypes.SECRET) {
+ if (!mCursor.isNull(KeyListFragment.INDEX_HAS_SECRET)) {
return 1L;
}
// otherwise, return the first character of the name as ID