From 728768db499a883badbbc9281c3b00b4a945e164 Mon Sep 17 00:00:00 2001 From: oroce Date: Fri, 28 Oct 2016 21:31:02 +0200 Subject: [PATCH] feat: implement ongoing notification setting --- README.md | 2 +- .../java/io/neson/react/notification/Notification.java | 1 + .../neson/react/notification/NotificationAttributes.java | 8 ++++++-- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 46f0b34..7147679 100644 --- a/README.md +++ b/README.md @@ -299,7 +299,7 @@ Set a number on the notification. Not yet implemented. **ongoing (`boolean`)** -Not yet implemented. +Set the notification ongoing (like playing music), it makes the notification dismissable. **category (`string`)** Set the notification category, e.g.: `alarm`, `call`, `email`, `event`, `progress`, `reminder`, `social`. It may be used by the Android system for ranking and filtering. diff --git a/android/src/main/java/io/neson/react/notification/Notification.java b/android/src/main/java/io/neson/react/notification/Notification.java index 66a2f38..452abe2 100644 --- a/android/src/main/java/io/neson/react/notification/Notification.java +++ b/android/src/main/java/io/neson/react/notification/Notification.java @@ -126,6 +126,7 @@ public android.app.Notification build() { .setContentText(attributes.message) .setSmallIcon(context.getResources().getIdentifier(attributes.smallIcon, "mipmap", context.getPackageName())) .setAutoCancel(attributes.autoClear) + .setOngoing(attributes.ongoing) .setContentIntent(getContentIntent()); diff --git a/android/src/main/java/io/neson/react/notification/NotificationAttributes.java b/android/src/main/java/io/neson/react/notification/NotificationAttributes.java index 941288f..1a0c748 100644 --- a/android/src/main/java/io/neson/react/notification/NotificationAttributes.java +++ b/android/src/main/java/io/neson/react/notification/NotificationAttributes.java @@ -66,6 +66,7 @@ public class NotificationAttributes { public ArrayList inboxStyleLines; public String group; + public Boolean ongoing; public void loadFromMap(Map map) { WritableMap writableMap = (WritableMap) new WritableNativeMap(); @@ -89,13 +90,13 @@ public void loadFromMap(Map map) { } else if (value.getClass().equals(Boolean.class)) { writableMap.putBoolean(key, (Boolean) value); - + } else if ("inboxStyle".equals(key)) { inboxStyle = true; WritableMap inboxStyleMap = new WritableNativeMap(); - Map inboxMap = (Map) value; + Map inboxMap = (Map) value; if (inboxMap.containsKey("bigContentTitle")) { inboxStyleBigContentTitle = (String) inboxMap.get("bigContentTitle"); inboxStyleMap.putString("bigContentTitle", inboxStyleBigContentTitle); @@ -177,6 +178,8 @@ public void loadFromReadableMap(ReadableMap readableMap) { if (readableMap.hasKey("category")) category = readableMap.getString("category"); if (readableMap.hasKey("localOnly")) localOnly = readableMap.getBoolean("localOnly"); if (readableMap.hasKey("group")) group = readableMap.getString("group"); + if (readableMap.hasKey("ongoing")) ongoing = readableMap.getBoolean("ongoing"); + else ongoing = false; if (readableMap.hasKey("inboxStyle")){ inboxStyle = true; @@ -248,6 +251,7 @@ public ReadableMap asReadableMap() { if (progressEnd != null) writableMap.putInt("progressEnd", progressEnd); if (lifetime != null) writableMap.putInt("lifetime", lifetime); + if (ongoing != null) writableMap.putBoolean("ongoing", ongoing); if (inboxStyle){