Add LED light for message notifications

This commit is contained in:
schwma
2018-11-08 15:30:31 +01:00
committed by Jannis Mattheis
parent 6196626020
commit 9a1ffa91df
2 changed files with 5 additions and 0 deletions

View File

@@ -2,6 +2,7 @@ package com.github.gotify;
import android.app.NotificationChannel; import android.app.NotificationChannel;
import android.app.NotificationManager; import android.app.NotificationManager;
import android.graphics.Color;
import android.os.Build; import android.os.Build;
import androidx.annotation.RequiresApi; import androidx.annotation.RequiresApi;
import com.github.gotify.log.Log; import com.github.gotify.log.Log;
@@ -38,6 +39,8 @@ public class NotificationSupport {
Channel.MESSAGES, Channel.MESSAGES,
"Gotify messages", "Gotify messages",
NotificationManager.IMPORTANCE_HIGH); NotificationManager.IMPORTANCE_HIGH);
messages.enableLights(true);
messages.setLightColor(Color.CYAN);
notificationManager.createNotificationChannel(foreground); notificationManager.createNotificationChannel(foreground);
notificationManager.createNotificationChannel(messages); notificationManager.createNotificationChannel(messages);
} catch (Exception e) { } catch (Exception e) {

View File

@@ -6,6 +6,7 @@ import android.app.PendingIntent;
import android.app.Service; import android.app.Service;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.graphics.Color;
import android.os.Build; import android.os.Build;
import android.os.IBinder; import android.os.IBinder;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
@@ -189,6 +190,7 @@ public class WebSocketService extends Service {
.setContentText(message) .setContentText(message)
.setStyle(new NotificationCompat.BigTextStyle().bigText(message)) .setStyle(new NotificationCompat.BigTextStyle().bigText(message))
.setDefaults(Notification.DEFAULT_LIGHTS | Notification.DEFAULT_SOUND) .setDefaults(Notification.DEFAULT_LIGHTS | Notification.DEFAULT_SOUND)
.setLights(Color.CYAN, 1000, 5000)
.setContentIntent(contentIntent); .setContentIntent(contentIntent);
NotificationManager notificationManager = NotificationManager notificationManager =