change notifications led color
This commit is contained in:
parent
6872b36f74
commit
9b748a7b4f
|
@ -13,7 +13,6 @@ import android.content.SharedPreferences;
|
|||
import android.content.pm.ShortcutManager;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Typeface;
|
||||
import android.media.AudioAttributes;
|
||||
import android.media.Ringtone;
|
||||
|
@ -29,7 +28,6 @@ import android.text.style.StyleSpan;
|
|||
import android.util.DisplayMetrics;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.ColorInt;
|
||||
import androidx.annotation.RequiresApi;
|
||||
import androidx.core.app.NotificationCompat;
|
||||
import androidx.core.app.NotificationCompat.BigPictureStyle;
|
||||
|
@ -95,6 +93,8 @@ public class NotificationService {
|
|||
|
||||
public static final Object CATCHUP_LOCK = new Object();
|
||||
|
||||
private static final int LED_COLOR = 0xffffffff;
|
||||
|
||||
private static final long[] CALL_PATTERN = {0, 500, 300, 600};
|
||||
|
||||
private static final String MESSAGES_GROUP = "eu.siacs.conversations.messages";
|
||||
|
@ -216,7 +216,7 @@ public class NotificationService {
|
|||
NotificationManager.IMPORTANCE_HIGH);
|
||||
incomingCallsChannel.setSound(null, null);
|
||||
incomingCallsChannel.setShowBadge(false);
|
||||
incomingCallsChannel.setLightColor(getPrimaryColor());
|
||||
incomingCallsChannel.setLightColor(LED_COLOR);
|
||||
incomingCallsChannel.enableLights(true);
|
||||
incomingCallsChannel.setGroup("calls");
|
||||
incomingCallsChannel.setBypassDnd(true);
|
||||
|
@ -239,7 +239,7 @@ public class NotificationService {
|
|||
NotificationManager.IMPORTANCE_HIGH);
|
||||
missedCallsChannel.setShowBadge(true);
|
||||
missedCallsChannel.setSound(null, null);
|
||||
missedCallsChannel.setLightColor(getPrimaryColor());
|
||||
missedCallsChannel.setLightColor(LED_COLOR);
|
||||
missedCallsChannel.enableLights(true);
|
||||
missedCallsChannel.setGroup("calls");
|
||||
notificationManager.createNotificationChannel(missedCallsChannel);
|
||||
|
@ -256,7 +256,7 @@ public class NotificationService {
|
|||
.setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION)
|
||||
.setUsage(AudioAttributes.USAGE_NOTIFICATION_COMMUNICATION_INSTANT)
|
||||
.build());
|
||||
messagesChannel.setLightColor(getPrimaryColor());
|
||||
messagesChannel.setLightColor(LED_COLOR);
|
||||
final int dat = 70;
|
||||
final long[] pattern = {0, 3 * dat, dat, dat};
|
||||
messagesChannel.setVibrationPattern(pattern);
|
||||
|
@ -272,7 +272,7 @@ public class NotificationService {
|
|||
silentMessagesChannel.setDescription(
|
||||
c.getString(R.string.silent_messages_channel_description));
|
||||
silentMessagesChannel.setShowBadge(true);
|
||||
silentMessagesChannel.setLightColor(getPrimaryColor());
|
||||
silentMessagesChannel.setLightColor(LED_COLOR);
|
||||
silentMessagesChannel.enableLights(true);
|
||||
silentMessagesChannel.setGroup("chats");
|
||||
notificationManager.createNotificationChannel(silentMessagesChannel);
|
||||
|
@ -283,7 +283,7 @@ public class NotificationService {
|
|||
c.getString(R.string.title_pref_quiet_hours),
|
||||
NotificationManager.IMPORTANCE_LOW);
|
||||
quietHoursChannel.setShowBadge(true);
|
||||
quietHoursChannel.setLightColor(getPrimaryColor());
|
||||
quietHoursChannel.setLightColor(LED_COLOR);
|
||||
quietHoursChannel.enableLights(true);
|
||||
quietHoursChannel.setGroup("chats");
|
||||
quietHoursChannel.enableVibration(false);
|
||||
|
@ -831,13 +831,8 @@ public class NotificationService {
|
|||
}
|
||||
|
||||
private void setNotificationColor(final Builder mBuilder) {
|
||||
mBuilder.setColor(getPrimaryColor());
|
||||
}
|
||||
|
||||
@ColorInt
|
||||
private int getPrimaryColor() {
|
||||
Integer primaryColorOverride = ThemeHelper.getOverriddenPrimaryColor(mXmppConnectionService);
|
||||
return primaryColorOverride == null ? ContextCompat.getColor(mXmppConnectionService, R.color.green600) : primaryColorOverride;
|
||||
mBuilder.setColor(primaryColorOverride == null ? ContextCompat.getColor(mXmppConnectionService, R.color.green600) : primaryColorOverride);
|
||||
}
|
||||
|
||||
public void updateNotification() {
|
||||
|
@ -977,14 +972,14 @@ public class NotificationService {
|
|||
setNotificationColor(mBuilder);
|
||||
mBuilder.setDefaults(0);
|
||||
if (led) {
|
||||
mBuilder.setLights(getPrimaryColor(), 2000, 3000);
|
||||
mBuilder.setLights(LED_COLOR, 2000, 3000);
|
||||
}
|
||||
}
|
||||
|
||||
private void modifyIncomingCall(final Builder mBuilder) {
|
||||
mBuilder.setPriority(NotificationCompat.PRIORITY_HIGH);
|
||||
setNotificationColor(mBuilder);
|
||||
mBuilder.setLights(getPrimaryColor(), 2000, 3000);
|
||||
mBuilder.setLights(LED_COLOR, 2000, 3000);
|
||||
}
|
||||
|
||||
private Uri fixRingtoneUri(Uri uri) {
|
||||
|
@ -1109,7 +1104,7 @@ public class NotificationService {
|
|||
final Resources resources = mXmppConnectionService.getResources();
|
||||
final boolean led = preferences.getBoolean("led", resources.getBoolean(R.bool.led));
|
||||
if (led) {
|
||||
builder.setLights(getPrimaryColor(), 2000, 3000);
|
||||
builder.setLights(LED_COLOR, 2000, 3000);
|
||||
}
|
||||
builder.setPriority(NotificationCompat.PRIORITY_HIGH);
|
||||
builder.setSound(null);
|
||||
|
|
Loading…
Reference in a new issue