Add subtitle in ApsAlert by chemidy · Pull Request #219 · firebase/firebase-admin-java
Expand Up
@@ -34,6 +34,9 @@ public class ApsAlert {
@Key("title")
private final String title;
@Key("subtitle") private final String subtitle;
@Key("body") private final String body;
Expand All @@ -49,6 +52,12 @@ public class ApsAlert { @Key("title-loc-args") private final List<String> titleLocArgs;
@Key("subtitle-loc-key") private final String subtitleLocKey;
@Key("subtitle-loc-args") private final List<String> subtitleLocArgs;
@Key("action-loc-key") private final String actionLocKey;
Expand All @@ -57,6 +66,7 @@ public class ApsAlert {
private ApsAlert(Builder builder) { this.title = builder.title; this.subtitle = builder.subtitle; this.body = builder.body; this.actionLocKey = builder.actionLocKey; this.locKey = builder.locKey; Expand All @@ -76,6 +86,14 @@ private ApsAlert(Builder builder) { } else { this.titleLocArgs = null; } this.subtitleLocKey = builder.subtitleLocKey; if (!builder.subtitleLocArgs.isEmpty()) { checkArgument(!Strings.isNullOrEmpty(builder.subtitleLocKey), "subtitleLocKey is required when specifying subtitleLocArgs"); this.subtitleLocArgs = ImmutableList.copyOf(builder.subtitleLocArgs); } else { this.subtitleLocArgs = null; } this.launchImage = builder.launchImage; }
Expand All @@ -91,11 +109,14 @@ public static Builder builder() { public static class Builder {
private String title; private String subtitle; private String body; private String locKey; private List<String> locArgs = new ArrayList<>(); private String titleLocKey; private List<String> titleLocArgs = new ArrayList<>(); private String subtitleLocKey; private List<String> subtitleLocArgs = new ArrayList<>(); private String actionLocKey; private String launchImage;
Expand All @@ -113,6 +134,17 @@ public Builder setTitle(String title) { return this; }
/** * Sets the subtitle of the alert. * * @param subtitle Subtitle of the notification. * @return This builder. */ public Builder setSubtitle(String subtitle) { this.subtitle = subtitle; return this; }
/** * Sets the body of the alert. When provided, overrides the body sent * via {@link Notification}. Expand Down Expand Up @@ -209,6 +241,42 @@ public Builder addAllTitleLocArgs(@NonNull List<String> args) { return this; }
/** * Sets the key of the subtitle string in the app's string resources to use to localize * the subtitle text. * * @param subtitleLocKey Resource key string. * @return This builder. */ public Builder setSubtitleLocalizationKey(String subtitleLocKey) { this.subtitleLocKey = subtitleLocKey; return this; }
/** * Adds a resource key string that will be used in place of the format specifiers in * {@code subtitleLocKey}. * * @param arg Resource key string. * @return This builder. */ public Builder addSubtitleLocalizationArg(@NonNull String arg) { this.subtitleLocArgs.add(arg); return this; }
/** * Adds a list of resource keys that will be used in place of the format specifiers in * {@code subtitleLocKey}. * * @param args List of resource key strings. * @return This builder. */ public Builder addAllSubtitleLocArgs(@NonNull List<String> args) { this.subtitleLocArgs.addAll(args); return this; }
/** * Sets the launch image for the notification action. * Expand Down
@Key("subtitle") private final String subtitle;
@Key("body") private final String body;
Expand All @@ -49,6 +52,12 @@ public class ApsAlert { @Key("title-loc-args") private final List<String> titleLocArgs;
@Key("subtitle-loc-key") private final String subtitleLocKey;
@Key("subtitle-loc-args") private final List<String> subtitleLocArgs;
@Key("action-loc-key") private final String actionLocKey;
Expand All @@ -57,6 +66,7 @@ public class ApsAlert {
private ApsAlert(Builder builder) { this.title = builder.title; this.subtitle = builder.subtitle; this.body = builder.body; this.actionLocKey = builder.actionLocKey; this.locKey = builder.locKey; Expand All @@ -76,6 +86,14 @@ private ApsAlert(Builder builder) { } else { this.titleLocArgs = null; } this.subtitleLocKey = builder.subtitleLocKey; if (!builder.subtitleLocArgs.isEmpty()) { checkArgument(!Strings.isNullOrEmpty(builder.subtitleLocKey), "subtitleLocKey is required when specifying subtitleLocArgs"); this.subtitleLocArgs = ImmutableList.copyOf(builder.subtitleLocArgs); } else { this.subtitleLocArgs = null; } this.launchImage = builder.launchImage; }
Expand All @@ -91,11 +109,14 @@ public static Builder builder() { public static class Builder {
private String title; private String subtitle; private String body; private String locKey; private List<String> locArgs = new ArrayList<>(); private String titleLocKey; private List<String> titleLocArgs = new ArrayList<>(); private String subtitleLocKey; private List<String> subtitleLocArgs = new ArrayList<>(); private String actionLocKey; private String launchImage;
Expand All @@ -113,6 +134,17 @@ public Builder setTitle(String title) { return this; }
/** * Sets the subtitle of the alert. * * @param subtitle Subtitle of the notification. * @return This builder. */ public Builder setSubtitle(String subtitle) { this.subtitle = subtitle; return this; }
/** * Sets the body of the alert. When provided, overrides the body sent * via {@link Notification}. Expand Down Expand Up @@ -209,6 +241,42 @@ public Builder addAllTitleLocArgs(@NonNull List<String> args) { return this; }
/** * Sets the key of the subtitle string in the app's string resources to use to localize * the subtitle text. * * @param subtitleLocKey Resource key string. * @return This builder. */ public Builder setSubtitleLocalizationKey(String subtitleLocKey) { this.subtitleLocKey = subtitleLocKey; return this; }
/** * Adds a resource key string that will be used in place of the format specifiers in * {@code subtitleLocKey}. * * @param arg Resource key string. * @return This builder. */ public Builder addSubtitleLocalizationArg(@NonNull String arg) { this.subtitleLocArgs.add(arg); return this; }
/** * Adds a list of resource keys that will be used in place of the format specifiers in * {@code subtitleLocKey}. * * @param args List of resource key strings. * @return This builder. */ public Builder addAllSubtitleLocArgs(@NonNull List<String> args) { this.subtitleLocArgs.addAll(args); return this; }
/** * Sets the launch image for the notification action. * Expand Down