Add low and high detail svgs to badges

This commit is contained in:
Ehren Kret 2021-09-27 17:00:09 -05:00
parent 7864405efd
commit 559026933d
6 changed files with 83 additions and 21 deletions

View File

@ -110,6 +110,8 @@ public class ConfiguredProfileBadgeConverter implements ProfileBadgeConverter {
configuration.getXhdpi(), configuration.getXhdpi(),
configuration.getXxhdpi(), configuration.getXxhdpi(),
configuration.getXxxhdpi(), configuration.getXxxhdpi(),
configuration.getLowDetailSvg(),
configuration.getHighDetailSvg(),
accountBadge.getExpiration(), accountBadge.getExpiration(),
accountBadge.isVisible()); accountBadge.isVisible());
}) })
@ -128,6 +130,8 @@ public class ConfiguredProfileBadgeConverter implements ProfileBadgeConverter {
configuration.getXhdpi(), configuration.getXhdpi(),
configuration.getXxhdpi(), configuration.getXxhdpi(),
configuration.getXxxhdpi(), configuration.getXxxhdpi(),
configuration.getLowDetailSvg(),
configuration.getHighDetailSvg(),
now.plus(Duration.ofDays(1)), now.plus(Duration.ofDays(1)),
true); true);
}).collect(Collectors.toList())); }).collect(Collectors.toList()));
@ -146,12 +150,14 @@ public class ConfiguredProfileBadgeConverter implements ProfileBadgeConverter {
final String xhdpi, final String xhdpi,
final String xxhdpi, final String xxhdpi,
final String xxxhdpi, final String xxxhdpi,
final String lsvg,
final String hsvg,
final Instant expiration, final Instant expiration,
final boolean visible) { final boolean visible) {
if (isSelf) { if (isSelf) {
return new SelfBadge(id, category, name, description, ldpi, mdpi, hdpi, xhdpi, xxhdpi, xxxhdpi, expiration, visible); return new SelfBadge(id, category, name, description, ldpi, mdpi, hdpi, xhdpi, xxhdpi, xxxhdpi, lsvg, hsvg, expiration, visible);
} else { } else {
return new Badge(id, category, name, description, ldpi, mdpi, hdpi, xhdpi, xxhdpi, xxxhdpi); return new Badge(id, category, name, description, ldpi, mdpi, hdpi, xhdpi, xxhdpi, xxxhdpi, lsvg, hsvg);
} }
} }
} }

View File

@ -20,6 +20,8 @@ public class BadgeConfiguration {
private final String xhdpi; private final String xhdpi;
private final String xxhdpi; private final String xxhdpi;
private final String xxxhdpi; private final String xxxhdpi;
private final String lowDetailSvg;
private final String highDetailSvg;
@JsonCreator @JsonCreator
public BadgeConfiguration( public BadgeConfiguration(
@ -30,7 +32,9 @@ public class BadgeConfiguration {
@JsonProperty("hdpi") final String hdpi, @JsonProperty("hdpi") final String hdpi,
@JsonProperty("xhdpi") final String xhdpi, @JsonProperty("xhdpi") final String xhdpi,
@JsonProperty("xxhdpi") final String xxhdpi, @JsonProperty("xxhdpi") final String xxhdpi,
@JsonProperty("xxxhdpi") final String xxxhdpi) { @JsonProperty("xxxhdpi") final String xxxhdpi,
@JsonProperty("lowDetailSvg") final String lowDetailSvg,
@JsonProperty("highDetailSvg") final String highDetailSvg) {
this.id = id; this.id = id;
this.category = category; this.category = category;
this.ldpi = ldpi; this.ldpi = ldpi;
@ -39,6 +43,8 @@ public class BadgeConfiguration {
this.xhdpi = xhdpi; this.xhdpi = xhdpi;
this.xxhdpi = xxhdpi; this.xxhdpi = xxhdpi;
this.xxxhdpi = xxxhdpi; this.xxxhdpi = xxxhdpi;
this.lowDetailSvg = lowDetailSvg;
this.highDetailSvg = highDetailSvg;
} }
@NotEmpty @NotEmpty
@ -51,30 +57,46 @@ public class BadgeConfiguration {
return category; return category;
} }
@NotEmpty
public String getLdpi() { public String getLdpi() {
return ldpi; return ldpi;
} }
@NotEmpty
public String getMdpi() { public String getMdpi() {
return mdpi; return mdpi;
} }
@NotEmpty
public String getHdpi() { public String getHdpi() {
return hdpi; return hdpi;
} }
@NotEmpty
public String getXhdpi() { public String getXhdpi() {
return xhdpi; return xhdpi;
} }
@NotEmpty
public String getXxhdpi() { public String getXxhdpi() {
return xxhdpi; return xxhdpi;
} }
@NotEmpty
public String getXxxhdpi() { public String getXxxhdpi() {
return xxxhdpi; return xxxhdpi;
} }
@NotEmpty
public String getLowDetailSvg() {
return lowDetailSvg;
}
@NotEmpty
public String getHighDetailSvg() {
return highDetailSvg;
}
public boolean isTestBadge() { public boolean isTestBadge() {
return CATEGORY_TESTING.equals(category); return CATEGORY_TESTING.equals(category);
} }

View File

@ -20,6 +20,8 @@ public class Badge {
private final String xhdpi; private final String xhdpi;
private final String xxhdpi; private final String xxhdpi;
private final String xxxhdpi; private final String xxxhdpi;
private final String lsvg;
private final String hsvg;
@JsonCreator @JsonCreator
public Badge( public Badge(
@ -32,7 +34,9 @@ public class Badge {
@JsonProperty("hdpi") final String hdpi, @JsonProperty("hdpi") final String hdpi,
@JsonProperty("xhdpi") final String xhdpi, @JsonProperty("xhdpi") final String xhdpi,
@JsonProperty("xxhdpi") final String xxhdpi, @JsonProperty("xxhdpi") final String xxhdpi,
@JsonProperty("xxxhdpi") final String xxxhdpi) { @JsonProperty("xxxhdpi") final String xxxhdpi,
@JsonProperty("lsvg") final String lsvg,
@JsonProperty("hsvg") final String hsvg) {
this.id = id; this.id = id;
this.category = category; this.category = category;
this.name = name; this.name = name;
@ -43,6 +47,8 @@ public class Badge {
this.xhdpi = xhdpi; this.xhdpi = xhdpi;
this.xxhdpi = xxhdpi; this.xxhdpi = xxhdpi;
this.xxxhdpi = xxxhdpi; this.xxxhdpi = xxxhdpi;
this.lsvg = lsvg;
this.hsvg = hsvg;
} }
public String getId() { public String getId() {
@ -85,6 +91,14 @@ public class Badge {
return xxxhdpi; return xxxhdpi;
} }
public String getLsvg() {
return lsvg;
}
public String getHsvg() {
return hsvg;
}
@Override @Override
public boolean equals(final Object o) { public boolean equals(final Object o) {
if (this == o) { if (this == o) {
@ -94,16 +108,34 @@ public class Badge {
return false; return false;
} }
Badge badge = (Badge) o; Badge badge = (Badge) o;
return Objects.equals(id, badge.id) && Objects.equals(category, return Objects.equals(id, badge.id)
badge.category) && Objects.equals(name, badge.name) && Objects.equals( && Objects.equals(category, badge.category)
description, badge.description) && Objects.equals(ldpi, badge.ldpi) && Objects.equals(name, badge.name)
&& Objects.equals(mdpi, badge.mdpi) && Objects.equals(hdpi, badge.hdpi) && Objects.equals(description, badge.description)
&& Objects.equals(xhdpi, badge.xhdpi) && Objects.equals(xxhdpi, && Objects.equals(ldpi, badge.ldpi)
badge.xxhdpi) && Objects.equals(xxxhdpi, badge.xxxhdpi); && Objects.equals(mdpi, badge.mdpi)
&& Objects.equals(hdpi, badge.hdpi)
&& Objects.equals(xhdpi, badge.xhdpi)
&& Objects.equals(xxhdpi, badge.xxhdpi)
&& Objects.equals(xxxhdpi, badge.xxxhdpi)
&& Objects.equals(lsvg, badge.lsvg)
&& Objects.equals(hsvg, badge.hsvg);
} }
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hash(id, category, name, description, ldpi, mdpi, hdpi, xhdpi, xxhdpi, xxxhdpi); return Objects.hash(
id,
category,
name,
description,
ldpi,
mdpi,
hdpi,
xhdpi,
xxhdpi,
xxxhdpi,
lsvg,
hsvg);
} }
} }

View File

@ -27,9 +27,11 @@ public class SelfBadge extends Badge {
@JsonProperty("xhdpi") final String xhdpi, @JsonProperty("xhdpi") final String xhdpi,
@JsonProperty("xxhdpi") final String xxhdpi, @JsonProperty("xxhdpi") final String xxhdpi,
@JsonProperty("xxxhdpi") final String xxxhdpi, @JsonProperty("xxxhdpi") final String xxxhdpi,
@JsonProperty("lsvg") final String lsvg,
@JsonProperty("hsvg") final String hsvg,
final Instant expiration, final Instant expiration,
final boolean visible) { final boolean visible) {
super(id, category, name, description, ldpi, mdpi, hdpi, xhdpi, xxhdpi, xxxhdpi); super(id, category, name, description, ldpi, mdpi, hdpi, xhdpi, xxhdpi, xxxhdpi, lsvg, hsvg);
this.expiration = expiration; this.expiration = expiration;
this.visible = visible; this.visible = visible;
} }

View File

@ -63,7 +63,7 @@ public class ConfiguredProfileBadgeConverterTest {
} }
private static BadgeConfiguration newBadge(int i) { private static BadgeConfiguration newBadge(int i) {
return new BadgeConfiguration(idFor(i), "other", "l", "m", "h", "x", "xx", "xxx"); return new BadgeConfiguration(idFor(i), "other", "l", "m", "h", "x", "xx", "xxx", "s", "S");
} }
private BadgesConfiguration createBadges(int count) { private BadgesConfiguration createBadges(int count) {
@ -133,15 +133,15 @@ public class ConfiguredProfileBadgeConverterTest {
arguments(idFor(0), expired, false, false, null), arguments(idFor(0), expired, false, false, null),
arguments(idFor(0), notExpired, false, false, null), arguments(idFor(0), notExpired, false, false, null),
arguments(idFor(0), expired, true, false, null), arguments(idFor(0), expired, true, false, null),
arguments(idFor(0), notExpired, true, false, new Badge(idFor(0), "other", nameFor(0), desriptionFor(0), "l", "m", "h", "x", "xx", "xxx")), arguments(idFor(0), notExpired, true, false, new Badge(idFor(0), "other", nameFor(0), desriptionFor(0), "l", "m", "h", "x", "xx", "xxx", "s", "S")),
arguments(idFor(1), expired, false, false, null), arguments(idFor(1), expired, false, false, null),
arguments(idFor(1), notExpired, false, false, null), arguments(idFor(1), notExpired, false, false, null),
arguments(idFor(1), expired, true, false, null), arguments(idFor(1), expired, true, false, null),
arguments(idFor(1), notExpired, true, false, null), arguments(idFor(1), notExpired, true, false, null),
arguments(idFor(0), expired, false, true, null), arguments(idFor(0), expired, false, true, null),
arguments(idFor(0), notExpired, false, true, new SelfBadge(idFor(0), "other", nameFor(0), desriptionFor(0), "l", "m", "h", "x", "xx", "xxx", notExpired, false)), arguments(idFor(0), notExpired, false, true, new SelfBadge(idFor(0), "other", nameFor(0), desriptionFor(0), "l", "m", "h", "x", "xx", "xxx", "s", "S", notExpired, false)),
arguments(idFor(0), expired, true, true, null), arguments(idFor(0), expired, true, true, null),
arguments(idFor(0), notExpired, true, true, new SelfBadge(idFor(0), "other", nameFor(0), desriptionFor(0), "l", "m", "h", "x", "xx", "xxx", notExpired, true)), arguments(idFor(0), notExpired, true, true, new SelfBadge(idFor(0), "other", nameFor(0), desriptionFor(0), "l", "m", "h", "x", "xx", "xxx", "s", "S", notExpired, true)),
arguments(idFor(1), expired, false, true, null), arguments(idFor(1), expired, false, true, null),
arguments(idFor(1), notExpired, false, true, null), arguments(idFor(1), notExpired, false, true, null),
arguments(idFor(1), expired, true, true, null), arguments(idFor(1), expired, true, true, null),

View File

@ -108,13 +108,13 @@ class ProfileControllerTest {
usernamesManager, usernamesManager,
dynamicConfigurationManager, dynamicConfigurationManager,
(acceptableLanguages, accountBadges, isSelf) -> List.of( (acceptableLanguages, accountBadges, isSelf) -> List.of(
new Badge("TEST", "other", "Test Badge", "This badge is in unit tests.", "l", "m", "h", "x", "xx", "xxx") new Badge("TEST", "other", "Test Badge", "This badge is in unit tests.", "l", "m", "h", "x", "xx", "xxx", "s", "S")
), ),
new BadgesConfiguration(List.of( new BadgesConfiguration(List.of(
new BadgeConfiguration("TEST", "other", "l", "m", "h", "x", "xx", "xxx"), new BadgeConfiguration("TEST", "other", "l", "m", "h", "x", "xx", "xxx", "s", "S"),
new BadgeConfiguration("TEST1", "testing", "l", "m", "h", "x", "xx", "xxx"), new BadgeConfiguration("TEST1", "testing", "l", "m", "h", "x", "xx", "xxx", "s", "S"),
new BadgeConfiguration("TEST2", "testing", "l", "m", "h", "x", "xx", "xxx"), new BadgeConfiguration("TEST2", "testing", "l", "m", "h", "x", "xx", "xxx", "s", "S"),
new BadgeConfiguration("TEST3", "testing", "l", "m", "h", "x", "xx", "xxx") new BadgeConfiguration("TEST3", "testing", "l", "m", "h", "x", "xx", "xxx", "s", "S")
), List.of("TEST1")), ), List.of("TEST1")),
s3client, s3client,
postPolicyGenerator, postPolicyGenerator,