update fork #128

Manually merged
tristan merged 181 commits from mirror/monocles_chat_clean:master into master 2026-01-23 14:02:38 +01:00
2 changed files with 45 additions and 0 deletions
Showing only changes of commit 8423a6bbc8 - Show all commits

Show list of people who liked a post on long press
Some checks are pending
Android CI / build (pull_request) Waiting to run

Arne 2026-01-21 17:38:32 +01:00

View file

@ -479,6 +479,11 @@ public class PostsAdapter extends RecyclerView.Adapter<PostsAdapter.PostViewHold
holder.binding.likeButton.setEnabled(true);
holder.binding.likeCount.setText(String.valueOf(likes.size()));
holder.binding.likeButton.setOnLongClickListener(v -> {
showLikesDialog(likes);
return true;
});
Comment myLike = null;
Account myLikerAccount = null;
for (Account acc : onlineAccounts) {
@ -513,6 +518,42 @@ public class PostsAdapter extends RecyclerView.Adapter<PostsAdapter.PostViewHold
});
}
private void showLikesDialog(List<Comment> likes) {
if (likes.isEmpty()) {
return;
}
final ArrayList<String> likerDisplayNames = new ArrayList<>();
final List<Account> accounts = mActivity.xmppConnectionService.getAccounts();
for (Comment like : likes) {
if (like.getAuthor() != null) {
final Jid authorJid = like.getAuthor().asBareJid();
String displayName = null;
for (Account account : accounts) {
if (account.getRoster() != null) {
final Contact contact = account.getRoster().getContact(authorJid);
if (contact != null && contact.getDisplayName() != null && !contact.getDisplayName().isEmpty()) {
displayName = contact.getDisplayName();
break;
}
}
}
if (displayName != null) {
likerDisplayNames.add(displayName);
} else {
likerDisplayNames.add(authorJid.toString());
}
}
}
final ArrayAdapter<String> adapter = new ArrayAdapter<>(mActivity, android.R.layout.simple_list_item_1, likerDisplayNames);
new MaterialAlertDialogBuilder(mActivity)
.setTitle(mActivity.getResources().getQuantityString(R.plurals.liked_by_title, likes.size(), likes.size()))
.setAdapter(adapter, null)
.setPositiveButton(R.string.action_close, null)
.create()
.show();
}
private void publishLike(final Account account, final Post post, final PostViewHolder holder) {
mActivity.xmppConnectionService.publishComment(account, post.getCommentsNode(), "", new XmppConnectionService.OnPostPublished() {
@Override

View file

@ -1652,4 +1652,8 @@
<item quantity="one">Publishing to %d contact</item>
<item quantity="other">Publishing to %d contacts</item>
</plurals>
<plurals name="liked_by_title">
<item quantity="one">Liked by %d person</item>
<item quantity="other">Liked by %d people</item>
</plurals>
</resources>