@@ -34,6 +34,9 @@ public class ApsAlert {
3434 @ Key ("title" )
3535 private final String title ;
3636
37+ @ Key ("subtitle" )
38+ private final String subtitle ;
39+
3740 @ Key ("body" )
3841 private final String body ;
3942
@@ -49,6 +52,12 @@ public class ApsAlert {
4952 @ Key ("title-loc-args" )
5053 private final List <String > titleLocArgs ;
5154
55+ @ Key ("subtitle-loc-key" )
56+ private final String subtitleLocKey ;
57+
58+ @ Key ("subtitle-loc-args" )
59+ private final List <String > subtitleLocArgs ;
60+
5261 @ Key ("action-loc-key" )
5362 private final String actionLocKey ;
5463
@@ -57,6 +66,7 @@ public class ApsAlert {
5766
5867 private ApsAlert (Builder builder ) {
5968 this .title = builder .title ;
69+ this .subtitle = builder .subtitle ;
6070 this .body = builder .body ;
6171 this .actionLocKey = builder .actionLocKey ;
6272 this .locKey = builder .locKey ;
@@ -76,6 +86,14 @@ private ApsAlert(Builder builder) {
7686 } else {
7787 this .titleLocArgs = null ;
7888 }
89+ this .subtitleLocKey = builder .subtitleLocKey ;
90+ if (!builder .subtitleLocArgs .isEmpty ()) {
91+ checkArgument (!Strings .isNullOrEmpty (builder .subtitleLocKey ),
92+ "subtitleLocKey is required when specifying subtitleLocArgs" );
93+ this .subtitleLocArgs = ImmutableList .copyOf (builder .subtitleLocArgs );
94+ } else {
95+ this .subtitleLocArgs = null ;
96+ }
7997 this .launchImage = builder .launchImage ;
8098 }
8199
@@ -91,11 +109,14 @@ public static Builder builder() {
91109 public static class Builder {
92110
93111 private String title ;
112+ private String subtitle ;
94113 private String body ;
95114 private String locKey ;
96115 private List <String > locArgs = new ArrayList <>();
97116 private String titleLocKey ;
98117 private List <String > titleLocArgs = new ArrayList <>();
118+ private String subtitleLocKey ;
119+ private List <String > subtitleLocArgs = new ArrayList <>();
99120 private String actionLocKey ;
100121 private String launchImage ;
101122
@@ -113,6 +134,17 @@ public Builder setTitle(String title) {
113134 return this ;
114135 }
115136
137+ /**
138+ * Sets the subtitle of the alert.
139+ *
140+ * @param subtitle Subtitle of the notification.
141+ * @return This builder.
142+ */
143+ public Builder setSubtitle (String subtitle ) {
144+ this .subtitle = subtitle ;
145+ return this ;
146+ }
147+
116148 /**
117149 * Sets the body of the alert. When provided, overrides the body sent
118150 * via {@link Notification}.
@@ -209,6 +241,42 @@ public Builder addAllTitleLocArgs(@NonNull List<String> args) {
209241 return this ;
210242 }
211243
244+ /**
245+ * Sets the key of the subtitle string in the app's string resources to use to localize
246+ * the subtitle text.
247+ *
248+ * @param subtitleLocKey Resource key string.
249+ * @return This builder.
250+ */
251+ public Builder setSubtitleLocalizationKey (String subtitleLocKey ) {
252+ this .subtitleLocKey = subtitleLocKey ;
253+ return this ;
254+ }
255+
256+ /**
257+ * Adds a resource key string that will be used in place of the format specifiers in
258+ * {@code subtitleLocKey}.
259+ *
260+ * @param arg Resource key string.
261+ * @return This builder.
262+ */
263+ public Builder addSubtitleLocalizationArg (@ NonNull String arg ) {
264+ this .subtitleLocArgs .add (arg );
265+ return this ;
266+ }
267+
268+ /**
269+ * Adds a list of resource keys that will be used in place of the format specifiers in
270+ * {@code subtitleLocKey}.
271+ *
272+ * @param args List of resource key strings.
273+ * @return This builder.
274+ */
275+ public Builder addAllSubtitleLocArgs (@ NonNull List <String > args ) {
276+ this .subtitleLocArgs .addAll (args );
277+ return this ;
278+ }
279+
212280 /**
213281 * Sets the launch image for the notification action.
214282 *
0 commit comments