Commit 5cb48c41 by Sebastián Katzer

Added color option for Android

parent 3afb5985
...@@ -4,7 +4,8 @@ ChangeLog ...@@ -4,7 +4,8 @@ ChangeLog
Please also read the [Upgrade Guide](https://github.com/katzer/cordova-plugin-local-notifications/wiki/Upgrade-Guide) for more information. Please also read the [Upgrade Guide](https://github.com/katzer/cordova-plugin-local-notifications/wiki/Upgrade-Guide) for more information.
#### Version 0.8.3 (not yet released) #### Version 0.8.3 (not yet released)
- New "quarter" intervall for iOS & Android - New `color` attribute for Android (Thanks to @Eusebius1920)
- New `quarter` intervall for iOS & Android
- Made small icon optional (Android) - Made small icon optional (Android)
- Fixed #588 crash when basename & extension can't be extracted (Android) - Fixed #588 crash when basename & extension can't be extracted (Android)
- Fixed #732 loop between update and trigger (Android) - Fixed #732 loop between update and trigger (Android)
......
...@@ -127,12 +127,17 @@ public class Builder { ...@@ -127,12 +127,17 @@ public class Builder {
.setTicker(options.getText()) .setTicker(options.getText())
.setAutoCancel(options.isAutoClear()) .setAutoCancel(options.isAutoClear())
.setOngoing(options.isOngoing()) .setOngoing(options.isOngoing())
.setColor(options.getColor())
.setLights(options.getLedColor(), 500, 500); .setLights(options.getLedColor(), 500, 500);
if (sound != null) { if (sound != null) {
builder.setSound(sound); builder.setSound(sound);
} }
if (sound != null) {
builder.setSound(sound);
}
if (smallIcon == 0) { if (smallIcon == 0) {
builder.setSmallIcon(options.getIcon()); builder.setSmallIcon(options.getIcon());
} else { } else {
......
...@@ -27,6 +27,7 @@ import android.app.AlarmManager; ...@@ -27,6 +27,7 @@ import android.app.AlarmManager;
import android.content.Context; import android.content.Context;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.net.Uri; import android.net.Uri;
import android.support.v4.app.NotificationCompat;
import org.json.JSONException; import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
...@@ -250,6 +251,23 @@ public class Options { ...@@ -250,6 +251,23 @@ public class Options {
} }
/** /**
* @return
* The notification background color for the small icon
* Returns null, if no color is given.
*/
public Integer getColor() {
String hex = options.optString("color", null);
if (hex == null) {
return NotificationCompat.COLOR_DEFAULT;
}
int aRGB = Integer.parseInt(hex, 16);
return aRGB + 0xFF000000;
}
/**
* Sound file path for the local notification. * Sound file path for the local notification.
*/ */
public Uri getSoundUri() { public Uri getSoundUri() {
......
...@@ -65,6 +65,7 @@ exports.applyPlatformSpecificOptions = function () { ...@@ -65,6 +65,7 @@ exports.applyPlatformSpecificOptions = function () {
defaults.ongoing = false; defaults.ongoing = false;
defaults.autoClear = true; defaults.autoClear = true;
defaults.led = 'FFFFFF'; defaults.led = 'FFFFFF';
defaults.color = undefined;
break; break;
} }
......
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