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 | |
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
8 files changed, 92 insertions, 53 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); + } + } diff --git a/OpenKeychain/src/main/res/layout/view_key_main_fragment.xml b/OpenKeychain/src/main/res/layout/view_key_main_fragment.xml index 27e0ab22e..38769324e 100644 --- a/OpenKeychain/src/main/res/layout/view_key_main_fragment.xml +++ b/OpenKeychain/src/main/res/layout/view_key_main_fragment.xml @@ -110,6 +110,28 @@ android:drawablePadding="8dp" android:gravity="center_vertical" /> + <View + android:layout_width="match_parent" + android:layout_height="1dip" + android:background="?android:attr/listDivider" /> + + <TextView + android:id="@+id/view_key_action_update" + android:paddingLeft="8dp" + android:paddingRight="8dp" + android:layout_marginBottom="8dp" + android:textAppearance="?android:attr/textAppearanceMedium" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:minHeight="?android:attr/listPreferredItemHeight" + android:clickable="true" + style="@style/SelectableItem" + android:text="@string/key_view_action_update" + android:layout_weight="1" + android:drawableRight="@drawable/ic_action_download" + android:drawablePadding="8dp" + android:gravity="center_vertical" /> + </LinearLayout> </ScrollView> diff --git a/OpenKeychain/src/main/res/layout/view_key_share_fragment.xml b/OpenKeychain/src/main/res/layout/view_key_share_fragment.xml index 1cd2b9f1b..a8786c461 100644 --- a/OpenKeychain/src/main/res/layout/view_key_share_fragment.xml +++ b/OpenKeychain/src/main/res/layout/view_key_share_fragment.xml @@ -129,6 +129,29 @@ android:layout_height="1dip" android:background="?android:attr/listDivider" /> + <TextView + android:id="@+id/view_key_action_upload" + android:paddingLeft="8dp" + android:paddingRight="8dp" + android:layout_marginBottom="8dp" + android:textAppearance="?android:attr/textAppearanceMedium" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:minHeight="?android:attr/listPreferredItemHeight" + android:clickable="true" + style="@style/SelectableItem" + android:text="@string/key_view_action_upload" + android:layout_weight="1" + android:drawableRight="@drawable/ic_action_upload" + android:drawablePadding="8dp" + android:gravity="center_vertical" + android:editable="false" /> + + <View + android:layout_width="match_parent" + android:layout_height="1dip" + android:background="?android:attr/listDivider" /> + <LinearLayout android:id="@+id/view_key_action_nfc_help" android:layout_width="match_parent" diff --git a/OpenKeychain/src/main/res/menu/key_view.xml b/OpenKeychain/src/main/res/menu/key_view.xml index 64877d725..5a156b5ac 100644 --- a/OpenKeychain/src/main/res/menu/key_view.xml +++ b/OpenKeychain/src/main/res/menu/key_view.xml @@ -3,23 +3,6 @@ xmlns:app="http://schemas.android.com/apk/res-auto"> <item - android:id="@+id/menu_key_keyserver" - android:icon="@drawable/ic_action_cloud" - app:showAsAction="always" - android:title="@string/menu_key_server"> - <menu> - <item - android:id="@+id/menu_key_view_update" - app:showAsAction="never" - android:title="@string/menu_update_key" /> - <item - android:id="@+id/menu_key_view_export_keyserver" - app:showAsAction="never" - android:title="@string/menu_export_key_to_server" /> - </menu> - </item> - - <item android:id="@+id/menu_key_view_export_file" android:icon="@drawable/ic_action_import_export" app:showAsAction="never" diff --git a/OpenKeychain/src/main/res/values/strings.xml b/OpenKeychain/src/main/res/values/strings.xml index 70a70d238..9d2c5efb5 100644 --- a/OpenKeychain/src/main/res/values/strings.xml +++ b/OpenKeychain/src/main/res/values/strings.xml @@ -82,8 +82,6 @@ <string name="menu_import_existing_key">Import existing key</string> <string name="menu_search">Search</string> <string name="menu_key_server">Keyserver…</string> - <string name="menu_update_key">Update from keyserver</string> - <string name="menu_export_key_to_server">Upload to key server</string> <string name="menu_share">Share…</string> <string name="menu_share_title_fingerprint">Share fingerprint…</string> <string name="menu_share_title">Share whole key…</string> @@ -482,8 +480,10 @@ <string name="key_view_action_edit">Edit key</string> <string name="key_view_action_encrypt">Encrypt with this key</string> <string name="key_view_action_certify">Certify identities</string> + <string name="key_view_action_update">Update from keyserver</string> <string name="key_view_action_share_with">Share with…</string> <string name="key_view_action_share_nfc">Share over NFC by holding the devices back to back</string> + <string name="key_view_action_upload">Upload to key server</string> <string name="key_view_tab_main">Main Info</string> <string name="key_view_tab_share">Share</string> <string name="key_view_tab_keys">Subkeys</string> |