From 310f39d1e3648764d5eb860cba490613106cd71c Mon Sep 17 00:00:00 2001 From: M66B Date: Tue, 18 Aug 2020 17:29:51 +0200 Subject: [PATCH] Show icon single source/target folder --- .../eu/faircode/email/FragmentMessages.java | 35 ++++++++++++++++--- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/FragmentMessages.java b/app/src/main/java/eu/faircode/email/FragmentMessages.java index 086381a48e..b0703963b2 100644 --- a/app/src/main/java/eu/faircode/email/FragmentMessages.java +++ b/app/src/main/java/eu/faircode/email/FragmentMessages.java @@ -7293,6 +7293,19 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences. this.name = folder.name; this.display = folder.getDisplayName(context); } + + @Override + public boolean equals(Object other) { + if (other instanceof Folder) + return this.id == ((Folder) other).id; + else + return false; + } + + @Override + public int hashCode() { + return Objects.hash(id); + } } } @@ -7554,15 +7567,27 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences. tvSourceFolders.setText(getDisplay(result, false)); tvTargetFolders.setText(getDisplay(result, true)); + List sources = new ArrayList<>(); + List targets = new ArrayList<>(); + for (MessageTarget t : result) { + if (!sources.contains(t.sourceFolder)) + sources.add(t.sourceFolder); + if (!targets.contains(t.targetFolder)) + targets.add(t.targetFolder); + } + Drawable source = null; - Drawable target = null; - if (result.size() == 1) { - source = getResources().getDrawable(EntityFolder.getIcon(result.get(0).sourceFolder.type), null); - target = getResources().getDrawable(EntityFolder.getIcon(result.get(0).targetFolder.type), null); + if (sources.size() == 1) { + source = getResources().getDrawable(EntityFolder.getIcon(sources.get(0).type), null); if (source != null) source.setBounds(0, 0, source.getIntrinsicWidth(), source.getIntrinsicHeight()); + } + + Drawable target = null; + if (targets.size() == 1) { + target = getResources().getDrawable(EntityFolder.getIcon(targets.get(0).type), null); if (target != null) - target.setBounds(0, 0, target.getIntrinsicWidth(), source.getIntrinsicHeight()); + target.setBounds(0, 0, target.getIntrinsicWidth(), target.getIntrinsicHeight()); } tvSourceFolders.setCompoundDrawablesRelative(source, null, null, null);