make avatars from contacts configurable

This commit is contained in:
Christian Schneppe 2019-01-26 22:37:40 +01:00
parent d827482d90
commit fb5825bd86
5 changed files with 20 additions and 7 deletions

View file

@ -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;

View file

@ -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;

View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<bool name="prefer_xmpp_avatar">true</bool>
</resources>

View file

@ -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>

View file

@ -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