Skip to content

Commit 327f01f

Browse files
dpaloukatzer
authored andcommitted
Allow configuring Android led time (katzer#1080)
Default time extended from 100 to 1000 ms
1 parent 366557f commit 327f01f

File tree

3 files changed

+39
-1
lines changed

3 files changed

+39
-1
lines changed

src/android/notification/Builder.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ public Notification build() {
131131
.setColor(options.getColor());
132132

133133
if (ledColor != 0) {
134-
builder.setLights(ledColor, 100, 100);
134+
builder.setLights(ledColor, options.getLedOnTime(), options.getLedOffTime());
135135
}
136136

137137
if (sound != null) {

src/android/notification/Options.java

+36
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,42 @@ public int getLedColor() {
250250
return aRGB + 0xFF000000;
251251
}
252252

253+
/**
254+
* @return
255+
* The time that the LED should be on (in milliseconds).
256+
*/
257+
public int getLedOnTime() {
258+
String timeOn = options.optString("ledOnTime", null);
259+
260+
if (timeOn == null) {
261+
return 1000;
262+
}
263+
264+
try {
265+
return Integer.parseInt(timeOn);
266+
} catch (NumberFormatException e) {
267+
return 1000;
268+
}
269+
}
270+
271+
/**
272+
* @return
273+
* The time that the LED should be off (in milliseconds).
274+
*/
275+
public int getLedOffTime() {
276+
String timeOff = options.optString("ledOffTime", null);
277+
278+
if (timeOff == null) {
279+
return 1000;
280+
}
281+
282+
try {
283+
return Integer.parseInt(timeOff);
284+
} catch (NumberFormatException e) {
285+
return 1000;
286+
}
287+
}
288+
253289
/**
254290
* @return
255291
* The notification background color for the small icon

www/local-notification-util.js

+2
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ exports.applyPlatformSpecificOptions = function () {
6868
defaults.ongoing = false;
6969
defaults.autoClear = true;
7070
defaults.led = undefined;
71+
defaults.ledOnTime = undefined;
72+
defaults.ledOffTime = undefined;
7173
defaults.color = undefined;
7274
break;
7375
}

0 commit comments

Comments
 (0)