Commit b03bdf08 by Sebastián Katzer

Added Android specific property `smallImage`

parent 7ae2981b
......@@ -58,6 +58,7 @@ More informations can be found [here](https://build.phonegap.com/plugins/356).
- [enhancement:] The background callback on Android is called, even the app is not running when the notification is tapped.
- [enhancement:] Notifications are repeated more precisely.
- [feature:] Added `json` property to pass custom data through the notification.
- [enhancement:] Added Android specific property `smallImage`.
#### Version 0.6.3 (12.12.2013)
- [bugfix:] Black screen on Android.
......@@ -186,8 +187,8 @@ function foreground (id, json) {
## Platform specifics
### Notification icon on Android
By default all notifications will display the app icon. But an specific icon can be defined through the `icon` property.
### Small and large icons on Android
By default all notifications will display the app icon. But an specific icon can be defined through the `icon` and `smallIcon` properties.
```javascript
/**
* Displays the <package.name>.R.drawable.ic_launcher icon
......@@ -197,7 +198,7 @@ window.plugin.notification.local.add({ icon: 'ic_launcher' });
/**
* Displays the android.R.drawable.ic_dialog_email icon
*/
window.plugin.notification.local.add({ icon: 'ic_dialog_email' });
window.plugin.notification.local.add({ smallIcon: 'ic_dialog_email' });
```
### Notification sound on Android
......
......@@ -147,7 +147,7 @@ public class Options {
}
/**
* Gibt den Pfad zum Icon der Notification an.
* Gibt den ID Code des Bildes an.
*/
public int getIcon () {
int icon = 0;
......@@ -167,6 +167,22 @@ public class Options {
}
/**
* Gibt den ID Code des kleinen Bildes an.
*/
public int getSmallIcon () {
int resId = 0;
String iconName = options.optString("smallIcon", "");
resId = getIconValue(packageName, iconName);
if (resId == 0) {
resId = getIconValue("android", iconName);
}
return options.optInt("smallIcon", resId);
}
/**
* Gibt den Pfad zur Callback-Funktion der Notification an.
*/
public String getForeground () {
......
......@@ -36,6 +36,8 @@ import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Build;
import android.os.Bundle;
import android.text.TextUtils;
......@@ -118,12 +120,15 @@ public class Receiver extends BroadcastReceiver {
* Erstellt die Notification.
*/
private Builder buildNotification () {
Bitmap icon = BitmapFactory.decodeResource(context.getResources(), options.getIcon());
Builder notification = new Notification.Builder(context)
.setContentTitle(options.getTitle())
.setContentText(options.getMessage())
.setNumber(options.getBadge())
.setTicker(options.getTitle())
.setSmallIcon(options.getIcon())
.setSmallIcon(options.getSmallIcon())
.setLargeIcon(icon)
.setSound(options.getSound())
.setAutoCancel(options.getAutoCancel());
......
......@@ -47,6 +47,7 @@ LocalNotification.prototype = {
switch (device.platform) {
case 'Android':
defaults.icon = 'icon';
defaults.smallIcon = null;
defaults.sound = 'TYPE_NOTIFICATION'; break;
case 'iOS':
defaults.sound = ''; 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