aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/pixart/messenger
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/de/pixart/messenger')
-rw-r--r--src/main/java/de/pixart/messenger/parser/MessageParser.java10
-rw-r--r--src/main/java/de/pixart/messenger/parser/PresenceParser.java1
-rw-r--r--src/main/java/de/pixart/messenger/persistance/DatabaseBackend.java2
-rw-r--r--src/main/java/de/pixart/messenger/services/AvatarService.java10
-rw-r--r--src/main/java/de/pixart/messenger/services/XmppConnectionService.java18
5 files changed, 27 insertions, 14 deletions
diff --git a/src/main/java/de/pixart/messenger/parser/MessageParser.java b/src/main/java/de/pixart/messenger/parser/MessageParser.java
index bbfab612d..2f8d19810 100644
--- a/src/main/java/de/pixart/messenger/parser/MessageParser.java
+++ b/src/main/java/de/pixart/messenger/parser/MessageParser.java
@@ -275,10 +275,12 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece
mXmppConnectionService.updateAccountUi();
} else {
Contact contact = account.getRoster().getContact(from);
- contact.setAvatar(avatar);
- mXmppConnectionService.getAvatarService().clear(contact);
- mXmppConnectionService.updateConversationUi();
- mXmppConnectionService.updateRosterUi();
+ if (contact.setAvatar(avatar)) {
+ mXmppConnectionService.syncRoster(account);
+ mXmppConnectionService.getAvatarService().clear(contact);
+ mXmppConnectionService.updateConversationUi();
+ mXmppConnectionService.updateRosterUi();
+ }
}
} else if (mXmppConnectionService.isDataSaverDisabled()) {
mXmppConnectionService.fetchAvatar(account, avatar);
diff --git a/src/main/java/de/pixart/messenger/parser/PresenceParser.java b/src/main/java/de/pixart/messenger/parser/PresenceParser.java
index 1da8553dc..f3ca0e747 100644
--- a/src/main/java/de/pixart/messenger/parser/PresenceParser.java
+++ b/src/main/java/de/pixart/messenger/parser/PresenceParser.java
@@ -229,6 +229,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();
diff --git a/src/main/java/de/pixart/messenger/persistance/DatabaseBackend.java b/src/main/java/de/pixart/messenger/persistance/DatabaseBackend.java
index b2f4fe9d5..62b15c816 100644
--- a/src/main/java/de/pixart/messenger/persistance/DatabaseBackend.java
+++ b/src/main/java/de/pixart/messenger/persistance/DatabaseBackend.java
@@ -901,7 +901,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 + "=?";
diff --git a/src/main/java/de/pixart/messenger/services/AvatarService.java b/src/main/java/de/pixart/messenger/services/AvatarService.java
index 06b0e1f5f..bf415515b 100644
--- a/src/main/java/de/pixart/messenger/services/AvatarService.java
+++ b/src/main/java/de/pixart/messenger/services/AvatarService.java
@@ -54,7 +54,7 @@ public class AvatarService implements OnAdvancedStreamFeaturesLoaded {
protected XmppConnectionService mXmppConnectionService = null;
- public AvatarService(XmppConnectionService service) {
+ AvatarService(XmppConnectionService service) {
this.mXmppConnectionService = service;
}
@@ -231,7 +231,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 {
diff --git a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java
index f45a5ac8e..bf760949a 100644
--- a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java
+++ b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java
@@ -3223,10 +3223,12 @@ public class XmppConnectionService extends Service {
updateAccountUi();
} else {
Contact contact = a.getRoster().getContact(avatar.owner);
- contact.setAvatar(avatar);
- getAvatarService().clear(contact);
- updateConversationUi();
- updateRosterUi();
+ if (contact.setAvatar(avatar)) {
+ syncRoster(account);
+ getAvatarService().clear(contact);
+ updateConversationUi();
+ updateRosterUi();
+ }
}
if (callback != null) {
callback.success(avatar);
@@ -3278,9 +3280,11 @@ public class XmppConnectionService extends Service {
updateAccountUi();
} else {
Contact contact = account.getRoster().getContact(avatar.owner);
- contact.setAvatar(avatar);
- getAvatarService().clear(contact);
- updateRosterUi();
+ if (contact.setAvatar(avatar)) {
+ syncRoster(account);
+ getAvatarService().clear(contact);
+ updateRosterUi();
+ }
}
updateConversationUi();
} else {