@@ -34,6 +34,9 @@ public class ApsAlert {
34
34
@ Key ("title" )
35
35
private final String title ;
36
36
37
+ @ Key ("subtitle" )
38
+ private final String subtitle ;
39
+
37
40
@ Key ("body" )
38
41
private final String body ;
39
42
@@ -49,6 +52,12 @@ public class ApsAlert {
49
52
@ Key ("title-loc-args" )
50
53
private final List <String > titleLocArgs ;
51
54
55
+ @ Key ("subtitle-loc-key" )
56
+ private final String subtitleLocKey ;
57
+
58
+ @ Key ("subtitle-loc-args" )
59
+ private final List <String > subtitleLocArgs ;
60
+
52
61
@ Key ("action-loc-key" )
53
62
private final String actionLocKey ;
54
63
@@ -57,6 +66,7 @@ public class ApsAlert {
57
66
58
67
private ApsAlert (Builder builder ) {
59
68
this .title = builder .title ;
69
+ this .subtitle = builder .subtitle ;
60
70
this .body = builder .body ;
61
71
this .actionLocKey = builder .actionLocKey ;
62
72
this .locKey = builder .locKey ;
@@ -76,6 +86,14 @@ private ApsAlert(Builder builder) {
76
86
} else {
77
87
this .titleLocArgs = null ;
78
88
}
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
+ }
79
97
this .launchImage = builder .launchImage ;
80
98
}
81
99
@@ -91,11 +109,14 @@ public static Builder builder() {
91
109
public static class Builder {
92
110
93
111
private String title ;
112
+ private String subtitle ;
94
113
private String body ;
95
114
private String locKey ;
96
115
private List <String > locArgs = new ArrayList <>();
97
116
private String titleLocKey ;
98
117
private List <String > titleLocArgs = new ArrayList <>();
118
+ private String subtitleLocKey ;
119
+ private List <String > subtitleLocArgs = new ArrayList <>();
99
120
private String actionLocKey ;
100
121
private String launchImage ;
101
122
@@ -113,6 +134,17 @@ public Builder setTitle(String title) {
113
134
return this ;
114
135
}
115
136
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
+
116
148
/**
117
149
* Sets the body of the alert. When provided, overrides the body sent
118
150
* via {@link Notification}.
@@ -209,6 +241,42 @@ public Builder addAllTitleLocArgs(@NonNull List<String> args) {
209
241
return this ;
210
242
}
211
243
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
+
212
280
/**
213
281
* Sets the launch image for the notification action.
214
282
*
0 commit comments