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 ...@@ -5,6 +5,7 @@ Please also read the [Upgrade Guide](https://github.com/katzer/cordova-plugin-lo
#### Version 0.8.3 (not yet released) #### Version 0.8.3 (not yet released)
- New "quarter" intervall for iOS & Android - New "quarter" intervall for iOS & 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)
- Fixed #710 crash due to >500 notifications (Android) - Fixed #710 crash due to >500 notifications (Android)
......
...@@ -116,6 +116,7 @@ public class Builder { ...@@ -116,6 +116,7 @@ public class Builder {
*/ */
public Notification build() { public Notification build() {
Uri sound = options.getSoundUri(); Uri sound = options.getSoundUri();
int smallIcon = options.getSmallIcon();
NotificationCompat.Builder builder; NotificationCompat.Builder builder;
builder = new NotificationCompat.Builder(context) builder = new NotificationCompat.Builder(context)
...@@ -124,8 +125,6 @@ public class Builder { ...@@ -124,8 +125,6 @@ public class Builder {
.setContentText(options.getText()) .setContentText(options.getText())
.setNumber(options.getBadgeNumber()) .setNumber(options.getBadgeNumber())
.setTicker(options.getText()) .setTicker(options.getText())
.setSmallIcon(options.getSmallIcon())
.setLargeIcon(options.getIconBitmap())
.setAutoCancel(options.isAutoClear()) .setAutoCancel(options.isAutoClear())
.setOngoing(options.isOngoing()) .setOngoing(options.isOngoing())
.setLights(options.getLedColor(), 500, 500); .setLights(options.getLedColor(), 500, 500);
...@@ -134,6 +133,13 @@ public class Builder { ...@@ -134,6 +133,13 @@ public class Builder {
builder.setSound(sound); builder.setSound(sound);
} }
if (smallIcon == 0) {
builder.setSmallIcon(options.getIcon());
} else {
builder.setSmallIcon(options.getSmallIcon());
builder.setLargeIcon(options.getIconBitmap());
}
applyDeleteReceiver(builder); applyDeleteReceiver(builder);
applyContentReceiver(builder); applyContentReceiver(builder);
......
...@@ -282,21 +282,34 @@ public class Options { ...@@ -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 () { public int getIcon () {
String icon = options.optString("smallIcon", ""); String icon = options.optString("icon", "");
int resId = assets.getResIdForDrawable(icon); int resId = assets.getResIdForDrawable(icon);
if (resId == 0) { if (resId == 0) {
resId = android.R.drawable.screen_background_dark; resId = getSmallIcon();
}
if (resId == 0) {
resId = android.R.drawable.ic_popup_reminder;
} }
return resId; 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. * JSON object as string.
*/ */
public String toString() { public String toString() {
......
...@@ -60,8 +60,8 @@ exports.applyPlatformSpecificOptions = function () { ...@@ -60,8 +60,8 @@ exports.applyPlatformSpecificOptions = function () {
switch (device.platform) { switch (device.platform) {
case 'Android': case 'Android':
defaults.icon = 'res://icon'; defaults.icon = 'res://ic_popup_reminder';
defaults.smallIcon = 'res://ic_popup_reminder'; defaults.smallIcon = undefined;
defaults.ongoing = false; defaults.ongoing = false;
defaults.autoClear = true; defaults.autoClear = true;
defaults.led = 'FFFFFF'; 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