Sfoglia il codice sorgente

New Android specific `led:` flag

Sebastián Katzer 11 anni fa
parent
commit
215a6597b1
5 ha cambiato i file con 25 aggiunte e 1 eliminazioni
  1. 1 0
      CHANGELOG.md
  2. 8 0
      README.md
  3. 13 0
      src/android/Options.java
  4. 2 1
      src/android/Receiver.java
  5. 1 0
      www/local-notification.js

+ 1 - 0
CHANGELOG.md

@@ -4,6 +4,7 @@
 - [enhancement:] Scope parameter for `isScheduled` and `getScheduledIds`
 - [enhancement:] Callbacks for `cancel` & `cancelAll`
 - [enhancement:] `image:` accepts remote URLs and local URIs (Android)
+- [feature:] New Android specific `led:` flag.
 
 #### Version 0.7.4 (22.03.2014)
 - [bugfix:] Platform specific properties were ignored.

+ 8 - 0
README.md

@@ -74,6 +74,7 @@ More informations can be found [here][PGB_plugin].
 - [enhancement:] Scope parameter for `isScheduled` and `getScheduledIds`
 - [enhancement:] Callbacks for `cancel` & `cancelAll`
 - [enhancement:] `image:` accepts remote URLs and local URIs (Android)
+- [feature:] New Android specific `led:` flag
 
 #### Further informations
 - See [CHANGELOG.md][changelog] to get the full changelog for the plugin.
@@ -420,6 +421,13 @@ To specify a custom interval, the `repeat` property can be assigned with an numb
 window.plugin.notification.local.add({ repeat: 15 });
 ```
 
+### Change the LED color on Android devices
+The LED color can be specified through the `led` property. By default the color value is white (FFFFFF). Its possible to change that value by setting another hex code.
+
+```javascript
+window.plugin.notification.local.add({ led: 'A0FF05' });
+```
+
 
 ## Quirks
 

+ 13 - 0
src/android/Options.java

@@ -244,6 +244,19 @@ public class Options {
         return options.optString("json", "");
     }
 
+    /**
+     * @return
+     *      The notification color for LED
+     */
+   public int getColor () {
+        String hexColor = options.optString("led", "000000");
+        int aRGB        = Integer.parseInt(hexColor,16);
+
+        aRGB += 0xFF000000;
+
+        return aRGB;
+    }
+
     /**
      * Returns numerical icon Value
      *

+ 2 - 1
src/android/Receiver.java

@@ -126,7 +126,8 @@ public class Receiver extends BroadcastReceiver {
             .setSmallIcon(options.getSmallIcon())
             .setLargeIcon(options.getIcon())
             .setAutoCancel(options.getAutoCancel())
-            .setOngoing(options.getOngoing());
+            .setOngoing(options.getOngoing())
+            .setLights(options.getColor(), 500, 500);
 
         if (sound != null) {
             notification.setSound(sound);

+ 1 - 0
www/local-notification.js

@@ -95,6 +95,7 @@ LocalNotification.prototype = {
             defaults.icon       = 'icon';
             defaults.smallIcon  = null;
             defaults.ongoing    = false;
+            defaults.led        = 'FFFFFF'; /*RRGGBB*/
             defaults.sound      = 'TYPE_NOTIFICATION'; break;
         case 'iOS':
             defaults.sound      = ''; break;