store avatars received over muc presence in contact
This commit is contained in:
parent
b8d831f02a
commit
1985f6bdec
|
@ -431,10 +431,14 @@ public class Contact implements ListItem, Blockable {
|
|||
}
|
||||
}
|
||||
|
||||
public String getAvatar() {
|
||||
public String getAvatarFilename() {
|
||||
return avatar == null ? null : avatar.getFilename();
|
||||
}
|
||||
|
||||
public Avatar getAvatar() {
|
||||
return avatar;
|
||||
}
|
||||
|
||||
public boolean mutualPresenceSubscription() {
|
||||
return getOption(Options.FROM) && getOption(Options.TO);
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -119,6 +119,14 @@ public class PresenceParser extends AbstractParser implements
|
|||
if (user.setAvatar(avatar)) {
|
||||
mXmppConnectionService.getAvatarService().clear(user);
|
||||
}
|
||||
if (user.getRealJid() != null) {
|
||||
Contact c = conversation.getAccount().getRoster().getContact(user.getRealJid());
|
||||
if (c.setAvatar(avatar)) {
|
||||
mXmppConnectionService.syncRoster(conversation.getAccount());
|
||||
mXmppConnectionService.getAvatarService().clear(c);
|
||||
mXmppConnectionService.updateRosterUi();
|
||||
}
|
||||
}
|
||||
} else if (mXmppConnectionService.isDataSaverDisabled()) {
|
||||
mXmppConnectionService.fetchAvatar(mucOptions.getAccount(), avatar);
|
||||
}
|
||||
|
|
|
@ -911,7 +911,7 @@ public class DatabaseBackend extends SQLiteOpenHelper {
|
|||
final SQLiteDatabase db = this.getWritableDatabase();
|
||||
db.beginTransaction();
|
||||
for (Contact contact : roster.getContacts()) {
|
||||
if (contact.getOption(Contact.Options.IN_ROSTER) || contact.getAvatar() != null) {
|
||||
if (contact.getOption(Contact.Options.IN_ROSTER) || contact.getAvatarFilename() != null) {
|
||||
db.insert(Contact.TABLENAME, null, contact.getContentValues());
|
||||
} else {
|
||||
String where = Contact.ACCOUNT + "=? AND " + Contact.JID + "=?";
|
||||
|
|
|
@ -69,8 +69,8 @@ public class AvatarService implements OnAdvancedStreamFeaturesLoaded {
|
|||
if (contact.getProfilePhoto() != null) {
|
||||
avatar = mXmppConnectionService.getFileBackend().cropCenterSquare(Uri.parse(contact.getProfilePhoto()), size);
|
||||
}
|
||||
if (avatar == null && contact.getAvatar() != null) {
|
||||
avatar = mXmppConnectionService.getFileBackend().getAvatar(contact.getAvatar(), size);
|
||||
if (avatar == null && contact.getAvatarFilename() != null) {
|
||||
avatar = mXmppConnectionService.getFileBackend().getAvatar(contact.getAvatarFilename(), size);
|
||||
}
|
||||
if (avatar == null) {
|
||||
avatar = get(contact.getDisplayName(), contact.getJid().asBareJid().toString(), size, cachedOnly);
|
||||
|
@ -128,7 +128,7 @@ public class AvatarService implements OnAdvancedStreamFeaturesLoaded {
|
|||
|
||||
public Bitmap get(final MucOptions.User user, final int size, boolean cachedOnly) {
|
||||
Contact c = user.getContact();
|
||||
if (c != null && (c.getProfilePhoto() != null || c.getAvatar() != null || user.getAvatar() == null)) {
|
||||
if (c != null && (c.getProfilePhoto() != null || c.getAvatarFilename() != null || user.getAvatar() == null)) {
|
||||
return get(c, size, cachedOnly);
|
||||
} else {
|
||||
return getImpl(user, size, cachedOnly);
|
||||
|
@ -165,6 +165,10 @@ public class AvatarService implements OnAdvancedStreamFeaturesLoaded {
|
|||
}
|
||||
}
|
||||
for (Conversation conversation : mXmppConnectionService.findAllConferencesWith(contact)) {
|
||||
MucOptions.User user = conversation.getMucOptions().findUserByRealJid(contact.getJid().asBareJid());
|
||||
if (user != null) {
|
||||
clear(user);
|
||||
}
|
||||
clear(conversation);
|
||||
}
|
||||
}
|
||||
|
@ -216,7 +220,7 @@ public class AvatarService implements OnAdvancedStreamFeaturesLoaded {
|
|||
Jid jid = bookmark.getJid();
|
||||
Account account = bookmark.getAccount();
|
||||
Contact contact = jid == null ? null : account.getRoster().getContact(jid);
|
||||
if (contact != null && contact.getAvatar() != null) {
|
||||
if (contact != null && contact.getAvatarFilename() != null) {
|
||||
return get(contact, size, cachedOnly);
|
||||
}
|
||||
String seed = jid != null ? jid.asBareJid().toString() : null;
|
||||
|
@ -400,14 +404,14 @@ public class AvatarService implements OnAdvancedStreamFeaturesLoaded {
|
|||
return get(message.getCounterparts(), size, cachedOnly);
|
||||
} else if (message.getStatus() == Message.STATUS_RECEIVED) {
|
||||
Contact c = message.getContact();
|
||||
if (c != null && (c.getProfilePhoto() != null || c.getAvatar() != null)) {
|
||||
if (c != null && (c.getProfilePhoto() != null || c.getAvatarFilename() != null)) {
|
||||
return get(c, size, cachedOnly);
|
||||
} else if (conversation instanceof Conversation && message.getConversation().getMode() == Conversation.MODE_MULTI) {
|
||||
final Jid trueCounterpart = message.getTrueCounterpart();
|
||||
final MucOptions mucOptions = ((Conversation) conversation).getMucOptions();
|
||||
MucOptions.User user;
|
||||
if (trueCounterpart != null) {
|
||||
user = mucOptions.findUserByRealJid(trueCounterpart);
|
||||
user = mucOptions.findOrCreateUserByRealJid(trueCounterpart, message.getCounterpart());
|
||||
} else {
|
||||
user = mucOptions.findUserByFullJid(message.getCounterpart());
|
||||
}
|
||||
|
@ -508,9 +512,9 @@ public class AvatarService implements OnAdvancedStreamFeaturesLoaded {
|
|||
Uri uri = null;
|
||||
if (contact.getProfilePhoto() != null) {
|
||||
uri = Uri.parse(contact.getProfilePhoto());
|
||||
} else if (contact.getAvatar() != null) {
|
||||
} else if (contact.getAvatarFilename() != null) {
|
||||
uri = mXmppConnectionService.getFileBackend().getAvatarUri(
|
||||
contact.getAvatar());
|
||||
contact.getAvatarFilename());
|
||||
}
|
||||
if (drawTile(canvas, uri, left, top, right, bottom)) {
|
||||
return true;
|
||||
|
|
|
@ -3114,6 +3114,14 @@ public class XmppConnectionService extends Service {
|
|||
updateConversationUi();
|
||||
updateMucRosterUi();
|
||||
}
|
||||
if (user.getRealJid() != null) {
|
||||
Contact contact = account.getRoster().getContact(user.getRealJid());
|
||||
if (contact.setAvatar(avatar)) {
|
||||
syncRoster(account);
|
||||
getAvatarService().clear(contact);
|
||||
updateRosterUi();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -874,7 +874,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
|
|||
attachLocationToConversation(conversation, attachment.getUri());
|
||||
} else if (attachment.getType() == Attachment.Type.IMAGE) {
|
||||
Log.d(Config.LOGTAG, "ConversationsActivity.commitAttachments() - attaching image to conversations. CHOOSE_IMAGE");
|
||||
attachImageToConversation(conversation, attachment.getUri());
|
||||
attachImageToConversation(conversation, attachment.getUri());
|
||||
} else {
|
||||
Log.d(Config.LOGTAG, "ConversationsActivity.commitAttachments() - attaching file to conversations. CHOOSE_FILE/RECORD_VOICE/RECORD_VIDEO");
|
||||
attachFileToConversation(conversation, attachment.getUri(), attachment.getMime());
|
||||
|
@ -901,7 +901,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
|
|||
switch (requestCode) {
|
||||
case ATTACHMENT_CHOICE_TAKE_PHOTO:
|
||||
if (pendingTakePhotoUri.clear()) {
|
||||
Log.d(Config.LOGTAG,"cleared pending photo uri after negative activity result");
|
||||
Log.d(Config.LOGTAG, "cleared pending photo uri after negative activity result");
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -1033,7 +1033,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
|
|||
Jid tcp = message.getTrueCounterpart();
|
||||
Jid cp = message.getCounterpart();
|
||||
if (cp != null && !cp.isBareJid()) {
|
||||
User userByRealJid = tcp != null ? conversation.getMucOptions().findOrCreateUserByRealJid(tcp) : null;
|
||||
User userByRealJid = tcp != null ? conversation.getMucOptions().findOrCreateUserByRealJid(tcp, cp) : null;
|
||||
final User user = userByRealJid != null ? userByRealJid : conversation.getMucOptions().findUserByFullJid(cp);
|
||||
final PopupMenu popupMenu = new PopupMenu(getActivity(), v);
|
||||
popupMenu.inflate(R.menu.muc_details_context);
|
||||
|
@ -2670,7 +2670,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
|
|||
setScrollPosition(scrollState, lastMessageUuid);
|
||||
}
|
||||
if (attachments != null && attachments.size() > 0) {
|
||||
Log.d(Config.LOGTAG,"had attachments on restore");
|
||||
Log.d(Config.LOGTAG, "had attachments on restore");
|
||||
mediaPreviewAdapter.addMediaPreviews(attachments);
|
||||
toggleInputMethod();
|
||||
}
|
||||
|
@ -2682,7 +2682,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
|
|||
Log.e(Config.LOGTAG, "cleared pending intent with unhandled result left");
|
||||
}
|
||||
if (pendingScrollState.clear()) {
|
||||
Log.e(Config.LOGTAG,"cleared scroll state");
|
||||
Log.e(Config.LOGTAG, "cleared scroll state");
|
||||
}
|
||||
if (pendingTakePhotoUri.clear()) {
|
||||
Log.e(Config.LOGTAG, "cleared pending photo uri");
|
||||
|
|
Loading…
Reference in a new issue