Commit 52623f11 by Sebastián Katzer

Support for silent, group, groupSummary flags on Android

parent d9bb523c
......@@ -638,7 +638,7 @@ public class LocalNotification extends CordovaPlugin {
*
* @return "background" or "foreground"
*/
static String getApplicationState () {
static String getApplicationState() {
return isInBackground ? "background" : "foreground";
}
......
......@@ -90,10 +90,15 @@ public class Builder {
int smallIcon = options.getSmallIcon();
NotificationCompat.Builder builder;
builder = new NotificationCompat.Builder(context, "group")
if (options.isSilent()) {
return new Notification(context, options);
}
builder = new NotificationCompat.Builder(context, "channel")
.setDefaults(options.getDefaults())
.setContentTitle(options.getTitle())
.setContentText(options.getText())
.setTicker(options.getText())
.setNumber(options.getBadgeNumber())
.setAutoCancel(options.isAutoClear())
.setOngoing(options.isSticky())
......@@ -103,6 +108,8 @@ public class Builder {
.setPriority(options.getPriority())
.setShowWhen(options.getShowWhen())
.setUsesChronometer(options.isWithProgressBar())
.setGroup(options.getGroup())
.setGroupSummary(options.getGroupSummary())
.setLights(options.getLedColor(), options.getLedOn(), options.getLedOff());
if (options.isWithProgressBar()) {
......
......@@ -30,7 +30,6 @@ import org.json.JSONArray;
import org.json.JSONObject;
import java.io.IOException;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.List;
......@@ -488,6 +487,27 @@ public class Options {
}
/**
* The group for that notification.
*/
String getGroup() {
return options.optString("group", null);
}
/**
* If the group shall show a summary.
*/
boolean getGroupSummary() {
return options.optBoolean("groupSummary", false);
}
/**
* Gets the value of the silent flag.
*/
boolean isSilent() {
return options.optBoolean("silent", false);
}
/**
* Gets the raw trigger spec as provided by the user.
*/
public JSONObject getTrigger() {
......
......@@ -31,6 +31,7 @@ exports._defaults = {
badge: undefined,
data: undefined,
icon: undefined,
silent: false,
trigger: { type: 'calendar' },
actions: [],
actionGroupId: undefined,
......@@ -51,6 +52,8 @@ exports.applyPlatformSpecificOptions = function () {
switch (device.platform) {
case 'Android':
defaults.group = undefined;
defaults.groupSummary = false;
defaults.summary = undefined;
defaults.icon = 'res://icon';
defaults.smallIcon = undefined;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment