jpg link in status is avatar now

This commit is contained in:
Arne 2024-03-17 22:31:33 +01:00
parent 0a1cdcdf29
commit 0f9b9d71cb
3 changed files with 24 additions and 9 deletions

View file

@ -1106,11 +1106,9 @@ public class StoriesActivity extends XmppActivity implements XmppConnectionServi
if (account.isEnabled()) {
for (Contact contact : account.getRoster().getContacts()) {
List<String> 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());
}
}

View file

@ -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;

View file

@ -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<ListItem> {
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<ListItem> {
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);
}