Commit 46b8f4f6 by Sebastián Katzer

Set icon property to be null by default

parent 9a6d89b5
...@@ -293,8 +293,7 @@ public class LocalNotification extends CordovaPlugin { ...@@ -293,8 +293,7 @@ public class LocalNotification extends CordovaPlugin {
/** /**
* Update multiple local notifications. * Update multiple local notifications.
* *
* @param updates * @param updates Notification properties including their IDs
* Notification properties including their IDs
*/ */
private void update (JSONArray updates) { private void update (JSONArray updates) {
for (int i = 0; i < updates.length(); i++) { for (int i = 0; i < updates.length(); i++) {
......
...@@ -116,7 +116,6 @@ public final class Builder { ...@@ -116,7 +116,6 @@ public final class Builder {
return new Notification(context, options); return new Notification(context, options);
} }
int smallIcon = options.getSmallIcon();
Uri sound = options.getSound(); Uri sound = options.getSound();
Bundle extras = new Bundle(); Bundle extras = new Bundle();
...@@ -151,11 +150,11 @@ public final class Builder { ...@@ -151,11 +150,11 @@ public final class Builder {
options.isIndeterminateProgress()); options.isIndeterminateProgress());
} }
if (smallIcon != 0) { if (options.hasLargeIcon()) {
builder.setSmallIcon(smallIcon); builder.setSmallIcon(options.getSmallIcon());
builder.setLargeIcon(options.getLargeIcon()); builder.setLargeIcon(options.getLargeIcon());
} else { } else {
builder.setSmallIcon(options.getIcon()); builder.setSmallIcon(options.getSmallIcon());
} }
applyStyle(builder); applyStyle(builder);
......
...@@ -332,27 +332,21 @@ public final class Options { ...@@ -332,27 +332,21 @@ public final class Options {
return assets.parse(options.optString("sound", null)); return assets.parse(options.optString("sound", null));
} }
public long[] getVibrate() { /**
JSONArray array = options.optJSONArray("vibrate"); * Icon resource ID for the local notification.
*/
if (array == null) public boolean hasLargeIcon () {
return null; String icon = options.optString("icon", null);
return icon != null;
long[] rv = new long[array.length()];
for (int i = 0; i < array.length(); i++) {
rv[i] = array.optInt(i);
}
return rv;
} }
/** /**
* Icon bitmap for the local notification. * Icon bitmap for the local notification.
*/ */
Bitmap getLargeIcon() { Bitmap getLargeIcon() {
Uri uri = assets.parse(options.optString("icon", DEFAULT_ICON)); String icon = options.optString("icon", null);
Bitmap bmp = null; Uri uri = assets.parse(icon);
Bitmap bmp = null;
try { try {
bmp = assets.getIconFromUri(uri); bmp = assets.getIconFromUri(uri);
...@@ -364,16 +358,11 @@ public final class Options { ...@@ -364,16 +358,11 @@ public final class Options {
} }
/** /**
* Icon resource ID for the local notification. * Small icon resource ID for the local notification.
*/ */
public int getIcon () { int getSmallIcon() {
String icon = options.optString("icon", DEFAULT_ICON); String icon = options.optString("smallIcon", DEFAULT_ICON);
int resId = assets.getResId(icon);
int resId = assets.getResId(icon);
if (resId == 0) {
resId = getSmallIcon();
}
if (resId == 0) { if (resId == 0) {
resId = assets.getResId(DEFAULT_ICON); resId = assets.getResId(DEFAULT_ICON);
...@@ -391,14 +380,6 @@ public final class Options { ...@@ -391,14 +380,6 @@ public final class Options {
} }
/** /**
* Small icon resource ID for the local notification.
*/
int getSmallIcon() {
String icon = options.optString("smallIcon", "");
return assets.getResId(icon);
}
/**
* If the phone should vibrate. * If the phone should vibrate.
*/ */
private boolean isWithVibration() { private boolean isWithVibration() {
......
...@@ -55,8 +55,8 @@ exports.applyPlatformSpecificOptions = function () { ...@@ -55,8 +55,8 @@ exports.applyPlatformSpecificOptions = function () {
defaults.group = null; defaults.group = null;
defaults.groupSummary = false; defaults.groupSummary = false;
defaults.summary = null; defaults.summary = null;
defaults.icon = 'res://icon'; defaults.icon = null;
defaults.smallIcon = null; defaults.smallIcon = 'res://icon';
defaults.sticky = false; defaults.sticky = false;
defaults.autoClear = true; defaults.autoClear = true;
defaults.led = true; defaults.led = true;
...@@ -146,6 +146,10 @@ exports.convertProperties = function (options) { ...@@ -146,6 +146,10 @@ exports.convertProperties = function (options) {
options.defaults = parseToInt('defaults', options); options.defaults = parseToInt('defaults', options);
} }
if (options.smallIcon && !options.smallIcon.match(/^res:/)) {
console.warn('Property "smallIcon" must be of kind res://...');
}
options.data = JSON.stringify(options.data); options.data = JSON.stringify(options.data);
this.convertTrigger(options); this.convertTrigger(options);
......
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