mirror of
https://github.com/ArcaneChat/android.git
synced 2026-07-03 14:05:24 +02:00
avatars from system contacts #55
This commit is contained in:
@@ -38,11 +38,14 @@ import com.b44t.messenger.DcMsg;
|
||||
import org.thoughtcrime.securesms.ApplicationContext;
|
||||
import org.thoughtcrime.securesms.BuildConfig;
|
||||
import org.thoughtcrime.securesms.R;
|
||||
import org.thoughtcrime.securesms.contacts.avatars.SystemContactPhoto;
|
||||
import org.thoughtcrime.securesms.database.Address;
|
||||
import org.thoughtcrime.securesms.database.ThreadDatabase;
|
||||
import org.thoughtcrime.securesms.database.model.ThreadRecord;
|
||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
import org.thoughtcrime.securesms.recipients.RecipientProvider;
|
||||
import org.thoughtcrime.securesms.util.Hash;
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||
import org.thoughtcrime.securesms.util.Util;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
@@ -176,13 +179,30 @@ public class ApplicationDcContext extends DcContext {
|
||||
participants.add(getRecipient(RECIPIENT_TYPE_CONTACT, contactId));
|
||||
}
|
||||
RecipientProvider.RecipientDetails recipientDetails = new RecipientProvider.RecipientDetails(chat.getName(), null, false, null, participants);
|
||||
return new Recipient(Address.fromChat(chat.getId()), recipientDetails);
|
||||
Recipient recipient = new Recipient(Address.fromChat(chat.getId()), recipientDetails);
|
||||
if (!chat.isGroup()) {
|
||||
String identifier = Hash.sha256(chat.getName() + chat.getSubtitle());
|
||||
Uri systemContactPhoto = TextSecurePreferences.getSystemContactPhoto(context, identifier);
|
||||
if (systemContactPhoto != null) {
|
||||
recipient.setSystemContactPhoto(systemContactPhoto);
|
||||
}
|
||||
}
|
||||
return recipient;
|
||||
}
|
||||
@NonNull
|
||||
|
||||
public Recipient getRecipient(DcContact contact) {
|
||||
RecipientProvider.RecipientDetails recipientDetails = new RecipientProvider.RecipientDetails(contact.getDisplayName(), null, false, null, null);
|
||||
return new Recipient(Address.fromContact(contact.getId()), recipientDetails);
|
||||
Recipient recipient = new Recipient(Address.fromContact(contact.getId()), recipientDetails);
|
||||
String identifier = Hash.sha256(contact.getName() + contact.getAddr());
|
||||
Uri systemContactPhoto = TextSecurePreferences.getSystemContactPhoto(context, identifier);
|
||||
if (systemContactPhoto != null) {
|
||||
recipient.setSystemContactPhoto(systemContactPhoto);
|
||||
}
|
||||
if (contact.getId() == DcContact.DC_CONTACT_ID_SELF) {
|
||||
recipient.setProfileAvatar("SELF");
|
||||
}
|
||||
return recipient;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package org.thoughtcrime.securesms.contacts;
|
||||
|
||||
import android.content.Context;
|
||||
import android.net.Uri;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
@@ -18,8 +17,6 @@ import org.thoughtcrime.securesms.database.Address;
|
||||
import org.thoughtcrime.securesms.mms.GlideRequests;
|
||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
import org.thoughtcrime.securesms.recipients.RecipientModifiedListener;
|
||||
import org.thoughtcrime.securesms.util.Hash;
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||
import org.thoughtcrime.securesms.util.Util;
|
||||
import org.thoughtcrime.securesms.util.ViewUtil;
|
||||
|
||||
@@ -72,11 +69,6 @@ public class ContactSelectionListItem extends LinearLayout implements RecipientM
|
||||
}
|
||||
else {
|
||||
this.recipient = DcHelper.getContext(getContext()).getRecipient(contact);
|
||||
String identifier = Hash.sha256(contact.getName() + contact.getAddr());
|
||||
Uri systemContactPhoto = TextSecurePreferences.getSystemContactPhoto(getContext(), identifier);
|
||||
if (systemContactPhoto != null) {
|
||||
this.recipient.setSystemContactPhoto(systemContactPhoto);
|
||||
}
|
||||
this.recipient.addListener(this);
|
||||
if (this.recipient.getName() != null) {
|
||||
name = this.recipient.getName();
|
||||
|
||||
@@ -44,6 +44,8 @@ public class AvatarHelper {
|
||||
if (bitmap == null) {
|
||||
return;
|
||||
}
|
||||
//noinspection ResultOfMethodCallIgnored
|
||||
new File(getAvatarDirectoryPath(context)).mkdirs();
|
||||
DcContext dcContext = DcHelper.getContext(context);
|
||||
String avatarPath = dcContext.getChat(chatId).getProfileImage();
|
||||
if (avatarPath != null && !avatarPath.isEmpty()) {
|
||||
|
||||
Reference in New Issue
Block a user