Show icon single source/target folder

This commit is contained in:
M66B 2020-08-18 17:29:51 +02:00
parent e3ea98e43a
commit 310f39d1e3
1 changed files with 30 additions and 5 deletions

View File

@ -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<MessageTarget.Folder> sources = new ArrayList<>();
List<MessageTarget.Folder> 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);