cheogram-android
created pr with
cheogram-android/webxdc-thread-name.1
cmds
checkout latest patchset:
ssh pr.pico.sh pull cheogram-android:webxdc-thread-name | git am -3checkout specific patchset revision:
ssh pr.pico.sh pull cheogram-android:webxdc-thread-name [rev] | git am -3add changes to patch request:
git format-patch main --stdout | ssh pr.pico.sh cheogram-android:webxdc-thread-nameadd comment to patch request:
ssh pr.pico.sh comment cheogram-android:webxdc-thread-name "lgtm!"
Patchset
cheogram-android/webxdc-thread-name.1
Fall back to webxdc name or filename
Stephen Paul Weber
2026-11-03T18:37:32ZIf 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 | |
| 4245 | 4245 | } | |
| 4246 | 4246 | ||
| 4247 | 4247 | public String getDisplay() { | |
| 4248 | + | return getDisplay(null); | |
| 4249 | + | } | |
| 4250 | + | ||
| 4251 | + | public String getDisplay(final Function<Message, String> webxdcNameResolver) { | |
| 4248 | 4252 | final String s = getSubject(); | |
| 4249 | 4253 | if (s != null) return s; | |
| 4250 | 4254 | ||
| 4251 | 4255 | 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; | |
| 4253 | 4266 | } | |
| 4254 | 4267 | ||
| 4255 | 4268 | return ""; |
+20
-1
src/main/java/eu/siacs/conversations/ui/ConferenceDetailsActivity.java
#
| ... | ... | @@ -35,6 +35,7 @@ import androidx.core.content.ContextCompat; | |
| 35 | 35 | import androidx.databinding.DataBindingUtil; | |
| 36 | 36 | ||
| 37 | 37 | import com.cheogram.android.Util; | |
| 38 | + | import com.cheogram.android.WebxdcPage; | |
| 38 | 39 | ||
| 39 | 40 | import com.google.android.material.dialog.MaterialAlertDialogBuilder; | |
| 40 | 41 | import com.google.android.material.color.MaterialColors; |
| ... | ... | @@ -63,6 +64,7 @@ import eu.siacs.conversations.entities.Account; | |
| 63 | 64 | import eu.siacs.conversations.entities.Contact; | |
| 64 | 65 | import eu.siacs.conversations.entities.Conversation; | |
| 65 | 66 | import eu.siacs.conversations.entities.ListItem; | |
| 67 | + | import eu.siacs.conversations.entities.Message; | |
| 66 | 68 | import eu.siacs.conversations.entities.MucOptions; | |
| 67 | 69 | import eu.siacs.conversations.entities.MucOptions.User; | |
| 68 | 70 | import eu.siacs.conversations.services.XmppConnectionService; |
| ... | ... | @@ -989,6 +991,23 @@ public class ConferenceDetailsActivity extends XmppActivity | |
| 989 | 991 | class ThreadAdapter extends ArrayAdapter<Conversation.Thread> { | |
| 990 | 992 | ThreadAdapter() { super(ConferenceDetailsActivity.this, 0); } | |
| 991 | 993 | ||
| 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 | + | ||
| 992 | 1011 | @Override | |
| 993 | 1012 | public View getView(int position, View view, @NonNull ViewGroup parent) { | |
| 994 | 1013 | final ThreadRowBinding binding = DataBindingUtil.inflate(LayoutInflater.from(parent.getContext()), R.layout.thread_row, parent, false); |
| ... | ... | @@ -997,7 +1016,7 @@ public class ConferenceDetailsActivity extends XmppActivity | |
| 997 | 1016 | binding.threadIdenticon.setColor(UIHelper.getColorForName(item.getThreadId())); | |
| 998 | 1017 | binding.threadIdenticon.setHash(UIHelper.identiconHash(item.getThreadId())); | |
| 999 | 1018 | ||
| 1000 | - | binding.threadSubject.setText(item.getDisplay()); | |
| 1019 | + | binding.threadSubject.setText(item.getDisplay(this::getWebxdcName)); | |
| 1001 | 1020 | ||
| 1002 | 1021 | return binding.getRoot(); | |
| 1003 | 1022 | } |
+33
-0
src/test/java/eu/siacs/conversations/entities/ConversationTest.java
#
| ... | ... | @@ -61,6 +61,39 @@ public class ConversationTest { | |
| 61 | 61 | ||
| 62 | 62 | } | |
| 63 | 63 | ||
| 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 | + | ||
| 64 | 97 | @Test | |
| 65 | 98 | public void getMucOccupantsCacheReturnsCache() throws Exception { | |
| 66 | 99 | var cache = withOccupantId.getMucOccupantCache(); |