Update badge configuration to new style
This commit is contained in:
parent
1af53f2612
commit
5f2656710c
|
@ -7,44 +7,29 @@ package org.whispersystems.textsecuregcm.configuration;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import java.util.List;
|
||||||
import javax.validation.constraints.NotEmpty;
|
import javax.validation.constraints.NotEmpty;
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
import org.whispersystems.textsecuregcm.util.ExactlySize;
|
||||||
|
|
||||||
public class BadgeConfiguration {
|
public class BadgeConfiguration {
|
||||||
public static final String CATEGORY_TESTING = "testing";
|
public static final String CATEGORY_TESTING = "testing";
|
||||||
|
|
||||||
private final String id;
|
private final String id;
|
||||||
private final String category;
|
private final String category;
|
||||||
private final String ldpi;
|
private final List<String> sprites;
|
||||||
private final String mdpi;
|
private final List<String> svgs;
|
||||||
private final String hdpi;
|
|
||||||
private final String xhdpi;
|
|
||||||
private final String xxhdpi;
|
|
||||||
private final String xxxhdpi;
|
|
||||||
private final String lowDetailSvg;
|
|
||||||
private final String highDetailSvg;
|
|
||||||
|
|
||||||
@JsonCreator
|
@JsonCreator
|
||||||
public BadgeConfiguration(
|
public BadgeConfiguration(
|
||||||
@JsonProperty("id") final String id,
|
@JsonProperty("id") final String id,
|
||||||
@JsonProperty("category") final String category,
|
@JsonProperty("category") final String category,
|
||||||
@JsonProperty("ldpi") final String ldpi,
|
@JsonProperty("sprites") final List<String> sprites,
|
||||||
@JsonProperty("mdpi") final String mdpi,
|
@JsonProperty("svgs") final List<String> svgs) {
|
||||||
@JsonProperty("hdpi") final String hdpi,
|
|
||||||
@JsonProperty("xhdpi") final String xhdpi,
|
|
||||||
@JsonProperty("xxhdpi") final String xxhdpi,
|
|
||||||
@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.sprites = sprites;
|
||||||
this.mdpi = mdpi;
|
this.svgs = svgs;
|
||||||
this.hdpi = hdpi;
|
|
||||||
this.xhdpi = xhdpi;
|
|
||||||
this.xxhdpi = xxhdpi;
|
|
||||||
this.xxxhdpi = xxxhdpi;
|
|
||||||
this.lowDetailSvg = lowDetailSvg;
|
|
||||||
this.highDetailSvg = highDetailSvg;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotEmpty
|
@NotEmpty
|
||||||
|
@ -57,47 +42,59 @@ public class BadgeConfiguration {
|
||||||
return category;
|
return category;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotEmpty
|
@NotNull
|
||||||
public String getLdpi() {
|
@ExactlySize(6)
|
||||||
return ldpi;
|
public List<String> getSprites() {
|
||||||
|
return sprites;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotEmpty
|
@NotNull
|
||||||
public String getMdpi() {
|
@ExactlySize(4)
|
||||||
return mdpi;
|
public List<String> getSvgs() {
|
||||||
}
|
return svgs;
|
||||||
|
|
||||||
@NotEmpty
|
|
||||||
public String getHdpi() {
|
|
||||||
return hdpi;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotEmpty
|
|
||||||
public String getXhdpi() {
|
|
||||||
return xhdpi;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotEmpty
|
|
||||||
public String getXxhdpi() {
|
|
||||||
return xxhdpi;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotEmpty
|
|
||||||
public String getXxxhdpi() {
|
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
public String getLdpi() {
|
||||||
|
return sprites.get(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
public String getMdpi() {
|
||||||
|
return sprites.get(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
public String getHdpi() {
|
||||||
|
return sprites.get(2);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
public String getXhdpi() {
|
||||||
|
return sprites.get(3);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
public String getXxhdpi() {
|
||||||
|
return sprites.get(4);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
public String getXxxhdpi() {
|
||||||
|
return sprites.get(5);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
public String getLowDetailSvg() {
|
||||||
|
return svgs.get(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
public String getHighDetailSvg() {
|
||||||
|
return svgs.get(3);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,7 @@ import javax.validation.Payload;
|
||||||
@Constraint(validatedBy = {
|
@Constraint(validatedBy = {
|
||||||
ExactlySizeValidatorForString.class,
|
ExactlySizeValidatorForString.class,
|
||||||
ExactlySizeValidatorForArraysOfByte.class,
|
ExactlySizeValidatorForArraysOfByte.class,
|
||||||
|
ExactlySizeValidatorForCollection.class,
|
||||||
})
|
})
|
||||||
@Documented
|
@Documented
|
||||||
public @interface ExactlySize {
|
public @interface ExactlySize {
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2021 Signal Messenger, LLC
|
||||||
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.whispersystems.textsecuregcm.util;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
|
public class ExactlySizeValidatorForCollection extends ExactlySizeValidator<Collection<?>> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected int size(final Collection<?> value) {
|
||||||
|
return value == null ? 0 : value.size();
|
||||||
|
}
|
||||||
|
}
|
|
@ -64,7 +64,8 @@ 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", "s", "S");
|
return new BadgeConfiguration(
|
||||||
|
idFor(i), "other", List.of("l", "m", "h", "x", "xx", "xxx"), List.of("s", "m", "M", "S"));
|
||||||
}
|
}
|
||||||
|
|
||||||
private BadgesConfiguration createBadges(int count) {
|
private BadgesConfiguration createBadges(int count) {
|
||||||
|
|
|
@ -89,10 +89,10 @@ class DonationControllerTest {
|
||||||
static BadgesConfiguration getBadgesConfiguration() {
|
static BadgesConfiguration getBadgesConfiguration() {
|
||||||
return new BadgesConfiguration(
|
return new BadgesConfiguration(
|
||||||
List.of(
|
List.of(
|
||||||
new BadgeConfiguration("TEST", "other", "l", "m", "h", "x", "xx", "xxx", "s", "S"),
|
new BadgeConfiguration("TEST", "other", List.of("l", "m", "h", "x", "xx", "xxx"), List.of("s", "m", "M", "S")),
|
||||||
new BadgeConfiguration("TEST1", "testing", "l", "m", "h", "x", "xx", "xxx", "s", "S"),
|
new BadgeConfiguration("TEST1", "testing", List.of("l", "m", "h", "x", "xx", "xxx"), List.of("s", "m", "M", "S")),
|
||||||
new BadgeConfiguration("TEST2", "testing", "l", "m", "h", "x", "xx", "xxx", "s", "S"),
|
new BadgeConfiguration("TEST2", "testing", List.of("l", "m", "h", "x", "xx", "xxx"), List.of("s", "m", "M", "S")),
|
||||||
new BadgeConfiguration("TEST3", "testing", "l", "m", "h", "x", "xx", "xxx", "s", "S")),
|
new BadgeConfiguration("TEST3", "testing", List.of("l", "m", "h", "x", "xx", "xxx"), List.of("s", "m", "M", "S"))),
|
||||||
List.of("TEST"),
|
List.of("TEST"),
|
||||||
Map.of(1L, "TEST1", 2L, "TEST2", 3L, "TEST3"));
|
Map.of(1L, "TEST1", 2L, "TEST2", 3L, "TEST3"));
|
||||||
}
|
}
|
||||||
|
|
|
@ -112,10 +112,10 @@ class ProfileControllerTest {
|
||||||
new Badge("TEST", "other", "Test Badge", "This badge is in unit tests.", "l", "m", "h", "x", "xx", "xxx", "s", "S")
|
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", "s", "S"),
|
new BadgeConfiguration("TEST", "other", List.of("l", "m", "h", "x", "xx", "xxx"), List.of("s", "m", "M", "S")),
|
||||||
new BadgeConfiguration("TEST1", "testing", "l", "m", "h", "x", "xx", "xxx", "s", "S"),
|
new BadgeConfiguration("TEST1", "testing", List.of("l", "m", "h", "x", "xx", "xxx"), List.of("s", "m", "M", "S")),
|
||||||
new BadgeConfiguration("TEST2", "testing", "l", "m", "h", "x", "xx", "xxx", "s", "S"),
|
new BadgeConfiguration("TEST2", "testing", List.of("l", "m", "h", "x", "xx", "xxx"), List.of("s", "m", "M", "S")),
|
||||||
new BadgeConfiguration("TEST3", "testing", "l", "m", "h", "x", "xx", "xxx", "s", "S")
|
new BadgeConfiguration("TEST3", "testing", List.of("l", "m", "h", "x", "xx", "xxx"), List.of("s", "m", "M", "S"))
|
||||||
), List.of("TEST1"), Map.of(1L, "TEST1", 2L, "TEST2", 3L, "TEST3")),
|
), List.of("TEST1"), Map.of(1L, "TEST1", 2L, "TEST2", 3L, "TEST3")),
|
||||||
s3client,
|
s3client,
|
||||||
postPolicyGenerator,
|
postPolicyGenerator,
|
||||||
|
|
Loading…
Reference in New Issue