cheogram-android

created pr with cheogram-android/webxdc-thread-name.1 on 2026-11-03T18:38:01Z · by 9e834e0d
cmds
checkout latest patchset:
ssh pr.pico.sh pull cheogram-android:webxdc-thread-name | git am -3
checkout specific patchset revision:
ssh pr.pico.sh pull cheogram-android:webxdc-thread-name [rev] | git am -3
add changes to patch request:
git format-patch main --stdout | ssh pr.pico.sh cheogram-android:webxdc-thread-name
add comment to patch request:
ssh pr.pico.sh comment cheogram-android:webxdc-thread-name "lgtm!"

Patchset cheogram-android/webxdc-thread-name.1 on 2026-11-03T18:38:01Z · commit e0881e2

Fall back to webxdc name or filename
Stephen Paul Weber 2026-11-03T18:37:32Z
If no subject or body for thread label
Semantic diff summary
0 added, 0 modified, 0 signature changed, 0 removed across 0 analyzed files (3 files skipped: unsupported file type)
+14 -1 src/main/java/eu/siacs/conversations/entities/Conversation.java #
......@@ -4245,11 +4245,24 @@ public class Conversation extends AbstractEntity
42454245 }
42464246
42474247 public String getDisplay() {
4248+ return getDisplay(null);
4249+ }
4250+
4251+ public String getDisplay(final Function<Message, String> webxdcNameResolver) {
42484252 final String s = getSubject();
42494253 if (s != null) return s;
42504254
42514255 if (first != null) {
4252- return first.getBody();
4256+ final String body = first.getBody();
4257+ if (body != null && !body.trim().isEmpty()) return body;
4258+
4259+ if (webxdcNameResolver != null) {
4260+ final String webxdcName = webxdcNameResolver.apply(first);
4261+ if (webxdcName != null) return webxdcName;
4262+ }
4263+
4264+ final String fileName = first.getFileParams().getName();
4265+ if (fileName != null) return fileName;
42534266 }
42544267
42554268 return "";
+20 -1 src/main/java/eu/siacs/conversations/ui/ConferenceDetailsActivity.java #
......@@ -35,6 +35,7 @@ import androidx.core.content.ContextCompat;
3535 import androidx.databinding.DataBindingUtil;
3636
3737 import com.cheogram.android.Util;
38+import com.cheogram.android.WebxdcPage;
3839
3940 import com.google.android.material.dialog.MaterialAlertDialogBuilder;
4041 import com.google.android.material.color.MaterialColors;
......@@ -63,6 +64,7 @@ import eu.siacs.conversations.entities.Account;
6364 import eu.siacs.conversations.entities.Contact;
6465 import eu.siacs.conversations.entities.Conversation;
6566 import eu.siacs.conversations.entities.ListItem;
67+import eu.siacs.conversations.entities.Message;
6668 import eu.siacs.conversations.entities.MucOptions;
6769 import eu.siacs.conversations.entities.MucOptions.User;
6870 import eu.siacs.conversations.services.XmppConnectionService;
......@@ -989,6 +991,23 @@ public class ConferenceDetailsActivity extends XmppActivity
989991 class ThreadAdapter extends ArrayAdapter<Conversation.Thread> {
990992 ThreadAdapter() { super(ConferenceDetailsActivity.this, 0); }
991993
994+ private String getWebxdcName(final Message message) {
995+ final var fileParams = message.getFileParams();
996+ if (!"application/webxdc+zip".equals(fileParams.getMediaType())
997+ || fileParams.getCids().isEmpty()) return null;
998+ final WebxdcPage webxdc = new WebxdcPage(
999+ ConferenceDetailsActivity.this,
1000+ fileParams.getCids().get(0),
1001+ message
1002+ );
1003+ try {
1004+ final String name = webxdc.getName();
1005+ return "Widget".equals(name) ? null : name;
1006+ } finally {
1007+ webxdc.close();
1008+ }
1009+ }
1010+
9921011 @Override
9931012 public View getView(int position, View view, @NonNull ViewGroup parent) {
9941013 final ThreadRowBinding binding = DataBindingUtil.inflate(LayoutInflater.from(parent.getContext()), R.layout.thread_row, parent, false);
......@@ -997,7 +1016,7 @@ public class ConferenceDetailsActivity extends XmppActivity
9971016 binding.threadIdenticon.setColor(UIHelper.getColorForName(item.getThreadId()));
9981017 binding.threadIdenticon.setHash(UIHelper.identiconHash(item.getThreadId()));
9991018
1000- binding.threadSubject.setText(item.getDisplay());
1019+ binding.threadSubject.setText(item.getDisplay(this::getWebxdcName));
10011020
10021021 return binding.getRoot();
10031022 }
+33 -0 src/test/java/eu/siacs/conversations/entities/ConversationTest.java #
......@@ -61,6 +61,39 @@ public class ConversationTest {
6161
6262 }
6363
64+ @Test
65+ public void threadDisplayUsesWebxdcNameBeforeFileName() {
66+ final var message = new Message(
67+ withoutOccupantId,
68+ "",
69+ Message.ENCRYPTION_NONE,
70+ Message.STATUS_RECEIVED
71+ );
72+ message.getFileParams().setName("app.xdc");
73+ message.getFileParams().setMediaType("application/webxdc+zip");
74+
75+ final var thread = new Conversation.Thread("thread-id");
76+ thread.first = message;
77+
78+ Assert.assertEquals("My Widget", thread.getDisplay(m -> "My Widget"));
79+ }
80+
81+ @Test
82+ public void threadDisplayFallsBackToFileName() {
83+ final var message = new Message(
84+ withoutOccupantId,
85+ "",
86+ Message.ENCRYPTION_NONE,
87+ Message.STATUS_RECEIVED
88+ );
89+ message.getFileParams().setName("app.xdc");
90+
91+ final var thread = new Conversation.Thread("thread-id");
92+ thread.first = message;
93+
94+ Assert.assertEquals("app.xdc", thread.getDisplay());
95+ }
96+
6497 @Test
6598 public void getMucOccupantsCacheReturnsCache() throws Exception {
6699 var cache = withOccupantId.getMucOccupantCache();
Back to top