1
0
Fork 0
mirror of https://github.com/M66B/FairEmail.git synced 2025-03-04 02:28:18 +00:00

Analyze public key

This commit is contained in:
M66B 2024-12-27 20:31:13 +01:00
parent aed28d31db
commit 21deb1ff69
2 changed files with 38 additions and 1 deletions

View file

@ -21,11 +21,13 @@ package eu.faircode.email;
import android.content.Context;
import android.graphics.Typeface;
import android.net.Uri;
import android.os.Bundle;
import android.text.SpannableString;
import android.text.TextUtils;
import android.text.style.RelativeSizeSpan;
import android.text.style.StyleSpan;
import android.util.Base64;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
@ -105,7 +107,9 @@ public class AdapterCertificate extends RecyclerView.Adapter<AdapterCertificate.
popupMenu.getMenu().add(Menu.NONE, 0, 0, ss).setEnabled(false);
popupMenu.getMenu().add(Menu.NONE, R.string.title_share, 1, R.string.title_share);
popupMenu.getMenu().add(Menu.NONE, R.string.title_delete, 2, R.string.title_delete);
if (!Helper.isPlayStoreInstall())
popupMenu.getMenu().add(Menu.NONE, R.string.title_analyze, 2, R.string.title_analyze);
popupMenu.getMenu().add(Menu.NONE, R.string.title_delete, 3, R.string.title_delete);
popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
@Override
@ -114,6 +118,9 @@ public class AdapterCertificate extends RecyclerView.Adapter<AdapterCertificate.
if (id == R.string.title_share) {
onActionShare();
return true;
} else if (id == R.string.title_analyze) {
onActionAnalyze();
return true;
} else if (id == R.string.title_delete) {
onActionDelete();
return true;
@ -158,6 +165,35 @@ public class AdapterCertificate extends RecyclerView.Adapter<AdapterCertificate.
}.execute(context, owner, args, "certificate:share");
}
private void onActionAnalyze() {
Bundle args = new Bundle();
args.putLong("id", certificate.id);
new SimpleTask<String>() {
@Override
protected String onExecute(Context context, Bundle args) throws CertificateException, IOException {
long id = args.getLong("id");
DB db = DB.getInstance(context);
EntityCertificate certificate = db.certificate().getCertificate(id);
if (certificate == null)
return null;
return Base64.encodeToString(certificate.getCertificate().getEncoded(), Base64.URL_SAFE);
}
@Override
protected void onExecuted(Bundle args, String cert) {
Helper.view(context, Uri.parse("https://lapo.it/asn1js/#" + cert), true);
}
@Override
protected void onException(Bundle args, Throwable ex) {
Log.unexpectedError(parentFragment.getParentFragmentManager(), ex);
}
}.execute(context, owner, args, "certificate:share");
}
private void onActionDelete() {
Bundle args = new Bundle();
args.putLong("id", certificate.id);

View file

@ -1552,6 +1552,7 @@
<string name="title_force_light">Force light theme</string>
<string name="title_rename">Rename</string>
<string name="title_share">Share</string>
<string name="title_analyze">Analyze</string>
<string name="title_share_link" translatable="false">Share link</string>
<string name="title_share_link_open" translatable="false">Open message</string>
<string name="title_zip" translatable="false">ZIP</string>