diff options
author | Dominik Schürmann <dominik@dominikschuermann.de> | 2014-07-31 23:54:11 +0200 |
---|---|---|
committer | Dominik Schürmann <dominik@dominikschuermann.de> | 2014-07-31 23:54:11 +0200 |
commit | 08ae9db4eeeecb865943b2b1386b3a845ed4e0fb (patch) | |
tree | a424b1ba90a2a7db32650e4af13bb47a29c9293d /OpenKeychain/src/main/java | |
parent | 55b764eb1d39a8f07286454cfce952fb459b7a89 (diff) | |
parent | faf3868f017cae72a7c90a622004fc87bdd1cb5d (diff) | |
download | open-keychain-08ae9db4eeeecb865943b2b1386b3a845ed4e0fb.tar.gz open-keychain-08ae9db4eeeecb865943b2b1386b3a845ed4e0fb.tar.bz2 open-keychain-08ae9db4eeeecb865943b2b1386b3a845ed4e0fb.zip |
Merge branch 'master' of github.com:open-keychain/open-keychain
Diffstat (limited to 'OpenKeychain/src/main/java')
4 files changed, 45 insertions, 34 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/HkpKeyserver.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/HkpKeyserver.java index 43bed8397..41f1e6997 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/HkpKeyserver.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/HkpKeyserver.java @@ -285,9 +285,9 @@ public class HkpKeyserver extends Keyserver { // group 1 contains the full fingerprint (v4) or the long key id if available // see http://bit.ly/1d4bxbk and http://bit.ly/1gD1wwr - String fingerprintOrKeyId = matcher.group(1); + String fingerprintOrKeyId = matcher.group(1).toLowerCase(Locale.US); if (fingerprintOrKeyId.length() > 16) { - entry.setFingerprintHex(fingerprintOrKeyId.toLowerCase(Locale.US)); + entry.setFingerprintHex(fingerprintOrKeyId); entry.setKeyIdHex("0x" + fingerprintOrKeyId.substring(fingerprintOrKeyId.length() - 16, fingerprintOrKeyId.length())); } else { diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java index b6b35a804..c5f4d482d 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java @@ -89,8 +89,6 @@ public class ViewKeyActivity extends ActionBarActivity implements private ImageView mStatusImage; private View mStatusDivider; - public static final int REQUEST_CODE_LOOKUP_KEY = 0x00007006; - // NFC private NfcAdapter mNfcAdapter; private NfcAdapter.CreateNdefMessageCallback mNdefCallback; @@ -262,14 +260,6 @@ public class ViewKeyActivity extends ActionBarActivity implements startActivity(homeIntent); return true; } - case R.id.menu_key_view_update: { - updateFromKeyserver(mDataUri, mProviderHelper); - return true; - } - case R.id.menu_key_view_export_keyserver: { - uploadToKeyserver(mDataUri); - return true; - } case R.id.menu_key_view_export_file: { exportToFile(mDataUri, mExportHelper, mProviderHelper); return true; @@ -311,26 +301,6 @@ public class ViewKeyActivity extends ActionBarActivity implements ); } - private void uploadToKeyserver(Uri dataUri) throws ProviderHelper.NotFoundException { - Intent uploadIntent = new Intent(this, UploadKeyActivity.class); - uploadIntent.setData(dataUri); - startActivityForResult(uploadIntent, 0); - } - - private void updateFromKeyserver(Uri dataUri, ProviderHelper providerHelper) - throws ProviderHelper.NotFoundException { - byte[] blob = (byte[]) providerHelper.getGenericData( - KeychainContract.KeyRings.buildUnifiedKeyRingUri(dataUri), - KeychainContract.Keys.FINGERPRINT, ProviderHelper.FIELD_TYPE_BLOB); - String fingerprint = PgpKeyHelper.convertFingerprintToHex(blob); - - Intent queryIntent = new Intent(this, ImportKeysActivity.class); - queryIntent.setAction(ImportKeysActivity.ACTION_IMPORT_KEY_FROM_KEYSERVER_AND_RETURN_RESULT); - queryIntent.putExtra(ImportKeysActivity.EXTRA_FINGERPRINT, fingerprint); - - startActivityForResult(queryIntent, REQUEST_CODE_LOOKUP_KEY); - } - private void deleteKey(Uri dataUri, ExportHelper exportHelper) { // Message is received after key is deleted Handler returnHandler = new Handler() { diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyMainFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyMainFragment.java index a156ff5f1..370a7312f 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyMainFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyMainFragment.java @@ -33,11 +33,13 @@ import android.widget.ListView; import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.R; +import org.sufficientlysecure.keychain.pgp.PgpKeyHelper; import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException; import org.sufficientlysecure.keychain.provider.KeychainContract; import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings; import org.sufficientlysecure.keychain.provider.KeychainContract.UserIds; import org.sufficientlysecure.keychain.provider.ProviderHelper; +import org.sufficientlysecure.keychain.provider.ProviderHelper.NotFoundException; import org.sufficientlysecure.keychain.ui.adapter.UserIdsAdapter; import org.sufficientlysecure.keychain.util.Log; import org.sufficientlysecure.keychain.util.Notify; @@ -55,7 +57,7 @@ public class ViewKeyMainFragment extends LoaderFragment implements private View mActionCertify; private View mActionCertifyText; private ImageView mActionCertifyImage; - private View mActionCertifyDivider; + private View mActionUpdate; private ListView mUserIds; @@ -84,7 +86,7 @@ public class ViewKeyMainFragment extends LoaderFragment implements // make certify image gray, like action icons mActionCertifyImage.setColorFilter(getResources().getColor(R.color.tertiary_text_light), PorterDuff.Mode.SRC_IN); - mActionCertifyDivider = view.findViewById(R.id.view_key_action_certify_divider); + mActionUpdate = view.findViewById(R.id.view_key_action_update); return root; } @@ -124,6 +126,15 @@ public class ViewKeyMainFragment extends LoaderFragment implements editKey(mDataUri); } }); + mActionUpdate.setOnClickListener(new View.OnClickListener() { + public void onClick(View view) { + try { + updateFromKeyserver(mDataUri, new ProviderHelper(getActivity())); + } catch (NotFoundException e) { + Notify.showNotify(getActivity(), R.string.error_key_not_found, Notify.Style.ERROR); + } + } + }); mUserIdsAdapter = new UserIdsAdapter(getActivity(), null, 0); mUserIds.setAdapter(mUserIdsAdapter); @@ -254,6 +265,20 @@ public class ViewKeyMainFragment extends LoaderFragment implements } } + private void updateFromKeyserver(Uri dataUri, ProviderHelper providerHelper) + throws ProviderHelper.NotFoundException { + byte[] blob = (byte[]) providerHelper.getGenericData( + KeychainContract.KeyRings.buildUnifiedKeyRingUri(dataUri), + KeychainContract.Keys.FINGERPRINT, ProviderHelper.FIELD_TYPE_BLOB); + String fingerprint = PgpKeyHelper.convertFingerprintToHex(blob); + + Intent queryIntent = new Intent(getActivity(), ImportKeysActivity.class); + queryIntent.setAction(ImportKeysActivity.ACTION_IMPORT_KEY_FROM_KEYSERVER_AND_RETURN_RESULT); + queryIntent.putExtra(ImportKeysActivity.EXTRA_FINGERPRINT, fingerprint); + + startActivityForResult(queryIntent, 0); + } + private void certify(Uri dataUri) { Intent signIntent = new Intent(getActivity(), CertifyKeyActivity.class); signIntent.setData(dataUri); diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyShareFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyShareFragment.java index e81d5dbf7..54ab76464 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyShareFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyShareFragment.java @@ -49,6 +49,7 @@ import org.sufficientlysecure.keychain.provider.KeychainContract; import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings; import org.sufficientlysecure.keychain.provider.KeychainContract.Keys; import org.sufficientlysecure.keychain.provider.ProviderHelper; +import org.sufficientlysecure.keychain.provider.ProviderHelper.NotFoundException; import org.sufficientlysecure.keychain.ui.dialog.ShareNfcDialogFragment; import org.sufficientlysecure.keychain.util.Log; import org.sufficientlysecure.keychain.util.Notify; @@ -70,6 +71,7 @@ public class ViewKeyShareFragment extends LoaderFragment implements private View mKeyClipboardButton; private View mNfcHelpButton; private View mNfcPrefsButton; + private View mKeyUploadButton; ProviderHelper mProviderHelper; @@ -94,6 +96,7 @@ public class ViewKeyShareFragment extends LoaderFragment implements mKeyClipboardButton = view.findViewById(R.id.view_key_action_key_clipboard); mNfcHelpButton = view.findViewById(R.id.view_key_action_nfc_help); mNfcPrefsButton = view.findViewById(R.id.view_key_action_nfc_prefs); + mKeyUploadButton = view.findViewById(R.id.view_key_action_upload); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { mNfcPrefsButton.setVisibility(View.VISIBLE); @@ -144,6 +147,12 @@ public class ViewKeyShareFragment extends LoaderFragment implements showNfcPrefs(); } }); + mKeyUploadButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + uploadToKeyserver(); + } + }); return root; } @@ -345,4 +354,11 @@ public class ViewKeyShareFragment extends LoaderFragment implements loadTask.execute(); } + + private void uploadToKeyserver() { + Intent uploadIntent = new Intent(getActivity(), UploadKeyActivity.class); + uploadIntent.setData(mDataUri); + startActivityForResult(uploadIntent, 0); + } + } |