From 5c35f0cbf0aec22b4b169204a906ec6a21122bee Mon Sep 17 00:00:00 2001 From: Arne Date: Thu, 5 Sep 2024 21:40:10 +0200 Subject: [PATCH] Apply option to show less avatars --- .../eu/siacs/conversations/ui/adapter/MessageAdapter.java | 8 +++++++- src/main/res/layout/item_message_received.xml | 3 ++- src/main/res/layout/item_message_sent.xml | 3 ++- src/main/res/values/bools.xml | 1 + src/main/res/values/strings.xml | 2 ++ src/main/res/xml/preferences_interface.xml | 5 +++++ 6 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java b/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java index 0bc33cfcb..652ac54e7 100644 --- a/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java +++ b/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java @@ -1105,6 +1105,9 @@ public class MessageAdapter extends ArrayAdapter { viewHolder.message_box_inner = view.findViewById(R.id.message_box_inner); viewHolder.message_box = view.findViewById(R.id.message_box); viewHolder.contact_picture = view.findViewById(R.id.message_photo); + if (activity.xmppConnectionService != null && !activity.xmppConnectionService.getBooleanPreference("show_less_avatars", R.bool.show_less_avatars)) { + viewHolder.contact_picture.setVisibility(View.VISIBLE); + } viewHolder.download_button = view.findViewById(R.id.download_button); viewHolder.indicator = view.findViewById(R.id.security_indicator); viewHolder.edit_indicator = view.findViewById(R.id.edit_indicator); @@ -1125,6 +1128,9 @@ public class MessageAdapter extends ArrayAdapter { viewHolder.message_box_inner = view.findViewById(R.id.message_box_inner); viewHolder.message_box = view.findViewById(R.id.message_box); viewHolder.contact_picture = view.findViewById(R.id.message_photo); + if (message.getConversation().getMode() == Conversation.MODE_SINGLE && activity.xmppConnectionService.getBooleanPreference("show_less_avatars", R.bool.show_less_avatars)) { + viewHolder.contact_picture.setVisibility(View.GONE); + } viewHolder.download_button = view.findViewById(R.id.download_button); viewHolder.indicator = view.findViewById(R.id.security_indicator); viewHolder.edit_indicator = view.findViewById(R.id.edit_indicator); @@ -1292,7 +1298,7 @@ public class MessageAdapter extends ArrayAdapter { } else if (message.getCounterpart() != null || message.getTrueCounterpart() != null || (message.getCounterparts() != null - && message.getCounterparts().size() > 0)) { + && !message.getCounterparts().isEmpty())) { showAvatar = true; AvatarWorkerTask.loadAvatar( message, viewHolder.contact_picture, R.dimen.avatar_on_status_message); diff --git a/src/main/res/layout/item_message_received.xml b/src/main/res/layout/item_message_received.xml index de9717852..ba1a16529 100644 --- a/src/main/res/layout/item_message_received.xml +++ b/src/main/res/layout/item_message_received.xml @@ -34,7 +34,8 @@ android:layout_alignParentStart="true" android:layout_alignParentTop="true" android:layout_marginEnd="0dp" - android:scaleType="centerCrop" /> + android:scaleType="centerCrop" + android:visibility="visible" /> + android:scaleType="centerCrop" + android:visibility="gone" /> diff --git a/src/main/res/values/bools.xml b/src/main/res/values/bools.xml index fc3a0ed39..8df72ca1e 100644 --- a/src/main/res/values/bools.xml +++ b/src/main/res/values/bools.xml @@ -1,4 +1,5 @@ true + true diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml index b4c182fb1..57060ab90 100644 --- a/src/main/res/values/strings.xml +++ b/src/main/res/values/strings.xml @@ -1079,4 +1079,6 @@ Do you really want to retract this message? Show avatar Block avatar + Show less avatars + Show only needed avatars in the chats diff --git a/src/main/res/xml/preferences_interface.xml b/src/main/res/xml/preferences_interface.xml index f5040143a..f955b83c9 100644 --- a/src/main/res/xml/preferences_interface.xml +++ b/src/main/res/xml/preferences_interface.xml @@ -91,6 +91,11 @@ android:icon="@drawable/ic_delete_24dp" android:summary="@string/pref_delete_background_summary" android:title="@string/delete_background" /> +