persist muc avatar and show in bookmarks

This commit is contained in:
Daniel Gultsch 2018-06-30 13:35:17 +02:00
parent 9408dd597a
commit dfb95f0a84
5 changed files with 27 additions and 14 deletions

View File

@ -183,11 +183,13 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece
mXmppConnectionService.updateAccountUi();
} else {
Contact contact = account.getRoster().getContact(from);
contact.setAvatar(avatar);
if (contact.setAvatar(avatar)) {
mXmppConnectionService.syncRoster(account);
mXmppConnectionService.getAvatarService().clear(contact);
mXmppConnectionService.updateConversationUi();
mXmppConnectionService.updateRosterUi();
}
}
} else if (mXmppConnectionService.isDataSaverDisabled()) {
mXmppConnectionService.fetchAvatar(account, avatar);
}

View File

@ -233,6 +233,7 @@ public class PresenceParser extends AbstractParser implements
mXmppConnectionService.updateConversationUi();
mXmppConnectionService.updateAccountUi();
} else if (contact.setAvatar(avatar)) {
mXmppConnectionService.syncRoster(account);
mXmppConnectionService.getAvatarService().clear(contact);
mXmppConnectionService.updateConversationUi();
mXmppConnectionService.updateRosterUi();

View File

@ -888,7 +888,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)) {
if (contact.getOption(Contact.Options.IN_ROSTER) || contact.getAvatar() != null) {
db.insert(Contact.TABLENAME, null, contact.getContentValues());
} else {
String where = Contact.ACCOUNT + "=? AND " + Contact.JID + "=?";

View File

@ -53,7 +53,7 @@ public class AvatarService implements OnAdvancedStreamFeaturesLoaded {
protected XmppConnectionService mXmppConnectionService = null;
public AvatarService(XmppConnectionService service) {
AvatarService(XmppConnectionService service) {
this.mXmppConnectionService = service;
}
@ -213,7 +213,13 @@ public class AvatarService implements OnAdvancedStreamFeaturesLoaded {
if (bookmark.getConversation() != null) {
return get(bookmark.getConversation(), size, cachedOnly);
} else {
String seed = bookmark.getJid() != null ? bookmark.getJid().asBareJid().toString() : null;
Jid jid = bookmark.getJid();
Account account = bookmark.getAccount();
Contact contact = jid == null ? null : account.getRoster().getContact(jid);
if (contact != null && contact.getAvatar() != null) {
return get(contact, size, cachedOnly);
}
String seed = jid != null ? jid.asBareJid().toString() : null;
return get(bookmark.getDisplayName(), seed, size, cachedOnly);
}
} else {

View File

@ -2886,11 +2886,13 @@ public class XmppConnectionService extends Service {
updateAccountUi();
} else {
Contact contact = a.getRoster().getContact(avatar.owner);
contact.setAvatar(avatar);
if (contact.setAvatar(avatar)) {
syncRoster(account);
getAvatarService().clear(contact);
updateConversationUi();
updateRosterUi();
}
}
if (callback != null) {
callback.success(avatar);
}
@ -2943,10 +2945,12 @@ public class XmppConnectionService extends Service {
updateAccountUi();
} else {
Contact contact = account.getRoster().getContact(avatar.owner);
contact.setAvatar(avatar);
if (contact.setAvatar(avatar)) {
syncRoster(account);
getAvatarService().clear(contact);
updateRosterUi();
}
}
updateConversationUi();
} else {
Conversation conversation = find(account, avatar.owner.asBareJid());