Browse Source

Allow configuring Android led time (#1080)

Default time extended from 100 to 1000 ms
Dani Palou 9 years ago
parent
commit
327f01f9e4

+ 1 - 1
src/android/notification/Builder.java

@@ -131,7 +131,7 @@ public class Builder {
                 .setColor(options.getColor());
 
         if (ledColor != 0) {
-            builder.setLights(ledColor, 100, 100);
+            builder.setLights(ledColor, options.getLedOnTime(), options.getLedOffTime());
         }
 
         if (sound != null) {

+ 36 - 0
src/android/notification/Options.java

@@ -250,6 +250,42 @@ public class Options {
         return aRGB + 0xFF000000;
     }
 
+    /**
+     * @return
+     *      The time that the LED should be on (in milliseconds).
+     */
+    public int getLedOnTime() {
+        String timeOn = options.optString("ledOnTime", null);
+
+        if (timeOn == null) {
+            return 1000;
+        }
+
+        try {
+            return Integer.parseInt(timeOn);
+        } catch (NumberFormatException e) {
+           return 1000;
+        }
+    }
+
+    /**
+     * @return
+     *      The time that the LED should be off (in milliseconds).
+     */
+    public int getLedOffTime() {
+        String timeOff = options.optString("ledOffTime", null);
+
+        if (timeOff == null) {
+            return 1000;
+        }
+
+        try {
+            return Integer.parseInt(timeOff);
+        } catch (NumberFormatException e) {
+           return 1000;
+        }
+    }
+
     /**
      * @return
      *      The notification background color for the small icon

+ 2 - 0
www/local-notification-util.js

@@ -68,6 +68,8 @@ exports.applyPlatformSpecificOptions = function () {
         defaults.ongoing   = false;
         defaults.autoClear = true;
         defaults.led       = undefined;
+        defaults.ledOnTime = undefined;
+        defaults.ledOffTime = undefined;
         defaults.color     = undefined;
         break;
     }