aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2019-01-26 22:37:40 +0100
committerChristian Schneppe <christian@pix-art.de>2019-01-26 22:37:40 +0100
commitfb5825bd8696a8a8b651c18000c5c73e0b265254 (patch)
tree18b74bf60391af1fa1bf7631e35b74f77606ea56
parentd827482d9085b5e560c5fd6d4287cc3ea9b6fbb7 (diff)
make avatars from contacts configurable
-rw-r--r--src/main/java/de/pixart/messenger/services/AvatarService.java15
-rw-r--r--src/main/java/de/pixart/messenger/ui/SettingsActivity.java1
-rw-r--r--src/main/res/values/bools.xml4
-rw-r--r--src/main/res/values/strings.xml2
-rw-r--r--src/main/res/xml/preferences.xml5
5 files changed, 20 insertions, 7 deletions
diff --git a/src/main/java/de/pixart/messenger/services/AvatarService.java b/src/main/java/de/pixart/messenger/services/AvatarService.java
index fc6235a55..f4a9b9818 100644
--- a/src/main/java/de/pixart/messenger/services/AvatarService.java
+++ b/src/main/java/de/pixart/messenger/services/AvatarService.java
@@ -44,6 +44,7 @@ import de.pixart.messenger.xmpp.XmppConnection;
import rocks.xmpp.addr.Jid;
import static de.pixart.messenger.Config.SYSTEM_UI_AVATAR_SIZE;
+import static de.pixart.messenger.ui.SettingsActivity.PREFER_XMPP_AVATAR;
public class AvatarService implements OnAdvancedStreamFeaturesLoaded {
@@ -80,15 +81,15 @@ public class AvatarService implements OnAdvancedStreamFeaturesLoaded {
if (avatar != null || cachedOnly) {
return avatar;
}
- if (contact.getAvatarFilename() != null && QuickConversationsService.isQuicksy()) {
+ if (contact.getAvatarFilename() != null && QuickConversationsService.isQuicksy() && mXmppConnectionService.getPreferences().getBoolean(PREFER_XMPP_AVATAR, mXmppConnectionService.getResources().getBoolean(R.bool.prefer_xmpp_avatar))) {
+ avatar = mXmppConnectionService.getFileBackend().getAvatar(contact.getAvatarFilename(), size);
+ }
+ if (avatar == null && contact.getAvatarFilename() != null && mXmppConnectionService.getPreferences().getBoolean(PREFER_XMPP_AVATAR, mXmppConnectionService.getResources().getBoolean(R.bool.prefer_xmpp_avatar))) {
avatar = mXmppConnectionService.getFileBackend().getAvatar(contact.getAvatarFilename(), size);
}
if (avatar == null && contact.getProfilePhoto() != null) {
avatar = mXmppConnectionService.getFileBackend().cropCenterSquare(Uri.parse(contact.getProfilePhoto()), 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, false);
}
@@ -558,12 +559,12 @@ public class AvatarService implements OnAdvancedStreamFeaturesLoaded {
Contact contact = user.getContact();
if (contact != null) {
Uri uri = null;
- if (contact.getAvatarFilename() != null && QuickConversationsService.isQuicksy()) {
+ if (contact.getAvatarFilename() != null && QuickConversationsService.isQuicksy() && mXmppConnectionService.getPreferences().getBoolean(PREFER_XMPP_AVATAR, mXmppConnectionService.getResources().getBoolean(R.bool.prefer_xmpp_avatar))) {
+ uri = mXmppConnectionService.getFileBackend().getAvatarUri(contact.getAvatarFilename());
+ } else if (contact.getAvatarFilename() != null && mXmppConnectionService.getPreferences().getBoolean(PREFER_XMPP_AVATAR, mXmppConnectionService.getResources().getBoolean(R.bool.prefer_xmpp_avatar))) {
uri = mXmppConnectionService.getFileBackend().getAvatarUri(contact.getAvatarFilename());
} else if (contact.getProfilePhoto() != null) {
uri = Uri.parse(contact.getProfilePhoto());
- } else if (contact.getAvatarFilename() != null) {
- uri = mXmppConnectionService.getFileBackend().getAvatarUri(contact.getAvatarFilename());
}
if (drawTile(canvas, uri, left, top, right, bottom)) {
return true;
diff --git a/src/main/java/de/pixart/messenger/ui/SettingsActivity.java b/src/main/java/de/pixart/messenger/ui/SettingsActivity.java
index a8080f482..37fb8bb6d 100644
--- a/src/main/java/de/pixart/messenger/ui/SettingsActivity.java
+++ b/src/main/java/de/pixart/messenger/ui/SettingsActivity.java
@@ -64,6 +64,7 @@ public class SettingsActivity extends XmppActivity implements
public static final String QUICK_SHARE_ATTACHMENT_CHOICE = "quick_share_attachment_choice";
public static final String NUMBER_OF_ACCOUNTS = "number_of_accounts";
public static final String PLAY_GIF_INSIDE = "play_gif_inside";
+ public static final String PREFER_XMPP_AVATAR = "prefer_xmpp_avatar";
public static final int REQUEST_CREATE_BACKUP = 0xbf8701;
Preference multiAccountPreference;
diff --git a/src/main/res/values/bools.xml b/src/main/res/values/bools.xml
new file mode 100644
index 000000000..4807728ca
--- /dev/null
+++ b/src/main/res/values/bools.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+ <bool name="prefer_xmpp_avatar">true</bool>
+</resources> \ No newline at end of file
diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml
index 5f3d159e7..188fc764c 100644
--- a/src/main/res/values/strings.xml
+++ b/src/main/res/values/strings.xml
@@ -868,4 +868,6 @@
<string name="restore_warning">Do not use the restore backup feature in an attempt to clone (run simultaneously) an installation. Restoring a backup is only meant for migrations or in case you have lost the original device.</string>
<string name="unable_to_restore_backup">Unable to restore backup.</string>
<string name="unable_to_decrypt_backup">Unable to decrypt backup. Is the password correct?</string>
+ <string name="pref_prefer_xmpp_avatar_summary">Prefer the users XMPP avatar instead of the one from your address book</string>
+ <string name="pref_prefer_xmpp_avatar">Prefer XMPP avatar</string>
</resources>
diff --git a/src/main/res/xml/preferences.xml b/src/main/res/xml/preferences.xml
index 0244da459..52a957f98 100644
--- a/src/main/res/xml/preferences.xml
+++ b/src/main/res/xml/preferences.xml
@@ -76,6 +76,11 @@
android:key="play_gif_inside"
android:summary="@string/pref_play_gif_inside_summary"
android:title="@string/pref_play_gif_inside" />
+ <CheckBoxPreference
+ android:defaultValue="@bool/prefer_xmpp_avatar"
+ android:key="prefer_xmpp_avatar"
+ android:summary="@string/pref_prefer_xmpp_avatar_summary"
+ android:title="@string/pref_prefer_xmpp_avatar" />
</PreferenceScreen>
<!--Notifications-->
<PreferenceScreen