Include 32px and 100px avatar URLs
PolyGerrit UI uses these other sizes and would prefer URLs for them. Change-Id: Id35878427e3d69fc44435306a669c7cdcfdba9ab
This commit is contained in:
@@ -12,12 +12,10 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
|
|
||||||
package com.google.gerrit.server.account;
|
package com.google.gerrit.server.account;
|
||||||
|
|
||||||
import com.google.common.base.Strings;
|
import com.google.common.base.Strings;
|
||||||
import com.google.common.collect.ArrayListMultimap;
|
import com.google.common.collect.ArrayListMultimap;
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
import com.google.common.collect.Multimap;
|
import com.google.common.collect.Multimap;
|
||||||
import com.google.gerrit.extensions.common.AccountInfo;
|
import com.google.gerrit.extensions.common.AccountInfo;
|
||||||
import com.google.gerrit.extensions.common.AvatarInfo;
|
import com.google.gerrit.extensions.common.AvatarInfo;
|
||||||
@@ -32,6 +30,7 @@ import com.google.inject.Inject;
|
|||||||
import com.google.inject.Provider;
|
import com.google.inject.Provider;
|
||||||
import com.google.inject.Singleton;
|
import com.google.inject.Singleton;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@@ -123,17 +122,36 @@ public class InternalAccountDirectory extends AccountDirectory {
|
|||||||
if (options.contains(FillOptions.AVATARS)) {
|
if (options.contains(FillOptions.AVATARS)) {
|
||||||
AvatarProvider ap = avatar.get();
|
AvatarProvider ap = avatar.get();
|
||||||
if (ap != null) {
|
if (ap != null) {
|
||||||
info.avatars = Lists.newArrayListWithCapacity(1);
|
info.avatars = new ArrayList<>(3);
|
||||||
String u = ap.getUrl(
|
IdentifiedUser user = userFactory.create(account.getId());
|
||||||
userFactory.create(account.getId()),
|
|
||||||
AvatarInfo.DEFAULT_SIZE);
|
// GWT UI uses DEFAULT_SIZE (26px).
|
||||||
if (u != null) {
|
addAvatar(ap, info, user, AvatarInfo.DEFAULT_SIZE);
|
||||||
AvatarInfo a = new AvatarInfo();
|
|
||||||
a.url = u;
|
// PolyGerrit UI prefers 32px and 100px.
|
||||||
a.height = AvatarInfo.DEFAULT_SIZE;
|
if (!info.avatars.isEmpty()) {
|
||||||
info.avatars.add(a);
|
if (32 != AvatarInfo.DEFAULT_SIZE) {
|
||||||
|
addAvatar(ap, info, user, 32);
|
||||||
|
}
|
||||||
|
if (100 != AvatarInfo.DEFAULT_SIZE) {
|
||||||
|
addAvatar(ap, info, user, 100);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void addAvatar(
|
||||||
|
AvatarProvider provider,
|
||||||
|
AccountInfo account,
|
||||||
|
IdentifiedUser user,
|
||||||
|
int size) {
|
||||||
|
String url = provider.getUrl(user, size);
|
||||||
|
if (url != null) {
|
||||||
|
AvatarInfo avatar = new AvatarInfo();
|
||||||
|
avatar.url = url;
|
||||||
|
avatar.height = size;
|
||||||
|
account.avatars.add(avatar);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user