Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ public class AndroidNotification {
@Key("notification_count")
private final Integer notificationCount;

@Key("proxy")
private final String proxy;

private static final Map<Priority, String> PRIORITY_MAP =
ImmutableMap.<Priority, String>builder()
.put(Priority.MIN, "PRIORITY_MIN")
Expand Down Expand Up @@ -179,6 +182,11 @@ private AndroidNotification(Builder builder) {
checkArgument(builder.notificationCount >= 0,
"notificationCount if specified must be zero or positive valued");
}
if (builder.proxy != null) {
this.proxy = builder.proxy.name();
} else {
this.proxy = null;
}
this.notificationCount = builder.notificationCount;
}

Expand All @@ -194,13 +202,20 @@ public String toString() {
return PRIORITY_MAP.get(this);
}
}

public enum Visibility {
PRIVATE,
PUBLIC,
SECRET,
}

public enum Proxy {
PROXY_UNSPECIFIED,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's remove PROXY_UNSPECIFIED and have the absence of the field be enough to show it's not specified.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PROXY_UNSPECIFIED is removed.

Thanks for the feedback.

ALLOW,
DENY,
IF_PRIORITY_LOWERED
}

/**
* Creates a new {@link AndroidNotification.Builder}.
*
Expand Down Expand Up @@ -237,6 +252,7 @@ public static class Builder {
private LightSettings lightSettings;
private Boolean defaultLightSettings;
private Visibility visibility;
private Proxy proxy;

private Builder() {}

Expand Down Expand Up @@ -602,6 +618,19 @@ public Builder setNotificationCount(int notificationCount) {
return this;
}

/**
* Sets the proxy of this notification.
*
* @param proxy The proxy value. one of the values in
* {PROXY_UNSPECIFIED, ALLOW, DENY, IF_PRIORITY_LOWERED}
*
* @return This builder.
*/
public Builder setProxy(Proxy proxy) {
this.proxy = proxy;
return this;
}

/**
* Creates a new {@link AndroidNotification} instance from the parameters set on this builder.
*
Expand Down
2 changes: 2 additions & 0 deletions src/test/java/com/google/firebase/messaging/MessageTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -890,6 +890,7 @@ public void testExtendedAndroidNotificationParameters() throws IOException {
.setDefaultLightSettings(false)
.setVisibility(AndroidNotification.Visibility.PUBLIC)
.setNotificationCount(10)
.setProxy(AndroidNotification.Proxy.DENY)
.build())
.build())
.setTopic("test-topic")
Expand Down Expand Up @@ -923,6 +924,7 @@ public void testExtendedAndroidNotificationParameters() throws IOException {
.put("default_light_settings", false)
.put("visibility", "public")
.put("notification_count", new BigDecimal(10))
.put("proxy", "DENY")
.build())
.build();
assertJsonEquals(ImmutableMap.of(
Expand Down
Loading