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 {
/**
* Update multiple local notifications.
*
* @param updates
* Notification properties including their IDs
* @param updates Notification properties including their IDs
*/
private void update (JSONArray updates) {
for (int i = 0; i < updates.length(); i++) {
......
......@@ -116,7 +116,6 @@ public final class Builder {
return new Notification(context, options);
}
int smallIcon = options.getSmallIcon();
Uri sound = options.getSound();
Bundle extras = new Bundle();
......@@ -151,11 +150,11 @@ public final class Builder {
options.isIndeterminateProgress());
}
if (smallIcon != 0) {
builder.setSmallIcon(smallIcon);
if (options.hasLargeIcon()) {
builder.setSmallIcon(options.getSmallIcon());
builder.setLargeIcon(options.getLargeIcon());
} else {
builder.setSmallIcon(options.getIcon());
builder.setSmallIcon(options.getSmallIcon());
}
applyStyle(builder);
......
......@@ -332,26 +332,20 @@ public final class Options {
return assets.parse(options.optString("sound", null));
}
public long[] getVibrate() {
JSONArray array = options.optJSONArray("vibrate");
if (array == null)
return null;
long[] rv = new long[array.length()];
for (int i = 0; i < array.length(); i++) {
rv[i] = array.optInt(i);
}
return rv;
/**
* Icon resource ID for the local notification.
*/
public boolean hasLargeIcon () {
String icon = options.optString("icon", null);
return icon != null;
}
/**
* Icon bitmap for the local notification.
*/
Bitmap getLargeIcon() {
Uri uri = assets.parse(options.optString("icon", DEFAULT_ICON));
String icon = options.optString("icon", null);
Uri uri = assets.parse(icon);
Bitmap bmp = null;
try {
......@@ -364,18 +358,13 @@ public final class Options {
}
/**
* Icon resource ID for the local notification.
* Small icon resource ID for the local notification.
*/
public int getIcon () {
String icon = options.optString("icon", DEFAULT_ICON);
int getSmallIcon() {
String icon = options.optString("smallIcon", DEFAULT_ICON);
int resId = assets.getResId(icon);
if (resId == 0) {
resId = getSmallIcon();
}
if (resId == 0) {
resId = assets.getResId(DEFAULT_ICON);
}
......@@ -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.
*/
private boolean isWithVibration() {
......
......@@ -55,8 +55,8 @@ exports.applyPlatformSpecificOptions = function () {
defaults.group = null;
defaults.groupSummary = false;
defaults.summary = null;
defaults.icon = 'res://icon';
defaults.smallIcon = null;
defaults.icon = null;
defaults.smallIcon = 'res://icon';
defaults.sticky = false;
defaults.autoClear = true;
defaults.led = true;
......@@ -146,6 +146,10 @@ exports.convertProperties = function (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);
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