Commit b03bdf08 authored by Sebastián Katzer's avatar Sebastián Katzer
Browse files

Added Android specific property `smallImage`

parent 7ae2981b
Loading
Loading
Loading
Loading
+4 −3
Changes for README.md: 4 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -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
+17 −1
Changes for src/android/Options.java: 17 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -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;
@@ -166,6 +166,22 @@ public class Options {
        return options.optInt("icon", icon);
    }

    /**
     * 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.
     */
+6 −1
Changes for src/android/Receiver.java: 6 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -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());

+1 −0
Changes for www/local-notification.js: 1 added line, 0 removed lines.
Original line number Diff line number Diff line
@@ -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;