mirror of
https://github.com/signalapp/Signal-Server
synced 2026-04-20 05:38:04 +01:00
Remove single URL in favor of density based sprite sheets
This commit is contained in:
@@ -6,7 +6,6 @@
|
||||
package org.whispersystems.textsecuregcm.badges;
|
||||
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import java.net.URL;
|
||||
import java.time.Clock;
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
@@ -103,9 +102,14 @@ public class ConfiguredProfileBadgeConverter implements ProfileBadgeConverter {
|
||||
isSelf,
|
||||
accountBadge.getId(),
|
||||
configuration.getCategory(),
|
||||
configuration.getImageUrl(),
|
||||
resourceBundle.getString(accountBadge.getId() + "_name"),
|
||||
resourceBundle.getString(accountBadge.getId() + "_description"),
|
||||
configuration.getLdpi(),
|
||||
configuration.getMdpi(),
|
||||
configuration.getHdpi(),
|
||||
configuration.getXhdpi(),
|
||||
configuration.getXxhdpi(),
|
||||
configuration.getXxxhdpi(),
|
||||
accountBadge.getExpiration(),
|
||||
accountBadge.isVisible());
|
||||
})
|
||||
@@ -116,9 +120,14 @@ public class ConfiguredProfileBadgeConverter implements ProfileBadgeConverter {
|
||||
isSelf,
|
||||
id,
|
||||
configuration.getCategory(),
|
||||
configuration.getImageUrl(),
|
||||
resourceBundle.getString(id + "_name"),
|
||||
resourceBundle.getString(id + "_description"),
|
||||
configuration.getLdpi(),
|
||||
configuration.getMdpi(),
|
||||
configuration.getHdpi(),
|
||||
configuration.getXhdpi(),
|
||||
configuration.getXxhdpi(),
|
||||
configuration.getXxxhdpi(),
|
||||
now.plus(Duration.ofDays(1)),
|
||||
true);
|
||||
}).collect(Collectors.toList()));
|
||||
@@ -129,15 +138,20 @@ public class ConfiguredProfileBadgeConverter implements ProfileBadgeConverter {
|
||||
final boolean isSelf,
|
||||
final String id,
|
||||
final String category,
|
||||
final URL imageUrl,
|
||||
final String name,
|
||||
final String description,
|
||||
final String ldpi,
|
||||
final String mdpi,
|
||||
final String hdpi,
|
||||
final String xhdpi,
|
||||
final String xxhdpi,
|
||||
final String xxxhdpi,
|
||||
final Instant expiration,
|
||||
final boolean visible) {
|
||||
if (isSelf) {
|
||||
return new SelfBadge(id, category, imageUrl, name, description, expiration, visible);
|
||||
return new SelfBadge(id, category, name, description, ldpi, mdpi, hdpi, xhdpi, xxhdpi, xxxhdpi, expiration, visible);
|
||||
} else {
|
||||
return new Badge(id, category, imageUrl, name, description);
|
||||
return new Badge(id, category, name, description, ldpi, mdpi, hdpi, xhdpi, xxhdpi, xxxhdpi);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,27 +7,38 @@ package org.whispersystems.textsecuregcm.configuration;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import java.net.URL;
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
public class BadgeConfiguration {
|
||||
public static final String CATEGORY_TESTING = "testing";
|
||||
|
||||
private final String id;
|
||||
private final URL imageUrl;
|
||||
private final String category;
|
||||
private final String ldpi;
|
||||
private final String mdpi;
|
||||
private final String hdpi;
|
||||
private final String xhdpi;
|
||||
private final String xxhdpi;
|
||||
private final String xxxhdpi;
|
||||
|
||||
@JsonCreator
|
||||
public BadgeConfiguration(
|
||||
@JsonProperty("id") final String id,
|
||||
@JsonProperty("imageUrl") @JsonDeserialize(converter = URLDeserializationConverter.class) final URL imageUrl,
|
||||
@JsonProperty("category") final String category) {
|
||||
@JsonProperty("category") final String category,
|
||||
@JsonProperty("ldpi") final String ldpi,
|
||||
@JsonProperty("mdpi") final String mdpi,
|
||||
@JsonProperty("hdpi") final String hdpi,
|
||||
@JsonProperty("xhdpi") final String xhdpi,
|
||||
@JsonProperty("xxhdpi") final String xxhdpi,
|
||||
@JsonProperty("xxxhdpi") final String xxxhdpi) {
|
||||
this.id = id;
|
||||
this.imageUrl = imageUrl;
|
||||
this.category = category;
|
||||
this.ldpi = ldpi;
|
||||
this.mdpi = mdpi;
|
||||
this.hdpi = hdpi;
|
||||
this.xhdpi = xhdpi;
|
||||
this.xxhdpi = xxhdpi;
|
||||
this.xxxhdpi = xxxhdpi;
|
||||
}
|
||||
|
||||
@NotEmpty
|
||||
@@ -35,17 +46,35 @@ public class BadgeConfiguration {
|
||||
return id;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@JsonSerialize(converter = URLSerializationConverter.class)
|
||||
public URL getImageUrl() {
|
||||
return imageUrl;
|
||||
}
|
||||
|
||||
@NotEmpty
|
||||
public String getCategory() {
|
||||
return category;
|
||||
}
|
||||
|
||||
public String getLdpi() {
|
||||
return ldpi;
|
||||
}
|
||||
|
||||
public String getMdpi() {
|
||||
return mdpi;
|
||||
}
|
||||
|
||||
public String getHdpi() {
|
||||
return hdpi;
|
||||
}
|
||||
|
||||
public String getXhdpi() {
|
||||
return xhdpi;
|
||||
}
|
||||
|
||||
public String getXxhdpi() {
|
||||
return xxhdpi;
|
||||
}
|
||||
|
||||
public String getXxxhdpi() {
|
||||
return xxxhdpi;
|
||||
}
|
||||
|
||||
public boolean isTestBadge() {
|
||||
return CATEGORY_TESTING.equals(category);
|
||||
}
|
||||
|
||||
@@ -7,28 +7,42 @@ package org.whispersystems.textsecuregcm.entities;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import java.net.URL;
|
||||
import java.util.Objects;
|
||||
|
||||
public class Badge {
|
||||
private final String id;
|
||||
private final String category;
|
||||
private final URL imageUrl;
|
||||
private final String name;
|
||||
private final String description;
|
||||
private final String ldpi;
|
||||
private final String mdpi;
|
||||
private final String hdpi;
|
||||
private final String xhdpi;
|
||||
private final String xxhdpi;
|
||||
private final String xxxhdpi;
|
||||
|
||||
@JsonCreator
|
||||
public Badge(
|
||||
@JsonProperty("id") final String id,
|
||||
@JsonProperty("category") final String category,
|
||||
@JsonProperty("imageUrl") final URL imageUrl,
|
||||
@JsonProperty("name") final String name,
|
||||
@JsonProperty("description") final String description) {
|
||||
@JsonProperty("description") final String description,
|
||||
@JsonProperty("ldpi") final String ldpi,
|
||||
@JsonProperty("mdpi") final String mdpi,
|
||||
@JsonProperty("hdpi") final String hdpi,
|
||||
@JsonProperty("xhdpi") final String xhdpi,
|
||||
@JsonProperty("xxhdpi") final String xxhdpi,
|
||||
@JsonProperty("xxxhdpi") final String xxxhdpi) {
|
||||
this.id = id;
|
||||
this.category = category;
|
||||
this.imageUrl = imageUrl;
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
this.ldpi = ldpi;
|
||||
this.mdpi = mdpi;
|
||||
this.hdpi = hdpi;
|
||||
this.xhdpi = xhdpi;
|
||||
this.xxhdpi = xxhdpi;
|
||||
this.xxxhdpi = xxxhdpi;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
@@ -39,10 +53,6 @@ public class Badge {
|
||||
return category;
|
||||
}
|
||||
|
||||
public URL getImageUrl() {
|
||||
return imageUrl;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
@@ -51,6 +61,30 @@ public class Badge {
|
||||
return description;
|
||||
}
|
||||
|
||||
public String getLdpi() {
|
||||
return ldpi;
|
||||
}
|
||||
|
||||
public String getMdpi() {
|
||||
return mdpi;
|
||||
}
|
||||
|
||||
public String getHdpi() {
|
||||
return hdpi;
|
||||
}
|
||||
|
||||
public String getXhdpi() {
|
||||
return xhdpi;
|
||||
}
|
||||
|
||||
public String getXxhdpi() {
|
||||
return xxhdpi;
|
||||
}
|
||||
|
||||
public String getXxxhdpi() {
|
||||
return xxxhdpi;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object o) {
|
||||
if (this == o) {
|
||||
@@ -61,13 +95,15 @@ public class Badge {
|
||||
}
|
||||
Badge badge = (Badge) o;
|
||||
return Objects.equals(id, badge.id) && Objects.equals(category,
|
||||
badge.category) && Objects.equals(imageUrl, badge.imageUrl)
|
||||
&& Objects.equals(name, badge.name) && Objects.equals(description,
|
||||
badge.description);
|
||||
badge.category) && Objects.equals(name, badge.name) && Objects.equals(
|
||||
description, badge.description) && Objects.equals(ldpi, badge.ldpi)
|
||||
&& 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);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(id, category, imageUrl, name, description);
|
||||
return Objects.hash(id, category, name, description, ldpi, mdpi, hdpi, xhdpi, xxhdpi, xxxhdpi);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,9 +5,7 @@
|
||||
|
||||
package org.whispersystems.textsecuregcm.entities;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import java.net.URL;
|
||||
import java.time.Instant;
|
||||
import java.util.Objects;
|
||||
|
||||
@@ -18,16 +16,20 @@ public class SelfBadge extends Badge {
|
||||
private final Instant expiration;
|
||||
private final boolean visible;
|
||||
|
||||
@JsonCreator
|
||||
public SelfBadge(
|
||||
@JsonProperty("id") final String id,
|
||||
@JsonProperty("category") final String category,
|
||||
@JsonProperty("imageUrl") final URL imageUrl,
|
||||
@JsonProperty("name") final String name,
|
||||
@JsonProperty("description") final String description,
|
||||
@JsonProperty("expiration") final Instant expiration,
|
||||
@JsonProperty("visible") final boolean visible) {
|
||||
super(id, category, imageUrl, name, description);
|
||||
@JsonProperty("ldpi") final String ldpi,
|
||||
@JsonProperty("mdpi") final String mdpi,
|
||||
@JsonProperty("hdpi") final String hdpi,
|
||||
@JsonProperty("xhdpi") final String xhdpi,
|
||||
@JsonProperty("xxhdpi") final String xxhdpi,
|
||||
@JsonProperty("xxxhdpi") final String xxxhdpi,
|
||||
final Instant expiration,
|
||||
final boolean visible) {
|
||||
super(id, category, name, description, ldpi, mdpi, hdpi, xhdpi, xxhdpi, xxxhdpi);
|
||||
this.expiration = expiration;
|
||||
this.visible = visible;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user