mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-11-23 17:22:16 -05:00
improve sharing of key
This commit is contained in:
parent
a966d1afa1
commit
6f1dbc2f74
@ -8,25 +8,43 @@
|
|||||||
android:title="@string/menu_share">
|
android:title="@string/menu_share">
|
||||||
<menu>
|
<menu>
|
||||||
<item
|
<item
|
||||||
android:id="@+id/menu_key_view_share_default"
|
android:id="@+id/menu_key_view_share_fingerprint_title"
|
||||||
android:showAsAction="never"
|
android:showAsAction="never"
|
||||||
android:title="@string/menu_share"/>
|
android:title="@string/menu_share_title_fingerprint">
|
||||||
|
<menu>
|
||||||
|
<item
|
||||||
|
android:id="@+id/menu_key_view_share_default_fingerprint"
|
||||||
|
android:showAsAction="never"
|
||||||
|
android:title="@string/menu_share_default_fingerprint"/>
|
||||||
|
<item
|
||||||
|
android:id="@+id/menu_key_view_share_qr_code_fingerprint"
|
||||||
|
android:showAsAction="never"
|
||||||
|
android:title="@string/menu_share_qr_code_fingerprint"/>
|
||||||
|
</menu>
|
||||||
|
</item>
|
||||||
<item
|
<item
|
||||||
android:id="@+id/menu_key_view_share_qr_code_fingerprint"
|
android:id="@+id/menu_key_view_share_title"
|
||||||
android:showAsAction="never"
|
android:showAsAction="never"
|
||||||
android:title="@string/menu_share_qr_code_fingerprint"/>
|
android:title="@string/menu_share_title">
|
||||||
<item
|
<menu>
|
||||||
android:id="@+id/menu_key_view_share_qr_code"
|
<item
|
||||||
android:showAsAction="never"
|
android:id="@+id/menu_key_view_share_default"
|
||||||
android:title="@string/menu_share_qr_code"/>
|
android:showAsAction="never"
|
||||||
<item
|
android:title="@string/menu_share_default"/>
|
||||||
android:id="@+id/menu_key_view_share_nfc"
|
<item
|
||||||
android:showAsAction="never"
|
android:id="@+id/menu_key_view_share_qr_code"
|
||||||
android:title="@string/menu_share_nfc"/>
|
android:showAsAction="never"
|
||||||
<item
|
android:title="@string/menu_share_qr_code"/>
|
||||||
android:id="@+id/menu_key_view_share_clipboard"
|
<item
|
||||||
android:showAsAction="never"
|
android:id="@+id/menu_key_view_share_nfc"
|
||||||
android:title="@string/menu_copy_to_clipboard"/>
|
android:showAsAction="never"
|
||||||
|
android:title="@string/menu_share_nfc"/>
|
||||||
|
<item
|
||||||
|
android:id="@+id/menu_key_view_share_clipboard"
|
||||||
|
android:showAsAction="never"
|
||||||
|
android:title="@string/menu_copy_to_clipboard"/>
|
||||||
|
</menu>
|
||||||
|
</item>
|
||||||
</menu>
|
</menu>
|
||||||
</item>
|
</item>
|
||||||
<item
|
<item
|
||||||
|
@ -84,10 +84,15 @@
|
|||||||
<string name="menu_key_server">Import from key server</string>
|
<string name="menu_key_server">Import from key server</string>
|
||||||
<string name="menu_update_key">Update from key server</string>
|
<string name="menu_update_key">Update from key server</string>
|
||||||
<string name="menu_export_key_to_server">Upload to key server</string>
|
<string name="menu_export_key_to_server">Upload to key server</string>
|
||||||
<string name="menu_share">Share with…</string>
|
<string name="menu_share">Share</string>
|
||||||
<string name="menu_share_qr_code">Share with QR Code (whole key)</string>
|
<string name="menu_share_title_fingerprint">Share fingerprint…</string>
|
||||||
<string name="menu_share_qr_code_fingerprint">Share with QR Code (fingerprint)</string>
|
<string name="menu_share_title">Share data…</string>
|
||||||
<string name="menu_share_nfc">Share with NFC</string>
|
|
||||||
|
<string name="menu_share_default_fingerprint">with…</string>
|
||||||
|
<string name="menu_share_default">with…</string>
|
||||||
|
<string name="menu_share_qr_code">with QR Code</string>
|
||||||
|
<string name="menu_share_qr_code_fingerprint">with QR Code</string>
|
||||||
|
<string name="menu_share_nfc">with NFC</string>
|
||||||
<string name="menu_copy_to_clipboard">Copy to clipboard</string>
|
<string name="menu_copy_to_clipboard">Copy to clipboard</string>
|
||||||
<string name="menu_sign_key">Sign key</string>
|
<string name="menu_sign_key">Sign key</string>
|
||||||
<string name="menu_beam_preferences">Beam settings</string>
|
<string name="menu_beam_preferences">Beam settings</string>
|
||||||
@ -211,6 +216,7 @@
|
|||||||
<string name="key_copied_to_clipboard">Key has been copied to the clipboard!</string>
|
<string name="key_copied_to_clipboard">Key has been copied to the clipboard!</string>
|
||||||
<string name="key_has_already_been_signed">Key has already been signed!</string>
|
<string name="key_has_already_been_signed">Key has already been signed!</string>
|
||||||
<string name="select_key_to_sign">Please select a key to be used for signing!</string>
|
<string name="select_key_to_sign">Please select a key to be used for signing!</string>
|
||||||
|
<string name="key_too_big_for_sharing">Key is too big to be shared this way!</string>
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
errors
|
errors
|
||||||
|
@ -166,8 +166,11 @@ public class ViewKeyActivity extends SherlockFragmentActivity implements CreateN
|
|||||||
mExportHelper.showExportKeysDialog(mDataUri, Id.type.public_key, Constants.path.APP_DIR
|
mExportHelper.showExportKeysDialog(mDataUri, Id.type.public_key, Constants.path.APP_DIR
|
||||||
+ "/pubexport.asc");
|
+ "/pubexport.asc");
|
||||||
return true;
|
return true;
|
||||||
|
case R.id.menu_key_view_share_default_fingerprint:
|
||||||
|
shareKey(mDataUri, true);
|
||||||
|
return true;
|
||||||
case R.id.menu_key_view_share_default:
|
case R.id.menu_key_view_share_default:
|
||||||
shareKey(mDataUri);
|
shareKey(mDataUri, false);
|
||||||
return true;
|
return true;
|
||||||
case R.id.menu_key_view_share_qr_code_fingerprint:
|
case R.id.menu_key_view_share_qr_code_fingerprint:
|
||||||
shareKeyQrCode(mDataUri, true);
|
shareKeyQrCode(mDataUri, true);
|
||||||
@ -435,15 +438,37 @@ public class ViewKeyActivity extends SherlockFragmentActivity implements CreateN
|
|||||||
startActivity(signIntent);
|
startActivity(signIntent);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void shareKey(Uri dataUri) {
|
private void shareKey(Uri dataUri, boolean fingerprintOnly) {
|
||||||
// get public keyring as ascii armored string
|
String content = null;
|
||||||
long masterKeyId = ProviderHelper.getMasterKeyId(this, dataUri);
|
if (fingerprintOnly) {
|
||||||
ArrayList<String> keyringArmored = ProviderHelper.getKeyRingsAsArmoredString(this, dataUri,
|
long masterKeyId = ProviderHelper.getMasterKeyId(this, dataUri);
|
||||||
new long[] { masterKeyId });
|
|
||||||
|
// TODO: dublicated in ShareQrCodeDialog
|
||||||
|
content = "openpgp4fpr:";
|
||||||
|
|
||||||
|
String fingerprint = PgpKeyHelper.convertKeyToHex(masterKeyId);
|
||||||
|
|
||||||
|
content = content + fingerprint;
|
||||||
|
} else {
|
||||||
|
// get public keyring as ascii armored string
|
||||||
|
long masterKeyId = ProviderHelper.getMasterKeyId(this, dataUri);
|
||||||
|
ArrayList<String> keyringArmored = ProviderHelper.getKeyRingsAsArmoredString(this,
|
||||||
|
dataUri, new long[] { masterKeyId });
|
||||||
|
|
||||||
|
content = keyringArmored.get(0);
|
||||||
|
|
||||||
|
// Android will fail with android.os.TransactionTooLargeException if key is too big
|
||||||
|
// see http://www.lonestarprod.com/?p=34
|
||||||
|
if (content.length() >= 86389) {
|
||||||
|
Toast.makeText(getApplicationContext(), R.string.key_too_big_for_sharing,
|
||||||
|
Toast.LENGTH_LONG).show();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// let user choose application
|
// let user choose application
|
||||||
Intent sendIntent = new Intent(Intent.ACTION_SEND);
|
Intent sendIntent = new Intent(Intent.ACTION_SEND);
|
||||||
sendIntent.putExtra(Intent.EXTRA_TEXT, keyringArmored.get(0));
|
sendIntent.putExtra(Intent.EXTRA_TEXT, content);
|
||||||
sendIntent.setType("text/plain");
|
sendIntent.setType("text/plain");
|
||||||
startActivity(Intent.createChooser(sendIntent,
|
startActivity(Intent.createChooser(sendIntent,
|
||||||
getResources().getText(R.string.action_share_key_with)));
|
getResources().getText(R.string.action_share_key_with)));
|
||||||
|
Loading…
Reference in New Issue
Block a user