diff --git a/app/src/main/java/com/nextcloud/talk/activities/CallActivity.java b/app/src/main/java/com/nextcloud/talk/activities/CallActivity.java index f6d685005..cc6ebdd14 100644 --- a/app/src/main/java/com/nextcloud/talk/activities/CallActivity.java +++ b/app/src/main/java/com/nextcloud/talk/activities/CallActivity.java @@ -2188,13 +2188,13 @@ public class CallActivity extends CallBaseActivity { String urlForAvatar; if (!TextUtils.isEmpty(userId)) { - urlForAvatar = ApiUtils.getUrlForAvatarWithName(baseUrl, - userId, - R.dimen.avatar_size_big); + urlForAvatar = ApiUtils.getUrlForAvatar(baseUrl, + userId, + true); } else { - urlForAvatar = ApiUtils.getUrlForAvatarWithNameForGuests(baseUrl, - nick, - R.dimen.avatar_size_big); + urlForAvatar = ApiUtils.getUrlForGuestAvatar(baseUrl, + nick, + true); } ParticipantDisplayItem participantDisplayItem = new ParticipantDisplayItem(userId, diff --git a/app/src/main/java/com/nextcloud/talk/activities/CallNotificationActivity.java b/app/src/main/java/com/nextcloud/talk/activities/CallNotificationActivity.java index 97b29f915..426f5454f 100644 --- a/app/src/main/java/com/nextcloud/talk/activities/CallNotificationActivity.java +++ b/app/src/main/java/com/nextcloud/talk/activities/CallNotificationActivity.java @@ -330,9 +330,9 @@ public class CallNotificationActivity extends CallBaseActivity { private void setAvatarForOneToOneCall() { ImageRequest imageRequest = DisplayUtils.getImageRequestForUrl( - ApiUtils.getUrlForAvatarWithName(userBeingCalled.getBaseUrl(), - currentConversation.getName(), - R.dimen.avatar_size_big), null); + ApiUtils.getUrlForAvatar(userBeingCalled.getBaseUrl(), + currentConversation.getName(), + true), null); ImagePipeline imagePipeline = Fresco.getImagePipeline(); DataSource> dataSource = imagePipeline.fetchDecodedImage(imageRequest, null); diff --git a/app/src/main/java/com/nextcloud/talk/adapters/items/AdvancedUserItem.java b/app/src/main/java/com/nextcloud/talk/adapters/items/AdvancedUserItem.java index 5fc9ab7f2..6a5d5118a 100644 --- a/app/src/main/java/com/nextcloud/talk/adapters/items/AdvancedUserItem.java +++ b/app/src/main/java/com/nextcloud/talk/adapters/items/AdvancedUserItem.java @@ -138,10 +138,10 @@ public class AdvancedUserItem extends AbstractFlexibleItem> dataSource = imagePipeline.fetchDecodedImage(imageRequest, null); diff --git a/app/src/main/java/com/nextcloud/talk/jobs/NotificationWorker.java b/app/src/main/java/com/nextcloud/talk/jobs/NotificationWorker.java index 33b3907fa..14ae12927 100644 --- a/app/src/main/java/com/nextcloud/talk/jobs/NotificationWorker.java +++ b/app/src/main/java/com/nextcloud/talk/jobs/NotificationWorker.java @@ -379,11 +379,13 @@ public class NotificationWorker extends Worker { notificationBuilder.setOnlyAlertOnce(true); if (decryptedPushMessage.getNotificationUser().getType().equals("user") || decryptedPushMessage.getNotificationUser().getType().equals("guest")) { - String avatarUrl = ApiUtils.getUrlForAvatarWithName(signatureVerification.getUserEntity().getBaseUrl(), decryptedPushMessage.getNotificationUser().getId(), R.dimen.avatar_size); + String avatarUrl = ApiUtils.getUrlForAvatar(signatureVerification.getUserEntity().getBaseUrl(), + decryptedPushMessage.getNotificationUser().getId(), false); if (decryptedPushMessage.getNotificationUser().getType().equals("guest")) { - avatarUrl = ApiUtils.getUrlForAvatarWithNameForGuests(signatureVerification.getUserEntity().getBaseUrl(), - decryptedPushMessage.getNotificationUser().getName(), R.dimen.avatar_size); + avatarUrl = ApiUtils.getUrlForGuestAvatar(signatureVerification.getUserEntity().getBaseUrl(), + decryptedPushMessage.getNotificationUser().getName(), + false); } ImageRequest imageRequest = diff --git a/app/src/main/java/com/nextcloud/talk/models/json/chat/ChatMessage.java b/app/src/main/java/com/nextcloud/talk/models/json/chat/ChatMessage.java index 9dd6322b9..b2254a788 100644 --- a/app/src/main/java/com/nextcloud/talk/models/json/chat/ChatMessage.java +++ b/app/src/main/java/com/nextcloud/talk/models/json/chat/ChatMessage.java @@ -290,10 +290,10 @@ public class ChatMessage implements MessageContentType, MessageContentType.Image @Override public String getAvatar() { if (getActorType().equals("users")) { - return ApiUtils.getUrlForAvatarWithName(getActiveUser().getBaseUrl(), actorId, R.dimen.avatar_size); + return ApiUtils.getUrlForAvatar(getActiveUser().getBaseUrl(), actorId, true); } else if (getActorType().equals("bridged")) { - return ApiUtils.getUrlForAvatarWithName(getActiveUser().getBaseUrl(), "bridge-bot", - R.dimen.avatar_size); + return ApiUtils.getUrlForAvatar(getActiveUser().getBaseUrl(), "bridge-bot", + true); } else { String apiId = NextcloudTalkApplication.Companion.getSharedApplication().getString(R.string.nc_guest); @@ -301,7 +301,7 @@ public class ChatMessage implements MessageContentType, MessageContentType.Image if (!TextUtils.isEmpty(getActorDisplayName())) { apiId = getActorDisplayName(); } - return ApiUtils.getUrlForAvatarWithNameForGuests(getActiveUser().getBaseUrl(), apiId, R.dimen.avatar_size); + return ApiUtils.getUrlForGuestAvatar(getActiveUser().getBaseUrl(), apiId, true); } } }; diff --git a/app/src/main/java/com/nextcloud/talk/ui/dialog/ChooseAccountDialogFragment.java b/app/src/main/java/com/nextcloud/talk/ui/dialog/ChooseAccountDialogFragment.java index 52b9b869e..1b2652e36 100644 --- a/app/src/main/java/com/nextcloud/talk/ui/dialog/ChooseAccountDialogFragment.java +++ b/app/src/main/java/com/nextcloud/talk/ui/dialog/ChooseAccountDialogFragment.java @@ -129,10 +129,10 @@ public class ChooseAccountDialogFragment extends DialogFragment { .setOldController(binding.currentAccount.userIcon.getController()) .setAutoPlayAnimations(true) .setImageRequest(DisplayUtils.getImageRequestForUrl( - ApiUtils.getUrlForAvatarWithName( + ApiUtils.getUrlForAvatar( user.getBaseUrl(), user.getUserId(), - R.dimen.small_item_height), + false), null)) .build(); binding.currentAccount.userIcon.setController(draweeController); diff --git a/app/src/main/java/com/nextcloud/talk/utils/ApiUtils.java b/app/src/main/java/com/nextcloud/talk/utils/ApiUtils.java index 89ed1f667..b189c0f4f 100644 --- a/app/src/main/java/com/nextcloud/talk/utils/ApiUtils.java +++ b/app/src/main/java/com/nextcloud/talk/utils/ApiUtils.java @@ -44,6 +44,8 @@ public class ApiUtils { public static final int APIv2 = 2; public static final int APIv3 = 3; public static final int APIv4 = 4; + public static final int AVATAR_SIZE_BIG = 512; + public static final int AVATAR_SIZE_SMALL = 64; private static final String TAG = "ApiUtils"; private static final String ocsApiVersion = "/ocs/v2.php"; private static final String spreedApiVersion = "/apps/spreed/api/v1"; @@ -347,22 +349,13 @@ public class ApiUtils { return "/status.php"; } - public static String getUrlForAvatarWithNameAndPixels(String baseUrl, String name, int avatarSize) { + public static String getUrlForAvatar(String baseUrl, String name, boolean requestBigSize) { + int avatarSize = requestBigSize ? AVATAR_SIZE_BIG : AVATAR_SIZE_SMALL; return baseUrl + "/index.php/avatar/" + Uri.encode(name) + "/" + avatarSize; } - public static String getUrlForAvatarWithName(String baseUrl, String name, @DimenRes int avatarSize) { - avatarSize = Math.round(NextcloudTalkApplication - .Companion.getSharedApplication().getResources().getDimension(avatarSize)); - - return baseUrl + "/index.php/avatar/" + Uri.encode(name) + "/" + avatarSize; - } - - public static String getUrlForAvatarWithNameForGuests(String baseUrl, String name, - @DimenRes int avatarSize) { - avatarSize = Math.round(NextcloudTalkApplication - .Companion.getSharedApplication().getResources().getDimension(avatarSize)); - + public static String getUrlForGuestAvatar(String baseUrl, String name, boolean requestBigSize) { + int avatarSize = requestBigSize ? AVATAR_SIZE_BIG : AVATAR_SIZE_SMALL; return baseUrl + "/index.php/avatar/guest/" + Uri.encode(name) + "/" + avatarSize; } diff --git a/app/src/main/java/com/nextcloud/talk/utils/DisplayUtils.java b/app/src/main/java/com/nextcloud/talk/utils/DisplayUtils.java index acff16d5f..5b910ceed 100644 --- a/app/src/main/java/com/nextcloud/talk/utils/DisplayUtils.java +++ b/app/src/main/java/com/nextcloud/talk/utils/DisplayUtils.java @@ -318,11 +318,11 @@ public class DisplayUtils { chip.setBounds(0, 0, chip.getIntrinsicWidth(), chip.getIntrinsicHeight()); if (!isCall) { - String url = ApiUtils.getUrlForAvatarWithName(conversationUser.getBaseUrl(), id, R.dimen.avatar_size_big); + String url = ApiUtils.getUrlForAvatar(conversationUser.getBaseUrl(), id, true); if ("guests".equals(type) || "guest".equals(type)) { - url = ApiUtils.getUrlForAvatarWithNameForGuests( + url = ApiUtils.getUrlForGuestAvatar( conversationUser.getBaseUrl(), - String.valueOf(label), R.dimen.avatar_size_big); + String.valueOf(label), true); } ImageRequest imageRequest = getImageRequestForUrl(url, null); ImagePipeline imagePipeline = Fresco.getImagePipeline(); @@ -572,7 +572,7 @@ public class DisplayUtils { avatarId = user.getUsername(); } - String avatarString = ApiUtils.getUrlForAvatarWithName(user.getBaseUrl(), avatarId, R.dimen.avatar_size_big); + String avatarString = ApiUtils.getUrlForAvatar(user.getBaseUrl(), avatarId, true); // clear cache if (deleteCache) {