From 2c1ce39b78d648169ea175d55852bec0184c3096 Mon Sep 17 00:00:00 2001 From: M66B Date: Fri, 4 Mar 2022 08:26:25 +0100 Subject: [PATCH] Show image file size --- .../java/eu/faircode/email/AdapterImage.java | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/AdapterImage.java b/app/src/main/java/eu/faircode/email/AdapterImage.java index 9ac68a39c8..a5f0dbd8b4 100644 --- a/app/src/main/java/eu/faircode/email/AdapterImage.java +++ b/app/src/main/java/eu/faircode/email/AdapterImage.java @@ -107,6 +107,8 @@ public class AdapterImage extends RecyclerView.Adapter String type = args.getString("type"); int max = args.getInt("max"); + args.putLong("size", file.length()); + try { BitmapFactory.Options options = new BitmapFactory.Options(); options.inJustDecodeBounds = true; @@ -140,10 +142,22 @@ public class AdapterImage extends RecyclerView.Adapter image instanceof AnimatedImageDrawable) ((AnimatedImageDrawable) image).start(); + StringBuilder sb = new StringBuilder(); + int width = args.getInt("width"); int height = args.getInt("height"); - if (width > 0 && height > 0) { - tvProperties.setText(String.format("%d \u00d7 %d", width, height)); + if (width > 0 && height > 0) + sb.append(width).append(" \u00d7 ").append(width); + + long size = args.getLong("size"); + if (size > 0) { + if (sb.length() > 0) + sb.append(" \u2013 "); + sb.append(Helper.humanReadableByteCount(size)); + } + + if (sb.length() > 0) { + tvProperties.setText(sb); tvProperties.setVisibility(View.VISIBLE); } }