mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-11-05 08:45:08 -05:00
Merge branch 'master' of github.com:open-keychain/open-keychain
This commit is contained in:
commit
08ae9db4ee
@ -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 {
|
||||
|
@ -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() {
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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>
|
||||
|
@ -124,6 +124,29 @@
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
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"
|
||||
|
@ -2,23 +2,6 @@
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
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"
|
||||
|
@ -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>
|
||||
|
Loading…
Reference in New Issue
Block a user