aboutsummaryrefslogtreecommitdiffstats
path: root/OpenKeychain
diff options
context:
space:
mode:
authorDominik Schürmann <dominik@dominikschuermann.de>2014-08-05 00:23:04 +0200
committerDominik Schürmann <dominik@dominikschuermann.de>2014-08-05 00:23:04 +0200
commit80408460a0aa16c38dc5b3269061bac85306d24a (patch)
tree8453d5502e45d4b00359da7e89a9ba8ba0ff42ba /OpenKeychain
parentde6950377cf8954ec5be1f07fb360e07fd0547b8 (diff)
downloadopen-keychain-80408460a0aa16c38dc5b3269061bac85306d24a.tar.gz
open-keychain-80408460a0aa16c38dc5b3269061bac85306d24a.tar.bz2
open-keychain-80408460a0aa16c38dc5b3269061bac85306d24a.zip
KeychainContract: use longs instead of String, other fixes
Diffstat (limited to 'OpenKeychain')
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/helper/ContactHelper.java2
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/CachedPublicKeyRing.java2
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainContract.java26
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/ProviderHelper.java14
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyFragment.java29
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyCertsFragment.java2
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/SubkeysAdapter.java10
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/DeleteKeyDialogFragment.java2
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/EncryptKeyCompletionView.java2
-rw-r--r--OpenKeychain/src/main/res/values/strings.xml2
10 files changed, 56 insertions, 35 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/helper/ContactHelper.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/helper/ContactHelper.java
index 8fed40a86..1d8661bfe 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/helper/ContactHelper.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/helper/ContactHelper.java
@@ -385,7 +385,7 @@ public class ContactHelper {
int rawContactId, long masterKeyId) {
ops.add(selectByRawContactAndItemType(ContentProviderOperation.newDelete(ContactsContract.Data.CONTENT_URI),
rawContactId, ContactsContract.CommonDataKinds.Email.CONTENT_ITEM_TYPE).build());
- Cursor ids = resolver.query(KeychainContract.UserIds.buildUserIdsUri(Long.toString(masterKeyId)),
+ Cursor ids = resolver.query(KeychainContract.UserIds.buildUserIdsUri(masterKeyId),
USER_IDS_PROJECTION, NON_REVOKED_SELECTION, null, null);
if (ids != null) {
while (ids.moveToNext()) {
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/CachedPublicKeyRing.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/CachedPublicKeyRing.java
index 89acbd488..e076fd9cc 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/CachedPublicKeyRing.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/CachedPublicKeyRing.java
@@ -218,7 +218,7 @@ public class CachedPublicKeyRing extends KeyRing {
}
private Cursor getSubkeys() throws PgpGeneralException {
- Uri keysUri = KeychainContract.Keys.buildKeysUri(Long.toString(extractOrGetMasterKeyId()));
+ Uri keysUri = KeychainContract.Keys.buildKeysUri(extractOrGetMasterKeyId());
return mProviderHelper.getContentResolver().query(keysUri, null, null, null, null);
}
}
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainContract.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainContract.java
index 483f762f7..56168847f 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainContract.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainContract.java
@@ -172,8 +172,8 @@ public class KeychainContract {
return CONTENT_URI.buildUpon().appendPath(PATH_PUBLIC).build();
}
- public static Uri buildPublicKeyRingUri(String masterKeyId) {
- return CONTENT_URI.buildUpon().appendPath(masterKeyId).appendPath(PATH_PUBLIC).build();
+ public static Uri buildPublicKeyRingUri(long masterKeyId) {
+ return CONTENT_URI.buildUpon().appendPath(Long.toString(masterKeyId)).appendPath(PATH_PUBLIC).build();
}
public static Uri buildPublicKeyRingUri(Uri uri) {
@@ -184,8 +184,8 @@ public class KeychainContract {
return CONTENT_URI.buildUpon().appendPath(PATH_SECRET).build();
}
- public static Uri buildSecretKeyRingUri(String masterKeyId) {
- return CONTENT_URI.buildUpon().appendPath(masterKeyId).appendPath(PATH_SECRET).build();
+ public static Uri buildSecretKeyRingUri(long masterKeyId) {
+ return CONTENT_URI.buildUpon().appendPath(Long.toString(masterKeyId)).appendPath(PATH_SECRET).build();
}
public static Uri buildSecretKeyRingUri(Uri uri) {
@@ -210,8 +210,8 @@ public class KeychainContract {
public static final String CONTENT_ITEM_TYPE
= "vnd.android.cursor.item/vnd.org.sufficientlysecure.keychain.provider.keychain.keys";
- public static Uri buildKeysUri(String masterKeyId) {
- return CONTENT_URI.buildUpon().appendPath(masterKeyId).appendPath(PATH_KEYS).build();
+ public static Uri buildKeysUri(long masterKeyId) {
+ return CONTENT_URI.buildUpon().appendPath(Long.toString(masterKeyId)).appendPath(PATH_KEYS).build();
}
public static Uri buildKeysUri(Uri uri) {
@@ -237,8 +237,8 @@ public class KeychainContract {
public static final String CONTENT_ITEM_TYPE
= "vnd.android.cursor.item/vnd.org.sufficientlysecure.keychain.provider.user_ids";
- public static Uri buildUserIdsUri(String masterKeyId) {
- return CONTENT_URI.buildUpon().appendPath(masterKeyId).appendPath(PATH_USER_IDS).build();
+ public static Uri buildUserIdsUri(long masterKeyId) {
+ return CONTENT_URI.buildUpon().appendPath(Long.toString(masterKeyId)).appendPath(PATH_USER_IDS).build();
}
public static Uri buildUserIdsUri(Uri uri) {
@@ -304,12 +304,14 @@ public class KeychainContract {
public static final Uri CONTENT_URI = BASE_CONTENT_URI_INTERNAL.buildUpon()
.appendPath(BASE_KEY_RINGS).build();
- public static Uri buildCertsUri(String masterKeyId) {
- return CONTENT_URI.buildUpon().appendPath(masterKeyId).appendPath(PATH_CERTS).build();
+ public static Uri buildCertsUri(long masterKeyId) {
+ return CONTENT_URI.buildUpon().appendPath(Long.toString(masterKeyId)).appendPath(PATH_CERTS).build();
}
- public static Uri buildCertsSpecificUri(String masterKeyId, String rank, String certifier) {
- return CONTENT_URI.buildUpon().appendPath(masterKeyId).appendPath(PATH_CERTS).appendPath(rank).appendPath(certifier).build();
+ public static Uri buildCertsSpecificUri(long masterKeyId, long rank, long certifier) {
+ return CONTENT_URI.buildUpon().appendPath(Long.toString(masterKeyId))
+ .appendPath(PATH_CERTS).appendPath(Long.toString(rank))
+ .appendPath(Long.toString(certifier)).build();
}
public static Uri buildCertsUri(Uri uri) {
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/ProviderHelper.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/ProviderHelper.java
index aa85577e0..e79771ed6 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/ProviderHelper.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/ProviderHelper.java
@@ -299,7 +299,7 @@ public class ProviderHelper {
return SaveKeyringResult.RESULT_ERROR;
}
- Uri uri = KeyRingData.buildPublicKeyRingUri(Long.toString(masterKeyId));
+ Uri uri = KeyRingData.buildPublicKeyRingUri(masterKeyId);
operations.add(ContentProviderOperation.newInsert(uri).withValues(values).build());
}
@@ -307,7 +307,7 @@ public class ProviderHelper {
progress.setProgress(LogType.MSG_IP_INSERT_SUBKEYS.getMsgId(), 40, 100);
mIndent += 1;
{ // insert subkeys
- Uri uri = Keys.buildKeysUri(Long.toString(masterKeyId));
+ Uri uri = Keys.buildKeysUri(masterKeyId);
int rank = 0;
for (CanonicalizedPublicKey key : keyRing.publicKeyIterator()) {
long keyId = key.getKeyId();
@@ -498,7 +498,7 @@ public class ProviderHelper {
try {
// delete old version of this keyRing, which also deletes all keys and userIds on cascade
int deleted = mContentResolver.delete(
- KeyRingData.buildPublicKeyRingUri(Long.toString(masterKeyId)), null, null);
+ KeyRingData.buildPublicKeyRingUri(masterKeyId), null, null);
if (deleted > 0) {
log(LogLevel.DEBUG, LogType.MSG_IP_DELETE_OLD_OK);
result |= SaveKeyringResult.UPDATED;
@@ -567,7 +567,7 @@ public class ProviderHelper {
values.put(KeyRingData.MASTER_KEY_ID, masterKeyId);
values.put(KeyRingData.KEY_RING_DATA, keyRing.getEncoded());
// insert new version of this keyRing
- Uri uri = KeyRingData.buildSecretKeyRingUri(Long.toString(masterKeyId));
+ Uri uri = KeyRingData.buildSecretKeyRingUri(masterKeyId);
if (mContentResolver.insert(uri, values) == null) {
log(LogLevel.ERROR, LogType.MSG_IS_DB_EXCEPTION);
return SaveKeyringResult.RESULT_ERROR;
@@ -579,7 +579,7 @@ public class ProviderHelper {
}
{
- Uri uri = Keys.buildKeysUri(Long.toString(masterKeyId));
+ Uri uri = Keys.buildKeysUri(masterKeyId);
// first, mark all keys as not available
ContentValues values = new ContentValues();
@@ -836,7 +836,7 @@ public class ProviderHelper {
values.put(Certs.VERIFIED, verified);
values.put(Certs.DATA, cert.getEncoded());
- Uri uri = Certs.buildCertsUri(Long.toString(masterKeyId));
+ Uri uri = Certs.buildCertsUri(masterKeyId);
return ContentProviderOperation.newInsert(uri).withValues(values).build();
}
@@ -853,7 +853,7 @@ public class ProviderHelper {
values.put(UserIds.IS_REVOKED, item.isRevoked);
values.put(UserIds.RANK, rank);
- Uri uri = UserIds.buildUserIdsUri(Long.toString(masterKeyId));
+ Uri uri = UserIds.buildUserIdsUri(masterKeyId);
return ContentProviderOperation.newInsert(uri).withValues(values).build();
}
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyFragment.java
index 2d8bdad27..7460b73b4 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyFragment.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyFragment.java
@@ -45,6 +45,7 @@ import org.sufficientlysecure.keychain.helper.ActionBarHelper;
import org.sufficientlysecure.keychain.pgp.CanonicalizedSecretKeyRing;
import org.sufficientlysecure.keychain.pgp.KeyRing;
import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException;
+import org.sufficientlysecure.keychain.provider.CachedPublicKeyRing;
import org.sufficientlysecure.keychain.provider.KeychainContract;
import org.sufficientlysecure.keychain.provider.ProviderHelper;
import org.sufficientlysecure.keychain.service.KeychainIntentService;
@@ -215,8 +216,7 @@ public class EditKeyFragment extends LoaderFragment implements
mUserIdsList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
- String userId = mUserIdsAdapter.getUserId(position);
- editUserId(userId);
+ editUserId(position);
}
});
@@ -230,8 +230,7 @@ public class EditKeyFragment extends LoaderFragment implements
mSubkeysList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
- long keyId = mSubkeysAdapter.getKeyId(position);
- editSubkey(keyId);
+ editSubkey(position);
}
});
@@ -320,7 +319,9 @@ public class EditKeyFragment extends LoaderFragment implements
setPassphraseDialog.show(getActivity().getSupportFragmentManager(), "setPassphraseDialog");
}
- private void editUserId(final String userId) {
+ private void editUserId(final int position) {
+ final String userId = mUserIdsAdapter.getUserId(position);
+
Handler returnHandler = new Handler() {
@Override
public void handleMessage(Message message) {
@@ -360,13 +361,15 @@ public class EditKeyFragment extends LoaderFragment implements
});
}
- private void editSubkey(final long keyId) {
+ private void editSubkey(final int position) {
+ final long keyId = mSubkeysAdapter.getKeyId(position);
+
Handler returnHandler = new Handler() {
@Override
public void handleMessage(Message message) {
switch (message.what) {
case EditSubkeyDialogFragment.MESSAGE_CHANGE_EXPIRY:
- editSubkeyExpiry(keyId);
+ editSubkeyExpiry(position);
break;
case EditSubkeyDialogFragment.MESSAGE_REVOKE:
// toggle
@@ -394,13 +397,19 @@ public class EditKeyFragment extends LoaderFragment implements
});
}
- private void editSubkeyExpiry(final long keyId) {
+ private void editSubkeyExpiry(final int position) {
+ final long keyId = mSubkeysAdapter.getKeyId(position);
+ final Date creationDate = new Date(mSubkeysAdapter.getCreationDate(position));
+ final Date expiryDate = new Date(mSubkeysAdapter.getExpiryDate(position));
+
Handler returnHandler = new Handler() {
@Override
public void handleMessage(Message message) {
switch (message.what) {
case ChangeExpiryDialogFragment.MESSAGE_NEW_EXPIRY_DATE:
- // toggle
+// SaveKeyringParcel.SubkeyChange subkeyChange = new SaveKeyringParcel.SubkeyChange();
+
+// mSaveKeyringParcel.mChangeSubKeys.add()
// if (mSaveKeyringParcel.changePrimaryUserId != null
// && mSaveKeyringParcel.changePrimaryUserId.equals(userId)) {
// mSaveKeyringParcel.changePrimaryUserId = null;
@@ -419,7 +428,7 @@ public class EditKeyFragment extends LoaderFragment implements
DialogFragmentWorkaround.INTERFACE.runnableRunDelayed(new Runnable() {
public void run() {
ChangeExpiryDialogFragment dialogFragment =
- ChangeExpiryDialogFragment.newInstance(messenger, new Date(), new Date());
+ ChangeExpiryDialogFragment.newInstance(messenger, creationDate, expiryDate);
dialogFragment.show(getActivity().getSupportFragmentManager(), "editSubkeyExpiryDialog");
}
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyCertsFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyCertsFragment.java
index e98562690..5a55b0dad 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyCertsFragment.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyCertsFragment.java
@@ -150,7 +150,7 @@ public class ViewKeyCertsFragment extends LoaderFragment
Intent viewIntent = new Intent(getActivity(), ViewCertActivity.class);
viewIntent.setData(Certs.buildCertsSpecificUri(
- Long.toString(masterKeyId), Long.toString(rank), Long.toString(certifierId)));
+ masterKeyId, rank, certifierId));
startActivity(viewIntent);
}
}
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/SubkeysAdapter.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/SubkeysAdapter.java
index 0d8c7240d..25b3c0fc5 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/SubkeysAdapter.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/SubkeysAdapter.java
@@ -90,6 +90,16 @@ public class SubkeysAdapter extends CursorAdapter {
return mCursor.getLong(INDEX_KEY_ID);
}
+ public long getCreationDate(int position) {
+ mCursor.moveToPosition(position);
+ return mCursor.getLong(INDEX_CREATION);
+ }
+
+ public long getExpiryDate(int position) {
+ mCursor.moveToPosition(position);
+ return mCursor.getLong(INDEX_EXPIRY);
+ }
+
@Override
public Cursor swapCursor(Cursor newCursor) {
hasAnySecret = false;
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/DeleteKeyDialogFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/DeleteKeyDialogFragment.java
index 01d2fae6a..4927a4d24 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/DeleteKeyDialogFragment.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/DeleteKeyDialogFragment.java
@@ -123,7 +123,7 @@ public class DeleteKeyDialogFragment extends DialogFragment {
boolean success = false;
for (long masterKeyId : masterKeyIds) {
int count = activity.getContentResolver().delete(
- KeyRingData.buildPublicKeyRingUri(Long.toString(masterKeyId)), null, null
+ KeyRingData.buildPublicKeyRingUri(masterKeyId), null, null
);
success = count > 0;
}
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/EncryptKeyCompletionView.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/EncryptKeyCompletionView.java
index c730e5662..03b0d658f 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/EncryptKeyCompletionView.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/EncryptKeyCompletionView.java
@@ -69,7 +69,7 @@ public class EncryptKeyCompletionView extends TokenCompleteTextView {
private void initView() {
swapCursor(null);
- setPrefix(getContext().getString(R.string.label_to) + ": ");
+ setPrefix(getContext().getString(R.string.label_to));
allowDuplicates(false);
}
diff --git a/OpenKeychain/src/main/res/values/strings.xml b/OpenKeychain/src/main/res/values/strings.xml
index 122fa20b1..ed5dca813 100644
--- a/OpenKeychain/src/main/res/values/strings.xml
+++ b/OpenKeychain/src/main/res/values/strings.xml
@@ -92,7 +92,7 @@
<string name="label_conceal_pgp_application">Let others know that you\'re using OpenKeychain</string>
<string name="label_conceal_pgp_application_summary">Writes \'OpenKeychain v2.7\' to OpenPGP signatures, ciphertext, and exported keys</string>
<string name="label_asymmetric_from">From:</string>
- <string name="label_to">To</string>
+ <string name="label_to">To:</string>
<string name="label_delete_after_encryption">Files: Delete After Encryption</string>
<string name="label_delete_after_decryption">Delete After Decryption</string>
<string name="label_encryption_algorithm">Encryption Algorithm</string>