diff --git a/app/src/main/java/eu/faircode/email/AdapterAttachment.java b/app/src/main/java/eu/faircode/email/AdapterAttachment.java index 943ecc8064..49af22299b 100644 --- a/app/src/main/java/eu/faircode/email/AdapterAttachment.java +++ b/app/src/main/java/eu/faircode/email/AdapterAttachment.java @@ -48,7 +48,11 @@ import androidx.recyclerview.widget.DiffUtil; import androidx.recyclerview.widget.ListUpdateCallback; import androidx.recyclerview.widget.RecyclerView; +import java.io.BufferedInputStream; import java.io.File; +import java.io.FileInputStream; +import java.io.InputStream; +import java.security.MessageDigest; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; @@ -79,6 +83,7 @@ public class AdapterAttachment extends RecyclerView.Adapter() { + @Override + protected String onExecute(Context context, Bundle args) throws Throwable { + long id = args.getLong("id"); + + DB db = DB.getInstance(context); + EntityAttachment attachment = db.attachment().getAttachment(id); + if (attachment == null) + return null; + + MessageDigest digest = MessageDigest.getInstance("SHA-256"); + + try (InputStream is = new BufferedInputStream(new FileInputStream(attachment.getFile(context)))) { + int count; + byte[] buffer = new byte[1024]; + while ((count = is.read(buffer)) != -1) + digest.update(buffer, 0, count); + } + + return Helper.hex(digest.digest()); + } + + @Override + protected void onExecuted(Bundle args, String hash) { + if (hash == null) + return; + + Uri uri = Uri.parse(Helper.URI_VIRUS_TOTAL + "gui/file/" + hash); + Helper.view(context, uri, false); + } + + @Override + protected void onException(Bundle args, Throwable ex) { + Log.unexpectedError(parentFragment.getParentFragmentManager(), ex); + } + }.execute(context, owner, args, "attachment:scan"); + } + private void onShare(EntityAttachment attachment) { String title = (attachment.name == null ? attachment.cid : attachment.name); Helper.share(context, attachment.getFile(context), attachment.getMimeType(), title); diff --git a/app/src/main/java/eu/faircode/email/Helper.java b/app/src/main/java/eu/faircode/email/Helper.java index 2f4c77f5ee..2c9e077798 100644 --- a/app/src/main/java/eu/faircode/email/Helper.java +++ b/app/src/main/java/eu/faircode/email/Helper.java @@ -201,6 +201,7 @@ public class Helper { static final String DONTKILL_URI = "https://dontkillmyapp.com/"; static final String URI_SUPPORT_RESET_OPEN = "https://support.google.com/pixelphone/answer/6271667"; static final String URI_SUPPORT_CONTACT_GROUP = "https://support.google.com/contacts/answer/30970"; + static final String URI_VIRUS_TOTAL = "https://www.virustotal.com/"; // https://developer.android.com/distribute/marketing-tools/linking-to-google-play#PerformingSearch private static final String PLAY_STORE_SEARCH = "https://play.google.com/store/search"; diff --git a/app/src/main/res/drawable/twotone_travel_explore_24.xml b/app/src/main/res/drawable/twotone_travel_explore_24.xml new file mode 100644 index 0000000000..93adef5e72 --- /dev/null +++ b/app/src/main/res/drawable/twotone_travel_explore_24.xml @@ -0,0 +1,10 @@ + + + diff --git a/app/src/main/res/layout/item_attachment.xml b/app/src/main/res/layout/item_attachment.xml index df8f08e4f5..2be359b18a 100644 --- a/app/src/main/res/layout/item_attachment.xml +++ b/app/src/main/res/layout/item_attachment.xml @@ -79,10 +79,23 @@ android:padding="6dp" android:scaleType="fitCenter" app:layout_constraintBottom_toBottomOf="@+id/tvType" - app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintEnd_toStartOf="@+id/ibScan" app:layout_constraintTop_toTopOf="parent" app:srcCompat="@drawable/twotone_save_alt_24" /> + + Synchronization state Download state Save + Scan Delete Count Folder type