Commit 4f9f3d06 by Sebastián Katzer

Made small icon on Android optional

parent 34110162
......@@ -5,6 +5,7 @@ Please also read the [Upgrade Guide](https://github.com/katzer/cordova-plugin-lo
#### Version 0.8.3 (not yet released)
- New "quarter" intervall for iOS & Android
- Made small icon optional (Android)
- Fixed #588 crash when basename & extension can't be extracted (Android)
- Fixed #732 loop between update and trigger (Android)
- Fixed #710 crash due to >500 notifications (Android)
......
......@@ -115,7 +115,8 @@ public class Builder {
* Creates the notification with all its options passed through JS.
*/
public Notification build() {
Uri sound = options.getSoundUri();
Uri sound = options.getSoundUri();
int smallIcon = options.getSmallIcon();
NotificationCompat.Builder builder;
builder = new NotificationCompat.Builder(context)
......@@ -124,8 +125,6 @@ public class Builder {
.setContentText(options.getText())
.setNumber(options.getBadgeNumber())
.setTicker(options.getText())
.setSmallIcon(options.getSmallIcon())
.setLargeIcon(options.getIconBitmap())
.setAutoCancel(options.isAutoClear())
.setOngoing(options.isOngoing())
.setLights(options.getLedColor(), 500, 500);
......@@ -134,6 +133,13 @@ public class Builder {
builder.setSound(sound);
}
if (smallIcon == 0) {
builder.setSmallIcon(options.getIcon());
} else {
builder.setSmallIcon(options.getSmallIcon());
builder.setLargeIcon(options.getIconBitmap());
}
applyDeleteReceiver(builder);
applyContentReceiver(builder);
......
......@@ -131,7 +131,7 @@ public class Options {
if (options.has("iconUri"))
return;
Uri iconUri = assets.parse(options.optString("icon", "icon"));
Uri iconUri = assets.parse(options.optString("icon", "icon"));
Uri soundUri = assets.parseSound(options.optString("sound", null));
try {
......@@ -282,21 +282,34 @@ public class Options {
}
/**
* Small icon resource ID for the local notification.
* Icon resource ID for the local notification.
*/
public int getSmallIcon () {
String icon = options.optString("smallIcon", "");
public int getIcon () {
String icon = options.optString("icon", "");
int resId = assets.getResIdForDrawable(icon);
if (resId == 0) {
resId = android.R.drawable.screen_background_dark;
resId = getSmallIcon();
}
if (resId == 0) {
resId = android.R.drawable.ic_popup_reminder;
}
return resId;
}
/**
* Small icon resource ID for the local notification.
*/
public int getSmallIcon () {
String icon = options.optString("smallIcon", "");
return assets.getResIdForDrawable(icon);
}
/**
* JSON object as string.
*/
public String toString() {
......
......@@ -60,8 +60,8 @@ exports.applyPlatformSpecificOptions = function () {
switch (device.platform) {
case 'Android':
defaults.icon = 'res://icon';
defaults.smallIcon = 'res://ic_popup_reminder';
defaults.icon = 'res://ic_popup_reminder';
defaults.smallIcon = undefined;
defaults.ongoing = false;
defaults.autoClear = true;
defaults.led = 'FFFFFF';
......
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