From 0f9b9d71cb0bc8464af3e95e8ee26297074ec4b1 Mon Sep 17 00:00:00 2001 From: Arne Date: Sun, 17 Mar 2024 22:31:33 +0100 Subject: [PATCH] jpg link in status is avatar now --- .../de/monocles/chat/StoriesActivity.java | 8 +++---- .../siacs/conversations/entities/Message.java | 2 +- .../ui/adapter/ListItemStoriesAdapter.java | 23 ++++++++++++++++--- 3 files changed, 24 insertions(+), 9 deletions(-) diff --git a/src/main/java/de/monocles/chat/StoriesActivity.java b/src/main/java/de/monocles/chat/StoriesActivity.java index dfab6526d1..3645136cae 100644 --- a/src/main/java/de/monocles/chat/StoriesActivity.java +++ b/src/main/java/de/monocles/chat/StoriesActivity.java @@ -1106,11 +1106,9 @@ public class StoriesActivity extends XmppActivity implements XmppConnectionServi if (account.isEnabled()) { for (Contact contact : account.getRoster().getContacts()) { List statusMessages = contact.getPresences().getStatusMessages(); - for (String statusMessage : statusMessages) { - if (contact.showInContactList() && !statusMessage.isEmpty()) { - this.contacts.add(contact); - } - + if (contact.showInContactList() && !statusMessages.isEmpty()) { + this.contacts.add(contact); + //statusMessages.addAll(contact.getPresences().getStatusMessages()); } } diff --git a/src/main/java/eu/siacs/conversations/entities/Message.java b/src/main/java/eu/siacs/conversations/entities/Message.java index 9cacbd08d9..0fa50d08a7 100644 --- a/src/main/java/eu/siacs/conversations/entities/Message.java +++ b/src/main/java/eu/siacs/conversations/entities/Message.java @@ -142,7 +142,7 @@ public class Message extends AbstractEntity implements AvatarService.Avatarable public static final String ME_COMMAND = "/me"; public static final String ERROR_MESSAGE_CANCELLED = "eu.siacs.conversations.cancelled"; public static final String DELETED_MESSAGE_BODY = "eu.siacs.conversations.message_deleted"; - public static final String DELETED_MESSAGE_BODY_OLD = "de.pixart.messenger.message_deleted"; + public static final String DELETED_MESSAGE_BODY_OLD = "de.monocles.chat.message_deleted"; public static final String RETRACT_ID = "retractId"; public boolean markable = false; diff --git a/src/main/java/eu/siacs/conversations/ui/adapter/ListItemStoriesAdapter.java b/src/main/java/eu/siacs/conversations/ui/adapter/ListItemStoriesAdapter.java index b28f4f22d8..4b881eb78a 100644 --- a/src/main/java/eu/siacs/conversations/ui/adapter/ListItemStoriesAdapter.java +++ b/src/main/java/eu/siacs/conversations/ui/adapter/ListItemStoriesAdapter.java @@ -1,7 +1,10 @@ package eu.siacs.conversations.ui.adapter; import android.content.SharedPreferences; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; import android.graphics.drawable.Drawable; +import android.net.Uri; import android.preference.PreferenceManager; import android.text.Spannable; import android.text.SpannableString; @@ -19,6 +22,9 @@ import androidx.databinding.DataBindingUtil; import com.wefika.flowlayout.FlowLayout; +import java.io.File; +import java.io.IOException; +import java.net.URL; import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -99,6 +105,19 @@ public class ListItemStoriesAdapter extends ArrayAdapter { for (String statusMessage : statusMessages) { if (statusMessage == null) { viewHolder.statusMessage.setVisibility(View.GONE); + } else if (statusMessage.endsWith(".jpg")) { + + Thread imageDataThread = new Thread(() -> { + try { + URL tUrl = new URL(statusMessage); + Bitmap imageBitmap = BitmapFactory.decodeStream(tUrl.openConnection().getInputStream()); + activity.runOnUiThread(() -> viewHolder.avatar.setImageBitmap(imageBitmap)); + } catch(IOException pExc) { + pExc.printStackTrace(); + } + }); + imageDataThread.start(); + } else if (statusMessages.size() == 1) { final String message = statusMessages.get(0); viewHolder.statusMessage.setVisibility(View.VISIBLE); @@ -152,9 +171,7 @@ public class ListItemStoriesAdapter extends ArrayAdapter { viewHolder.avatar.setAlpha(ACTIVE_ALPHA); viewHolder.statusMessage.setAlpha(ACTIVE_ALPHA); } - if (activity.xmppConnectionService != null) { - AvatarWorkerTask.loadAvatar(item, viewHolder.avatar, R.dimen.avatar); - } + if (item != null && item.getActive()) { viewHolder.activeIndicator.setVisibility(View.VISIBLE); }